1 /*
2  * Copyright 2023, 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  *  Prototypes of functions for controlling the Wi-Fi system
20  *
21  *  This file provides prototypes for end-user functions which allow
22  *  actions such as scanning for Wi-Fi networks, joining Wi-Fi
23  *  networks, getting the MAC address, etc
24  *
25  */
26 
27 #include "cybsp.h"
28 #include "whd.h"
29 #include "whd_types.h"
30 
31 #ifndef INCLUDED_WHD_WIFI_API_H
32 #define INCLUDED_WHD_WIFI_API_H
33 
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #endif
38 
39 /******************************************************
40 *             Function declarations
41 ******************************************************/
42 
43 /** @addtogroup wifi WHD Wi-Fi API
44  *  APIs for controlling the Wi-Fi system
45  *  @{
46  */
47 
48 /** @addtogroup wifimanagement WHD Wi-Fi Management API
49  *  @ingroup wifi
50  *  Initialisation and other management functions for WHD system
51  *  @{
52  */
53 
54 /** Initialize an instance of the WHD driver
55  *
56  *  @param whd_driver_ptr       Pointer to Pointer to handle instance of the driver
57  *  @param whd_init_config      Pointer to configuration data that controls how the driver is initialized
58  *  @param resource_ops         Pointer to resource interface to provide resources to the driver initialization process
59  *  @param buffer_ops           Pointer to a buffer interface to provide buffer related services to the driver instance
60  *  @param network_ops          Pointer to a whd_netif_funcs_t to provide network stack services to the driver instance
61  *
62  *  @return WHD_SUCCESS or Error code
63  */
64 extern uint32_t whd_init(whd_driver_t *whd_driver_ptr, whd_init_config_t *whd_init_config,
65                          whd_resource_source_t *resource_ops, whd_buffer_funcs_t *buffer_ops,
66                          whd_netif_funcs_t *network_ops);
67 /* @} */
68 /* @} */
69 
70 /** @addtogroup busapi WHD Bus API
71  * Allows WHD to operate with specific SDIO/SPI bus
72  *  @{
73  */
74 
75 #if (CYBSP_WIFI_INTERFACE_TYPE == CYBSP_SDIO_INTERFACE)
76 /** Attach the WLAN Device to a specific SDIO bus
77  *
78  *  @param  whd_driver         Pointer to handle instance of the driver
79  *  @param  whd_config         Configuration for SDIO bus
80  *  @param  sdio_obj           The SDHC hardware interface, from the Level 3 CY HW APIs
81  *
82  *  @return WHD_SUCCESS or Error code
83  */
84 extern uint32_t whd_bus_sdio_attach(whd_driver_t whd_driver, whd_sdio_config_t *whd_config, whd_sdio_t *sdio_obj);
85 
86 /** Detach the WLAN Device to a specific SDIO bus
87  *
88  *  @param  whd_driver         Pointer to handle instance of the driver
89  */
90 extern void whd_bus_sdio_detach(whd_driver_t whd_driver);
91 
92 #elif (CYBSP_WIFI_INTERFACE_TYPE == CYBSP_SPI_INTERFACE)
93 /** Attach the WLAN Device to a specific SPI bus
94  *
95  *  @param  whd_driver        Pointer to handle instance of the driver
96  *  @param  whd_config        Configuration for SPI bus
97  *  @param  spi_obj           The SPI hardware interface, from the Level 3 CY HW APIs
98  *
99  *  @return WHD_SUCCESS or Error code
100  */
101 extern uint32_t whd_bus_spi_attach(whd_driver_t whd_driver, whd_spi_config_t *whd_config, whd_spi_t *spi_obj);
102 
103 /** Detach the WLAN Device to a specific SPI bus
104  *
105  *  @param  whd_driver         Pointer to handle instance of the driver
106  */
107 extern void whd_bus_spi_detach(whd_driver_t whd_driver);
108 
109 #elif (CYBSP_WIFI_INTERFACE_TYPE == CYBSP_M2M_INTERFACE)
110 /** Attach the WLAN Device to M2M bus
111  *
112  *  @param  whd_driver        Pointer to handle instance of the driver
113  *  @param  whd_config        Configuration for M2M bus
114  *  @param  m2m_obj           The M2M hardware interface, from the Level 3 CY HW APIs
115  *
116  *  @return WHD_SUCCESS or Error code
117  */
118 extern uint32_t whd_bus_m2m_attach(whd_driver_t whd_driver, whd_m2m_config_t *whd_config, whd_m2m_t *m2m_obj);
119 
120 /** Detach the WLAN Device to a specific M2M bus
121  *
122  *  @param  whd_driver         Pointer to handle instance of the driver
123  */
124 extern void whd_bus_m2m_detach(whd_driver_t whd_driver);
125 
126 #else
127 error "CYBSP_WIFI_INTERFACE_TYPE is not defined"
128 #endif
129 
130 /*  @} */
131 
132 /** @addtogroup wifi WHD Wi-Fi API
133  *  APIs for controlling the Wi-Fi system
134  *  @{
135  */
136 
137 /** @addtogroup wifimanagement WHD Wi-Fi Management API
138  *  @ingroup wifi
139  *  Initialisation and other management functions for WHD system
140  *  @{
141  */
142 
143 /**
144  * Turn on the Wi-Fi device
145  *
146  *  Initialise Wi-Fi platform
147  *  Program various WiFi parameters and modes
148  *
149  *  @param  whd_driver        Pointer to handle instance of the driver
150  *  @param   ifpp             Pointer to Pointer to handle instance of whd interface
151  *
152  *  @return WHD_SUCCESS if initialization is successful, error code otherwise
153  */
154 extern uint32_t whd_wifi_on(whd_driver_t whd_driver, whd_interface_t *ifpp);
155 
156 /**
157  * Turn off the Wi-Fi device
158  *
159  *  - De-Initialises the required parts of the hardware platform
160  *    i.e. pins for SDIO/SPI, interrupt, reset, power etc.
161  *
162  *  - De-Initialises the whd thread which arbitrates access
163  *    to the SDIO/SPI bus
164  *
165  *  @param   ifp              Pointer to handle instance of whd interface
166  *
167  *  @return WHD_SUCCESS if deinitialization is successful, Error code otherwise
168  */
169 extern uint32_t whd_wifi_off(whd_interface_t ifp);
170 
171 /** Shutdown this instance of the wifi driver, freeing all used resources
172  *
173  *  @param   ifp              Pointer to handle instance of whd interface
174  *
175  *  @return WHD_SUCCESS or Error code
176  */
177 extern uint32_t whd_deinit(whd_interface_t ifp);
178 
179 /** Brings up the Wi-Fi core
180  *
181  *  @param   ifp              Pointer to handle instance of whd interface
182  *
183  *  @return WHD_SUCCESS or Error code
184  */
185 extern uint32_t whd_wifi_set_up(whd_interface_t ifp);
186 
187 /** Bring down the Wi-Fi core
188  *
189  *  WARNING / NOTE:
190  *     This brings down the Wi-Fi core and existing network connections will be lost.
191  *
192  *  @param   ifp               Pointer to handle instance of whd interface
193  *
194  *  @return WHD_SUCCESS or Error code
195  */
196 extern uint32_t whd_wifi_set_down(whd_interface_t ifp);
197 
198 /** Creates a secondary interface
199  *
200  *  @param  whd_drv              Pointer to handle instance of the driver
201  *  @param  mac_addr             MAC address for the interface
202  *  @param  ifpp                 Pointer to the whd interface pointer
203  *
204  *  @return WHD_SUCCESS or Error code
205  */
206 extern uint32_t whd_add_secondary_interface(whd_driver_t whd_drv, whd_mac_t *mac_addr, whd_interface_t *ifpp);
207 /*  @} */
208 
209 /** @addtogroup wifijoin   WHD Wi-Fi Join, Scan and Halt API
210  *  @ingroup wifi
211  *  Wi-Fi APIs for join, scan & leave
212  *  @{
213  */
214 
215 /** Scan result callback function pointer type
216  *
217  * @param result_ptr   A pointer to the pointer that indicates where to put the next scan result
218  * @param user_data    User provided data
219  * @param status       Status of scan process
220  */
221 typedef void (*whd_scan_result_callback_t)(whd_scan_result_t **result_ptr, void *user_data, whd_scan_status_t status);
222 
223 /** Initiates a scan to search for 802.11 networks.
224  *
225  *  This functions returns the scan results with limited sets of parameter in a buffer provided by the caller.
226  *  It is also a blocking call. It is an simplified version of the whd_wifi_scan().
227  *
228  *  @param   ifp                       Pointer to handle instance of whd interface
229  *  @param   scan_result               Pointer to user requested records buffer.
230  *  @param   count                     Pointer to the no of records user is interested in, and also to the no of record received.
231  *
232  *  @note    When scanning specific channels, devices with a strong signal strength on nearby channels may be detected
233  *
234  *  @return  WHD_SUCCESS or Error code
235  */
236 extern uint32_t whd_wifi_scan_synch(whd_interface_t ifp,
237                                     whd_sync_scan_result_t *scan_result,
238                                     uint32_t *count
239                                     );
240 
241 /** Initiates a scan to search for 802.11 networks.
242  *
243  *  The scan progressively accumulates results over time, and may take between 1 and 10 seconds to complete.
244  *  The results of the scan will be individually provided to the callback function.
245  *  Note: The callback function will be executed in the context of the WHD thread and so must not perform any
246  *  actions that may cause a bus transaction.
247  *
248  *  @param   ifp                       Pointer to handle instance of whd interface
249  *  @param   scan_type                 Specifies whether the scan should be Active, Passive or scan Prohibited channels
250  *  @param   bss_type                  Specifies whether the scan should search for Infrastructure networks (those using
251  *                                     an Access Point), Ad-hoc networks, or both types.
252  *  @param   optional_ssid             If this is non-Null, then the scan will only search for networks using the specified SSID.
253  *  @param   optional_mac              If this is non-Null, then the scan will only search for networks where
254  *                                     the BSSID (MAC address of the Access Point) matches the specified MAC address.
255  *  @param   optional_channel_list     If this is non-Null, then the scan will only search for networks on the
256  *                                     specified channels - array of channel numbers to search, terminated with a zero
257  *  @param   optional_extended_params  If this is non-Null, then the scan will obey the specifications about
258  *                                     dwell times and number of probes.
259  *  @param   callback                  The callback function which will receive and process the result data.
260  *  @param   result_ptr                Pointer to a pointer to a result storage structure.
261  *  @param   user_data                 user specific data that will be passed directly to the callback function
262  *
263  *  @note - When scanning specific channels, devices with a strong signal strength on nearby channels may be detected
264  *        - Callback must not use blocking functions, nor use WHD functions, since it is called from the context of the
265  *          WHD thread.
266  *        - The callback, result_ptr and user_data variables will be referenced after the function returns.
267  *          Those variables must remain valid until the scan is complete.
268  *
269  *  @return WHD_SUCCESS or Error code
270  */
271 extern uint32_t whd_wifi_scan(whd_interface_t ifp,
272                               whd_scan_type_t scan_type,
273                               whd_bss_type_t bss_type,
274                               const whd_ssid_t *optional_ssid,
275                               const whd_mac_t *optional_mac,
276                               const uint16_t *optional_channel_list,
277                               const whd_scan_extended_params_t *optional_extended_params,
278                               whd_scan_result_callback_t callback,
279                               whd_scan_result_t *result_ptr,
280                               void *user_data);
281 
282 /** Abort a previously issued scan
283  *
284  *  @param   ifp           Pointer to handle instance of whd interface
285  *
286  *  @return WHD_SUCCESS or Error code
287  */
288 extern uint32_t whd_wifi_stop_scan(whd_interface_t ifp);
289 
290 /** Auth result callback function pointer type
291  *
292  * @param result_prt   A pointer to the pointer that indicates where to put the auth result
293  * @param len          the size of result
294  * @param status       Status of auth process
295  * @param flag         flag of h2e will be indicated in auth request event, otherwise is NULL.
296  * @param user_data    user specific data that will be passed directly to the callback function
297  *
298  */
299 typedef void (*whd_auth_result_callback_t)(void *result_ptr, uint32_t len, whd_auth_status_t status, uint8_t *flag,
300                                            void *user_data);
301 
302 /** Initiates SAE auth
303  *
304  *  The results of the auth will be individually provided to the callback function.
305  *  Note: The callback function will be executed in the context of the WHD thread and so must not perform any
306  *  actions that may cause a bus transaction.
307  *
308  *  @param   ifp                       Pointer to handle instance of whd interface
309  *  @param   callback                  The callback function which will receive and process the result data.
310  *  @param   data                      Pointer to a pointer to a result storage structure.
311  *  @param   user_data                 user specific data that will be passed directly to the callback function
312  *
313  *  @note - Callback must not use blocking functions, nor use WHD functions, since it is called from the context of the
314  *          WHD thread.
315  *        - The callback, result_ptr and user_data variables will be referenced after the function returns.
316  *          Those variables must remain valid until the scan is complete.
317  *
318  *  @return WHD_SUCCESS or Error code
319  */
320 extern uint32_t whd_wifi_external_auth_request(whd_interface_t ifp,
321                                                whd_auth_result_callback_t callback,
322                                                void *result_ptr,
323                                                void *user_data);
324 /** Abort authentication request
325  *
326  *  @param   ifp           Pointer to handle instance of whd interface
327  *
328  *  @return WHD_SUCCESS or Error code
329  */
330 extern uint32_t whd_wifi_stop_external_auth_request(whd_interface_t ifp);
331 
332 /** Joins a Wi-Fi network
333  *
334  *  Scans for, associates and authenticates with a Wi-Fi network.
335  *  On successful return, the system is ready to send data packets.
336  *
337  *  @param   ifp           Pointer to handle instance of whd interface
338  *  @param   ssid          A null terminated string containing the SSID name of the network to join
339  *  @param   auth_type     Authentication type
340  *  @param   security_key  A byte array containing either the cleartext security key for WPA/WPA2/WPA3 secured networks
341  *  @param   key_length    The length of the security_key in bytes.
342  *
343  *  @note    In case of WPA3/WPA2 transition mode, the security_key value is WPA3 password.
344  *
345  *  @return  WHD_SUCCESS   when the system is joined and ready to send data packets
346  *           Error code    if an error occurred
347  */
348 extern uint32_t whd_wifi_join(whd_interface_t ifp, const whd_ssid_t *ssid, whd_security_t auth_type,
349                               const uint8_t *security_key, uint8_t key_length);
350 
351 /** Joins a specific Wi-Fi network
352  *
353  *  Associates and authenticates with a specific Wi-Fi access point.
354  *  On successful return, the system is ready to send data packets.
355  *
356  *  @param   ifp           Pointer to handle instance of whd interface
357  *  @param   ap            A pointer to a whd_scan_result_t structure containing AP details and
358  *                         set ap.channel to 0 for unspecificed channel
359  *  @param   security_key  A byte array containing either the cleartext security key for WPA/WPA2
360  *                         secured networks
361  *  @param   key_length    The length of the security_key in bytes.
362  *
363  *  @return  WHD_SUCCESS   when the system is joined and ready to send data packets
364  *           Error code    if an error occurred
365  */
366 extern uint32_t whd_wifi_join_specific(whd_interface_t ifp, const whd_scan_result_t *ap, const uint8_t *security_key,
367                                        uint8_t key_length);
368 
369 /*  @} */
370 
371 /** @addtogroup wifiutilities   WHD Wi-Fi Utility API
372  *  @ingroup wifi
373  *  Allows WHD to perform utility operations
374  *  @{
375  */
376 
377 /** Set the current channel on the WLAN radio
378  *
379  *  @note  On most WLAN devices this will set the channel for both AP *AND* STA
380  *        (since there is only one radio - it cannot be on two channels simulaneously)
381  *
382  *  @param   ifp           Pointer to handle instance of whd interface
383  *  @param   channel       The desired channel
384  *
385  *  @return  WHD_SUCCESS   if the channel was successfully set
386  *           Error code    if the channel was not successfully set
387  */
388 extern uint32_t whd_wifi_set_channel(whd_interface_t ifp, uint32_t channel);
389 
390 /** Get the current channel on the WLAN radio
391  *
392  *  @note On most WLAN devices this will get the channel for both AP *AND* STA
393  *       (since there is only one radio - it cannot be on two channels simulaneously)
394  *
395  *  @param   ifp            Pointer to handle instance of whd interface
396  *  @param   channel        Pointer to receive the current channel
397  *
398  *  @return  WHD_SUCCESS    if the channel was successfully retrieved
399  *           Error code     if the channel was not successfully retrieved
400  */
401 extern uint32_t whd_wifi_get_channel(whd_interface_t ifp, uint32_t *channel);
402 
403 /** Gets the supported channels
404  *
405  *  @param   ifp                 Pointer to handle instance of whd interface
406  *  @param   channel_list        Buffer to store list of the supported channels
407  *                               and max channel is WL_NUMCHANNELS
408  *
409  *  @return  WHD_SUCCESS         if the active connections was successfully read
410  *           WHD_ERROR           if the active connections was not successfully read
411  */
412 extern uint32_t whd_wifi_get_channels(whd_interface_t ifp, whd_list_t *channel_list);
413 
414 
415 /** Set the passphrase
416  *
417  *  @param   ifp            Pointer to handle instance of whd interface
418  *  @param   security_key   The security key (passphrase) which is to be set
419  *  @param   key_length     length of the key
420  *
421  *  @return  WHD_SUCCESS    when the key is set
422  *           Error code     if an error occurred
423  */
424 extern uint32_t whd_wifi_set_passphrase(whd_interface_t ifp, const uint8_t *security_key, uint8_t key_length);
425 
426 /** Set the SAE password
427  *
428  *  @param   ifp            Pointer to handle instance of whd interface
429  *  @param   security_key   The security key (password) which is to be set
430  *  @param   key_length     length of the key
431  *
432  *  @return  WHD_SUCCESS    when the key is set
433  *           Error code     if an error occurred
434  */
435 extern uint32_t whd_wifi_sae_password(whd_interface_t ifp, const uint8_t *security_key, uint8_t key_length);
436 
437 /** Enable WHD internal supplicant and set WPA2 passphrase in case of WPA3/WPA2 transition mode
438  *
439  *  @param   ifp                Pointer to handle instance of whd interface
440  *  @param   security_key_psk   The security key (passphrase) which is to be set
441  *  @param   psk_length         length of the key
442  *  @param   auth_type          Authentication type: @ref WHD_SECURITY_WPA3_WPA2_PSK
443  *
444  *  @return  WHD_SUCCESS        when the supplicant variable and wpa2 passphrase is set
445  *           Error code         if an error occurred
446  */
447 extern uint32_t whd_wifi_enable_sup_set_passphrase(whd_interface_t ifp, const uint8_t *security_key_psk,
448                                                    uint8_t psk_length, whd_security_t auth_type);
449 
450 /** Set the PMK Key
451  *
452  *  @param   ifp            Pointer to handle instance of whd interface
453  *  @param   security_key   The security key (PMK) which is to be set
454  *  @param   key_length     length of the PMK(It must be 32 bytes)
455  *
456  *  @return  WHD_SUCCESS    when the key is set
457  *           Error code     if an error occurred
458  */
459 extern whd_result_t whd_wifi_set_pmk(whd_interface_t ifp, const uint8_t *security_key, uint8_t key_length);
460 
461 /** Set the Roam time threshold
462  *
463  *  @param ifp                  Pointer to handle instance of whd interface
464  *  @param roam_time_threshold  The maximum roam time threshold which is to be set
465  *
466  *  @return  WHD_SUCCESS    when the roam_time_threshold is set
467  *           Error code     if an error occurred
468  */
469 extern whd_result_t whd_wifi_set_roam_time_threshold(whd_interface_t ifp, uint32_t roam_time_threshold);
470 
471 /** Enable WHD internal supplicant
472  *
473  *  @param   ifp            Pointer to handle instance of whd interface
474  *  @param   auth_type      Authentication type
475  *
476  *  @return  WHD_SUCCESS    when the supplicant variable is set
477  *           Error code     if an error occurred
478  */
479 extern uint32_t whd_wifi_enable_supplicant(whd_interface_t ifp, whd_security_t auth_type);
480 
481 /** Set PMKID in Device (WLAN)
482  *
483  *  @param   ifp            Pointer to handle instance of whd interface
484  *  @param   pmkid          Pointer to BSSID and PMKID(16 bytes)
485  *
486  *  @return whd_result_t
487  */
488 extern whd_result_t whd_wifi_set_pmksa(whd_interface_t ifp, const pmkid_t *pmkid);
489 
490 /** Clear all PMKIDs in Device (WLAN), especially the PMKIDs in Supplicant module
491  *
492  *  @param   ifp            Pointer to handle instance of whd interface
493  *
494  *  @return whd_result_t
495  */
496 extern whd_result_t whd_wifi_pmkid_clear(whd_interface_t ifp);
497 
498 /** Retrieve the latest RSSI value
499  *
500  *  @param   ifp           Pointer to handle instance of whd interface
501  *  @param   rssi          The location where the RSSI value will be stored
502  *
503  *  @return  WHD_SUCCESS   if the RSSI was successfully retrieved
504  *           Error code    if the RSSI was not retrieved
505  */
506 extern uint32_t whd_wifi_get_rssi(whd_interface_t ifp, int32_t *rssi);
507 
508 /** Retrieve the latest Roam time threshold value
509  *
510  *  @param   ifp                  Pointer to handle instance of whd interface
511  *  @param   roam_time_threshold  The location where the roam time threshold value will be stored
512  *
513  *  @return  WHD_SUCCESS   if the roam time threshold was successfully retrieved
514  *           Error code    if the roam time threshold was not retrieved
515  */
516 extern uint32_t whd_wifi_get_roam_time_threshold(whd_interface_t ifp, uint32_t *roam_time_threshold);
517 
518 /** Retrieve the associated STA's RSSI value
519  *
520  *  @param   ifp          : Pointer to handle instance of whd interface
521  *  @param   rssi         : The location where the RSSI value will be stored
522  *  @param   client_mac   : Pointer to associated client's MAC address
523  *
524  *  @return  WHD_SUCCESS  : if the RSSI was successfully retrieved
525  *           Error code   : if the RSSI was not retrieved
526  */
527 extern uint32_t whd_wifi_get_ap_client_rssi(whd_interface_t ifp, int32_t *rssi, const whd_mac_t *client_mac);
528 
529 
530 /* @} */
531 
532 /** @addtogroup wifijoin   WHD Wi-Fi Join, Scan and Halt API
533  *  @ingroup wifi
534  *  Wi-Fi APIs for join, scan & leave
535  *  @{
536  */
537 /** Disassociates from a Wi-Fi network.
538  *  Applicable only for STA role
539  *
540  *  @param   ifp           Pointer to handle instance of whd interface.
541  *
542  *  @return  WHD_SUCCESS   On successful disassociation from the AP
543  *           Error code    If an error occurred
544  */
545 extern uint32_t whd_wifi_leave(whd_interface_t ifp);
546 /* @} */
547 
548 /** @addtogroup wifiutilities   WHD Wi-Fi Utility API
549  *  @ingroup wifi
550  *  Allows WHD to perform utility operations
551  *  @{
552  */
553 
554 /** Retrieves the current Media Access Control (MAC) address
555  *  (or Ethernet hardware address) of the 802.11 device
556  *
557  *  @param   ifp           Pointer to handle instance of whd interface
558  *  @param   mac           Pointer to a variable that the current MAC address will be written to
559  *
560  *  @return  WHD_SUCCESS or Error code
561  */
562 extern uint32_t whd_wifi_get_mac_address(whd_interface_t ifp, whd_mac_t *mac);
563 
564 /** Get the BSSID of the interface
565  *
566  *  @param  ifp           Pointer to the whd_interface_t
567  *  @param  bssid         Returns the BSSID address (mac address) if associated
568  *
569  *  @return WHD_SUCCESS or Error code
570  */
571 extern uint32_t whd_wifi_get_bssid(whd_interface_t ifp, whd_mac_t *bssid);
572 /* @} */
573 
574 /** @addtogroup wifisoftap     WHD Wi-Fi SoftAP API
575  *  @ingroup wifi
576  *  Wi-Fi APIs to perform SoftAP related functionalities
577  *  @{
578  */
579 
580 /** Initialises an infrastructure WiFi network (SoftAP)
581  *
582  *  @param   ifp           Pointer to handle instance of whd interface
583  *  @param   ssid          A null terminated string containing the SSID name of the network to join
584  *  @param   auth_type     Authentication type
585  *  @param   security_key  A byte array containing the cleartext security key for the network
586  *  @param   key_length    The length of the security_key in bytes.
587  *  @param   channel       802.11 channel number
588  *
589  *  @return  WHD_SUCCESS   if successfully initialises an AP
590  *           Error code    if an error occurred
591  */
592 extern uint32_t whd_wifi_init_ap(whd_interface_t ifp, whd_ssid_t *ssid, whd_security_t auth_type,
593                                  const uint8_t *security_key, uint8_t key_length, uint8_t channel);
594 
595 /** Start the infrastructure WiFi network (SoftAP)
596  *  using the parameter set by whd_wifi_init_ap() and optionaly by whd_wifi_manage_custom_ie()
597  *
598  *  @return  WHD_SUCCESS   if successfully creates an AP
599  *           Error code    if an error occurred
600  */
601 extern uint32_t whd_wifi_start_ap(whd_interface_t ifp);
602 
603 /** Stops an existing infrastructure WiFi network
604  *
605  *  @param   ifp           Pointer to handle instance of whd interface
606  *
607  *  @return  WHD_SUCCESS   if the AP is successfully stopped or if the AP has not yet been brought up
608  *           Error code    if an error occurred
609  */
610 extern uint32_t whd_wifi_stop_ap(whd_interface_t ifp);
611 
612 
613 /** Get the maximum number of associations supported by AP interfaces
614  *
615  *  @param   ifp           Pointer to handle instance of whd interface
616  *  @param   max_assoc     The maximum number of associations supported by Soft AP interfaces.
617  *
618  *  @return  WHD_SUCCESS   if the maximum number of associated clients was successfully read
619  *           WHD_ERROR     if the maximum number of associated clients was not successfully read
620  */
621 extern uint32_t whd_wifi_ap_get_max_assoc(whd_interface_t ifp, uint32_t *max_assoc);
622 
623 /** Gets the current number of active connections
624  *
625  *  @param   ifp                 Pointer to handle instance of whd interface
626  *  @param   client_list_buffer  Buffer to store list of associated clients
627  *  @param   buffer_length       Length of client list buffer
628  *
629  *  @return  WHD_SUCCESS         if the active connections was successfully read
630  *           WHD_ERROR           if the active connections was not successfully read
631  */
632 extern uint32_t whd_wifi_get_associated_client_list(whd_interface_t ifp, void *client_list_buffer,
633                                                     uint16_t buffer_length);
634 
635 /** Deauthenticates a STA which may or may not be associated to SoftAP
636  *
637  * @param   ifp             Pointer to handle instance of whd interface
638  * @param   mac             Pointer to a variable containing the MAC address to which the deauthentication will be sent
639  *                          NULL mac address will deauthenticate all the associated STAs
640  *
641  * @param   reason          Deauthentication reason code
642  *
643  * @return  WHD_SUCCESS     On successful deauthentication of the other STA
644  *          WHD_ERROR       If an error occurred
645  */
646 extern uint32_t whd_wifi_deauth_sta(whd_interface_t ifp, whd_mac_t *mac, whd_dot11_reason_code_t reason);
647 
648 /** Retrieves AP information
649  *
650  *  @param  ifp            Pointer to handle instance of whd interface
651  *  @param  ap_info        Returns a whd_bss_info_t structure containing AP details
652  *  @param  security       Authentication type
653  *
654  *  @return WHD_SUCCESS    if the AP info was successfully retrieved
655  *          Error code     if the AP info was not successfully retrieved
656  */
657 extern uint32_t whd_wifi_get_ap_info(whd_interface_t ifp, whd_bss_info_t *ap_info, whd_security_t *security);
658 
659 /** Set the beacon interval.
660  *
661  *  Note that the value needs to be set before ap_start in order to beacon interval to take effect.
662  *
663  *  @param  ifp            Pointer to handle instance of whd interface
664  *  @param  interval       Beacon interval in time units (Default: 100 time units = 102.4 ms)
665  *
666  *  @return WHD_SUCCESS or Error code
667  */
668 extern uint32_t whd_wifi_ap_set_beacon_interval(whd_interface_t ifp, uint16_t interval);
669 
670 /** Set the DTIM interval.
671  *
672  *  Note that the value needs to be set before ap_start in order to DTIM interval to take effect.
673  *
674  *  @param  ifp            Pointer to handle instance of whd interface
675  *  @param  interval       DTIM interval, in unit of beacon interval
676  *
677  *  @return WHD_SUCCESS or Error code
678  */
679 extern uint32_t whd_wifi_ap_set_dtim_interval(whd_interface_t ifp, uint16_t interval);
680 /*  @} */
681 
682 
683 /** @addtogroup wifipowersave   WHD Wi-Fi Power Save API
684  *  @ingroup wifi
685  *  Wi-Fi functions for WLAN low power modes
686  *  @{
687  */
688 
689 /** Enables powersave mode on specified interface without regard for throughput reduction
690  *
691  *  This function enables (legacy) 802.11 PS-Poll mode and should be used
692  *  to achieve the lowest power consumption possible when the Wi-Fi device
693  *  is primarily passively listening to the network
694  *
695  *  @param  ifp            Pointer to handle instance of whd interface
696  *
697  *  @return WHD_SUCCESS or Error code
698  */
699 extern uint32_t whd_wifi_enable_powersave(whd_interface_t ifp);
700 
701 /** Enables powersave mode on specified interface while attempting to maximise throughput
702  *
703  *
704  *  Network traffic is typically bursty. Reception of a packet often means that another
705  *  packet will be received shortly afterwards (and vice versa for transmit).
706  *
707  *  In high throughput powersave mode, rather then entering powersave mode immediately
708  *  after receiving or sending a packet, the WLAN chip waits for a timeout period before
709  *  returning to sleep.
710  *
711  *  @param   ifp                    Pointer to handle instance of whd interface
712  *  @param   return_to_sleep_delay  The variable to set return to sleep delay.
713  *                                 return to sleep delay must be set to a multiple of 10 and not equal to zero.
714  *
715  *  @return  WHD_SUCCESS            if power save mode was successfully enabled
716  *           Error code             if power save mode was not successfully enabled
717  *
718  */
719 extern uint32_t whd_wifi_enable_powersave_with_throughput(whd_interface_t ifp, uint16_t return_to_sleep_delay);
720 
721 /** Get powersave mode on specified interface
722  *
723  *  @param  ifp            Pointer to handle instance of whd interface
724  *  @param  value          Value of the current powersave state
725  *                          PM1_POWERSAVE_MODE, PM2_POWERSAVE_MODE, NO_POWERSAVE_MODE
726  *
727  *  @return WHD_SUCCESS or Error code
728  */
729 extern uint32_t whd_wifi_get_powersave_mode(whd_interface_t ifp, uint32_t *value);
730 
731 /** Disables 802.11 power save mode on specified interface
732  *
733  *  @param   ifp               Pointer to handle instance of whd interface
734  *
735  *  @return  WHD_SUCCESS       if power save mode was successfully disabled
736  *           Error code        if power save mode was not successfully disabled
737  *
738  */
739 extern uint32_t whd_wifi_disable_powersave(whd_interface_t ifp);
740 /* @} */
741 
742 /** @addtogroup wifiutilities   WHD Wi-Fi Utility API
743  *  @ingroup wifi
744  *  Allows WHD to perform utility operations
745  *  @{
746  */
747 /** Registers interest in a multicast address
748  *
749  *  Once a multicast address has been registered, all packets detected on the
750  *  medium destined for that address are forwarded to the host.
751  *  Otherwise they are ignored.
752  *
753  *  @param  ifp              Pointer to handle instance of whd interface
754  *  @param  mac              Ethernet MAC address
755  *
756  *  @return WHD_SUCCESS      if the address was registered successfully
757  *          Error code       if the address was not registered
758  */
759 extern uint32_t whd_wifi_register_multicast_address(whd_interface_t ifp, const whd_mac_t *mac);
760 
761 /** Unregisters interest in a multicast address
762  *
763  *  Once a multicast address has been unregistered, all packets detected on the
764  *  medium destined for that address are ignored.
765  *
766  *  @param  ifp              Pointer to handle instance of whd interface
767  *  @param  mac              Ethernet MAC address
768  *
769  *  @return WHD_SUCCESS      if the address was unregistered successfully
770  *          Error code       if the address was not unregistered
771  */
772 extern uint32_t whd_wifi_unregister_multicast_address(whd_interface_t ifp, const whd_mac_t *mac);
773 
774 /** Sets the 802.11 powersave listen interval for a Wi-Fi client, and communicates
775  *  the listen interval to the Access Point. The listen interval will be set to
776  *  (listen_interval x time_unit) seconds.
777  *
778  *  The default value for the listen interval is 0. With the default value of 0 set,
779  *  the Wi-Fi device wakes to listen for AP beacons every DTIM period.
780  *
781  *  If the DTIM listen interval is non-zero, the DTIM listen interval will over ride
782  *  the beacon listen interval value.
783  *
784  *  @param  ifp              Pointer to handle instance of whd interface
785  *  @param  listen_interval  The desired beacon listen interval
786  *  @param  time_unit        The listen interval time unit; options are beacon period or DTIM period.
787  *
788  *  @return WHD_SUCCESS      If the listen interval was successfully set.
789  *          Error code       If the listen interval was not successfully set.
790  */
791 extern uint32_t whd_wifi_set_listen_interval(whd_interface_t ifp, uint8_t listen_interval,
792                                              whd_listen_interval_time_unit_t time_unit);
793 
794 /** Gets the current value of all beacon listen interval variables
795  *
796  *  @param  ifp                     Pointer to handle instance of whd interface
797  *  @param  li                      Powersave listen interval values
798  *                                     - listen_interval_beacon : The current value of the listen interval set as a multiple of the beacon period
799  *                                     - listen_interval_dtim   : The current value of the listen interval set as a multiple of the DTIM period
800  *                                     - listen_interval_assoc  : The current value of the listen interval sent to access points in an association request frame
801  *
802  *  @return WHD_SUCCESS             If all listen interval values are read successfully
803  *          Error code              If at least one of the listen interval values are NOT read successfully
804  */
805 extern uint32_t whd_wifi_get_listen_interval(whd_interface_t ifp, whd_listen_interval_t *li);
806 
807 /** Determines if a particular interface is ready to transceive ethernet packets
808  *
809  *  @param     ifp                    Pointer to handle instance of whd interface
810  *
811  *  @return    WHD_SUCCESS            if the interface is ready to transceive ethernet packets
812  *             WHD_NOTFOUND           no AP with a matching SSID was found
813  *             WHD_NOT_AUTHENTICATED  Matching AP was found but it won't let you authenticate.
814  *                                    This can occur if this device is in the block list on the AP.
815  *             WHD_NOT_KEYED          Device has authenticated and associated but has not completed the key exchange.
816  *                                    This can occur if the passphrase is incorrect.
817  *             Error code             if the interface is not ready to transceive ethernet packets
818  */
819 extern uint32_t whd_wifi_is_ready_to_transceive(whd_interface_t ifp);
820 
821 /* Certification APIs */
822 
823 /** Retrieve the latest STA EDCF AC parameters
824  *
825  *  Retrieve the latest Station (STA) interface EDCF (Enhanced Distributed
826  *  Coordination Function) Access Category parameters
827  *
828  *  @param  ifp            Pointer to handle instance of whd interface
829  *  @param  acp            The location where the array of AC parameters will be stored
830  *
831  *  @return  WHD_SUCCESS   if the AC Parameters were successfully retrieved
832  *           Error code    if the AC Parameters were not retrieved
833  */
834 extern uint32_t whd_wifi_get_acparams(whd_interface_t ifp, whd_edcf_ac_param_t *acp);
835 
836 /* Action Frames */
837 
838 /** Manage the addition and removal of custom IEs
839  *
840  *  @param  ifp            Pointer to handle instance of whd interface
841  *  @param  action         the action to take (add or remove IE)
842  *  @param  oui            the oui of the custom IE
843  *  @param  subtype        the IE sub-type
844  *  @param  data           a pointer to the buffer that hold the custom IE
845  *  @param  length         the length of the buffer pointed to by 'data'
846  *  @param  which_packets  A mask to indicate in which all packets this IE should be included. See whd_ie_packet_flag_t.
847  *
848  *  @return WHD_SUCCESS    if the custom IE action was successful
849  *          Error code     if the custom IE action failed
850  */
851 extern uint32_t whd_wifi_manage_custom_ie(whd_interface_t ifp, whd_custom_ie_action_t action,
852                                           const uint8_t *oui, uint8_t subtype, const void *data,
853                                           uint16_t length, uint16_t which_packets);
854 
855 /** Send a pre-prepared action frame
856  *
857  *  @param  ifp            Pointer to handle instance of whd interface
858  *  @param  af_params      A pointer to a pre-prepared action frame structure
859  *
860  *  @return WHD_SUCCESS or Error code
861  */
862 extern uint32_t whd_wifi_send_action_frame(whd_interface_t ifp, whd_af_params_t *af_params);
863 
864 /** Send a pre-prepared authentication frame
865  *
866  *  @param  ifp            Pointer to handle instance of whd interface
867  *  @param  auth_params    pointer to a pre-prepared authentication frame structure
868  *
869  *  @return WHD_SUCCESS or Error code
870  */
871 extern whd_result_t whd_wifi_send_auth_frame(whd_interface_t ifp, whd_auth_params_t *auth_params);
872 
873 /** Configure HE OM Control
874  *
875  *  @param  ifp            Pointer to handle instance of whd interface
876  *  @param  he_omi_params  pointer to he_omi parameters
877  *
878  *  @return WHD_SUCCESS or Error code
879  */
880 extern uint32_t whd_wifi_he_omi(whd_interface_t ifp, whd_he_omi_params_t *he_omi_params);
881 
882 /** Configure BSS Max Idle Time
883  *
884  *  @param  ifp            Pointer to handle instance of whd interface
885  *  @param  period         The bss max idle period time unit(seconds)
886  *
887  *  @return WHD_SUCCESS or Error code
888  */
889 extern uint32_t whd_wifi_bss_max_idle(whd_interface_t ifp, uint16_t period);
890 
891 /** Trigger individual TWT session(used by STA)
892  *
893  *  @param  ifp            Pointer to handle instance of whd interface
894  *  @param  twt_params     pointer to itwt_setup parameters
895  *
896  *  @return WHD_SUCCESS or Error code
897  */
898 extern uint32_t whd_wifi_itwt_setup(whd_interface_t ifp, whd_itwt_setup_params_t *twt_params);
899 
900 /** Trigger Join broadcast TWT session(used by STA)
901  *
902  *  @param  ifp            Pointer to handle instance of whd interface
903  *  @param  twt_params     pointer to btwt_join parameters
904  *
905  *  @return WHD_SUCCESS or Error code
906  */
907 extern uint32_t whd_wifi_btwt_join(whd_interface_t ifp, whd_btwt_join_params_t *twt_params);
908 
909 /** Trigger teardown all individual or broadcast TWT sessions
910  *
911  *  @param  ifp            Pointer to handle instance of whd interface
912  *  @param  twt_params     pointer to twt_taerdown parameters
913  *
914  *  @return WHD_SUCCESS or Error code
915  */
916 extern uint32_t whd_wifi_twt_teardown(whd_interface_t ifp, whd_twt_teardown_params_t *twt_params);
917 
918 /** Trigger TWT information frame(used by STA)
919  *
920  *  @param  ifp            Pointer to handle instance of whd interface
921  *  @param  twt_params     pointer to twt_information parameters
922  *
923  *
924  *  @return WHD_SUCCESS or Error code
925  */
926 extern uint32_t whd_wifi_twt_information_frame(whd_interface_t ifp, whd_twt_information_params_t *twt_params);
927 
928 /** Configure TWT IE in beacon(used by AP)
929  *
930  *  @param  ifp            Pointer to handle instance of whd interface
931  *  @param  twt_params     pointer to btwt_config parameters
932  *
933  *  @return WHD_SUCCESS or Error code
934  */
935 extern uint32_t whd_wifi_btwt_config(whd_interface_t ifp, whd_btwt_config_params_t *twt_params);
936 
937 /** Set coex configuration
938  *
939  *  @param  ifp                  Pointer to handle instance of whd interface
940  *  @param  coex_config          Pointer to the structure whd_coex_config_t
941  *
942  *  @return WHD_SUCCESS or Error code
943  */
944 extern uint32_t whd_wifi_set_coex_config(whd_interface_t ifp, whd_coex_config_t *coex_config);
945 
946 /** Set auth status used for External AUTH(SAE)
947  *
948  *  @param   ifp                    Pointer to handle instance of whd interface
949  *  @param   whd_auth_req_status    Pointer to Auth_Status structure
950  *
951  *  @return WHD_SUCCESS or Error code
952  */
953 extern whd_result_t whd_wifi_set_auth_status(whd_interface_t ifp, whd_auth_req_status_t *params);
954 
955 /** Get FW(chip) Capability
956  *
957  *  @param  ifp            Pointer to handle instance of whd interface
958  *  @param  value          Enum value of the current FW capability, ex: sae or sae_ext or ...etc,
959  *                         (enum value map to whd_fwcap_id_t)
960  *  @return WHD_SUCCESS or Error code
961  */
962 extern whd_result_t whd_wifi_get_fwcap(whd_interface_t ifp, uint32_t *value);
963 
964 /** Get version of Device (WLAN) Firmware
965  *
966  * @param[in]    ifp            : pointer to handle instance of whd interface
967  * @param[out]   version        : pointer to store version #
968  *
969  * @return whd_result_t
970  */
971 whd_result_t whd_arp_version(whd_interface_t ifp, uint32_t *version);
972 
973 /** Get ARP Offload Peer Age from Device (WLAN)
974  *    Length of time in seconds before aging out an entry in the WLAN processor ARP table.
975  *
976  * @param[in]    ifp            : pointer to handle instance of whd interface
977  * @param[out]   seconds        : pointer to store value
978  *
979  * @return whd_result_t
980  */
981 whd_result_t whd_arp_peerage_get(whd_interface_t ifp, uint32_t *seconds);
982 
983 /** Set ARP Offload Peer Age in Device (WLAN)
984  *    Length of time in seconds before aging out an entry in the WLAN processor ARP table.
985  *
986  * @param[in]    ifp            : pointer to handle instance of whd interface
987  * @param[in]    seconds        : Seconds to age out IP
988  *
989  * @return whd_result_t
990  */
991 whd_result_t whd_arp_peerage_set(whd_interface_t ifp, uint32_t seconds);
992 
993 /** Get ARP Offload Agent Enable from Device (WLAN)
994  *
995  * @param[in]    ifp            : pointer to handle instance of whd interface
996  * @param[out]   agent_enable   : pointer to store value
997  *
998  * @return whd_result_t
999  */
1000 whd_result_t whd_arp_arpoe_get(whd_interface_t ifp, uint32_t *agent_enable);
1001 
1002 /** Set ARP Offload Agent Enable in Device (WLAN)
1003  *    Set Enable/Disable of ARP Offload Agent
1004  *
1005  * @param[in]    ifp            : pointer to handle instance of whd interface
1006  * @param[in]    agent_enable   : Enable=1 / Disable=0
1007  *
1008  * @return whd_result_t
1009  */
1010 whd_result_t whd_arp_arpoe_set(whd_interface_t ifp, uint32_t agent_enable);
1011 
1012 /** Clear ARP Offload cache in Device (WLAN)
1013  *
1014  * @param[in]    ifp            : pointer to handle instance of whd interface
1015  *
1016  * @return whd_result_t
1017  */
1018 whd_result_t whd_arp_cache_clear(whd_interface_t ifp);
1019 
1020 /** Get ARP Offload Feature Flags from Device (WLAN)
1021  *
1022  * @param[in]    ifp        : pointer to handle instance of whd interface
1023  * @param[out]   features   : ptr to store currently set features - bit flags CY_ARP_OL_AGENT_ENABLE, etc.
1024  *                            ARL_OL_AGENT | ARL_OL_SNOOP | ARP_OL_HOST_AUTO_REPLY | ARP_OL_PEER_AUTO_REPLY
1025  *
1026  * @return whd_result_t
1027  */
1028 whd_result_t whd_arp_features_get(whd_interface_t ifp, uint32_t *features);
1029 
1030 /** Set ARP Offload Feature Flags in Device (WLAN)
1031  *
1032  * @param[in]    ifp        : pointer to handle instance of whd interface
1033  * @param[in]    features   : features to set value (you can OR ('|') multiple flags) CY_ARP_OL_AGENT_ENABLE, etc.
1034  *                           ARL_OL_AGENT | ARL_OL_SNOOP | ARP_OL_HOST_AUTO_REPLY | ARP_OL_PEER_AUTO_REPLY
1035  *
1036  * @return whd_result_t
1037  */
1038 whd_result_t whd_arp_features_set(whd_interface_t ifp, uint32_t features);
1039 
1040 /** Print ARP Offload Feature Flags in Human readable form to console
1041  *
1042  * @param[in]    features   : feature flags to set (you can OR '|' multiple flags) CY_ARP_OL_AGENT_ENABLE, etc.
1043  *                            ARL_OL_AGENT | ARL_OL_SNOOP | ARP_OL_HOST_AUTO_REPLY | ARP_OL_PEER_AUTO_REPLY
1044  * @param[in]    title      : Optional: Title for output (NULL == no title)
1045  *
1046  * @return whd_result_t
1047  */
1048 whd_result_t whd_arp_features_print(uint32_t features, const char *title);
1049 
1050 /** Add ARP Offload Host IP Identifier(s) to HostIP List to Device (WLAN)
1051  *
1052  * @param[in]    ifp            : pointer to handle instance of whd interface
1053  * @param[in]    host_ipv4_list : pointer to host_ip data (IPv4, 1 uint32_t per ip addr)
1054  * @param[in]    count          : Number of array elements in host_ip
1055  *
1056  * @return whd_result_t
1057  */
1058 whd_result_t whd_arp_hostip_list_add(whd_interface_t ifp, uint32_t *host_ipv4_list, uint32_t count);
1059 
1060 /** Add One ARP Offload Host IP Identifier to HostIP List (mbed-style IP string) to Device (WLAN)
1061  *
1062  * @param[in]    ifp        : pointer to handle instance of whd interface
1063  * @param[in]    ip_addr    : pointer to ip string (as returned from mbedos calls)
1064  *
1065  * @return whd_result_t
1066  */
1067 whd_result_t whd_arp_hostip_list_add_string(whd_interface_t ifp, const char *ip_addr);
1068 
1069 /** Clear One ARP Offload Host IP Identifier from Host IP List in Device (WLAN)
1070  *
1071  * @param[in]    ifp        : pointer to handle instance of whd interface
1072  * @param[in]    ipv4_addr  : ip addr expressed as a uint32_t
1073  *
1074  * @return whd_result_t
1075  */
1076 whd_result_t whd_arp_hostip_list_clear_id(whd_interface_t ifp, uint32_t ipv4_addr);
1077 
1078 /** Clear One ARP Offload Host IP Identifier from Host IP List (mbed-style IP string) in Device (WLAN)
1079  *
1080  * @param[in]    ifp        : pointer to handle instance of whd interface
1081  * @param[in]    ip_addr    : pointer to ip string (as returned from mbedos calls)
1082  *
1083  * @return whd_result_t
1084  */
1085 whd_result_t whd_arp_hostip_list_clear_id_string(whd_interface_t ifp, const char *ip_addr);
1086 
1087 /** Clear all ARP Offload Host IP Identifier List
1088  *
1089  * @param[in]    ifp        : pointer to handle instance of whd interface
1090  *
1091  * @return whd_result_t
1092  */
1093 whd_result_t whd_arp_hostip_list_clear(whd_interface_t ifp);
1094 
1095 /** Get ARP Offload Host IP Identifiers from Device (WLAN)
1096  *
1097  * @param[in]    ifp        : pointer to handle instance of whd interface
1098  * @param[in]    count          : Number of array elements in host_ip
1099  * @param[out]   host_ipv4_list : Pointer to structure array to store host_ip data
1100  * @param[out]   filled         : Number of array elements filled by this routine
1101  *
1102  * @return whd_result_t
1103  */
1104 whd_result_t whd_arp_hostip_list_get(whd_interface_t ifp, uint32_t count, uint32_t *host_ipv4_list, uint32_t *filled);
1105 
1106 /** Clear ARP Offload statistics in Device (WLAN)
1107  *
1108  * @param[in]    ifp        : pointer to handle instance of whd interface
1109  *
1110  * @return whd_result_t
1111  */
1112 whd_result_t whd_arp_stats_clear(whd_interface_t ifp);
1113 
1114 /** Get ARP Offload statistics from Device (WLAN)
1115  *
1116  * @param[in]    ifp        : pointer to handle instance of whd interface
1117  * @param[out]   stats      : Ptr to store statistics whd_arp_stats_t
1118  *
1119  * @return whd_result_t
1120  */
1121 whd_result_t whd_arp_stats_get(whd_interface_t ifp, whd_arp_stats_t *stats);
1122 
1123 /** Print ARP Offload statistics
1124  *  NOTE: call whd_arp_stats_get(), then print them using this function.
1125  *
1126  * @param[in]    arp_stats  : Ptr to ARP statistics structure
1127  * @param[in]    title      : Optional: Title for output (NULL == no title)
1128  *
1129  * @return whd_result_t
1130  */
1131 whd_result_t whd_arp_stats_print(whd_arp_stats_t *arp_stats, const char *title);
1132 
1133 /** A filter must be added (e.g. created) before it can be enabled.
1134  * @param[in]    ifp        : pointer to handle instance of whd interface
1135  * @param[in]    settings   : Ptr to filter settings @ref whd_packet_filter_t
1136  * @return whd_result_t
1137  */
1138 whd_result_t whd_pf_add_packet_filter(whd_interface_t ifp, const whd_packet_filter_t *settings);
1139 
1140 /** Remove a previously added filter.
1141  * @param[in]    ifp        : pointer to handle instance of whd interface
1142  * @param[in]    filter_id  : filter to remove
1143  * @return whd_result_t
1144  */
1145 whd_result_t whd_pf_remove_packet_filter(whd_interface_t ifp, uint8_t filter_id);
1146 
1147 /** After a filter has been added it can be enabled or disabled as needed.
1148  * @param[in]    ifp        : pointer to handle instance of whd interface
1149  * @param[in]    filter_id  : filter to enable
1150  * @return whd_result_t
1151  */
1152 whd_result_t whd_pf_enable_packet_filter(whd_interface_t ifp, uint8_t filter_id);
1153 
1154 /** After a filter has been added it can be enabled or disabled as needed.
1155  * @param[in]    ifp        : pointer to handle instance of whd interface
1156  * @param[in]    filter_id  : filter to disable
1157  * @return whd_result_t
1158  */
1159 whd_result_t whd_pf_disable_packet_filter(whd_interface_t ifp, uint8_t filter_id);
1160 
1161 /** After a filter has been added it can be enabled or disabled as needed.
1162  * @param[in]    ifp        : pointer to handle instance of whd interface
1163  * @param[in]    filter_id  : filter to disable/enable
1164  * @param[in]    enable     : Enable/Disable Flag
1165  * @return whd_result_t
1166  */
1167 whd_result_t whd_wifi_toggle_packet_filter(whd_interface_t ifp, uint8_t filter_id, whd_bool_t enable);
1168 
1169 /** Filters are implemented in WLAN subsystem as a bit pattern and matching bit mask that
1170  *  are applied to incoming packets.  This API retrieves the pattern and mask.
1171  * @param[in]    ifp        : pointer to handle instance of whd interface
1172  * @param[in]    filter_id  : which filter to retrieve
1173  * @param[in]    max_size   : size of both mask and pattern buffers
1174  * @param[out]   mask       : mask for this filter
1175  * @param[out]   pattern    : pattern for this filter
1176  * @param[out]   size_out   : length of both mask and pattern
1177  * @return whd_result_t
1178  */
1179 whd_result_t whd_pf_get_packet_filter_mask_and_pattern(whd_interface_t ifp, uint8_t filter_id, uint32_t max_size,
1180                                                        uint8_t *mask,
1181                                                        uint8_t *pattern, uint32_t *size_out);
1182 
1183 /** Clear the packet filter stats associated with a filter id
1184  * @param[in]    ifp        : pointer to handle instance of whd interface
1185  * @param[in]    filter_id  : which filter
1186  * @return whd_result_t
1187  */
1188 whd_result_t whd_wifi_clear_packet_filter_stats(whd_interface_t ifp, uint32_t filter_id);
1189 
1190 /** Return the stats associated with a filter
1191  * @param[in]    ifp        : pointer to handle instance of whd interface
1192  * @param[in]    filter_id  : which filter
1193  * @param[out]   stats      : Ptr to store statistics wl_pkt_filter_stats_t
1194  * @return whd_result_t
1195  */
1196 whd_result_t whd_pf_get_packet_filter_stats(whd_interface_t ifp, uint8_t filter_id, whd_pkt_filter_stats_t *stats);
1197 
1198 /** Set/Get TKO retry & interval parameters
1199  * @param[in]    ifp            : Pointer to handle instance of whd interface
1200  * @param[in]    whd_tko_retry  : whd retry & interval parameters structure
1201  * @param[in]    set            : Set(1)/Get(0) Flag
1202  * @return whd_result_t
1203  */
1204 whd_result_t whd_tko_param(whd_interface_t ifp, whd_tko_retry_t *whd_tko_retry, uint8_t set);
1205 
1206 /** Return the tko status for all indexes
1207  * @param[in]    ifp        : Pointer to handle instance of whd interface
1208  * @param[out]   tko_status : Ptr to store tko_status
1209  * @return whd_result_t
1210  */
1211 whd_result_t whd_tko_get_status(whd_interface_t ifp, whd_tko_status_t *tko_status);
1212 
1213 /** Return the stats associated with a filter
1214  * @param[in]    ifp        : Pointer to handle instance of whd interface
1215  * @param[out]   max        : returns Max TCP connections supported by WLAN Firmware
1216  * @return whd_result_t
1217  */
1218 whd_result_t whd_tko_max_assoc(whd_interface_t ifp, uint8_t *max);
1219 
1220 /** Return the stats associated with a filter
1221  * @param[in]    ifp          : Pointer to handle instance of whd interface
1222  * @param[in]    index        : index for TCP offload connection
1223  * @param[out]   whd_connect  : tko_connect structure buffer from Firmware
1224  * @param[in]    buflen       : Buffer given for tko_connect
1225  * @return whd_result_t
1226  */
1227 whd_result_t whd_tko_get_FW_connect(whd_interface_t ifp, uint8_t index, whd_tko_connect_t *whd_connect,
1228                                     uint16_t buflen);
1229 
1230 /** Return the stats associated with a filter
1231  * @param[in]    ifp        : Pointer to handle instance of whd interface
1232  * @param[in]    enable     : Enable/Disable TCP Keepalive offload
1233  * @return whd_result_t
1234  */
1235 whd_result_t whd_tko_toggle(whd_interface_t ifp, whd_bool_t enable);
1236 
1237 
1238 /* @} */
1239 
1240 /** @addtogroup wifiioctl   WHD Wi-Fi IOCTL Set/Get API
1241  *  @ingroup wifi
1242  *  Set and get IOCTL values
1243  *  @{
1244  */
1245 /** Sends an IOCTL command - CDC_SET IOCTL value
1246  *
1247  *  @param  ifp            Pointer to handle instance of whd interface
1248  *  @param  ioctl          CDC_SET - To set the I/O control
1249  *  @param  value          Data value to be sent
1250  *
1251  *  @return WHD_SUCCESS or Error code
1252  */
1253 extern uint32_t whd_wifi_set_ioctl_value(whd_interface_t ifp, uint32_t ioctl, uint32_t value);
1254 
1255 /** Sends an IOCTL command - CDC_GET IOCTL value
1256  *
1257  *  @param  ifp            Pointer to handle instance of whd interface
1258  *  @param  ioctl          CDC_GET - To get the I/O control
1259  *  @param  value          Pointer to receive the data value
1260  *
1261  *  @return WHD_SUCCESS or Error code
1262  */
1263 extern uint32_t whd_wifi_get_ioctl_value(whd_interface_t ifp, uint32_t ioctl, uint32_t *value);
1264 
1265 /** Sends an IOCTL command - CDC_SET IOCTL buffer
1266  *
1267  *  @param  ifp            Pointer to handle instance of whd interface
1268  *  @param  ioctl          CDC_SET - To set the I/O control
1269  *  @param  buffer         Handle for a packet buffer containing the data value to be sent.
1270  *  @param  buffer_length  Length of buffer
1271  *
1272  *  @return WHD_SUCCESS or Error code
1273  */
1274 extern uint32_t whd_wifi_set_ioctl_buffer(whd_interface_t ifp, uint32_t ioctl, void *buffer, uint16_t buffer_length);
1275 
1276 /** Sends an IOCTL command - CDC_GET IOCTL buffer
1277  *
1278  *  @param  ifp           Pointer to handle instance of whd interface
1279  *  @param  ioctl         CDC_GET - To get the I/O control
1280  *  @param  out_buffer    Pointer to receive the handle for the packet buffer containing the response data value received
1281  *  @param  out_length    Length of out_buffer
1282  *
1283  *  @return WHD_SUCCESS or Error code
1284  */
1285 extern uint32_t whd_wifi_get_ioctl_buffer(whd_interface_t ifp, uint32_t ioctl, uint8_t *out_buffer,
1286                                           uint16_t out_length);
1287 
1288 /** Sends an IOVAR command
1289  *
1290  *  @param  ifp           Pointer to handle instance of whd interface
1291  *  @param  iovar_name    SDPCM_GET - To get the I/O Variable
1292  *  @param  param         Paramater to be passed for the IOVAR
1293  *  @param  paramlen      Paramter length
1294  *  @param  out_buffer    Pointer to receive the handle for the packet buffer containing the response data value received
1295  *  @param  out_length    Length of out_buffer
1296  *
1297  *  @return WHD_SUCCESS or Error code
1298  */
1299 extern uint32_t whd_wifi_get_iovar_buffer_with_param(whd_interface_t ifp, const char *iovar_name, void *param,
1300                                                      uint32_t paramlen, uint8_t *out_buffer, uint32_t out_length);
1301 
1302 /* @} */
1303 
1304 /** @addtogroup dbg  WHD Wi-Fi Debug API
1305  *  @ingroup wifi
1306  *  WHD APIs which allows debugging like, printing whd log information, getting whd stats, etc.
1307  *  @{
1308  */
1309 /** Retrieves the WLAN firmware version
1310  *
1311  *  @param  ifp            Pointer to handle instance of whd interface
1312  *  @param  version        Pointer to a buffer that version information will be written to
1313  *  @param  length         Length of the buffer
1314  *
1315  *  @return WHD_SUCCESS or Error code
1316  */
1317 extern uint32_t whd_wifi_get_wifi_version(whd_interface_t ifp, char *version, uint8_t length);
1318 
1319 /** Retrieves the WLAN CLM version
1320  *
1321  *  @param  ifp            Pointer to handle instance of whd interface
1322  *  @param  version        Pointer to a buffer that version information will be written to
1323  *  @param  length         Length of the buffer
1324  *
1325  *  @return WHD_SUCCESS or Error code
1326  */
1327 extern uint32_t whd_wifi_get_clm_version(whd_interface_t ifp, char *version, uint8_t length);
1328 
1329 /** To print whd log information
1330  *
1331  *  @param  whd_drv        Pointer to handle instance of the driver
1332  *  @param  buffer         Buffer to store read log results
1333  *  @param  buffer_size    Variable to store size of the buffer
1334  *
1335  *  @return WHD_SUCCESS or Error code
1336  */
1337 extern uint32_t whd_wifi_read_wlan_log(whd_driver_t whd_drv, char *buffer, uint32_t buffer_size);
1338 
1339 /** To print whd log information
1340  *
1341  *  @param  whd_drv        Pointer to handle instance of the driver
1342  *
1343  *  @return WHD_SUCCESS or Error code
1344  */
1345 extern uint32_t whd_wifi_print_whd_log(whd_driver_t whd_drv);
1346 
1347 /** Retrieves the ifidx from interface pointer.
1348  *  ifidx is a unique value and be used to identify a instance of tcp/ip stack
1349  *
1350  *  @param  ifp           Pointer to the whd_interface_t
1351  *  @param  ifidx         Pointer to ifidx
1352  *
1353  *  @return WHD_SUCCESS or Error code
1354  */
1355 extern uint32_t whd_network_get_ifidx_from_ifp(whd_interface_t ifp, uint8_t *ifidx);
1356 
1357 /** Retrieves the bsscfgidx from interface pointer.
1358  *
1359  *  Can be used to send IOCTL with requires bsscfgidx
1360  *
1361  *  @param  ifp           Pointer to handle instance of whd interface
1362  *  @param  bsscfgidx     Pointer to bsscfgidx
1363  *
1364  *  @return WHD_SUCCESS or Error code
1365  */
1366 extern uint32_t whd_network_get_bsscfgidx_from_ifp(whd_interface_t ifp, uint8_t *bsscfgidx);
1367 
1368 
1369 /** Retrives the bss info
1370  *
1371  *  @param  ifp                  Pointer to handle instance of whd interface
1372  *  @param  bi                   A pointer to the structure wl_bss_info_t
1373  *
1374  *  @return WHD_SUCCESS or Error code
1375  */
1376 extern uint32_t whd_wifi_get_bss_info(whd_interface_t ifp, wl_bss_info_t *bi);
1377 
1378 /** Prints WHD stats
1379  *
1380  *  @param  whd_drv              Pointer to handle instance of the driver
1381  *  @param  reset_after_print    Bool variable to decide if whd_stats to be reset
1382  *
1383  *  @return WHD_SUCCESS or Error code
1384  */
1385 extern uint32_t whd_print_stats(whd_driver_t whd_drv, whd_bool_t reset_after_print);
1386 
1387 /* @} */
1388 /* @} */
1389 
1390 #ifdef __cplusplus
1391 } /* extern "C" */
1392 #endif
1393 #endif /* ifndef INCLUDED_WHD_WIFI_H */
1394 
1395