ATH12K驱动框架架构图

ATH12K驱动框架架构图

ATH12K驱动框架架构图(分层描述)

I. 顶层架构
II. 核心数据结构层次关系
III. 主要模块详解

1. 核心模块 (Core)
2. 硬件抽象层 (HAL)
3. 无线管理接口 (WMI)
4. 主机目标通信 (HTC)
5. 复制引擎 (CE)
6. MAC层
7. 数据路径 (DP)

IV. 关键数据流路径

1. 发送数据流 (TX Path)
2. 接收数据流 (RX Path)

V. WMI命令流和事件处理
VI. MLO架构 (多链路操作)
VII. 初始化序列图

ATH12K驱动框架架构图(分层描述)

I. 顶层架构

┌───────────────────────────────────────────────────────┐
│                     Linux Kernel                      │
├───────────────────────────────────────────────────────┤
│                      mac80211                         │
├───────────────────────────────────────────────────────┤
│                     ATH12K Driver                     │
│  ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────────┐  │
│  │  Core   │ │   MAC   │ │   DP    │ │Debug/Tracing│  │
│  └─────────┘ └─────────┘ └─────────┘ └─────────────┘  │
│  ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────────┐  │
│  │   HAL   │ │   HTC   │ │   WMI   │ │     CE      │  │
│  └─────────┘ └─────────┘ └─────────┘ └─────────────┘  │
├───────────────────────────────────────────────────────┤
│           PCI/AHB 总线接口层 (Bus Interface)          │
├───────────────────────────────────────────────────────┤
│                      Hardware                         │
└───────────────────────────────────────────────────────┘

II. 核心数据结构层次关系

┌──────────────────────────────────────────────────────────────┐
│                     struct ath12k_hw_group                   │
│  ┌──────────────────────────────────────────────┐            │
│  │               struct ath12k_hw               │            │
│  │  ┌──────────────┐  ┌──────────────┐          │            │
│  │  │  struct      │  │  struct      │          │            │
│  │  │  ath12k      │  │  ath12k      │...       │            │
│  │  │  (radio 0)   │  │  (radio 1)   │          │            │
│  │  └──────────────┘  └──────────────┘          │            │
│  └──────────────────────────────────────────────┘            │
│                                                              │
│  ┌──────────────────────────────────────────────┐            │
│  │           struct ath12k_base  (SOC 0)        │            │
│  │  ┌─────────────┐ ┌─────────────┐             │            │
│  │  │struct ath12k│ │struct ath12k│...          │            │
│  │  │_pdev (0)    │ │_pdev (1)    │             │            │
│  │  └─────────────┘ └─────────────┘             │            │
│  └──────────────────────────────────────────────┘            │
│                                                              │
│  ┌──────────────────────────────────────────────┐            │
│  │           struct ath12k_base  (SOC 1)        │            │
│  │  ┌─────────────┐ ┌─────────────┐             │            │
│  │  │struct ath12k│ │struct ath12k│...          │            │
│  │  │_pdev (0)    │ │_pdev (1)    │             │            │
│  │  └─────────────┘ └─────────────┘             │            │
│  └──────────────────────────────────────────────┘            │
└──────────────────────────────────────────────────────────────┘

III. 主要模块详解

1. 核心模块 (Core)

┌──────────────────────────────────────────────────────────────┐
│                       Core Module                            │
├──────────────────────────────────────────────────────────────┤
│ ┌────────────────────┐  ┌─────────────────────────────────┐  │
│ │ Initialization     │  │ Resource Management             │  │
│ │ - ath12k_core_init │  │ - Memory allocation            │  │
│ │ - ath12k_core_qmi  │  │ - Interrupts                   │  │
│ │ - Firmware loading │  │ - Device tree parsing          │  │
│ └────────────────────┘  └─────────────────────────────────┘  │
│                                                              │
│ ┌────────────────────┐  ┌─────────────────────────────────┐  │
│ │ Power Management   │  │ Recovery handling               │  │
│ │ - Suspend/Resume   │  │ - SSR (Subsystem restart)       │  │
│ │ - Runtime PM       │  │ - FW crash handling             │  │
│ └────────────────────┘  └─────────────────────────────────┘  │
└──────────────────────────────────────────────────────────────┘

2. 硬件抽象层 (HAL)

┌──────────────────────────────────────────────────────────────┐
│                       HAL Module                             │
├──────────────────────────────────────────────────────────────┤
│ ┌────────────────────┐  ┌─────────────────────────────────┐  │
│ │ SRNG Management    │  │ Register Access                 │  │
│ │ - Source rings     │  │ - Direct register read/write    │  │
│ │ - Destination rings│  │ - Shadow register handling      │  │
│ │ - Ring init/deinit │  │ - CE register access           │  │
│ └────────────────────┘  └─────────────────────────────────┘  │
│                                                              │
│ ┌────────────────────┐  ┌─────────────────────────────────┐  │
│ │ Descriptor Handling│  │ Hardware specific operations    │  │
│ │ - RX desc parsing  │  │ - QCN9274 ops                   │  │
│ │ - TX desc setup    │  │ - WCN7850 ops                   │  │
│ │ - REO cmd/response │  │ - QCN6432 ops                   │  │
│ └────────────────────┘  └─────────────────────────────────┘  │
└──────────────────────────────────────────────────────────────┘

3. 无线管理接口 (WMI)

┌──────────────────────────────────────────────────────────────┐
│                       WMI Module                             │
├──────────────────────────────────────────────────────────────┤
│ ┌────────────────────┐  ┌─────────────────────────────────┐  │
│ │ Command Processing │  │ Event Handling                  │  │
│ │ - SCAN commands    │  │ - Service ready events          │  │
│ │ - PDEV commands    │  │ - Scan events                   │  │
│ │ - VDEV commands    │  │ - PEER events                   │  │
│ │ - PEER commands    │  │ - MGMT RX events                │  │
│ │ - MLO commands     │  │ - MLO events                    │  │
│ └────────────────────┘  └─────────────────────────────────┘  │
│                                                              │
│ ┌────────────────────┐  ┌─────────────────────────────────┐  │
│ │ TLV Processing     │  │ Service handling                │  │
│ │ - TLV parsing      │  │ - Service bitmap                │  │
│ │ - TLV generation   │  │ - Service availability check    │  │
│ └────────────────────┘  └─────────────────────────────────┘  │
└──────────────────────────────────────────────────────────────┘

4. 主机目标通信 (HTC)

┌──────────────────────────────────────────────────────────────┐
│                       HTC Module                             │
├──────────────────────────────────────────────────────────────┤
│ ┌────────────────────┐  ┌─────────────────────────────────┐  │
│ │ Endpoint Management│  │ Message Handling                │  │
│ │ - EP allocation    │  │ - Message send                  │  │
│ │ - EP configuration │  │ - Message receive               │  │
│ │ - Service mapping  │  │ - Message completion            │  │
│ └────────────────────┘  └─────────────────────────────────┘  │
│                                                              │
│ ┌────────────────────┐  ┌─────────────────────────────────┐  │
│ │ Credit Management  │  │ Connection Management           │  │
│ │ - Credit tracking  │  │ - Connection setup/teardown     │  │
│ │ - Flow control     │  │ - Service connection mapping    │  │
│ └────────────────────┘  └─────────────────────────────────┘  │
└──────────────────────────────────────────────────────────────┘

5. 复制引擎 (CE)

┌──────────────────────────────────────────────────────────────┐
│                       CE Module                              │
├──────────────────────────────────────────────────────────────┤
│ ┌────────────────────┐  ┌─────────────────────────────────┐  │
│ │ CE Ring Management │  │ Transfer Operations             │  │
│ │ - Source rings     │  │ - Message transfer              │  │
│ │ - Destination rings│  │ - Buffer transfer               │  │
│ │ - CE initialization│  │ - Completion handling           │  │
│ └────────────────────┘  └─────────────────────────────────┘  │
│                                                              │
│ ┌────────────────────┐  ┌─────────────────────────────────┐  │
│ │ Interrupt Handling │  │ CE-specific Operations          │  │
│ │ - MSI handling     │  │ - CE pipe configuration         │  │
│ │ - IRQ registration │  │ - DMA management                │  │
│ └────────────────────┘  └─────────────────────────────────┘  │
└──────────────────────────────────────────────────────────────┘

6. MAC层

┌──────────────────────────────────────────────────────────────┐
│                       MAC Module                             │
├──────────────────────────────────────────────────────────────┤
│ ┌────────────────────┐  ┌─────────────────────────────────┐  │
│ │ Interface Management│ │ STA/AP Operations               │  │
│ │ - VIF creation     │  │ - STA connection management     │  │
│ │ - VIF configuration│  │ - AP beacon handling            │  │
│ │ - PEER management  │  │ - TX/RX packet processing       │  │
│ └────────────────────┘  └─────────────────────────────────┘  │
│                                                              │
│ ┌────────────────────┐  ┌─────────────────────────────────┐  │
│ │ MLO Support        │  │ mac80211 Callbacks              │  │
│ │ - Multi-link setup │  │ - TX/RX handlers                │  │
│ │ - Link management  │  │ - Configuration callbacks       │  │
│ │ - ML PEER handling │  │ - Scan interface                │  │
│ └────────────────────┘  └─────────────────────────────────┘  │
└──────────────────────────────────────────────────────────────┘

7. 数据路径 (DP)

┌──────────────────────────────────────────────────────────────┐
│                       DP Module                              │
├──────────────────────────────────────────────────────────────┤
│ ┌────────────────────┐  ┌─────────────────────────────────┐  │
│ │ TX Data Path       │  │ RX Data Path                    │  │
│ │ - TCL rings        │  │ - REO rings                     │  │
│ │ - SW2TCL processing│  │ - REO2SW processing             │  │
│ │ - TX completion    │  │ - RXDMA handling                │  │
│ │ - WBM release      │  │ - RX reordering                 │  │
│ └────────────────────┘  └─────────────────────────────────┘  │
│                                                              │
│ ┌────────────────────┐  ┌─────────────────────────────────┐  │
│ │ Buffer Management  │  │ Statistics and Monitoring       │  │
│ │ - RX buffer pools  │  │ - TX/RX statistics              │  │
│ │ - TX buffer pools  │  │ - Performance monitoring        │  │
│ │ - WBM idle list    │  │ - Debug information             │  │
│ └────────────────────┘  └─────────────────────────────────┘  │
└──────────────────────────────────────────────────────────────┘

IV. 关键数据流路径

1. 发送数据流 (TX Path)

┌────────────┐     ┌────────────┐     ┌────────────┐
│ mac80211   │     │ ath12k MAC │     │ ath12k DP  │
│ TX handler │────▶│ TX handler │────▶│ TX handler │
└────────────┘     └────────────┘     └────────────┘
                                             │
                                             ▼
┌────────────┐     ┌────────────┐     ┌────────────┐
│  Hardware  │     │  TCL/WBM   │     │   HAL TX   │
│ Processing │◀────│   Rings    │◀────│  Processing│
└────────────┘     └────────────┘     └────────────┘

详细TX路径步骤:

mac80211将TX帧传递给ath12k_mac_tx()
MAC层处理:加密、分片、序列号分配
将帧传递给DP层的TX处理函数
DP层分配TX描述符,设置元数据
通过HAL将TX描述符推送到SW2TCL环形缓冲区
硬件接收描述符并发送帧
硬件完成后,将完成状态写入WBM2SW释放环
驱动处理TX完成事件,释放资源

2. 接收数据流 (RX Path)

┌────────────┐     ┌────────────┐     ┌────────────┐
│  Hardware  │     │ REO/RXDMA  │     │   HAL RX   │
│ Processing │────▶│   Rings    │────▶│ Processing │
└────────────┘     └────────────┘     └────────────┘
                                             │
                                             ▼
┌────────────┐     ┌────────────┐     ┌────────────┐
│ mac80211   │     │ ath12k MAC │     │ ath12k DP  │
│ RX handler │◀────│ RX handler │◀────│ RX handler │
└────────────┘     └────────────┘     └────────────┘

详细RX路径步骤:

硬件接收帧并处理
硬件将RX描述符和数据写入REO2SW环形缓冲区
驱动通过中断或轮询检测新的RX描述符
HAL层解析RX描述符
DP层处理RX数据:重排序、组装
将处理后的帧传递给MAC层
MAC层处理:解密、过滤
将帧传递给mac80211层

V. WMI命令流和事件处理

┌───────────────────────────────┐     ┌───────────────────┐
│        Host Driver            │     │     Firmware      │
├───────────────┬───────────────┤     ├─────────┬─────────┤
│  MAC/DP/Core  │   WMI Module  │     │  WMI    │   HW    │
│   Modules     │               │     │ Service │         │
├───────────────┼───────────────┤     ├─────────┼─────────┤
│ 1. Generate   │               │     │         │         │
│    Command    │               │     │         │         │
├───────────────┼───────────────┤     │         │         │
│ 2. Call       │               │     │         │         │
│    WMI API    │               │     │         │         │
├───────┬───────┼───────────────┤     │         │         │
│       │       │ 3. Format WMI │     │         │         │
│       │       │    TLV Command│     │         │         │
│       │       ├───────────────┤     │         │         │
│       │       │ 4. Send via   │     │         │         │
│       │       │    HTC/CE     │─────▶         │         │
│       │       │               │     │         │         │
│       │       │               │     │ 5. Process        │
│       │       │               │     │    Command        │
│       │       │               │     │         │         │
│       │       │               │     │ 6. Execute        │
│       │       │               │     │    Operation      │
│       │       │               │     │         │         │
│       │       │ 8. Process    │     │ 7. Generate       │
│       │       │    Event      │◀────│    Response Event │
│       │       ├───────────────┤     │         │         │
│ 9. Handle     │               │     │         │         │
│    Response   │               │     │         │         │
└───────────────┴───────────────┘     └─────────┴─────────┘

VI. MLO架构 (多链路操作)

┌─────────────────────────────────────────────────────────────┐
│                     MLO Architecture                        │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│  ┌───────────────────┐       ┌───────────────────┐          │
│  │   MLD Interface   │       │  MLD PEER(STA)    │          │
│  │ (ath12k_vif)      │       │ (ath12k_sta)      │          │
│  └─────────┬─────────┘       └────────┬──────────┘          │
│            │                           │                    │
│  ┌─────────┼─────────┬─────────────────┼──────────┐         │
│  │         │         │                 │          │         │
│  ▼         ▼         ▼                 ▼          ▼         │
│ ┌─────┐  ┌─────┐  ┌─────┐           ┌─────┐    ┌─────┐      │
│ │Link │  │Link │  │Link │           │Link │    │Link │      │
│ │ 0   │  │ 1   │  │ 2   │    ...    │ 0   │    │ 1   │ ...  │
│ │Vif  │  │Vif  │  │Vif  │           │Sta  │    │Sta  │      │
│ └─────┘  └─────┘  └─────┘           └─────┘    └─────┘      │
│                                                             │
└─────────────────────────────────────────────────────────────┘

VII. 初始化序列图

┌─────────┐      ┌────────┐      ┌──────┐      ┌─────┐      ┌───────┐
│PCI/AHB  │      │Core    │      │HAL   │      │WMI  │      │MAC    │
│Driver   │      │Module  │      │Module│      │HTC  │      │Module │
├─────────┤      ├────────┤      ├──────┤      ├─────┤      ├───────┤
│         │      │        │      │      │      │     │      │       │
│probe()  │─────▶│        │      │      │      │     │      │       │
│         │      │        │      │      │      │     │      │       │
│         │      │core_alloc()  │      │      │     │      │       │
│         │      │───────┐      │      │      │     │      │       │
│         │      │       │      │      │      │     │      │       │
│         │      │◀──────┘      │      │      │     │      │       │
│         │      │qmi_init()    │      │      │     │      │       │
│         │      │───────┐      │      │      │     │      │       │
│         │      │       │      │      │      │     │      │       │
│         │      │◀──────┘      │      │      │     │      │       │
│         │      │        │      │      │      │     │      │       │
│         │      │fetch_fw()   │      │      │     │      │       │
│         │      │───────┐      │      │      │     │      │       │
│         │      │       │      │      │      │     │      │       │
│         │      │◀──────┘      │      │      │     │      │       │
│         │      │        │      │      │      │     │      │       │
│         │      │core_init()   │      │      │     │      │       │
│         │      │──────────────┼─────▶│      │      │     │      │       │
│         │      │        │      │      │      │     │      │       │
│         │      │        │      │hal_init()  │     │      │       │
│         │      │        │      │────┐ │      │     │      │       │
│         │      │        │      │    │ │      │     │      │       │
│         │      │        │      │◀───┘ │      │     │      │       │
│         │      │        │      │      │      │     │      │       │
│         │      │        │      │srng_init() │     │      │       │
│         │      │        │      │────┐ │      │     │      │       │
│         │      │        │      │    │ │      │     │      │       │
│         │      │        │      │◀───┘ │      │     │      │       │
│         │      │        │      │      │      │     │      │       │
│         │      │        │      │      │wmi_init()  │     │      │       │
│         │      │        │      │      │────────────┼────▶│     │      │       │
│         │      │        │      │      │      │     │      │       │
│         │      │        │      │      │      │htc_init()  │     │      │       │
│         │      │        │      │      │      │────┐│     │      │       │
│         │      │        │      │      │      │    ││     │      │       │
│         │      │        │      │      │      │◀───┘│     │      │       │
│         │      │        │      │      │      │     │      │       │
│         │      │        │      │      │      │     │mac_allocate()│
│         │      │        │      │      │      │     │─────────────▶
│         │      │        │      │      │      │     │      │       │
│         │      │        │      │      │      │     │      │mac_register()
│         │      │        │      │      │      │     │      │───────┐
│         │      │        │      │      │      │     │      │       │
│         │      │        │      │      │      │     │      │◀──────┘
└─────────┘      └────────┘      └──────┘      └─────┘      └───────┘

以上是ATH12K驱动框架的详细结构图和交互逻辑。您可以根据这些信息创建一个全面的框架图,以便更好地理解驱动程序各模块之间的关系和数据流。

© 版权声明
THE END
如果内容对您有所帮助,就支持一下吧!
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容