VSF Documented
vsf_wifi_netdrv.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_NETDRV_H__
19#define __VSF_WIFI_NETDRV_H__
20
21/*============================ INCLUDES ======================================*/
22
23#include "./vsf_wifi_cfg.h"
24
25#if VSF_USE_WIFI == ENABLED \
26 && VSF_USE_TCPIP == ENABLED && VSF_USE_LWIP == ENABLED
27
28#include "./vsf_wifi.h"
30
31/*============================ LOGGING HELPERS ===============================*/
32
33#if VSF_WIFI_CFG_NETDRV_LOG_LEVEL >= 1
34# define vsf_wifi_netdrv_trace_error(...) vsf_trace_error(__VA_ARGS__)
35#else
36# define vsf_wifi_netdrv_trace_error(...) ((void)0)
37#endif
38
39#if VSF_WIFI_CFG_NETDRV_LOG_LEVEL >= 2
40# define vsf_wifi_netdrv_trace_info(...) vsf_trace_info(__VA_ARGS__)
41#else
42# define vsf_wifi_netdrv_trace_info(...) ((void)0)
43#endif
44
45#if VSF_WIFI_CFG_NETDRV_LOG_LEVEL >= 4
46# define vsf_wifi_netdrv_trace_debug(...) vsf_trace_info(__VA_ARGS__)
47#else
48# define vsf_wifi_netdrv_trace_debug(...) ((void)0)
49#endif
50
51#if defined(__VSF_WIFI_NETDRV_CLASS_IMPLEMENT)
52# undef __VSF_WIFI_NETDRV_CLASS_IMPLEMENT
53# define __VSF_CLASS_IMPLEMENT__
54#endif
55
56#include "utilities/ooc_class.h"
57
58#ifdef __cplusplus
59extern "C" {
60#endif
61
62/*============================ MACROS ========================================*/
63
64/* Number of inbound frames the bus-context RX hook can stage for the netdrv
65 * worker thread. Each slot holds one fully built Ethernet frame. */
66#ifndef VSF_WIFI_NETDRV_CFG_RX_QUEUE_SIZE
67# define VSF_WIFI_NETDRV_CFG_RX_QUEUE_SIZE 8
68#endif
69
70/* Ethernet frame staging size: 14-byte Ethernet II header + 1500 MTU. */
71#define VSF_WIFI_NETDRV_ETH_FRAME_SIZE (14 + 1500)
72
73/* 802.11 TX frame size: QoS data header(26) + LLC/SNAP(8) + 1500 payload. */
74#define VSF_WIFI_NETDRV_DOT11_FRAME_SIZE (26 + 8 + 1500)
75
76/*============================ MACROFIED FUNCTIONS ===========================*/
77/*============================ TYPES =========================================*/
78
83
85 public_member(
86 implement(vk_netdrv_t)
87 vsf_wifi_t *wifi;
88 )
89 private_member(
90 vsf_eda_t *thread;
91 uint8_t bssid[6]; /* cached on link-up, used as TX RA/addr1 */
92
93 /* Single-producer (bus EDA RX hook) / single-consumer (worker thread)
94 * ring of pre-built Ethernet frames. head is advanced by the worker,
95 * tail by the RX hook; both indices are touched under vsf_protect. */
97 uint8_t rx_head;
98 uint8_t rx_tail;
99
100 /* Event flags raised in bus-EDA context (link up/down, rx ready) and
101 * drained by the worker thread under vsf_protect. */
102 uint8_t pending;
103
104 /* TX scratch (worker/tcpip-thread context only, single-threaded). */
106 )
107};
108
109/*============================ GLOBAL VARIABLES ==============================*/
110
112
113/*============================ PROTOTYPES ====================================*/
114
115/* Wire a wifi-core instance to a netdrv instance and hand it to the lwIP
116 * pnp layer. After this call decrypted RX data frames and link up/down
117 * events from `wifi` are bridged to lwIP; the stack auto-starts DHCP on
118 * link-up via the existing vsf_pnp_on_netdrv_connected hook. `netdrv` must
119 * stay valid for the lifetime of the binding. */
121
122#ifdef __cplusplus
123}
124#endif
125
126#endif // VSF_USE_WIFI && VSF_USE_TCPIP && VSF_USE_LWIP
127#endif // __VSF_WIFI_NETDRV_H__
Definition vsf_netdrv.h:99
Definition vsf_wifi_netdrv.h:84
Definition vsf_eda.h:769
u8 bssid[ETH_ALEN]
Definition ieee80211.h:2
#define vsf_class(__name)
Definition ooc_class.h:52
unsigned short uint16_t
Definition stdint.h:7
unsigned char uint8_t
Definition stdint.h:5
Definition vsf_wifi_netdrv.h:79
uint16_t len
Definition vsf_wifi_netdrv.h:80
uint8_t buf[VSF_WIFI_NETDRV_ETH_FRAME_SIZE]
Definition vsf_wifi_netdrv.h:81
Definition vsf_wifi_priv.h:36
void vsf_wifi_netdrv_start(vk_netdrv_wifi_t *netdrv, vsf_wifi_t *wifi)
Definition vsf_wifi_netdrv.c:411
#define VSF_WIFI_NETDRV_DOT11_FRAME_SIZE
Definition vsf_wifi_netdrv.h:74
#define VSF_WIFI_NETDRV_CFG_RX_QUEUE_SIZE
Definition vsf_wifi_netdrv.h:67
const struct vk_netlink_op_t vk_netdrv_wifi_netlink_op
Definition vsf_wifi_netdrv.c:59
#define VSF_WIFI_NETDRV_ETH_FRAME_SIZE
Definition vsf_wifi_netdrv.h:71
struct vk_netdrv_wifi_rxslot_t vk_netdrv_wifi_rxslot_t
Generated from commit: vsfteam/vsf@d3b40b2