2 * @file wilc_wfi_cfgopertaions.c
3 * @brief CFG80211 Function Implementation functionality
8 * @sa wilc_wfi_cfgopertaions.h top level OS wrapper file
13 #include "wilc_wfi_cfgoperations.h"
14 #include "wilc_wlan.c"
16 #include "linux_wlan_sdio.h" /* tony : for set_wiphy_dev() */
20 #define IS_MANAGMEMENT 0x100
21 #define IS_MANAGMEMENT_CALLBACK 0x080
22 #define IS_MGMT_STATUS_SUCCES 0x040
23 #define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff)
25 extern int linux_wlan_get_firmware(perInterface_wlan_t *p_nic);
26 extern u16 Set_machw_change_vir_if(bool bValue);
28 extern int mac_open(struct net_device *ndev);
29 extern int mac_close(struct net_device *ndev);
31 tstrNetworkInfo astrLastScannedNtwrksShadow[MAX_NUM_SCANNED_NETWORKS_SHADOW];
32 u32 u32LastScannedNtwrksCountShadow;
33 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
34 struct timer_list hDuringIpTimer;
36 struct timer_list hAgingTimer;
38 extern u8 u8ConnectedSSID[6];
41 u8 g_wilc_initialized = 1;
42 extern linux_wlan_t *g_linux_wlan;
43 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
44 extern bool g_obtainingIP;
47 #define CHAN2G(_channel, _freq, _flags) { \
48 .band = IEEE80211_BAND_2GHZ, \
49 .center_freq = (_freq), \
50 .hw_value = (_channel), \
52 .max_antenna_gain = 0, \
56 /*Frequency range for channels*/
57 static struct ieee80211_channel WILC_WFI_2ghz_channels[] = {
74 #define RATETAB_ENT(_rate, _hw_value, _flags) { \
76 .hw_value = (_hw_value), \
81 /* Table 6 in section 3.2.1.1 */
82 static struct ieee80211_rate WILC_WFI_rates[] = {
83 RATETAB_ENT(10, 0, 0),
84 RATETAB_ENT(20, 1, 0),
85 RATETAB_ENT(55, 2, 0),
86 RATETAB_ENT(110, 3, 0),
87 RATETAB_ENT(60, 9, 0),
88 RATETAB_ENT(90, 6, 0),
89 RATETAB_ENT(120, 7, 0),
90 RATETAB_ENT(180, 8, 0),
91 RATETAB_ENT(240, 9, 0),
92 RATETAB_ENT(360, 10, 0),
93 RATETAB_ENT(480, 11, 0),
94 RATETAB_ENT(540, 12, 0),
98 struct p2p_mgmt_data {
103 /*Global variable used to state the current connected STA channel*/
104 u8 u8WLANChannel = INVALID_CHANNEL;
109 u8 u8P2P_oui[] = {0x50, 0x6f, 0x9A, 0x09};
110 u8 u8P2Plocalrandom = 0x01;
111 u8 u8P2Precvrandom = 0x00;
112 u8 u8P2P_vendorspec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};
116 static struct ieee80211_supported_band WILC_WFI_band_2ghz = {
117 .channels = WILC_WFI_2ghz_channels,
118 .n_channels = ARRAY_SIZE(WILC_WFI_2ghz_channels),
119 .bitrates = WILC_WFI_rates,
120 .n_bitrates = ARRAY_SIZE(WILC_WFI_rates),
125 struct add_key_params {
130 struct add_key_params g_add_gtk_key_params;
131 struct wilc_wfi_key g_key_gtk_params;
132 struct add_key_params g_add_ptk_key_params;
133 struct wilc_wfi_key g_key_ptk_params;
134 struct wilc_wfi_wep_key g_key_wep_params;
135 u8 g_flushing_in_progress;
136 bool g_ptk_keys_saved;
137 bool g_gtk_keys_saved;
138 bool g_wep_keys_saved;
140 #define AGING_TIME (9 * 1000)
141 #define duringIP_TIME 15000
143 void clear_shadow_scan(void *pUserVoid)
148 del_timer_sync(&hAgingTimer);
149 PRINT_INFO(CORECONFIG_DBG, "destroy aging timer\n");
151 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
152 if (astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs != NULL) {
153 kfree(astrLastScannedNtwrksShadow[i].pu8IEs);
154 astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs = NULL;
157 host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
158 astrLastScannedNtwrksShadow[i].pJoinParams = NULL;
160 u32LastScannedNtwrksCountShadow = 0;
165 uint32_t get_rssi_avg(tstrNetworkInfo *pstrNetworkInfo)
169 uint8_t num_rssi = (pstrNetworkInfo->strRssi.u8Full) ? NUM_RSSI : (pstrNetworkInfo->strRssi.u8Index);
171 for (i = 0; i < num_rssi; i++)
172 rssi_v += pstrNetworkInfo->strRssi.as8RSSI[i];
178 void refresh_scan(void *pUserVoid, uint8_t all, bool bDirectScan)
180 struct WILC_WFI_priv *priv;
182 struct cfg80211_bss *bss = NULL;
186 priv = (struct WILC_WFI_priv *)pUserVoid;
187 wiphy = priv->dev->ieee80211_ptr->wiphy;
189 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
190 tstrNetworkInfo *pstrNetworkInfo;
192 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
195 if ((!pstrNetworkInfo->u8Found) || all) {
197 struct ieee80211_channel *channel;
199 if (pstrNetworkInfo != NULL) {
201 s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
202 channel = ieee80211_get_channel(wiphy, s32Freq);
204 rssi = get_rssi_avg(pstrNetworkInfo);
205 if (memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7) || bDirectScan) {
206 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
207 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
208 (size_t)pstrNetworkInfo->u16IEsLen, (((s32)rssi) * 100), GFP_KERNEL);
209 cfg80211_put_bss(wiphy, bss);
218 void reset_shadow_found(void *pUserVoid)
222 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
223 astrLastScannedNtwrksShadow[i].u8Found = 0;
228 void update_scan_time(void *pUserVoid)
232 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
233 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
237 static void remove_network_from_shadow(unsigned long arg)
239 unsigned long now = jiffies;
243 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
244 if (time_after(now, astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan + (unsigned long)(SCAN_RESULT_EXPIRE))) {
245 PRINT_D(CFG80211_DBG, "Network expired in ScanShadow: %s\n", astrLastScannedNtwrksShadow[i].au8ssid);
247 if (astrLastScannedNtwrksShadow[i].pu8IEs != NULL) {
248 kfree(astrLastScannedNtwrksShadow[i].pu8IEs);
249 astrLastScannedNtwrksShadow[i].pu8IEs = NULL;
252 host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
254 for (j = i; (j < u32LastScannedNtwrksCountShadow - 1); j++) {
255 astrLastScannedNtwrksShadow[j] = astrLastScannedNtwrksShadow[j + 1];
257 u32LastScannedNtwrksCountShadow--;
261 PRINT_D(CFG80211_DBG, "Number of cached networks: %d\n", u32LastScannedNtwrksCountShadow);
262 if (u32LastScannedNtwrksCountShadow != 0) {
263 hAgingTimer.data = arg;
264 mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
266 PRINT_D(CFG80211_DBG, "No need to restart Aging timer\n");
270 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
271 static void clear_duringIP(unsigned long arg)
273 PRINT_D(GENERIC_DBG, "GO:IP Obtained , enable scan\n");
274 g_obtainingIP = false;
278 int8_t is_network_in_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid)
283 if (u32LastScannedNtwrksCountShadow == 0) {
284 PRINT_D(CFG80211_DBG, "Starting Aging timer\n");
285 hAgingTimer.data = (unsigned long)pUserVoid;
286 mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
289 /* Linear search for now */
290 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
291 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
292 pstrNetworkInfo->au8bssid, 6) == 0) {
301 void add_network_to_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
303 int8_t ap_found = is_network_in_shadow(pstrNetworkInfo, pUserVoid);
304 uint32_t ap_index = 0;
305 uint8_t rssi_index = 0;
307 if (u32LastScannedNtwrksCountShadow >= MAX_NUM_SCANNED_NETWORKS_SHADOW) {
308 PRINT_D(CFG80211_DBG, "Shadow network reached its maximum limit\n");
311 if (ap_found == -1) {
312 ap_index = u32LastScannedNtwrksCountShadow;
313 u32LastScannedNtwrksCountShadow++;
318 rssi_index = astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index;
319 astrLastScannedNtwrksShadow[ap_index].strRssi.as8RSSI[rssi_index++] = pstrNetworkInfo->s8rssi;
320 if (rssi_index == NUM_RSSI) {
322 astrLastScannedNtwrksShadow[ap_index].strRssi.u8Full = 1;
324 astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index = rssi_index;
326 astrLastScannedNtwrksShadow[ap_index].s8rssi = pstrNetworkInfo->s8rssi;
327 astrLastScannedNtwrksShadow[ap_index].u16CapInfo = pstrNetworkInfo->u16CapInfo;
329 astrLastScannedNtwrksShadow[ap_index].u8SsidLen = pstrNetworkInfo->u8SsidLen;
330 memcpy(astrLastScannedNtwrksShadow[ap_index].au8ssid,
331 pstrNetworkInfo->au8ssid, pstrNetworkInfo->u8SsidLen);
333 memcpy(astrLastScannedNtwrksShadow[ap_index].au8bssid,
334 pstrNetworkInfo->au8bssid, ETH_ALEN);
336 astrLastScannedNtwrksShadow[ap_index].u16BeaconPeriod = pstrNetworkInfo->u16BeaconPeriod;
337 astrLastScannedNtwrksShadow[ap_index].u8DtimPeriod = pstrNetworkInfo->u8DtimPeriod;
338 astrLastScannedNtwrksShadow[ap_index].u8channel = pstrNetworkInfo->u8channel;
340 astrLastScannedNtwrksShadow[ap_index].u16IEsLen = pstrNetworkInfo->u16IEsLen;
341 astrLastScannedNtwrksShadow[ap_index].u64Tsf = pstrNetworkInfo->u64Tsf;
343 kfree(astrLastScannedNtwrksShadow[ap_index].pu8IEs);
344 astrLastScannedNtwrksShadow[ap_index].pu8IEs =
345 kmalloc(pstrNetworkInfo->u16IEsLen, GFP_KERNEL); /* will be deallocated by the WILC_WFI_CfgScan() function */
346 memcpy(astrLastScannedNtwrksShadow[ap_index].pu8IEs,
347 pstrNetworkInfo->pu8IEs, pstrNetworkInfo->u16IEsLen);
349 astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScan = jiffies;
350 astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScanCached = jiffies;
351 astrLastScannedNtwrksShadow[ap_index].u8Found = 1;
353 host_int_freeJoinParams(astrLastScannedNtwrksShadow[ap_index].pJoinParams);
354 astrLastScannedNtwrksShadow[ap_index].pJoinParams = pJoinParams;
360 * @brief CfgScanResult
361 * @details Callback function which returns the scan results found
363 * @param[in] tenuScanEvent enuScanEvent: enum, indicating the scan event triggered, whether that is
364 * SCAN_EVENT_NETWORK_FOUND or SCAN_EVENT_DONE
365 * tstrNetworkInfo* pstrNetworkInfo: structure holding the scan results information
366 * void* pUserVoid: Private structure associated with the wireless interface
372 static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
374 struct WILC_WFI_priv *priv;
377 struct ieee80211_channel *channel;
378 s32 s32Error = WILC_SUCCESS;
379 struct cfg80211_bss *bss = NULL;
381 priv = (struct WILC_WFI_priv *)pUserVoid;
382 if (priv->bCfgScanning == true) {
383 if (enuScanEvent == SCAN_EVENT_NETWORK_FOUND) {
384 wiphy = priv->dev->ieee80211_ptr->wiphy;
385 WILC_NULLCHECK(s32Error, wiphy);
386 if (wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC
388 ((((s32)pstrNetworkInfo->s8rssi) * 100) < 0
390 (((s32)pstrNetworkInfo->s8rssi) * 100) > 100)
392 WILC_ERRORREPORT(s32Error, WILC_FAIL);
395 if (pstrNetworkInfo != NULL) {
396 s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
397 channel = ieee80211_get_channel(wiphy, s32Freq);
399 WILC_NULLCHECK(s32Error, channel);
401 PRINT_INFO(CFG80211_DBG, "Network Info:: CHANNEL Frequency: %d, RSSI: %d, CapabilityInfo: %d,"
402 "BeaconPeriod: %d\n", channel->center_freq, (((s32)pstrNetworkInfo->s8rssi) * 100),
403 pstrNetworkInfo->u16CapInfo, pstrNetworkInfo->u16BeaconPeriod);
405 if (pstrNetworkInfo->bNewNetwork == true) {
406 if (priv->u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
408 PRINT_D(CFG80211_DBG, "Network %s found\n", pstrNetworkInfo->au8ssid);
411 priv->u32RcvdChCount++;
415 if (pJoinParams == NULL) {
416 PRINT_INFO(CORECONFIG_DBG, ">> Something really bad happened\n");
418 add_network_to_shadow(pstrNetworkInfo, priv, pJoinParams);
420 /*P2P peers are sent to WPA supplicant and added to shadow table*/
422 if (!(memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7))) {
423 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
424 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
425 (size_t)pstrNetworkInfo->u16IEsLen, (((s32)pstrNetworkInfo->s8rssi) * 100), GFP_KERNEL);
426 cfg80211_put_bss(wiphy, bss);
431 PRINT_ER("Discovered networks exceeded the max limit\n");
435 /* So this network is discovered before, we'll just update its RSSI */
436 for (i = 0; i < priv->u32RcvdChCount; i++) {
437 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid, pstrNetworkInfo->au8bssid, 6) == 0) {
438 PRINT_D(CFG80211_DBG, "Update RSSI of %s\n", astrLastScannedNtwrksShadow[i].au8ssid);
440 astrLastScannedNtwrksShadow[i].s8rssi = pstrNetworkInfo->s8rssi;
441 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
447 } else if (enuScanEvent == SCAN_EVENT_DONE) {
448 PRINT_D(CFG80211_DBG, "Scan Done[%p]\n", priv->dev);
449 PRINT_D(CFG80211_DBG, "Refreshing Scan ...\n");
450 refresh_scan(priv, 1, false);
452 if (priv->u32RcvdChCount > 0)
453 PRINT_D(CFG80211_DBG, "%d Network(s) found\n", priv->u32RcvdChCount);
455 PRINT_D(CFG80211_DBG, "No networks found\n");
457 down(&(priv->hSemScanReq));
459 if (priv->pstrScanReq != NULL) {
460 cfg80211_scan_done(priv->pstrScanReq, false);
461 priv->u32RcvdChCount = 0;
462 priv->bCfgScanning = false;
463 priv->pstrScanReq = NULL;
465 up(&(priv->hSemScanReq));
468 /*Aborting any scan operation during mac close*/
469 else if (enuScanEvent == SCAN_EVENT_ABORTED) {
470 down(&(priv->hSemScanReq));
472 PRINT_D(CFG80211_DBG, "Scan Aborted\n");
473 if (priv->pstrScanReq != NULL) {
475 update_scan_time(priv);
476 refresh_scan(priv, 1, false);
478 cfg80211_scan_done(priv->pstrScanReq, false);
479 priv->bCfgScanning = false;
480 priv->pstrScanReq = NULL;
482 up(&(priv->hSemScanReq));
494 * @brief WILC_WFI_Set_PMKSA
495 * @details Check if pmksa is cached and set it.
497 * @return int : Return 0 on Success
502 int WILC_WFI_Set_PMKSA(u8 *bssid, struct WILC_WFI_priv *priv)
505 s32 s32Error = WILC_SUCCESS;
508 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
510 if (!memcmp(bssid, priv->pmkid_list.pmkidlist[i].bssid,
512 PRINT_D(CFG80211_DBG, "PMKID successful comparison");
514 /*If bssid is found, set the values*/
515 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
517 if (s32Error != WILC_SUCCESS)
518 PRINT_ER("Error in pmkid\n");
528 int linux_wlan_set_bssid(struct net_device *wilc_netdev, uint8_t *pBSSID);
532 * @brief CfgConnectResult
534 * @param[in] tenuConnDisconnEvent enuConnDisconnEvent: Type of connection response either
535 * connection response or disconnection notification.
536 * tstrConnectInfo* pstrConnectInfo: COnnection information.
537 * u8 u8MacStatus: Mac Status from firmware
538 * tstrDisconnectNotifInfo* pstrDisconnectNotifInfo: Disconnection Notification
539 * void* pUserVoid: Private data associated with wireless interface
547 static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent,
548 tstrConnectInfo *pstrConnectInfo,
550 tstrDisconnectNotifInfo *pstrDisconnectNotifInfo,
553 struct WILC_WFI_priv *priv;
554 struct net_device *dev;
556 tstrWILC_WFIDrv *pstrWFIDrv;
558 u8 NullBssid[ETH_ALEN] = {0};
562 priv = (struct WILC_WFI_priv *)pUserVoid;
565 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
568 if (enuConnDisconnEvent == CONN_DISCONN_EVENT_CONN_RESP) {
570 u16 u16ConnectStatus = WLAN_STATUS_SUCCESS;
572 u16ConnectStatus = pstrConnectInfo->u16ConnectStatus;
574 PRINT_D(CFG80211_DBG, " Connection response received = %d\n", u8MacStatus);
576 if ((u8MacStatus == MAC_DISCONNECTED) &&
577 (pstrConnectInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
578 /* The case here is that our station was waiting for association response frame and has just received it containing status code
579 * = SUCCESSFUL_STATUSCODE, while mac status is MAC_DISCONNECTED (which means something wrong happened) */
580 u16ConnectStatus = WLAN_STATUS_UNSPECIFIED_FAILURE;
581 linux_wlan_set_bssid(priv->dev, NullBssid);
582 memset(u8ConnectedSSID, 0, ETH_ALEN);
585 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
587 if (!pstrWFIDrv->u8P2PConnect)
588 u8WLANChannel = INVALID_CHANNEL;
591 PRINT_ER("Unspecified failure: Connection status %d : MAC status = %d\n", u16ConnectStatus, u8MacStatus);
594 if (u16ConnectStatus == WLAN_STATUS_SUCCESS) {
595 bool bNeedScanRefresh = false;
598 PRINT_INFO(CFG80211_DBG, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo->au8bssid[0],
599 pstrConnectInfo->au8bssid[1], pstrConnectInfo->au8bssid[2], pstrConnectInfo->au8bssid[3], pstrConnectInfo->au8bssid[4], pstrConnectInfo->au8bssid[5]);
600 memcpy(priv->au8AssociatedBss, pstrConnectInfo->au8bssid, ETH_ALEN);
602 /* BugID_4209: if this network has expired in the scan results in the above nl80211 layer, refresh them here by calling
603 * cfg80211_inform_bss() with the last Scan results before calling cfg80211_connect_result() to avoid
604 * Linux kernel warning generated at the nl80211 layer */
606 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
607 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
608 pstrConnectInfo->au8bssid, ETH_ALEN) == 0) {
609 unsigned long now = jiffies;
612 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScanCached + (unsigned long)(nl80211_SCAN_RESULT_EXPIRE - (1 * HZ)))) {
613 bNeedScanRefresh = true;
620 if (bNeedScanRefresh) {
622 /*Also, refrsh DIRECT- results if */
623 refresh_scan(priv, 1, true);
630 PRINT_D(CFG80211_DBG, "Association request info elements length = %zu\n", pstrConnectInfo->ReqIEsLen);
632 PRINT_D(CFG80211_DBG, "Association response info elements length = %d\n", pstrConnectInfo->u16RespIEsLen);
634 cfg80211_connect_result(dev, pstrConnectInfo->au8bssid,
635 pstrConnectInfo->pu8ReqIEs, pstrConnectInfo->ReqIEsLen,
636 pstrConnectInfo->pu8RespIEs, pstrConnectInfo->u16RespIEsLen,
637 u16ConnectStatus, GFP_KERNEL); /* TODO: mostafa: u16ConnectStatus to */
638 /* be replaced by pstrConnectInfo->u16ConnectStatus */
639 } else if (enuConnDisconnEvent == CONN_DISCONN_EVENT_DISCONN_NOTIF) {
640 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
641 g_obtainingIP = false;
643 PRINT_ER("Received MAC_DISCONNECTED from firmware with reason %d on dev [%p]\n",
644 pstrDisconnectNotifInfo->u16reason, priv->dev);
645 u8P2Plocalrandom = 0x01;
646 u8P2Precvrandom = 0x00;
648 memset(priv->au8AssociatedBss, 0, ETH_ALEN);
649 linux_wlan_set_bssid(priv->dev, NullBssid);
650 memset(u8ConnectedSSID, 0, ETH_ALEN);
653 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
655 if (!pstrWFIDrv->u8P2PConnect)
656 u8WLANChannel = INVALID_CHANNEL;
659 /*Incase "P2P CLIENT Connected" send deauthentication reason by 3 to force the WPA_SUPPLICANT to directly change
660 * virtual interface to station*/
661 if ((pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) {
662 pstrDisconnectNotifInfo->u16reason = 3;
665 /*Incase "P2P CLIENT during connection(not connected)" send deauthentication reason by 1 to force the WPA_SUPPLICANT
666 * to scan again and retry the connection*/
667 else if ((!pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) {
668 pstrDisconnectNotifInfo->u16reason = 1;
670 cfg80211_disconnected(dev, pstrDisconnectNotifInfo->u16reason, pstrDisconnectNotifInfo->ie,
671 pstrDisconnectNotifInfo->ie_len, false,
681 * @details Set channel for a given wireless interface. Some devices
682 * may support multi-channel operation (by channel hopping) so cfg80211
683 * doesn't verify much. Note, however, that the passed netdev may be
684 * %NULL as well if the user requested changing the channel for the
685 * device itself, or for a monitor interface.
687 * @return int : Return 0 on Success
692 static int set_channel(struct wiphy *wiphy,
693 struct cfg80211_chan_def *chandef)
697 struct WILC_WFI_priv *priv;
698 s32 s32Error = WILC_SUCCESS;
700 priv = wiphy_priv(wiphy);
702 channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq);
703 PRINT_D(CFG80211_DBG, "Setting channel %d with frequency %d\n", channelnum, chandef->chan->center_freq);
705 u8CurrChannel = channelnum;
706 s32Error = host_int_set_mac_chnl_num(priv->hWILCWFIDrv, channelnum);
708 if (s32Error != WILC_SUCCESS)
709 PRINT_ER("Error in setting channel %d\n", channelnum);
716 * @details Request to do a scan. If returning zero, the scan request is given
717 * the driver, and will be valid until passed to cfg80211_scan_done().
718 * For scan results, call cfg80211_inform_bss(); you can call this outside
719 * the scan/scan_done bracket too.
721 * @return int : Return 0 on Success
728 * kernel version 3.8.8 supported
729 * tony, sswd, WILC-KR, 2013-10-29
731 static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
733 struct WILC_WFI_priv *priv;
735 s32 s32Error = WILC_SUCCESS;
736 u8 au8ScanChanList[MAX_NUM_SCANNED_NETWORKS];
737 tstrHiddenNetwork strHiddenNetwork;
739 priv = wiphy_priv(wiphy);
741 priv->pstrScanReq = request;
743 priv->u32RcvdChCount = 0;
745 host_int_set_wfi_drv_handler(priv->hWILCWFIDrv);
748 reset_shadow_found(priv);
750 priv->bCfgScanning = true;
751 if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
753 for (i = 0; i < request->n_channels; i++) {
754 au8ScanChanList[i] = (u8)ieee80211_frequency_to_channel(request->channels[i]->center_freq);
755 PRINT_INFO(CFG80211_DBG, "ScanChannel List[%d] = %d,", i, au8ScanChanList[i]);
758 PRINT_D(CFG80211_DBG, "Requested num of scan channel %d\n", request->n_channels);
759 PRINT_D(CFG80211_DBG, "Scan Request IE len = %zu\n", request->ie_len);
761 PRINT_D(CFG80211_DBG, "Number of SSIDs %d\n", request->n_ssids);
763 if (request->n_ssids >= 1) {
766 strHiddenNetwork.pstrHiddenNetworkInfo = kmalloc(request->n_ssids * sizeof(tstrHiddenNetwork), GFP_KERNEL);
767 strHiddenNetwork.u8ssidnum = request->n_ssids;
771 for (i = 0; i < request->n_ssids; i++) {
773 if (request->ssids[i].ssid != NULL && request->ssids[i].ssid_len != 0) {
774 strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid = kmalloc(request->ssids[i].ssid_len, GFP_KERNEL);
775 memcpy(strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, request->ssids[i].ssid, request->ssids[i].ssid_len);
776 strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen = request->ssids[i].ssid_len;
778 PRINT_D(CFG80211_DBG, "Received one NULL SSID\n");
779 strHiddenNetwork.u8ssidnum -= 1;
782 PRINT_D(CFG80211_DBG, "Trigger Scan Request\n");
783 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
784 au8ScanChanList, request->n_channels,
785 (const u8 *)request->ie, request->ie_len,
786 CfgScanResult, (void *)priv, &strHiddenNetwork);
788 PRINT_D(CFG80211_DBG, "Trigger Scan Request\n");
789 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
790 au8ScanChanList, request->n_channels,
791 (const u8 *)request->ie, request->ie_len,
792 CfgScanResult, (void *)priv, NULL);
796 PRINT_ER("Requested num of scanned channels is greater than the max, supported"
800 if (s32Error != WILC_SUCCESS) {
802 PRINT_WRN(CFG80211_DBG, "Device is busy: Error(%d)\n", s32Error);
810 * @details Connect to the ESS with the specified parameters. When connected,
811 * call cfg80211_connect_result() with status code %WLAN_STATUS_SUCCESS.
812 * If the connection fails for some reason, call cfg80211_connect_result()
813 * with the status from the AP.
815 * @return int : Return 0 on Success
820 static int connect(struct wiphy *wiphy, struct net_device *dev,
821 struct cfg80211_connect_params *sme)
823 s32 s32Error = WILC_SUCCESS;
825 u8 u8security = NO_ENCRYPT;
826 AUTHTYPE_T tenuAuth_type = ANY;
827 char *pcgroup_encrypt_val = NULL;
828 char *pccipher_group = NULL;
829 char *pcwpa_version = NULL;
831 struct WILC_WFI_priv *priv;
832 tstrWILC_WFIDrv *pstrWFIDrv;
833 tstrNetworkInfo *pstrNetworkInfo = NULL;
837 priv = wiphy_priv(wiphy);
838 pstrWFIDrv = (tstrWILC_WFIDrv *)(priv->hWILCWFIDrv);
840 host_int_set_wfi_drv_handler(priv->hWILCWFIDrv);
842 PRINT_D(CFG80211_DBG, "Connecting to SSID [%s] on netdev [%p] host if [%p]\n", sme->ssid, dev, priv->hWILCWFIDrv);
844 if (!(strncmp(sme->ssid, "DIRECT-", 7))) {
845 PRINT_D(CFG80211_DBG, "Connected to Direct network,OBSS disabled\n");
846 pstrWFIDrv->u8P2PConnect = 1;
848 pstrWFIDrv->u8P2PConnect = 0;
850 PRINT_INFO(CFG80211_DBG, "Required SSID = %s\n , AuthType = %d\n", sme->ssid, sme->auth_type);
852 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
853 if ((sme->ssid_len == astrLastScannedNtwrksShadow[i].u8SsidLen) &&
854 memcmp(astrLastScannedNtwrksShadow[i].au8ssid,
856 sme->ssid_len) == 0) {
857 PRINT_INFO(CFG80211_DBG, "Network with required SSID is found %s\n", sme->ssid);
858 if (sme->bssid == NULL) {
859 /* BSSID is not passed from the user, so decision of matching
860 * is done by SSID only */
861 PRINT_INFO(CFG80211_DBG, "BSSID is not passed from the user\n");
864 /* BSSID is also passed from the user, so decision of matching
865 * should consider also this passed BSSID */
866 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
869 PRINT_INFO(CFG80211_DBG, "BSSID is passed from the user and matched\n");
876 if (i < u32LastScannedNtwrksCountShadow) {
877 PRINT_D(CFG80211_DBG, "Required bss is in scan results\n");
879 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
881 PRINT_INFO(CFG80211_DBG, "network BSSID to be associated: %x%x%x%x%x%x\n",
882 pstrNetworkInfo->au8bssid[0], pstrNetworkInfo->au8bssid[1],
883 pstrNetworkInfo->au8bssid[2], pstrNetworkInfo->au8bssid[3],
884 pstrNetworkInfo->au8bssid[4], pstrNetworkInfo->au8bssid[5]);
887 if (u32LastScannedNtwrksCountShadow == 0)
888 PRINT_D(CFG80211_DBG, "No Scan results yet\n");
890 PRINT_D(CFG80211_DBG, "Required bss not in scan results: Error(%d)\n", s32Error);
895 priv->WILC_WFI_wep_default = 0;
896 memset(priv->WILC_WFI_wep_key, 0, sizeof(priv->WILC_WFI_wep_key));
897 memset(priv->WILC_WFI_wep_key_len, 0, sizeof(priv->WILC_WFI_wep_key_len));
899 PRINT_INFO(CFG80211_DBG, "sme->crypto.wpa_versions=%x\n", sme->crypto.wpa_versions);
900 PRINT_INFO(CFG80211_DBG, "sme->crypto.cipher_group=%x\n", sme->crypto.cipher_group);
902 PRINT_INFO(CFG80211_DBG, "sme->crypto.n_ciphers_pairwise=%d\n", sme->crypto.n_ciphers_pairwise);
905 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++)
906 PRINT_D(CORECONFIG_DBG, "sme->crypto.ciphers_pairwise[%d]=%x\n", i, sme->crypto.ciphers_pairwise[i]);
909 if (sme->crypto.cipher_group != NO_ENCRYPT) {
910 /* To determine the u8security value, first we check the group cipher suite then {in case of WPA or WPA2}
911 * we will add to it the pairwise cipher suite(s) */
912 pcwpa_version = "Default";
913 PRINT_D(CORECONFIG_DBG, ">> sme->crypto.wpa_versions: %x\n", sme->crypto.wpa_versions);
914 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) {
915 u8security = ENCRYPT_ENABLED | WEP;
916 pcgroup_encrypt_val = "WEP40";
917 pccipher_group = "WLAN_CIPHER_SUITE_WEP40";
918 PRINT_INFO(CFG80211_DBG, "WEP Default Key Idx = %d\n", sme->key_idx);
921 for (i = 0; i < sme->key_len; i++)
922 PRINT_D(CORECONFIG_DBG, "WEP Key Value[%d] = %d\n", i, sme->key[i]);
924 priv->WILC_WFI_wep_default = sme->key_idx;
925 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
926 memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
929 g_key_wep_params.key_len = sme->key_len;
930 g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL);
931 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
932 g_key_wep_params.key_idx = sme->key_idx;
933 g_wep_keys_saved = true;
935 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
936 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
937 } else if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104) {
938 u8security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
939 pcgroup_encrypt_val = "WEP104";
940 pccipher_group = "WLAN_CIPHER_SUITE_WEP104";
942 priv->WILC_WFI_wep_default = sme->key_idx;
943 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
944 memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
947 g_key_wep_params.key_len = sme->key_len;
948 g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL);
949 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
950 g_key_wep_params.key_idx = sme->key_idx;
951 g_wep_keys_saved = true;
953 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
954 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
955 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) {
956 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
957 u8security = ENCRYPT_ENABLED | WPA2 | TKIP;
958 pcgroup_encrypt_val = "WPA2_TKIP";
959 pccipher_group = "TKIP";
960 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
961 /* tenuSecurity_t = WPA2_AES; */
962 u8security = ENCRYPT_ENABLED | WPA2 | AES;
963 pcgroup_encrypt_val = "WPA2_AES";
964 pccipher_group = "AES";
966 pcwpa_version = "WPA_VERSION_2";
967 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) {
968 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
969 u8security = ENCRYPT_ENABLED | WPA | TKIP;
970 pcgroup_encrypt_val = "WPA_TKIP";
971 pccipher_group = "TKIP";
972 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
973 /* tenuSecurity_t = WPA_AES; */
974 u8security = ENCRYPT_ENABLED | WPA | AES;
975 pcgroup_encrypt_val = "WPA_AES";
976 pccipher_group = "AES";
979 pcwpa_version = "WPA_VERSION_1";
982 s32Error = -ENOTSUPP;
983 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
990 /* After we set the u8security value from checking the group cipher suite, {in case of WPA or WPA2} we will
991 * add to it the pairwise cipher suite(s) */
992 if ((sme->crypto.wpa_versions & NL80211_WPA_VERSION_1)
993 || (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)) {
994 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) {
995 if (sme->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP) {
996 u8security = u8security | TKIP;
997 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
998 u8security = u8security | AES;
1003 PRINT_D(CFG80211_DBG, "Adding key with cipher group = %x\n", sme->crypto.cipher_group);
1005 PRINT_D(CFG80211_DBG, "Authentication Type = %d\n", sme->auth_type);
1006 switch (sme->auth_type) {
1007 case NL80211_AUTHTYPE_OPEN_SYSTEM:
1008 PRINT_D(CFG80211_DBG, "In OPEN SYSTEM\n");
1009 tenuAuth_type = OPEN_SYSTEM;
1012 case NL80211_AUTHTYPE_SHARED_KEY:
1013 tenuAuth_type = SHARED_KEY;
1014 PRINT_D(CFG80211_DBG, "In SHARED KEY\n");
1018 PRINT_D(CFG80211_DBG, "Automatic Authentation type = %d\n", sme->auth_type);
1022 /* ai: key_mgmt: enterprise case */
1023 if (sme->crypto.n_akm_suites) {
1024 switch (sme->crypto.akm_suites[0]) {
1025 case WLAN_AKM_SUITE_8021X:
1026 tenuAuth_type = IEEE8021;
1035 PRINT_INFO(CFG80211_DBG, "Required Channel = %d\n", pstrNetworkInfo->u8channel);
1037 PRINT_INFO(CFG80211_DBG, "Group encryption value = %s\n Cipher Group = %s\n WPA version = %s\n",
1038 pcgroup_encrypt_val, pccipher_group, pcwpa_version);
1041 u8CurrChannel = pstrNetworkInfo->u8channel;
1043 if (!pstrWFIDrv->u8P2PConnect) {
1044 u8WLANChannel = pstrNetworkInfo->u8channel;
1047 linux_wlan_set_bssid(dev, pstrNetworkInfo->au8bssid);
1049 s32Error = host_int_set_join_req(priv->hWILCWFIDrv, pstrNetworkInfo->au8bssid, sme->ssid,
1050 sme->ssid_len, sme->ie, sme->ie_len,
1051 CfgConnectResult, (void *)priv, u8security,
1052 tenuAuth_type, pstrNetworkInfo->u8channel,
1053 pstrNetworkInfo->pJoinParams);
1054 if (s32Error != WILC_SUCCESS) {
1055 PRINT_ER("host_int_set_join_req(): Error(%d)\n", s32Error);
1068 * @details Disconnect from the BSS/ESS.
1070 * @return int : Return 0 on Success
1075 static int disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code)
1077 s32 s32Error = WILC_SUCCESS;
1078 struct WILC_WFI_priv *priv;
1080 tstrWILC_WFIDrv *pstrWFIDrv;
1082 uint8_t NullBssid[ETH_ALEN] = {0};
1085 priv = wiphy_priv(wiphy);
1088 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
1090 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
1091 if (!pstrWFIDrv->u8P2PConnect)
1092 u8WLANChannel = INVALID_CHANNEL;
1094 linux_wlan_set_bssid(priv->dev, NullBssid);
1096 PRINT_D(CFG80211_DBG, "Disconnecting with reason code(%d)\n", reason_code);
1098 u8P2Plocalrandom = 0x01;
1099 u8P2Precvrandom = 0x00;
1102 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
1105 s32Error = host_int_disconnect(priv->hWILCWFIDrv, reason_code);
1106 if (s32Error != WILC_SUCCESS) {
1107 PRINT_ER("Error in disconnecting: Error(%d)\n", s32Error);
1116 * @details Add a key with the given parameters. @mac_addr will be %NULL
1117 * when adding a group key.
1118 * @param[in] key : key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key, 8-byte Rx Mic Key
1119 * @return int : Return 0 on Success
1124 static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1126 const u8 *mac_addr, struct key_params *params)
1129 s32 s32Error = WILC_SUCCESS, KeyLen = params->key_len;
1131 struct WILC_WFI_priv *priv;
1132 const u8 *pu8RxMic = NULL;
1133 const u8 *pu8TxMic = NULL;
1134 u8 u8mode = NO_ENCRYPT;
1135 #ifdef WILC_AP_EXTERNAL_MLME
1136 u8 u8gmode = NO_ENCRYPT;
1137 u8 u8pmode = NO_ENCRYPT;
1138 AUTHTYPE_T tenuAuth_type = ANY;
1141 priv = wiphy_priv(wiphy);
1143 PRINT_D(CFG80211_DBG, "Adding key with cipher suite = %x\n", params->cipher);
1146 PRINT_D(CFG80211_DBG, "%p %p %d\n", wiphy, netdev, key_index);
1148 PRINT_D(CFG80211_DBG, "key %x %x %x\n", params->key[0],
1153 switch (params->cipher) {
1154 case WLAN_CIPHER_SUITE_WEP40:
1155 case WLAN_CIPHER_SUITE_WEP104:
1156 #ifdef WILC_AP_EXTERNAL_MLME
1157 if (priv->wdev->iftype == NL80211_IFTYPE_AP) {
1159 priv->WILC_WFI_wep_default = key_index;
1160 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
1161 memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
1163 PRINT_D(CFG80211_DBG, "Adding AP WEP Default key Idx = %d\n", key_index);
1164 PRINT_D(CFG80211_DBG, "Adding AP WEP Key len= %d\n", params->key_len);
1166 for (i = 0; i < params->key_len; i++)
1167 PRINT_D(CFG80211_DBG, "WEP AP key val[%d] = %x\n", i, params->key[i]);
1169 tenuAuth_type = OPEN_SYSTEM;
1171 if (params->cipher == WLAN_CIPHER_SUITE_WEP40)
1172 u8mode = ENCRYPT_ENABLED | WEP;
1174 u8mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
1176 host_int_add_wep_key_bss_ap(priv->hWILCWFIDrv, params->key, params->key_len, key_index, u8mode, tenuAuth_type);
1180 if (memcmp(params->key, priv->WILC_WFI_wep_key[key_index], params->key_len)) {
1181 priv->WILC_WFI_wep_default = key_index;
1182 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
1183 memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
1185 PRINT_D(CFG80211_DBG, "Adding WEP Default key Idx = %d\n", key_index);
1186 PRINT_D(CFG80211_DBG, "Adding WEP Key length = %d\n", params->key_len);
1188 for (i = 0; i < params->key_len; i++)
1189 PRINT_INFO(CFG80211_DBG, "WEP key value[%d] = %d\n", i, params->key[i]);
1191 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, params->key, params->key_len, key_index);
1196 case WLAN_CIPHER_SUITE_TKIP:
1197 case WLAN_CIPHER_SUITE_CCMP:
1198 #ifdef WILC_AP_EXTERNAL_MLME
1199 if (priv->wdev->iftype == NL80211_IFTYPE_AP || priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) {
1201 if (priv->wilc_gtk[key_index] == NULL) {
1202 priv->wilc_gtk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL);
1203 priv->wilc_gtk[key_index]->key = NULL;
1204 priv->wilc_gtk[key_index]->seq = NULL;
1207 if (priv->wilc_ptk[key_index] == NULL) {
1208 priv->wilc_ptk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL);
1209 priv->wilc_ptk[key_index]->key = NULL;
1210 priv->wilc_ptk[key_index]->seq = NULL;
1216 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1217 u8gmode = ENCRYPT_ENABLED | WPA | TKIP;
1219 u8gmode = ENCRYPT_ENABLED | WPA2 | AES;
1221 priv->wilc_groupkey = u8gmode;
1223 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1225 pu8TxMic = params->key + 24;
1226 pu8RxMic = params->key + 16;
1227 KeyLen = params->key_len - 16;
1229 /* if there has been previous allocation for the same index through its key, free that memory and allocate again*/
1230 if (priv->wilc_gtk[key_index]->key)
1231 kfree(priv->wilc_gtk[key_index]->key);
1233 priv->wilc_gtk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
1234 memcpy(priv->wilc_gtk[key_index]->key, params->key, params->key_len);
1236 /* if there has been previous allocation for the same index through its seq, free that memory and allocate again*/
1237 if (priv->wilc_gtk[key_index]->seq)
1238 kfree(priv->wilc_gtk[key_index]->seq);
1240 if ((params->seq_len) > 0) {
1241 priv->wilc_gtk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
1242 memcpy(priv->wilc_gtk[key_index]->seq, params->seq, params->seq_len);
1245 priv->wilc_gtk[key_index]->cipher = params->cipher;
1246 priv->wilc_gtk[key_index]->key_len = params->key_len;
1247 priv->wilc_gtk[key_index]->seq_len = params->seq_len;
1250 for (i = 0; i < params->key_len; i++)
1251 PRINT_INFO(CFG80211_DBG, "Adding group key value[%d] = %x\n", i, params->key[i]);
1252 for (i = 0; i < params->seq_len; i++)
1253 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1257 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1258 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, AP_MODE, u8gmode);
1261 PRINT_INFO(CFG80211_DBG, "STA Address: %x%x%x%x%x\n", mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4]);
1263 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1264 u8pmode = ENCRYPT_ENABLED | WPA | TKIP;
1266 u8pmode = priv->wilc_groupkey | AES;
1269 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1271 pu8TxMic = params->key + 24;
1272 pu8RxMic = params->key + 16;
1273 KeyLen = params->key_len - 16;
1276 if (priv->wilc_ptk[key_index]->key)
1277 kfree(priv->wilc_ptk[key_index]->key);
1279 priv->wilc_ptk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
1281 if (priv->wilc_ptk[key_index]->seq)
1282 kfree(priv->wilc_ptk[key_index]->seq);
1284 if ((params->seq_len) > 0)
1285 priv->wilc_ptk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
1288 for (i = 0; i < params->key_len; i++)
1289 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %x\n", i, params->key[i]);
1291 for (i = 0; i < params->seq_len; i++)
1292 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1295 memcpy(priv->wilc_ptk[key_index]->key, params->key, params->key_len);
1297 if ((params->seq_len) > 0)
1298 memcpy(priv->wilc_ptk[key_index]->seq, params->seq, params->seq_len);
1300 priv->wilc_ptk[key_index]->cipher = params->cipher;
1301 priv->wilc_ptk[key_index]->key_len = params->key_len;
1302 priv->wilc_ptk[key_index]->seq_len = params->seq_len;
1304 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1305 pu8RxMic, pu8TxMic, AP_MODE, u8pmode, key_index);
1314 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1315 /* swap the tx mic by rx mic */
1316 pu8RxMic = params->key + 24;
1317 pu8TxMic = params->key + 16;
1318 KeyLen = params->key_len - 16;
1322 /*save keys only on interface 0 (wifi interface)*/
1323 if (!g_gtk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1324 g_add_gtk_key_params.key_idx = key_index;
1325 g_add_gtk_key_params.pairwise = pairwise;
1327 g_add_gtk_key_params.mac_addr = NULL;
1329 g_add_gtk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL);
1330 memcpy(g_add_gtk_key_params.mac_addr, mac_addr, ETH_ALEN);
1332 g_key_gtk_params.key_len = params->key_len;
1333 g_key_gtk_params.seq_len = params->seq_len;
1334 g_key_gtk_params.key = kmalloc(params->key_len, GFP_KERNEL);
1335 memcpy(g_key_gtk_params.key, params->key, params->key_len);
1336 if (params->seq_len > 0) {
1337 g_key_gtk_params.seq = kmalloc(params->seq_len, GFP_KERNEL);
1338 memcpy(g_key_gtk_params.seq, params->seq, params->seq_len);
1340 g_key_gtk_params.cipher = params->cipher;
1342 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_gtk_params.key[0],
1343 g_key_gtk_params.key[1],
1344 g_key_gtk_params.key[2]);
1345 g_gtk_keys_saved = true;
1348 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1349 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, STATION_MODE, u8mode);
1351 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1352 /* swap the tx mic by rx mic */
1353 pu8RxMic = params->key + 24;
1354 pu8TxMic = params->key + 16;
1355 KeyLen = params->key_len - 16;
1359 /*save keys only on interface 0 (wifi interface)*/
1360 if (!g_ptk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1361 g_add_ptk_key_params.key_idx = key_index;
1362 g_add_ptk_key_params.pairwise = pairwise;
1364 g_add_ptk_key_params.mac_addr = NULL;
1366 g_add_ptk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL);
1367 memcpy(g_add_ptk_key_params.mac_addr, mac_addr, ETH_ALEN);
1369 g_key_ptk_params.key_len = params->key_len;
1370 g_key_ptk_params.seq_len = params->seq_len;
1371 g_key_ptk_params.key = kmalloc(params->key_len, GFP_KERNEL);
1372 memcpy(g_key_ptk_params.key, params->key, params->key_len);
1373 if (params->seq_len > 0) {
1374 g_key_ptk_params.seq = kmalloc(params->seq_len, GFP_KERNEL);
1375 memcpy(g_key_ptk_params.seq, params->seq, params->seq_len);
1377 g_key_ptk_params.cipher = params->cipher;
1379 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_ptk_params.key[0],
1380 g_key_ptk_params.key[1],
1381 g_key_ptk_params.key[2]);
1382 g_ptk_keys_saved = true;
1385 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1386 pu8RxMic, pu8TxMic, STATION_MODE, u8mode, key_index);
1387 PRINT_D(CFG80211_DBG, "Adding pairwise key\n");
1389 for (i = 0; i < params->key_len; i++)
1390 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %d\n", i, params->key[i]);
1397 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
1398 s32Error = -ENOTSUPP;
1407 * @details Remove a key given the @mac_addr (%NULL for a group key)
1408 * and @key_index, return -ENOENT if the key doesn't exist.
1410 * @return int : Return 0 on Success
1415 static int del_key(struct wiphy *wiphy, struct net_device *netdev,
1420 struct WILC_WFI_priv *priv;
1421 s32 s32Error = WILC_SUCCESS;
1423 priv = wiphy_priv(wiphy);
1426 /*delete saved keys, if any*/
1427 if (netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1428 g_ptk_keys_saved = false;
1429 g_gtk_keys_saved = false;
1430 g_wep_keys_saved = false;
1432 /*Delete saved WEP keys params, if any*/
1433 if (g_key_wep_params.key != NULL) {
1434 kfree(g_key_wep_params.key);
1435 g_key_wep_params.key = NULL;
1438 /*freeing memory allocated by "wilc_gtk" and "wilc_ptk" in "WILC_WIFI_ADD_KEY"*/
1440 #ifdef WILC_AP_EXTERNAL_MLME
1441 if ((priv->wilc_gtk[key_index]) != NULL) {
1443 if (priv->wilc_gtk[key_index]->key != NULL) {
1445 kfree(priv->wilc_gtk[key_index]->key);
1446 priv->wilc_gtk[key_index]->key = NULL;
1448 if (priv->wilc_gtk[key_index]->seq) {
1450 kfree(priv->wilc_gtk[key_index]->seq);
1451 priv->wilc_gtk[key_index]->seq = NULL;
1454 kfree(priv->wilc_gtk[key_index]);
1455 priv->wilc_gtk[key_index] = NULL;
1459 if ((priv->wilc_ptk[key_index]) != NULL) {
1461 if (priv->wilc_ptk[key_index]->key) {
1463 kfree(priv->wilc_ptk[key_index]->key);
1464 priv->wilc_ptk[key_index]->key = NULL;
1466 if (priv->wilc_ptk[key_index]->seq) {
1468 kfree(priv->wilc_ptk[key_index]->seq);
1469 priv->wilc_ptk[key_index]->seq = NULL;
1471 kfree(priv->wilc_ptk[key_index]);
1472 priv->wilc_ptk[key_index] = NULL;
1476 /*Delete saved PTK and GTK keys params, if any*/
1477 if (g_key_ptk_params.key != NULL) {
1478 kfree(g_key_ptk_params.key);
1479 g_key_ptk_params.key = NULL;
1481 if (g_key_ptk_params.seq != NULL) {
1482 kfree(g_key_ptk_params.seq);
1483 g_key_ptk_params.seq = NULL;
1486 if (g_key_gtk_params.key != NULL) {
1487 kfree(g_key_gtk_params.key);
1488 g_key_gtk_params.key = NULL;
1490 if (g_key_gtk_params.seq != NULL) {
1491 kfree(g_key_gtk_params.seq);
1492 g_key_gtk_params.seq = NULL;
1495 /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/
1496 Set_machw_change_vir_if(false);
1499 if (key_index >= 0 && key_index <= 3) {
1500 memset(priv->WILC_WFI_wep_key[key_index], 0, priv->WILC_WFI_wep_key_len[key_index]);
1501 priv->WILC_WFI_wep_key_len[key_index] = 0;
1503 PRINT_D(CFG80211_DBG, "Removing WEP key with index = %d\n", key_index);
1504 host_int_remove_wep_key(priv->hWILCWFIDrv, key_index);
1506 PRINT_D(CFG80211_DBG, "Removing all installed keys\n");
1507 host_int_remove_key(priv->hWILCWFIDrv, mac_addr);
1515 * @details Get information about the key with the given parameters.
1516 * @mac_addr will be %NULL when requesting information for a group
1517 * key. All pointers given to the @callback function need not be valid
1518 * after it returns. This function should return an error if it is
1519 * not possible to retrieve the key, -ENOENT if it doesn't exist.
1521 * @return int : Return 0 on Success
1526 static int get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1528 const u8 *mac_addr, void *cookie, void (*callback)(void *cookie, struct key_params *))
1531 s32 s32Error = WILC_SUCCESS;
1533 struct WILC_WFI_priv *priv;
1534 struct key_params key_params;
1537 priv = wiphy_priv(wiphy);
1542 PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index);
1544 key_params.key = priv->wilc_gtk[key_index]->key;
1545 key_params.cipher = priv->wilc_gtk[key_index]->cipher;
1546 key_params.key_len = priv->wilc_gtk[key_index]->key_len;
1547 key_params.seq = priv->wilc_gtk[key_index]->seq;
1548 key_params.seq_len = priv->wilc_gtk[key_index]->seq_len;
1550 for (i = 0; i < key_params.key_len; i++)
1551 PRINT_INFO(CFG80211_DBG, "Retrieved key value %x\n", key_params.key[i]);
1554 PRINT_D(CFG80211_DBG, "Getting pairwise key\n");
1556 key_params.key = priv->wilc_ptk[key_index]->key;
1557 key_params.cipher = priv->wilc_ptk[key_index]->cipher;
1558 key_params.key_len = priv->wilc_ptk[key_index]->key_len;
1559 key_params.seq = priv->wilc_ptk[key_index]->seq;
1560 key_params.seq_len = priv->wilc_ptk[key_index]->seq_len;
1563 callback(cookie, &key_params);
1565 return s32Error; /* priv->wilc_gtk->key_len ?0 : -ENOENT; */
1569 * @brief set_default_key
1570 * @details Set the default management frame key on an interface
1572 * @return int : Return 0 on Success.
1577 static int set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1578 bool unicast, bool multicast)
1580 s32 s32Error = WILC_SUCCESS;
1581 struct WILC_WFI_priv *priv;
1584 priv = wiphy_priv(wiphy);
1586 PRINT_D(CFG80211_DBG, "Setting default key with idx = %d\n", key_index);
1588 if (key_index != priv->WILC_WFI_wep_default) {
1590 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, key_index);
1597 * @brief WILC_WFI_dump_survey
1598 * @details Get site survey information
1600 * @return int : Return 0 on Success.
1605 static int WILC_WFI_dump_survey(struct wiphy *wiphy, struct net_device *netdev,
1606 int idx, struct survey_info *info)
1608 s32 s32Error = WILC_SUCCESS;
1613 PRINT_ER("Error Idx value doesn't equal zero: Error(%d)\n", s32Error);
1622 * @brief WILC_WFI_get_station
1623 * @details Get station information for the station identified by @mac
1625 * @return int : Return 0 on Success.
1631 static int WILC_WFI_get_station(struct wiphy *wiphy, struct net_device *dev,
1632 const u8 *mac, struct station_info *sinfo)
1634 s32 s32Error = WILC_SUCCESS;
1635 struct WILC_WFI_priv *priv;
1636 perInterface_wlan_t *nic;
1637 #ifdef WILC_AP_EXTERNAL_MLME
1639 u32 associatedsta = 0;
1640 u32 inactive_time = 0;
1642 priv = wiphy_priv(wiphy);
1643 nic = netdev_priv(dev);
1645 #ifdef WILC_AP_EXTERNAL_MLME
1646 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
1647 PRINT_D(HOSTAPD_DBG, "Getting station parameters\n");
1649 PRINT_INFO(HOSTAPD_DBG, ": %x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4]);
1651 for (i = 0; i < NUM_STA_ASSOCIATED; i++) {
1653 if (!(memcmp(mac, priv->assoc_stainfo.au8Sta_AssociatedBss[i], ETH_ALEN))) {
1660 if (associatedsta == -1) {
1662 PRINT_ER("Station required is not associated : Error(%d)\n", s32Error);
1667 sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME);
1669 host_int_get_inactive_time(priv->hWILCWFIDrv, mac, &(inactive_time));
1670 sinfo->inactive_time = 1000 * inactive_time;
1671 PRINT_D(CFG80211_DBG, "Inactive time %d\n", sinfo->inactive_time);
1676 if (nic->iftype == STATION_MODE) {
1677 tstrStatistics strStatistics;
1679 host_int_get_statistics(priv->hWILCWFIDrv, &strStatistics);
1683 * tx_failed introduced more than
1684 * kernel version 3.0.0
1686 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) |
1687 BIT(NL80211_STA_INFO_RX_PACKETS) |
1688 BIT(NL80211_STA_INFO_TX_PACKETS) |
1689 BIT(NL80211_STA_INFO_TX_FAILED) |
1690 BIT(NL80211_STA_INFO_TX_BITRATE);
1692 sinfo->signal = strStatistics.s8RSSI;
1693 sinfo->rx_packets = strStatistics.u32RxCount;
1694 sinfo->tx_packets = strStatistics.u32TxCount + strStatistics.u32TxFailureCount;
1695 sinfo->tx_failed = strStatistics.u32TxFailureCount;
1696 sinfo->txrate.legacy = strStatistics.u8LinkSpeed * 10;
1698 #ifdef TCP_ENHANCEMENTS
1699 if ((strStatistics.u8LinkSpeed > TCP_ACK_FILTER_LINK_SPEED_THRESH) && (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED))
1700 Enable_TCP_ACK_Filter(true);
1701 else if (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED)
1702 Enable_TCP_ACK_Filter(false);
1705 PRINT_D(CORECONFIG_DBG, "*** stats[%d][%d][%d][%d][%d]\n", sinfo->signal, sinfo->rx_packets, sinfo->tx_packets,
1706 sinfo->tx_failed, sinfo->txrate.legacy);
1713 * @brief WILC_WFI_change_bss
1714 * @details Modify parameters for a given BSS.
1716 * -use_cts_prot: Whether to use CTS protection
1717 * (0 = no, 1 = yes, -1 = do not change)
1718 * -use_short_preamble: Whether the use of short preambles is allowed
1719 * (0 = no, 1 = yes, -1 = do not change)
1720 * -use_short_slot_time: Whether the use of short slot time is allowed
1721 * (0 = no, 1 = yes, -1 = do not change)
1722 * -basic_rates: basic rates in IEEE 802.11 format
1723 * (or NULL for no change)
1724 * -basic_rates_len: number of basic rates
1725 * -ap_isolate: do not forward packets between connected stations
1726 * -ht_opmode: HT Operation mode
1727 * (u16 = opmode, -1 = do not change)
1728 * @return int : Return 0 on Success.
1733 static int WILC_WFI_change_bss(struct wiphy *wiphy, struct net_device *dev,
1734 struct bss_parameters *params)
1736 PRINT_D(CFG80211_DBG, "Changing Bss parametrs\n");
1741 * @brief WILC_WFI_auth
1742 * @details Request to authenticate with the specified peer
1744 * @return int : Return 0 on Success.
1749 static int WILC_WFI_auth(struct wiphy *wiphy, struct net_device *dev,
1750 struct cfg80211_auth_request *req)
1752 PRINT_D(CFG80211_DBG, "In Authentication Function\n");
1757 * @brief WILC_WFI_assoc
1758 * @details Request to (re)associate with the specified peer
1760 * @return int : Return 0 on Success.
1765 static int WILC_WFI_assoc(struct wiphy *wiphy, struct net_device *dev,
1766 struct cfg80211_assoc_request *req)
1768 PRINT_D(CFG80211_DBG, "In Association Function\n");
1773 * @brief WILC_WFI_deauth
1774 * @details Request to deauthenticate from the specified peer
1776 * @return int : Return 0 on Success.
1781 static int WILC_WFI_deauth(struct wiphy *wiphy, struct net_device *dev,
1782 struct cfg80211_deauth_request *req, void *cookie)
1784 PRINT_D(CFG80211_DBG, "In De-authentication Function\n");
1789 * @brief WILC_WFI_disassoc
1790 * @details Request to disassociate from the specified peer
1792 * @return int : Return 0 on Success
1797 static int WILC_WFI_disassoc(struct wiphy *wiphy, struct net_device *dev,
1798 struct cfg80211_disassoc_request *req, void *cookie)
1800 PRINT_D(CFG80211_DBG, "In Disassociation Function\n");
1805 * @brief WILC_WFI_set_wiphy_params
1806 * @details Notify that wiphy parameters have changed;
1807 * @param[in] Changed bitfield (see &enum wiphy_params_flags) describes which values
1809 * @return int : Return 0 on Success
1814 static int WILC_WFI_set_wiphy_params(struct wiphy *wiphy, u32 changed)
1816 s32 s32Error = WILC_SUCCESS;
1817 tstrCfgParamVal pstrCfgParamVal;
1818 struct WILC_WFI_priv *priv;
1820 priv = wiphy_priv(wiphy);
1822 pstrCfgParamVal.u32SetCfgFlag = 0;
1823 PRINT_D(CFG80211_DBG, "Setting Wiphy params\n");
1825 if (changed & WIPHY_PARAM_RETRY_SHORT) {
1826 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_SHORT %d\n",
1827 priv->dev->ieee80211_ptr->wiphy->retry_short);
1828 pstrCfgParamVal.u32SetCfgFlag |= RETRY_SHORT;
1829 pstrCfgParamVal.short_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_short;
1831 if (changed & WIPHY_PARAM_RETRY_LONG) {
1833 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_LONG %d\n", priv->dev->ieee80211_ptr->wiphy->retry_long);
1834 pstrCfgParamVal.u32SetCfgFlag |= RETRY_LONG;
1835 pstrCfgParamVal.long_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_long;
1838 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
1839 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->frag_threshold);
1840 pstrCfgParamVal.u32SetCfgFlag |= FRAG_THRESHOLD;
1841 pstrCfgParamVal.frag_threshold = priv->dev->ieee80211_ptr->wiphy->frag_threshold;
1845 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
1846 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->rts_threshold);
1848 pstrCfgParamVal.u32SetCfgFlag |= RTS_THRESHOLD;
1849 pstrCfgParamVal.rts_threshold = priv->dev->ieee80211_ptr->wiphy->rts_threshold;
1853 PRINT_D(CFG80211_DBG, "Setting CFG params in the host interface\n");
1854 s32Error = hif_set_cfg(priv->hWILCWFIDrv, &pstrCfgParamVal);
1856 PRINT_ER("Error in setting WIPHY PARAMS\n");
1863 * @brief WILC_WFI_set_bitrate_mask
1864 * @details set the bitrate mask configuration
1866 * @return int : Return 0 on Success
1871 static int WILC_WFI_set_bitrate_mask(struct wiphy *wiphy,
1872 struct net_device *dev, const u8 *peer,
1873 const struct cfg80211_bitrate_mask *mask)
1875 s32 s32Error = WILC_SUCCESS;
1877 PRINT_D(CFG80211_DBG, "Setting Bitrate mask function\n");
1883 * @brief WILC_WFI_set_pmksa
1884 * @details Cache a PMKID for a BSSID. This is mostly useful for fullmac
1885 * devices running firmwares capable of generating the (re) association
1886 * RSN IE. It allows for faster roaming between WPA2 BSSIDs.
1888 * @return int : Return 0 on Success
1893 static int WILC_WFI_set_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1894 struct cfg80211_pmksa *pmksa)
1897 s32 s32Error = WILC_SUCCESS;
1900 struct WILC_WFI_priv *priv = wiphy_priv(wiphy);
1902 PRINT_D(CFG80211_DBG, "Setting PMKSA\n");
1905 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
1906 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
1908 /*If bssid already exists and pmkid value needs to reset*/
1910 PRINT_D(CFG80211_DBG, "PMKID already exists\n");
1914 if (i < WILC_MAX_NUM_PMKIDS) {
1915 PRINT_D(CFG80211_DBG, "Setting PMKID in private structure\n");
1916 memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid,
1918 memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid,
1920 if (!(flag == PMKID_FOUND))
1921 priv->pmkid_list.numpmkid++;
1923 PRINT_ER("Invalid PMKID index\n");
1928 PRINT_D(CFG80211_DBG, "Setting pmkid in the host interface\n");
1929 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
1935 * @brief WILC_WFI_del_pmksa
1936 * @details Delete a cached PMKID.
1938 * @return int : Return 0 on Success
1943 static int WILC_WFI_del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1944 struct cfg80211_pmksa *pmksa)
1949 s32 s32Error = WILC_SUCCESS;
1951 struct WILC_WFI_priv *priv = wiphy_priv(wiphy);
1953 PRINT_D(CFG80211_DBG, "Deleting PMKSA keys\n");
1955 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
1956 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
1958 /*If bssid is found, reset the values*/
1959 PRINT_D(CFG80211_DBG, "Reseting PMKID values\n");
1960 memset(&priv->pmkid_list.pmkidlist[i], 0, sizeof(tstrHostIFpmkid));
1966 if (i < priv->pmkid_list.numpmkid && priv->pmkid_list.numpmkid > 0) {
1967 for (; i < (priv->pmkid_list.numpmkid - 1); i++) {
1968 memcpy(priv->pmkid_list.pmkidlist[i].bssid,
1969 priv->pmkid_list.pmkidlist[i + 1].bssid,
1971 memcpy(priv->pmkid_list.pmkidlist[i].pmkid,
1972 priv->pmkid_list.pmkidlist[i].pmkid,
1975 priv->pmkid_list.numpmkid--;
1984 * @brief WILC_WFI_flush_pmksa
1985 * @details Flush all cached PMKIDs.
1987 * @return int : Return 0 on Success
1992 static int WILC_WFI_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev)
1994 struct WILC_WFI_priv *priv = wiphy_priv(wiphy);
1996 PRINT_D(CFG80211_DBG, "Flushing PMKID key values\n");
1998 /*Get cashed Pmkids and set all with zeros*/
1999 memset(&priv->pmkid_list, 0, sizeof(tstrHostIFpmkidAttr));
2007 * @brief WILC_WFI_CfgParseRxAction
2008 * @details Function parses the received frames and modifies the following attributes:
2011 * -Operating Channel
2013 * @param[in] u8* Buffer, u32 length
2020 void WILC_WFI_CfgParseRxAction(u8 *buf, u32 len)
2026 #ifdef USE_SUPPLICANT_GO_INTENT
2029 bool is_wilc_go = true;
2031 u8 op_channel_attr_index = 0;
2032 u8 channel_list_attr_index = 0;
2034 while (index < len) {
2035 if (buf[index] == GO_INTENT_ATTR_ID) {
2036 #ifdef USE_SUPPLICANT_GO_INTENT
2038 /*Case 1: If we are going to be p2p client, no need to modify channels attributes*/
2039 /*In negotiation frames, go intent attr value determines who will be GO*/
2040 intent = GET_GO_INTENT(buf[index + 3]);
2041 tie_breaker = GET_TIE_BREAKER(buf[index + 3]);
2042 if (intent > SUPPLICANT_GO_INTENT
2043 || (intent == SUPPLICANT_GO_INTENT && tie_breaker == 1)) {
2044 PRINT_D(GENERIC_DBG, "WILC will be client (intent %d tie breaker %d)\n", intent, tie_breaker);
2047 PRINT_D(GENERIC_DBG, "WILC will be GO (intent %d tie breaker %d)\n", intent, tie_breaker);
2051 #else /* USE_SUPPLICANT_GO_INTENT */
2052 #ifdef FORCE_P2P_CLIENT
2053 buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1);
2055 buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1);
2057 #endif /* USE_SUPPLICANT_GO_INTENT */
2060 #ifdef USE_SUPPLICANT_GO_INTENT
2061 /*Case 2: If group bssid attribute is present, no need to modify channels attributes*/
2062 /*In invitation req and rsp, group bssid attr presence determines who will be GO*/
2063 if (buf[index] == GROUP_BSSID_ATTR_ID) {
2064 PRINT_D(GENERIC_DBG, "Group BSSID: %2x:%2x:%2x\n", buf[index + 3]
2069 #endif /* USE_SUPPLICANT_GO_INTENT */
2071 if (buf[index] == CHANLIST_ATTR_ID)
2072 channel_list_attr_index = index;
2073 else if (buf[index] == OPERCHAN_ATTR_ID)
2074 op_channel_attr_index = index;
2075 index += buf[index + 1] + 3; /* ID,Length byte */
2078 #ifdef USE_SUPPLICANT_GO_INTENT
2079 if (u8WLANChannel != INVALID_CHANNEL && is_wilc_go)
2081 if (u8WLANChannel != INVALID_CHANNEL)
2084 /*Modify channel list attribute*/
2085 if (channel_list_attr_index) {
2086 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
2087 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
2088 if (buf[i] == 0x51) {
2089 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
2090 buf[j] = u8WLANChannel;
2096 /*Modify operating channel attribute*/
2097 if (op_channel_attr_index) {
2098 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
2099 buf[op_channel_attr_index + 6] = 0x51;
2100 buf[op_channel_attr_index + 7] = u8WLANChannel;
2106 * @brief WILC_WFI_CfgParseTxAction
2107 * @details Function parses the transmitted action frames and modifies the
2108 * GO Intent attribute
2109 * @param[in] u8* Buffer, u32 length, bool bOperChan, u8 iftype
2115 void WILC_WFI_CfgParseTxAction(u8 *buf, u32 len, bool bOperChan, u8 iftype)
2120 u8 op_channel_attr_index = 0;
2121 u8 channel_list_attr_index = 0;
2122 #ifdef USE_SUPPLICANT_GO_INTENT
2123 bool is_wilc_go = false;
2126 /*Case 1: If we are already p2p client, no need to modify channels attributes*/
2127 /*This to handle the case of inviting a p2p peer to join an existing group which we are a member in*/
2128 if (iftype == CLIENT_MODE)
2132 while (index < len) {
2133 #ifdef USE_SUPPLICANT_GO_INTENT
2134 /*Case 2: If group bssid attribute is present, no need to modify channels attributes*/
2135 /*In invitation req and rsp, group bssid attr presence determines who will be GO*/
2136 /*Note: If we are already p2p client, group bssid attr may also be present (handled in Case 1)*/
2137 if (buf[index] == GROUP_BSSID_ATTR_ID) {
2138 PRINT_D(GENERIC_DBG, "Group BSSID: %2x:%2x:%2x\n", buf[index + 3]
2144 #else /* USE_SUPPLICANT_GO_INTENT */
2145 if (buf[index] == GO_INTENT_ATTR_ID) {
2146 #ifdef FORCE_P2P_CLIENT
2147 buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1);
2149 buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1);
2156 if (buf[index] == CHANLIST_ATTR_ID)
2157 channel_list_attr_index = index;
2158 else if (buf[index] == OPERCHAN_ATTR_ID)
2159 op_channel_attr_index = index;
2160 index += buf[index + 1] + 3; /* ID,Length byte */
2163 #ifdef USE_SUPPLICANT_GO_INTENT
2164 /*No need to check bOperChan since only transmitted invitation frames are parsed*/
2165 if (u8WLANChannel != INVALID_CHANNEL && is_wilc_go)
2167 if (u8WLANChannel != INVALID_CHANNEL && bOperChan)
2170 /*Modify channel list attribute*/
2171 if (channel_list_attr_index) {
2172 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
2173 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
2174 if (buf[i] == 0x51) {
2175 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
2176 buf[j] = u8WLANChannel;
2182 /*Modify operating channel attribute*/
2183 if (op_channel_attr_index) {
2184 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
2185 buf[op_channel_attr_index + 6] = 0x51;
2186 buf[op_channel_attr_index + 7] = u8WLANChannel;
2191 /* @brief WILC_WFI_p2p_rx
2196 * @author Mai Daftedar
2201 void WILC_WFI_p2p_rx (struct net_device *dev, uint8_t *buff, uint32_t size)
2204 struct WILC_WFI_priv *priv;
2205 u32 header, pkt_offset;
2206 tstrWILC_WFIDrv *pstrWFIDrv;
2210 priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
2211 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2213 /* Get WILC header */
2214 memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
2216 /* The packet offset field conain info about what type of managment frame */
2217 /* we are dealing with and ack status */
2218 pkt_offset = GET_PKT_OFFSET(header);
2220 if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
2221 if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP) {
2222 PRINT_D(GENERIC_DBG, "Probe response ACK\n");
2223 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
2226 if (pkt_offset & IS_MGMT_STATUS_SUCCES) {
2227 PRINT_D(GENERIC_DBG, "Success Ack - Action frame category: %x Action Subtype: %d Dialog T: %x OR %x\n", buff[ACTION_CAT_ID], buff[ACTION_SUBTYPE_ID],
2228 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
2229 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
2231 PRINT_D(GENERIC_DBG, "Fail Ack - Action frame category: %x Action Subtype: %d Dialog T: %x OR %x\n", buff[ACTION_CAT_ID], buff[ACTION_SUBTYPE_ID],
2232 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
2233 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, false, GFP_KERNEL);
2239 PRINT_D(GENERIC_DBG, "Rx Frame Type:%x\n", buff[FRAME_TYPE_ID]);
2242 /*Upper layer is informed that the frame is received on this freq*/
2243 s32Freq = ieee80211_channel_to_frequency(u8CurrChannel, IEEE80211_BAND_2GHZ);
2245 if (ieee80211_is_action(buff[FRAME_TYPE_ID])) {
2246 PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]);
2248 if (priv->bCfgScanning == true && time_after_eq(jiffies, (unsigned long)pstrWFIDrv->u64P2p_MgmtTimeout)) {
2249 PRINT_D(GENERIC_DBG, "Receiving action frames from wrong channels\n");
2252 if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
2254 switch (buff[ACTION_SUBTYPE_ID]) {
2255 case GAS_INTIAL_REQ:
2256 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buff[ACTION_SUBTYPE_ID]);
2259 case GAS_INTIAL_RSP:
2260 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buff[ACTION_SUBTYPE_ID]);
2263 case PUBLIC_ACT_VENDORSPEC:
2264 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2265 * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/
2266 if (!memcmp(u8P2P_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) {
2267 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
2269 for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) {
2270 if (!memcmp(u8P2P_vendorspec, &buff[i], 6)) {
2271 u8P2Precvrandom = buff[i + 6];
2273 PRINT_D(GENERIC_DBG, "WILC Vendor specific IE:%02x\n", u8P2Precvrandom);
2279 if (u8P2Plocalrandom > u8P2Precvrandom) {
2280 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
2281 || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
2282 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) {
2283 if (buff[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buff[i + 2], 4))) {
2284 WILC_WFI_CfgParseRxAction(&buff[i + 6], size - (i + 6));
2290 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2294 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP) && (bWilc_ie)) {
2295 PRINT_D(GENERIC_DBG, "Sending P2P to host without extra elemnt\n");
2296 /* extra attribute for sig_dbm: signal strength in mBm, or 0 if unknown */
2297 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
2303 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff[ACTION_SUBTYPE_ID]);
2309 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
2314 * @brief WILC_WFI_mgmt_tx_complete
2315 * @details Returns result of writing mgmt frame to VMM (Tx buffers are freed here)
2317 * transmitting status
2319 * @author Amr Abdelmoghny
2323 static void WILC_WFI_mgmt_tx_complete(void *priv, int status)
2325 struct p2p_mgmt_data *pv_data = (struct p2p_mgmt_data *)priv;
2328 kfree(pv_data->buff);
2333 * @brief WILC_WFI_RemainOnChannelReady
2334 * @details Callback function, called from handle_remain_on_channel on being ready on channel
2337 * @author Amr abdelmoghny
2342 static void WILC_WFI_RemainOnChannelReady(void *pUserVoid)
2344 struct WILC_WFI_priv *priv;
2346 priv = (struct WILC_WFI_priv *)pUserVoid;
2348 PRINT_D(HOSTINF_DBG, "Remain on channel ready\n");
2350 priv->bInP2PlistenState = true;
2352 cfg80211_ready_on_channel(priv->wdev,
2353 priv->strRemainOnChanParams.u64ListenCookie,
2354 priv->strRemainOnChanParams.pstrListenChan,
2355 priv->strRemainOnChanParams.u32ListenDuration,
2360 * @brief WILC_WFI_RemainOnChannelExpired
2361 * @details Callback function, called on expiration of remain-on-channel duration
2364 * @author Amr abdelmoghny
2369 static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, u32 u32SessionID)
2371 struct WILC_WFI_priv *priv;
2373 priv = (struct WILC_WFI_priv *)pUserVoid;
2376 if (u32SessionID == priv->strRemainOnChanParams.u32ListenSessionID) {
2377 PRINT_D(GENERIC_DBG, "Remain on channel expired\n");
2379 priv->bInP2PlistenState = false;
2381 /*Inform wpas of remain-on-channel expiration*/
2382 cfg80211_remain_on_channel_expired(priv->wdev,
2383 priv->strRemainOnChanParams.u64ListenCookie,
2384 priv->strRemainOnChanParams.pstrListenChan,
2387 PRINT_D(GENERIC_DBG, "Received ID 0x%x Expected ID 0x%x (No match)\n", u32SessionID
2388 , priv->strRemainOnChanParams.u32ListenSessionID);
2394 * @brief WILC_WFI_remain_on_channel
2395 * @details Request the driver to remain awake on the specified
2396 * channel for the specified duration to complete an off-channel
2397 * operation (e.g., public action frame exchange). When the driver is
2398 * ready on the requested channel, it must indicate this with an event
2399 * notification by calling cfg80211_ready_on_channel().
2401 * @return int : Return 0 on Success
2406 static int WILC_WFI_remain_on_channel(struct wiphy *wiphy,
2407 struct wireless_dev *wdev,
2408 struct ieee80211_channel *chan,
2409 unsigned int duration, u64 *cookie)
2411 s32 s32Error = WILC_SUCCESS;
2412 struct WILC_WFI_priv *priv;
2414 priv = wiphy_priv(wiphy);
2416 PRINT_D(GENERIC_DBG, "Remaining on channel %d\n", chan->hw_value);
2418 /*BugID_4800: if in AP mode, return.*/
2419 /*This check is to handle the situation when user*/
2420 /*requests "create group" during a running scan*/
2422 if (wdev->iftype == NL80211_IFTYPE_AP) {
2423 PRINT_D(GENERIC_DBG, "Required remain-on-channel while in AP mode");
2427 u8CurrChannel = chan->hw_value;
2429 /*Setting params needed by WILC_WFI_RemainOnChannelExpired()*/
2430 priv->strRemainOnChanParams.pstrListenChan = chan;
2431 priv->strRemainOnChanParams.u64ListenCookie = *cookie;
2432 priv->strRemainOnChanParams.u32ListenDuration = duration;
2433 priv->strRemainOnChanParams.u32ListenSessionID++;
2435 s32Error = host_int_remain_on_channel(priv->hWILCWFIDrv
2436 , priv->strRemainOnChanParams.u32ListenSessionID
2439 , WILC_WFI_RemainOnChannelExpired
2440 , WILC_WFI_RemainOnChannelReady
2447 * @brief WILC_WFI_cancel_remain_on_channel
2448 * @details Cancel an on-going remain-on-channel operation.
2449 * This allows the operation to be terminated prior to timeout based on
2450 * the duration value.
2451 * @param[in] struct wiphy *wiphy,
2452 * @param[in] struct net_device *dev
2453 * @param[in] u64 cookie,
2454 * @return int : Return 0 on Success
2459 static int WILC_WFI_cancel_remain_on_channel(struct wiphy *wiphy,
2460 struct wireless_dev *wdev,
2463 s32 s32Error = WILC_SUCCESS;
2464 struct WILC_WFI_priv *priv;
2466 priv = wiphy_priv(wiphy);
2468 PRINT_D(CFG80211_DBG, "Cancel remain on channel\n");
2470 s32Error = host_int_ListenStateExpired(priv->hWILCWFIDrv, priv->strRemainOnChanParams.u32ListenSessionID);
2474 * @brief WILC_WFI_add_wilcvendorspec
2475 * @details Adding WILC information elemet to allow two WILC devices to
2476 * identify each other and connect
2477 * @param[in] u8 * buf
2483 void WILC_WFI_add_wilcvendorspec(u8 *buff)
2485 memcpy(buff, u8P2P_vendorspec, sizeof(u8P2P_vendorspec));
2488 * @brief WILC_WFI_mgmt_tx_frame
2497 extern linux_wlan_t *g_linux_wlan;
2498 extern bool bEnablePS;
2499 int WILC_WFI_mgmt_tx(struct wiphy *wiphy,
2500 struct wireless_dev *wdev,
2501 struct cfg80211_mgmt_tx_params *params,
2504 struct ieee80211_channel *chan = params->chan;
2505 unsigned int wait = params->wait;
2506 const u8 *buf = params->buf;
2507 size_t len = params->len;
2508 const struct ieee80211_mgmt *mgmt;
2509 struct p2p_mgmt_data *mgmt_tx;
2510 struct WILC_WFI_priv *priv;
2511 s32 s32Error = WILC_SUCCESS;
2512 tstrWILC_WFIDrv *pstrWFIDrv;
2514 perInterface_wlan_t *nic;
2515 u32 buf_len = len + sizeof(u8P2P_vendorspec) + sizeof(u8P2Plocalrandom);
2517 nic = netdev_priv(wdev->netdev);
2518 priv = wiphy_priv(wiphy);
2519 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2521 *cookie = (unsigned long)buf;
2522 priv->u64tx_cookie = *cookie;
2523 mgmt = (const struct ieee80211_mgmt *) buf;
2525 if (ieee80211_is_mgmt(mgmt->frame_control)) {
2527 /*mgmt frame allocation*/
2528 mgmt_tx = kmalloc(sizeof(struct p2p_mgmt_data), GFP_KERNEL);
2529 if (mgmt_tx == NULL) {
2530 PRINT_ER("Failed to allocate memory for mgmt_tx structure\n");
2533 mgmt_tx->buff = kmalloc(buf_len, GFP_KERNEL);
2534 if (mgmt_tx->buff == NULL) {
2535 PRINT_ER("Failed to allocate memory for mgmt_tx buff\n");
2539 memcpy(mgmt_tx->buff, buf, len);
2540 mgmt_tx->size = len;
2543 if (ieee80211_is_probe_resp(mgmt->frame_control)) {
2544 PRINT_D(GENERIC_DBG, "TX: Probe Response\n");
2545 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2546 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2547 /*Save the current channel after we tune to it*/
2548 u8CurrChannel = chan->hw_value;
2549 } else if (ieee80211_is_action(mgmt->frame_control)) {
2550 PRINT_D(GENERIC_DBG, "ACTION FRAME:%x\n", (u16)mgmt->frame_control);
2554 if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
2556 /*Only set the channel, if not a negotiation confirmation frame
2557 * (If Negotiation confirmation frame, force it
2558 * to be transmitted on the same negotiation channel)*/
2560 if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC ||
2561 buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) {
2562 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2563 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2564 /*Save the current channel after we tune to it*/
2565 u8CurrChannel = chan->hw_value;
2567 switch (buf[ACTION_SUBTYPE_ID]) {
2568 case GAS_INTIAL_REQ:
2570 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buf[ACTION_SUBTYPE_ID]);
2574 case GAS_INTIAL_RSP:
2576 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buf[ACTION_SUBTYPE_ID]);
2580 case PUBLIC_ACT_VENDORSPEC:
2582 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2583 * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/
2584 if (!memcmp(u8P2P_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) {
2585 /*For the connection of two WILC's connection generate a rand number to determine who will be a GO*/
2586 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
2587 if (u8P2Plocalrandom == 1 && u8P2Precvrandom < u8P2Plocalrandom) {
2588 get_random_bytes(&u8P2Plocalrandom, 1);
2589 /*Increment the number to prevent if its 0*/
2594 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
2595 || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
2596 if (u8P2Plocalrandom > u8P2Precvrandom) {
2597 PRINT_D(GENERIC_DBG, "LOCAL WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2599 /*Search for the p2p information information element , after the Public action subtype theres a byte for teh dialog token, skip that*/
2600 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) {
2601 if (buf[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buf[i + 2], 4))) {
2602 if (buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)
2603 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), true, nic->iftype);
2606 /*If using supplicant go intent, no need at all*/
2607 /*to parse transmitted negotiation frames*/
2608 #ifndef USE_SUPPLICANT_GO_INTENT
2610 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), false, nic->iftype);
2616 if (buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_REQ && buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_RSP) {
2617 WILC_WFI_add_wilcvendorspec(&mgmt_tx->buff[len]);
2618 mgmt_tx->buff[len + sizeof(u8P2P_vendorspec)] = u8P2Plocalrandom;
2619 mgmt_tx->size = buf_len;
2622 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2626 PRINT_D(GENERIC_DBG, "Not a P2P public action frame\n");
2634 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf[ACTION_SUBTYPE_ID]);
2641 PRINT_D(GENERIC_DBG, "TX: ACTION FRAME Type:%x : Chan:%d\n", buf[ACTION_SUBTYPE_ID], chan->hw_value);
2642 pstrWFIDrv->u64P2p_MgmtTimeout = (jiffies + msecs_to_jiffies(wait));
2644 PRINT_D(GENERIC_DBG, "Current Jiffies: %lu Timeout:%llu\n", jiffies, pstrWFIDrv->u64P2p_MgmtTimeout);
2648 g_linux_wlan->oup.wlan_add_mgmt_to_tx_que(mgmt_tx, mgmt_tx->buff, mgmt_tx->size, WILC_WFI_mgmt_tx_complete);
2650 PRINT_D(GENERIC_DBG, "This function transmits only management frames\n");
2655 int WILC_WFI_mgmt_tx_cancel_wait(struct wiphy *wiphy,
2656 struct wireless_dev *wdev,
2659 struct WILC_WFI_priv *priv;
2660 tstrWILC_WFIDrv *pstrWFIDrv;
2662 priv = wiphy_priv(wiphy);
2663 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2666 PRINT_D(GENERIC_DBG, "Tx Cancel wait :%lu\n", jiffies);
2667 pstrWFIDrv->u64P2p_MgmtTimeout = jiffies;
2669 if (priv->bInP2PlistenState == false) {
2670 /* Bug 5504: This is just to avoid connection failure when getting stuck when the supplicant
2671 * considers the driver falsely that it is in Listen state */
2672 cfg80211_remain_on_channel_expired(priv->wdev,
2673 priv->strRemainOnChanParams.u64ListenCookie,
2674 priv->strRemainOnChanParams.pstrListenChan,
2682 * @brief WILC_WFI_frame_register
2683 * @details Notify driver that a management frame type was
2684 * registered. Note that this callback may not sleep, and cannot run
2685 * concurrently with itself.
2692 void WILC_WFI_frame_register(struct wiphy *wiphy,
2693 struct wireless_dev *wdev,
2694 u16 frame_type, bool reg)
2697 struct WILC_WFI_priv *priv;
2698 perInterface_wlan_t *nic;
2701 priv = wiphy_priv(wiphy);
2702 nic = netdev_priv(priv->wdev->netdev);
2710 PRINT_D(GENERIC_DBG, "Frame registering Frame Type: %x: Boolean: %d\n", frame_type, reg);
2711 switch (frame_type) {
2714 nic->g_struct_frame_reg[0].frame_type = frame_type;
2715 nic->g_struct_frame_reg[0].reg = reg;
2721 nic->g_struct_frame_reg[1].frame_type = frame_type;
2722 nic->g_struct_frame_reg[1].reg = reg;
2732 /*If mac is closed, then return*/
2733 if (!g_linux_wlan->wilc1000_initialized) {
2734 PRINT_D(GENERIC_DBG, "Return since mac is closed\n");
2737 host_int_frame_register(priv->hWILCWFIDrv, frame_type, reg);
2744 * @brief WILC_WFI_set_cqm_rssi_config
2745 * @details Configure connection quality monitor RSSI threshold.
2746 * @param[in] struct wiphy *wiphy:
2747 * @param[in] struct net_device *dev:
2748 * @param[in] s32 rssi_thold:
2749 * @param[in] u32 rssi_hyst:
2750 * @return int : Return 0 on Success
2755 static int WILC_WFI_set_cqm_rssi_config(struct wiphy *wiphy,
2756 struct net_device *dev, s32 rssi_thold, u32 rssi_hyst)
2758 PRINT_D(CFG80211_DBG, "Setting CQM RSSi Function\n");
2763 * @brief WILC_WFI_dump_station
2764 * @details Configure connection quality monitor RSSI threshold.
2765 * @param[in] struct wiphy *wiphy:
2766 * @param[in] struct net_device *dev
2767 * @param[in] int idx
2768 * @param[in] u8 *mac
2769 * @param[in] struct station_info *sinfo
2770 * @return int : Return 0 on Success
2775 static int WILC_WFI_dump_station(struct wiphy *wiphy, struct net_device *dev,
2776 int idx, u8 *mac, struct station_info *sinfo)
2778 struct WILC_WFI_priv *priv;
2780 PRINT_D(CFG80211_DBG, "Dumping station information\n");
2785 priv = wiphy_priv(wiphy);
2787 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
2789 host_int_get_rssi(priv->hWILCWFIDrv, &(sinfo->signal));
2797 * @brief WILC_WFI_set_power_mgmt
2800 * @return int : Return 0 on Success.
2803 * @version 1.0WILC_WFI_set_cqmWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_config_rssi_config
2805 int WILC_WFI_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2806 bool enabled, int timeout)
2808 struct WILC_WFI_priv *priv;
2810 PRINT_D(CFG80211_DBG, " Power save Enabled= %d , TimeOut = %d\n", enabled, timeout);
2815 priv = wiphy_priv(wiphy);
2816 if (priv->hWILCWFIDrv == NULL) {
2817 PRINT_ER("Driver is NULL\n");
2822 host_int_set_power_mgmt(priv->hWILCWFIDrv, enabled, timeout);
2825 return WILC_SUCCESS;
2828 #ifdef WILC_AP_EXTERNAL_MLME
2830 * @brief WILC_WFI_change_virt_intf
2831 * @details Change type/configuration of virtual interface,
2832 * keep the struct wireless_dev's iftype updated.
2834 * @return int : Return 0 on Success.
2839 void wilc1000_wlan_deinit(linux_wlan_t *nic);
2840 int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic);
2842 static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev,
2843 enum nl80211_iftype type, u32 *flags, struct vif_params *params)
2845 s32 s32Error = WILC_SUCCESS;
2846 struct WILC_WFI_priv *priv;
2847 perInterface_wlan_t *nic;
2854 nic = netdev_priv(dev);
2855 priv = wiphy_priv(wiphy);
2857 PRINT_D(HOSTAPD_DBG, "In Change virtual interface function\n");
2858 PRINT_D(HOSTAPD_DBG, "Wireless interface name =%s\n", dev->name);
2859 u8P2Plocalrandom = 0x01;
2860 u8P2Precvrandom = 0x00;
2864 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2865 g_obtainingIP = false;
2866 del_timer(&hDuringIpTimer);
2867 PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n");
2870 /*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to CE H/W*/
2871 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2872 Set_machw_change_vir_if(true);
2876 case NL80211_IFTYPE_STATION:
2878 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_STATION\n");
2880 /* send delba over wlan interface */
2883 dev->ieee80211_ptr->iftype = type;
2884 priv->wdev->iftype = type;
2885 nic->monitor_flag = 0;
2886 nic->iftype = STATION_MODE;
2888 /*Remove the enteries of the previously connected clients*/
2889 memset(priv->assoc_stainfo.au8Sta_AssociatedBss, 0, MAX_NUM_STA * ETH_ALEN);
2891 interface_type = nic->iftype;
2892 nic->iftype = STATION_MODE;
2894 if (g_linux_wlan->wilc1000_initialized) {
2895 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
2896 /* ensure that the message Q is empty */
2897 host_int_wait_msg_queue_idle();
2900 /*Eliminate host interface blocking state*/
2901 up(&g_linux_wlan->cfg_event);
2903 wilc1000_wlan_deinit(g_linux_wlan);
2904 wilc1000_wlan_init(dev, nic);
2905 g_wilc_initialized = 1;
2906 nic->iftype = interface_type;
2908 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
2909 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
2910 host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler,
2911 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
2912 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2914 /*Add saved WEP keys, if any*/
2915 if (g_wep_keys_saved) {
2916 host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler,
2917 g_key_wep_params.key_idx);
2918 host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler,
2919 g_key_wep_params.key,
2920 g_key_wep_params.key_len,
2921 g_key_wep_params.key_idx);
2924 /*No matter the driver handler passed here, it will be overwriiten*/
2925 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2926 host_int_flush_join_req(priv->hWILCWFIDrv);
2928 /*Add saved PTK and GTK keys, if any*/
2929 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2930 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
2931 g_key_ptk_params.key[1],
2932 g_key_ptk_params.key[2]);
2933 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
2934 g_key_gtk_params.key[1],
2935 g_key_gtk_params.key[2]);
2936 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2937 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2938 g_add_ptk_key_params.key_idx,
2939 g_add_ptk_key_params.pairwise,
2940 g_add_ptk_key_params.mac_addr,
2941 (struct key_params *)(&g_key_ptk_params));
2943 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2944 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2945 g_add_gtk_key_params.key_idx,
2946 g_add_gtk_key_params.pairwise,
2947 g_add_gtk_key_params.mac_addr,
2948 (struct key_params *)(&g_key_gtk_params));
2951 /*BugID_4847: registered frames in firmware are now*/
2952 /*lost due to mac close. So re-register those frames*/
2953 if (g_linux_wlan->wilc1000_initialized) {
2954 for (i = 0; i < num_reg_frame; i++) {
2955 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2956 nic->g_struct_frame_reg[i].reg);
2957 host_int_frame_register(priv->hWILCWFIDrv,
2958 nic->g_struct_frame_reg[i].frame_type,
2959 nic->g_struct_frame_reg[i].reg);
2964 host_int_set_power_mgmt(priv->hWILCWFIDrv, 1, 0);
2969 case NL80211_IFTYPE_P2P_CLIENT:
2971 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
2973 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n");
2975 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
2977 dev->ieee80211_ptr->iftype = type;
2978 priv->wdev->iftype = type;
2979 nic->monitor_flag = 0;
2983 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
2984 nic->iftype = CLIENT_MODE;
2987 if (g_linux_wlan->wilc1000_initialized) {
2988 /* ensure that the message Q is empty */
2989 host_int_wait_msg_queue_idle();
2991 wilc1000_wlan_deinit(g_linux_wlan);
2992 wilc1000_wlan_init(dev, nic);
2993 g_wilc_initialized = 1;
2995 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
2996 host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler,
2997 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
2998 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
3000 /*Add saved WEP keys, if any*/
3001 if (g_wep_keys_saved) {
3002 host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler,
3003 g_key_wep_params.key_idx);
3004 host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler,
3005 g_key_wep_params.key,
3006 g_key_wep_params.key_len,
3007 g_key_wep_params.key_idx);
3010 /*No matter the driver handler passed here, it will be overwriiten*/
3011 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
3012 host_int_flush_join_req(priv->hWILCWFIDrv);
3014 /*Add saved PTK and GTK keys, if any*/
3015 if (g_ptk_keys_saved && g_gtk_keys_saved) {
3016 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
3017 g_key_ptk_params.key[1],
3018 g_key_ptk_params.key[2]);
3019 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
3020 g_key_gtk_params.key[1],
3021 g_key_gtk_params.key[2]);
3022 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3023 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3024 g_add_ptk_key_params.key_idx,
3025 g_add_ptk_key_params.pairwise,
3026 g_add_ptk_key_params.mac_addr,
3027 (struct key_params *)(&g_key_ptk_params));
3029 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3030 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3031 g_add_gtk_key_params.key_idx,
3032 g_add_gtk_key_params.pairwise,
3033 g_add_gtk_key_params.mac_addr,
3034 (struct key_params *)(&g_key_gtk_params));
3037 /*Refresh scan, to refresh the scan results to the wpa_supplicant. Set MachHw to false to enable further key installments*/
3038 refresh_scan(priv, 1, true);
3039 Set_machw_change_vir_if(false);
3041 /*BugID_4847: registered frames in firmware are now lost
3042 * due to mac close. So re-register those frames */
3043 if (g_linux_wlan->wilc1000_initialized) {
3044 for (i = 0; i < num_reg_frame; i++) {
3045 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
3046 nic->g_struct_frame_reg[i].reg);
3047 host_int_frame_register(priv->hWILCWFIDrv,
3048 nic->g_struct_frame_reg[i].frame_type,
3049 nic->g_struct_frame_reg[i].reg);
3056 case NL80211_IFTYPE_AP:
3058 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_AP %d\n", type);
3059 dev->ieee80211_ptr->iftype = type;
3060 priv->wdev->iftype = type;
3061 nic->iftype = AP_MODE;
3062 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
3064 PRINT_D(HOSTAPD_DBG, "Downloading AP firmware\n");
3065 linux_wlan_get_firmware(nic);
3067 /*If wilc is running, then close-open to actually get new firmware running (serves P2P)*/
3068 if (g_linux_wlan->wilc1000_initialized) {
3069 nic->iftype = AP_MODE;
3070 g_linux_wlan->wilc1000_initialized = 1;
3074 /*BugID_4847: registered frames in firmware are now lost
3075 * due to mac close. So re-register those frames */
3076 for (i = 0; i < num_reg_frame; i++) {
3077 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
3078 nic->g_struct_frame_reg[i].reg);
3079 host_int_frame_register(priv->hWILCWFIDrv,
3080 nic->g_struct_frame_reg[i].frame_type,
3081 nic->g_struct_frame_reg[i].reg);
3087 case NL80211_IFTYPE_P2P_GO:
3088 PRINT_D(GENERIC_DBG, "start duringIP timer\n");
3090 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3091 g_obtainingIP = true;
3092 mod_timer(&hDuringIpTimer, jiffies + msecs_to_jiffies(duringIP_TIME));
3094 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
3096 /*Delete block ack has to be the latest config packet*/
3097 /*sent before downloading new FW. This is because it blocks on*/
3098 /*hWaitResponse semaphore, which allows previous config*/
3099 /*packets to actually take action on old FW*/
3100 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
3102 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n");
3103 dev->ieee80211_ptr->iftype = type;
3104 priv->wdev->iftype = type;
3106 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
3109 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
3113 nic->iftype = GO_MODE;
3115 /* ensure that the message Q is empty */
3116 host_int_wait_msg_queue_idle();
3117 wilc1000_wlan_deinit(g_linux_wlan);
3118 wilc1000_wlan_init(dev, nic);
3119 g_wilc_initialized = 1;
3122 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
3123 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
3124 host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler,
3125 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
3126 host_int_set_operation_mode(priv->hWILCWFIDrv, AP_MODE);
3128 /*Add saved WEP keys, if any*/
3129 if (g_wep_keys_saved) {
3130 host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler,
3131 g_key_wep_params.key_idx);
3132 host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler,
3133 g_key_wep_params.key,
3134 g_key_wep_params.key_len,
3135 g_key_wep_params.key_idx);
3138 /*No matter the driver handler passed here, it will be overwriiten*/
3139 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
3140 host_int_flush_join_req(priv->hWILCWFIDrv);
3142 /*Add saved PTK and GTK keys, if any*/
3143 if (g_ptk_keys_saved && g_gtk_keys_saved) {
3144 PRINT_D(CFG80211_DBG, "ptk %x %x %x cipher %x\n", g_key_ptk_params.key[0],
3145 g_key_ptk_params.key[1],
3146 g_key_ptk_params.key[2],
3147 g_key_ptk_params.cipher);
3148 PRINT_D(CFG80211_DBG, "gtk %x %x %x cipher %x\n", g_key_gtk_params.key[0],
3149 g_key_gtk_params.key[1],
3150 g_key_gtk_params.key[2],
3151 g_key_gtk_params.cipher);
3153 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3154 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3155 g_add_ptk_key_params.key_idx,
3156 g_add_ptk_key_params.pairwise,
3157 g_add_ptk_key_params.mac_addr,
3158 (struct key_params *)(&g_key_ptk_params));
3160 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3161 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3162 g_add_gtk_key_params.key_idx,
3163 g_add_gtk_key_params.pairwise,
3164 g_add_gtk_key_params.mac_addr,
3165 (struct key_params *)(&g_key_gtk_params));
3170 /*BugID_4847: registered frames in firmware are now*/
3171 /*lost due to mac close. So re-register those frames*/
3172 if (g_linux_wlan->wilc1000_initialized) {
3173 for (i = 0; i < num_reg_frame; i++) {
3174 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
3175 nic->g_struct_frame_reg[i].reg);
3176 host_int_frame_register(priv->hWILCWFIDrv,
3177 nic->g_struct_frame_reg[i].frame_type,
3178 nic->g_struct_frame_reg[i].reg);
3185 PRINT_ER("Unknown interface type= %d\n", type);
3194 /* (austin.2013-07-23)
3196 * To support revised cfg80211_ops
3198 * add_beacon --> start_ap
3199 * set_beacon --> change_beacon
3200 * del_beacon --> stop_ap
3202 * beacon_parameters --> cfg80211_ap_settings
3203 * cfg80211_beacon_data
3205 * applicable for linux kernel 3.4+
3209 * @brief WILC_WFI_start_ap
3210 * @details Add a beacon with given parameters, @head, @interval
3211 * and @dtim_period will be valid, @tail is optional.
3213 * @param[in] dev The net device structure
3214 * @param[in] settings cfg80211_ap_settings parameters for the beacon to be added
3215 * @return int : Return 0 on Success.
3220 static int WILC_WFI_start_ap(struct wiphy *wiphy, struct net_device *dev,
3221 struct cfg80211_ap_settings *settings)
3223 struct cfg80211_beacon_data *beacon = &(settings->beacon);
3224 struct WILC_WFI_priv *priv;
3225 s32 s32Error = WILC_SUCCESS;
3227 priv = wiphy_priv(wiphy);
3228 PRINT_D(HOSTAPD_DBG, "Starting ap\n");
3230 PRINT_D(HOSTAPD_DBG, "Interval = %d\n DTIM period = %d\n Head length = %zu Tail length = %zu\n",
3231 settings->beacon_interval, settings->dtim_period, beacon->head_len, beacon->tail_len);
3233 s32Error = set_channel(wiphy, &settings->chandef);
3235 if (s32Error != WILC_SUCCESS)
3236 PRINT_ER("Error in setting channel\n");
3238 linux_wlan_set_bssid(dev, g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
3240 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
3241 settings->beacon_interval,
3242 settings->dtim_period,
3243 beacon->head_len, (u8 *)beacon->head,
3244 beacon->tail_len, (u8 *)beacon->tail);
3250 * @brief WILC_WFI_change_beacon
3251 * @details Add a beacon with given parameters, @head, @interval
3252 * and @dtim_period will be valid, @tail is optional.
3254 * @param[in] dev The net device structure
3255 * @param[in] beacon cfg80211_beacon_data for the beacon to be changed
3256 * @return int : Return 0 on Success.
3261 static int WILC_WFI_change_beacon(struct wiphy *wiphy, struct net_device *dev,
3262 struct cfg80211_beacon_data *beacon)
3264 struct WILC_WFI_priv *priv;
3265 s32 s32Error = WILC_SUCCESS;
3267 priv = wiphy_priv(wiphy);
3268 PRINT_D(HOSTAPD_DBG, "Setting beacon\n");
3271 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
3274 beacon->head_len, (u8 *)beacon->head,
3275 beacon->tail_len, (u8 *)beacon->tail);
3281 * @brief WILC_WFI_stop_ap
3282 * @details Remove beacon configuration and stop sending the beacon.
3284 * @return int : Return 0 on Success.
3289 static int WILC_WFI_stop_ap(struct wiphy *wiphy, struct net_device *dev)
3291 s32 s32Error = WILC_SUCCESS;
3292 struct WILC_WFI_priv *priv;
3293 u8 NullBssid[ETH_ALEN] = {0};
3296 WILC_NULLCHECK(s32Error, wiphy);
3298 priv = wiphy_priv(wiphy);
3300 PRINT_D(HOSTAPD_DBG, "Deleting beacon\n");
3303 linux_wlan_set_bssid(dev, NullBssid);
3305 s32Error = host_int_del_beacon(priv->hWILCWFIDrv);
3307 WILC_ERRORCHECK(s32Error);
3309 WILC_CATCH(s32Error)
3316 * @brief WILC_WFI_add_station
3317 * @details Add a new station.
3319 * @return int : Return 0 on Success.
3324 static int WILC_WFI_add_station(struct wiphy *wiphy, struct net_device *dev,
3325 const u8 *mac, struct station_parameters *params)
3327 s32 s32Error = WILC_SUCCESS;
3328 struct WILC_WFI_priv *priv;
3329 tstrWILC_AddStaParam strStaParams = { {0} };
3330 perInterface_wlan_t *nic;
3333 WILC_NULLCHECK(s32Error, wiphy);
3335 priv = wiphy_priv(wiphy);
3336 nic = netdev_priv(dev);
3338 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3339 memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
3340 memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN);
3341 strStaParams.u16AssocID = params->aid;
3342 strStaParams.u8NumRates = params->supported_rates_len;
3343 strStaParams.pu8Rates = params->supported_rates;
3345 PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid);
3347 PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n", priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][0], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][1], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][2], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][3], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][4],
3348 priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]);
3349 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3350 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3352 if (params->ht_capa == NULL) {
3353 strStaParams.bIsHTSupported = false;
3355 strStaParams.bIsHTSupported = true;
3356 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3357 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
3358 memcpy(strStaParams.au8SuppMCsSet, ¶ms->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
3359 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3360 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3361 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3364 strStaParams.u16FlagsMask = params->sta_flags_mask;
3365 strStaParams.u16FlagsSet = params->sta_flags_set;
3367 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3368 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3369 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3370 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3371 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3372 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3373 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3374 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3376 s32Error = host_int_add_station(priv->hWILCWFIDrv, &strStaParams);
3377 WILC_ERRORCHECK(s32Error);
3380 WILC_CATCH(s32Error)
3387 * @brief WILC_WFI_del_station
3388 * @details Remove a station; @mac may be NULL to remove all stations.
3390 * @return int : Return 0 on Success.
3395 static int WILC_WFI_del_station(struct wiphy *wiphy, struct net_device *dev,
3396 struct station_del_parameters *params)
3398 const u8 *mac = params->mac;
3399 s32 s32Error = WILC_SUCCESS;
3400 struct WILC_WFI_priv *priv;
3401 perInterface_wlan_t *nic;
3403 WILC_NULLCHECK(s32Error, wiphy);
3405 priv = wiphy_priv(wiphy);
3406 nic = netdev_priv(dev);
3408 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3409 PRINT_D(HOSTAPD_DBG, "Deleting station\n");
3413 PRINT_D(HOSTAPD_DBG, "All associated stations\n");
3414 s32Error = host_int_del_allstation(priv->hWILCWFIDrv, priv->assoc_stainfo.au8Sta_AssociatedBss);
3416 PRINT_D(HOSTAPD_DBG, "With mac address: %x%x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
3419 s32Error = host_int_del_station(priv->hWILCWFIDrv, mac);
3421 WILC_ERRORCHECK(s32Error);
3423 WILC_CATCH(s32Error)
3430 * @brief WILC_WFI_change_station
3431 * @details Modify a given station.
3433 * @return int : Return 0 on Success.
3438 static int WILC_WFI_change_station(struct wiphy *wiphy, struct net_device *dev,
3439 const u8 *mac, struct station_parameters *params)
3441 s32 s32Error = WILC_SUCCESS;
3442 struct WILC_WFI_priv *priv;
3443 tstrWILC_AddStaParam strStaParams = { {0} };
3444 perInterface_wlan_t *nic;
3447 PRINT_D(HOSTAPD_DBG, "Change station paramters\n");
3449 WILC_NULLCHECK(s32Error, wiphy);
3451 priv = wiphy_priv(wiphy);
3452 nic = netdev_priv(dev);
3454 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3455 memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
3456 strStaParams.u16AssocID = params->aid;
3457 strStaParams.u8NumRates = params->supported_rates_len;
3458 strStaParams.pu8Rates = params->supported_rates;
3460 PRINT_D(HOSTAPD_DBG, "BSSID = %x%x%x%x%x%x\n", strStaParams.au8BSSID[0], strStaParams.au8BSSID[1], strStaParams.au8BSSID[2], strStaParams.au8BSSID[3], strStaParams.au8BSSID[4],
3461 strStaParams.au8BSSID[5]);
3462 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3463 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3465 if (params->ht_capa == NULL) {
3466 strStaParams.bIsHTSupported = false;
3468 strStaParams.bIsHTSupported = true;
3469 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3470 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
3471 memcpy(strStaParams.au8SuppMCsSet, ¶ms->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
3472 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3473 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3474 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3478 strStaParams.u16FlagsMask = params->sta_flags_mask;
3479 strStaParams.u16FlagsSet = params->sta_flags_set;
3481 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3482 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3483 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3484 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3485 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3486 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3487 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3488 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3490 s32Error = host_int_edit_station(priv->hWILCWFIDrv, &strStaParams);
3491 WILC_ERRORCHECK(s32Error);
3493 WILC_CATCH(s32Error)
3501 * @brief WILC_WFI_add_virt_intf
3504 * @return int : Return 0 on Success.
3509 struct wireless_dev *WILC_WFI_add_virt_intf(struct wiphy *wiphy, const char *name,
3510 unsigned char name_assign_type,
3511 enum nl80211_iftype type, u32 *flags,
3512 struct vif_params *params)
3514 perInterface_wlan_t *nic;
3515 struct WILC_WFI_priv *priv;
3516 struct net_device *new_ifc = NULL;
3518 priv = wiphy_priv(wiphy);
3522 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", priv->wdev->netdev);
3524 nic = netdev_priv(priv->wdev->netdev);
3527 if (type == NL80211_IFTYPE_MONITOR) {
3528 PRINT_D(HOSTAPD_DBG, "Monitor interface mode: Initializing mon interface virtual device driver\n");
3529 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", nic->wilc_netdev);
3530 new_ifc = WILC_WFI_init_mon_interface(name, nic->wilc_netdev);
3531 if (new_ifc != NULL) {
3532 PRINT_D(HOSTAPD_DBG, "Setting monitor flag in private structure\n");
3533 nic = netdev_priv(priv->wdev->netdev);
3534 nic->monitor_flag = 1;
3536 PRINT_ER("Error in initializing monitor interface\n ");
3542 * @brief WILC_WFI_del_virt_intf
3545 * @return int : Return 0 on Success.
3550 int WILC_WFI_del_virt_intf(struct wiphy *wiphy, struct wireless_dev *wdev) /* tony for v3.8 support */
3552 PRINT_D(HOSTAPD_DBG, "Deleting virtual interface\n");
3553 return WILC_SUCCESS;
3558 #endif /*WILC_AP_EXTERNAL_MLME*/
3559 static struct cfg80211_ops WILC_WFI_cfg80211_ops = {
3561 .set_monitor_channel = set_channel,
3564 .disconnect = disconnect,
3568 .set_default_key = set_default_key,
3569 #ifdef WILC_AP_EXTERNAL_MLME
3570 .add_virtual_intf = WILC_WFI_add_virt_intf,
3571 .del_virtual_intf = WILC_WFI_del_virt_intf,
3572 .change_virtual_intf = WILC_WFI_change_virt_intf,
3574 .start_ap = WILC_WFI_start_ap,
3575 .change_beacon = WILC_WFI_change_beacon,
3576 .stop_ap = WILC_WFI_stop_ap,
3577 .add_station = WILC_WFI_add_station,
3578 .del_station = WILC_WFI_del_station,
3579 .change_station = WILC_WFI_change_station,
3580 #endif /* WILC_AP_EXTERNAL_MLME*/
3581 .get_station = WILC_WFI_get_station,
3582 .dump_station = WILC_WFI_dump_station,
3583 .change_bss = WILC_WFI_change_bss,
3584 .set_wiphy_params = WILC_WFI_set_wiphy_params,
3586 .set_pmksa = WILC_WFI_set_pmksa,
3587 .del_pmksa = WILC_WFI_del_pmksa,
3588 .flush_pmksa = WILC_WFI_flush_pmksa,
3590 .remain_on_channel = WILC_WFI_remain_on_channel,
3591 .cancel_remain_on_channel = WILC_WFI_cancel_remain_on_channel,
3592 .mgmt_tx_cancel_wait = WILC_WFI_mgmt_tx_cancel_wait,
3593 .mgmt_tx = WILC_WFI_mgmt_tx,
3594 .mgmt_frame_register = WILC_WFI_frame_register,
3595 .set_power_mgmt = WILC_WFI_set_power_mgmt,
3596 .set_cqm_rssi_config = WILC_WFI_set_cqm_rssi_config,
3606 * @brief WILC_WFI_update_stats
3607 * @details Modify parameters for a given BSS.
3609 * @return int : Return 0 on Success.
3612 * @version 1.0WILC_WFI_set_cqmWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_config_rssi_config
3614 int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed)
3617 struct WILC_WFI_priv *priv;
3619 priv = wiphy_priv(wiphy);
3623 case WILC_WFI_RX_PKT:
3625 priv->netstats.rx_packets++;
3626 priv->netstats.rx_bytes += pktlen;
3627 priv->netstats.rx_time = get_jiffies_64();
3631 case WILC_WFI_TX_PKT:
3633 priv->netstats.tx_packets++;
3634 priv->netstats.tx_bytes += pktlen;
3635 priv->netstats.tx_time = get_jiffies_64();
3648 * @brief WILC_WFI_CfgAlloc
3649 * @details Allocation of the wireless device structure and assigning it
3650 * to the cfg80211 operations structure.
3652 * @return wireless_dev : Returns pointer to wireless_dev structure.
3657 struct wireless_dev *WILC_WFI_CfgAlloc(void)
3660 struct wireless_dev *wdev;
3663 PRINT_D(CFG80211_DBG, "Allocating wireless device\n");
3664 /*Allocating the wireless device structure*/
3665 wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
3667 PRINT_ER("Cannot allocate wireless device\n");
3671 /*Creating a new wiphy, linking wireless structure with the wiphy structure*/
3672 wdev->wiphy = wiphy_new(&WILC_WFI_cfg80211_ops, sizeof(struct WILC_WFI_priv));
3674 PRINT_ER("Cannot allocate wiphy\n");
3679 #ifdef WILC_AP_EXTERNAL_MLME
3680 /* enable 802.11n HT */
3681 WILC_WFI_band_2ghz.ht_cap.ht_supported = 1;
3682 WILC_WFI_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT);
3683 WILC_WFI_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff;
3684 WILC_WFI_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K;
3685 WILC_WFI_band_2ghz.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE;
3689 wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &WILC_WFI_band_2ghz;
3700 * @brief WILC_WFI_WiphyRegister
3701 * @details Registering of the wiphy structure and interface modes
3708 struct wireless_dev *WILC_WFI_WiphyRegister(struct net_device *net)
3710 struct WILC_WFI_priv *priv;
3711 struct wireless_dev *wdev;
3712 s32 s32Error = WILC_SUCCESS;
3714 PRINT_D(CFG80211_DBG, "Registering wifi device\n");
3716 wdev = WILC_WFI_CfgAlloc();
3718 PRINT_ER("CfgAlloc Failed\n");
3723 /*Return hardware description structure (wiphy)'s priv*/
3724 priv = wdev_priv(wdev);
3725 sema_init(&(priv->SemHandleUpdateStats), 1);
3727 /*Link the wiphy with wireless structure*/
3730 /*Maximum number of probed ssid to be added by user for the scan request*/
3731 wdev->wiphy->max_scan_ssids = MAX_NUM_PROBED_SSID;
3732 /*Maximum number of pmkids to be cashed*/
3733 wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS;
3734 PRINT_INFO(CFG80211_DBG, "Max number of PMKIDs = %d\n", wdev->wiphy->max_num_pmkids);
3736 wdev->wiphy->max_scan_ie_len = 1000;
3738 /*signal strength in mBm (100*dBm) */
3739 wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
3741 /*Set the availaible cipher suites*/
3742 wdev->wiphy->cipher_suites = cipher_suites;
3743 wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
3744 /*Setting default managment types: for register action frame: */
3745 wdev->wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types;
3748 wdev->wiphy->max_remain_on_channel_duration = 500;
3749 /*Setting the wiphy interfcae mode and type before registering the wiphy*/
3750 wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | BIT(NL80211_IFTYPE_P2P_GO) |
3751 BIT(NL80211_IFTYPE_P2P_CLIENT);
3752 wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
3754 wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR);
3756 wdev->iftype = NL80211_IFTYPE_STATION;
3760 PRINT_INFO(CFG80211_DBG, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n",
3761 wdev->wiphy->max_scan_ssids, wdev->wiphy->max_scan_ie_len, wdev->wiphy->signal_type,
3762 wdev->wiphy->interface_modes, wdev->iftype);
3765 set_wiphy_dev(wdev->wiphy, &local_sdio_func->dev); /* tony */
3768 /*Register wiphy structure*/
3769 s32Error = wiphy_register(wdev->wiphy);
3771 PRINT_ER("Cannot register wiphy device\n");
3772 /*should define what action to be taken in such failure*/
3774 PRINT_D(CFG80211_DBG, "Successful Registering\n");
3783 * @brief WILC_WFI_WiphyFree
3784 * @details Freeing allocation of the wireless device structure
3791 int WILC_WFI_InitHostInt(struct net_device *net)
3794 s32 s32Error = WILC_SUCCESS;
3796 struct WILC_WFI_priv *priv;
3798 PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr);
3799 priv = wdev_priv(net->ieee80211_ptr);
3801 setup_timer(&hAgingTimer, remove_network_from_shadow, 0);
3802 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3803 setup_timer(&hDuringIpTimer, clear_duringIP, 0);
3808 PRINT_ER("Failed to creat refresh Timer\n");
3812 priv->gbAutoRateAdjusted = false;
3814 priv->bInP2PlistenState = false;
3816 sema_init(&(priv->hSemScanReq), 1);
3817 s32Error = host_int_init(&priv->hWILCWFIDrv);
3819 PRINT_ER("Error while initializing hostinterface\n");
3825 * @brief WILC_WFI_WiphyFree
3826 * @details Freeing allocation of the wireless device structure
3833 int WILC_WFI_DeInitHostInt(struct net_device *net)
3835 s32 s32Error = WILC_SUCCESS;
3837 struct WILC_WFI_priv *priv;
3839 priv = wdev_priv(net->ieee80211_ptr);
3841 priv->gbAutoRateAdjusted = false;
3843 priv->bInP2PlistenState = false;
3847 s32Error = host_int_deinit(priv->hWILCWFIDrv);
3849 /* Clear the Shadow scan */
3850 clear_shadow_scan(priv);
3851 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3853 PRINT_D(CORECONFIG_DBG, "destroy during ip\n");
3854 del_timer_sync(&hDuringIpTimer);
3859 PRINT_ER("Error while deintializing host interface\n");
3866 * @brief WILC_WFI_WiphyFree
3867 * @details Freeing allocation of the wireless device structure
3874 void WILC_WFI_WiphyFree(struct net_device *net)
3877 PRINT_D(CFG80211_DBG, "Unregistering wiphy\n");
3880 PRINT_D(INIT_DBG, "net_device is NULL\n");
3884 if (net->ieee80211_ptr == NULL) {
3885 PRINT_D(INIT_DBG, "ieee80211_ptr is NULL\n");
3889 if (net->ieee80211_ptr->wiphy == NULL) {
3890 PRINT_D(INIT_DBG, "wiphy is NULL\n");
3894 wiphy_unregister(net->ieee80211_ptr->wiphy);
3896 PRINT_D(INIT_DBG, "Freeing wiphy\n");
3897 wiphy_free(net->ieee80211_ptr->wiphy);
3898 kfree(net->ieee80211_ptr);