简体   繁体   English

将PCIe驱动程序从Linux移植到FreeBSD

[英]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. 我在Linux上编写了一个相当大的PCIe驱动程序,现在我需要在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. 我还不知道BSD版本,但我认为在这一点上它是无关紧要的,因为我想了解一般在移植过程中必须修改哪些主要项目。

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. 好处是驱动程序被分区为独立于操作系统的“库”层(OSI)和操作系统,因此它已经有一个“框架”允许将其移植到其他操作系统上,我希望大部分工作都是专注于OSI方面。 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) init代码,即将驱动程序“插入”系统的特定于操作系统的代码(类似于Linux中的init_module,cleanup_module)
  2. code registering driver in a PCI core subsystem of the kernel 代码在内核的PCI核心子系统中注册驱动程序
  3. character driver registration code 4) DMA operations 字符驱动程序注册码4)DMA操作

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). 此驱动程序是一个进行硬件加密的设备,因此它是卸载设备(来自NIC的入口数据包正常进入系统,然后转移到设备)。

If there are useful web links to description of BSD drivers development/porting (similar to LDD), I'd happily accept it :) 如果有有用的Web链接来描述BSD驱动程序开发/移植(类似于LDD),我很乐意接受它:)

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. 在2011年,Jeff Roberson(以及后来的Mellanox)添加了一些垫片来简化移植Linux驱动程序,这使得大部分代码可以按原样使用,当他将Linux InfiniBand驱动程序移植到FreeBSD时。 So, assuming I am some newcomer from Linux driver development world, I'd start by looking at: 所以,假设我是Linux驱动程序开发世界的新手,我首先看一下:

https://svnweb.freebsd.org/base/head/sys/ofed/include/linux/ 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. 在哪里可以找到许多必需的Linux驱动程序API及其FreeBSD本机对应物的实现。

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. 如果您希望从头开始,我认为FreeBSD架构手册将是一个有用的起点。

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. 此外,还有Kirk McKusick,Robert Watson和George Neville-Neil的书,题为“FreeBSD操作系统的设计和实现”,此时的最新版本是第2版,第8章是详细的设备驱动程序。

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. 大多数设备驱动程序只是硬件操作的包装器以适应OS接口,因此如今,分层良好的驱动程序应该相对容易移植。

If you have questions, or is a vendor of hardware, you can also join various FreeBSD mailing lists (freebsd-drivers@, etc.). 如果您有疑问,或者是硬件供应商,您还可以加入各种FreeBSD邮件列表(freebsd-drivers @等)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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