简体   繁体   中英

Porting PCIe driver from Linux to FreeBSD

I have a fairly large PCIe driver written on/for Linux, now I need to port it on FreeBSD. I don't yet know the BSD version, but I think at this point it's irrelevant, as I'd like to understand in general what major items will have to be modified during the porting efforts.

The good thing is that the driver is partitioned into OS independent "library" layer (OSI) and OS dependent, so it already has a "framework" permitting to port it on other OS-es, and I hope most of the efforts will be focused on OSI side. So far I see the following big chunks of work:

  1. init code, ie the OS-specific code that "plugs" the driver into system (similar to what init_module, cleanup_module does in Linux)
  2. code registering driver in a PCI core subsystem of the kernel
  3. character driver registration code 4) DMA operations

What else should I be paying attention to? This driver is a device doing hardware encryption, so it is offload device (ingress packets from NIC enter system normally and then diverted to the device).

If there are useful web links to description of BSD drivers development/porting (similar to LDD), I'd happily accept it :)

In 2011, Jeff Roberson (and later Mellanox) added some shims to ease porting Linux drivers, which makes most of the code be used as-is, when he ported the Linux InfiniBand drivers to FreeBSD. So, assuming I am some newcomer from Linux driver development world, I'd start by looking at:

https://svnweb.freebsd.org/base/head/sys/ofed/include/linux/

Where you would find implementations of many required Linux driver API and their FreeBSD native counterpart.

There is another quickstart document by John-Mark, here , helpful for those who are already familiar with driver writing.

If you would prefer starting from the beginning, I think the FreeBSD Architecture Handbook would be an useful start point.

Additionally, there is a book by Kirk McKusick, Robert Watson and George Neville-Neil, titled "The Design and Implementation of the FreeBSD Operating System", the latest version at this time is 2nd edition, and the chapter 8 detailed device drivers.

Most device drivers are merely wrappers of hardware operation to fit OS interfaces, so a well layered driver should be relatively easy to port nowadays.

If you have questions, or is a vendor of hardware, you can also join various FreeBSD mailing lists (freebsd-drivers@, etc.).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM