VSF Documented
vsf_wifi_radio.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __VSF_WIFI_RADIO_H__
19#define __VSF_WIFI_RADIO_H__
20
21/*============================ INCLUDES ======================================*/
22
23#include "./vsf_wifi_cfg.h"
24
25#if VSF_USE_WIFI == ENABLED
26
27#include "kernel/vsf_kernel.h"
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33/*============================ MACROS ========================================*/
34
35/*============================ TYPES =========================================*/
36
37/* Forward declarations: full definitions live in vsf_wifi_priv.h. */
38typedef struct vsf_wifi_t vsf_wifi_t;
40
41/* RX callback invoked for every 802.11 frame received in raw-radio mode. */
42typedef void (*vsf_wifi_radio_rx_cb_t)(vsf_wifi_radio_t *radio, void *param,
43 uint8_t *frame, uint16_t len);
44
45/* Completion callback for async raw-radio operations. */
47
48/*
49 * Raw WiFi radio operations.
50 *
51 * These are low-level, 802.11-frame-oriented hooks that a WiFi chip driver can
52 * expose when the standard station-mode state machine (MLME/WPA/DHCP) is not
53 * needed. They are intentionally minimal: init/fini, TX, channel/filter
54 * control, and a power-save hook.
55 *
56 * All operations are asynchronous and MUST NOT block. The caller is the
57 * same EDA/interrupt context used by the rest of the WiFi subsystem.
58 */
59typedef struct vsf_wifi_radio_ops_t {
60 /*
61 * Prepare the radio for raw operation. Called after the chip has already
62 * been attached and firmware-loaded by the normal WiFi bring-up chain.
63 * The implementation should enable RX with a sensible default filter and
64 * leave the radio in a state where subsequent TX/RX/channel calls work.
65 */
68
69 /*
70 * Shut down raw operation. Typically disables RX / clears the filter.
71 * After fini returns the instance can either be re-initialized as raw
72 * radio or returned to standard WiFi mode.
73 */
76
77 /*
78 * Transmit a naked 802.11 frame. The chip driver wraps it with its
79 * on-wire descriptor (e.g. RT2800 TXINFO + TXWI) and ships it over the
80 * bus. Fire-and-forget: there is no per-frame TX completion callback.
81 */
83 const uint8_t *frame, uint16_t len);
84
85 /* Set the RF channel. Completion via `done`. */
88
89 /* Set the RX filter (chip-specific mask). Completion via `done`. */
92
93 /*
94 * Enter/leave chip power-save state. This is a placeholder in the first
95 * revision; implementations may return VSF_ERR_NONE until real RF
96 * sleep/wakeup scripts are added.
97 */
101
102/*============================ GLOBAL VARIABLES ==============================*/
103
104/*============================ PROTOTYPES ====================================*/
105
106/*
107 * Obtain the raw-radio handle embedded in a vsf_wifi_t instance.
108 * Returns NULL if the chip driver does not expose wifi_radio_ops.
109 */
111
112/*
113 * Register the RX callback that will receive 802.11 frames while raw radio
114 * mode is active. May be called before or after vsf_wifi_radio_init().
115 */
118 void *param);
119
120/*
121 * Start raw-radio mode. Mutually exclusive with standard WiFi connect/scan:
122 * returns VSF_ERR_NOT_AVAILABLE if the WiFi layer is currently busy.
123 * Completion via `done`.
124 */
130 const uint8_t *frame,
131 uint16_t len);
133 uint8_t ch,
136 uint32_t mask,
139 bool sleep,
141
142/*
143 * Chip drivers call this to deliver a received 802.11 frame to the registered
144 * raw-radio RX callback. Safe to call even when no callback is registered.
145 */
146extern void vsf_wifi_radio_on_rx(vsf_wifi_t *wifi, uint8_t *frame,
147 uint16_t len);
148
149/*
150 * Internal adapter for chip drivers that delegate async work to the existing
151 * vsf_wifi_* script helpers (which take a vsf_wifi_done_t callback). The chip
152 * driver stashes the user `done` with vsf_wifi_radio_adapter_done_set() and
153 * passes vsf_wifi_radio_adapter_done() as the vsf_wifi_done_t callback.
154 */
157extern void vsf_wifi_radio_adapter_done (vsf_wifi_t *wifi,
158 vsf_err_t err);
159
160#ifdef __cplusplus
161}
162#endif
163
164#endif /* VSF_USE_WIFI */
165#endif /* __VSF_WIFI_RADIO_H__ */
vsf_err_t
Definition __type.h:42
unsigned short uint16_t
Definition stdint.h:7
unsigned uint32_t
Definition stdint.h:9
unsigned char uint8_t
Definition stdint.h:5
Definition vsf_wifi_radio.h:59
vsf_err_t(* tx)(vsf_wifi_radio_t *radio, const uint8_t *frame, uint16_t len)
Definition vsf_wifi_radio.h:82
vsf_err_t(* set_channel)(vsf_wifi_radio_t *radio, uint8_t ch, vsf_wifi_radio_done_t done)
Definition vsf_wifi_radio.h:86
vsf_err_t(* fini)(vsf_wifi_radio_t *radio, vsf_wifi_radio_done_t done)
Definition vsf_wifi_radio.h:74
vsf_err_t(* set_filter)(vsf_wifi_radio_t *radio, uint32_t mask, vsf_wifi_radio_done_t done)
Definition vsf_wifi_radio.h:90
vsf_err_t(* set_ps)(vsf_wifi_radio_t *radio, bool sleep, vsf_wifi_radio_done_t done)
Definition vsf_wifi_radio.h:98
vsf_err_t(* init)(vsf_wifi_radio_t *radio, vsf_wifi_radio_done_t done)
Definition vsf_wifi_radio.h:66
Definition vsf_wifi_priv.h:35
Definition vsf_wifi_priv.h:53
#define sleep
Definition unistd.h:53
vsf_err_t vsf_wifi_radio_tx(vsf_wifi_radio_t *radio, const uint8_t *frame, uint16_t len)
Definition vsf_wifi.c:2178
void vsf_wifi_radio_adapter_done(vsf_wifi_t *wifi, vsf_err_t err)
Definition vsf_wifi.c:2100
void(* vsf_wifi_radio_rx_cb_t)(vsf_wifi_radio_t *radio, void *param, uint8_t *frame, uint16_t len)
Definition vsf_wifi_radio.h:42
void vsf_wifi_radio_adapter_done_set(vsf_wifi_radio_t *radio, vsf_wifi_radio_done_t done)
Definition vsf_wifi.c:2093
vsf_err_t vsf_wifi_radio_set_filter(vsf_wifi_radio_t *radio, uint32_t mask, vsf_wifi_radio_done_t done)
Definition vsf_wifi.c:2205
vsf_err_t vsf_wifi_radio_set_ps(vsf_wifi_radio_t *radio, bool sleep, vsf_wifi_radio_done_t done)
Definition vsf_wifi.c:2218
vsf_err_t vsf_wifi_radio_init(vsf_wifi_radio_t *radio, vsf_wifi_radio_done_t done)
Definition vsf_wifi.c:2137
void(* vsf_wifi_radio_done_t)(vsf_wifi_radio_t *radio, vsf_err_t err)
Definition vsf_wifi_radio.h:46
void vsf_wifi_radio_on_rx(vsf_wifi_t *wifi, uint8_t *frame, uint16_t len)
Definition vsf_wifi.c:2128
vsf_err_t vsf_wifi_radio_set_channel(vsf_wifi_radio_t *radio, uint8_t ch, vsf_wifi_radio_done_t done)
Definition vsf_wifi.c:2191
vsf_err_t vsf_wifi_radio_fini(vsf_wifi_radio_t *radio, vsf_wifi_radio_done_t done)
Definition vsf_wifi.c:2164
struct vsf_wifi_radio_ops_t vsf_wifi_radio_ops_t
vsf_wifi_radio_t * vsf_wifi_radio_from_wifi(vsf_wifi_t *wifi)
Definition vsf_wifi.c:2111
void vsf_wifi_radio_register_rx(vsf_wifi_radio_t *radio, vsf_wifi_radio_rx_cb_t cb, void *param)
Definition vsf_wifi.c:2119
Generated from commit: vsfteam/vsf@ceb53fd