Mistake on this page?
Report an issue in GitHub or email us
whd_chip.h
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 #ifndef INCLUDED_WHD_CHIP_H
19 #define INCLUDED_WHD_CHIP_H
20 
21 #include "cyabs_rtos.h" /* For cy_semaphore_t */
22 
23 #include "whd_endian.h"
24 #include "whd.h"
25 #include "whd_wifi_api.h"
26 
27 #ifdef __cplusplus
28 extern "C"
29 {
30 #endif
31 
32 /******************************************************
33 * Constants
34 ******************************************************/
35 #define WHD_WLAN_WAKE_TIMEOUT (10000)
36 #define WHD_SHARED_MEMORY_POLLING_DELAY (10)
37 #define SICF_CPUHALT (0x0020)
38 
39 /******************************************************
40 * Enumerations
41 ******************************************************/
42 /**
43  * Enumerated list of aggregate codes and edit WHD_COUNTRY_AGGREGATE_CUSTOMER for supporting new aggregate
44  * as per customer like XZ/278
45  */
46 typedef enum
47 {
48  WHD_COUNTRY_AGGREGATE_XA_0 = MK_CNTRY('X', 'A', 0),
49  WHD_COUNTRY_AGGREGATE_XT_0 = MK_CNTRY('X', 'T', 0),
50  WHD_COUNTRY_AGGREGATE_XV_0 = MK_CNTRY('X', 'V', 0),
51  WHD_COUNTRY_AGGREGATE_CUSTOMER = MK_CNTRY('X', 'Z', 278),
52 } whd_aggregate_code_t;
53 
54 typedef enum
55 {
56  /* Note : If changing this, core_base_address must be changed also */
57  WLAN_ARM_CORE = 0, SOCRAM_CORE = 1, SDIOD_CORE = 2
58 } device_core_t;
59 
60 typedef enum
61 {
62  WLAN_DOWN, WLAN_UP, WLAN_OFF
63 } wlan_state_t;
64 
65 typedef enum
66 {
67  WLAN_CORE_FLAG_NONE, WLAN_CORE_FLAG_CPU_HALT,
68 } wlan_core_flag_t;
69 
70 /**
71  * Enumeration of AKM (authentication and key management) suites. Table 8-140 802.11mc D3.0.
72  */
73 typedef enum
74 {
75  WHD_AKM_RESERVED = 0,
76  WHD_AKM_8021X = 1, /**< WPA2 enterprise */
77  WHD_AKM_PSK = 2, /**< WPA2 PSK */
78  WHD_AKM_FT_8021X = 3, /**< 802.11r Fast Roaming enterprise */
79  WHD_AKM_FT_PSK = 4, /**< 802.11r Fast Roaming PSK */
80  WHD_AKM_8021X_SHA256 = 5,
81  WHD_AKM_PSK_SHA256 = 6,
82  WHD_AKM_TDLS = 7, /**< Tunneled Direct Link Setup */
83  WHD_AKM_SAE_SHA256 = 8,
84  WHD_AKM_FT_SAE_SHA256 = 9,
85  WHD_AKM_AP_PEER_KEY_SHA256 = 10,
86  WHD_AKM_SUITEB_8021X_HMAC_SHA256 = 11,
87  WHD_AKM_SUITEB_8021X_HMAC_SHA384 = 12,
88  WHD_AKM_SUITEB_FT_8021X_HMAC_SHA384 = 13,
89 } whd_akm_suite_t;
90 
91 /**
92  * Enumeration of cipher suites. Table 8-138 802.11mc D3.0.
93  */
94 typedef enum
95 {
96  WHD_CIPHER_GROUP = 0, /**< Use group cipher suite */
97  WHD_CIPHER_WEP_40 = 1, /**< WEP-40 */
98  WHD_CIPHER_TKIP = 2, /**< TKIP */
99  WHD_CIPHER_RESERVED = 3, /**< Reserved */
100  WHD_CIPHER_CCMP_128 = 4, /**< CCMP-128 - default pairwise and group cipher suite in an RSNA */
101  WHD_CIPHER_WEP_104 = 5, /**< WEP-104 - also known as WEP-128 */
102  WHD_CIPHER_BIP_CMAC_128 = 6, /**< BIP-CMAC-128 - default management frame cipher suite */
103  WHD_CIPHER_GROUP_DISALLOWED = 7, /**< Group address traffic not allowed */
104  WHD_CIPHER_GCMP_128 = 8, /**< GCMP-128 - default for 60 GHz STAs */
105  WHD_CIPHER_GCMP_256 = 9, /**< GCMP-256 - introduced for Suite B */
106  WHD_CIPHER_CCMP_256 = 10, /**< CCMP-256 - introduced for suite B */
107  WHD_CIPHER_BIP_GMAC_128 = 11, /**< BIP-GMAC-128 - introduced for suite B */
108  WHD_CIPHER_BIP_GMAC_256 = 12, /**< BIP-GMAC-256 - introduced for suite B */
109  WHD_CIPHER_BIP_CMAC_256 = 13, /**< BIP-CMAC-256 - introduced for suite B */
110 } whd_80211_cipher_t;
111 
112 /******************************************************
113 * Structures
114 ******************************************************/
115 
116 typedef struct whd_chip_info
117 {
118  uint16_t chip_id;
119  whd_bool_t save_restore_enable;
120 
122 
123 typedef struct
124 {
125  wlan_state_t state;
126  whd_country_code_t country_code;
127  whd_aggregate_code_t aggregate_code;
128  uint32_t keep_wlan_awake;
130 
131 #pragma pack(1)
132 
133 /* 802.11 Information Element structures */
134 
135 /* Country Information */
136 #define COUNTRY_INFO_IE_MINIMUM_LENGTH (6)
137 
138 typedef struct
139 {
140  uint8_t first_chan_num;
141  uint8_t num_chans;
142  uint8_t max_tx_pwr_level;
144 
145 /* Structures for TLVs with 8-bit type and 8-bit length */
146 typedef struct
147 {
148  uint8_t type;
149  uint8_t length;
151 
152 typedef struct
153 {
154  uint8_t type;
155  uint8_t length;
156  uint8_t data[1];
158 
159 typedef struct
160 {
161  whd_tlv8_header_t tlv_header; /* id, length */
162  char ccode[2]; /* dot11CountryString MIB octet 1~2, two letter country code */
163  uint8_t env; /* dot11CountryString MIB octet 3, indicate indoor/outdoor environment */
164  country_chan_info_t country_chan_info[1]; /* At least one country channel info triples */
166 
167 /* Robust Secure Network */
168 typedef struct
169 {
170  whd_tlv8_header_t tlv_header; /* id, length */
171  uint16_t version;
172  uint32_t group_key_suite; /* See whd_80211_cipher_t for values */
173  uint16_t pairwise_suite_count;
174  uint32_t pairwise_suite_list[1];
176 
177 #define RSN_IE_MINIMUM_LENGTH (8)
178 
179 typedef struct
180 {
181  whd_tlv8_header_t tlv_header; /* id, length */
182  uint8_t oui[4];
184 
185 #define VENDOR_SPECIFIC_IE_MINIMUM_LENGTH (4)
186 
187 /* WPA IE */
188 typedef struct
189 {
190  vendor_specific_ie_header_t vendor_specific_header;
191  uint16_t version;
192  uint32_t multicast_suite;
193  uint16_t unicast_suite_count;
194  uint8_t unicast_suite_list[1][4];
196 
197 #define WPA_IE_MINIMUM_LENGTH (12)
198 
199 typedef struct
200 {
201  uint16_t akm_suite_count;
202  uint32_t akm_suite_list[1];
204 
205 typedef struct
206 {
207  whd_tlv8_header_t tlv_header; /* id, length */
208  uint16_t ht_capabilities_info;
209  uint8_t ampdu_parameters;
210  uint8_t rx_mcs[10];
211  uint16_t rxhighest_supported_data_rate;
212  uint8_t tx_supported_mcs_set;
213  uint8_t tx_mcs_info[3];
214  uint16_t ht_extended_capabilities;
215  uint32_t transmit_beam_forming_capabilities;
216  uint8_t antenna_selection_capabilities;
218 
219 #define HT_CAPABILITIES_INFO_LDPC_CODING_CAPABILITY (1 << 0)
220 #define HT_CAPABILITIES_INFO_SUPPORTED_CHANNEL_WIDTH_SET (1 << 1)
221 #define HT_CAPABILITIES_INFO_SM_POWER_SAVE_OFFSET (1 << 2)
222 #define HT_CAPABILITIES_INFO_SM_POWER_SAVE_MASK (3 << 2)
223 #define HT_CAPABILITIES_INFO_HT_GREENFIELD (1 << 4)
224 #define HT_CAPABILITIES_INFO_SHORT_GI_FOR_20MHZ (1 << 5)
225 #define HT_CAPABILITIES_INFO_SHORT_GI_FOR_40MHZ (1 << 6)
226 #define HT_CAPABILITIES_INFO_TX_STBC (1 << 7)
227 #define HT_CAPABILITIES_INFO_RX_STBC_OFFSET (1 << 8)
228 #define HT_CAPABILITIES_INFO_RX_STBC_MASK (3 << 8)
229 #define HT_CAPABILITIES_INFO_HT_DELAYED_BLOCK_ACK (1 << 10)
230 #define HT_CAPABILITIES_INFO_MAXIMUM_A_MSDU_LENGTH (1 << 11)
231 #define HT_CAPABILITIES_INFO_DSSS_CCK_MODE_IN_40MHZ (1 << 12)
232 /* bit 13 reserved */
233 #define HT_CAPABILITIES_INFO_40MHZ_INTOLERANT (1 << 14)
234 #define HT_CAPABILITIES_INFO_L_SIG_TXOP_PROTECTION_SUPPORT (1 << 15)
235 
236 typedef unsigned int uint;
237 typedef struct
238 {
239  uint buf;
240  uint buf_size;
241  uint idx;
242  uint out_idx; /* output index */
243 } hnd_log_t;
244 
245 #define CBUF_LEN 128
246 
247 typedef struct
248 {
249  /* Virtual UART
250  * When there is no UART (e.g. Quickturn), the host should write a complete
251  * input line directly into cbuf and then write the length into vcons_in.
252  * This may also be used when there is a real UART (at risk of conflicting with
253  * the real UART). vcons_out is currently unused.
254  */
255  volatile uint vcons_in;
256  volatile uint vcons_out;
257 
258  /* Output (logging) buffer
259  * Console output is written to a ring buffer log_buf at index log_idx.
260  * The host may read the output when it sees log_idx advance.
261  * Output will be lost if the output wraps around faster than the host polls.
262  */
263  hnd_log_t log;
264 
265  /* Console input line buffer
266  * Characters are read one at a time into cbuf until <CR> is received, then
267  * the buffer is processed as a command line. Also used for virtual UART.
268  */
269  uint cbuf_idx;
270  char cbuf[CBUF_LEN];
271 } hnd_cons_t;
272 
273 typedef struct wifi_console
274 {
275  uint count; /* Poll interval msec counter */
276  uint log_addr; /* Log struct address (fixed) */
277  hnd_log_t log; /* Log struct (host copy) */
278  uint bufsize; /* Size of log buffer */
279  char *buf; /* Log buffer (host copy) */
280  uint last; /* Last buffer read index */
282 
283 typedef struct
284 {
285  uint flags;
286  uint trap_addr;
287  uint assert_exp_addr;
288  uint assert_file_addr;
289  uint assert_line;
290  uint console_addr;
291  uint msgtrace_addr;
292  uint fwid;
293 } wlan_shared_t;
294 
295 /* Buffer size to be allocated to read wlan log */
296 #define WLAN_LOG_BUF_LEN (4 * 1024)
297 
298 #define WHD_IOCTL_LOG_SIZE 64
299 #define WHD_IOVAR_STRING_SIZE 128
300 #define WHD_MAX_DATA_SIZE 64
301 
302 #define WHD_IOCTL_LOG_ADD(x, y, z) whd_ioctl_log_add(x, y, z)
303 #define WHD_IOCTL_LOG_ADD_EVENT(w, x, y, z) whd_ioctl_log_add_event(w, x, y, z)
304 #define WHD_IOCTL_PRINT(x) whd_ioctl_print(x)
305 
306 typedef struct
307 {
308  uint32_t ioct_log;
309  uint8_t is_this_event;
310  uint8_t data[WHD_MAX_DATA_SIZE];
311  uint32_t data_size;
312  uint16_t flag;
313  uint32_t reason;
315 
316 void whd_ioctl_log_add(whd_driver_t whd_driver, uint32_t cmd, whd_buffer_t buffer);
317 void whd_ioctl_log_add_event(whd_driver_t whd_driver, uint32_t cmd, uint16_t flag, uint32_t data);
318 
319 whd_result_t whd_ioctl_print(whd_driver_t whd_driver);
320 
321 #pragma pack()
322 
323 typedef struct whd_internal_info
324 {
325  whd_wlan_status_t whd_wlan_status;
326  wifi_console_t *c;
327  wifi_console_t console;
328  wlan_shared_t sh;
329  uint32_t console_addr;
330  whd_scan_result_callback_t scan_result_callback;
331  whd_scan_result_t *whd_scan_result_ptr;
332  /* The semaphore used to wait for completion of a join;
333  * whd_wifi_join_halt uses this to release waiting threads (if any) */
334  cy_semaphore_t *active_join_semaphore;
335  whd_bool_t active_join_mutex_initted;
336  cy_semaphore_t active_join_mutex;
337  uint con_lastpos;
338  whd_bool_t whd_wifi_p2p_go_is_up;
339  uint32_t whd_join_status[3];
340 
342 
343 #pragma pack(1)
344 
345 typedef struct
346 {
347  char abbrev[3];
348  uint8_t rev;
349  uint8_t data[64];
351 
352 #pragma pack()
353 
354 void whd_internal_info_init(whd_driver_t whd_driver);
355 
356 /******************************************************
357 * Function Declarations
358 ******************************************************/
359 
360 extern void whd_wifi_chip_info_init(whd_driver_t whd_driver);
361 extern whd_result_t whd_wlan_bus_complete_ds_wake(whd_driver_t whd_driver, whd_bool_t wake_from_firmware,
362  uint32_t wake_event_indication_addr, uint32_t wake_indication_addr,
363  uint32_t sdio_control_addr);
364 extern whd_result_t whd_wifi_set_custom_country_code(whd_interface_t ifp, const whd_country_info_t *country_code);
365 
366 /* Device core control functions */
367 extern whd_result_t whd_disable_device_core(whd_driver_t whd_driver, device_core_t core_id, wlan_core_flag_t core_flag);
368 extern whd_result_t whd_reset_device_core(whd_driver_t whd_driver, device_core_t core_id, wlan_core_flag_t core_flag);
369 extern whd_result_t whd_reset_core(whd_driver_t whd_driver, device_core_t core_id, uint32_t bits, uint32_t resetbits);
370 extern whd_result_t whd_wlan_armcore_run(whd_driver_t whd_driver, device_core_t core_id, wlan_core_flag_t core_flag);
371 extern whd_result_t whd_device_core_is_up(whd_driver_t whd_driver, device_core_t core_id);
372 
373 /* Chip specific functions */
374 extern whd_result_t whd_allow_wlan_bus_to_sleep(whd_driver_t whd_driver);
375 extern whd_result_t whd_ensure_wlan_bus_is_up(whd_driver_t whd_driver);
376 
377 extern whd_result_t whd_chip_specific_init(whd_driver_t whd_driver);
378 extern whd_result_t whd_chip_specific_socsram_init(whd_driver_t whd_driver);
379 extern whd_result_t whd_wifi_read_wlan_log(whd_driver_t whd_driver, char *buffer, uint32_t buffer_size);
381 extern whd_result_t whd_wifi_read_wlan_log_unsafe(whd_driver_t whd_driver, uint32_t wlan_shared_address, char *buffer,
382  uint32_t buffer_size);
383 
384 extern void whd_wifi_peek(whd_driver_t whd_driver, uint32_t address, uint8_t register_length, uint8_t *value);
385 extern void whd_wifi_poke(whd_driver_t whd_driver, uint32_t address, uint8_t register_length, uint32_t value);
386 extern uint32_t whd_wifi_get_btc_params(whd_driver_t whd_driver, uint32_t address, whd_interface_t interface);
387 
388 #ifdef __cplusplus
389 } /* extern "C" */
390 #endif
391 
392 #endif /* ifndef INCLUDED_WHD_CHIP_H */
393 
whd_country_code_t
Enumerated list of country codes.
Definition: whd_types.h:434
Provides abstract pointer type to act as instance for: driver, interface, buffer funcs, network funcs, resource funcs and bus funcs.
Structure for storing scan results.
Definition: whd_types.h:690
void(* whd_scan_result_callback_t)(whd_scan_result_t **result_ptr, void *user_data, whd_scan_status_t status)
Scan result callback function pointer type.
Definition: whd_wifi_api.h:197
whd_bool_t
Boolean values.
Definition: whd_types.h:162
uint32_t whd_wifi_print_whd_log(whd_driver_t whd_drv)
To print whd log information.
uint32_t whd_result_t
WHD result is specified as uint32_t value.
Definition: whd_types.h:776
uint32_t whd_wifi_read_wlan_log(whd_driver_t whd_drv, char *buffer, uint32_t buffer_size)
To print whd log information.
#define MK_CNTRY(a, b, rev)
Macro for creating country codes according to endianness.
Definition: whd_types.h:425
Prototypes of functions for controlling the Wi-Fi system.
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.