# morrownr/88x2bu-20210702 architecture

> Architecture diagram of the GitHub repository morrownr/88x2bu-20210702, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/morrownr/88x2bu-20210702
- Repository: https://github.com/morrownr/88x2bu-20210702

## Overview

This repository is an out-of-tree Linux USB WiFi driver for Realtek RTL8812BU/RTL8822BU adapters. Its principal workflow is to expose wireless controls to Linux, manage station/AP/P2P and related link features, then transmit and receive WiFi traffic through the chipset and USB interface. Separate subsystems provide security, mesh, monitoring, coexistence, and radio management. The graph combines README-described capabilities with sampled source and the generated source index; many runtime call paths were not shown, so uncertain links are dashed.

Main entry points: [`core/rtw_mlme.c`](https://github.com/morrownr/88x2bu-20210702/blob/main/core/rtw_mlme.c) (Link management), [`hal/rtl8822b/rtl8822b_ops.c`](https://github.com/morrownr/88x2bu-20210702/blob/main/hal/rtl8822b/rtl8822b_ops.c) (Chipset operations), [`hal/halmac/halmac_88xx/halmac_common_88xx.c`](https://github.com/morrownr/88x2bu-20210702/blob/main/hal/halmac/halmac_88xx/halmac_common_88xx.c) (HALMAC control), [`hal/phydm/phydm.c`](https://github.com/morrownr/88x2bu-20210702/blob/main/hal/phydm/phydm.c) (PHYDM framework)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_linux["Linux Wireless Interface"]
  node_cfg80211["Cfg80211 interface<br/>[ioctl_cfg80211.c]"]
  node_legacy_ioctl["Legacy ioctl controls<br/>[ioctl_linux.c]"]
  node_os_lifecycle["Device lifecycle<br/>[os_intfs.c]"]
end

subgraph group_wifi["WiFi Protocol"]
  node_mlme["Link management<br/>[rtw_mlme.c]"]
  node_mlme_ext["802.11 management<br/>[rtw_mlme_ext.c]"]
  node_ap["Access point<br/>[rtw_ap.c]"]
  node_p2p["WiFi Direct<br/>[rtw_p2p.c]"]
  node_tx["Packet transmit<br/>[rtw_xmit.c]"]
  node_rx["Packet receive<br/>[rtw_recv.c]"]
  node_wifi_defs["WiFi definitions<br/>[wifi.h]"]
end

subgraph group_hardware["Chipset and USB"]
  node_efuse["Efuse configuration<br/>[rtw_efuse.c]"]
  node_hal["Chipset operations<br/>[rtl8822b_ops.c]"]
  node_halmac["HALMAC control"]
  node_usb["USB transport<br/>[hal_usb.c]"]
  node_usb_chip["RTL8822BU transport<br/>[rtl8822bu_xmit.c]"]
  node_hal_com["Common hardware config<br/>[hal_com.c]"]
  node_halmac_api["HALMAC API<br/>[halmac_api.h]"]
  node_regdefs["Chip register definitions<br/>[halmac_reg2.h]"]
  node_hal_defs["HAL data and commands<br/>[hal_data.h]"]
  node_chip_reg["Chip-specific register maps<br/>[halmac_reg_8822b.h]"]
end

subgraph group_radio["Radio Management"]
  node_phy["PHY management<br/>[phydm_antdiv.c]"]
  node_rf["RF calibration<br/>[halrf_iqk_8822b.c]"]
  node_btcoex["Bluetooth coexistence<br/>[halbtc8822b2ant.c]"]
  node_phydm_core["PHYDM framework<br/>[phydm.c]"]
  node_phydm_defs["PHYDM interfaces<br/>[phydm_precomp.h]"]
  node_coex_api["Coexistence interfaces<br/>[halbtcoutsrc.h]"]
end

subgraph group_features["Security and Features"]
  node_security["WiFi security<br/>[rtw_security.c]"]
  node_crypto["Crypto primitives<br/>[aes-internal.c]"]
  node_mesh["Mesh routing<br/>[rtw_mesh.c]"]
  node_monitor["Monitor radiotap<br/>[rtw_radiotap.c]"]
end

node_user(("Linux wireless user"))

node_user -.->|"configures"| node_cfg80211
node_user -.->|"controls"| node_legacy_ioctl
node_cfg80211 -.->|"requests link"| node_mlme
node_legacy_ioctl -.->|"controls link"| node_mlme
node_mlme -.->|"manages protocol"| node_mlme_ext
node_mlme -.->|"supports AP mode"| node_ap
node_mlme -.->|"supports P2P"| node_p2p
node_mlme -.->|"uses data path"| node_tx
node_tx -.->|"transmits packets"| node_usb_chip
node_usb_chip -.->|"uses USB transport"| node_usb
node_usb -.->|"receives packets"| node_rx
node_rx -.->|"supports monitor"| node_monitor
node_security -.->|"uses primitives"| node_crypto
node_mlme -.->|"supports protected links"| node_security
node_mlme -.->|"supports mesh"| node_mesh
node_efuse -->|"reads chipset data"| node_hal
node_hal_com -->|"calls HALMAC"| node_halmac
node_hal -.->|"uses HALMAC interface"| node_halmac
node_halmac -.->|"implements API"| node_halmac_api
node_halmac -.->|"uses registers"| node_regdefs
node_hal -.->|"uses HAL data"| node_hal_defs
node_hal -.->|"uses chip registers"| node_chip_reg
node_phydm_core -.->|"uses interfaces"| node_phydm_defs
node_phy -.->|"uses PHYDM"| node_phydm_core
node_rf -.->|"provides RF control"| node_phydm_core
node_btcoex -.->|"uses coexistence API"| node_coex_api
node_mlme_ext -.->|"uses WiFi definitions"| node_wifi_defs

click node_cfg80211 "https://github.com/morrownr/88x2bu-20210702/blob/main/os_dep/linux/ioctl_cfg80211.c"
click node_legacy_ioctl "https://github.com/morrownr/88x2bu-20210702/blob/main/os_dep/linux/ioctl_linux.c"
click node_os_lifecycle "https://github.com/morrownr/88x2bu-20210702/blob/main/os_dep/linux/os_intfs.c"
click node_mlme "https://github.com/morrownr/88x2bu-20210702/blob/main/core/rtw_mlme.c"
click node_mlme_ext "https://github.com/morrownr/88x2bu-20210702/blob/main/core/rtw_mlme_ext.c"
click node_ap "https://github.com/morrownr/88x2bu-20210702/blob/main/core/rtw_ap.c"
click node_p2p "https://github.com/morrownr/88x2bu-20210702/blob/main/core/rtw_p2p.c"
click node_tx "https://github.com/morrownr/88x2bu-20210702/blob/main/core/rtw_xmit.c"
click node_rx "https://github.com/morrownr/88x2bu-20210702/blob/main/core/rtw_recv.c"
click node_security "https://github.com/morrownr/88x2bu-20210702/blob/main/core/rtw_security.c"
click node_crypto "https://github.com/morrownr/88x2bu-20210702/blob/main/core/crypto/aes-internal.c"
click node_mesh "https://github.com/morrownr/88x2bu-20210702/blob/main/core/mesh/rtw_mesh.c"
click node_monitor "https://github.com/morrownr/88x2bu-20210702/blob/main/core/monitor/rtw_radiotap.c"
click node_efuse "https://github.com/morrownr/88x2bu-20210702/blob/main/core/efuse/rtw_efuse.c"
click node_hal "https://github.com/morrownr/88x2bu-20210702/blob/main/hal/rtl8822b/rtl8822b_ops.c"
click node_halmac "https://github.com/morrownr/88x2bu-20210702/blob/main/hal/halmac/halmac_88xx/halmac_common_88xx.c"
click node_usb "https://github.com/morrownr/88x2bu-20210702/blob/main/hal/hal_hci/hal_usb.c"
click node_usb_chip "https://github.com/morrownr/88x2bu-20210702/blob/main/hal/rtl8822b/usb/rtl8822bu_xmit.c"
click node_phy "https://github.com/morrownr/88x2bu-20210702/blob/main/hal/phydm/phydm_antdiv.c"
click node_rf "https://github.com/morrownr/88x2bu-20210702/blob/main/hal/phydm/halrf/rtl8822b/halrf_iqk_8822b.c"
click node_btcoex "https://github.com/morrownr/88x2bu-20210702/blob/main/hal/btc/halbtc8822b2ant.c"
click node_hal_com "https://github.com/morrownr/88x2bu-20210702/blob/main/hal/hal_com.c"
click node_halmac_api "https://github.com/morrownr/88x2bu-20210702/blob/main/hal/halmac/halmac_api.h"
click node_regdefs "https://github.com/morrownr/88x2bu-20210702/blob/main/hal/halmac/halmac_reg2.h"
click node_phydm_core "https://github.com/morrownr/88x2bu-20210702/blob/main/hal/phydm/phydm.c"
click node_phydm_defs "https://github.com/morrownr/88x2bu-20210702/blob/main/hal/phydm/phydm_precomp.h"
click node_hal_defs "https://github.com/morrownr/88x2bu-20210702/blob/main/include/hal_data.h"
click node_wifi_defs "https://github.com/morrownr/88x2bu-20210702/blob/main/include/wifi.h"
click node_coex_api "https://github.com/morrownr/88x2bu-20210702/blob/main/hal/btc/halbtcoutsrc.h"
click node_chip_reg "https://github.com/morrownr/88x2bu-20210702/blob/main/hal/halmac/halmac_reg_8822b.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cfg80211,node_legacy_ioctl,node_os_lifecycle,node_user toneBlue
class node_mlme,node_mlme_ext,node_ap,node_p2p,node_tx,node_rx,node_wifi_defs toneAmber
class node_efuse,node_hal,node_halmac,node_usb,node_usb_chip,node_hal_com,node_halmac_api,node_regdefs,node_hal_defs,node_chip_reg toneMint
class node_phy,node_rf,node_btcoex,node_phydm_core,node_phydm_defs,node_coex_api toneRose
class node_security,node_crypto,node_mesh,node_monitor toneIndigo
```

## Components

### Linux Wireless Interface

- [Cfg80211 interface](https://github.com/morrownr/88x2bu-20210702/blob/main/os_dep/linux/ioctl_cfg80211.c): `os_dep/linux/ioctl_cfg80211.c`
- [Legacy ioctl controls](https://github.com/morrownr/88x2bu-20210702/blob/main/os_dep/linux/ioctl_linux.c): `os_dep/linux/ioctl_linux.c`
- [Device lifecycle](https://github.com/morrownr/88x2bu-20210702/blob/main/os_dep/linux/os_intfs.c): `os_dep/linux/os_intfs.c`

### WiFi Protocol

- [Link management](https://github.com/morrownr/88x2bu-20210702/blob/main/core/rtw_mlme.c): `core/rtw_mlme.c`
- [802.11 management](https://github.com/morrownr/88x2bu-20210702/blob/main/core/rtw_mlme_ext.c): `core/rtw_mlme_ext.c`
- [Access point](https://github.com/morrownr/88x2bu-20210702/blob/main/core/rtw_ap.c): `core/rtw_ap.c`
- [WiFi Direct](https://github.com/morrownr/88x2bu-20210702/blob/main/core/rtw_p2p.c): `core/rtw_p2p.c`
- [Packet transmit](https://github.com/morrownr/88x2bu-20210702/blob/main/core/rtw_xmit.c): `core/rtw_xmit.c`
- [Packet receive](https://github.com/morrownr/88x2bu-20210702/blob/main/core/rtw_recv.c): `core/rtw_recv.c`
- [WiFi definitions](https://github.com/morrownr/88x2bu-20210702/blob/main/include/wifi.h): `include/wifi.h`

### Chipset and USB

- [Efuse configuration](https://github.com/morrownr/88x2bu-20210702/blob/main/core/efuse/rtw_efuse.c): `core/efuse/rtw_efuse.c`
- [Chipset operations](https://github.com/morrownr/88x2bu-20210702/blob/main/hal/rtl8822b/rtl8822b_ops.c): `hal/rtl8822b/rtl8822b_ops.c`
- [HALMAC control](https://github.com/morrownr/88x2bu-20210702/blob/main/hal/halmac/halmac_88xx/halmac_common_88xx.c): `hal/halmac/halmac_88xx/halmac_common_88xx.c`
- [USB transport](https://github.com/morrownr/88x2bu-20210702/blob/main/hal/hal_hci/hal_usb.c): `hal/hal_hci/hal_usb.c`
- [RTL8822BU transport](https://github.com/morrownr/88x2bu-20210702/blob/main/hal/rtl8822b/usb/rtl8822bu_xmit.c): `hal/rtl8822b/usb/rtl8822bu_xmit.c`
- [Common hardware config](https://github.com/morrownr/88x2bu-20210702/blob/main/hal/hal_com.c): `hal/hal_com.c`
- [HALMAC API](https://github.com/morrownr/88x2bu-20210702/blob/main/hal/halmac/halmac_api.h): `hal/halmac/halmac_api.h`
- [Chip register definitions](https://github.com/morrownr/88x2bu-20210702/blob/main/hal/halmac/halmac_reg2.h): `hal/halmac/halmac_reg2.h`
- [HAL data and commands](https://github.com/morrownr/88x2bu-20210702/blob/main/include/hal_data.h): `include/hal_data.h`
- [Chip-specific register maps](https://github.com/morrownr/88x2bu-20210702/blob/main/hal/halmac/halmac_reg_8822b.h): `hal/halmac/halmac_reg_8822b.h`

### Radio Management

- [PHY management](https://github.com/morrownr/88x2bu-20210702/blob/main/hal/phydm/phydm_antdiv.c): `hal/phydm/phydm_antdiv.c`
- [RF calibration](https://github.com/morrownr/88x2bu-20210702/blob/main/hal/phydm/halrf/rtl8822b/halrf_iqk_8822b.c): `hal/phydm/halrf/rtl8822b/halrf_iqk_8822b.c`
- [Bluetooth coexistence](https://github.com/morrownr/88x2bu-20210702/blob/main/hal/btc/halbtc8822b2ant.c): `hal/btc/halbtc8822b2ant.c`
- [PHYDM framework](https://github.com/morrownr/88x2bu-20210702/blob/main/hal/phydm/phydm.c): `hal/phydm/phydm.c`
- [PHYDM interfaces](https://github.com/morrownr/88x2bu-20210702/blob/main/hal/phydm/phydm_precomp.h): `hal/phydm/phydm_precomp.h`
- [Coexistence interfaces](https://github.com/morrownr/88x2bu-20210702/blob/main/hal/btc/halbtcoutsrc.h): `hal/btc/halbtcoutsrc.h`

### Security and Features

- [WiFi security](https://github.com/morrownr/88x2bu-20210702/blob/main/core/rtw_security.c): `core/rtw_security.c`
- [Crypto primitives](https://github.com/morrownr/88x2bu-20210702/blob/main/core/crypto/aes-internal.c): `core/crypto/aes-internal.c`
- [Mesh routing](https://github.com/morrownr/88x2bu-20210702/blob/main/core/mesh/rtw_mesh.c): `core/mesh/rtw_mesh.c`
- [Monitor radiotap](https://github.com/morrownr/88x2bu-20210702/blob/main/core/monitor/rtw_radiotap.c): `core/monitor/rtw_radiotap.c`

### Other components

- **Linux wireless user**

## Connections

- Linux wireless user → Cfg80211 interface: configures
- Linux wireless user → Legacy ioctl controls: controls
- Cfg80211 interface → Link management: requests link
- Legacy ioctl controls → Link management: controls link (evidence: `os_dep/linux/ioctl_linux.c`)
- Link management → 802.11 management: manages protocol
- Link management → Access point: supports AP mode
- Link management → WiFi Direct: supports P2P
- Link management → Packet transmit: uses data path
- Packet transmit → RTL8822BU transport: transmits packets
- RTL8822BU transport → USB transport: uses USB transport
- USB transport → Packet receive: receives packets
- Packet receive → Monitor radiotap: supports monitor
- WiFi security → Crypto primitives: uses primitives
- Link management → WiFi security: supports protected links
- Link management → Mesh routing: supports mesh
- Efuse configuration → Chipset operations: reads chipset data (evidence: `core/efuse/rtw_efuse.c`)
- Common hardware config → HALMAC control: calls HALMAC (evidence: `hal/hal_com.c`)
- Chipset operations → HALMAC control: uses HALMAC interface (evidence: `hal/rtl8822b/rtl8822b_ops.c`)
- HALMAC control → HALMAC API: implements API (evidence: `hal/halmac/halmac_88xx/halmac_common_88xx.c`)
- HALMAC control → Chip register definitions: uses registers
- Chipset operations → HAL data and commands: uses HAL data (evidence: `hal/rtl8822b/rtl8822b_ops.c`)
- Chipset operations → Chip-specific register maps: uses chip registers
- PHYDM framework → PHYDM interfaces: uses interfaces (evidence: `hal/phydm/phydm_precomp.h`)
- PHY management → PHYDM framework: uses PHYDM (evidence: `hal/phydm/phydm_antdiv.c`)
- RF calibration → PHYDM framework: provides RF control
- Bluetooth coexistence → Coexistence interfaces: uses coexistence API (evidence: `hal/btc/halbtc8822b2ant.c`)
- 802.11 management → WiFi definitions: uses WiFi definitions
