1 /*
2 * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19 #ifndef __OAL_NET_H__
20 #define __OAL_NET_H__
21
22 /* ****************************************************************************
23 1 其他头文件包含
24 **************************************************************************** */
25 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
26 #include <linux/kernel.h>
27 #include <linux/skbuff.h>
28 #include <linux/slab.h>
29 #include <linux/printk.h>
30 #include <linux/in6.h>
31 #include <net/netlink.h>
32
33 #ifndef _PRE_HDF_LINUX
34 #include <net/iw_handler.h>
35 #include <linux/if.h>
36 #include <linux/netdevice.h>
37 #include <net/cfg80211.h>
38 #endif
39
40 #include <linux/etherdevice.h>
41 #include <linux/kobject.h>
42 #include "oal_mm.h"
43 #include "oal_netbuf.h"
44 #endif
45 #include "oal_err_wifi.h"
46 #include "oal_util.h"
47 #include "oal_schedule.h"
48 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
49 #include "oal_netbuf.h"
50 #include "lwip/netif.h"
51 #include "lwip/dhcp.h"
52 #endif
53 #include "wlan_spec_1131h.h"
54 #include "wlan_types.h"
55 #include "net_device.h"
56 #include "hdf_wifi_cmd.h"
57 #include "wifi_mac80211_ops.h"
58 #include "eapol.h"
59 #ifdef __cplusplus
60 #if __cplusplus
61 extern "C" {
62 #endif
63 #endif
64
65 /* ****************************************************************************
66 2 宏定义
67 **************************************************************************** */
68 #define OAL_IF_NAME_SIZE 16
69
70 #define OAL_ASSOC_REQ_IE_OFFSET 28 /* 上报内核关联请求帧偏移量 */
71 #define OAL_ASSOC_RSP_IE_OFFSET 30 /* 上报内核关联响应帧偏移量 */
72 #define OAL_ASSOC_RSP_FIXED_OFFSET 6 /* 关联响应帧帧长FIXED PARAMETERS偏移量 */
73 #define OAL_MAC_ADDR_LEN 6
74 #define OAL_PMKID_LEN 16
75 #define OAL_WPA_KEY_LEN 32
76 #define OAL_WPA_SEQ_LEN 16
77 #define NETLINK_DEV_ERROR 27
78 #define WLAN_DSCP_PRI_SHIFT 2
79 #define WLAN_IP_PRI_SHIFT 5
80 #define WLAN_IPV6_PRIORITY_MASK 0x0FF00000
81 #define WLAN_IPV6_PRIORITY_SHIFT 20
82
83 #define LLC_UI 0x3
84 #define SNAP_LLC_FRAME_LEN 8
85 #define SNAP_LLC_LSAP 0xaa
86
87 #define ORG_CODE_LEN 3
88 #define SNAP_RFC1042_ORGCODE_0 0x00
89 #define SNAP_RFC1042_ORGCODE_1 0x00
90 #define SNAP_RFC1042_ORGCODE_2 0x00
91 #define SNAP_BTEP_ORGCODE_0 0x00
92 #define SNAP_BTEP_ORGCODE_1 0x00
93 #define SNAP_BTEP_ORGCODE_2 0xf8
94
95 #define ETHER_ADDR_LEN MAC_ADDR_SIZE /* length of an Ethernet address */
96 #define IP6_ETHER_ADDR_LEN 16 /* efuse中ipv6 MAC地址大小 */
97 #define ETHER_HDR_LEN 14
98 #define IP_HDR_LEN 20
99
100 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
101 /* DHCP message types */
102 #define DHCP_DISCOVER 1
103 #define DHCP_OFFER 2
104 #define DHCP_REQUEST 3
105 #define DHCP_DECLINE 4
106 #define DHCP_ACK 5
107 #define DHCP_NAK 6
108 #define DHCP_RELEASE 7
109 #define DHCP_INFORM 8
110 #endif
111
112 #define WLAN_CCMP_ENCRYP_LEN 16 /* CCMP加密字节数 */
113 #define ether_is_multicast(_a) (*(_a) & 0x01) /* is address mcast? */
114
115 /* is address bcast? */
116 #define ether_is_broadcast(_a) (((_a)[0] & (_a)[1] & (_a)[2] & (_a)[3] & (_a)[4] & (_a)[5]) == 0xFF)
117 #define WLAN_DATA_VIP_TID WLAN_TIDNO_BCAST
118
119 /* wiphy */
120 #define IEEE80211_HT_MCS_MASK_LEN 10
121
122 /* ICMP codes for neighbour discovery messages */
123 #define OAL_NDISC_NEIGHBOUR_SOLICITATION 135
124 #define OAL_NDISC_NEIGHBOUR_ADVERTISEMENT 136
125
126 #define OAL_ND_OPT_SOURCE_LL_ADDR 1
127 #define OAL_ND_OPT_TARGET_LL_ADDR 2
128 #define OAL_IPV6_ADDR_ANY 0x0000U
129 #define OAL_IPV6_ADDR_MULTICAST 0x0002U
130
131 #define OAL_IPV4_ADDR_SIZE 4
132 #define OAL_IPV6_ADDR_SIZE 16
133 #define OAL_IP_ADDR_MAX_SIZE OAL_IPV6_ADDR_SIZE
134
135 /* IPv4受限广播: 255.255.255.255 , IPv4直接广播: 如192.168.10.255 */
136 #define oal_ipv4_is_broadcast(_a) ((hi_u8)((_a)[3]) == 0xff)
137
138 /* IPv4多播范围: 224.0.0.0--239.255.255.255 */
139 #define oal_ipv4_multicast(_a) ((hi_u8)((_a)[0]) >= 224 && ((hi_u8)((_a)[0]) <= 239))
140
141 /* IPv6组播地址: FFXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX(第一个字节全一) */
142 #define oal_ipv6_is_multicast(_a) ((hi_u8)((_a)[0]) == 0xff)
143
144 /* wiphy */
145 #define OAL_IEEE80211_MAX_SSID_LEN 32 /* 最大SSID长度 */
146
147 #define ICMPV6_NA_OPTION_LEN 8
148
149 /* ether type */
150 #define ETHER_TYPE_RARP 0x8035
151 #define ETHER_TYPE_PAE 0x888e /* EAPOL PAE/802.1x */
152 #define ETHER_TYPE_IP 0x0800 /* IP protocol */
153 #define ETHER_TYPE_AARP 0x80f3 /* Appletalk AARP protocol */
154 #define ETHER_TYPE_IPX 0x8137 /* IPX over DIX protocol */
155 #define ETHER_TYPE_ARP 0x0806 /* ARP protocol */
156 #define ETHER_TYPE_IPV6 0x86dd /* IPv6 */
157 #define ETHER_TYPE_TDLS 0x890d /* TDLS */
158 #define ETHER_TYPE_VLAN 0x8100 /* VLAN TAG protocol */
159 #define ETHER_TYPE_WAI 0x88b4 /* WAI/WAPI */
160 #define ETHER_LLTD_TYPE 0x88D9 /* LLTD */
161 #define ETHER_ONE_X_TYPE 0x888E /* 802.1x Authentication */
162 #define ETHER_TUNNEL_TYPE 0x88bd /* 自定义tunnel协议 */
163 #define ETHER_TYPE_PPP_DISC 0x8863 /* PPPoE discovery messages */
164 #define ETHER_TYPE_PPP_SES 0x8864 /* PPPoE session messages */
165 #define ETHER_TYPE_6LO 0xa0ed /* 6lowpan包头压缩 */
166
167 #define ETH_IP_ADDR_LEN 4 /* length of an Ethernet ip address */
168 #define ETH_SENDER_IP_ADDR_LEN 4 /* length of an Ethernet send ip address */
169 #define ETH_TARGET_IP_ADDR_LEN 4 /* length of an Ethernet target ip address */
170
171 #define oal_netif_running(_pst_net_dev) 0
172
173 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
174 #define OAL_EXCP_DATA_BUF_LEN 64
175
176 /* netlink 相关 */
177 #define oal_nlmsg_space(_len) NLMSG_SPACE(_len)
178 #define oal_netlink_cb(_skb) NETLINK_CB(_skb)
179 #endif
180
181 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
182 #define oal_smp_mb() smp_mb()
183 #else
184 #define oal_smp_mb()
185 #endif
186
187 typedef hi_u32 gfp_t;
188 #define oal_container_of(_member_ptr, _stru_type, _stru_member_name) \
189 container_of(_member_ptr, _stru_type, _stru_member_name)
190
191 #define oal_netdevice_ops(_pst_dev) GET_NET_DEV_IF(_pst_dev)
192
193 #define oal_netdevice_last_rx(_pst_dev) GET_NET_DEV_LAST_RX_TIME(_pst_dev)
194 #define oal_netdevice_mac_addr(_pst_dev) GET_NET_DEV_MAC_ADDR(_pst_dev)
195 #define oal_netdevice_master(_pst_dev) GET_NET_DEV_OWNER(_pst_dev)
196
197
198 #if LINUX_VERSION_CODE >= kernel_version(2, 6, 34) || (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
199 #define oal_netdevice_qdisc(_pst_dev, pst_val) ((_pst_dev)->qdisc = (pst_val))
200 #else
201 #define oal_netdevice_qdisc(_pst_dev, pst_val)
202 #endif
203
204 #define oal_netdevice_wdev(_pst_dev) GET_NET_DEV_CFG80211_WIRELESS(_pst_dev)
205 #define oal_netdevice_headroom(_pst_dev) GET_NET_DEV_HEAD_ROOM(_pst_dev)
206 #define oal_netdevice_tailroom(_pst_dev) GET_NET_DEV_TAIL_ROOM(_pst_dev)
207 #define oal_netdevice_flags(_pst_dev) GET_NET_DEV_FLAGS(_pst_dev)
208 #define oal_netdevice_watchdog_timeo(_pst_dev) GET_NET_DEV_WATCHDOG_TIME(_pst_dev)
209 #define oal_net_dev_priv(_pst_dev) GET_NET_DEV_PRIV(_pst_dev)
210 #define oal_net_dev_wireless_dev(_pst_dev) GET_NET_DEV_CFG80211_WIRELESS(_pst_dev)
211 #define oal_netdevice_specical_proc_priv(_pst_dev) GET_NET_DEV_SPECIAL_PROC_PRIV(_pst_dev)
212 #define NL80211_RRF_NO_OFDM (1<<0)
213 #define NL80211_RRF_DFS (1<<4)
214 #define OAL_NL80211_MAX_NR_CIPHER_SUITES 5
215 #define OAL_NL80211_MAX_NR_AKM_SUITES 2
216 #define IEEE80211_MAX_SSID_LEN 32
217 #define NL80211_MAX_NR_CIPHER_SUITES 5
218 #define NL80211_MAX_NR_AKM_SUITES 2
219 #define NL80211_RRF_NO_OUTDOOR (1<<3)
220 #ifndef ETH_ALEN
221 #define ETH_ALEN 6
222 #endif
223 #ifndef GFP_ATOMIC
224 #define GFP_ATOMIC 0
225 #endif
226
227 #define OAL_IFF_RUNNING NET_DEVICE_IFF_RUNNING
228 #define OAL_SIOCIWFIRSTPRIV 0x8BE0
229
230 /* iw_priv参数类型OAL封装 */
231 #define OAL_IW_PRIV_TYPE_BYTE 0x1000 /* Char as number */
232 #define OAL_IW_PRIV_TYPE_CHAR 0x2000 /* Char as character */
233 #define OAL_IW_PRIV_TYPE_INT 0x4000 /* 32 bits integer */
234 #define OAL_IW_PRIV_TYPE_ADDR 0x6000 /* struct sockaddr */
235 #define OAL_IW_PRIV_SIZE_FIXED 0x0800 /* Variable or fixed number of args */
236
237 #define OAL_VLAN_PRIO_SHIFT 13
238
239 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
240 #define OAL_IPPROTO_UDP IPPROTO_UDP /* User Datagram Protocot */
241 #define OAL_IPPROTO_ICMPV6 IPPROTO_ICMPV6 /* ICMPv6 */
242 #else
243 #define OAL_IPPROTO_UDP 17 /* User Datagram Protocot */
244 #define OAL_IPPROTO_ICMPV6 58 /* ICMPv6 */
245 #endif
246 #define OAL_INIT_NET init_net
247 #define OAL_THIS_MODULE THIS_MODULE
248 #define OAL_IP4_ADDR IP4_ADDR
249
250 #define HI_MAX_SCAN_CHANNELS 14
251 #define WLAN_SA_QUERY_TR_ID_LEN 2
252
253 #define oal_is_broadcast_ether_addr(a) (((a)[0] & (a)[1] & (a)[2] & (a)[3] & (a)[4] & (a)[5]) == 0xff)
254
255 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
256 #define OAL_EXCP_DATA_BUF_LEN 64
257 #endif
258
259 #define oal_ll_allocated_space(dev) \
260 ((((dev)->hardHeaderLen + (dev)->neededHeadRoom + (dev)->neededTailRoom) & ~(15)) + 16)
261
262 /* 管制域相关结构体定义 */
263 #define mhz_to_khz(freq) ((freq) * 1000)
264 #define dbi_to_mbi(gain) ((gain) * 100)
265 #define dbm_to_mbm(gain) ((gain) * 100)
266
267 #define reg_rule(start, end, bw, gain, eirp, reg_flags) { \
268 .freq_range.start_freq_khz = mhz_to_khz(start), \
269 .freq_range.end_freq_khz = mhz_to_khz(end), \
270 .freq_range.max_bandwidth_khz = mhz_to_khz(bw), \
271 .power_rule.max_antenna_gain = dbi_to_mbi(gain), \
272 .power_rule.max_eirp = dbm_to_mbm(eirp), \
273 .flags = (reg_flags), \
274 }
275
276 /* ****************************************************************************
277 3 枚举定义
278 **************************************************************************** */
279 /* DHCP options */
280 enum dhcp_opt {
281 DHCP_OPT_PAD = 0,
282 DHCP_OPT_SUBNETMASK = 1,
283 DHCP_OPT_ROUTER = 3,
284 DHCP_OPT_DNSSERVER = 6,
285 DHCP_OPT_HOSTNAME = 12,
286 DHCP_OPT_DNSDOMAIN = 15,
287 DHCP_OPT_MTU = 26,
288 DHCP_OPT_BROADCAST = 28,
289 DHCP_OPT_STATICROUTE = 33,
290 DHCP_OPT_NISDOMAIN = 40,
291 DHCP_OPT_NISSERVER = 41,
292 DHCP_OPT_NTPSERVER = 42,
293 DHCP_OPT_VENDOR = 43,
294 DHCP_OPT_IPADDRESS = 50,
295 DHCP_OPT_LEASETIME = 51,
296 DHCP_OPT_OPTIONSOVERLOADED = 52,
297 DHCP_OPT_MESSAGETYPE = 53,
298 DHCP_OPT_SERVERID = 54,
299 DHCP_OPT_PARAMETERREQUESTLIST = 55,
300 DHCP_OPT_MESSAGE = 56,
301 DHCP_OPT_MAXMESSAGESIZE = 57,
302 DHCP_OPT_RENEWALTIME = 58,
303 DHCP_OPT_REBINDTIME = 59,
304 DHCP_OPT_VENDORCLASSID = 60,
305 DHCP_OPT_CLIENTID = 61,
306 DHCP_OPT_USERCLASS = 77, /* RFC 3004 */
307 DHCP_OPT_FQDN = 81,
308 DHCP_OPT_DNSSEARCH = 119, /* RFC 3397 */
309 DHCP_OPT_CSR = 121, /* RFC 3442 */
310 DHCP_OPT_SIXRD = 212, /* RFC 5969 */
311 DHCP_OPT_MSCSR = 249, /* MS code for RFC 3442 */
312 DHCP_OPT_END = 255
313 };
314
315 enum nl80211_iftype {
316 NL80211_IFTYPE_UNSPECIFIED,
317 NL80211_IFTYPE_ADHOC,
318 NL80211_IFTYPE_STATION,
319 NL80211_IFTYPE_AP,
320 NL80211_IFTYPE_AP_VLAN,
321 NL80211_IFTYPE_WDS,
322 NL80211_IFTYPE_MONITOR,
323 NL80211_IFTYPE_MESH_POINT,
324 NL80211_IFTYPE_P2P_CLIENT,
325 NL80211_IFTYPE_P2P_GO,
326 NL80211_IFTYPE_P2P_DEVICE,
327 /* keep last */
328 NUM_NL80211_IFTYPES,
329 NL80211_IFTYPE_MAX = NUM_NL80211_IFTYPES - 1
330 };
331
332 #define OAL_NETDEV_TX_OK NETDEV_TX_OK
333 #define OAL_NETDEV_TX_BUSY NETDEV_TX_BUSY
334 #define OAL_NETDEV_TX_LOCKED NETDEV_TX_LOCKED
335
336 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
337 typedef NetDevTxResult oal_net_dev_tx_enum;
338 #elif (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
339 typedef int32_t oal_net_dev_tx_enum;
340 #endif
341
342 typedef hi_u8 ieee80211_band_uint8;
343
344 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX)
345
346 typedef hi_u8 oal_nl80211_channel_type_uint8;
347
348 typedef hi_u8 nl80211_iftype_uint8;
349 #endif /* #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX) */
350
351 typedef enum {
352 NETIF_FLOW_CTRL_OFF, /* stop flow_ctrl, continue to transfer data to driver */
353 NETIF_FLOW_CTRL_ON, /* start flow_ctrl, stop transferring data to driver */
354 NETIF_FLOW_CTRL_BUTT
355 } netif_flow_ctrl_enum;
356 typedef hi_u8 netif_flow_ctrl_enum_uint8;
357
358 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
359 enum cfg80211_signal_type {
360 CFG80211_SIGNAL_TYPE_NONE,
361 CFG80211_SIGNAL_TYPE_MBM,
362 CFG80211_SIGNAL_TYPE_UNSPEC,
363 };
364 #endif
365
366 enum station_info_flags {
367 STATION_INFO_INACTIVE_TIME = 1 << 0,
368 STATION_INFO_RX_BYTES = 1 << 1,
369 STATION_INFO_TX_BYTES = 1 << 2,
370 STATION_INFO_LLID = 1 << 3,
371 STATION_INFO_PLID = 1 << 4,
372 STATION_INFO_PLINK_STATE = 1 << 5,
373 STATION_INFO_SIGNAL = 1 << 6,
374 STATION_INFO_TX_BITRATE = 1 << 7,
375 STATION_INFO_RX_PACKETS = 1 << 8,
376 STATION_INFO_TX_PACKETS = 1 << 9,
377 STATION_INFO_TX_RETRIES = 1 << 10,
378 STATION_INFO_TX_FAILED = 1 << 11,
379 STATION_INFO_RX_DROP_MISC = 1 << 12,
380 STATION_INFO_SIGNAL_AVG = 1 << 13,
381 STATION_INFO_RX_BITRATE = 1 << 14,
382 STATION_INFO_BSS_PARAM = 1 << 15,
383 STATION_INFO_CONNECTED_TIME = 1 << 16,
384 STATION_INFO_ASSOC_REQ_IES = 1 << 17,
385 STATION_INFO_STA_FLAGS = 1 << 18,
386 STATION_INFO_BEACON_LOSS_COUNT = 1 << 19,
387 STATION_INFO_T_OFFSET = 1 << 20,
388 STATION_INFO_LOCAL_PM = 1 << 21,
389 STATION_INFO_PEER_PM = 1 << 22,
390 STATION_INFO_NONPEER_PM = 1 << 23,
391 STATION_INFO_RX_BYTES64 = 1 << 24,
392 STATION_INFO_TX_BYTES64 = 1 << 25,
393 };
394
395 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX)
396
397 enum nl80211_channel_type {
398 NL80211_CHAN_NO_HT,
399 NL80211_CHAN_HT20,
400 NL80211_CHAN_HT40MINUS,
401 NL80211_CHAN_HT40PLUS
402 };
403
404 typedef hi_u8 oal_nl80211_auth_type_enum_uint8;
405 typedef enum nl80211_channel_type oal_nl80211_channel_type;
406
407 typedef enum nl80211_mfp {
408 NL80211_MFP_NO,
409 NL80211_MFP_REQUIRED,
410 } oal_nl80211_mfp_enum;
411 typedef hi_u8 oal_nl80211_mfp_enum_uint8;
412
413 enum wiphy_flags {
414 WIPHY_FLAG_CUSTOM_REGULATORY = bit(0),
415 WIPHY_FLAG_STRICT_REGULATORY = bit(1),
416 WIPHY_FLAG_DISABLE_BEACON_HINTS = bit(2),
417 WIPHY_FLAG_NETNS_OK = bit(3),
418 WIPHY_FLAG_PS_ON_BY_DEFAULT = bit(4),
419 WIPHY_FLAG_4ADDR_AP = bit(5),
420 WIPHY_FLAG_4ADDR_STATION = bit(6),
421 WIPHY_FLAG_CONTROL_PORT_PROTOCOL = bit(7),
422 WIPHY_FLAG_IBSS_RSN = bit(8),
423 WIPHY_FLAG_MESH_AUTH = bit(10),
424 WIPHY_FLAG_SUPPORTS_SCHED_SCAN = bit(11),
425 /* use hole at 12 */
426 WIPHY_FLAG_SUPPORTS_FW_ROAM = bit(13),
427 WIPHY_FLAG_AP_UAPSD = bit(14),
428 WIPHY_FLAG_SUPPORTS_TDLS = bit(15),
429 WIPHY_FLAG_TDLS_EXTERNAL_SETUP = bit(16),
430 WIPHY_FLAG_HAVE_AP_SME = bit(17),
431 WIPHY_FLAG_REPORTS_OBSS = bit(18),
432 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD = bit(19),
433 WIPHY_FLAG_OFFCHAN_TX = bit(20),
434 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL = bit(21),
435 };
436
437 enum nl80211_mesh_power_mode {
438 NL80211_MESH_POWER_UNKNOWN,
439 NL80211_MESH_POWER_ACTIVE,
440 NL80211_MESH_POWER_LIGHT_SLEEP,
441 NL80211_MESH_POWER_DEEP_SLEEP,
442
443 __NL80211_MESH_POWER_AFTER_LAST,
444 NL80211_MESH_POWER_MAX = __NL80211_MESH_POWER_AFTER_LAST - 1
445 };
446
447 typedef enum nl80211_key_type {
448 NL80211_KEYTYPE_GROUP,
449 NL80211_KEYTYPE_PAIRWISE,
450 NL80211_KEYTYPE_PEERKEY,
451 NUM_NL80211_KEYTYPES
452 } oal_nl80211_key_type;
453
454 enum rate_info_flags {
455 RATE_INFO_FLAGS_MCS = bit(0),
456 RATE_INFO_FLAGS_VHT_MCS = bit(1),
457 RATE_INFO_FLAGS_40_MHZ_WIDTH = bit(2),
458 RATE_INFO_FLAGS_80_MHZ_WIDTH = bit(3),
459 RATE_INFO_FLAGS_80P80_MHZ_WIDTH = bit(4),
460 RATE_INFO_FLAGS_160_MHZ_WIDTH = bit(5),
461 RATE_INFO_FLAGS_SHORT_GI = bit(6),
462 RATE_INFO_FLAGS_60G = bit(7),
463 };
464 #endif /* #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX) */
465
466 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION) && !defined(_PRE_HDF_LINUX)
467 typedef hi_u8 oal_nl80211_channel_type_uint8;
468 typedef hi_u8 oal_nl80211_mfp_enum_uint8;
469 typedef enum nl80211_channel_type oal_nl80211_channel_type;
470 typedef enum nl80211_iftype enum_nl80211_iftype;
471 typedef hi_u8 nl80211_iftype_uint8;
472 typedef hi_u8 oal_nl80211_auth_type_enum_uint8;
473 typedef enum nl80211_key_type oal_nl80211_key_type;
474 #endif
475
476 typedef enum {
477 OAL_PASSIVE_SCAN = 0,
478 OAL_ACTIVE_SCAN = 1,
479 OAL_SCAN_BUTT
480 } oal_scan_enum;
481
482 /* 内核下发的扫描频段 */
483 typedef enum {
484 OAL_SCAN_2G_BAND = 1,
485 OAL_SCAN_5G_BAND = 2,
486 OAL_SCAN_ALL_BAND = 3,
487
488 OAL_SCAN_BAND_BUTT
489 } oal_scan_band_enum;
490
491 /* hostapd 下发私有命令 */
492 enum hwifi_ioctl_cmd {
493 /*
494 IOCTL_CMD的起始值由0修改为0x8EE0,修改原因:51 WiFi模块和类似于dhdutil之类的其他模块共用同一个ioctl通道,
495 而51命令的枚举值从0开始,其他模块下发的ioctl命令也包含从0开始的这部分,这样就会同时“组播”到自己的模块和WiFi模块,
496 从而对WiFi模块的功能产生影响。所以将51 WiFi模块命令的枚举值调整到0x8EE0起,便规避了其他模块命令的影响。
497 */
498 HWIFI_IOCTL_CMD_GET_STA_ASSOC_REQ_IE = 0x8EE0, /* get sta assocate request ie */
499 HWIFI_IOCTL_CMD_SET_AP_AUTH_ALG, /* set auth alg to driver */
500 HWIFI_IOCTL_CMD_SET_COUNTRY, /* 设置国家码 */
501 HWIFI_IOCTL_CMD_SET_SSID, /* 设置ssid */
502 HWIFI_IOCTL_CMD_SET_MAX_USER, /* 设置最大用户数 */
503 HWIFI_IOCTL_CMD_SET_FREQ, /* 设置频段 */
504 HWIFI_IOCTL_CMD_SET_WPS_IE, /* 设置AP WPS 信息元素 */
505 HWIFI_IOCTL_CMD_PRIV_CONNECT, /* linux-2.6.30 sta发起connect */
506 HWIFI_IOCTL_CMD_PRIV_DISCONNECT, /* linux-2.6.30 sta发起disconnect */
507 HWIFI_IOCTL_CMD_SET_FRAG, /* 设置分片门限值 */
508 HWIFI_IOCTL_CMD_SET_RTS, /* 设置RTS 门限值 */
509
510 HWIFI_IOCTL_CMD_NUM
511 };
512
513 enum app_ie_type {
514 OAL_APP_BEACON_IE = 1,
515 OAL_APP_PROBE_REQ_IE = 1,
516 OAL_APP_PROBE_RSP_IE = 2,
517 OAL_APP_ASSOC_REQ_IE = 3,
518 OAL_APP_ASSOC_RSP_IE = 4,
519 OAL_APP_IE_NUM
520 };
521 typedef hi_u8 en_app_ie_type_uint8;
522
523 typedef enum _wlan_net_queue_type_ {
524 WLAN_HI_QUEUE = 0,
525 WLAN_NORMAL_QUEUE,
526
527 WLAN_TCP_DATA_QUEUE,
528 WLAN_TCP_ACK_QUEUE,
529
530 WLAN_UDP_BK_QUEUE,
531 WLAN_UDP_BE_QUEUE,
532 WLAN_UDP_VI_QUEUE,
533 WLAN_UDP_VO_QUEUE,
534
535 WLAN_NET_QUEUE_BUTT
536 } wlan_net_queue_type;
537 typedef struct NetDevice oal_net_device_stru;
538 /* ****************************************************************************
539 4 结构体定义
540 **************************************************************************** */
541 typedef struct ieee80211_regdomain oal_ieee80211_regdomain_stru;
542
543 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
544 typedef hi_u8 oal_mem_state_enum_uint8;
545 typedef struct sock oal_sock_stru;
546 typedef struct module oal_module_stru;
547 typedef struct nlmsghdr oal_nlmsghdr_stru;
548
549 typedef struct kobj_uevent_env oal_kobj_uevent_env_stru;
550 struct dev_excp_globals {
551 oal_sock_stru* nlsk;
552 hi_u8 mode;
553 hi_u8* data;
554 hi_u32 usepid;
555 };
556
557 struct dev_netlink_msg_hdr_stru {
558 hi_u32 cmd;
559 hi_u32 len;
560 };
561 #endif /* #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION) */
562
563 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX)
564 #define ieee80211_band Ieee80211Band
565
566 struct ieee80211_hdr {
567 hi_u16 frame_control;
568 hi_u16 duration_id;
569 hi_u8 addr1[OAL_MAC_ADDR_LEN];
570 hi_u8 addr2[OAL_MAC_ADDR_LEN];
571 hi_u8 addr3[OAL_MAC_ADDR_LEN];
572 hi_u16 seq_ctrl;
573 /* followed by 'u8 addr4[6];' if ToDS and FromDS is set in data frame */
574 };
575
576 struct ieee80211_freq_range {
577 hi_u32 start_freq_khz;
578 hi_u32 end_freq_khz;
579 hi_u32 max_bandwidth_khz;
580 };
581
582 struct ieee80211_power_rule {
583 hi_u32 max_antenna_gain;
584 hi_u32 max_eirp;
585 };
586
587 struct ieee80211_reg_rule {
588 struct ieee80211_freq_range freq_range;
589 struct ieee80211_power_rule power_rule;
590 hi_u32 flags;
591 };
592
593 struct ieee80211_msrment_ie {
594 hi_u8 token;
595 hi_u8 mode;
596 hi_u8 type;
597 hi_u8 request[0];
598 };
599
600 struct ieee80211_ext_chansw_ie {
601 hi_u8 mode;
602 hi_u8 new_operating_class;
603 hi_u8 new_ch_num;
604 hi_u8 count;
605 };
606
607 typedef struct ieee80211_mgmt {
608 hi_u16 frame_control;
609 hi_u16 duration;
610 hi_u8 da[6]; /* 6: SIZE(0..6) */
611 hi_u8 sa[6]; /* 6: SIZE(0..6) */
612 hi_u8 bssid[6]; /* 6: SIZE(0..6) */
613 hi_u16 seq_ctrl;
614 union {
615 struct {
616 hi_u16 auth_alg;
617 hi_u16 auth_transaction;
618 hi_u16 status_code;
619 /* possibly followed by Challenge text */
620 hi_u8 variable[0];
621 } auth;
622 struct {
623 hi_u16 reason_code;
624 } deauth;
625 struct {
626 hi_u16 capab_info;
627 hi_u16 listen_interval;
628 /* followed by SSID and Supported rates */
629 hi_u8 variable[0];
630 } assoc_req;
631 struct {
632 hi_u16 capab_info;
633 hi_u16 status_code;
634 hi_u16 aid;
635 /* followed by Supported rates */
636 hi_u8 variable[0];
637 } assoc_resp, reassoc_resp;
638 struct {
639 hi_u16 capab_info;
640 hi_u16 listen_interval;
641 hi_u8 current_ap[6]; /* 6: SIZE(0..6) */
642 /* followed by SSID and Supported rates */
643 hi_u8 variable[0];
644 } reassoc_req;
645 struct {
646 hi_u16 reason_code;
647 } disassoc;
648 struct {
649 hi_u64 timestamp;
650 hi_u16 beacon_int;
651 hi_u16 capab_info;
652 /* followed by some of SSID, Supported rates,
653 * FH Params, DS Params, CF Params, IBSS Params, TIM */
654 hi_u8 variable[4]; /* 4: FH Params, DS Params, CF Params, IBSS Params */
655 } beacon;
656 struct {
657 hi_u64 timestamp;
658 hi_u16 beacon_int;
659 hi_u16 capab_info;
660 /* followed by some of SSID, Supported rates,
661 * FH Params, DS Params, CF Params, IBSS Params */
662 hi_u8 variable[4]; /* 4: FH Params, DS Params, CF Params, IBSS Params */
663 } probe_resp;
664 struct {
665 hi_u8 category;
666 union {
667 struct {
668 hi_u8 action_code;
669 hi_u8 dialog_token;
670 hi_u8 status_code;
671 hi_u8 variable[0];
672 } wme_action;
673 struct {
674 hi_u8 action_code;
675 hi_u8 variable[0];
676 } chan_switch;
677 struct {
678 hi_u8 action_code;
679 struct ieee80211_ext_chansw_ie data;
680 hi_u8 variable[0];
681 } ext_chan_switch;
682 struct {
683 hi_u8 action_code;
684 hi_u8 dialog_token;
685 hi_u8 element_id;
686 hi_u8 length;
687 struct ieee80211_msrment_ie msr_elem;
688 } measurement;
689 struct {
690 hi_u8 action_code;
691 hi_u8 dialog_token;
692 hi_u16 capab;
693 hi_u16 timeout;
694 hi_u16 start_seq_num;
695 } addba_req;
696 struct {
697 hi_u8 action_code;
698 hi_u8 dialog_token;
699 hi_u16 status;
700 hi_u16 capab;
701 hi_u16 timeout;
702 } addba_resp;
703 struct {
704 hi_u8 action_code;
705 hi_u8 resv;
706 hi_u16 params;
707 hi_u16 reason_code;
708 } delba;
709 struct {
710 hi_u8 action_code;
711 hi_u8 variable[0];
712 } self_prot;
713 struct {
714 hi_u8 action_code;
715 hi_u8 variable[0];
716 } mesh_action;
717 struct {
718 hi_u8 action;
719 hi_u8 trans_id[WLAN_SA_QUERY_TR_ID_LEN];
720 } sa_query;
721 struct {
722 hi_u8 action;
723 hi_u8 smps_control;
724 } ht_smps;
725 struct {
726 hi_u8 action_code;
727 hi_u8 chanwidth;
728 } ht_notify_cw;
729 struct {
730 hi_u8 action_code;
731 hi_u8 dialog_token;
732 hi_u16 capability;
733 hi_u8 variable[0];
734 } tdls_discover_resp;
735 struct {
736 hi_u8 action_code;
737 hi_u8 operating_mode;
738 } vht_opmode_notif;
739 } u;
740 } action;
741 } u;
742 } oal_ieee80211_mgmt;
743
744
745 struct ieee80211_vht_mcs_info {
746 hi_u16 rx_mcs_map;
747 hi_u16 rx_highest;
748 hi_u16 tx_mcs_map;
749 hi_u16 tx_highest;
750 };
751
752 enum nl80211_hidden_ssid {
753 NL80211_HIDDEN_SSID_NOT_IN_USE,
754 NL80211_HIDDEN_SSID_ZERO_LEN,
755 NL80211_HIDDEN_SSID_ZERO_CONTENTS
756 };
757
758 struct ieee80211_mcs_info {
759 hi_u8 rx_mask[IEEE80211_HT_MCS_MASK_LEN];
760 hi_u16 rx_highest;
761 hi_u8 tx_params;
762 hi_u8 reserved[3]; /* 3: bytes保留字段 */
763 };
764
765 struct ieee80211_ht_cap {
766 /* 16 bytes MCS information */
767 struct ieee80211_mcs_info mcs;
768 hi_u32 tx_bf_cap_info;
769 hi_u16 cap_info;
770 hi_u16 extended_ht_cap_info;
771 hi_u8 antenna_selection_info;
772 hi_u8 ampdu_params_info;
773 hi_u8 resv[2]; /* 2: bytes保留字段 */
774 };
775
776 struct ieee80211_vht_cap {
777 hi_u32 vht_cap_info;
778 struct ieee80211_vht_mcs_info supp_mcs;
779 };
780
781 typedef struct cfg80211_beacon_data {
782 const hi_u8 *head, *tail;
783 const hi_u8 *beacon_ies;
784 const hi_u8 *proberesp_ies;
785 const hi_u8 *assocresp_ies;
786 const hi_u8 *probe_resp;
787
788 size_t head_len, tail_len;
789 size_t beacon_ies_len;
790 size_t proberesp_ies_len;
791 size_t assocresp_ies_len;
792 size_t probe_resp_len;
793 } oal_beacon_data_stru;
794
795 struct oal_mac_address {
796 hi_u8 addr[ETH_ALEN];
797 };
798
799 enum nl80211_acl_policy {
800 NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED,
801 NL80211_ACL_POLICY_DENY_UNLESS_LISTED,
802 };
803
804 enum nl80211_auth_type {
805 NL80211_AUTHTYPE_OPEN_SYSTEM,
806 NL80211_AUTHTYPE_SHARED_KEY,
807 NL80211_AUTHTYPE_FT,
808 NL80211_AUTHTYPE_NETWORK_EAP,
809 NL80211_AUTHTYPE_SAE,
810 __NL80211_AUTHTYPE_NUM,
811 NL80211_AUTHTYPE_MAX = __NL80211_AUTHTYPE_NUM - 1,
812 NL80211_AUTHTYPE_AUTOMATIC
813 };
814
815 struct cfg80211_acl_data {
816 enum nl80211_acl_policy acl_policy;
817 hi_s32 n_acl_entries;
818
819 /* Keep it last */
820 struct oal_mac_address mac_addrs[];
821 };
822
823 typedef struct ieee80211_channel {
824 enum ieee80211_band band;
825 hi_u16 center_freq;
826 hi_u16 hw_value;
827 hi_u32 flags;
828 hi_s32 max_antenna_gain;
829 hi_s32 max_power;
830 hi_bool beacon_found;
831 hi_u8 resv[3]; /* 3: bytes保留字段 */
832 hi_u32 orig_flags;
833 hi_s32 orig_mag;
834 hi_s32 orig_mpwr;
835 } oal_ieee80211_channel;
836
837 typedef struct cfg80211_chan_def {
838 oal_ieee80211_channel *chan;
839 oal_nl80211_channel_type width;
840 hi_s32 center_freq1;
841 hi_s32 center_freq2;
842 } oal_cfg80211_chan_def;
843
844 typedef struct cfg80211_ap_settings {
845 struct cfg80211_chan_def chandef;
846 struct cfg80211_beacon_data beacon;
847
848 hi_s32 beacon_interval;
849 hi_s32 dtim_period;
850 const hi_u8* ssid;
851 size_t ssid_len;
852
853 enum nl80211_hidden_ssid hidden_ssid;
854 enum nl80211_auth_type auth_type;
855 struct CryptoSettings crypto;
856
857 hi_s32 inactivity_timeout;
858 hi_bool privacy;
859 hi_bool p2p_opp_ps;
860 hi_u8 p2p_ctwindow;
861 hi_bool radar_required;
862
863 const struct cfg80211_acl_data *acl;
864 } oal_ap_settings_stru;
865
866 struct cfg80211_ssid {
867 hi_u8 ssid[IEEE80211_MAX_SSID_LEN];
868 hi_u8 ssid_len;
869 hi_u8 resv[3]; /* reserve 3byte */
870 };
871
872 struct cfg80211_match_set {
873 struct cfg80211_ssid ssid;
874 hi_s32 rssi_thold;
875 };
876
877 typedef struct cfg80211_sched_scan_request {
878 struct cfg80211_ssid* ssids;
879 hi_s32 n_ssids;
880 hi_u32 n_channels;
881 hi_u32 interval;
882 const hi_u8* ie;
883 size_t ie_len;
884 hi_u32 flags;
885 struct cfg80211_match_set* match_sets;
886 hi_s32 n_match_sets;
887 hi_s32 min_rssi_thold;
888 hi_s32 rssi_thold; /* just for backward compatible */
889
890 /* internal */
891 struct wiphy* wiphy;
892 struct oal_net_device_stru* dev;
893 hi_u32 scan_start;
894 /* keep last */
895 struct ieee80211_channel* channels[0];
896 } oal_cfg80211_sched_scan_request_stru;
897
898 typedef struct cfg80211_mgmt_tx_params {
899 struct Ieee80211Channel *chan;
900 bool offchan;
901 uint32_t wait;
902 const uint8_t *buf;
903 size_t len;
904 bool no_cck;
905 bool dont_wait_for_ack;
906 int32_t n_csa_offsets;
907 const uint16_t *csa_offsets;
908 } cfg80211_mgmt_tx_params;
909
910 #elif (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
911 typedef struct ieee80211_mgmt oal_ieee80211_mgmt;
912 typedef struct cfg80211_beacon_data oal_beacon_data_stru;
913 typedef struct ieee80211_channel oal_ieee80211_channel;
914 typedef struct cfg80211_ap_settings oal_ap_settings_stru;
915 typedef struct bss_parameters oal_bss_parameters;
916 typedef struct ieee80211_rate oal_ieee80211_rate;
917 typedef struct ieee80211_sta_ht_cap oal_ieee80211_sta_ht_cap;
918 typedef struct ieee80211_supported_band oal_ieee80211_supported_band;
919 typedef struct wireless_dev oal_wireless_dev;
920 typedef struct rate_info oal_rate_info_stru;
921 typedef struct vif_params oal_vif_params_stru;
922 typedef struct cfg80211_ssid oal_cfg80211_ssid_stru;
923 typedef struct station_parameters oal_station_parameters_stru;
924 typedef struct cfg80211_mgmt_tx_params oal_cfg80211_mgmt_tx_params_stru;
925 //typedef struct station_del_parameters oal_station_del_parameters_stru;
926 #endif /* #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX) */
927
928 typedef struct StationDelParameters oal_station_del_parameters_stru;
929
930 typedef struct oal_cpu_usage_stat {
931 hi_u64 ull_user;
932 hi_u64 ull_nice;
933 hi_u64 ull_system;
934 hi_u64 ull_softirq;
935 hi_u64 ull_irq;
936 hi_u64 ull_idle;
937 hi_u64 ull_iowait;
938 hi_u64 ull_steal;
939 hi_u64 ull_guest;
940 } oal_cpu_usage_stat_stru;
941
942 struct oal_ether_header {
943 hi_u8 auc_ether_dhost[ETHER_ADDR_LEN];
944 hi_u8 auc_ether_shost[ETHER_ADDR_LEN];
945 hi_u16 us_ether_type;
946 } __OAL_DECLARE_PACKED;
947
948 typedef struct oal_ether_header oal_ether_header_stru;
949
950 typedef IfReq oal_ifreq_stru;
951
952 typedef struct {
953 hi_u32 handle;
954 } oal_qdisc_stru;
955
956 /* iw_handler_def结构体封装 */
957 typedef struct {
958 hi_u16 cmd; /* Wireless Extension command */
959 hi_u16 flags; /* More to come ;-) */
960 } oal_iw_request_info_stru;
961
962 typedef struct {
963 hi_void *pointer; /* Pointer to the data (in user space) */
964 hi_u16 length; /* number of fields or size in bytes */
965 hi_u16 flags; /* Optional params */
966 } oal_iw_point_stru;
967
968 typedef struct {
969 hi_s32 value; /* The value of the parameter itself */
970 hi_u8 fixed; /* Hardware should not use auto select */
971 hi_u8 disabled; /* Disable the feature */
972 hi_u16 flags; /* Various specific flags (if any) */
973 } oal_iw_param_stru;
974
975 typedef struct {
976 hi_s32 m; /* Mantissa */
977 hi_s16 e; /* Exponent */
978 hi_u8 i; /* List index (when in range struct) */
979 hi_u8 flags; /* Flags (fixed/auto) */
980 } oal_iw_freq_stru;
981
982 typedef struct {
983 hi_u8 qual; /* link quality (%retries, SNR, %missed beacons or better...) */
984 hi_u8 level; /* signal level (dBm) */
985 hi_u8 noise; /* noise level (dBm) */
986 hi_u8 updated; /* Flags to know if updated */
987 } oal_iw_quality_stru;
988
989 typedef struct {
990 hi_u16 sa_family; /* address family, AF_xxx */
991 hi_u8 sa_data[14]; /* 14 bytes of protocol address */
992 } oal_sockaddr_stru;
993
994 typedef union {
995 /* Config - generic */
996 hi_char name[OAL_IF_NAME_SIZE];
997 oal_iw_point_stru essid; /* Extended network name */
998 oal_iw_param_stru nwid; /* network id (or domain - the cell) */
999 oal_iw_freq_stru freq; /* frequency or channel : * 0-1000 = channel * > 1000 = frequency in Hz */
1000 oal_iw_param_stru sens; /* signal level threshold */
1001 oal_iw_param_stru bitrate; /* default bit rate */
1002 oal_iw_param_stru txpower; /* default transmit power */
1003 oal_iw_param_stru rts; /* RTS threshold threshold */
1004 oal_iw_param_stru frag; /* Fragmentation threshold */
1005 hi_u32 mode; /* Operation mode */
1006 oal_iw_param_stru retry; /* Retry limits & lifetime */
1007 oal_iw_point_stru encoding; /* Encoding stuff : tokens */
1008 oal_iw_param_stru power; /* PM duration/timeout */
1009 oal_iw_quality_stru qual; /* Quality part of statistics */
1010 oal_sockaddr_stru ap_addr; /* Access point address */
1011 oal_sockaddr_stru addr; /* Destination address (hw/mac) */
1012 oal_iw_param_stru param; /* Other small parameters */
1013 oal_iw_point_stru data; /* Other large parameters */
1014 } oal_iwreq_data_union;
1015 void OalInitSpecialProcPriv(oal_net_device_stru *netdev);
1016 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX)
1017 typedef hi_u32 (*oal_iw_handler)(oal_net_device_stru* dev, oal_iw_request_info_stru* info,
1018 oal_iwreq_data_union* wrqu, hi_s8* extra);
1019 #elif (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
1020 typedef iw_handler oal_iw_handler;
1021 #endif
1022 typedef hi_u8 en_cfg80211_signal_type_uint8;
1023
1024 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX)
1025 /* 此结构体成员命名是为了保持跟linux一致 */
1026 typedef struct ieee80211_rate oal_ieee80211_rate;
1027 typedef struct ieee80211_sta_ht_cap oal_ieee80211_sta_ht_cap;
1028
1029 typedef struct ieee80211_rate {
1030 hi_u32 flags;
1031 hi_u16 bitrate;
1032 hi_u16 hw_value;
1033 hi_u16 hw_value_short;
1034 hi_u8 rsv[2]; /* 2: bytes保留字段 */
1035 } oal_ieee80211_rate;
1036
1037 typedef struct ieee80211_sta_ht_cap {
1038 hi_u16 cap; /* use IEEE80211_HT_CAP_ */
1039 hi_u8 ht_supported;
1040 hi_u8 ampdu_factor;
1041 hi_u8 ampdu_density;
1042 hi_u8 auc_rsv[3]; /* 3: bytes保留字段 */
1043 struct ieee80211_mcs_info mcs;
1044 } oal_ieee80211_sta_ht_cap;
1045
1046 typedef struct ieee80211_supported_band {
1047 oal_ieee80211_channel* channels;
1048 oal_ieee80211_rate* bitrates;
1049 enum ieee80211_band band;
1050 hi_s32 n_channels;
1051 hi_s32 n_bitrates;
1052 oal_ieee80211_sta_ht_cap ht_cap;
1053 } oal_ieee80211_supported_band;
1054
1055 typedef struct oal_wiphy_tag {
1056 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX)
1057 hi_u8 perm_addr[6]; /* 6: SIZE(0..6) */
1058 hi_u8 addr_mask[6]; /* 6: SIZE(0..6) */
1059 hi_u32 flags;
1060 en_cfg80211_signal_type_uint8 signal_type;
1061 hi_u8 max_scan_ssids;
1062 hi_u16 interface_modes;
1063 hi_u16 max_scan_ie_len;
1064 hi_u8 auc_rsv[2]; /* 2: bytes保留字段 */
1065 hi_s32 n_cipher_suites;
1066 const hi_u32* cipher_suites;
1067 hi_u32 frag_threshold;
1068 hi_u32 rts_threshold;
1069 #endif
1070 oal_ieee80211_supported_band* bands[IEEE80211_NUM_BANDS];
1071 hi_u8 priv[4]; /* 4: SIZE(0..4) */
1072 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION) && !defined(_PRE_HDF_LINUX)
1073 const struct ieee80211_txrx_stypes* mgmt_stypes;
1074 const struct ieee80211_iface_combination* iface_combinations;
1075 hi_s32 n_iface_combinations;
1076 hi_u16 max_remain_on_channel_duration;
1077 hi_u8 max_sched_scan_ssids;
1078 hi_u8 max_match_sets;
1079 hi_u16 max_sched_scan_ie_len;
1080 hi_void* ctx;
1081 #endif
1082 } oal_wiphy_stru;
1083 #elif (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
1084 typedef struct wiphy oal_wiphy_stru;
1085 #endif /* #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX) */
1086
1087 typedef struct {
1088 hi_u32 fake;
1089 } oal_iw_statistics_stru;
1090
1091 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
1092 /* 私有IOCTL接口信息 */
1093 typedef struct {
1094 hi_u32 cmd; /* ioctl命令号 */
1095 hi_u16 set_args; /* 类型和参数字符个数 */
1096 hi_u16 get_args; /* 类型和参数字符个数 */
1097 hi_char name[OAL_IF_NAME_SIZE]; /* 私有命令名 */
1098 } oal_iw_priv_args_stru;
1099
1100 typedef struct {
1101 const oal_iw_handler* standard;
1102 hi_u16 num_standard;
1103 hi_u16 num_private;
1104
1105 /* FangBaoshun For Hi1131 Compile */
1106 const oal_iw_handler *private;
1107 /* FangBaoshun For Hi1131 Compile */
1108 hi_u8 auc_resv[2]; /* 2: bytes保留字段 */
1109 hi_u16 num_private_args;
1110
1111 const oal_iw_handler* private_win32;
1112
1113 const oal_iw_priv_args_stru* private_args;
1114 oal_iw_statistics_stru* (*get_wireless_stats)(oal_net_device_stru* dev);
1115 } oal_iw_handler_def_stru;
1116 #elif (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
1117 typedef struct iw_handler_def oal_iw_handler_def_stru;
1118 typedef struct iw_priv_args oal_iw_priv_args_stru;
1119 #endif
1120
1121 typedef struct NetDevStats oal_net_device_stats_stru;
1122
1123 typedef IpV4Addr oal_ip_addr_t;
1124
1125 typedef struct ieee80211_mgmt oal_ieee80211_mgmt_stru;
1126 typedef struct ieee80211_channel oal_ieee80211_channel_stru;
1127 typedef struct cfg80211_bss oal_cfg80211_bss_stru;
1128
1129
1130 #ifdef _PRE_WLAN_FEATURE_MESH_LWIP_RIPPLE
1131 typedef struct linklayer_addr oal_linklayer_addr;
1132 typedef uniqid_t oal_uniqid_t;
1133 typedef ip6_addr_t oal_ipv6_addr_t;
1134 typedef linklayer_event_tx_info_t oal_event_tx_info_stru;
1135 typedef linklayer_event_new_peer_t oal_event_new_peer_stru;
1136 typedef linklayer_event_del_peer_t oal_event_del_peer_stru;
1137 #endif
1138 typedef struct EapolData oal_hisi_eapol_stru;
1139
1140 typedef struct oal_net_notify {
1141 hi_u32 ip_addr;
1142 hi_u32 notify_type;
1143 } oal_net_notify_stru;
1144
1145 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX)
1146 typedef struct wireless_dev {
1147 oal_net_device_stru* netdev;
1148 oal_wiphy_stru* wiphy;
1149 nl80211_iftype_uint8 iftype;
1150 hi_u8 resv[3]; /* reserve 3byte */
1151 /* 1102新内核新增字段 add by lm */
1152 oal_cfg80211_chan_def preset_chandef;
1153 } oal_wireless_dev;
1154
1155 #endif
1156
1157
1158 typedef struct NetDeviceInterFace oal_net_device_ops_stru;
1159
1160
1161 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX)
1162 typedef struct rate_info {
1163 hi_u8 flags;
1164 hi_u8 mcs;
1165 hi_u16 legacy;
1166 hi_u8 nss;
1167 hi_u8 resv;
1168 } oal_rate_info_stru;
1169 #endif
1170
1171 typedef struct {
1172 union {
1173 hi_u8 u6_addr8[16]; /* 16: u6_addr8 长度 */
1174 hi_u16 u6_addr16[8]; /* 8: u6_addr16 长度 */
1175 hi_u32 u6_addr32[4]; /* 4: u6_addr32 长度 */
1176 } in6_u;
1177 } oal_in6_addr;
1178
1179 typedef struct {
1180 hi_u32 reserved: 5,
1181 override: 1,
1182 solicited: 1,
1183 router: 1,
1184 reserved2: 24;
1185 } icmpv6_nd_advt;
1186
1187 typedef struct {
1188 hi_u8 version: 4,
1189 priority: 4;
1190 hi_u8 flow_lbl[3]; /* 3: SIZE(0..3) */
1191 hi_u16 payload_len;
1192
1193 hi_u8 nexthdr;
1194 hi_u8 hop_limit;
1195
1196 oal_in6_addr saddr;
1197 oal_in6_addr daddr;
1198 } oal_ipv6hdr_stru;
1199
1200 typedef struct {
1201 hi_u8 icmp6_type;
1202 hi_u8 icmp6_code;
1203 hi_u16 icmp6_cksum;
1204 union {
1205 hi_u32 data32[1];
1206 hi_u16 data16[2]; /* 2: SIZE(0..2) */
1207 hi_u8 data8[4]; /* 4: SIZE(0..4) */
1208 icmpv6_nd_advt u_nd_advt;
1209 } icmp6_dataun;
1210
1211 #define ICMP6_SOLICITED icmp6_dataun.u_nd_advt.solicited
1212 #define ICMP6_OVERRIDE icmp6_dataun.u_nd_advt.override
1213 } oal_icmp6hdr_stru;
1214
1215 /* 多了4字节,记得减去4 */
1216 typedef struct {
1217 oal_icmp6hdr_stru icmph;
1218 oal_in6_addr target;
1219 hi_u8 opt[4]; /* 4: SIZE(0..4) */
1220 } oal_nd_msg_stru;
1221
1222 typedef struct {
1223 hi_u8 nd_opt_type;
1224 hi_u8 nd_opt_len;
1225 } oal_nd_opt_hdr;
1226
1227 typedef struct oal_cfg80211_crypto_settings_tag {
1228 hi_u32 wpa_versions;
1229 hi_u32 cipher_group;
1230 hi_s32 n_ciphers_pairwise;
1231 hi_u32 ciphers_pairwise[OAL_NL80211_MAX_NR_CIPHER_SUITES];
1232 hi_s32 n_akm_suites;
1233 hi_u32 akm_suites[OAL_NL80211_MAX_NR_AKM_SUITES];
1234
1235 hi_u8 control_port;
1236 hi_u8 auc_arry[3]; /* 3: SIZE(0..3) */
1237 } oal_cfg80211_crypto_settings_stru;
1238
1239 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
1240 typedef struct {
1241 hi_s32 sk_wmem_queued;
1242 } oal_sock_stru;
1243 #endif
1244
1245 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX)
1246 struct sta_bss_parameters {
1247 hi_u8 flags;
1248 hi_u8 dtim_period;
1249 hi_u16 beacon_interval;
1250 };
1251
1252 struct nl80211_sta_flag_update {
1253 hi_u32 mask;
1254 hi_u32 set;
1255 };
1256
1257 typedef struct oal_station_info_tag {
1258 hi_u32 filled;
1259 hi_u32 connected_time;
1260 hi_u32 inactive_time;
1261 hi_u16 llid;
1262 hi_u16 plid;
1263
1264 hi_u64 rx_bytes;
1265 hi_u64 tx_bytes;
1266 oal_rate_info_stru txrate;
1267 oal_rate_info_stru rxrate;
1268
1269 hi_u32 rx_packets;
1270 hi_u32 tx_packets;
1271 hi_u32 tx_retries;
1272 hi_u32 tx_failed;
1273
1274 hi_u32 rx_dropped_misc;
1275 hi_s32 generation;
1276 struct sta_bss_parameters bss_param;
1277 struct nl80211_sta_flag_update sta_flags;
1278
1279 hi_s64 t_offset;
1280 const hi_u8* assoc_req_ies;
1281 hi_u32 assoc_req_ies_len;
1282 hi_u32 beacon_loss_count;
1283
1284 hi_u8 plink_state;
1285 hi_s8 signal;
1286 hi_s8 signal_avg;
1287 hi_u8 resv1;
1288
1289 enum nl80211_mesh_power_mode local_pm;
1290 enum nl80211_mesh_power_mode peer_pm;
1291 enum nl80211_mesh_power_mode nonpeer_pm;
1292 hi_u32 resv2;
1293 } oal_station_info_stru;
1294 #elif (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
1295 typedef struct station_info oal_station_info_stru;
1296 #endif /* #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX) */
1297
1298 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX)
1299 typedef struct oal_key_params_tag {
1300 hi_u8 *key;
1301 hi_u8 *seq;
1302 hi_s32 key_len;
1303 hi_s32 seq_len;
1304 hi_u32 cipher;
1305 } oal_key_params_stru;
1306 #elif (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
1307 typedef struct key_params oal_key_params_stru;
1308 #endif
1309
1310 typedef struct cfg80211_add_key_info_stru {
1311 hi_u8 key_index;
1312 hi_bool pairwise;
1313 } cfg80211_add_key_info_stru;
1314
1315 typedef struct cfg80211_get_key_info_stru {
1316 hi_u8 key_index;
1317 hi_u8 arsvd[2]; /* 2: 保留字段 */
1318 bool pairwise;
1319 const hi_u8 *puc_mac_addr;
1320 } cfg80211_get_key_info_stru;
1321
1322 /* VLAN以太网头 liteos封装 */
1323 typedef struct {
1324 hi_u8 h_dest[ETHER_ADDR_LEN];
1325 hi_u8 h_source[ETHER_ADDR_LEN];
1326 hi_u16 h_vlan_proto;
1327 hi_u16 h_vlan_tci;
1328 hi_u16 h_vlan_encapsulated_proto;
1329 } oal_vlan_ethhdr_stru; /* linux 结构体 */
1330
1331
1332 #if (LINUX_VERSION_CODE >= kernel_version(2, 6, 34)) || (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
1333 typedef struct cfg80211_pmksa oal_cfg80211_pmksa_stru;
1334 #endif
1335
1336 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX)
1337 typedef struct oal_cfg80211_ssid_tag {
1338 hi_u8 ssid[OAL_IEEE80211_MAX_SSID_LEN];
1339 hi_u8 ssid_len;
1340 hi_u8 auc_arry[3]; /* 3: SIZE(0..3) */
1341 } oal_cfg80211_ssid_stru;
1342
1343 /* linux-2.6.34内核才有以下两个结构体,加密相关 */
1344 typedef struct oal_cfg80211_connect_params_tag {
1345 oal_ieee80211_channel_stru *channel;
1346
1347 hi_u8* bssid;
1348 hi_u8* ssid;
1349 hi_u8* ie;
1350
1351 hi_u32 ssid_len;
1352 hi_u32 ie_len;
1353 oal_cfg80211_crypto_settings_stru crypto;
1354 const hi_u8* key;
1355
1356 oal_nl80211_auth_type_enum_uint8 auth_type;
1357 hi_u8 privacy;
1358 hi_u8 key_len;
1359 hi_u8 key_idx;
1360 oal_nl80211_mfp_enum_uint8 mfp;
1361 hi_u8 auc_resv[3]; /* 3: 保留字节 */
1362 } oal_cfg80211_connect_params_stru;
1363
1364 typedef struct vif_params {
1365 hi_s32 use_4addr;
1366 hi_u8 *macaddr;
1367 } oal_vif_params_stru;
1368
1369 typedef struct oal_cfg80211_scan_request_tag {
1370 oal_cfg80211_ssid_stru* ssids;
1371 hi_u32 n_ssids;
1372 hi_u32 n_channels;
1373 hi_u32 ie_len;
1374
1375 /* internal */
1376 oal_wiphy_stru* wiphy;
1377 oal_net_device_stru* dev;
1378
1379 struct wireless_dev* wdev;
1380
1381 hi_u8 aborted;
1382 hi_u8 prefix_ssid_scan_flag;
1383 hi_u8 resv[2]; /* 2: 保留字段 */
1384
1385 hi_u8* ie;
1386
1387 /* keep last */
1388 oal_ieee80211_channel_stru* channels[HI_MAX_SCAN_CHANNELS];
1389 } oal_cfg80211_scan_request_stru;
1390 #endif /* #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX) */
1391
1392 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
1393 #ifndef _PRE_HDF_LINUX
1394 typedef struct cfg80211_connect_params oal_cfg80211_connect_params_stru;
1395 typedef struct cfg80211_scan_request oal_cfg80211_scan_request_stru;
1396 #endif
1397 typedef struct cfg80211_sched_scan_request oal_cfg80211_sched_scan_request_stru;
1398 typedef struct ethtool_ops oal_ethtool_ops_stru;
1399 #endif
1400
1401 typedef struct beacon_parameters {
1402 hi_u8 *head, *tail;
1403 hi_u32 interval, dtim_period;
1404 hi_u32 head_len, tail_len;
1405 } oal_beacon_parameters;
1406
1407 typedef struct {
1408 oal_proc_dir_entry_stru *proc_net;
1409 } oal_net_stru;
1410
1411 typedef struct module oal_module_stru;
1412
1413 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
1414 typedef struct {
1415 hi_u32 nlmsg_len; /* 消息长度,包括首部在内 */
1416 hi_u16 nlmsg_type; /* 消息内容的类型 */
1417 hi_u16 nlmsg_flags; /* 附加的标志 */
1418 hi_u32 nlmsg_seq; /* 序列号 */
1419 hi_u32 nlmsg_pid; /* 发送进程的端口ID */
1420 } oal_nlmsghdr_stru;
1421 #endif
1422
1423 /* netlink相关 */
1424 #define OAL_NLMSG_ALIGNTO 4
1425 #define oal_nlmsg_align(_len) (((_len) + OAL_NLMSG_ALIGNTO - 1) & ~(OAL_NLMSG_ALIGNTO - 1))
1426 #define OAL_NLMSG_HDRLEN ((hi_s32) oal_nlmsg_align(sizeof(oal_nlmsghdr_stru)))
1427 #define oal_nlmsg_length(_len) ((_len) + oal_nlmsg_align(OAL_NLMSG_HDRLEN))
1428 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
1429 #define oal_nlmsg_space(_len) oal_nlmsg_align(oal_nlmsg_length(_len))
1430 #endif
1431 #define oal_nlmsg_data(_nlh) ((hi_void*)(((hi_s8*)(_nlh)) + oal_nlmsg_length(0)))
1432 #define oal_nlmsg_payload(_nlh, _len) ((_nlh)->nlmsg_len - oal_nlmsg_space((_len)))
1433 #define oal_nlmsg_ok(_nlh, _len) ((_len) >= (hi_s32)(sizeof(oal_nlmsghdr_stru)) && \
1434 (_nlh)->nlmsg_len >= (sizeof(oal_nlmsghdr_stru)) && \
1435 (_nlh)->nlmsg_len <= (_len))
1436
1437 /* IPv6伪首部,用于校验和计算(伪首部中下一首部字段的值必须为58) */
1438 typedef struct {
1439 oal_in6_addr saddr;
1440 oal_in6_addr daddr;
1441 hi_u32 payload_len;
1442 hi_u32 nexthdr;
1443 } oal_ipv6_pseudo_hdr_stru;
1444
1445 /* net_device ioctl结构体定义 */
1446 /* hostapd/wpa_supplicant 下发的信息元素结构 */
1447 /* 该结构为事件内存池大小,保存从hostapd/wpa_supplicant下发的ie 信息 */
1448 /* 注意: 整个结构体长度为事件内存池大小,如果事件内存池有修改,则需要同步修改app 数据结构 */
1449 typedef struct oal_app_ie {
1450 hi_u32 ie_len;
1451 en_app_ie_type_uint8 app_ie_type;
1452 hi_u8 auc_rsv[3]; /* 3: 保留字段 */
1453 /* auc_ie 中保存信息元素,长度 = (事件内存池大小 - 保留长度) */
1454 hi_u8 auc_ie[WLAN_WPS_IE_MAX_SIZE];
1455 } oal_app_ie_stru;
1456
1457 typedef struct oal_dhcp_packet {
1458 hi_u8 op; /* packet opcode type */
1459 hi_u8 htype; /* hardware addr type */
1460 hi_u8 hlen; /* hardware addr length */
1461 hi_u8 hops; /* gateway hops */
1462 hi_u32 xid; /* transaction ID */
1463 hi_u16 secs; /* seconds since boot began */
1464 hi_u16 flags; /* flags */
1465 hi_u32 ciaddr; /* client IP address */
1466 hi_u32 yiaddr; /* 'your' IP address */
1467 hi_u32 siaddr; /* server IP address */
1468 hi_u32 giaddr; /* gateway IP address */
1469 hi_u8 chaddr[16]; /* 16: client hardware address */
1470 hi_u8 sname[64]; /* 64: server host name */
1471 hi_u8 file[128]; /* 128: boot file name */
1472 hi_u8 options[4]; /* 4: variable-length options field */
1473 } oal_dhcp_packet_stru;
1474
1475 /* 不分平台通用结构体 */
1476 typedef struct {
1477 hi_u8 auc_ssid[OAL_IEEE80211_MAX_SSID_LEN]; /* ssid array */
1478 hi_u8 ssid_len; /* length of the array */
1479 hi_u8 auc_arry[3]; /* 3: 数组元素个数 */
1480 } oal_ssids_stru;
1481
1482 /* net_device ioctl结构体定义 */
1483 typedef struct oal_net_dev_ioctl_data_tag {
1484 hi_s32 l_cmd; /* 命令号 */
1485 union {
1486 struct {
1487 hi_u8 auc_mac[OAL_MAC_ADDR_LEN];
1488 hi_u8 auc_rsv[2]; /* 2: 保留字段 */
1489 hi_u32 buf_size; /* 用户空间ie 缓冲大小 */
1490 hi_u8* puc_buf; /* 用户空间ie 缓冲地址 */
1491 } assoc_req_ie; /* AP 模式,用于获取STA 关联请求ie 信息 */
1492
1493 struct {
1494 hi_u32 auth_alg;
1495 } auth_params;
1496
1497 struct {
1498 hi_u8 auc_country_code[4]; /* 4: 国家码长度 */
1499 } country_code;
1500
1501 hi_u8 ssid[OAL_IEEE80211_MAX_SSID_LEN + 4]; /* 4: 加4 */
1502 hi_u32 vap_max_user;
1503
1504 struct {
1505 hi_s32 l_freq;
1506 hi_s32 l_channel;
1507 hi_s32 l_ht_enabled;
1508 hi_s32 l_sec_channel_offset;
1509 hi_s32 l_vht_enabled;
1510 hi_s32 l_center_freq1;
1511 hi_s32 l_center_freq2;
1512 hi_s32 l_bandwidth;
1513 } freq;
1514
1515 oal_app_ie_stru app_ie; /* beacon ie,index 0; proberesp ie index 1; assocresp ie index 2 */
1516
1517 struct {
1518 hi_s32 l_freq; /* ap所在频段,与linux-2.6.34内核中定义不同 */
1519 hi_u32 ssid_len; /* SSID 长度 */
1520 hi_u32 ie_len;
1521 hi_u8* puc_ie;
1522 const hi_u8* puc_ssid; /* 期望关联的AP SSID */
1523 const hi_u8* puc_bssid; /* 期望关联的AP BSSID */
1524 hi_u8 privacy; /* 是否加密标志 */
1525 oal_nl80211_auth_type_enum_uint8 auth_type; /* 认证类型,OPEN or SHARE-KEY */
1526
1527 hi_u8 wep_key_len; /* WEP KEY长度 */
1528 hi_u8 wep_key_index; /* WEP KEY索引 */
1529 const hi_u8* puc_wep_key; /* WEP KEY密钥 */
1530 oal_cfg80211_crypto_settings_stru crypto; /* 密钥套件信息 */
1531 } cfg80211_connect_params;
1532 struct {
1533 hi_u8 auc_mac[OAL_MAC_ADDR_LEN];
1534 hi_u16 us_reason_code; /* 去关联 reason code */
1535 } kick_user_params;
1536
1537 hi_s32 l_frag; /* 分片门限值 */
1538 hi_s32 l_rts; /* RTS 门限值 */
1539 } pri_data;
1540 } oal_net_dev_ioctl_data_stru;
1541
1542 typedef struct {
1543 hi_u16 us_ar_hrd; /* format of hardware address */
1544 hi_u16 us_ar_pro; /* format of protocol address */
1545 hi_u8 ar_hln; /* length of hardware address */
1546 hi_u8 ar_pln; /* length of protocol address */
1547 hi_u16 us_ar_op; /* ARP opcode (command) */
1548
1549 hi_u8 auc_ar_sha[ETHER_ADDR_LEN]; /* sender hardware address */
1550 hi_u8 auc_ar_sip[ETH_SENDER_IP_ADDR_LEN]; /* sender IP address */
1551 hi_u8 auc_ar_tha[ETHER_ADDR_LEN]; /* target hardware address */
1552 hi_u8 auc_ar_tip[ETH_TARGET_IP_ADDR_LEN]; /* target IP address */
1553 } oal_eth_arphdr_stru;
1554
1555 typedef struct oal_eth_header_info_stru {
1556 hi_u32 type;
1557 hi_void *daddr;
1558 hi_void *saddr;
1559 hi_u32 len;
1560 } oal_eth_header_info_stru;
1561
1562 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX)
1563 struct ieee80211_txrx_stypes {
1564 hi_u16 tx;
1565 hi_u16 rx;
1566 };
1567
1568 typedef struct ieee80211_iface_limit {
1569 hi_u16 max;
1570 hi_u16 types;
1571 } oal_ieee80211_iface_limit;
1572
1573 typedef struct ieee80211_iface_combination {
1574 const struct ieee80211_iface_limit* limits;
1575 hi_u32 num_different_channels;
1576 hi_u16 max_interfaces;
1577 hi_u8 n_limits;
1578 hi_u8 radar_detect_widths;
1579 hi_bool beacon_int_infra_match;
1580 hi_u8 resv[3]; /* 3: 保留字段 */
1581 } oal_ieee80211_iface_combination;
1582 #endif
1583
1584 typedef struct oal_arp_create_info_stru {
1585 hi_u32 l_type;
1586 hi_u32 l_ptype;
1587 hi_u32 dest_ip;
1588 hi_u32 src_ip;
1589 hi_u8 *puc_dest_hw;
1590 hi_u8 *puc_src_hw;
1591 hi_u8 *puc_target_hw;
1592 } oal_arp_create_info_stru;
1593
1594 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
1595 typedef struct oal_cfg80211_ops_tag {
1596 hi_s32 (*add_key)(oal_wiphy_stru *wiphy, oal_net_device_stru *netdev,
1597 cfg80211_add_key_info_stru *p_cfg80211_add_key_info, const hi_u8 *mac_addr, oal_key_params_stru *params);
1598 hi_s32 (*get_key)(oal_wiphy_stru *wiphy, oal_net_device_stru *netdev,
1599 cfg80211_get_key_info_stru *p_cfg80211_get_key_info, hi_void *cookie,
1600 hi_void (*callback)(hi_void *cookie, oal_key_params_stru *key));
1601 hi_s32 (*del_key)(oal_wiphy_stru *wiphy, oal_net_device_stru *netdev, hi_u8 key_index, hi_bool en_pairwise,
1602 const hi_u8 *mac_addr);
1603 hi_s32 (*set_default_key)(oal_wiphy_stru *wiphy, oal_net_device_stru *netdev, hi_u8 key_index, hi_bool en_unicast,
1604 hi_bool en_multicast);
1605 hi_s32 (*set_default_mgmt_key)(oal_wiphy_stru *wiphy, oal_net_device_stru *netdev, hi_u8 key_index);
1606 hi_s32 (*scan)(oal_wiphy_stru *pst_wiphy, oal_cfg80211_scan_request_stru *pst_request);
1607 hi_s32 (*connect)(oal_wiphy_stru *pst_wiphy, oal_net_device_stru *netdev,
1608 oal_cfg80211_connect_params_stru *pst_sme);
1609 hi_s32 (*disconnect)(oal_wiphy_stru *pst_wiphy, oal_net_device_stru *netdev, hi_u16 us_reason_code);
1610 hi_s32 (*set_channel)(oal_wiphy_stru *pst_wiphy, oal_ieee80211_channel *pst_chan,
1611 oal_nl80211_channel_type en_channel_type);
1612 hi_s32 (*set_wiphy_params)(oal_wiphy_stru *pst_wiphy, hi_u32 ul_changed);
1613 hi_s32 (*add_beacon)(oal_wiphy_stru *pst_wiphy, oal_net_device_stru *netdev, oal_beacon_parameters *pst_info);
1614 hi_s32 (*change_virtual_intf)(oal_wiphy_stru *pst_wiphy, oal_net_device_stru *netdev, nl80211_iftype_uint8 en_type,
1615 hi_u32 *pul_flags, oal_vif_params_stru *pst_params);
1616 hi_s32 (*add_station)(oal_wiphy_stru *pst_wiphy, oal_net_device_stru *netdev, hi_u8 *mac_addr, hi_void *sta_parms);
1617 hi_s32 (*del_station)(oal_wiphy_stru *pst_wiphy, oal_net_device_stru *netdev, const hi_u8 *mac_addr);
1618 hi_s32 (*change_station)(oal_wiphy_stru *pst_wiphy, oal_net_device_stru *netdev, hi_u8 *mac_addr,
1619 hi_void *pst_sta_parms);
1620 hi_s32 (*get_station)(oal_wiphy_stru *pst_wiphy, oal_net_device_stru *netdev, hi_u8 *mac_addr,
1621 oal_station_info_stru *pst_sta_info);
1622 hi_s32 (*dump_station)(oal_wiphy_stru *wiphy, oal_net_device_stru *dev, hi_s32 idx, hi_u8 *mac,
1623 oal_station_info_stru *pst_sta_info);
1624 hi_s32 (*change_beacon)(oal_wiphy_stru *pst_wiphy, oal_net_device_stru *pst_netdev,
1625 oal_beacon_data_stru *pst_beacon_info);
1626 hi_s32 (*start_ap)(oal_wiphy_stru *pst_wiphy, oal_net_device_stru *pst_netdev,
1627 oal_ap_settings_stru *pst_ap_settings);
1628 hi_s32 (*stop_ap)(oal_wiphy_stru *pst_wiphy, oal_net_device_stru *pst_netdev);
1629 hi_s32 (*change_bss)(oal_wiphy_stru *pst_wiphy, oal_net_device_stru *pst_netdev, hi_void *pst_bss_params);
1630 hi_s32 (*set_power_mgmt)(oal_wiphy_stru *pst_wiphy, oal_net_device_stru *pst_ndev, hi_bool enabled,
1631 hi_s32 ul_timeout);
1632 hi_s32 (*sched_scan_start)(oal_wiphy_stru *wiphy, oal_net_device_stru *dev,
1633 struct cfg80211_sched_scan_request *request);
1634 hi_s32 (*sched_scan_stop)(oal_wiphy_stru *wiphy, oal_net_device_stru *dev);
1635 hi_s32 (*remain_on_channel)(oal_wiphy_stru *wiphy, struct wireless_dev *wdev, struct ieee80211_channel *chan,
1636 hi_u32 duration, hi_u64 *cookie);
1637 hi_s32 (*cancel_remain_on_channel)(oal_wiphy_stru *wiphy, struct wireless_dev *wdev, hi_u64 cookie);
1638 hi_s32 (*mgmt_tx)(oal_wiphy_stru *wiphy, struct wireless_dev *wdev, struct ieee80211_channel *chan, hi_bool offchan,
1639 hi_u32 wait, const hi_u8 *buf, size_t len, hi_bool no_cck, hi_bool dont_wait_for_ack, hi_u64 *cookie);
1640 hi_void (*mgmt_frame_register)(struct wiphy *wiphy, struct wireless_dev *wdev, hi_u16 frame_type, hi_bool reg);
1641 struct wireless_dev *(*add_virtual_intf)(oal_wiphy_stru *wiphy, const hi_char *name, nl80211_iftype_uint8 type,
1642 hi_u32 *flags, struct vif_params *params);
1643 hi_s32 (*del_virtual_intf)(oal_wiphy_stru *wiphy, struct wireless_dev *wdev);
1644 hi_s32 (*mgmt_tx_cancel_wait)(oal_wiphy_stru *wiphy, struct wireless_dev *wdev, hi_u64 cookie);
1645 hi_s32 (*start_p2p_device)(oal_wiphy_stru *wiphy, struct wireless_dev *wdev);
1646 hi_void (*stop_p2p_device)(oal_wiphy_stru *wiphy, struct wireless_dev *wdev);
1647 } oal_cfg80211_ops;
1648 #elif (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
1649 typedef struct cfg80211_ops oal_cfg80211_ops_stru;
1650 #endif /* #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) */
1651
1652 /* ****************************************************************************
1653 5 函数声明
1654 **************************************************************************** */
1655 hi_void netif_set_flow_ctrl_status(const oal_net_device_stru *netdev, netif_flow_ctrl_enum_uint8 status);
1656
oal_get_past_net_device_by_index(hi_u32 netdev_index)1657 static inline oal_net_device_stru *oal_get_past_net_device_by_index(hi_u32 netdev_index)
1658 {
1659 return NetDeviceGetInstByIndex(netdev_index);
1660 }
1661
1662 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
1663 hi_s32 oal_dev_netlink_create(hi_void);
1664 hi_s32 oal_dev_netlink_send(hi_u8 *data, hi_s32 data_len);
1665 hi_s32 oal_init_dev_excp_handler(hi_void);
1666 hi_void oal_deinit_dev_excp_handler(hi_void);
1667 #endif
1668
1669 hi_s32 oal_ieee80211_channel_to_frequency(hi_s32 l_channel, wlan_channel_band_enum_uint8 band);
1670 hi_s32 oal_ieee80211_frequency_to_channel(hi_s32 l_center_freq);
1671 oal_ieee80211_channel_stru *oal_ieee80211_get_channel(const oal_wiphy_stru *wiphy, hi_s32 freq);
1672 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
1673 oal_net_device_stru *oal_net_alloc_netdev(const hi_char *puc_name, hi_u8 max_name_len);
1674 #endif
1675 oal_net_device_stru *oal_net_alloc_netdev_mqs(const hi_char *puc_name);
1676 hi_void oal_net_clear_netdev(oal_net_device_stru *netdev);
1677 hi_void oal_net_free_netdev(oal_net_device_stru *netdev);
1678 hi_u32 oal_net_register_netdev(oal_net_device_stru *netdev, nl80211_iftype_uint8 type);
1679 hi_void oal_net_unregister_netdev(oal_net_device_stru *netdev);
1680 oal_net_device_stru *oal_get_netdev_by_name(const hi_char *pc_name);
1681 oal_net_device_stru *oal_get_netdevice_by_name(const hi_char *pc_name, hi_u32 len);
1682 hi_u32 oal_net_check_and_get_devname(nl80211_iftype_uint8 type, char *dev_name, hi_u32 *len);
1683 hi_void oal_dev_destroy_all(hi_void);
1684
1685
1686 /* ****************************************************************************
1687 6 内联函数
1688 **************************************************************************** */
1689 /* ==================BEGIN : Linux wiphy 结构相关的处理函数================== */
1690 /* ****************************************************************************
1691 功能描述 :
1692
1693 修改历史 :
1694 1.日 期 : 2013年8月28日
1695 作 者 : HiSilicon
1696 修改内容 : 新生成函数
1697 **************************************************************************** */
1698 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX)
oal_wiphy_new(hi_u32 sizeof_priv)1699 static inline oal_wiphy_stru *oal_wiphy_new(hi_u32 sizeof_priv)
1700 {
1701 return (oal_wiphy_stru *)oal_kzalloc(sizeof_priv + sizeof(oal_wiphy_stru), 0);
1702 }
1703 #elif (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
oal_wiphy_new(oal_cfg80211_ops_stru * ops,hi_u32 sizeof_priv)1704 static inline oal_wiphy_stru *oal_wiphy_new(oal_cfg80211_ops_stru *ops, hi_u32 sizeof_priv)
1705 {
1706 return wiphy_new(ops, sizeof_priv);
1707 }
1708 #endif /* #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX) */
1709
1710 /* ****************************************************************************
1711 功能描述 : 注册wiphy
1712 **************************************************************************** */
1713 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX)
1714 hi_void oal_wiphy_register(oal_wiphy_stru *wiphy);
1715 #elif (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
oal_wiphy_register(oal_wiphy_stru * wiphy)1716 static inline hi_s32 oal_wiphy_register(oal_wiphy_stru *wiphy)
1717 {
1718 return wiphy_register(wiphy);
1719 }
1720 #endif
1721 oal_wiphy_stru *oal_wiphy_get(hi_void);
1722
1723 /* ****************************************************************************
1724 功能描述 :
1725
1726 修改历史 :
1727 1.日 期 : 2013年9月5日
1728 作 者 : HiSilicon
1729 修改内容 : 新生成函数
1730
1731 **************************************************************************** */
1732 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX)
oal_wiphy_unregister(hi_void)1733 static inline hi_void oal_wiphy_unregister(hi_void)
1734 {
1735 return;
1736 }
1737 #elif (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
oal_wiphy_unregister(oal_wiphy_stru * wiphy)1738 static inline hi_void oal_wiphy_unregister(oal_wiphy_stru *wiphy)
1739 {
1740 return wiphy_unregister(wiphy);
1741 }
1742 #endif
1743
1744 /* ****************************************************************************
1745 功能描述 :
1746
1747 修改历史 :
1748 1.日 期 : 2013年8月28日
1749 作 者 : HiSilicon
1750 修改内容 : 新生成函数
1751
1752 **************************************************************************** */
oal_wiphy_free(oal_wiphy_stru * wiphy)1753 static inline hi_void oal_wiphy_free(oal_wiphy_stru *wiphy)
1754 {
1755 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX)
1756 oal_free(wiphy);
1757 #elif (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
1758 wiphy_free(wiphy);
1759 #endif
1760 }
1761
1762 /* ****************************************************************************
1763 功能描述 : 获取私有指针 指向hmac_device_stru指针
1764
1765 修改历史 :
1766 1.日 期 : 2013年8月28日
1767 作 者 : HiSilicon
1768 修改内容 : 由mac_device_stru指向hmac_device_stru
1769 **************************************************************************** */
oal_wiphy_priv(oal_wiphy_stru * wiphy)1770 static inline hi_void *oal_wiphy_priv(oal_wiphy_stru *wiphy)
1771 {
1772 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX)
1773 return wiphy->priv;
1774 #elif (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
1775 return wiphy_priv(wiphy);
1776 #endif
1777 }
1778
1779 /* ****************************************************************************
1780 功能描述 :
1781
1782 修改历史 :
1783 1.日 期 : 2013年9月13日
1784 作 者 : HiSilicon
1785 修改内容 : 新生成函数
1786
1787 **************************************************************************** */
1788 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX)
oal_wiphy_apply_custom_regulatory(hi_void)1789 static inline hi_void oal_wiphy_apply_custom_regulatory(hi_void)
1790 {
1791 return;
1792 }
1793 #elif (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
oal_wiphy_apply_custom_regulatory(oal_wiphy_stru * wiphy,HI_CONST oal_ieee80211_regdomain_stru * regd)1794 static inline hi_void oal_wiphy_apply_custom_regulatory(oal_wiphy_stru *wiphy,
1795 HI_CONST oal_ieee80211_regdomain_stru *regd)
1796 {
1797 wiphy_apply_custom_regulatory(wiphy, regd);
1798 }
1799 #endif
1800 /* ==================END : Linux wiphy 结构相关的处理函数================== */
1801 /* ****************************************************************************
1802 功能描述 : 获取协议模式
1803 输入参数 : pst_netbuf: skb指针
1804 pst_device: net device结构体指针
1805
1806 修改历史 :
1807 1.日 期 : 2012年12月12日
1808 作 者 : HiSilicon
1809 修改内容 : 新生成函数
1810
1811 **************************************************************************** */
oal_eth_type_trans(oal_netbuf_stru * netbuf,oal_net_device_stru * device)1812 static inline hi_u16 oal_eth_type_trans(oal_netbuf_stru *netbuf, oal_net_device_stru *device)
1813 {
1814 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
1815 /* 将netbuf的data指针指向mac frame的payload处 --fix by fangbaoshun for liteos */
1816 /* 此处linux有复杂操作,liteos做了简化,protocol为0,先pull 14字节,后面会用到,最后交给系统之前push回去。 */
1817 (void)device;
1818 oal_netbuf_pull(netbuf, sizeof(oal_ether_header_stru));
1819
1820 return 0;
1821 #elif (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION) && !defined(_PRE_HDF_LINUX)
1822 return eth_type_trans(netbuf, device);
1823 #else
1824 return 0;
1825 #endif
1826 }
1827
1828 /* ****************************************************************************
1829 功能描述 : 网络设备启动接口
1830
1831 修改历史 :
1832 1.日 期 : 2012年11月22日
1833 作 者 : HiSilicon
1834 修改内容 : 新生成函数
1835
1836 **************************************************************************** */
1837 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
oal_ether_setup(hi_void)1838 static inline hi_void oal_ether_setup(hi_void)
1839 #elif (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
1840 static inline hi_void oal_ether_setup(oal_net_device_stru *net_device)
1841 #endif
1842 {
1843 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION) && !defined(_PRE_HDF_LINUX)
1844 if (net_device == HI_NULL) {
1845 return;
1846 }
1847
1848 ether_setup(net_device);
1849 #endif
1850 return;
1851 }
1852
1853 /* ****************************************************************************
1854 功能描述 : 调用oal_dev_get_by_name后需要调用dev_put,是net_dev的引用计数减1
1855 输入参数 : _pst_dev: 指向net_dev的指针
1856
1857 修改历史 :
1858 1.日 期 : 2013年2月19日
1859 作 者 : HiSilicon
1860 修改内容 : 新生成函数
1861
1862 **************************************************************************** */
1863 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX)
1864 #define oal_dev_put(_pst_dev)
1865 #elif (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
1866 #define oal_dev_put(_pst_dev) dev_put(_pst_dev)
1867 #endif
1868
1869 /* ****************************************************************************
1870 功能描述 : 唤醒所有的队列
1871
1872 修改历史 :
1873 1.日 期 : 2014年3月4日
1874 作 者 : HiSilicon
1875 修改内容 : 新生成函数
1876
1877 **************************************************************************** */
oal_net_tx_wake_all_queues(hi_void)1878 static inline hi_void oal_net_tx_wake_all_queues(hi_void)
1879 {
1880 return;
1881 }
1882
1883 /* ****************************************************************************
1884 功能描述 : 停止所有的队列
1885
1886 修改历史 :
1887 1.日 期 : 2014年3月4日
1888 作 者 : HiSilicon
1889 修改内容 : 新生成函数
1890
1891 **************************************************************************** */
oal_net_tx_stop_all_queues(hi_void)1892 static inline hi_void oal_net_tx_stop_all_queues(hi_void)
1893 {
1894 return;
1895 }
1896
1897 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
1898 /* ****************************************************************************
1899 功能描述 : wake网络设备的某个subqueue
1900
1901 修改历史 :
1902 1.日 期 : 2014年3月3日
1903 作 者 : HiSilicon
1904 修改内容 : 新生成函数
1905
1906 **************************************************************************** */
oal_net_wake_subqueue(oal_net_device_stru * netdev,hi_u16 queue_idx)1907 static inline hi_void oal_net_wake_subqueue(oal_net_device_stru *netdev, hi_u16 queue_idx)
1908 {
1909 if (netdev == HI_NULL) {
1910 return;
1911 }
1912 #ifndef _PRE_HDF_LINUX
1913 return netif_wake_subqueue(netdev, queue_idx);
1914 #endif
1915 }
1916
1917 /* ****************************************************************************
1918 功能描述 : 暂停网络设备的某个subqueue
1919
1920 修改历史 :
1921 1.日 期 : 2014年3月3日
1922 作 者 : HiSilicon
1923 修改内容 : 新生成函数
1924
1925 **************************************************************************** */
oal_net_stop_subqueue(oal_net_device_stru * netdev,hi_u16 queue_idx)1926 static inline hi_void oal_net_stop_subqueue(oal_net_device_stru *netdev, hi_u16 queue_idx)
1927 {
1928 if (netdev == HI_NULL) {
1929 return;
1930 }
1931 #ifndef _PRE_HDF_LINUX
1932 return netif_stop_subqueue(netdev, queue_idx);
1933 #endif
1934 }
1935
oal_net_alloc_netdev(hi_u32 sizeof_priv,const hi_char * netdev_name,hi_void * set_up)1936 static inline oal_net_device_stru *oal_net_alloc_netdev(hi_u32 sizeof_priv, const hi_char *netdev_name, hi_void *set_up)
1937 {
1938 #ifdef _PRE_HDF_LINUX
1939 if (netdev_name == HI_NULL || set_up == HI_NULL) {
1940 return HI_NULL;
1941 }
1942 oal_net_device_stru *netdev = NetDeviceInit(netdev_name, strlen(netdev_name), WIFI_LINK, FULL_OS);
1943 if (netdev != NULL) {
1944 netdev->funType.wlanType = PROTOCOL_80211_IFTYPE_STATION;
1945 }
1946 return netdev;
1947 #else
1948 oal_net_device_stru *tmp_netdev = HI_NULL;
1949
1950 if ((netdev_name == HI_NULL) || (set_up == HI_NULL)) {
1951 return HI_NULL;
1952 }
1953
1954 #if (LINUX_VERSION_CODE >= kernel_version(3, 18, 0))
1955 tmp_netdev = alloc_netdev(sizeof_priv, netdev_name, NET_NAME_UNKNOWN, set_up);
1956 if (tmp_netdev == HI_NULL) {
1957 printk("oal_net_alloc_netdev***[%d]\n", __LINE__);
1958 }
1959 return tmp_netdev;
1960 #else
1961 return alloc_netdev(sizeof_priv, netdev_name, set_up);
1962 #endif
1963 #endif /* ifdef _PRE_HDF_LINUX */
1964 }
1965 #elif (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
1966 /* ****************************************************************************
1967 功能描述 : wake网络设备的某个subqueue
1968
1969 修改历史 :
1970 1.日 期 : 2014年3月3日
1971 作 者 : HiSilicon
1972 修改内容 : 新生成函数
1973
1974 **************************************************************************** */
oal_net_wake_subqueue(const oal_net_device_stru * netdev)1975 static inline hi_void oal_net_wake_subqueue(const oal_net_device_stru *netdev)
1976 {
1977 if (netdev == HI_NULL) {
1978 oal_io_print0("oal_net_wake_subqueue::pst_dev = NULL!!! \r\n");
1979 return;
1980 }
1981
1982 return;
1983 }
1984
1985 /* ****************************************************************************
1986 功能描述 : 暂停网络设备的某个subqueue
1987
1988 修改历史 :
1989 1.日 期 : 2014年3月3日
1990 作 者 : HiSilicon
1991 修改内容 : 新生成函数
1992
1993 **************************************************************************** */
oal_net_stop_subqueue(const oal_net_device_stru * netdev)1994 static inline hi_void oal_net_stop_subqueue(const oal_net_device_stru *netdev)
1995 {
1996 if (netdev == HI_NULL) {
1997 oal_io_print0("oal_net_stop_subqueue::pst_dev = NULL!!! \r\n");
1998 return;
1999 }
2000
2001 return;
2002 }
2003
2004 /* ****************************************************************************
2005 功能描述 : net device的open函数
2006 输入参数 : net device指针
2007 返 回 值 : 成功或者失败原因
2008
2009 修改历史 :
2010 1.日 期 : 2012年12月25日
2011 作 者 : HiSilicon
2012 修改内容 : 新生成函数
2013
2014 **************************************************************************** */
oal_net_device_open(oal_net_device_stru * netdev)2015 static inline hi_s32 oal_net_device_open(oal_net_device_stru *netdev)
2016 {
2017 /* netdevice相关接口函数后续统一优化 */
2018 netdev->flags |= OAL_IFF_RUNNING;
2019
2020 return HI_SUCCESS;
2021 }
2022 #endif /* #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION) */
2023
2024 /* ****************************************************************************
2025 功能描述 : net device的close函数
2026 输入参数 : net device指针
2027 返 回 值 : 成功或者失败原因
2028
2029 修改历史 :
2030 1.日 期 : 2012年12月25日
2031 作 者 : HiSilicon
2032 修改内容 : 新生成函数
2033
2034 **************************************************************************** */
oal_net_device_close(oal_net_device_stru * netdev)2035 static inline hi_s32 oal_net_device_close(oal_net_device_stru *netdev)
2036 {
2037 /* netdevice相关接口函数后续统一优化 */
2038 oal_netdevice_flags(netdev) &= ~OAL_IFF_RUNNING;
2039
2040 return HI_SUCCESS;
2041 }
2042
2043 /* ****************************************************************************
2044 功能描述 : net device的初始化函数
2045 输入参数 : net device指针
2046 返 回 值 : 成功或者失败原因
2047
2048 修改历史 :
2049 1.日 期 : 2012年12月25日
2050 作 者 : HiSilicon
2051 修改内容 : 新生成函数
2052
2053 **************************************************************************** */
2054 /* 作为全局变量g_wal_net_dev_ops成员引用,不用const修饰,lin_t e818告警屏蔽 */
oal_net_device_init(oal_net_device_stru * netdev)2055 static inline hi_s32 oal_net_device_init(oal_net_device_stru *netdev)
2056 {
2057 /* netdevice相关接口函数后续统一优化 */
2058 if (netdev == HI_NULL) {
2059 return HI_FAIL;
2060 }
2061
2062 return HI_SUCCESS;
2063 }
2064
2065 /* ****************************************************************************
2066 功能描述 : 将skb发给桥
2067 输入参数 : pst_netbuf: skb指针
2068 返 回 值 : 1,drop;0,succ
2069
2070 修改历史 :
2071 1.日 期 : 2012年12月12日
2072 作 者 : HiSilicon
2073 修改内容 : 新生成函数
2074 **************************************************************************** */
oal_netif_rx(oal_netbuf_stru * netbuf)2075 static inline hi_u32 oal_netif_rx(oal_netbuf_stru *netbuf)
2076 {
2077 return NetIfRx((struct NetDevice *)netbuf->dev, netbuf);
2078 }
2079
2080 /* ****************************************************************************
2081 功能描述 : 将skb发给桥 !in_interrupt()
2082 输入参数 : pst_netbuf: skb指针
2083 返 回 值 : 1,drop;0,succ
2084
2085 修改历史 :
2086 1.日 期 : 2012年12月12日
2087 作 者 : HiSilicon
2088 修改内容 : 新生成函数
2089 **************************************************************************** */
oal_netif_rx_ni(oal_netbuf_stru * netbuf)2090 static inline hi_u32 oal_netif_rx_ni(oal_netbuf_stru *netbuf)
2091 {
2092 return NetIfRxNi((struct NetDevice *)netbuf->dev, netbuf);
2093 }
2094
2095
2096 /* ****************************************************************************
2097 功能描述 : 创建netlink
2098 **************************************************************************** */
2099 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
2100 oal_sock_stru *oal_netlink_kernel_create(hi_void);
2101 #endif
2102
2103 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
2104 /* ****************************************************************************
2105 功能描述 : 创建netlink
2106 **************************************************************************** */
oal_netlink_kernel_create(hi_void (* input)(oal_netbuf_stru * pst_netbuf))2107 static inline oal_sock_stru *oal_netlink_kernel_create(hi_void (*input)(oal_netbuf_stru *pst_netbuf))
2108 {
2109 struct netlink_kernel_cfg cfg;
2110
2111 memset_s(&cfg, sizeof(cfg), 0, sizeof(cfg));
2112 cfg.groups = 0;
2113 cfg.input = input;
2114 cfg.cb_mutex = NULL;
2115
2116 return netlink_kernel_create(&init_net, NETLINK_DEV_ERROR, &cfg);
2117 }
2118 #endif
2119
2120 /* ****************************************************************************
2121 功能描述 : 释放资源
2122 **************************************************************************** */
2123 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
2124 hi_void oal_netlink_kernel_release(hi_void);
2125 #elif (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
oal_netlink_kernel_release(hi_void)2126 static inline hi_void oal_netlink_kernel_release(hi_void)
2127 {
2128 return;
2129 }
2130 #endif
2131
2132 /* ****************************************************************************
2133 功能描述 : 获取nlmsg头
2134
2135 修改历史 :
2136 1.日 期 : 2013年10月15日
2137 作 者 : HiSilicon
2138 修改内容 : 新生成函数
2139 **************************************************************************** */
oal_nlmsg_hdr(const oal_netbuf_stru * netbuf)2140 static inline oal_nlmsghdr_stru *oal_nlmsg_hdr(const oal_netbuf_stru *netbuf)
2141 {
2142 return (oal_nlmsghdr_stru *)oal_netbuf_header(netbuf);
2143 }
2144
2145 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
oal_nlmsg_put(oal_netbuf_stru * netbuf,hi_u32 pid,hi_u32 ul_seq,hi_u32 type,hi_u32 payload,hi_u32 flags)2146 static inline oal_nlmsghdr_stru *oal_nlmsg_put(oal_netbuf_stru *netbuf, hi_u32 pid, hi_u32 ul_seq, hi_u32 type,
2147 hi_u32 payload, hi_u32 flags)
2148 {
2149 return nlmsg_put(netbuf, pid, ul_seq, type, payload, flags);
2150 }
2151 #endif
2152
2153 /* ****************************************************************************
2154 功能描述 : 获取nlmsg消息大小
2155
2156 修改历史 :
2157 1.日 期 : 2013年10月16日
2158 作 者 : HiSilicon
2159 修改内容 : 新生成函数
2160 **************************************************************************** */
oal_nlmsg_msg_size(hi_s32 l_payload)2161 static inline hi_s32 oal_nlmsg_msg_size(hi_s32 l_payload)
2162 {
2163 return OAL_NLMSG_HDRLEN + l_payload;
2164 }
2165
2166 /* ****************************************************************************
2167 功能描述 : 获取nlmsg大小
2168
2169 修改历史 :
2170 1.日 期 : 2013年10月16日
2171 作 者 : HiSilicon
2172 修改内容 : 新生成函数
2173 **************************************************************************** */
oal_nlmsg_total_size(hi_s32 l_payload)2174 static inline hi_s32 oal_nlmsg_total_size(hi_s32 l_payload)
2175 {
2176 return oal_nlmsg_align(oal_nlmsg_msg_size(l_payload));
2177 }
2178
2179 /* ****************************************************************************
2180 功能描述 : 释放单播资源
2181
2182 修改历史 :
2183 1.日 期 : 2013年10月16日
2184 作 者 : HiSilicon
2185 修改内容 : 新生成函数
2186 **************************************************************************** */
2187 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
oal_netlink_unicast(oal_netbuf_stru * netbuf)2188 static inline hi_s32 oal_netlink_unicast(oal_netbuf_stru *netbuf)
2189 #elif (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
2190 static inline hi_s32 oal_netlink_unicast(oal_sock_stru *pst_sock, oal_netbuf_stru *netbuf, hi_u32 pid, hi_u32 nonblock)
2191 #endif
2192 {
2193 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
2194 oal_netbuf_free(netbuf);
2195 return HI_SUCCESS;
2196 #elif (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
2197 return netlink_unicast(pst_sock, netbuf, pid, nonblock);
2198 #endif
2199 }
2200
2201 /* ****************************************************************************
2202 功能描述 : 获取arp头的长度
2203
2204 修改历史 :
2205 1.日 期 : 2014年8月5日
2206 作 者 : HiSilicon
2207 修改内容 : 新生成函数
2208 **************************************************************************** */
oal_arp_hdr_len(const oal_net_device_stru * netdev)2209 static inline hi_s32 oal_arp_hdr_len(const oal_net_device_stru *netdev)
2210 {
2211 /* ARP header, plus 2 device addresses, plus 2 IP addresses. */
2212 return sizeof(oal_eth_arphdr_stru) +
2213 (netdev->addrLen + sizeof(hi_u32)) * 2; /* ARP header, plus 2 device addresses */
2214 }
2215
2216
2217 #ifdef __cplusplus
2218 #if __cplusplus
2219 }
2220 #endif
2221 #endif
2222
2223 #endif /* end of oal_net.h */
2224