NetHubArchitecture:修订间差异
跳转到导航
跳转到搜索
创建页面,内容为“= NetHub 架构说明 = 本文档面向需要理解模块边界和 API 的开发者。 == 1. 当前架构结论 == * 当前物理主路径是 '''SDIO''' * <code>USB / SPI</code> 目前仍保留 backend 骨架,不作为当前推荐 bringup 路径 * device 侧 Wi-Fi backend 支持 <code>fhost / wl80211</code> * 控制通道和 <code>USER virtual channel</code> 都是当前 host link 上的逻辑通道,不是独立物理接口 * host 控制 backend 运行…” |
小 Sync NetHub docs from local Markdown |
||
| 第1行: | 第1行: | ||
= NetHub | = NetHub Architecture Guide = | ||
This document is for developers who need to understand module boundaries and APIs. | |||
== 1. | == 1. Current Architecture Conclusions == | ||
* | * The current physical primary path is <code>SDIO</code> | ||
* <code>USB / SPI</code> | * <code>USB / SPI</code> still keep backend skeletons and are not recommended bring-up paths for now | ||
* device | * The device-side Wi-Fi backend supports <code>fhost / wl80211</code> | ||
* | * The control channel and <code>USER virtual channel</code> are logical channels on the current host link, not separate physical interfaces | ||
* host | * The host control backend is selected at runtime: <code>tty</code> or <code>vchan</code> | ||
== 2. | == 2. Functional Architecture Diagram == | ||
< | <pre> | ||
Host | flowchart LR | ||
Host["Host"] | |||
Link["Host Link | |||
current main path: SDIO"] | |||
Host Link | Data["Data Channel"] | ||
Ctrl["Control Channel"] | |||
User["USER VCHAN"] | |||
subgraph Device["Device"] | |||
subgraph Hub["nethub"] | |||
Bridge["data bridge"] | |||
Filter["hard-coded Wi-Fi RX filter"] | |||
Active["active Wi-Fi selector | |||
STA / AP"] | |||
CtrlPath["ctrlpath"] | |||
Vchan["virtual channel"] | |||
end | |||
Wifi["Wi-Fi backend | |||
fhost / wl80211 + lwIP"] | |||
AT["ATModule"] | |||
end | |||
Host --> Link | |||
Link --> Data | |||
Link --> Ctrl | |||
Link --> User | |||
Data --> Bridge | |||
Bridge --> Active | |||
Active --> Wifi | |||
Wifi --> Filter | |||
Filter --> Bridge | |||
Ctrl --> CtrlPath | |||
CtrlPath --> AT | |||
AT --> Wifi | |||
User --> Vchan | |||
</pre> | |||
- | |||
From a functional view, <code>nethub</code> mainly does four things: | |||
</ | |||
* maintain the <code>Wi-Fi <-> HostLink</code> data bridge | |||
* use a hard-coded filter to decide whether a packet is <code>local</code>, <code>host</code>, or <code>both</code> | |||
* maintain the currently active Wi-Fi channel, <code>STA / AP</code> | |||
* provide a control channel and an optional <code>USER virtual channel</code> on the same host link | |||
== 3. Technical / API Architecture Diagram == | |||
<pre> | |||
flowchart TB | |||
App["Application"] | |||
subgraph DevicePublic["device public API"] | |||
DevAPI["nethub.h"] | |||
DevVchan["nethub_vchan.h"] | |||
DevFilter["nethub_filter.h"] | |||
end | |||
subgraph DeviceSide["device side"] | |||
Bootstrap["nethub_bootstrap()"] | |||
Profile["profile select"] | |||
Endpoint["endpoint register"] | |||
Hub["hub lifecycle"] | |||
WifiBridge["Wi-Fi bridge"] | |||
HostBackend["host backend | |||
current main path: sdio"] | |||
end | |||
subgraph HostPublic["host public API"] | |||
HostAPI["bflbwifi.h"] | |||
HostVchan["virtualchan/nethub_vchan.h"] | |||
end | |||
subgraph HostSide["host side"] | |||
CLI["bflbwifictrl"] | |||
IPC["local IPC"] | |||
Daemon["bflbwifid"] | |||
Lib["libbflbwifi"] | |||
Facade["channel facade"] | |||
TTY["tty backend"] | |||
VCHAN["vchan backend"] | |||
Kernel["mr_sdio.ko + msg_router"] | |||
end | |||
App --> DevAPI | |||
App --> DevVchan | |||
App --> DevFilter | |||
App --> HostAPI | |||
App --> HostVchan | |||
DevAPI --> Bootstrap | |||
DevVchan --> HostBackend | |||
DevFilter --> WifiBridge | |||
Bootstrap --> Profile | |||
Bootstrap --> Endpoint | |||
Bootstrap --> Hub | |||
Hub --> WifiBridge | |||
Endpoint --> HostBackend | |||
CLI --> IPC | |||
IPC --> Daemon | |||
Daemon --> Lib | |||
Lib --> Facade | |||
Facade --> TTY | |||
Facade --> VCHAN | |||
TTY --> Kernel | |||
VCHAN --> Kernel | |||
HostVchan --> Kernel | |||
</pre> | |||
== 4. device-side Public Interfaces == | |||
Headers: | |||
* <code>components/net/nethub/include/nethub.h</code> | * <code>components/net/nethub/include/nethub.h</code> | ||
| 第85行: | 第133行: | ||
* <code>components/net/nethub/include/nethub_filter.h</code> | * <code>components/net/nethub/include/nethub_filter.h</code> | ||
Core APIs: | |||
* <code>nethub_bootstrap()</code> | * <code>nethub_bootstrap()</code> | ||
| 第97行: | 第145行: | ||
* <code>nethub_set_wifi_rx_filter()</code> | * <code>nethub_set_wifi_rx_filter()</code> | ||
Boundary notes: | |||
* <code>nethub_ctrl_*</code> | * <code>nethub_ctrl_*</code> maps to the logical control channel on the host link | ||
* <code>nethub_vchan_user_*</code> | * <code>nethub_vchan_user_*</code> maps to the logical <code>USER</code> channel on the host link | ||
* <code>nethub_set_wifi_rx_filter()</code> | * <code>nethub_set_wifi_rx_filter()</code> fully replaces the built-in Wi-Fi RX filter and must be called before <code>nethub_bootstrap()</code> | ||
== 5. | == 5. host-side Public Interfaces == | ||
Headers: | |||
* <code>bsp/common/msg_router/linux_host/userspace/nethub/bflbwifictrl/include/bflbwifi.h</code> | * <code>bsp/common/msg_router/linux_host/userspace/nethub/bflbwifictrl/include/bflbwifi.h</code> | ||
* <code>bsp/common/msg_router/linux_host/userspace/nethub/virtualchan/nethub_vchan.h</code> | * <code>bsp/common/msg_router/linux_host/userspace/nethub/virtualchan/nethub_vchan.h</code> | ||
Control-plane capabilities: | |||
* <code>bflbwifi_ctrl_config_init()</code> | * <code>bflbwifi_ctrl_config_init()</code> | ||
| 第127行: | 第175行: | ||
* <code>bflbwifi_ap_stop()</code> | * <code>bflbwifi_ap_stop()</code> | ||
USER virtual channel | USER virtual channel capabilities: | ||
* <code>nethub_vchan_init()</code> | * <code>nethub_vchan_init()</code> | ||
| 第136行: | 第184行: | ||
* <code>nethub_vchan_register_link_event_callback()</code> | * <code>nethub_vchan_register_link_event_callback()</code> | ||
== 6. | == 6. Key Data Flows == | ||
=== 6.1 connect_ap === | === 6.1 <code>connect_ap</code> === | ||
# | # The user runs <code>bflbwifictrl connect_ap <ssid> <password></code> | ||
# CLI | # The CLI sends the command to <code>bflbwifid</code> through local IPC | ||
# daemon | # The daemon calls <code>libbflbwifi</code> | ||
# <code>libbflbwifi</code> | # <code>libbflbwifi</code> sends control messages through the <code>tty</code> or <code>vchan</code> backend | ||
# device | # The device-side <code>ATModule</code> performs the Wi-Fi control operation | ||
# device | # The device reports responses and state updates, and the host refreshes the state and returns the result | ||
=== 6.2 | === 6.2 Data Plane === | ||
# | # Host network traffic enters <code>mr_eth0</code> | ||
# kernel/msg_router | # The kernel / <code>msg_router</code> communicates with the device over SDIO | ||
# | # Device-side <code>nethub</code> forwards host data to the currently active Wi-Fi | ||
# Wi-Fi RX | # After Wi-Fi RX packets pass through the <code>nethub</code> filter, they are handled locally, forwarded to the host, or both | ||
== 7. | == 7. Recommended Reading Order == | ||
* | * First-time bring-up: [[NetHubQuickBringup|NetHubQuickBringup.md]] | ||
* | * Understanding the <code>USER</code> channel: [[NetHubVirtualChannel|NetHubVirtualChannel.md]] | ||
* Top-level entry: [[NetHub|NetHub.md]] | |||
2026年3月17日 (二) 05:33的最新版本
NetHub Architecture Guide
This document is for developers who need to understand module boundaries and APIs.
1. Current Architecture Conclusions
- The current physical primary path is
SDIO USB / SPIstill keep backend skeletons and are not recommended bring-up paths for now- The device-side Wi-Fi backend supports
fhost / wl80211 - The control channel and
USER virtual channelare logical channels on the current host link, not separate physical interfaces - The host control backend is selected at runtime:
ttyorvchan
2. Functional Architecture Diagram
flowchart LR
Host["Host"]
Link["Host Link
current main path: SDIO"]
Data["Data Channel"]
Ctrl["Control Channel"]
User["USER VCHAN"]
subgraph Device["Device"]
subgraph Hub["nethub"]
Bridge["data bridge"]
Filter["hard-coded Wi-Fi RX filter"]
Active["active Wi-Fi selector
STA / AP"]
CtrlPath["ctrlpath"]
Vchan["virtual channel"]
end
Wifi["Wi-Fi backend
fhost / wl80211 + lwIP"]
AT["ATModule"]
end
Host --> Link
Link --> Data
Link --> Ctrl
Link --> User
Data --> Bridge
Bridge --> Active
Active --> Wifi
Wifi --> Filter
Filter --> Bridge
Ctrl --> CtrlPath
CtrlPath --> AT
AT --> Wifi
User --> Vchan
From a functional view, nethub mainly does four things:
- maintain the
Wi-Fi <-> HostLinkdata bridge - use a hard-coded filter to decide whether a packet is
local,host, orboth - maintain the currently active Wi-Fi channel,
STA / AP - provide a control channel and an optional
USER virtual channelon the same host link
3. Technical / API Architecture Diagram
flowchart TB
App["Application"]
subgraph DevicePublic["device public API"]
DevAPI["nethub.h"]
DevVchan["nethub_vchan.h"]
DevFilter["nethub_filter.h"]
end
subgraph DeviceSide["device side"]
Bootstrap["nethub_bootstrap()"]
Profile["profile select"]
Endpoint["endpoint register"]
Hub["hub lifecycle"]
WifiBridge["Wi-Fi bridge"]
HostBackend["host backend
current main path: sdio"]
end
subgraph HostPublic["host public API"]
HostAPI["bflbwifi.h"]
HostVchan["virtualchan/nethub_vchan.h"]
end
subgraph HostSide["host side"]
CLI["bflbwifictrl"]
IPC["local IPC"]
Daemon["bflbwifid"]
Lib["libbflbwifi"]
Facade["channel facade"]
TTY["tty backend"]
VCHAN["vchan backend"]
Kernel["mr_sdio.ko + msg_router"]
end
App --> DevAPI
App --> DevVchan
App --> DevFilter
App --> HostAPI
App --> HostVchan
DevAPI --> Bootstrap
DevVchan --> HostBackend
DevFilter --> WifiBridge
Bootstrap --> Profile
Bootstrap --> Endpoint
Bootstrap --> Hub
Hub --> WifiBridge
Endpoint --> HostBackend
CLI --> IPC
IPC --> Daemon
Daemon --> Lib
Lib --> Facade
Facade --> TTY
Facade --> VCHAN
TTY --> Kernel
VCHAN --> Kernel
HostVchan --> Kernel
4. device-side Public Interfaces
Headers:
components/net/nethub/include/nethub.hcomponents/net/nethub/include/nethub_vchan.hcomponents/net/nethub/include/nethub_filter.h
Core APIs:
nethub_bootstrap()nethub_shutdown()nethub_get_status()nethub_set_active_wifi_channel()nethub_ctrl_upld_send()nethub_ctrl_dnld_register()nethub_vchan_user_send()nethub_vchan_user_recv_register()nethub_set_wifi_rx_filter()
Boundary notes:
nethub_ctrl_*maps to the logical control channel on the host linknethub_vchan_user_*maps to the logicalUSERchannel on the host linknethub_set_wifi_rx_filter()fully replaces the built-in Wi-Fi RX filter and must be called beforenethub_bootstrap()
5. host-side Public Interfaces
Headers:
bsp/common/msg_router/linux_host/userspace/nethub/bflbwifictrl/include/bflbwifi.hbsp/common/msg_router/linux_host/userspace/nethub/virtualchan/nethub_vchan.h
Control-plane capabilities:
bflbwifi_ctrl_config_init()bflbwifi_ctrl_config_use_tty()bflbwifi_ctrl_config_use_vchan()bflbwifi_init_ex()bflbwifi_get_ctrl_status()bflbwifi_sta_connect()bflbwifi_sta_disconnect()bflbwifi_sta_get_state()bflbwifi_scan()bflbwifi_get_version()bflbwifi_restart()bflbwifi_ota_upgrade()bflbwifi_ap_start()bflbwifi_ap_stop()
USER virtual channel capabilities:
nethub_vchan_init()nethub_vchan_deinit()nethub_vchan_user_send()nethub_vchan_user_register_callback()nethub_vchan_get_state_snapshot()nethub_vchan_register_link_event_callback()
6. Key Data Flows
6.1 connect_ap
- The user runs
bflbwifictrl connect_ap <ssid> <password> - The CLI sends the command to
bflbwifidthrough local IPC - The daemon calls
libbflbwifi libbflbwifisends control messages through thettyorvchanbackend- The device-side
ATModuleperforms the Wi-Fi control operation - The device reports responses and state updates, and the host refreshes the state and returns the result
6.2 Data Plane
- Host network traffic enters
mr_eth0 - The kernel /
msg_routercommunicates with the device over SDIO - Device-side
nethubforwards host data to the currently active Wi-Fi - After Wi-Fi RX packets pass through the
nethubfilter, they are handled locally, forwarded to the host, or both
7. Recommended Reading Order
- First-time bring-up: NetHubQuickBringup.md
- Understanding the
USERchannel: NetHubVirtualChannel.md - Top-level entry: NetHub.md