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 void linux_wlan_unlock(void *vp);
27 extern u16 Set_machw_change_vir_if(bool bValue);
29 extern int mac_open(struct net_device *ndev);
30 extern int mac_close(struct net_device *ndev);
32 tstrNetworkInfo astrLastScannedNtwrksShadow[MAX_NUM_SCANNED_NETWORKS_SHADOW];
33 u32 u32LastScannedNtwrksCountShadow;
34 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
35 struct timer_list hDuringIpTimer;
37 struct timer_list hAgingTimer;
39 extern u8 u8ConnectedSSID[6];
42 u8 g_wilc_initialized = 1;
43 extern linux_wlan_t *g_linux_wlan;
44 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
45 extern bool g_obtainingIP;
48 #define CHAN2G(_channel, _freq, _flags) { \
49 .band = IEEE80211_BAND_2GHZ, \
50 .center_freq = (_freq), \
51 .hw_value = (_channel), \
53 .max_antenna_gain = 0, \
57 /*Frequency range for channels*/
58 static struct ieee80211_channel WILC_WFI_2ghz_channels[] = {
75 #define RATETAB_ENT(_rate, _hw_value, _flags) { \
77 .hw_value = (_hw_value), \
82 /* Table 6 in section 3.2.1.1 */
83 static struct ieee80211_rate WILC_WFI_rates[] = {
84 RATETAB_ENT(10, 0, 0),
85 RATETAB_ENT(20, 1, 0),
86 RATETAB_ENT(55, 2, 0),
87 RATETAB_ENT(110, 3, 0),
88 RATETAB_ENT(60, 9, 0),
89 RATETAB_ENT(90, 6, 0),
90 RATETAB_ENT(120, 7, 0),
91 RATETAB_ENT(180, 8, 0),
92 RATETAB_ENT(240, 9, 0),
93 RATETAB_ENT(360, 10, 0),
94 RATETAB_ENT(480, 11, 0),
95 RATETAB_ENT(540, 12, 0),
99 struct p2p_mgmt_data {
104 /*Global variable used to state the current connected STA channel*/
105 u8 u8WLANChannel = INVALID_CHANNEL;
110 u8 u8P2P_oui[] = {0x50, 0x6f, 0x9A, 0x09};
111 u8 u8P2Plocalrandom = 0x01;
112 u8 u8P2Precvrandom = 0x00;
113 u8 u8P2P_vendorspec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};
117 static struct ieee80211_supported_band WILC_WFI_band_2ghz = {
118 .channels = WILC_WFI_2ghz_channels,
119 .n_channels = ARRAY_SIZE(WILC_WFI_2ghz_channels),
120 .bitrates = WILC_WFI_rates,
121 .n_bitrates = ARRAY_SIZE(WILC_WFI_rates),
126 struct add_key_params {
131 struct add_key_params g_add_gtk_key_params;
132 struct wilc_wfi_key g_key_gtk_params;
133 struct add_key_params g_add_ptk_key_params;
134 struct wilc_wfi_key g_key_ptk_params;
135 struct wilc_wfi_wep_key g_key_wep_params;
136 u8 g_flushing_in_progress;
137 bool g_ptk_keys_saved;
138 bool g_gtk_keys_saved;
139 bool g_wep_keys_saved;
141 #define AGING_TIME (9 * 1000)
142 #define duringIP_TIME 15000
144 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;
191 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
194 if ((!pstrNetworkInfo->u8Found) || all) {
196 struct ieee80211_channel *channel;
198 if (pstrNetworkInfo != NULL) {
200 s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
201 channel = ieee80211_get_channel(wiphy, s32Freq);
203 rssi = get_rssi_avg(pstrNetworkInfo);
204 if (memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7) || bDirectScan) {
205 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
206 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
207 (size_t)pstrNetworkInfo->u16IEsLen, (((s32)rssi) * 100), GFP_KERNEL);
208 cfg80211_put_bss(wiphy, bss);
217 void reset_shadow_found(void *pUserVoid)
220 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
221 astrLastScannedNtwrksShadow[i].u8Found = 0;
226 void update_scan_time(void *pUserVoid)
229 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
230 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
234 static void remove_network_from_shadow(unsigned long arg)
236 unsigned long now = jiffies;
240 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
241 if (time_after(now, astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan + (unsigned long)(SCAN_RESULT_EXPIRE))) {
242 PRINT_D(CFG80211_DBG, "Network expired in ScanShadow: %s\n", astrLastScannedNtwrksShadow[i].au8ssid);
244 if (astrLastScannedNtwrksShadow[i].pu8IEs != NULL) {
245 kfree(astrLastScannedNtwrksShadow[i].pu8IEs);
246 astrLastScannedNtwrksShadow[i].pu8IEs = NULL;
249 host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
251 for (j = i; (j < u32LastScannedNtwrksCountShadow - 1); j++) {
252 astrLastScannedNtwrksShadow[j] = astrLastScannedNtwrksShadow[j + 1];
254 u32LastScannedNtwrksCountShadow--;
258 PRINT_D(CFG80211_DBG, "Number of cached networks: %d\n", u32LastScannedNtwrksCountShadow);
259 if (u32LastScannedNtwrksCountShadow != 0) {
260 hAgingTimer.data = arg;
261 mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
263 PRINT_D(CFG80211_DBG, "No need to restart Aging timer\n");
267 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
268 static void clear_duringIP(unsigned long arg)
270 PRINT_D(GENERIC_DBG, "GO:IP Obtained , enable scan\n");
271 g_obtainingIP = false;
275 int8_t is_network_in_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid)
280 if (u32LastScannedNtwrksCountShadow == 0) {
281 PRINT_D(CFG80211_DBG, "Starting Aging timer\n");
282 hAgingTimer.data = (unsigned long)pUserVoid;
283 mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
286 /* Linear search for now */
287 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
288 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
289 pstrNetworkInfo->au8bssid, 6) == 0) {
298 void add_network_to_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
300 int8_t ap_found = is_network_in_shadow(pstrNetworkInfo, pUserVoid);
301 uint32_t ap_index = 0;
302 uint8_t rssi_index = 0;
304 if (u32LastScannedNtwrksCountShadow >= MAX_NUM_SCANNED_NETWORKS_SHADOW) {
305 PRINT_D(CFG80211_DBG, "Shadow network reached its maximum limit\n");
308 if (ap_found == -1) {
309 ap_index = u32LastScannedNtwrksCountShadow;
310 u32LastScannedNtwrksCountShadow++;
315 rssi_index = astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index;
316 astrLastScannedNtwrksShadow[ap_index].strRssi.as8RSSI[rssi_index++] = pstrNetworkInfo->s8rssi;
317 if (rssi_index == NUM_RSSI) {
319 astrLastScannedNtwrksShadow[ap_index].strRssi.u8Full = 1;
321 astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index = rssi_index;
323 astrLastScannedNtwrksShadow[ap_index].s8rssi = pstrNetworkInfo->s8rssi;
324 astrLastScannedNtwrksShadow[ap_index].u16CapInfo = pstrNetworkInfo->u16CapInfo;
326 astrLastScannedNtwrksShadow[ap_index].u8SsidLen = pstrNetworkInfo->u8SsidLen;
327 memcpy(astrLastScannedNtwrksShadow[ap_index].au8ssid,
328 pstrNetworkInfo->au8ssid, pstrNetworkInfo->u8SsidLen);
330 memcpy(astrLastScannedNtwrksShadow[ap_index].au8bssid,
331 pstrNetworkInfo->au8bssid, ETH_ALEN);
333 astrLastScannedNtwrksShadow[ap_index].u16BeaconPeriod = pstrNetworkInfo->u16BeaconPeriod;
334 astrLastScannedNtwrksShadow[ap_index].u8DtimPeriod = pstrNetworkInfo->u8DtimPeriod;
335 astrLastScannedNtwrksShadow[ap_index].u8channel = pstrNetworkInfo->u8channel;
337 astrLastScannedNtwrksShadow[ap_index].u16IEsLen = pstrNetworkInfo->u16IEsLen;
338 astrLastScannedNtwrksShadow[ap_index].u64Tsf = pstrNetworkInfo->u64Tsf;
340 kfree(astrLastScannedNtwrksShadow[ap_index].pu8IEs);
341 astrLastScannedNtwrksShadow[ap_index].pu8IEs =
342 WILC_MALLOC(pstrNetworkInfo->u16IEsLen); /* will be deallocated by the WILC_WFI_CfgScan() function */
343 memcpy(astrLastScannedNtwrksShadow[ap_index].pu8IEs,
344 pstrNetworkInfo->pu8IEs, pstrNetworkInfo->u16IEsLen);
346 astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScan = jiffies;
347 astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScanCached = jiffies;
348 astrLastScannedNtwrksShadow[ap_index].u8Found = 1;
350 host_int_freeJoinParams(astrLastScannedNtwrksShadow[ap_index].pJoinParams);
351 astrLastScannedNtwrksShadow[ap_index].pJoinParams = pJoinParams;
357 * @brief CfgScanResult
358 * @details Callback function which returns the scan results found
360 * @param[in] tenuScanEvent enuScanEvent: enum, indicating the scan event triggered, whether that is
361 * SCAN_EVENT_NETWORK_FOUND or SCAN_EVENT_DONE
362 * tstrNetworkInfo* pstrNetworkInfo: structure holding the scan results information
363 * void* pUserVoid: Private structure associated with the wireless interface
369 static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
371 struct WILC_WFI_priv *priv;
374 struct ieee80211_channel *channel;
375 s32 s32Error = WILC_SUCCESS;
376 struct cfg80211_bss *bss = NULL;
378 priv = (struct WILC_WFI_priv *)pUserVoid;
379 if (priv->bCfgScanning == true) {
380 if (enuScanEvent == SCAN_EVENT_NETWORK_FOUND) {
381 wiphy = priv->dev->ieee80211_ptr->wiphy;
382 WILC_NULLCHECK(s32Error, wiphy);
383 if (wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC
385 ((((s32)pstrNetworkInfo->s8rssi) * 100) < 0
387 (((s32)pstrNetworkInfo->s8rssi) * 100) > 100)
389 WILC_ERRORREPORT(s32Error, WILC_FAIL);
392 if (pstrNetworkInfo != NULL) {
393 s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
394 channel = ieee80211_get_channel(wiphy, s32Freq);
396 WILC_NULLCHECK(s32Error, channel);
398 PRINT_INFO(CFG80211_DBG, "Network Info:: CHANNEL Frequency: %d, RSSI: %d, CapabilityInfo: %d,"
399 "BeaconPeriod: %d\n", channel->center_freq, (((s32)pstrNetworkInfo->s8rssi) * 100),
400 pstrNetworkInfo->u16CapInfo, pstrNetworkInfo->u16BeaconPeriod);
402 if (pstrNetworkInfo->bNewNetwork == true) {
403 if (priv->u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
405 PRINT_D(CFG80211_DBG, "Network %s found\n", pstrNetworkInfo->au8ssid);
408 priv->u32RcvdChCount++;
412 if (pJoinParams == NULL) {
413 PRINT_INFO(CORECONFIG_DBG, ">> Something really bad happened\n");
415 add_network_to_shadow(pstrNetworkInfo, priv, pJoinParams);
417 /*P2P peers are sent to WPA supplicant and added to shadow table*/
419 if (!(memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7))) {
420 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
421 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
422 (size_t)pstrNetworkInfo->u16IEsLen, (((s32)pstrNetworkInfo->s8rssi) * 100), GFP_KERNEL);
423 cfg80211_put_bss(wiphy, bss);
428 PRINT_ER("Discovered networks exceeded the max limit\n");
432 /* So this network is discovered before, we'll just update its RSSI */
433 for (i = 0; i < priv->u32RcvdChCount; i++) {
434 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid, pstrNetworkInfo->au8bssid, 6) == 0) {
435 PRINT_D(CFG80211_DBG, "Update RSSI of %s\n", astrLastScannedNtwrksShadow[i].au8ssid);
437 astrLastScannedNtwrksShadow[i].s8rssi = pstrNetworkInfo->s8rssi;
438 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
444 } else if (enuScanEvent == SCAN_EVENT_DONE) {
445 PRINT_D(CFG80211_DBG, "Scan Done[%p]\n", priv->dev);
446 PRINT_D(CFG80211_DBG, "Refreshing Scan ...\n");
447 refresh_scan(priv, 1, false);
449 if (priv->u32RcvdChCount > 0)
450 PRINT_D(CFG80211_DBG, "%d Network(s) found\n", priv->u32RcvdChCount);
452 PRINT_D(CFG80211_DBG, "No networks found\n");
454 down(&(priv->hSemScanReq));
456 if (priv->pstrScanReq != NULL) {
457 cfg80211_scan_done(priv->pstrScanReq, false);
458 priv->u32RcvdChCount = 0;
459 priv->bCfgScanning = false;
460 priv->pstrScanReq = NULL;
462 up(&(priv->hSemScanReq));
465 /*Aborting any scan operation during mac close*/
466 else if (enuScanEvent == SCAN_EVENT_ABORTED) {
467 down(&(priv->hSemScanReq));
469 PRINT_D(CFG80211_DBG, "Scan Aborted\n");
470 if (priv->pstrScanReq != NULL) {
472 update_scan_time(priv);
473 refresh_scan(priv, 1, false);
475 cfg80211_scan_done(priv->pstrScanReq, false);
476 priv->bCfgScanning = false;
477 priv->pstrScanReq = NULL;
479 up(&(priv->hSemScanReq));
491 * @brief WILC_WFI_Set_PMKSA
492 * @details Check if pmksa is cached and set it.
494 * @return int : Return 0 on Success
499 int WILC_WFI_Set_PMKSA(u8 *bssid, struct WILC_WFI_priv *priv)
502 s32 s32Error = WILC_SUCCESS;
505 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
507 if (!memcmp(bssid, priv->pmkid_list.pmkidlist[i].bssid,
509 PRINT_D(CFG80211_DBG, "PMKID successful comparison");
511 /*If bssid is found, set the values*/
512 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
514 if (s32Error != WILC_SUCCESS)
515 PRINT_ER("Error in pmkid\n");
525 int linux_wlan_set_bssid(struct net_device *wilc_netdev, uint8_t *pBSSID);
529 * @brief CfgConnectResult
531 * @param[in] tenuConnDisconnEvent enuConnDisconnEvent: Type of connection response either
532 * connection response or disconnection notification.
533 * tstrConnectInfo* pstrConnectInfo: COnnection information.
534 * u8 u8MacStatus: Mac Status from firmware
535 * tstrDisconnectNotifInfo* pstrDisconnectNotifInfo: Disconnection Notification
536 * void* pUserVoid: Private data associated with wireless interface
544 static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent,
545 tstrConnectInfo *pstrConnectInfo,
547 tstrDisconnectNotifInfo *pstrDisconnectNotifInfo,
550 struct WILC_WFI_priv *priv;
551 struct net_device *dev;
553 tstrWILC_WFIDrv *pstrWFIDrv;
555 u8 NullBssid[ETH_ALEN] = {0};
558 priv = (struct WILC_WFI_priv *)pUserVoid;
561 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
564 if (enuConnDisconnEvent == CONN_DISCONN_EVENT_CONN_RESP) {
566 u16 u16ConnectStatus = WLAN_STATUS_SUCCESS;
568 u16ConnectStatus = pstrConnectInfo->u16ConnectStatus;
570 PRINT_D(CFG80211_DBG, " Connection response received = %d\n", u8MacStatus);
572 if ((u8MacStatus == MAC_DISCONNECTED) &&
573 (pstrConnectInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
574 /* The case here is that our station was waiting for association response frame and has just received it containing status code
575 * = SUCCESSFUL_STATUSCODE, while mac status is MAC_DISCONNECTED (which means something wrong happened) */
576 u16ConnectStatus = WLAN_STATUS_UNSPECIFIED_FAILURE;
577 linux_wlan_set_bssid(priv->dev, NullBssid);
578 memset(u8ConnectedSSID, 0, ETH_ALEN);
581 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
583 if (!pstrWFIDrv->u8P2PConnect)
584 u8WLANChannel = INVALID_CHANNEL;
587 PRINT_ER("Unspecified failure: Connection status %d : MAC status = %d\n", u16ConnectStatus, u8MacStatus);
590 if (u16ConnectStatus == WLAN_STATUS_SUCCESS) {
591 bool bNeedScanRefresh = false;
594 PRINT_INFO(CFG80211_DBG, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo->au8bssid[0],
595 pstrConnectInfo->au8bssid[1], pstrConnectInfo->au8bssid[2], pstrConnectInfo->au8bssid[3], pstrConnectInfo->au8bssid[4], pstrConnectInfo->au8bssid[5]);
596 memcpy(priv->au8AssociatedBss, pstrConnectInfo->au8bssid, ETH_ALEN);
598 /* BugID_4209: if this network has expired in the scan results in the above nl80211 layer, refresh them here by calling
599 * cfg80211_inform_bss() with the last Scan results before calling cfg80211_connect_result() to avoid
600 * Linux kernel warning generated at the nl80211 layer */
602 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
603 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
604 pstrConnectInfo->au8bssid, ETH_ALEN) == 0) {
605 unsigned long now = jiffies;
608 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScanCached + (unsigned long)(nl80211_SCAN_RESULT_EXPIRE - (1 * HZ)))) {
609 bNeedScanRefresh = true;
616 if (bNeedScanRefresh) {
618 /*Also, refrsh DIRECT- results if */
619 refresh_scan(priv, 1, true);
626 PRINT_D(CFG80211_DBG, "Association request info elements length = %zu\n", pstrConnectInfo->ReqIEsLen);
628 PRINT_D(CFG80211_DBG, "Association response info elements length = %d\n", pstrConnectInfo->u16RespIEsLen);
630 cfg80211_connect_result(dev, pstrConnectInfo->au8bssid,
631 pstrConnectInfo->pu8ReqIEs, pstrConnectInfo->ReqIEsLen,
632 pstrConnectInfo->pu8RespIEs, pstrConnectInfo->u16RespIEsLen,
633 u16ConnectStatus, GFP_KERNEL); /* TODO: mostafa: u16ConnectStatus to */
634 /* be replaced by pstrConnectInfo->u16ConnectStatus */
635 } else if (enuConnDisconnEvent == CONN_DISCONN_EVENT_DISCONN_NOTIF) {
636 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
637 g_obtainingIP = false;
639 PRINT_ER("Received MAC_DISCONNECTED from firmware with reason %d on dev [%p]\n",
640 pstrDisconnectNotifInfo->u16reason, priv->dev);
641 u8P2Plocalrandom = 0x01;
642 u8P2Precvrandom = 0x00;
644 memset(priv->au8AssociatedBss, 0, ETH_ALEN);
645 linux_wlan_set_bssid(priv->dev, NullBssid);
646 memset(u8ConnectedSSID, 0, ETH_ALEN);
649 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
651 if (!pstrWFIDrv->u8P2PConnect)
652 u8WLANChannel = INVALID_CHANNEL;
655 /*Incase "P2P CLIENT Connected" send deauthentication reason by 3 to force the WPA_SUPPLICANT to directly change
656 * virtual interface to station*/
657 if ((pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) {
658 pstrDisconnectNotifInfo->u16reason = 3;
661 /*Incase "P2P CLIENT during connection(not connected)" send deauthentication reason by 1 to force the WPA_SUPPLICANT
662 * to scan again and retry the connection*/
663 else if ((!pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) {
664 pstrDisconnectNotifInfo->u16reason = 1;
666 cfg80211_disconnected(dev, pstrDisconnectNotifInfo->u16reason, pstrDisconnectNotifInfo->ie,
667 pstrDisconnectNotifInfo->ie_len, false,
676 * @brief WILC_WFI_CfgSetChannel
677 * @details Set channel for a given wireless interface. Some devices
678 * may support multi-channel operation (by channel hopping) so cfg80211
679 * doesn't verify much. Note, however, that the passed netdev may be
680 * %NULL as well if the user requested changing the channel for the
681 * device itself, or for a monitor interface.
683 * @return int : Return 0 on Success
688 static int WILC_WFI_CfgSetChannel(struct wiphy *wiphy,
689 struct cfg80211_chan_def *chandef)
693 struct WILC_WFI_priv *priv;
694 s32 s32Error = WILC_SUCCESS;
695 priv = wiphy_priv(wiphy);
697 channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq);
698 PRINT_D(CFG80211_DBG, "Setting channel %d with frequency %d\n", channelnum, chandef->chan->center_freq);
700 u8CurrChannel = channelnum;
701 s32Error = host_int_set_mac_chnl_num(priv->hWILCWFIDrv, channelnum);
703 if (s32Error != WILC_SUCCESS)
704 PRINT_ER("Error in setting channel %d\n", channelnum);
710 * @brief WILC_WFI_CfgScan
711 * @details Request to do a scan. If returning zero, the scan request is given
712 * the driver, and will be valid until passed to cfg80211_scan_done().
713 * For scan results, call cfg80211_inform_bss(); you can call this outside
714 * the scan/scan_done bracket too.
716 * @return int : Return 0 on Success
723 * kernel version 3.8.8 supported
724 * tony, sswd, WILC-KR, 2013-10-29
726 static int WILC_WFI_CfgScan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
728 struct WILC_WFI_priv *priv;
730 s32 s32Error = WILC_SUCCESS;
731 u8 au8ScanChanList[MAX_NUM_SCANNED_NETWORKS];
732 tstrHiddenNetwork strHiddenNetwork;
734 priv = wiphy_priv(wiphy);
736 priv->pstrScanReq = request;
738 priv->u32RcvdChCount = 0;
740 host_int_set_wfi_drv_handler(priv->hWILCWFIDrv);
743 reset_shadow_found(priv);
745 priv->bCfgScanning = true;
746 if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
748 for (i = 0; i < request->n_channels; i++) {
749 au8ScanChanList[i] = (u8)ieee80211_frequency_to_channel(request->channels[i]->center_freq);
750 PRINT_INFO(CFG80211_DBG, "ScanChannel List[%d] = %d,", i, au8ScanChanList[i]);
753 PRINT_D(CFG80211_DBG, "Requested num of scan channel %d\n", request->n_channels);
754 PRINT_D(CFG80211_DBG, "Scan Request IE len = %zu\n", request->ie_len);
756 PRINT_D(CFG80211_DBG, "Number of SSIDs %d\n", request->n_ssids);
758 if (request->n_ssids >= 1) {
761 strHiddenNetwork.pstrHiddenNetworkInfo = WILC_MALLOC(request->n_ssids * sizeof(tstrHiddenNetwork));
762 strHiddenNetwork.u8ssidnum = request->n_ssids;
766 for (i = 0; i < request->n_ssids; i++) {
768 if (request->ssids[i].ssid != NULL && request->ssids[i].ssid_len != 0) {
769 strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid = WILC_MALLOC(request->ssids[i].ssid_len);
770 memcpy(strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, request->ssids[i].ssid, request->ssids[i].ssid_len);
771 strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen = request->ssids[i].ssid_len;
773 PRINT_D(CFG80211_DBG, "Received one NULL SSID\n");
774 strHiddenNetwork.u8ssidnum -= 1;
777 PRINT_D(CFG80211_DBG, "Trigger Scan Request\n");
778 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
779 au8ScanChanList, request->n_channels,
780 (const u8 *)request->ie, request->ie_len,
781 CfgScanResult, (void *)priv, &strHiddenNetwork);
783 PRINT_D(CFG80211_DBG, "Trigger Scan Request\n");
784 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
785 au8ScanChanList, request->n_channels,
786 (const u8 *)request->ie, request->ie_len,
787 CfgScanResult, (void *)priv, NULL);
791 PRINT_ER("Requested num of scanned channels is greater than the max, supported"
795 if (s32Error != WILC_SUCCESS) {
797 PRINT_WRN(CFG80211_DBG, "Device is busy: Error(%d)\n", s32Error);
804 * @brief WILC_WFI_CfgConnect
805 * @details Connect to the ESS with the specified parameters. When connected,
806 * call cfg80211_connect_result() with status code %WLAN_STATUS_SUCCESS.
807 * If the connection fails for some reason, call cfg80211_connect_result()
808 * with the status from the AP.
810 * @return int : Return 0 on Success
815 static int WILC_WFI_CfgConnect(struct wiphy *wiphy, struct net_device *dev,
816 struct cfg80211_connect_params *sme)
818 s32 s32Error = WILC_SUCCESS;
820 u8 u8security = NO_ENCRYPT;
821 AUTHTYPE_T tenuAuth_type = ANY;
822 char *pcgroup_encrypt_val = NULL;
823 char *pccipher_group = NULL;
824 char *pcwpa_version = NULL;
826 struct WILC_WFI_priv *priv;
827 tstrWILC_WFIDrv *pstrWFIDrv;
828 tstrNetworkInfo *pstrNetworkInfo = NULL;
832 priv = wiphy_priv(wiphy);
833 pstrWFIDrv = (tstrWILC_WFIDrv *)(priv->hWILCWFIDrv);
835 host_int_set_wfi_drv_handler(priv->hWILCWFIDrv);
837 PRINT_D(CFG80211_DBG, "Connecting to SSID [%s] on netdev [%p] host if [%p]\n", sme->ssid, dev, priv->hWILCWFIDrv);
839 if (!(strncmp(sme->ssid, "DIRECT-", 7))) {
840 PRINT_D(CFG80211_DBG, "Connected to Direct network,OBSS disabled\n");
841 pstrWFIDrv->u8P2PConnect = 1;
843 pstrWFIDrv->u8P2PConnect = 0;
845 PRINT_INFO(CFG80211_DBG, "Required SSID = %s\n , AuthType = %d\n", sme->ssid, sme->auth_type);
847 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
848 if ((sme->ssid_len == astrLastScannedNtwrksShadow[i].u8SsidLen) &&
849 memcmp(astrLastScannedNtwrksShadow[i].au8ssid,
851 sme->ssid_len) == 0) {
852 PRINT_INFO(CFG80211_DBG, "Network with required SSID is found %s\n", sme->ssid);
853 if (sme->bssid == NULL) {
854 /* BSSID is not passed from the user, so decision of matching
855 * is done by SSID only */
856 PRINT_INFO(CFG80211_DBG, "BSSID is not passed from the user\n");
859 /* BSSID is also passed from the user, so decision of matching
860 * should consider also this passed BSSID */
861 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
864 PRINT_INFO(CFG80211_DBG, "BSSID is passed from the user and matched\n");
871 if (i < u32LastScannedNtwrksCountShadow) {
872 PRINT_D(CFG80211_DBG, "Required bss is in scan results\n");
874 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
876 PRINT_INFO(CFG80211_DBG, "network BSSID to be associated: %x%x%x%x%x%x\n",
877 pstrNetworkInfo->au8bssid[0], pstrNetworkInfo->au8bssid[1],
878 pstrNetworkInfo->au8bssid[2], pstrNetworkInfo->au8bssid[3],
879 pstrNetworkInfo->au8bssid[4], pstrNetworkInfo->au8bssid[5]);
882 if (u32LastScannedNtwrksCountShadow == 0)
883 PRINT_D(CFG80211_DBG, "No Scan results yet\n");
885 PRINT_D(CFG80211_DBG, "Required bss not in scan results: Error(%d)\n", s32Error);
890 priv->WILC_WFI_wep_default = 0;
891 memset(priv->WILC_WFI_wep_key, 0, sizeof(priv->WILC_WFI_wep_key));
892 memset(priv->WILC_WFI_wep_key_len, 0, sizeof(priv->WILC_WFI_wep_key_len));
894 PRINT_INFO(CFG80211_DBG, "sme->crypto.wpa_versions=%x\n", sme->crypto.wpa_versions);
895 PRINT_INFO(CFG80211_DBG, "sme->crypto.cipher_group=%x\n", sme->crypto.cipher_group);
897 PRINT_INFO(CFG80211_DBG, "sme->crypto.n_ciphers_pairwise=%d\n", sme->crypto.n_ciphers_pairwise);
900 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++)
901 PRINT_D(CORECONFIG_DBG, "sme->crypto.ciphers_pairwise[%d]=%x\n", i, sme->crypto.ciphers_pairwise[i]);
904 if (sme->crypto.cipher_group != NO_ENCRYPT) {
905 /* To determine the u8security value, first we check the group cipher suite then {in case of WPA or WPA2}
906 * we will add to it the pairwise cipher suite(s) */
907 pcwpa_version = "Default";
908 PRINT_D(CORECONFIG_DBG, ">> sme->crypto.wpa_versions: %x\n", sme->crypto.wpa_versions);
909 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) {
910 u8security = ENCRYPT_ENABLED | WEP;
911 pcgroup_encrypt_val = "WEP40";
912 pccipher_group = "WLAN_CIPHER_SUITE_WEP40";
913 PRINT_INFO(CFG80211_DBG, "WEP Default Key Idx = %d\n", sme->key_idx);
916 for (i = 0; i < sme->key_len; i++)
917 PRINT_D(CORECONFIG_DBG, "WEP Key Value[%d] = %d\n", i, sme->key[i]);
919 priv->WILC_WFI_wep_default = sme->key_idx;
920 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
921 memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
924 g_key_wep_params.key_len = sme->key_len;
925 g_key_wep_params.key = WILC_MALLOC(sme->key_len);
926 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
927 g_key_wep_params.key_idx = sme->key_idx;
928 g_wep_keys_saved = true;
930 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
931 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
932 } else if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104) {
933 u8security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
934 pcgroup_encrypt_val = "WEP104";
935 pccipher_group = "WLAN_CIPHER_SUITE_WEP104";
937 priv->WILC_WFI_wep_default = sme->key_idx;
938 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
939 memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
942 g_key_wep_params.key_len = sme->key_len;
943 g_key_wep_params.key = WILC_MALLOC(sme->key_len);
944 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
945 g_key_wep_params.key_idx = sme->key_idx;
946 g_wep_keys_saved = true;
948 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
949 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
950 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) {
951 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
952 u8security = ENCRYPT_ENABLED | WPA2 | TKIP;
953 pcgroup_encrypt_val = "WPA2_TKIP";
954 pccipher_group = "TKIP";
955 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
956 /* tenuSecurity_t = WPA2_AES; */
957 u8security = ENCRYPT_ENABLED | WPA2 | AES;
958 pcgroup_encrypt_val = "WPA2_AES";
959 pccipher_group = "AES";
961 pcwpa_version = "WPA_VERSION_2";
962 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) {
963 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
964 u8security = ENCRYPT_ENABLED | WPA | TKIP;
965 pcgroup_encrypt_val = "WPA_TKIP";
966 pccipher_group = "TKIP";
967 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
968 /* tenuSecurity_t = WPA_AES; */
969 u8security = ENCRYPT_ENABLED | WPA | AES;
970 pcgroup_encrypt_val = "WPA_AES";
971 pccipher_group = "AES";
974 pcwpa_version = "WPA_VERSION_1";
977 s32Error = -ENOTSUPP;
978 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
985 /* After we set the u8security value from checking the group cipher suite, {in case of WPA or WPA2} we will
986 * add to it the pairwise cipher suite(s) */
987 if ((sme->crypto.wpa_versions & NL80211_WPA_VERSION_1)
988 || (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)) {
989 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) {
990 if (sme->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP) {
991 u8security = u8security | TKIP;
992 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
993 u8security = u8security | AES;
998 PRINT_D(CFG80211_DBG, "Adding key with cipher group = %x\n", sme->crypto.cipher_group);
1000 PRINT_D(CFG80211_DBG, "Authentication Type = %d\n", sme->auth_type);
1001 switch (sme->auth_type) {
1002 case NL80211_AUTHTYPE_OPEN_SYSTEM:
1003 PRINT_D(CFG80211_DBG, "In OPEN SYSTEM\n");
1004 tenuAuth_type = OPEN_SYSTEM;
1007 case NL80211_AUTHTYPE_SHARED_KEY:
1008 tenuAuth_type = SHARED_KEY;
1009 PRINT_D(CFG80211_DBG, "In SHARED KEY\n");
1013 PRINT_D(CFG80211_DBG, "Automatic Authentation type = %d\n", sme->auth_type);
1017 /* ai: key_mgmt: enterprise case */
1018 if (sme->crypto.n_akm_suites) {
1019 switch (sme->crypto.akm_suites[0]) {
1020 case WLAN_AKM_SUITE_8021X:
1021 tenuAuth_type = IEEE8021;
1030 PRINT_INFO(CFG80211_DBG, "Required Channel = %d\n", pstrNetworkInfo->u8channel);
1032 PRINT_INFO(CFG80211_DBG, "Group encryption value = %s\n Cipher Group = %s\n WPA version = %s\n",
1033 pcgroup_encrypt_val, pccipher_group, pcwpa_version);
1036 u8CurrChannel = pstrNetworkInfo->u8channel;
1038 if (!pstrWFIDrv->u8P2PConnect) {
1039 u8WLANChannel = pstrNetworkInfo->u8channel;
1042 linux_wlan_set_bssid(dev, pstrNetworkInfo->au8bssid);
1044 s32Error = host_int_set_join_req(priv->hWILCWFIDrv, pstrNetworkInfo->au8bssid, sme->ssid,
1045 sme->ssid_len, sme->ie, sme->ie_len,
1046 CfgConnectResult, (void *)priv, u8security,
1047 tenuAuth_type, pstrNetworkInfo->u8channel,
1048 pstrNetworkInfo->pJoinParams);
1049 if (s32Error != WILC_SUCCESS) {
1050 PRINT_ER("host_int_set_join_req(): Error(%d)\n", s32Error);
1062 * @brief WILC_WFI_disconnect
1063 * @details Disconnect from the BSS/ESS.
1065 * @return int : Return 0 on Success
1070 static int WILC_WFI_disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code)
1072 s32 s32Error = WILC_SUCCESS;
1073 struct WILC_WFI_priv *priv;
1075 tstrWILC_WFIDrv *pstrWFIDrv;
1077 uint8_t NullBssid[ETH_ALEN] = {0};
1079 priv = wiphy_priv(wiphy);
1082 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
1084 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
1085 if (!pstrWFIDrv->u8P2PConnect)
1086 u8WLANChannel = INVALID_CHANNEL;
1088 linux_wlan_set_bssid(priv->dev, NullBssid);
1090 PRINT_D(CFG80211_DBG, "Disconnecting with reason code(%d)\n", reason_code);
1092 u8P2Plocalrandom = 0x01;
1093 u8P2Precvrandom = 0x00;
1096 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
1099 s32Error = host_int_disconnect(priv->hWILCWFIDrv, reason_code);
1100 if (s32Error != WILC_SUCCESS) {
1101 PRINT_ER("Error in disconnecting: Error(%d)\n", s32Error);
1109 * @brief WILC_WFI_add_key
1110 * @details Add a key with the given parameters. @mac_addr will be %NULL
1111 * when adding a group key.
1112 * @param[in] key : key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key, 8-byte Rx Mic Key
1113 * @return int : Return 0 on Success
1118 static int WILC_WFI_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1120 const u8 *mac_addr, struct key_params *params)
1123 s32 s32Error = WILC_SUCCESS, KeyLen = params->key_len;
1125 struct WILC_WFI_priv *priv;
1126 const u8 *pu8RxMic = NULL;
1127 const u8 *pu8TxMic = NULL;
1128 u8 u8mode = NO_ENCRYPT;
1129 #ifdef WILC_AP_EXTERNAL_MLME
1130 u8 u8gmode = NO_ENCRYPT;
1131 u8 u8pmode = NO_ENCRYPT;
1132 AUTHTYPE_T tenuAuth_type = ANY;
1135 priv = wiphy_priv(wiphy);
1137 PRINT_D(CFG80211_DBG, "Adding key with cipher suite = %x\n", params->cipher);
1140 PRINT_D(CFG80211_DBG, "%p %p %d\n", wiphy, netdev, key_index);
1142 PRINT_D(CFG80211_DBG, "key %x %x %x\n", params->key[0],
1147 switch (params->cipher) {
1148 case WLAN_CIPHER_SUITE_WEP40:
1149 case WLAN_CIPHER_SUITE_WEP104:
1150 #ifdef WILC_AP_EXTERNAL_MLME
1151 if (priv->wdev->iftype == NL80211_IFTYPE_AP) {
1153 priv->WILC_WFI_wep_default = key_index;
1154 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
1155 memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
1157 PRINT_D(CFG80211_DBG, "Adding AP WEP Default key Idx = %d\n", key_index);
1158 PRINT_D(CFG80211_DBG, "Adding AP WEP Key len= %d\n", params->key_len);
1160 for (i = 0; i < params->key_len; i++)
1161 PRINT_D(CFG80211_DBG, "WEP AP key val[%d] = %x\n", i, params->key[i]);
1163 tenuAuth_type = OPEN_SYSTEM;
1165 if (params->cipher == WLAN_CIPHER_SUITE_WEP40)
1166 u8mode = ENCRYPT_ENABLED | WEP;
1168 u8mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
1170 host_int_add_wep_key_bss_ap(priv->hWILCWFIDrv, params->key, params->key_len, key_index, u8mode, tenuAuth_type);
1174 if (memcmp(params->key, priv->WILC_WFI_wep_key[key_index], params->key_len)) {
1175 priv->WILC_WFI_wep_default = key_index;
1176 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
1177 memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
1179 PRINT_D(CFG80211_DBG, "Adding WEP Default key Idx = %d\n", key_index);
1180 PRINT_D(CFG80211_DBG, "Adding WEP Key length = %d\n", params->key_len);
1182 for (i = 0; i < params->key_len; i++)
1183 PRINT_INFO(CFG80211_DBG, "WEP key value[%d] = %d\n", i, params->key[i]);
1185 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, params->key, params->key_len, key_index);
1190 case WLAN_CIPHER_SUITE_TKIP:
1191 case WLAN_CIPHER_SUITE_CCMP:
1192 #ifdef WILC_AP_EXTERNAL_MLME
1193 if (priv->wdev->iftype == NL80211_IFTYPE_AP || priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) {
1195 if (priv->wilc_gtk[key_index] == NULL) {
1196 priv->wilc_gtk[key_index] = WILC_MALLOC(sizeof(struct wilc_wfi_key));
1197 priv->wilc_gtk[key_index]->key = NULL;
1198 priv->wilc_gtk[key_index]->seq = NULL;
1201 if (priv->wilc_ptk[key_index] == NULL) {
1202 priv->wilc_ptk[key_index] = WILC_MALLOC(sizeof(struct wilc_wfi_key));
1203 priv->wilc_ptk[key_index]->key = NULL;
1204 priv->wilc_ptk[key_index]->seq = NULL;
1210 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1211 u8gmode = ENCRYPT_ENABLED | WPA | TKIP;
1213 u8gmode = ENCRYPT_ENABLED | WPA2 | AES;
1215 priv->wilc_groupkey = u8gmode;
1217 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1219 pu8TxMic = params->key + 24;
1220 pu8RxMic = params->key + 16;
1221 KeyLen = params->key_len - 16;
1223 /* if there has been previous allocation for the same index through its key, free that memory and allocate again*/
1224 if (priv->wilc_gtk[key_index]->key)
1225 kfree(priv->wilc_gtk[key_index]->key);
1227 priv->wilc_gtk[key_index]->key = WILC_MALLOC(params->key_len);
1228 memcpy(priv->wilc_gtk[key_index]->key, params->key, params->key_len);
1230 /* if there has been previous allocation for the same index through its seq, free that memory and allocate again*/
1231 if (priv->wilc_gtk[key_index]->seq)
1232 kfree(priv->wilc_gtk[key_index]->seq);
1234 if ((params->seq_len) > 0) {
1235 priv->wilc_gtk[key_index]->seq = WILC_MALLOC(params->seq_len);
1236 memcpy(priv->wilc_gtk[key_index]->seq, params->seq, params->seq_len);
1239 priv->wilc_gtk[key_index]->cipher = params->cipher;
1240 priv->wilc_gtk[key_index]->key_len = params->key_len;
1241 priv->wilc_gtk[key_index]->seq_len = params->seq_len;
1244 for (i = 0; i < params->key_len; i++)
1245 PRINT_INFO(CFG80211_DBG, "Adding group key value[%d] = %x\n", i, params->key[i]);
1246 for (i = 0; i < params->seq_len; i++)
1247 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1251 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1252 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, AP_MODE, u8gmode);
1255 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]);
1257 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1258 u8pmode = ENCRYPT_ENABLED | WPA | TKIP;
1260 u8pmode = priv->wilc_groupkey | AES;
1263 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1265 pu8TxMic = params->key + 24;
1266 pu8RxMic = params->key + 16;
1267 KeyLen = params->key_len - 16;
1270 if (priv->wilc_ptk[key_index]->key)
1271 kfree(priv->wilc_ptk[key_index]->key);
1273 priv->wilc_ptk[key_index]->key = WILC_MALLOC(params->key_len);
1275 if (priv->wilc_ptk[key_index]->seq)
1276 kfree(priv->wilc_ptk[key_index]->seq);
1278 if ((params->seq_len) > 0)
1279 priv->wilc_ptk[key_index]->seq = WILC_MALLOC(params->seq_len);
1282 for (i = 0; i < params->key_len; i++)
1283 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %x\n", i, params->key[i]);
1285 for (i = 0; i < params->seq_len; i++)
1286 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1289 memcpy(priv->wilc_ptk[key_index]->key, params->key, params->key_len);
1291 if ((params->seq_len) > 0)
1292 memcpy(priv->wilc_ptk[key_index]->seq, params->seq, params->seq_len);
1294 priv->wilc_ptk[key_index]->cipher = params->cipher;
1295 priv->wilc_ptk[key_index]->key_len = params->key_len;
1296 priv->wilc_ptk[key_index]->seq_len = params->seq_len;
1298 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1299 pu8RxMic, pu8TxMic, AP_MODE, u8pmode, key_index);
1308 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1309 /* swap the tx mic by rx mic */
1310 pu8RxMic = params->key + 24;
1311 pu8TxMic = params->key + 16;
1312 KeyLen = params->key_len - 16;
1316 /*save keys only on interface 0 (wifi interface)*/
1317 if (!g_gtk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1318 g_add_gtk_key_params.key_idx = key_index;
1319 g_add_gtk_key_params.pairwise = pairwise;
1321 g_add_gtk_key_params.mac_addr = NULL;
1323 g_add_gtk_key_params.mac_addr = WILC_MALLOC(ETH_ALEN);
1324 memcpy(g_add_gtk_key_params.mac_addr, mac_addr, ETH_ALEN);
1326 g_key_gtk_params.key_len = params->key_len;
1327 g_key_gtk_params.seq_len = params->seq_len;
1328 g_key_gtk_params.key = WILC_MALLOC(params->key_len);
1329 memcpy(g_key_gtk_params.key, params->key, params->key_len);
1330 if (params->seq_len > 0) {
1331 g_key_gtk_params.seq = WILC_MALLOC(params->seq_len);
1332 memcpy(g_key_gtk_params.seq, params->seq, params->seq_len);
1334 g_key_gtk_params.cipher = params->cipher;
1336 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_gtk_params.key[0],
1337 g_key_gtk_params.key[1],
1338 g_key_gtk_params.key[2]);
1339 g_gtk_keys_saved = true;
1342 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1343 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, STATION_MODE, u8mode);
1345 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1346 /* swap the tx mic by rx mic */
1347 pu8RxMic = params->key + 24;
1348 pu8TxMic = params->key + 16;
1349 KeyLen = params->key_len - 16;
1353 /*save keys only on interface 0 (wifi interface)*/
1354 if (!g_ptk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1355 g_add_ptk_key_params.key_idx = key_index;
1356 g_add_ptk_key_params.pairwise = pairwise;
1358 g_add_ptk_key_params.mac_addr = NULL;
1360 g_add_ptk_key_params.mac_addr = WILC_MALLOC(ETH_ALEN);
1361 memcpy(g_add_ptk_key_params.mac_addr, mac_addr, ETH_ALEN);
1363 g_key_ptk_params.key_len = params->key_len;
1364 g_key_ptk_params.seq_len = params->seq_len;
1365 g_key_ptk_params.key = WILC_MALLOC(params->key_len);
1366 memcpy(g_key_ptk_params.key, params->key, params->key_len);
1367 if (params->seq_len > 0) {
1368 g_key_ptk_params.seq = WILC_MALLOC(params->seq_len);
1369 memcpy(g_key_ptk_params.seq, params->seq, params->seq_len);
1371 g_key_ptk_params.cipher = params->cipher;
1373 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_ptk_params.key[0],
1374 g_key_ptk_params.key[1],
1375 g_key_ptk_params.key[2]);
1376 g_ptk_keys_saved = true;
1379 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1380 pu8RxMic, pu8TxMic, STATION_MODE, u8mode, key_index);
1381 PRINT_D(CFG80211_DBG, "Adding pairwise key\n");
1383 for (i = 0; i < params->key_len; i++)
1384 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %d\n", i, params->key[i]);
1391 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
1392 s32Error = -ENOTSUPP;
1400 * @brief WILC_WFI_del_key
1401 * @details Remove a key given the @mac_addr (%NULL for a group key)
1402 * and @key_index, return -ENOENT if the key doesn't exist.
1404 * @return int : Return 0 on Success
1409 static int WILC_WFI_del_key(struct wiphy *wiphy, struct net_device *netdev,
1414 struct WILC_WFI_priv *priv;
1415 s32 s32Error = WILC_SUCCESS;
1417 priv = wiphy_priv(wiphy);
1420 /*delete saved keys, if any*/
1421 if (netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1422 g_ptk_keys_saved = false;
1423 g_gtk_keys_saved = false;
1424 g_wep_keys_saved = false;
1426 /*Delete saved WEP keys params, if any*/
1427 if (g_key_wep_params.key != NULL) {
1428 kfree(g_key_wep_params.key);
1429 g_key_wep_params.key = NULL;
1432 /*freeing memory allocated by "wilc_gtk" and "wilc_ptk" in "WILC_WIFI_ADD_KEY"*/
1434 #ifdef WILC_AP_EXTERNAL_MLME
1435 if ((priv->wilc_gtk[key_index]) != NULL) {
1437 if (priv->wilc_gtk[key_index]->key != NULL) {
1439 kfree(priv->wilc_gtk[key_index]->key);
1440 priv->wilc_gtk[key_index]->key = NULL;
1442 if (priv->wilc_gtk[key_index]->seq) {
1444 kfree(priv->wilc_gtk[key_index]->seq);
1445 priv->wilc_gtk[key_index]->seq = NULL;
1448 kfree(priv->wilc_gtk[key_index]);
1449 priv->wilc_gtk[key_index] = NULL;
1453 if ((priv->wilc_ptk[key_index]) != NULL) {
1455 if (priv->wilc_ptk[key_index]->key) {
1457 kfree(priv->wilc_ptk[key_index]->key);
1458 priv->wilc_ptk[key_index]->key = NULL;
1460 if (priv->wilc_ptk[key_index]->seq) {
1462 kfree(priv->wilc_ptk[key_index]->seq);
1463 priv->wilc_ptk[key_index]->seq = NULL;
1465 kfree(priv->wilc_ptk[key_index]);
1466 priv->wilc_ptk[key_index] = NULL;
1470 /*Delete saved PTK and GTK keys params, if any*/
1471 if (g_key_ptk_params.key != NULL) {
1472 kfree(g_key_ptk_params.key);
1473 g_key_ptk_params.key = NULL;
1475 if (g_key_ptk_params.seq != NULL) {
1476 kfree(g_key_ptk_params.seq);
1477 g_key_ptk_params.seq = NULL;
1480 if (g_key_gtk_params.key != NULL) {
1481 kfree(g_key_gtk_params.key);
1482 g_key_gtk_params.key = NULL;
1484 if (g_key_gtk_params.seq != NULL) {
1485 kfree(g_key_gtk_params.seq);
1486 g_key_gtk_params.seq = NULL;
1489 /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/
1490 Set_machw_change_vir_if(false);
1493 if (key_index >= 0 && key_index <= 3) {
1494 memset(priv->WILC_WFI_wep_key[key_index], 0, priv->WILC_WFI_wep_key_len[key_index]);
1495 priv->WILC_WFI_wep_key_len[key_index] = 0;
1497 PRINT_D(CFG80211_DBG, "Removing WEP key with index = %d\n", key_index);
1498 host_int_remove_wep_key(priv->hWILCWFIDrv, key_index);
1500 PRINT_D(CFG80211_DBG, "Removing all installed keys\n");
1501 host_int_remove_key(priv->hWILCWFIDrv, mac_addr);
1508 * @brief WILC_WFI_get_key
1509 * @details Get information about the key with the given parameters.
1510 * @mac_addr will be %NULL when requesting information for a group
1511 * key. All pointers given to the @callback function need not be valid
1512 * after it returns. This function should return an error if it is
1513 * not possible to retrieve the key, -ENOENT if it doesn't exist.
1515 * @return int : Return 0 on Success
1520 static int WILC_WFI_get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1522 const u8 *mac_addr, void *cookie, void (*callback)(void *cookie, struct key_params *))
1525 s32 s32Error = WILC_SUCCESS;
1527 struct WILC_WFI_priv *priv;
1528 struct key_params key_params;
1530 priv = wiphy_priv(wiphy);
1535 PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index);
1537 key_params.key = priv->wilc_gtk[key_index]->key;
1538 key_params.cipher = priv->wilc_gtk[key_index]->cipher;
1539 key_params.key_len = priv->wilc_gtk[key_index]->key_len;
1540 key_params.seq = priv->wilc_gtk[key_index]->seq;
1541 key_params.seq_len = priv->wilc_gtk[key_index]->seq_len;
1543 for (i = 0; i < key_params.key_len; i++)
1544 PRINT_INFO(CFG80211_DBG, "Retrieved key value %x\n", key_params.key[i]);
1547 PRINT_D(CFG80211_DBG, "Getting pairwise key\n");
1549 key_params.key = priv->wilc_ptk[key_index]->key;
1550 key_params.cipher = priv->wilc_ptk[key_index]->cipher;
1551 key_params.key_len = priv->wilc_ptk[key_index]->key_len;
1552 key_params.seq = priv->wilc_ptk[key_index]->seq;
1553 key_params.seq_len = priv->wilc_ptk[key_index]->seq_len;
1556 callback(cookie, &key_params);
1558 return s32Error; /* priv->wilc_gtk->key_len ?0 : -ENOENT; */
1562 * @brief WILC_WFI_set_default_key
1563 * @details Set the default management frame key on an interface
1565 * @return int : Return 0 on Success.
1570 static int WILC_WFI_set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1571 bool unicast, bool multicast)
1573 s32 s32Error = WILC_SUCCESS;
1574 struct WILC_WFI_priv *priv;
1577 priv = wiphy_priv(wiphy);
1579 PRINT_D(CFG80211_DBG, "Setting default key with idx = %d\n", key_index);
1581 if (key_index != priv->WILC_WFI_wep_default) {
1583 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, key_index);
1590 * @brief WILC_WFI_dump_survey
1591 * @details Get site survey information
1593 * @return int : Return 0 on Success.
1598 static int WILC_WFI_dump_survey(struct wiphy *wiphy, struct net_device *netdev,
1599 int idx, struct survey_info *info)
1601 s32 s32Error = WILC_SUCCESS;
1606 PRINT_ER("Error Idx value doesn't equal zero: Error(%d)\n", s32Error);
1615 * @brief WILC_WFI_get_station
1616 * @details Get station information for the station identified by @mac
1618 * @return int : Return 0 on Success.
1624 static int WILC_WFI_get_station(struct wiphy *wiphy, struct net_device *dev,
1625 const u8 *mac, struct station_info *sinfo)
1627 s32 s32Error = WILC_SUCCESS;
1628 struct WILC_WFI_priv *priv;
1629 perInterface_wlan_t *nic;
1630 #ifdef WILC_AP_EXTERNAL_MLME
1632 u32 associatedsta = 0;
1633 u32 inactive_time = 0;
1635 priv = wiphy_priv(wiphy);
1636 nic = netdev_priv(dev);
1638 #ifdef WILC_AP_EXTERNAL_MLME
1639 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
1640 PRINT_D(HOSTAPD_DBG, "Getting station parameters\n");
1642 PRINT_INFO(HOSTAPD_DBG, ": %x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4]);
1644 for (i = 0; i < NUM_STA_ASSOCIATED; i++) {
1646 if (!(memcmp(mac, priv->assoc_stainfo.au8Sta_AssociatedBss[i], ETH_ALEN))) {
1653 if (associatedsta == -1) {
1655 PRINT_ER("Station required is not associated : Error(%d)\n", s32Error);
1660 sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME);
1662 host_int_get_inactive_time(priv->hWILCWFIDrv, mac, &(inactive_time));
1663 sinfo->inactive_time = 1000 * inactive_time;
1664 PRINT_D(CFG80211_DBG, "Inactive time %d\n", sinfo->inactive_time);
1669 if (nic->iftype == STATION_MODE) {
1670 tstrStatistics strStatistics;
1671 host_int_get_statistics(priv->hWILCWFIDrv, &strStatistics);
1675 * tx_failed introduced more than
1676 * kernel version 3.0.0
1678 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) |
1679 BIT(NL80211_STA_INFO_RX_PACKETS) |
1680 BIT(NL80211_STA_INFO_TX_PACKETS) |
1681 BIT(NL80211_STA_INFO_TX_FAILED) |
1682 BIT(NL80211_STA_INFO_TX_BITRATE);
1684 sinfo->signal = strStatistics.s8RSSI;
1685 sinfo->rx_packets = strStatistics.u32RxCount;
1686 sinfo->tx_packets = strStatistics.u32TxCount + strStatistics.u32TxFailureCount;
1687 sinfo->tx_failed = strStatistics.u32TxFailureCount;
1688 sinfo->txrate.legacy = strStatistics.u8LinkSpeed * 10;
1690 #ifdef TCP_ENHANCEMENTS
1691 if ((strStatistics.u8LinkSpeed > TCP_ACK_FILTER_LINK_SPEED_THRESH) && (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED))
1692 Enable_TCP_ACK_Filter(true);
1693 else if (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED)
1694 Enable_TCP_ACK_Filter(false);
1697 PRINT_D(CORECONFIG_DBG, "*** stats[%d][%d][%d][%d][%d]\n", sinfo->signal, sinfo->rx_packets, sinfo->tx_packets,
1698 sinfo->tx_failed, sinfo->txrate.legacy);
1705 * @brief WILC_WFI_change_bss
1706 * @details Modify parameters for a given BSS.
1708 * -use_cts_prot: Whether to use CTS protection
1709 * (0 = no, 1 = yes, -1 = do not change)
1710 * -use_short_preamble: Whether the use of short preambles is allowed
1711 * (0 = no, 1 = yes, -1 = do not change)
1712 * -use_short_slot_time: Whether the use of short slot time is allowed
1713 * (0 = no, 1 = yes, -1 = do not change)
1714 * -basic_rates: basic rates in IEEE 802.11 format
1715 * (or NULL for no change)
1716 * -basic_rates_len: number of basic rates
1717 * -ap_isolate: do not forward packets between connected stations
1718 * -ht_opmode: HT Operation mode
1719 * (u16 = opmode, -1 = do not change)
1720 * @return int : Return 0 on Success.
1725 static int WILC_WFI_change_bss(struct wiphy *wiphy, struct net_device *dev,
1726 struct bss_parameters *params)
1728 PRINT_D(CFG80211_DBG, "Changing Bss parametrs\n");
1733 * @brief WILC_WFI_auth
1734 * @details Request to authenticate with the specified peer
1736 * @return int : Return 0 on Success.
1741 static int WILC_WFI_auth(struct wiphy *wiphy, struct net_device *dev,
1742 struct cfg80211_auth_request *req)
1744 PRINT_D(CFG80211_DBG, "In Authentication Function\n");
1749 * @brief WILC_WFI_assoc
1750 * @details Request to (re)associate with the specified peer
1752 * @return int : Return 0 on Success.
1757 static int WILC_WFI_assoc(struct wiphy *wiphy, struct net_device *dev,
1758 struct cfg80211_assoc_request *req)
1760 PRINT_D(CFG80211_DBG, "In Association Function\n");
1765 * @brief WILC_WFI_deauth
1766 * @details Request to deauthenticate from the specified peer
1768 * @return int : Return 0 on Success.
1773 static int WILC_WFI_deauth(struct wiphy *wiphy, struct net_device *dev,
1774 struct cfg80211_deauth_request *req, void *cookie)
1776 PRINT_D(CFG80211_DBG, "In De-authentication Function\n");
1781 * @brief WILC_WFI_disassoc
1782 * @details Request to disassociate from the specified peer
1784 * @return int : Return 0 on Success
1789 static int WILC_WFI_disassoc(struct wiphy *wiphy, struct net_device *dev,
1790 struct cfg80211_disassoc_request *req, void *cookie)
1792 PRINT_D(CFG80211_DBG, "In Disassociation Function\n");
1797 * @brief WILC_WFI_set_wiphy_params
1798 * @details Notify that wiphy parameters have changed;
1799 * @param[in] Changed bitfield (see &enum wiphy_params_flags) describes which values
1801 * @return int : Return 0 on Success
1806 static int WILC_WFI_set_wiphy_params(struct wiphy *wiphy, u32 changed)
1808 s32 s32Error = WILC_SUCCESS;
1809 tstrCfgParamVal pstrCfgParamVal;
1810 struct WILC_WFI_priv *priv;
1812 priv = wiphy_priv(wiphy);
1814 pstrCfgParamVal.u32SetCfgFlag = 0;
1815 PRINT_D(CFG80211_DBG, "Setting Wiphy params\n");
1817 if (changed & WIPHY_PARAM_RETRY_SHORT) {
1818 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_SHORT %d\n",
1819 priv->dev->ieee80211_ptr->wiphy->retry_short);
1820 pstrCfgParamVal.u32SetCfgFlag |= RETRY_SHORT;
1821 pstrCfgParamVal.short_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_short;
1823 if (changed & WIPHY_PARAM_RETRY_LONG) {
1825 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_LONG %d\n", priv->dev->ieee80211_ptr->wiphy->retry_long);
1826 pstrCfgParamVal.u32SetCfgFlag |= RETRY_LONG;
1827 pstrCfgParamVal.long_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_long;
1830 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
1831 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->frag_threshold);
1832 pstrCfgParamVal.u32SetCfgFlag |= FRAG_THRESHOLD;
1833 pstrCfgParamVal.frag_threshold = priv->dev->ieee80211_ptr->wiphy->frag_threshold;
1837 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
1838 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->rts_threshold);
1840 pstrCfgParamVal.u32SetCfgFlag |= RTS_THRESHOLD;
1841 pstrCfgParamVal.rts_threshold = priv->dev->ieee80211_ptr->wiphy->rts_threshold;
1845 PRINT_D(CFG80211_DBG, "Setting CFG params in the host interface\n");
1846 s32Error = hif_set_cfg(priv->hWILCWFIDrv, &pstrCfgParamVal);
1848 PRINT_ER("Error in setting WIPHY PARAMS\n");
1855 * @brief WILC_WFI_set_bitrate_mask
1856 * @details set the bitrate mask configuration
1858 * @return int : Return 0 on Success
1863 static int WILC_WFI_set_bitrate_mask(struct wiphy *wiphy,
1864 struct net_device *dev, const u8 *peer,
1865 const struct cfg80211_bitrate_mask *mask)
1867 s32 s32Error = WILC_SUCCESS;
1869 PRINT_D(CFG80211_DBG, "Setting Bitrate mask function\n");
1875 * @brief WILC_WFI_set_pmksa
1876 * @details Cache a PMKID for a BSSID. This is mostly useful for fullmac
1877 * devices running firmwares capable of generating the (re) association
1878 * RSN IE. It allows for faster roaming between WPA2 BSSIDs.
1880 * @return int : Return 0 on Success
1885 static int WILC_WFI_set_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1886 struct cfg80211_pmksa *pmksa)
1889 s32 s32Error = WILC_SUCCESS;
1892 struct WILC_WFI_priv *priv = wiphy_priv(wiphy);
1894 PRINT_D(CFG80211_DBG, "Setting PMKSA\n");
1897 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
1898 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
1900 /*If bssid already exists and pmkid value needs to reset*/
1902 PRINT_D(CFG80211_DBG, "PMKID already exists\n");
1906 if (i < WILC_MAX_NUM_PMKIDS) {
1907 PRINT_D(CFG80211_DBG, "Setting PMKID in private structure\n");
1908 memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid,
1910 memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid,
1912 if (!(flag == PMKID_FOUND))
1913 priv->pmkid_list.numpmkid++;
1915 PRINT_ER("Invalid PMKID index\n");
1920 PRINT_D(CFG80211_DBG, "Setting pmkid in the host interface\n");
1921 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
1927 * @brief WILC_WFI_del_pmksa
1928 * @details Delete a cached PMKID.
1930 * @return int : Return 0 on Success
1935 static int WILC_WFI_del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1936 struct cfg80211_pmksa *pmksa)
1941 s32 s32Error = WILC_SUCCESS;
1943 struct WILC_WFI_priv *priv = wiphy_priv(wiphy);
1945 PRINT_D(CFG80211_DBG, "Deleting PMKSA keys\n");
1947 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
1948 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
1950 /*If bssid is found, reset the values*/
1951 PRINT_D(CFG80211_DBG, "Reseting PMKID values\n");
1952 memset(&priv->pmkid_list.pmkidlist[i], 0, sizeof(tstrHostIFpmkid));
1958 if (i < priv->pmkid_list.numpmkid && priv->pmkid_list.numpmkid > 0) {
1959 for (; i < (priv->pmkid_list.numpmkid - 1); i++) {
1960 memcpy(priv->pmkid_list.pmkidlist[i].bssid,
1961 priv->pmkid_list.pmkidlist[i + 1].bssid,
1963 memcpy(priv->pmkid_list.pmkidlist[i].pmkid,
1964 priv->pmkid_list.pmkidlist[i].pmkid,
1967 priv->pmkid_list.numpmkid--;
1976 * @brief WILC_WFI_flush_pmksa
1977 * @details Flush all cached PMKIDs.
1979 * @return int : Return 0 on Success
1984 static int WILC_WFI_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev)
1986 struct WILC_WFI_priv *priv = wiphy_priv(wiphy);
1988 PRINT_D(CFG80211_DBG, "Flushing PMKID key values\n");
1990 /*Get cashed Pmkids and set all with zeros*/
1991 memset(&priv->pmkid_list, 0, sizeof(tstrHostIFpmkidAttr));
1999 * @brief WILC_WFI_CfgParseRxAction
2000 * @details Function parses the received frames and modifies the following attributes:
2003 * -Operating Channel
2005 * @param[in] u8* Buffer, u32 length
2012 void WILC_WFI_CfgParseRxAction(u8 *buf, u32 len)
2018 #ifdef USE_SUPPLICANT_GO_INTENT
2021 bool is_wilc_go = true;
2023 u8 op_channel_attr_index = 0;
2024 u8 channel_list_attr_index = 0;
2026 while (index < len) {
2027 if (buf[index] == GO_INTENT_ATTR_ID) {
2028 #ifdef USE_SUPPLICANT_GO_INTENT
2030 /*Case 1: If we are going to be p2p client, no need to modify channels attributes*/
2031 /*In negotiation frames, go intent attr value determines who will be GO*/
2032 intent = GET_GO_INTENT(buf[index + 3]);
2033 tie_breaker = GET_TIE_BREAKER(buf[index + 3]);
2034 if (intent > SUPPLICANT_GO_INTENT
2035 || (intent == SUPPLICANT_GO_INTENT && tie_breaker == 1)) {
2036 PRINT_D(GENERIC_DBG, "WILC will be client (intent %d tie breaker %d)\n", intent, tie_breaker);
2039 PRINT_D(GENERIC_DBG, "WILC will be GO (intent %d tie breaker %d)\n", intent, tie_breaker);
2043 #else /* USE_SUPPLICANT_GO_INTENT */
2044 #ifdef FORCE_P2P_CLIENT
2045 buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1);
2047 buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1);
2049 #endif /* USE_SUPPLICANT_GO_INTENT */
2052 #ifdef USE_SUPPLICANT_GO_INTENT
2053 /*Case 2: If group bssid attribute is present, no need to modify channels attributes*/
2054 /*In invitation req and rsp, group bssid attr presence determines who will be GO*/
2055 if (buf[index] == GROUP_BSSID_ATTR_ID) {
2056 PRINT_D(GENERIC_DBG, "Group BSSID: %2x:%2x:%2x\n", buf[index + 3]
2061 #endif /* USE_SUPPLICANT_GO_INTENT */
2063 if (buf[index] == CHANLIST_ATTR_ID)
2064 channel_list_attr_index = index;
2065 else if (buf[index] == OPERCHAN_ATTR_ID)
2066 op_channel_attr_index = index;
2067 index += buf[index + 1] + 3; /* ID,Length byte */
2070 #ifdef USE_SUPPLICANT_GO_INTENT
2071 if (u8WLANChannel != INVALID_CHANNEL && is_wilc_go)
2073 if (u8WLANChannel != INVALID_CHANNEL)
2076 /*Modify channel list attribute*/
2077 if (channel_list_attr_index) {
2078 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
2079 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
2080 if (buf[i] == 0x51) {
2081 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
2082 buf[j] = u8WLANChannel;
2088 /*Modify operating channel attribute*/
2089 if (op_channel_attr_index) {
2090 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
2091 buf[op_channel_attr_index + 6] = 0x51;
2092 buf[op_channel_attr_index + 7] = u8WLANChannel;
2098 * @brief WILC_WFI_CfgParseTxAction
2099 * @details Function parses the transmitted action frames and modifies the
2100 * GO Intent attribute
2101 * @param[in] u8* Buffer, u32 length, bool bOperChan, u8 iftype
2107 void WILC_WFI_CfgParseTxAction(u8 *buf, u32 len, bool bOperChan, u8 iftype)
2112 u8 op_channel_attr_index = 0;
2113 u8 channel_list_attr_index = 0;
2114 #ifdef USE_SUPPLICANT_GO_INTENT
2115 bool is_wilc_go = false;
2118 /*Case 1: If we are already p2p client, no need to modify channels attributes*/
2119 /*This to handle the case of inviting a p2p peer to join an existing group which we are a member in*/
2120 if (iftype == CLIENT_MODE)
2124 while (index < len) {
2125 #ifdef USE_SUPPLICANT_GO_INTENT
2126 /*Case 2: If group bssid attribute is present, no need to modify channels attributes*/
2127 /*In invitation req and rsp, group bssid attr presence determines who will be GO*/
2128 /*Note: If we are already p2p client, group bssid attr may also be present (handled in Case 1)*/
2129 if (buf[index] == GROUP_BSSID_ATTR_ID) {
2130 PRINT_D(GENERIC_DBG, "Group BSSID: %2x:%2x:%2x\n", buf[index + 3]
2136 #else /* USE_SUPPLICANT_GO_INTENT */
2137 if (buf[index] == GO_INTENT_ATTR_ID) {
2138 #ifdef FORCE_P2P_CLIENT
2139 buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1);
2141 buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1);
2148 if (buf[index] == CHANLIST_ATTR_ID)
2149 channel_list_attr_index = index;
2150 else if (buf[index] == OPERCHAN_ATTR_ID)
2151 op_channel_attr_index = index;
2152 index += buf[index + 1] + 3; /* ID,Length byte */
2155 #ifdef USE_SUPPLICANT_GO_INTENT
2156 /*No need to check bOperChan since only transmitted invitation frames are parsed*/
2157 if (u8WLANChannel != INVALID_CHANNEL && is_wilc_go)
2159 if (u8WLANChannel != INVALID_CHANNEL && bOperChan)
2162 /*Modify channel list attribute*/
2163 if (channel_list_attr_index) {
2164 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
2165 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
2166 if (buf[i] == 0x51) {
2167 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
2168 buf[j] = u8WLANChannel;
2174 /*Modify operating channel attribute*/
2175 if (op_channel_attr_index) {
2176 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
2177 buf[op_channel_attr_index + 6] = 0x51;
2178 buf[op_channel_attr_index + 7] = u8WLANChannel;
2183 /* @brief WILC_WFI_p2p_rx
2188 * @author Mai Daftedar
2193 void WILC_WFI_p2p_rx (struct net_device *dev, uint8_t *buff, uint32_t size)
2196 struct WILC_WFI_priv *priv;
2197 u32 header, pkt_offset;
2198 tstrWILC_WFIDrv *pstrWFIDrv;
2201 priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
2202 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2204 /* Get WILC header */
2205 memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
2207 /* The packet offset field conain info about what type of managment frame */
2208 /* we are dealing with and ack status */
2209 pkt_offset = GET_PKT_OFFSET(header);
2211 if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
2212 if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP) {
2213 PRINT_D(GENERIC_DBG, "Probe response ACK\n");
2214 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
2217 if (pkt_offset & IS_MGMT_STATUS_SUCCES) {
2218 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],
2219 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
2220 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
2222 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],
2223 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
2224 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, false, GFP_KERNEL);
2230 PRINT_D(GENERIC_DBG, "Rx Frame Type:%x\n", buff[FRAME_TYPE_ID]);
2233 /*Upper layer is informed that the frame is received on this freq*/
2234 s32Freq = ieee80211_channel_to_frequency(u8CurrChannel, IEEE80211_BAND_2GHZ);
2236 if (ieee80211_is_action(buff[FRAME_TYPE_ID])) {
2237 PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]);
2239 if (priv->bCfgScanning == true && time_after_eq(jiffies, (unsigned long)pstrWFIDrv->u64P2p_MgmtTimeout)) {
2240 PRINT_D(GENERIC_DBG, "Receiving action frames from wrong channels\n");
2243 if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
2245 switch (buff[ACTION_SUBTYPE_ID]) {
2246 case GAS_INTIAL_REQ:
2247 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buff[ACTION_SUBTYPE_ID]);
2250 case GAS_INTIAL_RSP:
2251 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buff[ACTION_SUBTYPE_ID]);
2254 case PUBLIC_ACT_VENDORSPEC:
2255 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2256 * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/
2257 if (!memcmp(u8P2P_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) {
2258 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
2260 for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) {
2261 if (!memcmp(u8P2P_vendorspec, &buff[i], 6)) {
2262 u8P2Precvrandom = buff[i + 6];
2264 PRINT_D(GENERIC_DBG, "WILC Vendor specific IE:%02x\n", u8P2Precvrandom);
2270 if (u8P2Plocalrandom > u8P2Precvrandom) {
2271 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
2272 || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
2273 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) {
2274 if (buff[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buff[i + 2], 4))) {
2275 WILC_WFI_CfgParseRxAction(&buff[i + 6], size - (i + 6));
2281 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2285 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP) && (bWilc_ie)) {
2286 PRINT_D(GENERIC_DBG, "Sending P2P to host without extra elemnt\n");
2287 /* extra attribute for sig_dbm: signal strength in mBm, or 0 if unknown */
2288 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
2294 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff[ACTION_SUBTYPE_ID]);
2300 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
2305 * @brief WILC_WFI_mgmt_tx_complete
2306 * @details Returns result of writing mgmt frame to VMM (Tx buffers are freed here)
2308 * transmitting status
2310 * @author Amr Abdelmoghny
2314 static void WILC_WFI_mgmt_tx_complete(void *priv, int status)
2316 struct p2p_mgmt_data *pv_data = (struct p2p_mgmt_data *)priv;
2319 kfree(pv_data->buff);
2324 * @brief WILC_WFI_RemainOnChannelReady
2325 * @details Callback function, called from handle_remain_on_channel on being ready on channel
2328 * @author Amr abdelmoghny
2333 static void WILC_WFI_RemainOnChannelReady(void *pUserVoid)
2335 struct WILC_WFI_priv *priv;
2336 priv = (struct WILC_WFI_priv *)pUserVoid;
2338 PRINT_D(HOSTINF_DBG, "Remain on channel ready\n");
2340 priv->bInP2PlistenState = true;
2342 cfg80211_ready_on_channel(priv->wdev,
2343 priv->strRemainOnChanParams.u64ListenCookie,
2344 priv->strRemainOnChanParams.pstrListenChan,
2345 priv->strRemainOnChanParams.u32ListenDuration,
2350 * @brief WILC_WFI_RemainOnChannelExpired
2351 * @details Callback function, called on expiration of remain-on-channel duration
2354 * @author Amr abdelmoghny
2359 static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, u32 u32SessionID)
2361 struct WILC_WFI_priv *priv;
2362 priv = (struct WILC_WFI_priv *)pUserVoid;
2365 if (u32SessionID == priv->strRemainOnChanParams.u32ListenSessionID) {
2366 PRINT_D(GENERIC_DBG, "Remain on channel expired\n");
2368 priv->bInP2PlistenState = false;
2370 /*Inform wpas of remain-on-channel expiration*/
2371 cfg80211_remain_on_channel_expired(priv->wdev,
2372 priv->strRemainOnChanParams.u64ListenCookie,
2373 priv->strRemainOnChanParams.pstrListenChan,
2376 PRINT_D(GENERIC_DBG, "Received ID 0x%x Expected ID 0x%x (No match)\n", u32SessionID
2377 , priv->strRemainOnChanParams.u32ListenSessionID);
2383 * @brief WILC_WFI_remain_on_channel
2384 * @details Request the driver to remain awake on the specified
2385 * channel for the specified duration to complete an off-channel
2386 * operation (e.g., public action frame exchange). When the driver is
2387 * ready on the requested channel, it must indicate this with an event
2388 * notification by calling cfg80211_ready_on_channel().
2390 * @return int : Return 0 on Success
2395 static int WILC_WFI_remain_on_channel(struct wiphy *wiphy,
2396 struct wireless_dev *wdev,
2397 struct ieee80211_channel *chan,
2398 unsigned int duration, u64 *cookie)
2400 s32 s32Error = WILC_SUCCESS;
2401 struct WILC_WFI_priv *priv;
2402 priv = wiphy_priv(wiphy);
2404 PRINT_D(GENERIC_DBG, "Remaining on channel %d\n", chan->hw_value);
2406 /*BugID_4800: if in AP mode, return.*/
2407 /*This check is to handle the situation when user*/
2408 /*requests "create group" during a running scan*/
2410 if (wdev->iftype == NL80211_IFTYPE_AP) {
2411 PRINT_D(GENERIC_DBG, "Required remain-on-channel while in AP mode");
2415 u8CurrChannel = chan->hw_value;
2417 /*Setting params needed by WILC_WFI_RemainOnChannelExpired()*/
2418 priv->strRemainOnChanParams.pstrListenChan = chan;
2419 priv->strRemainOnChanParams.u64ListenCookie = *cookie;
2420 priv->strRemainOnChanParams.u32ListenDuration = duration;
2421 priv->strRemainOnChanParams.u32ListenSessionID++;
2423 s32Error = host_int_remain_on_channel(priv->hWILCWFIDrv
2424 , priv->strRemainOnChanParams.u32ListenSessionID
2427 , WILC_WFI_RemainOnChannelExpired
2428 , WILC_WFI_RemainOnChannelReady
2435 * @brief WILC_WFI_cancel_remain_on_channel
2436 * @details Cancel an on-going remain-on-channel operation.
2437 * This allows the operation to be terminated prior to timeout based on
2438 * the duration value.
2439 * @param[in] struct wiphy *wiphy,
2440 * @param[in] struct net_device *dev
2441 * @param[in] u64 cookie,
2442 * @return int : Return 0 on Success
2447 static int WILC_WFI_cancel_remain_on_channel(struct wiphy *wiphy,
2448 struct wireless_dev *wdev,
2451 s32 s32Error = WILC_SUCCESS;
2452 struct WILC_WFI_priv *priv;
2453 priv = wiphy_priv(wiphy);
2455 PRINT_D(CFG80211_DBG, "Cancel remain on channel\n");
2457 s32Error = host_int_ListenStateExpired(priv->hWILCWFIDrv, priv->strRemainOnChanParams.u32ListenSessionID);
2461 * @brief WILC_WFI_add_wilcvendorspec
2462 * @details Adding WILC information elemet to allow two WILC devices to
2463 * identify each other and connect
2464 * @param[in] u8 * buf
2470 void WILC_WFI_add_wilcvendorspec(u8 *buff)
2472 memcpy(buff, u8P2P_vendorspec, sizeof(u8P2P_vendorspec));
2475 * @brief WILC_WFI_mgmt_tx_frame
2484 extern linux_wlan_t *g_linux_wlan;
2485 extern bool bEnablePS;
2486 int WILC_WFI_mgmt_tx(struct wiphy *wiphy,
2487 struct wireless_dev *wdev,
2488 struct cfg80211_mgmt_tx_params *params,
2491 struct ieee80211_channel *chan = params->chan;
2492 unsigned int wait = params->wait;
2493 const u8 *buf = params->buf;
2494 size_t len = params->len;
2495 const struct ieee80211_mgmt *mgmt;
2496 struct p2p_mgmt_data *mgmt_tx;
2497 struct WILC_WFI_priv *priv;
2498 s32 s32Error = WILC_SUCCESS;
2499 tstrWILC_WFIDrv *pstrWFIDrv;
2501 perInterface_wlan_t *nic;
2502 u32 buf_len = len + sizeof(u8P2P_vendorspec) + sizeof(u8P2Plocalrandom);
2504 nic = netdev_priv(wdev->netdev);
2505 priv = wiphy_priv(wiphy);
2506 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2508 *cookie = (unsigned long)buf;
2509 priv->u64tx_cookie = *cookie;
2510 mgmt = (const struct ieee80211_mgmt *) buf;
2512 if (ieee80211_is_mgmt(mgmt->frame_control)) {
2514 /*mgmt frame allocation*/
2515 mgmt_tx = WILC_MALLOC(sizeof(struct p2p_mgmt_data));
2516 if (mgmt_tx == NULL) {
2517 PRINT_ER("Failed to allocate memory for mgmt_tx structure\n");
2520 mgmt_tx->buff = WILC_MALLOC(buf_len);
2521 if (mgmt_tx->buff == NULL) {
2522 PRINT_ER("Failed to allocate memory for mgmt_tx buff\n");
2525 memcpy(mgmt_tx->buff, buf, len);
2526 mgmt_tx->size = len;
2529 if (ieee80211_is_probe_resp(mgmt->frame_control)) {
2530 PRINT_D(GENERIC_DBG, "TX: Probe Response\n");
2531 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2532 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2533 /*Save the current channel after we tune to it*/
2534 u8CurrChannel = chan->hw_value;
2535 } else if (ieee80211_is_action(mgmt->frame_control)) {
2536 PRINT_D(GENERIC_DBG, "ACTION FRAME:%x\n", (u16)mgmt->frame_control);
2540 if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
2542 /*Only set the channel, if not a negotiation confirmation frame
2543 * (If Negotiation confirmation frame, force it
2544 * to be transmitted on the same negotiation channel)*/
2546 if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC ||
2547 buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) {
2548 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2549 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2550 /*Save the current channel after we tune to it*/
2551 u8CurrChannel = chan->hw_value;
2553 switch (buf[ACTION_SUBTYPE_ID]) {
2554 case GAS_INTIAL_REQ:
2556 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buf[ACTION_SUBTYPE_ID]);
2560 case GAS_INTIAL_RSP:
2562 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buf[ACTION_SUBTYPE_ID]);
2566 case PUBLIC_ACT_VENDORSPEC:
2568 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2569 * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/
2570 if (!memcmp(u8P2P_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) {
2571 /*For the connection of two WILC's connection generate a rand number to determine who will be a GO*/
2572 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
2573 if (u8P2Plocalrandom == 1 && u8P2Precvrandom < u8P2Plocalrandom) {
2574 get_random_bytes(&u8P2Plocalrandom, 1);
2575 /*Increment the number to prevent if its 0*/
2580 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
2581 || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
2582 if (u8P2Plocalrandom > u8P2Precvrandom) {
2583 PRINT_D(GENERIC_DBG, "LOCAL WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2585 /*Search for the p2p information information element , after the Public action subtype theres a byte for teh dialog token, skip that*/
2586 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) {
2587 if (buf[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buf[i + 2], 4))) {
2588 if (buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)
2589 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), true, nic->iftype);
2592 /*If using supplicant go intent, no need at all*/
2593 /*to parse transmitted negotiation frames*/
2594 #ifndef USE_SUPPLICANT_GO_INTENT
2596 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), false, nic->iftype);
2602 if (buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_REQ && buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_RSP) {
2603 WILC_WFI_add_wilcvendorspec(&mgmt_tx->buff[len]);
2604 mgmt_tx->buff[len + sizeof(u8P2P_vendorspec)] = u8P2Plocalrandom;
2605 mgmt_tx->size = buf_len;
2608 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2612 PRINT_D(GENERIC_DBG, "Not a P2P public action frame\n");
2620 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf[ACTION_SUBTYPE_ID]);
2627 PRINT_D(GENERIC_DBG, "TX: ACTION FRAME Type:%x : Chan:%d\n", buf[ACTION_SUBTYPE_ID], chan->hw_value);
2628 pstrWFIDrv->u64P2p_MgmtTimeout = (jiffies + msecs_to_jiffies(wait));
2630 PRINT_D(GENERIC_DBG, "Current Jiffies: %lu Timeout:%llu\n", jiffies, pstrWFIDrv->u64P2p_MgmtTimeout);
2634 g_linux_wlan->oup.wlan_add_mgmt_to_tx_que(mgmt_tx, mgmt_tx->buff, mgmt_tx->size, WILC_WFI_mgmt_tx_complete);
2636 PRINT_D(GENERIC_DBG, "This function transmits only management frames\n");
2641 int WILC_WFI_mgmt_tx_cancel_wait(struct wiphy *wiphy,
2642 struct wireless_dev *wdev,
2645 struct WILC_WFI_priv *priv;
2646 tstrWILC_WFIDrv *pstrWFIDrv;
2647 priv = wiphy_priv(wiphy);
2648 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2651 PRINT_D(GENERIC_DBG, "Tx Cancel wait :%lu\n", jiffies);
2652 pstrWFIDrv->u64P2p_MgmtTimeout = jiffies;
2654 if (priv->bInP2PlistenState == false) {
2655 /* Bug 5504: This is just to avoid connection failure when getting stuck when the supplicant
2656 * considers the driver falsely that it is in Listen state */
2657 cfg80211_remain_on_channel_expired(priv->wdev,
2658 priv->strRemainOnChanParams.u64ListenCookie,
2659 priv->strRemainOnChanParams.pstrListenChan,
2667 * @brief WILC_WFI_frame_register
2668 * @details Notify driver that a management frame type was
2669 * registered. Note that this callback may not sleep, and cannot run
2670 * concurrently with itself.
2677 void WILC_WFI_frame_register(struct wiphy *wiphy,
2678 struct wireless_dev *wdev,
2679 u16 frame_type, bool reg)
2682 struct WILC_WFI_priv *priv;
2683 perInterface_wlan_t *nic;
2686 priv = wiphy_priv(wiphy);
2687 nic = netdev_priv(priv->wdev->netdev);
2695 PRINT_D(GENERIC_DBG, "Frame registering Frame Type: %x: Boolean: %d\n", frame_type, reg);
2696 switch (frame_type) {
2699 nic->g_struct_frame_reg[0].frame_type = frame_type;
2700 nic->g_struct_frame_reg[0].reg = reg;
2706 nic->g_struct_frame_reg[1].frame_type = frame_type;
2707 nic->g_struct_frame_reg[1].reg = reg;
2717 /*If mac is closed, then return*/
2718 if (!g_linux_wlan->wilc1000_initialized) {
2719 PRINT_D(GENERIC_DBG, "Return since mac is closed\n");
2722 host_int_frame_register(priv->hWILCWFIDrv, frame_type, reg);
2729 * @brief WILC_WFI_set_cqm_rssi_config
2730 * @details Configure connection quality monitor RSSI threshold.
2731 * @param[in] struct wiphy *wiphy:
2732 * @param[in] struct net_device *dev:
2733 * @param[in] s32 rssi_thold:
2734 * @param[in] u32 rssi_hyst:
2735 * @return int : Return 0 on Success
2740 static int WILC_WFI_set_cqm_rssi_config(struct wiphy *wiphy,
2741 struct net_device *dev, s32 rssi_thold, u32 rssi_hyst)
2743 PRINT_D(CFG80211_DBG, "Setting CQM RSSi Function\n");
2748 * @brief WILC_WFI_dump_station
2749 * @details Configure connection quality monitor RSSI threshold.
2750 * @param[in] struct wiphy *wiphy:
2751 * @param[in] struct net_device *dev
2752 * @param[in] int idx
2753 * @param[in] u8 *mac
2754 * @param[in] struct station_info *sinfo
2755 * @return int : Return 0 on Success
2760 static int WILC_WFI_dump_station(struct wiphy *wiphy, struct net_device *dev,
2761 int idx, u8 *mac, struct station_info *sinfo)
2763 struct WILC_WFI_priv *priv;
2764 PRINT_D(CFG80211_DBG, "Dumping station information\n");
2769 priv = wiphy_priv(wiphy);
2771 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
2773 host_int_get_rssi(priv->hWILCWFIDrv, &(sinfo->signal));
2781 * @brief WILC_WFI_set_power_mgmt
2784 * @return int : Return 0 on Success.
2787 * @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
2789 int WILC_WFI_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2790 bool enabled, int timeout)
2792 struct WILC_WFI_priv *priv;
2793 PRINT_D(CFG80211_DBG, " Power save Enabled= %d , TimeOut = %d\n", enabled, timeout);
2798 priv = wiphy_priv(wiphy);
2799 if (priv->hWILCWFIDrv == NULL) {
2800 PRINT_ER("Driver is NULL\n");
2805 host_int_set_power_mgmt(priv->hWILCWFIDrv, enabled, timeout);
2808 return WILC_SUCCESS;
2811 #ifdef WILC_AP_EXTERNAL_MLME
2813 * @brief WILC_WFI_change_virt_intf
2814 * @details Change type/configuration of virtual interface,
2815 * keep the struct wireless_dev's iftype updated.
2817 * @return int : Return 0 on Success.
2822 void wilc1000_wlan_deinit(linux_wlan_t *nic);
2823 int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic);
2825 static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev,
2826 enum nl80211_iftype type, u32 *flags, struct vif_params *params)
2828 s32 s32Error = WILC_SUCCESS;
2829 struct WILC_WFI_priv *priv;
2830 perInterface_wlan_t *nic;
2837 nic = netdev_priv(dev);
2838 priv = wiphy_priv(wiphy);
2840 PRINT_D(HOSTAPD_DBG, "In Change virtual interface function\n");
2841 PRINT_D(HOSTAPD_DBG, "Wireless interface name =%s\n", dev->name);
2842 u8P2Plocalrandom = 0x01;
2843 u8P2Precvrandom = 0x00;
2847 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2848 g_obtainingIP = false;
2849 del_timer(&hDuringIpTimer);
2850 PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n");
2853 /*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to CE H/W*/
2854 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2855 Set_machw_change_vir_if(true);
2859 case NL80211_IFTYPE_STATION:
2861 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_STATION\n");
2863 /* send delba over wlan interface */
2866 dev->ieee80211_ptr->iftype = type;
2867 priv->wdev->iftype = type;
2868 nic->monitor_flag = 0;
2869 nic->iftype = STATION_MODE;
2871 /*Remove the enteries of the previously connected clients*/
2872 memset(priv->assoc_stainfo.au8Sta_AssociatedBss, 0, MAX_NUM_STA * ETH_ALEN);
2874 interface_type = nic->iftype;
2875 nic->iftype = STATION_MODE;
2877 if (g_linux_wlan->wilc1000_initialized) {
2878 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
2879 /* ensure that the message Q is empty */
2880 host_int_wait_msg_queue_idle();
2883 /*Eliminate host interface blocking state*/
2884 linux_wlan_unlock((void *)&g_linux_wlan->cfg_event);
2886 wilc1000_wlan_deinit(g_linux_wlan);
2887 wilc1000_wlan_init(dev, nic);
2888 g_wilc_initialized = 1;
2889 nic->iftype = interface_type;
2891 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
2892 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
2893 host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler,
2894 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
2895 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2897 /*Add saved WEP keys, if any*/
2898 if (g_wep_keys_saved) {
2899 host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler,
2900 g_key_wep_params.key_idx);
2901 host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler,
2902 g_key_wep_params.key,
2903 g_key_wep_params.key_len,
2904 g_key_wep_params.key_idx);
2907 /*No matter the driver handler passed here, it will be overwriiten*/
2908 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2909 host_int_flush_join_req(priv->hWILCWFIDrv);
2911 /*Add saved PTK and GTK keys, if any*/
2912 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2913 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
2914 g_key_ptk_params.key[1],
2915 g_key_ptk_params.key[2]);
2916 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
2917 g_key_gtk_params.key[1],
2918 g_key_gtk_params.key[2]);
2919 WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2920 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2921 g_add_ptk_key_params.key_idx,
2922 g_add_ptk_key_params.pairwise,
2923 g_add_ptk_key_params.mac_addr,
2924 (struct key_params *)(&g_key_ptk_params));
2926 WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2927 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2928 g_add_gtk_key_params.key_idx,
2929 g_add_gtk_key_params.pairwise,
2930 g_add_gtk_key_params.mac_addr,
2931 (struct key_params *)(&g_key_gtk_params));
2934 /*BugID_4847: registered frames in firmware are now*/
2935 /*lost due to mac close. So re-register those frames*/
2936 if (g_linux_wlan->wilc1000_initialized) {
2937 for (i = 0; i < num_reg_frame; i++) {
2938 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2939 nic->g_struct_frame_reg[i].reg);
2940 host_int_frame_register(priv->hWILCWFIDrv,
2941 nic->g_struct_frame_reg[i].frame_type,
2942 nic->g_struct_frame_reg[i].reg);
2947 host_int_set_power_mgmt(priv->hWILCWFIDrv, 1, 0);
2952 case NL80211_IFTYPE_P2P_CLIENT:
2954 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
2956 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n");
2958 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
2960 dev->ieee80211_ptr->iftype = type;
2961 priv->wdev->iftype = type;
2962 nic->monitor_flag = 0;
2966 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
2967 nic->iftype = CLIENT_MODE;
2970 if (g_linux_wlan->wilc1000_initialized) {
2971 /* ensure that the message Q is empty */
2972 host_int_wait_msg_queue_idle();
2974 wilc1000_wlan_deinit(g_linux_wlan);
2975 wilc1000_wlan_init(dev, nic);
2976 g_wilc_initialized = 1;
2978 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
2979 host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler,
2980 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
2981 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2983 /*Add saved WEP keys, if any*/
2984 if (g_wep_keys_saved) {
2985 host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler,
2986 g_key_wep_params.key_idx);
2987 host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler,
2988 g_key_wep_params.key,
2989 g_key_wep_params.key_len,
2990 g_key_wep_params.key_idx);
2993 /*No matter the driver handler passed here, it will be overwriiten*/
2994 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2995 host_int_flush_join_req(priv->hWILCWFIDrv);
2997 /*Add saved PTK and GTK keys, if any*/
2998 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2999 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
3000 g_key_ptk_params.key[1],
3001 g_key_ptk_params.key[2]);
3002 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
3003 g_key_gtk_params.key[1],
3004 g_key_gtk_params.key[2]);
3005 WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3006 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3007 g_add_ptk_key_params.key_idx,
3008 g_add_ptk_key_params.pairwise,
3009 g_add_ptk_key_params.mac_addr,
3010 (struct key_params *)(&g_key_ptk_params));
3012 WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3013 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3014 g_add_gtk_key_params.key_idx,
3015 g_add_gtk_key_params.pairwise,
3016 g_add_gtk_key_params.mac_addr,
3017 (struct key_params *)(&g_key_gtk_params));
3020 /*Refresh scan, to refresh the scan results to the wpa_supplicant. Set MachHw to false to enable further key installments*/
3021 refresh_scan(priv, 1, true);
3022 Set_machw_change_vir_if(false);
3024 /*BugID_4847: registered frames in firmware are now lost
3025 * due to mac close. So re-register those frames */
3026 if (g_linux_wlan->wilc1000_initialized) {
3027 for (i = 0; i < num_reg_frame; i++) {
3028 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
3029 nic->g_struct_frame_reg[i].reg);
3030 host_int_frame_register(priv->hWILCWFIDrv,
3031 nic->g_struct_frame_reg[i].frame_type,
3032 nic->g_struct_frame_reg[i].reg);
3039 case NL80211_IFTYPE_AP:
3041 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_AP %d\n", type);
3042 dev->ieee80211_ptr->iftype = type;
3043 priv->wdev->iftype = type;
3044 nic->iftype = AP_MODE;
3045 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
3047 PRINT_D(HOSTAPD_DBG, "Downloading AP firmware\n");
3048 linux_wlan_get_firmware(nic);
3050 /*If wilc is running, then close-open to actually get new firmware running (serves P2P)*/
3051 if (g_linux_wlan->wilc1000_initialized) {
3052 nic->iftype = AP_MODE;
3053 g_linux_wlan->wilc1000_initialized = 1;
3057 /*BugID_4847: registered frames in firmware are now lost
3058 * due to mac close. So re-register those frames */
3059 for (i = 0; i < num_reg_frame; i++) {
3060 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
3061 nic->g_struct_frame_reg[i].reg);
3062 host_int_frame_register(priv->hWILCWFIDrv,
3063 nic->g_struct_frame_reg[i].frame_type,
3064 nic->g_struct_frame_reg[i].reg);
3070 case NL80211_IFTYPE_P2P_GO:
3071 PRINT_D(GENERIC_DBG, "start duringIP timer\n");
3073 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3074 g_obtainingIP = true;
3075 mod_timer(&hDuringIpTimer, jiffies + msecs_to_jiffies(duringIP_TIME));
3077 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
3079 /*Delete block ack has to be the latest config packet*/
3080 /*sent before downloading new FW. This is because it blocks on*/
3081 /*hWaitResponse semaphore, which allows previous config*/
3082 /*packets to actually take action on old FW*/
3083 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
3085 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n");
3086 dev->ieee80211_ptr->iftype = type;
3087 priv->wdev->iftype = type;
3089 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
3092 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
3096 nic->iftype = GO_MODE;
3098 /* ensure that the message Q is empty */
3099 host_int_wait_msg_queue_idle();
3100 wilc1000_wlan_deinit(g_linux_wlan);
3101 wilc1000_wlan_init(dev, nic);
3102 g_wilc_initialized = 1;
3105 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
3106 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
3107 host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler,
3108 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
3109 host_int_set_operation_mode(priv->hWILCWFIDrv, AP_MODE);
3111 /*Add saved WEP keys, if any*/
3112 if (g_wep_keys_saved) {
3113 host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler,
3114 g_key_wep_params.key_idx);
3115 host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler,
3116 g_key_wep_params.key,
3117 g_key_wep_params.key_len,
3118 g_key_wep_params.key_idx);
3121 /*No matter the driver handler passed here, it will be overwriiten*/
3122 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
3123 host_int_flush_join_req(priv->hWILCWFIDrv);
3125 /*Add saved PTK and GTK keys, if any*/
3126 if (g_ptk_keys_saved && g_gtk_keys_saved) {
3127 PRINT_D(CFG80211_DBG, "ptk %x %x %x cipher %x\n", g_key_ptk_params.key[0],
3128 g_key_ptk_params.key[1],
3129 g_key_ptk_params.key[2],
3130 g_key_ptk_params.cipher);
3131 PRINT_D(CFG80211_DBG, "gtk %x %x %x cipher %x\n", g_key_gtk_params.key[0],
3132 g_key_gtk_params.key[1],
3133 g_key_gtk_params.key[2],
3134 g_key_gtk_params.cipher);
3136 WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3137 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3138 g_add_ptk_key_params.key_idx,
3139 g_add_ptk_key_params.pairwise,
3140 g_add_ptk_key_params.mac_addr,
3141 (struct key_params *)(&g_key_ptk_params));
3143 WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3144 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3145 g_add_gtk_key_params.key_idx,
3146 g_add_gtk_key_params.pairwise,
3147 g_add_gtk_key_params.mac_addr,
3148 (struct key_params *)(&g_key_gtk_params));
3153 /*BugID_4847: registered frames in firmware are now*/
3154 /*lost due to mac close. So re-register those frames*/
3155 if (g_linux_wlan->wilc1000_initialized) {
3156 for (i = 0; i < num_reg_frame; i++) {
3157 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
3158 nic->g_struct_frame_reg[i].reg);
3159 host_int_frame_register(priv->hWILCWFIDrv,
3160 nic->g_struct_frame_reg[i].frame_type,
3161 nic->g_struct_frame_reg[i].reg);
3168 PRINT_ER("Unknown interface type= %d\n", type);
3177 /* (austin.2013-07-23)
3179 * To support revised cfg80211_ops
3181 * add_beacon --> start_ap
3182 * set_beacon --> change_beacon
3183 * del_beacon --> stop_ap
3185 * beacon_parameters --> cfg80211_ap_settings
3186 * cfg80211_beacon_data
3188 * applicable for linux kernel 3.4+
3192 * @brief WILC_WFI_start_ap
3193 * @details Add a beacon with given parameters, @head, @interval
3194 * and @dtim_period will be valid, @tail is optional.
3196 * @param[in] dev The net device structure
3197 * @param[in] settings cfg80211_ap_settings parameters for the beacon to be added
3198 * @return int : Return 0 on Success.
3203 static int WILC_WFI_start_ap(struct wiphy *wiphy, struct net_device *dev,
3204 struct cfg80211_ap_settings *settings)
3206 struct cfg80211_beacon_data *beacon = &(settings->beacon);
3207 struct WILC_WFI_priv *priv;
3208 s32 s32Error = WILC_SUCCESS;
3210 priv = wiphy_priv(wiphy);
3211 PRINT_D(HOSTAPD_DBG, "Starting ap\n");
3213 PRINT_D(HOSTAPD_DBG, "Interval = %d\n DTIM period = %d\n Head length = %zu Tail length = %zu\n",
3214 settings->beacon_interval, settings->dtim_period, beacon->head_len, beacon->tail_len);
3216 s32Error = WILC_WFI_CfgSetChannel(wiphy, &settings->chandef);
3218 if (s32Error != WILC_SUCCESS)
3219 PRINT_ER("Error in setting channel\n");
3221 linux_wlan_set_bssid(dev, g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
3223 #ifndef WILC_FULLY_HOSTING_AP
3224 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
3225 settings->beacon_interval,
3226 settings->dtim_period,
3227 beacon->head_len, (u8 *)beacon->head,
3228 beacon->tail_len, (u8 *)beacon->tail);
3230 s32Error = host_add_beacon(priv->hWILCWFIDrv,
3231 settings->beacon_interval,
3232 settings->dtim_period,
3233 beacon->head_len, (u8 *)beacon->head,
3234 beacon->tail_len, (u8 *)beacon->tail);
3241 * @brief WILC_WFI_change_beacon
3242 * @details Add a beacon with given parameters, @head, @interval
3243 * and @dtim_period will be valid, @tail is optional.
3245 * @param[in] dev The net device structure
3246 * @param[in] beacon cfg80211_beacon_data for the beacon to be changed
3247 * @return int : Return 0 on Success.
3252 static int WILC_WFI_change_beacon(struct wiphy *wiphy, struct net_device *dev,
3253 struct cfg80211_beacon_data *beacon)
3255 struct WILC_WFI_priv *priv;
3256 s32 s32Error = WILC_SUCCESS;
3258 priv = wiphy_priv(wiphy);
3259 PRINT_D(HOSTAPD_DBG, "Setting beacon\n");
3262 #ifndef WILC_FULLY_HOSTING_AP
3263 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
3266 beacon->head_len, (u8 *)beacon->head,
3267 beacon->tail_len, (u8 *)beacon->tail);
3269 s32Error = host_add_beacon(priv->hWILCWFIDrv,
3272 beacon->head_len, (u8 *)beacon->head,
3273 beacon->tail_len, (u8 *)beacon->tail);
3280 * @brief WILC_WFI_stop_ap
3281 * @details Remove beacon configuration and stop sending the beacon.
3283 * @return int : Return 0 on Success.
3288 static int WILC_WFI_stop_ap(struct wiphy *wiphy, struct net_device *dev)
3290 s32 s32Error = WILC_SUCCESS;
3291 struct WILC_WFI_priv *priv;
3292 u8 NullBssid[ETH_ALEN] = {0};
3295 WILC_NULLCHECK(s32Error, wiphy);
3297 priv = wiphy_priv(wiphy);
3299 PRINT_D(HOSTAPD_DBG, "Deleting beacon\n");
3302 linux_wlan_set_bssid(dev, NullBssid);
3304 #ifndef WILC_FULLY_HOSTING_AP
3305 s32Error = host_int_del_beacon(priv->hWILCWFIDrv);
3307 s32Error = host_del_beacon(priv->hWILCWFIDrv);
3310 WILC_ERRORCHECK(s32Error);
3312 WILC_CATCH(s32Error)
3319 * @brief WILC_WFI_add_station
3320 * @details Add a new station.
3322 * @return int : Return 0 on Success.
3327 static int WILC_WFI_add_station(struct wiphy *wiphy, struct net_device *dev,
3328 const u8 *mac, struct station_parameters *params)
3330 s32 s32Error = WILC_SUCCESS;
3331 struct WILC_WFI_priv *priv;
3332 tstrWILC_AddStaParam strStaParams = { {0} };
3333 perInterface_wlan_t *nic;
3336 WILC_NULLCHECK(s32Error, wiphy);
3338 priv = wiphy_priv(wiphy);
3339 nic = netdev_priv(dev);
3341 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3342 #ifndef WILC_FULLY_HOSTING_AP
3344 memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
3345 memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN);
3346 strStaParams.u16AssocID = params->aid;
3347 strStaParams.u8NumRates = params->supported_rates_len;
3348 strStaParams.pu8Rates = params->supported_rates;
3350 PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid);
3352 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],
3353 priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]);
3354 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3355 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3357 if (params->ht_capa == NULL) {
3358 strStaParams.bIsHTSupported = false;
3360 strStaParams.bIsHTSupported = true;
3361 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3362 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
3363 memcpy(strStaParams.au8SuppMCsSet, ¶ms->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
3364 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3365 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3366 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3369 strStaParams.u16FlagsMask = params->sta_flags_mask;
3370 strStaParams.u16FlagsSet = params->sta_flags_set;
3372 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3373 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3374 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3375 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3376 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3377 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3378 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3379 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3381 s32Error = host_int_add_station(priv->hWILCWFIDrv, &strStaParams);
3382 WILC_ERRORCHECK(s32Error);
3385 PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid);
3386 memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN);
3388 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],
3389 priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]);
3391 WILC_AP_AddSta(mac, params);
3392 WILC_ERRORCHECK(s32Error);
3393 #endif /* WILC_FULLY_HOSTING_AP */
3397 WILC_CATCH(s32Error)
3404 * @brief WILC_WFI_del_station
3405 * @details Remove a station; @mac may be NULL to remove all stations.
3407 * @return int : Return 0 on Success.
3412 static int WILC_WFI_del_station(struct wiphy *wiphy, struct net_device *dev,
3413 struct station_del_parameters *params)
3415 const u8 *mac = params->mac;
3416 s32 s32Error = WILC_SUCCESS;
3417 struct WILC_WFI_priv *priv;
3418 perInterface_wlan_t *nic;
3419 WILC_NULLCHECK(s32Error, wiphy);
3421 priv = wiphy_priv(wiphy);
3422 nic = netdev_priv(dev);
3424 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3425 PRINT_D(HOSTAPD_DBG, "Deleting station\n");
3429 PRINT_D(HOSTAPD_DBG, "All associated stations\n");
3430 s32Error = host_int_del_allstation(priv->hWILCWFIDrv, priv->assoc_stainfo.au8Sta_AssociatedBss);
3432 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]);
3435 #ifndef WILC_FULLY_HOSTING_AP
3436 s32Error = host_int_del_station(priv->hWILCWFIDrv, mac);
3438 WILC_AP_RemoveSta(mac);
3439 #endif /* WILC_FULLY_HOSTING_AP */
3441 WILC_ERRORCHECK(s32Error);
3443 WILC_CATCH(s32Error)
3450 * @brief WILC_WFI_change_station
3451 * @details Modify a given station.
3453 * @return int : Return 0 on Success.
3458 static int WILC_WFI_change_station(struct wiphy *wiphy, struct net_device *dev,
3459 const u8 *mac, struct station_parameters *params)
3461 s32 s32Error = WILC_SUCCESS;
3462 struct WILC_WFI_priv *priv;
3463 tstrWILC_AddStaParam strStaParams = { {0} };
3464 perInterface_wlan_t *nic;
3467 PRINT_D(HOSTAPD_DBG, "Change station paramters\n");
3469 WILC_NULLCHECK(s32Error, wiphy);
3471 priv = wiphy_priv(wiphy);
3472 nic = netdev_priv(dev);
3474 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3475 #ifndef WILC_FULLY_HOSTING_AP
3477 memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
3478 strStaParams.u16AssocID = params->aid;
3479 strStaParams.u8NumRates = params->supported_rates_len;
3480 strStaParams.pu8Rates = params->supported_rates;
3482 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],
3483 strStaParams.au8BSSID[5]);
3484 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3485 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3487 if (params->ht_capa == NULL) {
3488 strStaParams.bIsHTSupported = false;
3490 strStaParams.bIsHTSupported = true;
3491 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3492 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
3493 memcpy(strStaParams.au8SuppMCsSet, ¶ms->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
3494 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3495 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3496 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3500 strStaParams.u16FlagsMask = params->sta_flags_mask;
3501 strStaParams.u16FlagsSet = params->sta_flags_set;
3503 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3504 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3505 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3506 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3507 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3508 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3509 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3510 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3512 s32Error = host_int_edit_station(priv->hWILCWFIDrv, &strStaParams);
3513 WILC_ERRORCHECK(s32Error);
3516 WILC_AP_EditSta(mac, params);
3517 WILC_ERRORCHECK(s32Error);
3518 #endif /* WILC_FULLY_HOSTING_AP */
3521 WILC_CATCH(s32Error)
3529 * @brief WILC_WFI_add_virt_intf
3532 * @return int : Return 0 on Success.
3537 struct wireless_dev *WILC_WFI_add_virt_intf(struct wiphy *wiphy, const char *name,
3538 unsigned char name_assign_type,
3539 enum nl80211_iftype type, u32 *flags,
3540 struct vif_params *params)
3542 perInterface_wlan_t *nic;
3543 struct WILC_WFI_priv *priv;
3544 struct net_device *new_ifc = NULL;
3545 priv = wiphy_priv(wiphy);
3549 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", priv->wdev->netdev);
3551 nic = netdev_priv(priv->wdev->netdev);
3554 if (type == NL80211_IFTYPE_MONITOR) {
3555 PRINT_D(HOSTAPD_DBG, "Monitor interface mode: Initializing mon interface virtual device driver\n");
3556 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", nic->wilc_netdev);
3557 new_ifc = WILC_WFI_init_mon_interface(name, nic->wilc_netdev);
3558 if (new_ifc != NULL) {
3559 PRINT_D(HOSTAPD_DBG, "Setting monitor flag in private structure\n");
3560 nic = netdev_priv(priv->wdev->netdev);
3561 nic->monitor_flag = 1;
3563 PRINT_ER("Error in initializing monitor interface\n ");
3569 * @brief WILC_WFI_del_virt_intf
3572 * @return int : Return 0 on Success.
3577 int WILC_WFI_del_virt_intf(struct wiphy *wiphy, struct wireless_dev *wdev) /* tony for v3.8 support */
3579 PRINT_D(HOSTAPD_DBG, "Deleting virtual interface\n");
3580 return WILC_SUCCESS;
3585 #endif /*WILC_AP_EXTERNAL_MLME*/
3586 static struct cfg80211_ops WILC_WFI_cfg80211_ops = {
3588 .set_monitor_channel = WILC_WFI_CfgSetChannel,
3589 .scan = WILC_WFI_CfgScan,
3590 .connect = WILC_WFI_CfgConnect,
3591 .disconnect = WILC_WFI_disconnect,
3592 .add_key = WILC_WFI_add_key,
3593 .del_key = WILC_WFI_del_key,
3594 .get_key = WILC_WFI_get_key,
3595 .set_default_key = WILC_WFI_set_default_key,
3596 #ifdef WILC_AP_EXTERNAL_MLME
3597 .add_virtual_intf = WILC_WFI_add_virt_intf,
3598 .del_virtual_intf = WILC_WFI_del_virt_intf,
3599 .change_virtual_intf = WILC_WFI_change_virt_intf,
3601 .start_ap = WILC_WFI_start_ap,
3602 .change_beacon = WILC_WFI_change_beacon,
3603 .stop_ap = WILC_WFI_stop_ap,
3604 .add_station = WILC_WFI_add_station,
3605 .del_station = WILC_WFI_del_station,
3606 .change_station = WILC_WFI_change_station,
3607 #endif /* WILC_AP_EXTERNAL_MLME*/
3608 #ifndef WILC_FULLY_HOSTING_AP
3609 .get_station = WILC_WFI_get_station,
3611 .dump_station = WILC_WFI_dump_station,
3612 .change_bss = WILC_WFI_change_bss,
3613 .set_wiphy_params = WILC_WFI_set_wiphy_params,
3615 .set_pmksa = WILC_WFI_set_pmksa,
3616 .del_pmksa = WILC_WFI_del_pmksa,
3617 .flush_pmksa = WILC_WFI_flush_pmksa,
3619 .remain_on_channel = WILC_WFI_remain_on_channel,
3620 .cancel_remain_on_channel = WILC_WFI_cancel_remain_on_channel,
3621 .mgmt_tx_cancel_wait = WILC_WFI_mgmt_tx_cancel_wait,
3622 .mgmt_tx = WILC_WFI_mgmt_tx,
3623 .mgmt_frame_register = WILC_WFI_frame_register,
3624 .set_power_mgmt = WILC_WFI_set_power_mgmt,
3625 .set_cqm_rssi_config = WILC_WFI_set_cqm_rssi_config,
3635 * @brief WILC_WFI_update_stats
3636 * @details Modify parameters for a given BSS.
3638 * @return int : Return 0 on Success.
3641 * @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
3643 int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed)
3646 struct WILC_WFI_priv *priv;
3648 priv = wiphy_priv(wiphy);
3652 case WILC_WFI_RX_PKT:
3654 priv->netstats.rx_packets++;
3655 priv->netstats.rx_bytes += pktlen;
3656 priv->netstats.rx_time = get_jiffies_64();
3660 case WILC_WFI_TX_PKT:
3662 priv->netstats.tx_packets++;
3663 priv->netstats.tx_bytes += pktlen;
3664 priv->netstats.tx_time = get_jiffies_64();
3677 * @brief WILC_WFI_CfgAlloc
3678 * @details Allocation of the wireless device structure and assigning it
3679 * to the cfg80211 operations structure.
3681 * @return wireless_dev : Returns pointer to wireless_dev structure.
3686 struct wireless_dev *WILC_WFI_CfgAlloc(void)
3689 struct wireless_dev *wdev;
3692 PRINT_D(CFG80211_DBG, "Allocating wireless device\n");
3693 /*Allocating the wireless device structure*/
3694 wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
3696 PRINT_ER("Cannot allocate wireless device\n");
3700 /*Creating a new wiphy, linking wireless structure with the wiphy structure*/
3701 wdev->wiphy = wiphy_new(&WILC_WFI_cfg80211_ops, sizeof(struct WILC_WFI_priv));
3703 PRINT_ER("Cannot allocate wiphy\n");
3708 #ifdef WILC_AP_EXTERNAL_MLME
3709 /* enable 802.11n HT */
3710 WILC_WFI_band_2ghz.ht_cap.ht_supported = 1;
3711 WILC_WFI_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT);
3712 WILC_WFI_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff;
3713 WILC_WFI_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K;
3714 WILC_WFI_band_2ghz.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE;
3718 wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &WILC_WFI_band_2ghz;
3729 * @brief WILC_WFI_WiphyRegister
3730 * @details Registering of the wiphy structure and interface modes
3737 struct wireless_dev *WILC_WFI_WiphyRegister(struct net_device *net)
3739 struct WILC_WFI_priv *priv;
3740 struct wireless_dev *wdev;
3741 s32 s32Error = WILC_SUCCESS;
3743 PRINT_D(CFG80211_DBG, "Registering wifi device\n");
3745 wdev = WILC_WFI_CfgAlloc();
3747 PRINT_ER("CfgAlloc Failed\n");
3752 /*Return hardware description structure (wiphy)'s priv*/
3753 priv = wdev_priv(wdev);
3754 sema_init(&(priv->SemHandleUpdateStats), 1);
3756 /*Link the wiphy with wireless structure*/
3759 /*Maximum number of probed ssid to be added by user for the scan request*/
3760 wdev->wiphy->max_scan_ssids = MAX_NUM_PROBED_SSID;
3761 /*Maximum number of pmkids to be cashed*/
3762 wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS;
3763 PRINT_INFO(CFG80211_DBG, "Max number of PMKIDs = %d\n", wdev->wiphy->max_num_pmkids);
3765 wdev->wiphy->max_scan_ie_len = 1000;
3767 /*signal strength in mBm (100*dBm) */
3768 wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
3770 /*Set the availaible cipher suites*/
3771 wdev->wiphy->cipher_suites = cipher_suites;
3772 wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
3773 /*Setting default managment types: for register action frame: */
3774 wdev->wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types;
3777 wdev->wiphy->max_remain_on_channel_duration = 500;
3778 /*Setting the wiphy interfcae mode and type before registering the wiphy*/
3779 wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | BIT(NL80211_IFTYPE_P2P_GO) |
3780 BIT(NL80211_IFTYPE_P2P_CLIENT);
3781 wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
3783 wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR);
3785 wdev->iftype = NL80211_IFTYPE_STATION;
3789 PRINT_INFO(CFG80211_DBG, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n",
3790 wdev->wiphy->max_scan_ssids, wdev->wiphy->max_scan_ie_len, wdev->wiphy->signal_type,
3791 wdev->wiphy->interface_modes, wdev->iftype);
3794 set_wiphy_dev(wdev->wiphy, &local_sdio_func->dev); /* tony */
3797 /*Register wiphy structure*/
3798 s32Error = wiphy_register(wdev->wiphy);
3800 PRINT_ER("Cannot register wiphy device\n");
3801 /*should define what action to be taken in such failure*/
3803 PRINT_D(CFG80211_DBG, "Successful Registering\n");
3812 * @brief WILC_WFI_WiphyFree
3813 * @details Freeing allocation of the wireless device structure
3820 int WILC_WFI_InitHostInt(struct net_device *net)
3823 s32 s32Error = WILC_SUCCESS;
3825 struct WILC_WFI_priv *priv;
3827 PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr);
3828 priv = wdev_priv(net->ieee80211_ptr);
3830 setup_timer(&hAgingTimer, remove_network_from_shadow, 0);
3831 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3832 setup_timer(&hDuringIpTimer, clear_duringIP, 0);
3837 PRINT_ER("Failed to creat refresh Timer\n");
3841 priv->gbAutoRateAdjusted = false;
3843 priv->bInP2PlistenState = false;
3845 sema_init(&(priv->hSemScanReq), 1);
3846 s32Error = host_int_init(&priv->hWILCWFIDrv);
3848 PRINT_ER("Error while initializing hostinterface\n");
3854 * @brief WILC_WFI_WiphyFree
3855 * @details Freeing allocation of the wireless device structure
3862 int WILC_WFI_DeInitHostInt(struct net_device *net)
3864 s32 s32Error = WILC_SUCCESS;
3866 struct WILC_WFI_priv *priv;
3867 priv = wdev_priv(net->ieee80211_ptr);
3869 priv->gbAutoRateAdjusted = false;
3871 priv->bInP2PlistenState = false;
3875 s32Error = host_int_deinit(priv->hWILCWFIDrv);
3877 /* Clear the Shadow scan */
3878 clear_shadow_scan(priv);
3879 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3881 PRINT_D(CORECONFIG_DBG, "destroy during ip\n");
3882 del_timer_sync(&hDuringIpTimer);
3887 PRINT_ER("Error while deintializing host interface\n");
3894 * @brief WILC_WFI_WiphyFree
3895 * @details Freeing allocation of the wireless device structure
3902 void WILC_WFI_WiphyFree(struct net_device *net)
3905 PRINT_D(CFG80211_DBG, "Unregistering wiphy\n");
3908 PRINT_D(INIT_DBG, "net_device is NULL\n");
3912 if (net->ieee80211_ptr == NULL) {
3913 PRINT_D(INIT_DBG, "ieee80211_ptr is NULL\n");
3917 if (net->ieee80211_ptr->wiphy == NULL) {
3918 PRINT_D(INIT_DBG, "wiphy is NULL\n");
3922 wiphy_unregister(net->ieee80211_ptr->wiphy);
3924 PRINT_D(INIT_DBG, "Freeing wiphy\n");
3925 wiphy_free(net->ieee80211_ptr->wiphy);
3926 kfree(net->ieee80211_ptr);