Adding In-Tree Kernel Modules to RHEL/CentOS
Red Hat Enterprise Linux and the closely associated CentOS Stream 9 remove a lot of legacy kernel modules from their kernels. This seems to also include removing sources from their distributed kernels.
I wanted to add the scsi/bfa driver to support Brocade Fibre Channel adapters, this is mainlined but not part of the RHEL kernel sources.
To actually use a Brocade FC adapter you also need the bfa-firmware package, which can be found in the Fedora repos (just download the RPM and install directly, it's not getting any updates).
DKMS is the de facto tool to add kernel drivers to your Linux, this tool will automatically re-compile and install any out-of-tree kernel drivers you add. Unfortunately the documentation for adding something that's already part of the Linux kernel but was left out intentionally is less documented.
The CentOS Wiki has good documentation on usage https://wiki.centos.org/HowTos/BuildingKernelModules
I installed kernel-devel and kernel-sources packages, and the other requirements for compilation as defined in various wikis.
I then downloaded the matching kernel base version from kernel.org, in this case 5.14.19, and extracted it.
To add my drivers/scsi/bfa module, I made a folder /usr/src/bfa-5.14 and copied the contents of the kernel source drivers/scsi/bfa folder to it.
I then made a dkms.conf file in that folder:
There is a problem with the module Makefile, which I fixed manually:
obj-$(CONFIG_SCSI_BFA_FC) := bfa.o
Should be replaced with:
obj-m := bfa.o
This is since the Makefile is conditionally compiled based on the kernel .config, which doesn't include this module. You can also build by passing CONFIG_SCSI_BFA_FC=m to make, but adding this to the dkms.conf seemed daunting since I would have had to define the entire make-command from first principles.
dkms add -m bfa -v 5.14
dkms build -m bfa -v 5.14
dkms install -m bfa -v 5.14
This then installed and compiled successfully, and I observed that the module was recompiled automatically by yum when a new kernel release was installed.
Now I haven't actually tested this module, since I'm still waiting on the Brocade hardware, but the module is definitely compiled and plumbed up!
Update! It works, so if anyone needs to get a Brocade 400/800 series (e.g. 815, 825) FC HBA working on RHEL/CentOS, these are the exact instructions.
Use the open source LTFS project to talk to tapes.