Mistake on this page?
Report an issue in GitHub or email us
whd_types_int.h
Go to the documentation of this file.
1 /*
2  * Copyright 2021, Cypress Semiconductor Corporation (an Infineon company)
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /** @file
19  * Defines common constants used with WHD within src folder
20  *
21  */
22 
23 #ifndef INCLUDED_WHD_TYPES_INT_H_
24 #define INCLUDED_WHD_TYPES_INT_H_
25 
26 #include <stdint.h>
27 #include <stddef.h>
28 #include <inttypes.h>
29 
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #endif
34 
35 /******************************************************
36 * Macros
37 ******************************************************/
38 #define MAX_BUS_HEADER_SIZE 4
39 
40 /**
41  * The size of an Ethernet header
42  */
43 #define WHD_ETHERNET_SIZE (14)
44 
45 /**
46  * Ethernet Ethertypes
47  */
48 #define WHD_ETHERTYPE_IPv4 0x0800
49 #define WHD_ETHERTYPE_IPv6 0x86DD
50 #define WHD_ETHERTYPE_ARP 0x0806
51 #define WHD_ETHERTYPE_RARP 0x8035
52 #define WHD_ETHERTYPE_EAPOL 0x888E
53 #define WHD_ETHERTYPE_DOT1AS 0x88F7
54 #define WHD_ETHERTYPE_8021Q 0x8100
55 
56 /* bss_info_cap_t flags */
57 #define WL_BSS_FLAGS_FROM_BEACON 0x01 /* bss_info derived from beacon */
58 #define WL_BSS_FLAGS_FROM_CACHE 0x02 /* bss_info collected from cache */
59 #define WL_BSS_FLAGS_RSSI_ONCHANNEL 0x04 /* rssi info received on channel (vs offchannel) */
60 #define WL_BSS_FLAGS_HS20 0x08 /* hotspot 2.0 capable */
61 #define WL_BSS_FLAGS_RSSI_INVALID 0x10 /* BSS contains invalid RSSI */
62 #define WL_BSS_FLAGS_RSSI_INACCURATE 0x20 /* BSS contains inaccurate RSSI */
63 #define WL_BSS_FLAGS_SNR_INVALID 0x40 /* BSS contains invalid SNR */
64 #define WL_BSS_FLAGS_NF_INVALID 0x80 /* BSS contains invalid noise floor */
65 
66 #define HT_CAPABILITIES_IE_LENGTH (26)
67 #define DOT11_OUI_LEN (3)/** Length in bytes of 802.11 OUI*/
68 
69 #define WHD_ETHER_ADDR_STR_LEN (18)
70 #define WHD_ETHER_ADDR_LEN (6)
71 
72 #define CHECK_IOCTL_BUFFER(buff) if (buff == \
73  NULL){ WPRINT_WHD_ERROR( ("Buffer alloc failed in function %s at line %d \n", \
74  __func__, __LINE__) ); \
75  return WHD_BUFFER_ALLOC_FAIL; }
76 #define CHECK_RETURN(expr) { \
77  whd_result_t check_res = (expr); \
78  if (check_res != WHD_SUCCESS) \
79  { \
80  WPRINT_WHD_ERROR( ("Function %s failed at line %d checkres = %u \n", \
81  __func__, __LINE__, \
82  (unsigned int)check_res) ); \
83  return check_res; \
84  } \
85 }
86 
87 #define CHECK_RETURN_UNSUPPORTED_OK(expr) { whd_result_t check_res = (expr); \
88  if (check_res != WHD_SUCCESS) \
89  { \
90  return check_res; \
91  } \
92 }
93 #define CHECK_RETURN_UNSUPPORTED_CONTINUE(expr) { whd_result_t check_res = (expr); \
94  if (check_res != WHD_SUCCESS && check_res != WHD_WLAN_UNSUPPORTED) \
95  { \
96  return check_res; \
97  } \
98 }
99 #define RETURN_WITH_ASSERT(expr) { whd_result_t check_res = (expr); \
100  whd_assert("Command failed\n", check_res == WHD_SUCCESS); \
101  return check_res; }
102 
103 #define CHECK_RETURN_IGNORE(expr) { whd_result_t check_res = (expr); \
104  if (check_res != WHD_SUCCESS) \
105  { \
106  } \
107 }
108 
109 #define CHECK_IFP_NULL(ifp) if (ifp == \
110  NULL){ WPRINT_WHD_ERROR( ( \
111  "Interface is not up/NULL and failed in function %s at line %d \n", \
112  __func__, __LINE__) ); \
113  return WHD_UNKNOWN_INTERFACE; }
114 
115 #define CHECK_DRIVER_NULL(driver) if (driver == \
116  NULL){ WPRINT_WHD_ERROR( ( \
117  "WHD driver is not up/NULL and failed in function %s at line %d \n", \
118  __func__, __LINE__) ); \
119  return WHD_DOES_NOT_EXIST; }
120 
121 #define MIN_OF(x, y) ( (x) < (y) ? (x) : (y) )
122 #define MAX_OF(x, y) ( (x) > (y) ? (x) : (y) )
123 
124 #ifndef ROUND_UP
125 #define ROUND_UP(x, y) ( (x) % (y) ? (x) + (y) - ( (x) % (y) ) : (x) )
126 #endif
127 
128 #ifndef DIV_ROUND_UP
129 #define DIV_ROUND_UP(m, n) ( ( (m) + (n) - 1 ) / (n) )
130 #endif
131 
132 #define WHD_WRITE_16(pointer, value) (*( (uint16_t *)pointer ) = value)
133 #define WHD_WRITE_32(pointer, value) (*( (uint32_t *)pointer ) = value)
134 #define WHD_READ_16(pointer) *( (uint16_t *)pointer )
135 #define WHD_READ_32(pointer) *( (uint32_t *)pointer )
136 
137 /**
138  * Macro for checking for NULL MAC addresses
139  */
140 #define NULL_MAC(a) ( ( ( ( (unsigned char *)a )[0] ) == 0 ) && \
141  ( ( ( (unsigned char *)a )[1] ) == 0 ) && \
142  ( ( ( (unsigned char *)a )[2] ) == 0 ) && \
143  ( ( ( (unsigned char *)a )[3] ) == 0 ) && \
144  ( ( ( (unsigned char *)a )[4] ) == 0 ) && \
145  ( ( ( (unsigned char *)a )[5] ) == 0 ) )
146 
147 /**
148  * Macro for checking for Broadcast address
149  */
150 #define BROADCAST_ID(a) ( ( ( ( (unsigned char *)a )[0] ) == 255 ) && \
151  ( ( ( (unsigned char *)a )[1] ) == 255 ) && \
152  ( ( ( (unsigned char *)a )[2] ) == 255 ) && \
153  ( ( ( (unsigned char *)a )[3] ) == 255 ) && \
154  ( ( ( (unsigned char *)a )[4] ) == 255 ) && \
155  ( ( ( (unsigned char *)a )[5] ) == 255 ) )
156 
157 /* Suppress unused variable warning occurring due to an assert which is disabled in release mode */
158 #define REFERENCE_DEBUG_ONLY_VARIABLE(x) ( (void)(x) )
159 
160 /* Suppress unused parameter warning */
161 #define UNUSED_PARAMETER(x) ( (void)(x) )
162 
163 /* Suppress unused variable warning */
164 #define UNUSED_VARIABLE(x) ( (void)(x) )
165 
166 #if defined (__IAR_SYSTEMS_ICC__)
167 #define DISABLE_COMPILER_WARNING(x) _Pragma(#x)
168 #define ENABLE_COMPILER_WARNING(x) _Pragma(#x)
169 #else
170 #define DISABLE_COMPILER_WARNING(x)
171 #define ENABLE_COMPILER_WARNING(x)
172 #endif
173 
174 /******************************************************
175 * Type Definitions
176 ******************************************************/
177 
178 /******************************************************
179 * Constants
180 ******************************************************/
181 
182 /******************************************************
183 * Structures and Enumerations
184 ******************************************************/
185 #pragma pack(1)
186 typedef struct
187 {
188  whd_buffer_queue_ptr_t queue_next;
189  char bus_header[MAX_BUS_HEADER_SIZE];
191 #pragma pack()
192 
193 /* 802.11 Information Element Identification Numbers (as per section 8.4.2.1 of 802.11-2012) */
194 typedef enum
195 {
196  DOT11_IE_ID_SSID = 0,
197  DOT11_IE_ID_SUPPORTED_RATES = 1,
198  DOT11_IE_ID_FH_PARAMETER_SET = 2,
199  DOT11_IE_ID_DSSS_PARAMETER_SET = 3,
200  DOT11_IE_ID_CF_PARAMETER_SET = 4,
201  DOT11_IE_ID_TIM = 5,
202  DOT11_IE_ID_IBSS_PARAMETER_SET = 6,
203  DOT11_IE_ID_COUNTRY = 7,
204  DOT11_IE_ID_HOPPING_PATTERN_PARAMETERS = 8,
205  DOT11_IE_ID_HOPPING_PATTERN_TABLE = 9,
206  DOT11_IE_ID_REQUEST = 10,
207  DOT11_IE_ID_BSS_LOAD = 11,
208  DOT11_IE_ID_EDCA_PARAMETER_SET = 12,
209  DOT11_IE_ID_TSPEC = 13,
210  DOT11_IE_ID_TCLAS = 14,
211  DOT11_IE_ID_SCHEDULE = 15,
212  DOT11_IE_ID_CHALLENGE_TEXT = 16,
213  /* 17-31 Reserved */
214  DOT11_IE_ID_POWER_CONSTRAINT = 32,
215  DOT11_IE_ID_POWER_CAPABILITY = 33,
216  DOT11_IE_ID_TPC_REQUEST = 34,
217  DOT11_IE_ID_TPC_REPORT = 35,
218  DOT11_IE_ID_SUPPORTED_CHANNELS = 36,
219  DOT11_IE_ID_CHANNEL_SWITCH_ANNOUNCEMENT = 37,
220  DOT11_IE_ID_MEASUREMENT_REQUEST = 38,
221  DOT11_IE_ID_MEASUREMENT_REPORT = 39,
222  DOT11_IE_ID_QUIET = 40,
223  DOT11_IE_ID_IBSS_DFS = 41,
224  DOT11_IE_ID_ERP = 42,
225  DOT11_IE_ID_TS_DELAY = 43,
226  DOT11_IE_ID_TCLAS_PROCESSING = 44,
227  DOT11_IE_ID_HT_CAPABILITIES = 45,
228  DOT11_IE_ID_QOS_CAPABILITY = 46,
229  /* 47 Reserved */
230  DOT11_IE_ID_RSN = 48,
231  /* 49 Reserved */
232  DOT11_IE_ID_EXTENDED_SUPPORTED_RATES = 50,
233  DOT11_IE_ID_AP_CHANNEL_REPORT = 51,
234  DOT11_IE_ID_NEIGHBOR_REPORT = 52,
235  DOT11_IE_ID_RCPI = 53,
236  DOT11_IE_ID_MOBILITY_DOMAIN = 54,
237  DOT11_IE_ID_FAST_BSS_TRANSITION = 55,
238  DOT11_IE_ID_TIMEOUT_INTERVAL = 56,
239  DOT11_IE_ID_RIC_DATA = 57,
240  DOT11_IE_ID_DSE_REGISTERED_LOCATION = 58,
241  DOT11_IE_ID_SUPPORTED_OPERATING_CLASSES = 59,
242  DOT11_IE_ID_EXTENDED_CHANNEL_SWITCH_ANNOUNCEMENT = 60,
243  DOT11_IE_ID_HT_OPERATION = 61,
244  DOT11_IE_ID_SECONDARY_CHANNEL_OFFSET = 62,
245  DOT11_IE_ID_BSS_AVERAGE_ACCESS_DELAY = 63,
246  DOT11_IE_ID_ANTENNA = 64,
247  DOT11_IE_ID_RSNI = 65,
248  DOT11_IE_ID_MEASUREMENT_PILOT_TRANSMISSION = 66,
249  DOT11_IE_ID_BSS_AVAILABLE_ADMISSION_CAPACITY = 67,
250  DOT11_IE_ID_BSS_AC_ACCESS_DELAY = 68,
251  DOT11_IE_ID_TIME_ADVERTISEMENT = 69,
252  DOT11_IE_ID_RM_ENABLED_CAPABILITIES = 70,
253  DOT11_IE_ID_MULTIPLE_BSSID = 71,
254  DOT11_IE_ID_20_40_BSS_COEXISTENCE = 72,
255  DOT11_IE_ID_20_40_BSS_INTOLERANT_CHANNEL_REPORT = 73,
256  DOT11_IE_ID_OVERLAPPING_BSS_SCAN_PARAMETERS = 74,
257  DOT11_IE_ID_RIC_DESCRIPTOR = 75,
258  DOT11_IE_ID_MANAGEMENT_MIC = 76,
259  DOT11_IE_ID_EVENT_REQUEST = 78,
260  DOT11_IE_ID_EVENT_REPORT = 79,
261  DOT11_IE_ID_DIAGNOSTIC_REQUEST = 80,
262  DOT11_IE_ID_DIAGNOSTIC_REPORT = 81,
263  DOT11_IE_ID_LOCATION_PARAMETERS = 82,
264  DOT11_IE_ID_NONTRANSMITTED_BSSID_CAPABILITY = 83,
265  DOT11_IE_ID_SSID_LIST = 84,
266  DOT11_IE_ID_MULTIPLE_BSSID_INDEX = 85,
267  DOT11_IE_ID_FMS_DESCRIPTOR = 86,
268  DOT11_IE_ID_FMS_REQUEST = 87,
269  DOT11_IE_ID_FMS_RESPONSE = 88,
270  DOT11_IE_ID_QOS_TRAFFIC_CAPABILITY = 89,
271  DOT11_IE_ID_BSS_MAX_IDLE_PERIOD = 90,
272  DOT11_IE_ID_TFS_REQUEST = 91,
273  DOT11_IE_ID_TFS_RESPONSE = 92,
274  DOT11_IE_ID_WNM_SLEEP_MODE = 93,
275  DOT11_IE_ID_TIM_BROADCAST_REQUEST = 94,
276  DOT11_IE_ID_TIM_BROADCAST_RESPONSE = 95,
277  DOT11_IE_ID_COLLOCATED_INTERFERENCE_REPORT = 96,
278  DOT11_IE_ID_CHANNEL_USAGE = 97,
279  DOT11_IE_ID_TIME_ZONE = 98,
280  DOT11_IE_ID_DMS_REQUEST = 99,
281  DOT11_IE_ID_DMS_RESPONSE = 100,
282  DOT11_IE_ID_LINK_IDENTIFIER = 101,
283  DOT11_IE_ID_WAKEUP_SCHEDULE = 102,
284  /* 103 Reserved */
285  DOT11_IE_ID_CHANNEL_SWITCH_TIMING = 104,
286  DOT11_IE_ID_PTI_CONTROL = 105,
287  DOT11_IE_ID_TPU_BUFFER_STATUS = 106,
288  DOT11_IE_ID_INTERWORKING = 107,
289  DOT11_IE_ID_ADVERTISMENT_PROTOCOL = 108,
290  DOT11_IE_ID_EXPEDITED_BANDWIDTH_REQUEST = 109,
291  DOT11_IE_ID_QOS_MAP_SET = 110,
292  DOT11_IE_ID_ROAMING_CONSORTIUM = 111,
293  DOT11_IE_ID_EMERGENCY_ALERT_IDENTIFIER = 112,
294  DOT11_IE_ID_MESH_CONFIGURATION = 113,
295  DOT11_IE_ID_MESH_ID = 114,
296  DOT11_IE_ID_MESH_LINK_METRIC_REPORT = 115,
297  DOT11_IE_ID_CONGESTION_NOTIFICATION = 116,
298  DOT11_IE_ID_MESH_PEERING_MANAGEMENT = 117,
299  DOT11_IE_ID_MESH_CHANNEL_SWITCH_PARAMETERS = 118,
300  DOT11_IE_ID_MESH_AWAKE_WINDOW = 119,
301  DOT11_IE_ID_BEACON_TIMING = 120,
302  DOT11_IE_ID_MCCAOP_SETUP_REQUEST = 121,
303  DOT11_IE_ID_MCCAOP_SETUP_REPLY = 122,
304  DOT11_IE_ID_MCCAOP_ADVERTISMENT = 123,
305  DOT11_IE_ID_MCCAOP_TEARDOWN = 124,
306  DOT11_IE_ID_GANN = 125,
307  DOT11_IE_ID_RANN = 126,
308  DOT11_IE_ID_EXTENDED_CAPABILITIES = 127,
309  /* 128-129 Reserved */
310  DOT11_IE_ID_PREQ = 130,
311  DOT11_IE_ID_PREP = 131,
312  DOT11_IE_ID_PERR = 132,
313  /* 133-136 Reserved */
314  DOT11_IE_ID_PXU = 137,
315  DOT11_IE_ID_PXUC = 138,
316  DOT11_IE_ID_AUTHENTICATED_MESH_PEERING_EXCHANGE = 139,
317  DOT11_IE_ID_MIC = 140,
318  DOT11_IE_ID_DESTINATION_URI = 141,
319  DOT11_IE_ID_U_APSD_COEXISTENCE = 142,
320  /* 143-173 Reserved */
321  DOT11_IE_ID_MCCAOP_ADVERTISMENT_OVERVIEW = 174,
322  /* 175-220 Reserved */
323  DOT11_IE_ID_VENDOR_SPECIFIC = 221,
324  /* 222-255 Reserved */
325 } dot11_ie_id_t;
326 
327 uint32_t whd_wifi_get_iovar_value(whd_interface_t ifp, const char *iovar, uint32_t *value);
328 uint32_t whd_wifi_set_iovar_buffers(whd_interface_t ifp, const char *iovar, const void **in_buffers,
329  const uint16_t *lengths, const uint8_t num_buffers);
330 uint32_t whd_wifi_set_iovar_value(whd_interface_t ifp, const char *iovar, uint32_t value);
331 
332 /** Sends an IOVAR command
333  *
334  * @param ifp : Pointer to handle instance of whd interface
335  * @param iovar : IOVAR name
336  *
337  * @return WHD_SUCCESS or Error code
338  */
339 extern uint32_t whd_wifi_set_iovar_void(whd_interface_t ifp, const char *iovar);
340 
341 /** Sends an IOVAR command
342  *
343  * @param ifp : Pointer to handle instance of whd interface
344  * @param iovar : IOVAR name
345  * @param buffer : Handle for a packet buffer containing the data value to be sent.
346  * @param buffer_length : Length of out_buffer
347  *
348  * @return WHD_SUCCESS or Error code
349  */
350 extern uint32_t whd_wifi_set_iovar_buffer(whd_interface_t ifp, const char *iovar, void *buffer, uint16_t buffer_length);
351 
352 /** Sends an IOVAR command
353  *
354  * @param ifp : Pointer to handle instance of whd interface
355  * @param iovar : IOVAR name
356  * @param in_buffers : Handle for a packet buffers containing the data value to be sent.
357  * @param in_buffer_lengths : Length of in_buffers
358  * @param num_buffers : Number of handle buffers
359  *
360  * @return WHD_SUCCESS or Error code
361  */
362 extern uint32_t whd_wifi_set_iovar_buffers(whd_interface_t ifp, const char *iovar, const void **in_buffers,
363  const uint16_t *in_buffer_lengths, const uint8_t num_buffers);
364 
365 /** Sends an IOVAR command
366  *
367  * @param ifp : Pointer to handle instance of whd interface
368  * @param iovar : IOVAR name
369  * @param out_buffer : Pointer to receive the handle for the packet buffer containing the response data value received
370  * @param out_length : Length of out_buffer
371  *
372  * @return WHD_SUCCESS or Error code
373  */
374 extern uint32_t whd_wifi_get_iovar_buffer(whd_interface_t ifp, const char *iovar_name, uint8_t *out_buffer,
375  uint16_t out_length);
376 
377 /** Sends an IOVAR command
378  *
379  * @param ifp : Pointer to handle instance of whd interface
380  * @param iovar : IOVAR name
381  * @param buffer : Handle for a packet buffer containing the data value to be sent.
382  * @param buffer_length : Length of out_buffer
383  *
384  * @return WHD_SUCCESS or Error code
385  */
386 extern uint32_t whd_wifi_set_iovar_buffer(whd_interface_t ifp, const char *iovar, void *buffer, uint16_t buffer_length);
387 
388 /** Sends an IOVAR command
389  *
390  * @param ifp : Pointer to handle instance of whd interface
391  * @param iovar : IOVAR name
392  * @param in_buffers : Handle for a packet buffers containing the data value to be sent.
393  * @param in_buffer_lengths : Length of in_buffers
394  * @param num_buffers : Number of handle buffers
395  *
396  * @return WHD_SUCCESS or Error code
397  */
398 extern uint32_t whd_wifi_set_iovar_buffers(whd_interface_t ifp, const char *iovar, const void **in_buffers,
399  const uint16_t *in_buffer_lengths, const uint8_t num_buffers);
400 
401 extern uint32_t whd_wifi_set_mac_address(whd_interface_t ifp, whd_mac_t mac);
402 
403 #ifdef __cplusplus
404 } /* extern "C" */
405 #endif
406 #endif /* ifndef INCLUDED_WHD_TYPES_INT_H_ */
407 
#define MAX_BUS_HEADER_SIZE
Max bus header size for all bus types (sdio/spi)
Definition: whd_types.h:103
Structure for storing a MAC address (Wi-Fi Media Access Control address).
Definition: whd_types.h:385
uint32_t whd_wifi_get_iovar_buffer(whd_interface_t ifp, const char *iovar_name, uint8_t *out_buffer, uint16_t out_length)
Sends an IOVAR command.
uint32_t whd_wifi_set_iovar_void(whd_interface_t ifp, const char *iovar)
Sends an IOVAR command.
uint32_t whd_wifi_set_iovar_buffer(whd_interface_t ifp, const char *iovar, void *buffer, uint16_t buffer_length)
Sends an IOVAR command.
uint32_t whd_wifi_set_iovar_buffers(whd_interface_t ifp, const char *iovar, const void **in_buffers, const uint16_t *lengths, const uint8_t num_buffers)
Sends an IOVAR command.
whd_buffer_t whd_buffer_queue_ptr_t
type definition for whd_buffer_t
Definition: whd_types.h:910
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.