Realtek Vendor Driver
Realtek do publish source code for their vendor drivers. They even have some bits to suggest they have supported it in the past on FreeBSD.
Overview
The Realtek vendor driver consists of a large part of an 802.11 stack, driver, transport and HAL for hardware access (PHY, MAC, RF, etc.) Amusingly, everything needed to have a single driver support all of their PCIe/USB devices is available - indeed there's also code for other chipsets in the HAL and core driver! - however they ship a different driver tree with different core changes for each chipset.
On Linux, the Realtek driver exports an nl80211/cfg80211 API, rather than tie into mac80211.
Structure
The top-level structure is as follows.
- core/ - the core 802.11 layer, shared realtek driver infrastructure to drive the hardware and firmware
- hal/ - the bulk of the chipset hardware abstraction and transport layer (PCIe, USB)
- include/ - all of the include files for the driver - HAL, 802.11, transport, chipset register definitions, descriptor definitions, firmware message formats
- os_dep/ - the operating system specific components
Specific Deep Dives
(TBD - I'm listing what I'd like to cover here)
- firmware init/setup
- RF/BB/PHY setup
- MAC setup
- Calibration routines
- Transmit
- Receive
- Channel Change
- RX filtering
- Association/Disassociation
- Rate Control
TX power configuration (eg PHY_SetTxPowerIndex_8812A)
802.11 rate -> rate indexes (used in registers, tx power setup, rx rate, tx rate, etc) (include/hal_com.h)
- Encryption/Decryption
Links
Realtek USB 11ac and 11ax chipset drivers for Linux - https://github.com/morrownr/USB-WiFi?tab=readme-ov-file
Realtek USB 11ac and later chipset info / driver links - https://github.com/morrownr/USB-WiFi/blob/main/home/USB_WiFi_Adapter_out-of-kernel_drivers_for_Linux.md
RTL8812AU Vendor Driver - https://github.com/morrownr/8812au-20210820