NetHubVirtualChannel:修订间差异
跳转到导航
跳转到搜索
小 Sync NetHub docs from local Markdown (2026-04-24 wording update) |
小 Unify tone and terminology across NetHub docs (2026-04-24) |
||
| 第1行: | 第1行: | ||
= NetHub USER Virtual Channel = | = NetHub USER Virtual Channel = | ||
This document describes the current NetHub USER virtual | This document describes the current NetHub USER virtual channel support. | ||
== 1. Concept == | == 1. Concept == | ||
USER virtual channel is a logical message channel carried on the active host | USER virtual channel is a logical message channel carried on the active host interface. | ||
It is not a separate physical interface. The public API is | It is not a separate physical interface. The public API is transport-neutral, while the current in-tree implementation is still centered on the default <code>SDIO</code> interface. | ||
Common logical types: | Common logical types: | ||
| 第34行: | 第34行: | ||
| Host userspace library || currently aligned with <code>mr_sdio.ko + netlink</code> | | Host userspace library || currently aligned with <code>mr_sdio.ko + netlink</code> | ||
|- | |- | ||
| Default interface for the current in-tree USER | | Default interface for the current in-tree USER virtual channel path || <code>SDIO</code> | ||
|- | |- | ||
| USB || device-side ACM transport exists, but in-tree host <code>nethub_vchan</code> alignment is not finished | | USB || device-side ACM transport exists, but in-tree host <code>nethub_vchan</code> alignment is not finished | ||
| 第43行: | 第43行: | ||
== 3. Prerequisites == | == 3. Prerequisites == | ||
Before using the current in-tree USER virtual | Before using the current in-tree USER virtual channel path, confirm: | ||
* device side is built with <code>CONFIG_NETHUB=y</code> | * device side is built with <code>CONFIG_NETHUB=y</code> | ||
* device side enables <code>CONFIG_MR_VIRTUALCHAN=y</code> | * device side enables <code>CONFIG_MR_VIRTUALCHAN=y</code> | ||
* the selected bring-up path | * the selected bring-up path uses the default <code>SDIO</code> interface | ||
* host side has loaded <code>mr_sdio.ko</code> | * host side has loaded <code>mr_sdio.ko</code> | ||
* the host-device link is already working | * the host-device link is already working | ||
| 第55行: | 第55行: | ||
* USER and AT are parallel logical channels | * USER and AT are parallel logical channels | ||
* customer private data should stay on the <code>USER</code> type | * customer private data should stay on the <code>USER</code> type | ||
* documentation should not | * documentation should not describe USB and SPI as if they already share a finished end-to-end virtual channel stack | ||
== 4. Device-Side API == | == 4. Device-Side API == | ||
| 第152行: | 第152行: | ||
* USER virtual channel is packet-oriented, not a byte stream | * USER virtual channel is packet-oriented, not a byte stream | ||
* the current in-tree end-to-end path is SDIO-based | * the current in-tree end-to-end path is SDIO-based | ||
* if the device side does not enable <code>CONFIG_MR_VIRTUALCHAN</code>, the current in-tree USER virtual | * if the device side does not enable <code>CONFIG_MR_VIRTUALCHAN</code>, the current in-tree USER virtual channel path will not work | ||
* if control traffic and USER traffic coexist, keep private application traffic on <code>USER</code> and do not reuse the <code>AT</code> type | * if control traffic and USER traffic coexist, keep private application traffic on <code>USER</code> and do not reuse the <code>AT</code> type | ||
2026年4月24日 (五) 14:27的版本
NetHub USER Virtual Channel
This document describes the current NetHub USER virtual channel support.
1. Concept
USER virtual channel is a logical message channel carried on the active host interface.
It is not a separate physical interface. The public API is transport-neutral, while the current in-tree implementation is still centered on the default SDIO interface.
Common logical types:
| Type | Meaning |
|---|---|
USER |
private customer or application data |
AT |
control payloads |
SYSTEM |
internal coordination messages |
2. Current Support Status
| Area | Current status |
|---|---|
| Device API surface | transport-neutral by design |
| Device in-tree implementation | currently in backend/host/sdio/virtualchan.c
|
| Host userspace library | currently aligned with mr_sdio.ko + netlink
|
| Default interface for the current in-tree USER virtual channel path | SDIO
|
| USB | device-side ACM transport exists, but in-tree host nethub_vchan alignment is not finished
|
| SPI | not supported |
3. Prerequisites
Before using the current in-tree USER virtual channel path, confirm:
- device side is built with
CONFIG_NETHUB=y - device side enables
CONFIG_MR_VIRTUALCHAN=y - the selected bring-up path uses the default
SDIOinterface - host side has loaded
mr_sdio.ko - the host-device link is already working
Notes:
- USER and AT are parallel logical channels
- customer private data should stay on the
USERtype - documentation should not describe USB and SPI as if they already share a finished end-to-end virtual channel stack
4. Device-Side API
Header:
components/net/nethub/include/nethub_vchan.h
Common APIs:
int nethub_vchan_user_send(const void *data, uint16_t len);
int nethub_vchan_user_recv_register(nethub_vchan_recv_cb_t recv_cb, void *cb_arg);
5. Host-Side API
Header:
bsp/common/msg_router/linux_host/userspace/nethub/virtualchan/nethub_vchan.h
Initialization and cleanup:
int nethub_vchan_init(void);
int nethub_vchan_deinit(void);
USER channel:
typedef void (*nethub_vchan_recv_callback_t)(const void *data, size_t len);
int nethub_vchan_user_send(const void *data, size_t len);
int nethub_vchan_user_register_callback(nethub_vchan_recv_callback_t callback);
Optional state query:
typedef struct {
nethub_vchan_link_state_t link_state;
nethub_vchan_host_state_t host_state;
} nethub_vchan_state_snapshot_t;
int nethub_vchan_get_state_snapshot(nethub_vchan_state_snapshot_t *snapshot);
Optional link event callback:
int nethub_vchan_register_link_event_callback(
nethub_vchan_link_event_callback_t callback,
void *user_data);
6. Typical Usage Order
nethub_vchan_init()nethub_vchan_user_register_callback()nethub_vchan_user_send()nethub_vchan_deinit()when finished
Example:
#include <stdio.h>
#include <string.h>
#include "nethub_vchan.h"
static void user_rx_cb(const void *data, size_t len)
{
printf("recv USER data: %.*s\n", (int)len, (const char *)data);
}
int main(void)
{
const char *msg = "hello from host";
if (nethub_vchan_init() != 0) {
return -1;
}
nethub_vchan_user_register_callback(user_rx_cb);
nethub_vchan_user_send(msg, strlen(msg));
nethub_vchan_deinit();
return 0;
}
7. Limits and Notes
- maximum payload length per message is
1500bytes - USER virtual channel is packet-oriented, not a byte stream
- the current in-tree end-to-end path is SDIO-based
- if the device side does not enable
CONFIG_MR_VIRTUALCHAN, the current in-tree USER virtual channel path will not work - if control traffic and USER traffic coexist, keep private application traffic on
USERand do not reuse theATtype