1 /*
2  * Copyright 2022, 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, cyhal_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, cyhal_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, cyhal_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 /** Retrieve the latest RSSI value
491  *
492  *  @param   ifp           Pointer to handle instance of whd interface
493  *  @param   rssi          The location where the RSSI value will be stored
494  *
495  *  @return  WHD_SUCCESS   if the RSSI was successfully retrieved
496  *           Error code    if the RSSI was not retrieved
497  */
498 extern uint32_t whd_wifi_get_rssi(whd_interface_t ifp, int32_t *rssi);
499 
500 /** Retrieve the latest Roam time threshold value
501  *
502  *  @param   ifp                  Pointer to handle instance of whd interface
503  *  @param   roam_time_threshold  The location where the roam time threshold value will be stored
504  *
505  *  @return  WHD_SUCCESS   if the roam time threshold was successfully retrieved
506  *    	     Error code    if the roam time threshold was not retrieved
507  */
508 extern uint32_t whd_wifi_get_roam_time_threshold(whd_interface_t ifp, uint32_t *roam_time_threshold);
509 
510 /** Retrieve the associated STA's RSSI value
511  *
512  *  @param   ifp          : Pointer to handle instance of whd interface
513  *  @param   rssi         : The location where the RSSI value will be stored
514  *  @param   client_mac   : Pointer to associated client's MAC address
515  *
516  *  @return  WHD_SUCCESS  : if the RSSI was successfully retrieved
517  *           Error code   : if the RSSI was not retrieved
518  */
519 extern uint32_t whd_wifi_get_ap_client_rssi(whd_interface_t ifp, int32_t *rssi, const whd_mac_t *client_mac);
520 
521 
522 /* @} */
523 
524 /** @addtogroup wifijoin   WHD Wi-Fi Join, Scan and Halt API
525  *  @ingroup wifi
526  *  Wi-Fi APIs for join, scan & leave
527  *  @{
528  */
529 /** Disassociates from a Wi-Fi network.
530  *  Applicable only for STA role
531  *
532  *  @param   ifp           Pointer to handle instance of whd interface.
533  *
534  *  @return  WHD_SUCCESS   On successful disassociation from the AP
535  *           Error code    If an error occurred
536  */
537 extern uint32_t whd_wifi_leave(whd_interface_t ifp);
538 /* @} */
539 
540 /** @addtogroup wifiutilities   WHD Wi-Fi Utility API
541  *  @ingroup wifi
542  *  Allows WHD to perform utility operations
543  *  @{
544  */
545 
546 /** Retrieves the current Media Access Control (MAC) address
547  *  (or Ethernet hardware address) of the 802.11 device
548  *
549  *  @param   ifp           Pointer to handle instance of whd interface
550  *  @param   mac           Pointer to a variable that the current MAC address will be written to
551  *
552  *  @return  WHD_SUCCESS or Error code
553  */
554 extern uint32_t whd_wifi_get_mac_address(whd_interface_t ifp, whd_mac_t *mac);
555 
556 /** Get the BSSID of the interface
557  *
558  *  @param  ifp           Pointer to the whd_interface_t
559  *  @param  bssid         Returns the BSSID address (mac address) if associated
560  *
561  *  @return WHD_SUCCESS or Error code
562  */
563 extern uint32_t whd_wifi_get_bssid(whd_interface_t ifp, whd_mac_t *bssid);
564 /* @} */
565 
566 /** @addtogroup wifisoftap     WHD Wi-Fi SoftAP API
567  *  @ingroup wifi
568  *  Wi-Fi APIs to perform SoftAP related functionalities
569  *  @{
570  */
571 
572 /** Initialises an infrastructure WiFi network (SoftAP)
573  *
574  *  @param   ifp           Pointer to handle instance of whd interface
575  *  @param   ssid          A null terminated string containing the SSID name of the network to join
576  *  @param   auth_type     Authentication type
577  *  @param   security_key  A byte array containing the cleartext security key for the network
578  *  @param   key_length    The length of the security_key in bytes.
579  *  @param   channel       802.11 channel number
580  *
581  *  @return  WHD_SUCCESS   if successfully initialises an AP
582  *           Error code    if an error occurred
583  */
584 extern uint32_t whd_wifi_init_ap(whd_interface_t ifp, whd_ssid_t *ssid, whd_security_t auth_type,
585                                  const uint8_t *security_key, uint8_t key_length, uint8_t channel);
586 
587 /** Start the infrastructure WiFi network (SoftAP)
588  *  using the parameter set by whd_wifi_init_ap() and optionaly by whd_wifi_manage_custom_ie()
589  *
590  *  @return  WHD_SUCCESS   if successfully creates an AP
591  *           Error code    if an error occurred
592  */
593 extern uint32_t whd_wifi_start_ap(whd_interface_t ifp);
594 
595 /** Stops an existing infrastructure WiFi network
596  *
597  *  @param   ifp           Pointer to handle instance of whd interface
598  *
599  *  @return  WHD_SUCCESS   if the AP is successfully stopped or if the AP has not yet been brought up
600  *           Error code    if an error occurred
601  */
602 extern uint32_t whd_wifi_stop_ap(whd_interface_t ifp);
603 
604 
605 /** Get the maximum number of associations supported by AP interfaces
606  *
607  *  @param   ifp           Pointer to handle instance of whd interface
608  *  @param   max_assoc     The maximum number of associations supported by Soft AP interfaces.
609  *
610  *  @return  WHD_SUCCESS   if the maximum number of associated clients was successfully read
611  *           WHD_ERROR     if the maximum number of associated clients was not successfully read
612  */
613 extern uint32_t whd_wifi_ap_get_max_assoc(whd_interface_t ifp, uint32_t *max_assoc);
614 
615 /** Gets the current number of active connections
616  *
617  *  @param   ifp                 Pointer to handle instance of whd interface
618  *  @param   client_list_buffer  Buffer to store list of associated clients
619  *  @param   buffer_length       Length of client list buffer
620  *
621  *  @return  WHD_SUCCESS         if the active connections was successfully read
622  *           WHD_ERROR           if the active connections was not successfully read
623  */
624 extern uint32_t whd_wifi_get_associated_client_list(whd_interface_t ifp, void *client_list_buffer,
625                                                     uint16_t buffer_length);
626 
627 /** Deauthenticates a STA which may or may not be associated to SoftAP
628  *
629  * @param   ifp             Pointer to handle instance of whd interface
630  * @param   mac             Pointer to a variable containing the MAC address to which the deauthentication will be sent
631  *                          NULL mac address will deauthenticate all the associated STAs
632  *
633  * @param   reason          Deauthentication reason code
634  *
635  * @return  WHD_SUCCESS     On successful deauthentication of the other STA
636  *          WHD_ERROR       If an error occurred
637  */
638 extern uint32_t whd_wifi_deauth_sta(whd_interface_t ifp, whd_mac_t *mac, whd_dot11_reason_code_t reason);
639 
640 /** Retrieves AP information
641  *
642  *  @param  ifp            Pointer to handle instance of whd interface
643  *  @param  ap_info        Returns a whd_bss_info_t structure containing AP details
644  *  @param  security       Authentication type
645  *
646  *  @return WHD_SUCCESS    if the AP info was successfully retrieved
647  *          Error code     if the AP info was not successfully retrieved
648  */
649 extern uint32_t whd_wifi_get_ap_info(whd_interface_t ifp, whd_bss_info_t *ap_info, whd_security_t *security);
650 
651 /** Set the beacon interval.
652  *
653  *  Note that the value needs to be set before ap_start in order to beacon interval to take effect.
654  *
655  *  @param  ifp            Pointer to handle instance of whd interface
656  *  @param  interval       Beacon interval in time units (Default: 100 time units = 102.4 ms)
657  *
658  *  @return WHD_SUCCESS or Error code
659  */
660 extern uint32_t whd_wifi_ap_set_beacon_interval(whd_interface_t ifp, uint16_t interval);
661 
662 /** Set the DTIM interval.
663  *
664  *  Note that the value needs to be set before ap_start in order to DTIM interval to take effect.
665  *
666  *  @param  ifp            Pointer to handle instance of whd interface
667  *  @param  interval       DTIM interval, in unit of beacon interval
668  *
669  *  @return WHD_SUCCESS or Error code
670  */
671 extern uint32_t whd_wifi_ap_set_dtim_interval(whd_interface_t ifp, uint16_t interval);
672 /*  @} */
673 
674 
675 /** @addtogroup wifipowersave   WHD Wi-Fi Power Save API
676  *  @ingroup wifi
677  *  Wi-Fi functions for WLAN low power modes
678  *  @{
679  */
680 
681 /** Enables powersave mode on specified interface without regard for throughput reduction
682  *
683  *  This function enables (legacy) 802.11 PS-Poll mode and should be used
684  *  to achieve the lowest power consumption possible when the Wi-Fi device
685  *  is primarily passively listening to the network
686  *
687  *  @param  ifp            Pointer to handle instance of whd interface
688  *
689  *  @return WHD_SUCCESS or Error code
690  */
691 extern uint32_t whd_wifi_enable_powersave(whd_interface_t ifp);
692 
693 /** Enables powersave mode on specified interface while attempting to maximise throughput
694  *
695  *
696  *  Network traffic is typically bursty. Reception of a packet often means that another
697  *  packet will be received shortly afterwards (and vice versa for transmit).
698  *
699  *  In high throughput powersave mode, rather then entering powersave mode immediately
700  *  after receiving or sending a packet, the WLAN chip waits for a timeout period before
701  *  returning to sleep.
702  *
703  *  @param   ifp                    Pointer to handle instance of whd interface
704  *  @param   return_to_sleep_delay  The variable to set return to sleep delay.
705  *                                 return to sleep delay must be set to a multiple of 10 and not equal to zero.
706  *
707  *  @return  WHD_SUCCESS            if power save mode was successfully enabled
708  *           Error code             if power save mode was not successfully enabled
709  *
710  */
711 extern uint32_t whd_wifi_enable_powersave_with_throughput(whd_interface_t ifp, uint16_t return_to_sleep_delay);
712 
713 /** Get powersave mode on specified interface
714  *
715  *  @param  ifp            Pointer to handle instance of whd interface
716  *  @param  value          Value of the current powersave state
717  *                          PM1_POWERSAVE_MODE, PM2_POWERSAVE_MODE, NO_POWERSAVE_MODE
718  *
719  *  @return WHD_SUCCESS or Error code
720  */
721 extern uint32_t whd_wifi_get_powersave_mode(whd_interface_t ifp, uint32_t *value);
722 
723 /** Disables 802.11 power save mode on specified interface
724  *
725  *  @param   ifp               Pointer to handle instance of whd interface
726  *
727  *  @return  WHD_SUCCESS       if power save mode was successfully disabled
728  *           Error code        if power save mode was not successfully disabled
729  *
730  */
731 extern uint32_t whd_wifi_disable_powersave(whd_interface_t ifp);
732 /* @} */
733 
734 /** @addtogroup wifiutilities   WHD Wi-Fi Utility API
735  *  @ingroup wifi
736  *  Allows WHD to perform utility operations
737  *  @{
738  */
739 /** Registers interest in a multicast address
740  *
741  *  Once a multicast address has been registered, all packets detected on the
742  *  medium destined for that address are forwarded to the host.
743  *  Otherwise they are ignored.
744  *
745  *  @param  ifp              Pointer to handle instance of whd interface
746  *  @param  mac              Ethernet MAC address
747  *
748  *  @return WHD_SUCCESS      if the address was registered successfully
749  *          Error code       if the address was not registered
750  */
751 extern uint32_t whd_wifi_register_multicast_address(whd_interface_t ifp, const whd_mac_t *mac);
752 
753 /** Unregisters interest in a multicast address
754  *
755  *  Once a multicast address has been unregistered, all packets detected on the
756  *  medium destined for that address are ignored.
757  *
758  *  @param  ifp              Pointer to handle instance of whd interface
759  *  @param  mac              Ethernet MAC address
760  *
761  *  @return WHD_SUCCESS      if the address was unregistered successfully
762  *          Error code       if the address was not unregistered
763  */
764 extern uint32_t whd_wifi_unregister_multicast_address(whd_interface_t ifp, const whd_mac_t *mac);
765 
766 /** Sets the 802.11 powersave listen interval for a Wi-Fi client, and communicates
767  *  the listen interval to the Access Point. The listen interval will be set to
768  *  (listen_interval x time_unit) seconds.
769  *
770  *  The default value for the listen interval is 0. With the default value of 0 set,
771  *  the Wi-Fi device wakes to listen for AP beacons every DTIM period.
772  *
773  *  If the DTIM listen interval is non-zero, the DTIM listen interval will over ride
774  *  the beacon listen interval value.
775  *
776  *  @param  ifp              Pointer to handle instance of whd interface
777  *  @param  listen_interval  The desired beacon listen interval
778  *  @param  time_unit        The listen interval time unit; options are beacon period or DTIM period.
779  *
780  *  @return WHD_SUCCESS      If the listen interval was successfully set.
781  *          Error code       If the listen interval was not successfully set.
782  */
783 extern uint32_t whd_wifi_set_listen_interval(whd_interface_t ifp, uint8_t listen_interval,
784                                              whd_listen_interval_time_unit_t time_unit);
785 
786 /** Gets the current value of all beacon listen interval variables
787  *
788  *  @param  ifp                     Pointer to handle instance of whd interface
789  *  @param  li                      Powersave listen interval values
790  *                                     - listen_interval_beacon : The current value of the listen interval set as a multiple of the beacon period
791  *                                     - listen_interval_dtim   : The current value of the listen interval set as a multiple of the DTIM period
792  *                                     - listen_interval_assoc  : The current value of the listen interval sent to access points in an association request frame
793  *
794  *  @return WHD_SUCCESS             If all listen interval values are read successfully
795  *          Error code              If at least one of the listen interval values are NOT read successfully
796  */
797 extern uint32_t whd_wifi_get_listen_interval(whd_interface_t ifp, whd_listen_interval_t *li);
798 
799 /** Determines if a particular interface is ready to transceive ethernet packets
800  *
801  *  @param     ifp                    Pointer to handle instance of whd interface
802  *
803  *  @return    WHD_SUCCESS            if the interface is ready to transceive ethernet packets
804  *             WHD_NOTFOUND           no AP with a matching SSID was found
805  *             WHD_NOT_AUTHENTICATED  Matching AP was found but it won't let you authenticate.
806  *                                    This can occur if this device is in the block list on the AP.
807  *             WHD_NOT_KEYED          Device has authenticated and associated but has not completed the key exchange.
808  *                                    This can occur if the passphrase is incorrect.
809  *             Error code             if the interface is not ready to transceive ethernet packets
810  */
811 extern uint32_t whd_wifi_is_ready_to_transceive(whd_interface_t ifp);
812 
813 /* Certification APIs */
814 
815 /** Retrieve the latest STA EDCF AC parameters
816  *
817  *  Retrieve the latest Station (STA) interface EDCF (Enhanced Distributed
818  *  Coordination Function) Access Category parameters
819  *
820  *  @param  ifp            Pointer to handle instance of whd interface
821  *  @param  acp            The location where the array of AC parameters will be stored
822  *
823  *  @return  WHD_SUCCESS   if the AC Parameters were successfully retrieved
824  *           Error code    if the AC Parameters were not retrieved
825  */
826 extern uint32_t whd_wifi_get_acparams(whd_interface_t ifp, whd_edcf_ac_param_t *acp);
827 
828 /* Action Frames */
829 
830 /** Manage the addition and removal of custom IEs
831  *
832  *  @param  ifp            Pointer to handle instance of whd interface
833  *  @param  action         the action to take (add or remove IE)
834  *  @param  oui            the oui of the custom IE
835  *  @param  subtype        the IE sub-type
836  *  @param  data           a pointer to the buffer that hold the custom IE
837  *  @param  length         the length of the buffer pointed to by 'data'
838  *  @param  which_packets  A mask to indicate in which all packets this IE should be included. See whd_ie_packet_flag_t.
839  *
840  *  @return WHD_SUCCESS    if the custom IE action was successful
841  *          Error code     if the custom IE action failed
842  */
843 extern uint32_t whd_wifi_manage_custom_ie(whd_interface_t ifp, whd_custom_ie_action_t action,
844                                           const uint8_t *oui, uint8_t subtype, const void *data,
845                                           uint16_t length, uint16_t which_packets);
846 
847 /** Send a pre-prepared action frame
848  *
849  *  @param  ifp            Pointer to handle instance of whd interface
850  *  @param  af_params      A pointer to a pre-prepared action frame structure
851  *
852  *  @return WHD_SUCCESS or Error code
853  */
854 extern uint32_t whd_wifi_send_action_frame(whd_interface_t ifp, whd_af_params_t *af_params);
855 
856 /** Send a pre-prepared authentication frame
857  *
858  *  @param  ifp            Pointer to handle instance of whd interface
859  *  @param  auth_params    pointer to a pre-prepared authentication frame structure
860  *
861  *  @return WHD_SUCCESS or Error code
862  */
863 extern whd_result_t whd_wifi_send_auth_frame(whd_interface_t ifp, whd_auth_params_t *auth_params);
864 
865 /** Set coex configuration
866  *
867  *  @param  ifp                  Pointer to handle instance of whd interface
868  *  @param  coex_config          Pointer to the structure whd_coex_config_t
869  *
870  *  @return WHD_SUCCESS or Error code
871  */
872 extern uint32_t whd_wifi_set_coex_config(whd_interface_t ifp, whd_coex_config_t *coex_config);
873 
874 /** Set auth status used for External AUTH(SAE)
875  *
876  *  @param   ifp                    Pointer to handle instance of whd interface
877  *  @param   whd_auth_req_status    Pointer to Auth_Status structure
878  *
879  *  @return WHD_SUCCESS or Error code
880  */
881 extern whd_result_t whd_wifi_set_auth_status(whd_interface_t ifp, whd_auth_req_status_t *params);
882 
883 /** Get FW(chip) Capability
884  *
885  *  @param  ifp            Pointer to handle instance of whd interface
886  *  @param  value          Enum value of the current FW capability, ex: sae or sae_ext or ...etc,
887  *                         (enum value map to whd_fwcap_id_t)
888  *  @return WHD_SUCCESS or Error code
889  */
890 extern whd_result_t whd_wifi_get_fwcap(whd_interface_t ifp, uint32_t *value);
891 
892 /** Get version of Device (WLAN) Firmware
893  *
894  * @param[in]    ifp            : pointer to handle instance of whd interface
895  * @param[out]   version        : pointer to store version #
896  *
897  * @return whd_result_t
898  */
899 whd_result_t whd_arp_version(whd_interface_t ifp, uint32_t *version);
900 
901 /** Get ARP Offload Peer Age from Device (WLAN)
902  *    Length of time in seconds before aging out an entry in the WLAN processor ARP table.
903  *
904  * @param[in]    ifp            : pointer to handle instance of whd interface
905  * @param[out]   seconds        : pointer to store value
906  *
907  * @return whd_result_t
908  */
909 whd_result_t whd_arp_peerage_get(whd_interface_t ifp, uint32_t *seconds);
910 
911 /** Set ARP Offload Peer Age in Device (WLAN)
912  *    Length of time in seconds before aging out an entry in the WLAN processor ARP table.
913  *
914  * @param[in]    ifp            : pointer to handle instance of whd interface
915  * @param[in]    seconds        : Seconds to age out IP
916  *
917  * @return whd_result_t
918  */
919 whd_result_t whd_arp_peerage_set(whd_interface_t ifp, uint32_t seconds);
920 
921 /** Get ARP Offload Agent Enable from Device (WLAN)
922  *
923  * @param[in]    ifp            : pointer to handle instance of whd interface
924  * @param[out]   agent_enable   : pointer to store value
925  *
926  * @return whd_result_t
927  */
928 whd_result_t whd_arp_arpoe_get(whd_interface_t ifp, uint32_t *agent_enable);
929 
930 /** Set ARP Offload Agent Enable in Device (WLAN)
931  *    Set Enable/Disable of ARP Offload Agent
932  *
933  * @param[in]    ifp            : pointer to handle instance of whd interface
934  * @param[in]    agent_enable   : Enable=1 / Disable=0
935  *
936  * @return whd_result_t
937  */
938 whd_result_t whd_arp_arpoe_set(whd_interface_t ifp, uint32_t agent_enable);
939 
940 /** Clear ARP Offload cache in Device (WLAN)
941  *
942  * @param[in]    ifp            : pointer to handle instance of whd interface
943  *
944  * @return whd_result_t
945  */
946 whd_result_t whd_arp_cache_clear(whd_interface_t ifp);
947 
948 /** Get ARP Offload Feature Flags from Device (WLAN)
949  *
950  * @param[in]    ifp        : pointer to handle instance of whd interface
951  * @param[out]   features   : ptr to store currently set features - bit flags CY_ARP_OL_AGENT_ENABLE, etc.
952  *                            ARL_OL_AGENT | ARL_OL_SNOOP | ARP_OL_HOST_AUTO_REPLY | ARP_OL_PEER_AUTO_REPLY
953  *
954  * @return whd_result_t
955  */
956 whd_result_t whd_arp_features_get(whd_interface_t ifp, uint32_t *features);
957 
958 /** Set ARP Offload Feature Flags in Device (WLAN)
959  *
960  * @param[in]    ifp        : pointer to handle instance of whd interface
961  * @param[in]    features   : features to set value (you can OR ('|') multiple flags) CY_ARP_OL_AGENT_ENABLE, etc.
962  *                           ARL_OL_AGENT | ARL_OL_SNOOP | ARP_OL_HOST_AUTO_REPLY | ARP_OL_PEER_AUTO_REPLY
963  *
964  * @return whd_result_t
965  */
966 whd_result_t whd_arp_features_set(whd_interface_t ifp, uint32_t features);
967 
968 /** Print ARP Offload Feature Flags in Human readable form to console
969  *
970  * @param[in]    features   : feature flags to set (you can OR '|' multiple flags) CY_ARP_OL_AGENT_ENABLE, etc.
971  *                            ARL_OL_AGENT | ARL_OL_SNOOP | ARP_OL_HOST_AUTO_REPLY | ARP_OL_PEER_AUTO_REPLY
972  * @param[in]    title      : Optional: Title for output (NULL == no title)
973  *
974  * @return whd_result_t
975  */
976 whd_result_t whd_arp_features_print(uint32_t features, const char *title);
977 
978 /** Add ARP Offload Host IP Identifier(s) to HostIP List to Device (WLAN)
979  *
980  * @param[in]    ifp            : pointer to handle instance of whd interface
981  * @param[in]    host_ipv4_list : pointer to host_ip data (IPv4, 1 uint32_t per ip addr)
982  * @param[in]    count          : Number of array elements in host_ip
983  *
984  * @return whd_result_t
985  */
986 whd_result_t whd_arp_hostip_list_add(whd_interface_t ifp, uint32_t *host_ipv4_list, uint32_t count);
987 
988 /** Add One ARP Offload Host IP Identifier to HostIP List (mbed-style IP string) to Device (WLAN)
989  *
990  * @param[in]    ifp        : pointer to handle instance of whd interface
991  * @param[in]    ip_addr    : pointer to ip string (as returned from mbedos calls)
992  *
993  * @return whd_result_t
994  */
995 whd_result_t whd_arp_hostip_list_add_string(whd_interface_t ifp, const char *ip_addr);
996 
997 /** Clear One ARP Offload Host IP Identifier from Host IP List in Device (WLAN)
998  *
999  * @param[in]    ifp        : pointer to handle instance of whd interface
1000  * @param[in]    ipv4_addr  : ip addr expressed as a uint32_t
1001  *
1002  * @return whd_result_t
1003  */
1004 whd_result_t whd_arp_hostip_list_clear_id(whd_interface_t ifp, uint32_t ipv4_addr);
1005 
1006 /** Clear One ARP Offload Host IP Identifier from Host IP List (mbed-style IP string) in Device (WLAN)
1007  *
1008  * @param[in]    ifp        : pointer to handle instance of whd interface
1009  * @param[in]    ip_addr    : pointer to ip string (as returned from mbedos calls)
1010  *
1011  * @return whd_result_t
1012  */
1013 whd_result_t whd_arp_hostip_list_clear_id_string(whd_interface_t ifp, const char *ip_addr);
1014 
1015 /** Clear all ARP Offload Host IP Identifier List
1016  *
1017  * @param[in]    ifp        : pointer to handle instance of whd interface
1018  *
1019  * @return whd_result_t
1020  */
1021 whd_result_t whd_arp_hostip_list_clear(whd_interface_t ifp);
1022 
1023 /** Get ARP Offload Host IP Identifiers from Device (WLAN)
1024  *
1025  * @param[in]    ifp        : pointer to handle instance of whd interface
1026  * @param[in]    count          : Number of array elements in host_ip
1027  * @param[out]   host_ipv4_list : Pointer to structure array to store host_ip data
1028  * @param[out]   filled         : Number of array elements filled by this routine
1029  *
1030  * @return whd_result_t
1031  */
1032 whd_result_t whd_arp_hostip_list_get(whd_interface_t ifp, uint32_t count, uint32_t *host_ipv4_list, uint32_t *filled);
1033 
1034 /** Clear ARP Offload statistics in Device (WLAN)
1035  *
1036  * @param[in]    ifp        : pointer to handle instance of whd interface
1037  *
1038  * @return whd_result_t
1039  */
1040 whd_result_t whd_arp_stats_clear(whd_interface_t ifp);
1041 
1042 /** Get ARP Offload statistics from Device (WLAN)
1043  *
1044  * @param[in]    ifp        : pointer to handle instance of whd interface
1045  * @param[out]   stats      : Ptr to store statistics whd_arp_stats_t
1046  *
1047  * @return whd_result_t
1048  */
1049 whd_result_t whd_arp_stats_get(whd_interface_t ifp, whd_arp_stats_t *stats);
1050 
1051 /** Print ARP Offload statistics
1052  *  NOTE: call whd_arp_stats_get(), then print them using this function.
1053  *
1054  * @param[in]    arp_stats  : Ptr to ARP statistics structure
1055  * @param[in]    title      : Optional: Title for output (NULL == no title)
1056  *
1057  * @return whd_result_t
1058  */
1059 whd_result_t whd_arp_stats_print(whd_arp_stats_t *arp_stats, const char *title);
1060 
1061 /** A filter must be added (e.g. created) before it can be enabled.
1062  * @param[in]    ifp        : pointer to handle instance of whd interface
1063  * @param[in]    settings   : Ptr to filter settings @ref whd_packet_filter_t
1064  * @return whd_result_t
1065  */
1066 whd_result_t whd_pf_add_packet_filter(whd_interface_t ifp, const whd_packet_filter_t *settings);
1067 
1068 /** Remove a previously added filter.
1069  * @param[in]    ifp        : pointer to handle instance of whd interface
1070  * @param[in]    filter_id  : filter to remove
1071  * @return whd_result_t
1072  */
1073 whd_result_t whd_pf_remove_packet_filter(whd_interface_t ifp, uint8_t filter_id);
1074 
1075 /** After a filter has been added it can be enabled or disabled as needed.
1076  * @param[in]    ifp        : pointer to handle instance of whd interface
1077  * @param[in]    filter_id  : filter to enable
1078  * @return whd_result_t
1079  */
1080 whd_result_t whd_pf_enable_packet_filter(whd_interface_t ifp, uint8_t filter_id);
1081 
1082 /** After a filter has been added it can be enabled or disabled as needed.
1083  * @param[in]    ifp        : pointer to handle instance of whd interface
1084  * @param[in]    filter_id  : filter to disable
1085  * @return whd_result_t
1086  */
1087 whd_result_t whd_pf_disable_packet_filter(whd_interface_t ifp, uint8_t filter_id);
1088 
1089 /** After a filter has been added it can be enabled or disabled as needed.
1090  * @param[in]    ifp        : pointer to handle instance of whd interface
1091  * @param[in]    filter_id  : filter to disable/enable
1092  * @param[in]    enable     : Enable/Disable Flag
1093  * @return whd_result_t
1094  */
1095 whd_result_t whd_wifi_toggle_packet_filter(whd_interface_t ifp, uint8_t filter_id, whd_bool_t enable);
1096 
1097 /** Filters are implemented in WLAN subsystem as a bit pattern and matching bit mask that
1098  *  are applied to incoming packets.  This API retrieves the pattern and mask.
1099  * @param[in]    ifp        : pointer to handle instance of whd interface
1100  * @param[in]    filter_id  : which filter to retrieve
1101  * @param[in]    max_size   : size of both mask and pattern buffers
1102  * @param[out]   mask       : mask for this filter
1103  * @param[out]   pattern    : pattern for this filter
1104  * @param[out]   size_out   : length of both mask and pattern
1105  * @return whd_result_t
1106  */
1107 whd_result_t whd_pf_get_packet_filter_mask_and_pattern(whd_interface_t ifp, uint8_t filter_id, uint32_t max_size,
1108                                                        uint8_t *mask,
1109                                                        uint8_t *pattern, uint32_t *size_out);
1110 
1111 /** Clear the packet filter stats associated with a filter id
1112  * @param[in]    ifp        : pointer to handle instance of whd interface
1113  * @param[in]    filter_id  : which filter
1114  * @return whd_result_t
1115  */
1116 whd_result_t whd_wifi_clear_packet_filter_stats(whd_interface_t ifp, uint32_t filter_id);
1117 
1118 /** Return the stats associated with a filter
1119  * @param[in]    ifp        : pointer to handle instance of whd interface
1120  * @param[in]    filter_id  : which filter
1121  * @param[out]   stats      : Ptr to store statistics wl_pkt_filter_stats_t
1122  * @return whd_result_t
1123  */
1124 whd_result_t whd_pf_get_packet_filter_stats(whd_interface_t ifp, uint8_t filter_id, whd_pkt_filter_stats_t *stats);
1125 
1126 /** Set/Get TKO retry & interval parameters
1127  * @param[in]    ifp            : Pointer to handle instance of whd interface
1128  * @param[in]    whd_tko_retry  : whd retry & interval parameters structure
1129  * @param[in]    set            : Set(1)/Get(0) Flag
1130  * @return whd_result_t
1131  */
1132 whd_result_t whd_tko_param(whd_interface_t ifp, whd_tko_retry_t *whd_tko_retry, uint8_t set);
1133 
1134 /** Return the tko status for all indexes
1135  * @param[in]    ifp        : Pointer to handle instance of whd interface
1136  * @param[out]   tko_status : Ptr to store tko_status
1137  * @return whd_result_t
1138  */
1139 whd_result_t whd_tko_get_status(whd_interface_t ifp, whd_tko_status_t *tko_status);
1140 
1141 /** Return the stats associated with a filter
1142  * @param[in]    ifp        : Pointer to handle instance of whd interface
1143  * @param[out]   max        : returns Max TCP connections supported by WLAN Firmware
1144  * @return whd_result_t
1145  */
1146 whd_result_t whd_tko_max_assoc(whd_interface_t ifp, uint8_t *max);
1147 
1148 /** Return the stats associated with a filter
1149  * @param[in]    ifp          : Pointer to handle instance of whd interface
1150  * @param[in]    index        : index for TCP offload connection
1151  * @param[out]   whd_connect  : tko_connect structure buffer from Firmware
1152  * @param[in]    buflen       : Buffer given for tko_connect
1153  * @return whd_result_t
1154  */
1155 whd_result_t whd_tko_get_FW_connect(whd_interface_t ifp, uint8_t index, whd_tko_connect_t *whd_connect,
1156                                     uint16_t buflen);
1157 
1158 /** Return the stats associated with a filter
1159  * @param[in]    ifp        : Pointer to handle instance of whd interface
1160  * @param[in]    enable     : Enable/Disable TCP Keepalive offload
1161  * @return whd_result_t
1162  */
1163 whd_result_t whd_tko_toggle(whd_interface_t ifp, whd_bool_t enable);
1164 
1165 
1166 /* @} */
1167 
1168 /** @addtogroup wifiioctl   WHD Wi-Fi IOCTL Set/Get API
1169  *  @ingroup wifi
1170  *  Set and get IOCTL values
1171  *  @{
1172  */
1173 /** Sends an IOCTL command - CDC_SET IOCTL value
1174  *
1175  *  @param  ifp            Pointer to handle instance of whd interface
1176  *  @param  ioctl          CDC_SET - To set the I/O control
1177  *  @param  value          Data value to be sent
1178  *
1179  *  @return WHD_SUCCESS or Error code
1180  */
1181 extern uint32_t whd_wifi_set_ioctl_value(whd_interface_t ifp, uint32_t ioctl, uint32_t value);
1182 
1183 /** Sends an IOCTL command - CDC_GET IOCTL value
1184  *
1185  *  @param  ifp            Pointer to handle instance of whd interface
1186  *  @param  ioctl          CDC_GET - To get the I/O control
1187  *  @param  value          Pointer to receive the data value
1188  *
1189  *  @return WHD_SUCCESS or Error code
1190  */
1191 extern uint32_t whd_wifi_get_ioctl_value(whd_interface_t ifp, uint32_t ioctl, uint32_t *value);
1192 
1193 /** Sends an IOCTL command - CDC_SET IOCTL buffer
1194  *
1195  *  @param  ifp            Pointer to handle instance of whd interface
1196  *  @param  ioctl          CDC_SET - To set the I/O control
1197  *  @param  buffer         Handle for a packet buffer containing the data value to be sent.
1198  *  @param  buffer_length  Length of buffer
1199  *
1200  *  @return WHD_SUCCESS or Error code
1201  */
1202 extern uint32_t whd_wifi_set_ioctl_buffer(whd_interface_t ifp, uint32_t ioctl, void *buffer, uint16_t buffer_length);
1203 
1204 /** Sends an IOCTL command - CDC_GET IOCTL buffer
1205  *
1206  *  @param  ifp           Pointer to handle instance of whd interface
1207  *  @param  ioctl         CDC_GET - To get the I/O control
1208  *  @param  out_buffer    Pointer to receive the handle for the packet buffer containing the response data value received
1209  *  @param  out_length    Length of out_buffer
1210  *
1211  *  @return WHD_SUCCESS or Error code
1212  */
1213 extern uint32_t whd_wifi_get_ioctl_buffer(whd_interface_t ifp, uint32_t ioctl, uint8_t *out_buffer,
1214                                           uint16_t out_length);
1215 
1216 /** Sends an IOVAR command
1217  *
1218  *  @param  ifp           Pointer to handle instance of whd interface
1219  *  @param  iovar_name    SDPCM_GET - To get the I/O Variable
1220  *  @param  param         Paramater to be passed for the IOVAR
1221  *  @param  paramlen      Paramter length
1222  *  @param  out_buffer    Pointer to receive the handle for the packet buffer containing the response data value received
1223  *  @param  out_length    Length of out_buffer
1224  *
1225  *  @return WHD_SUCCESS or Error code
1226  */
1227 extern uint32_t whd_wifi_get_iovar_buffer_with_param(whd_interface_t ifp, const char *iovar_name, void *param,
1228                                                      uint32_t paramlen, uint8_t *out_buffer, uint32_t out_length);
1229 
1230 /* @} */
1231 
1232 /** @addtogroup dbg  WHD Wi-Fi Debug API
1233  *  @ingroup wifi
1234  *  WHD APIs which allows debugging like, printing whd log information, getting whd stats, etc.
1235  *  @{
1236  */
1237 /** Retrieves the WLAN firmware version
1238  *
1239  *  @param  ifp            Pointer to handle instance of whd interface
1240  *  @param  version        Pointer to a buffer that version information will be written to
1241  *  @param  length         Length of the buffer
1242  *
1243  *  @return WHD_SUCCESS or Error code
1244  */
1245 extern uint32_t whd_wifi_get_wifi_version(whd_interface_t ifp, char *version, uint8_t length);
1246 
1247 /** Retrieves the WLAN CLM version
1248  *
1249  *  @param  ifp            Pointer to handle instance of whd interface
1250  *  @param  version        Pointer to a buffer that version information will be written to
1251  *  @param  length         Length of the buffer
1252  *
1253  *  @return WHD_SUCCESS or Error code
1254  */
1255 extern uint32_t whd_wifi_get_clm_version(whd_interface_t ifp, char *version, uint8_t length);
1256 
1257 /** To print whd log information
1258  *
1259  *  @param  whd_drv        Pointer to handle instance of the driver
1260  *  @param  buffer         Buffer to store read log results
1261  *  @param  buffer_size    Variable to store size of the buffer
1262  *
1263  *  @return WHD_SUCCESS or Error code
1264  */
1265 extern uint32_t whd_wifi_read_wlan_log(whd_driver_t whd_drv, char *buffer, uint32_t buffer_size);
1266 
1267 /** To print whd log information
1268  *
1269  *  @param  whd_drv        Pointer to handle instance of the driver
1270  *
1271  *  @return WHD_SUCCESS or Error code
1272  */
1273 extern uint32_t whd_wifi_print_whd_log(whd_driver_t whd_drv);
1274 
1275 /** Retrieves the ifidx from interface pointer.
1276  *  ifidx is a unique value and be used to identify a instance of tcp/ip stack
1277  *
1278  *  @param  ifp           Pointer to the whd_interface_t
1279  *  @param  ifidx         Pointer to ifidx
1280  *
1281  *  @return WHD_SUCCESS or Error code
1282  */
1283 extern uint32_t whd_network_get_ifidx_from_ifp(whd_interface_t ifp, uint8_t *ifidx);
1284 
1285 /** Retrieves the bsscfgidx from interface pointer.
1286  *
1287  *  Can be used to send IOCTL with requires bsscfgidx
1288  *
1289  *  @param  ifp           Pointer to handle instance of whd interface
1290  *  @param  bsscfgidx     Pointer to bsscfgidx
1291  *
1292  *  @return WHD_SUCCESS or Error code
1293  */
1294 extern uint32_t whd_network_get_bsscfgidx_from_ifp(whd_interface_t ifp, uint8_t *bsscfgidx);
1295 
1296 
1297 /** Retrives the bss info
1298  *
1299  *  @param  ifp                  Pointer to handle instance of whd interface
1300  *  @param  bi                   A pointer to the structure wl_bss_info_t
1301  *
1302  *  @return WHD_SUCCESS or Error code
1303  */
1304 extern uint32_t whd_wifi_get_bss_info(whd_interface_t ifp, wl_bss_info_t *bi);
1305 
1306 /** Prints WHD stats
1307  *
1308  *  @param  whd_drv              Pointer to handle instance of the driver
1309  *  @param  reset_after_print    Bool variable to decide if whd_stats to be reset
1310  *
1311  *  @return WHD_SUCCESS or Error code
1312  */
1313 extern uint32_t whd_print_stats(whd_driver_t whd_drv, whd_bool_t reset_after_print);
1314 
1315 /* @} */
1316 /* @} */
1317 
1318 #ifdef __cplusplus
1319 } /* extern "C" */
1320 #endif
1321 #endif /* ifndef INCLUDED_WHD_WIFI_H */
1322