LinuxKPI is a small compatibility layer that allows Linux drivers to run in a FreeBSD environment with minor modification. You can find the LinuxKPI source in the FreeBSD kernel under sys/compat/linuxkpi. A quick look at the code reveals that the kernel programming interface (KPI) is simply a collection of Linux headers and source files that map Linux-exclusive functions to FreeBSD equivalents.
FreeBSD relies on LinuxKPI to power essential desktop features like graphics drivers and wireless networking. The drm-kmod package includes Linux drivers for AMD/Intel graphics and is able to compile and run smoothly on FreeBSD using LinuxKPI. Intel wireless networking through iwlwifi is also functional and is in FreeBSD base thanks to Bjoern Zeeb.
It should be noted that there is a distinction between Linuxulator (Linux Emulation) and LinuxKPI. Both subsystems exist to support Linux compatibility, but LinuxKPI focuses on providing a programming interface for kernel drivers, while Linuxulator runs unmodified Linux userspace binaries.
LinuxKPI does not officially target compatibility with any specific Linux kernel version. Instead, subsystems that use LinuxKPI often declare targets. For example, the drm-kmod meta-port encompasses many DRM targets and automatically serves a version based on the recommendation of the FreeBSDDesktop team.
Linux development occurs rapidly, so LinuxKPI is always receiving changes to keep up.
Due to the nature of Linux's GPLv2 licensing, FreeBSD developers cannot derive code directly from Linux source. Instead, manual pages serve as the primary source of reference for development specifications.
LinuxKPI is intended to be used in Linux kernel drivers, so the standard FreeBSD kernel debugging procedures are recommended.
A deeper dive into LinuxKPI source proves that Linux --> FreeBSD translation is not easy. Even though LinuxKPI enables working drivers, there exist FreeBSD-specific bugs and missing features as a result of LinuxKPI's incomplete, and sometimes incorrect, translation.
Create a Phabricator review with tag LinuxKPI for bug fixes.