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 void linux_wlan_free(void *vp);
26 extern int linux_wlan_get_firmware(perInterface_wlan_t *p_nic);
27 extern void linux_wlan_unlock(void *vp);
28 extern WILC_Uint16 Set_machw_change_vir_if(WILC_Bool bValue);
30 extern int mac_open(struct net_device *ndev);
31 extern int mac_close(struct net_device *ndev);
33 tstrNetworkInfo astrLastScannedNtwrksShadow[MAX_NUM_SCANNED_NETWORKS_SHADOW];
34 WILC_Uint32 u32LastScannedNtwrksCountShadow;
35 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
36 WILC_TimerHandle hDuringIpTimer;
38 WILC_TimerHandle hAgingTimer;
40 extern u8 u8ConnectedSSID[6];
43 u8 g_wilc_initialized = 1;
44 extern linux_wlan_t *g_linux_wlan;
45 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
46 extern WILC_Bool g_obtainingIP;
49 #define CHAN2G(_channel, _freq, _flags) { \
50 .band = IEEE80211_BAND_2GHZ, \
51 .center_freq = (_freq), \
52 .hw_value = (_channel), \
54 .max_antenna_gain = 0, \
58 /*Frequency range for channels*/
59 static struct ieee80211_channel WILC_WFI_2ghz_channels[] = {
76 #define RATETAB_ENT(_rate, _hw_value, _flags) { \
78 .hw_value = (_hw_value), \
83 /* Table 6 in section 3.2.1.1 */
84 static struct ieee80211_rate WILC_WFI_rates[] = {
85 RATETAB_ENT(10, 0, 0),
86 RATETAB_ENT(20, 1, 0),
87 RATETAB_ENT(55, 2, 0),
88 RATETAB_ENT(110, 3, 0),
89 RATETAB_ENT(60, 9, 0),
90 RATETAB_ENT(90, 6, 0),
91 RATETAB_ENT(120, 7, 0),
92 RATETAB_ENT(180, 8, 0),
93 RATETAB_ENT(240, 9, 0),
94 RATETAB_ENT(360, 10, 0),
95 RATETAB_ENT(480, 11, 0),
96 RATETAB_ENT(540, 12, 0),
100 struct p2p_mgmt_data {
105 /*Global variable used to state the current connected STA channel*/
106 u8 u8WLANChannel = INVALID_CHANNEL;
111 u8 u8P2P_oui[] = {0x50, 0x6f, 0x9A, 0x09};
112 u8 u8P2Plocalrandom = 0x01;
113 u8 u8P2Precvrandom = 0x00;
114 u8 u8P2P_vendorspec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};
115 WILC_Bool bWilc_ie = WILC_FALSE;
118 static struct ieee80211_supported_band WILC_WFI_band_2ghz = {
119 .channels = WILC_WFI_2ghz_channels,
120 .n_channels = ARRAY_SIZE(WILC_WFI_2ghz_channels),
121 .bitrates = WILC_WFI_rates,
122 .n_bitrates = ARRAY_SIZE(WILC_WFI_rates),
127 struct add_key_params {
132 struct add_key_params g_add_gtk_key_params;
133 struct wilc_wfi_key g_key_gtk_params;
134 struct add_key_params g_add_ptk_key_params;
135 struct wilc_wfi_key g_key_ptk_params;
136 struct wilc_wfi_wep_key g_key_wep_params;
137 u8 g_flushing_in_progress;
138 WILC_Bool g_ptk_keys_saved = WILC_FALSE;
139 WILC_Bool g_gtk_keys_saved = WILC_FALSE;
140 WILC_Bool g_wep_keys_saved = WILC_FALSE;
142 #define AGING_TIME (9 * 1000)
143 #define duringIP_TIME 15000
145 void clear_shadow_scan(void *pUserVoid)
147 struct WILC_WFI_priv *priv;
149 priv = (struct WILC_WFI_priv *)pUserVoid;
151 WILC_TimerDestroy(&hAgingTimer, NULL);
152 PRINT_INFO(CORECONFIG_DBG, "destroy aging timer\n");
154 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
155 if (astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs != NULL) {
156 WILC_FREE(astrLastScannedNtwrksShadow[i].pu8IEs);
157 astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs = NULL;
160 host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
161 astrLastScannedNtwrksShadow[i].pJoinParams = NULL;
163 u32LastScannedNtwrksCountShadow = 0;
168 uint32_t get_rssi_avg(tstrNetworkInfo *pstrNetworkInfo)
172 uint8_t num_rssi = (pstrNetworkInfo->strRssi.u8Full) ? NUM_RSSI : (pstrNetworkInfo->strRssi.u8Index);
174 for (i = 0; i < num_rssi; i++)
175 rssi_v += pstrNetworkInfo->strRssi.as8RSSI[i];
181 void refresh_scan(void *pUserVoid, uint8_t all, WILC_Bool bDirectScan)
183 struct WILC_WFI_priv *priv;
185 struct cfg80211_bss *bss = NULL;
189 priv = (struct WILC_WFI_priv *)pUserVoid;
190 wiphy = priv->dev->ieee80211_ptr->wiphy;
192 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
193 tstrNetworkInfo *pstrNetworkInfo;
194 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
197 if ((!pstrNetworkInfo->u8Found) || all) {
199 struct ieee80211_channel *channel;
201 if (pstrNetworkInfo != NULL) {
203 s32Freq = ieee80211_channel_to_frequency((WILC_Sint32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
204 channel = ieee80211_get_channel(wiphy, s32Freq);
206 rssi = get_rssi_avg(pstrNetworkInfo);
207 if (WILC_memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7) || bDirectScan) {
208 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
209 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
210 (size_t)pstrNetworkInfo->u16IEsLen, (((WILC_Sint32)rssi) * 100), GFP_KERNEL);
211 cfg80211_put_bss(wiphy, bss);
220 void reset_shadow_found(void *pUserVoid)
222 struct WILC_WFI_priv *priv;
224 priv = (struct WILC_WFI_priv *)pUserVoid;
225 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
226 astrLastScannedNtwrksShadow[i].u8Found = 0;
231 void update_scan_time(void *pUserVoid)
233 struct WILC_WFI_priv *priv;
235 priv = (struct WILC_WFI_priv *)pUserVoid;
236 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
237 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
241 void remove_network_from_shadow(void *pUserVoid)
243 struct WILC_WFI_priv *priv;
244 unsigned long now = jiffies;
247 priv = (struct WILC_WFI_priv *)pUserVoid;
249 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
250 if (time_after(now, astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan + (unsigned long)(SCAN_RESULT_EXPIRE))) {
251 PRINT_D(CFG80211_DBG, "Network expired in ScanShadow: %s \n", astrLastScannedNtwrksShadow[i].au8ssid);
253 if (astrLastScannedNtwrksShadow[i].pu8IEs != NULL) {
254 WILC_FREE(astrLastScannedNtwrksShadow[i].pu8IEs);
255 astrLastScannedNtwrksShadow[i].pu8IEs = NULL;
258 host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
260 for (j = i; (j < u32LastScannedNtwrksCountShadow - 1); j++) {
261 astrLastScannedNtwrksShadow[j] = astrLastScannedNtwrksShadow[j + 1];
263 u32LastScannedNtwrksCountShadow--;
267 PRINT_D(CFG80211_DBG, "Number of cached networks: %d\n", u32LastScannedNtwrksCountShadow);
268 if (u32LastScannedNtwrksCountShadow != 0)
269 WILC_TimerStart(&(hAgingTimer), AGING_TIME, pUserVoid, NULL);
271 PRINT_D(CFG80211_DBG, "No need to restart Aging timer\n");
274 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
275 void clear_duringIP(void *pUserVoid)
277 PRINT_D(GENERIC_DBG, "GO:IP Obtained , enable scan\n");
278 g_obtainingIP = WILC_FALSE;
282 int8_t is_network_in_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid)
284 struct WILC_WFI_priv *priv;
288 priv = (struct WILC_WFI_priv *)pUserVoid;
289 if (u32LastScannedNtwrksCountShadow == 0) {
290 PRINT_D(CFG80211_DBG, "Starting Aging timer\n");
291 WILC_TimerStart(&(hAgingTimer), AGING_TIME, pUserVoid, NULL);
294 /* Linear search for now */
295 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
296 if (WILC_memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
297 pstrNetworkInfo->au8bssid, 6) == 0) {
306 void add_network_to_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
308 struct WILC_WFI_priv *priv;
309 int8_t ap_found = is_network_in_shadow(pstrNetworkInfo, pUserVoid);
310 uint32_t ap_index = 0;
311 uint8_t rssi_index = 0;
312 priv = (struct WILC_WFI_priv *)pUserVoid;
314 if (u32LastScannedNtwrksCountShadow >= MAX_NUM_SCANNED_NETWORKS_SHADOW) {
315 PRINT_D(CFG80211_DBG, "Shadow network reached its maximum limit\n");
318 if (ap_found == -1) {
319 ap_index = u32LastScannedNtwrksCountShadow;
320 u32LastScannedNtwrksCountShadow++;
325 rssi_index = astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index;
326 astrLastScannedNtwrksShadow[ap_index].strRssi.as8RSSI[rssi_index++] = pstrNetworkInfo->s8rssi;
327 if (rssi_index == NUM_RSSI) {
329 astrLastScannedNtwrksShadow[ap_index].strRssi.u8Full = 1;
331 astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index = rssi_index;
333 astrLastScannedNtwrksShadow[ap_index].s8rssi = pstrNetworkInfo->s8rssi;
334 astrLastScannedNtwrksShadow[ap_index].u16CapInfo = pstrNetworkInfo->u16CapInfo;
336 astrLastScannedNtwrksShadow[ap_index].u8SsidLen = pstrNetworkInfo->u8SsidLen;
337 WILC_memcpy(astrLastScannedNtwrksShadow[ap_index].au8ssid,
338 pstrNetworkInfo->au8ssid, pstrNetworkInfo->u8SsidLen);
340 WILC_memcpy(astrLastScannedNtwrksShadow[ap_index].au8bssid,
341 pstrNetworkInfo->au8bssid, ETH_ALEN);
343 astrLastScannedNtwrksShadow[ap_index].u16BeaconPeriod = pstrNetworkInfo->u16BeaconPeriod;
344 astrLastScannedNtwrksShadow[ap_index].u8DtimPeriod = pstrNetworkInfo->u8DtimPeriod;
345 astrLastScannedNtwrksShadow[ap_index].u8channel = pstrNetworkInfo->u8channel;
347 astrLastScannedNtwrksShadow[ap_index].u16IEsLen = pstrNetworkInfo->u16IEsLen;
348 astrLastScannedNtwrksShadow[ap_index].u64Tsf = pstrNetworkInfo->u64Tsf;
350 WILC_FREE(astrLastScannedNtwrksShadow[ap_index].pu8IEs);
351 astrLastScannedNtwrksShadow[ap_index].pu8IEs =
352 (u8 *)WILC_MALLOC(pstrNetworkInfo->u16IEsLen); /* will be deallocated by the WILC_WFI_CfgScan() function */
353 WILC_memcpy(astrLastScannedNtwrksShadow[ap_index].pu8IEs,
354 pstrNetworkInfo->pu8IEs, pstrNetworkInfo->u16IEsLen);
356 astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScan = jiffies;
357 astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScanCached = jiffies;
358 astrLastScannedNtwrksShadow[ap_index].u8Found = 1;
360 host_int_freeJoinParams(astrLastScannedNtwrksShadow[ap_index].pJoinParams);
361 astrLastScannedNtwrksShadow[ap_index].pJoinParams = pJoinParams;
367 * @brief CfgScanResult
368 * @details Callback function which returns the scan results found
370 * @param[in] tenuScanEvent enuScanEvent: enum, indicating the scan event triggered, whether that is
371 * SCAN_EVENT_NETWORK_FOUND or SCAN_EVENT_DONE
372 * tstrNetworkInfo* pstrNetworkInfo: structure holding the scan results information
373 * void* pUserVoid: Private structure associated with the wireless interface
379 static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
381 struct WILC_WFI_priv *priv;
384 struct ieee80211_channel *channel;
385 WILC_Sint32 s32Error = WILC_SUCCESS;
386 struct cfg80211_bss *bss = NULL;
388 priv = (struct WILC_WFI_priv *)pUserVoid;
389 if (priv->bCfgScanning == WILC_TRUE) {
390 if (enuScanEvent == SCAN_EVENT_NETWORK_FOUND) {
391 wiphy = priv->dev->ieee80211_ptr->wiphy;
392 WILC_NULLCHECK(s32Error, wiphy);
393 if (wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC
395 ((((WILC_Sint32)pstrNetworkInfo->s8rssi) * 100) < 0
397 (((WILC_Sint32)pstrNetworkInfo->s8rssi) * 100) > 100)
399 WILC_ERRORREPORT(s32Error, WILC_FAIL);
402 if (pstrNetworkInfo != NULL) {
403 s32Freq = ieee80211_channel_to_frequency((WILC_Sint32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
404 channel = ieee80211_get_channel(wiphy, s32Freq);
406 WILC_NULLCHECK(s32Error, channel);
408 PRINT_INFO(CFG80211_DBG, "Network Info:: CHANNEL Frequency: %d, RSSI: %d, CapabilityInfo: %d,"
409 "BeaconPeriod: %d \n", channel->center_freq, (((WILC_Sint32)pstrNetworkInfo->s8rssi) * 100),
410 pstrNetworkInfo->u16CapInfo, pstrNetworkInfo->u16BeaconPeriod);
412 if (pstrNetworkInfo->bNewNetwork == WILC_TRUE) {
413 if (priv->u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
415 PRINT_D(CFG80211_DBG, "Network %s found\n", pstrNetworkInfo->au8ssid);
418 priv->u32RcvdChCount++;
422 if (pJoinParams == NULL) {
423 PRINT_INFO(CORECONFIG_DBG, ">> Something really bad happened\n");
425 add_network_to_shadow(pstrNetworkInfo, priv, pJoinParams);
427 /*P2P peers are sent to WPA supplicant and added to shadow table*/
429 if (!(WILC_memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7))) {
430 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
431 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
432 (size_t)pstrNetworkInfo->u16IEsLen, (((WILC_Sint32)pstrNetworkInfo->s8rssi) * 100), GFP_KERNEL);
433 cfg80211_put_bss(wiphy, bss);
438 PRINT_ER("Discovered networks exceeded the max limit\n");
442 /* So this network is discovered before, we'll just update its RSSI */
443 for (i = 0; i < priv->u32RcvdChCount; i++) {
444 if (WILC_memcmp(astrLastScannedNtwrksShadow[i].au8bssid, pstrNetworkInfo->au8bssid, 6) == 0) {
445 PRINT_D(CFG80211_DBG, "Update RSSI of %s \n", astrLastScannedNtwrksShadow[i].au8ssid);
447 astrLastScannedNtwrksShadow[i].s8rssi = pstrNetworkInfo->s8rssi;
448 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
454 } else if (enuScanEvent == SCAN_EVENT_DONE) {
455 PRINT_D(CFG80211_DBG, "Scan Done[%p] \n", priv->dev);
456 PRINT_D(CFG80211_DBG, "Refreshing Scan ... \n");
457 refresh_scan(priv, 1, WILC_FALSE);
459 if (priv->u32RcvdChCount > 0) {
460 PRINT_D(CFG80211_DBG, "%d Network(s) found \n", priv->u32RcvdChCount);
462 PRINT_D(CFG80211_DBG, "No networks found \n");
465 down(&(priv->hSemScanReq));
467 if (priv->pstrScanReq != NULL) {
468 cfg80211_scan_done(priv->pstrScanReq, WILC_FALSE);
469 priv->u32RcvdChCount = 0;
470 priv->bCfgScanning = WILC_FALSE;
471 priv->pstrScanReq = NULL;
473 up(&(priv->hSemScanReq));
476 /*Aborting any scan operation during mac close*/
477 else if (enuScanEvent == SCAN_EVENT_ABORTED) {
478 down(&(priv->hSemScanReq));
480 PRINT_D(CFG80211_DBG, "Scan Aborted \n");
481 if (priv->pstrScanReq != NULL) {
483 update_scan_time(priv);
484 refresh_scan(priv, 1, WILC_FALSE);
486 cfg80211_scan_done(priv->pstrScanReq, WILC_FALSE);
487 priv->bCfgScanning = WILC_FALSE;
488 priv->pstrScanReq = NULL;
490 up(&(priv->hSemScanReq));
502 * @brief WILC_WFI_Set_PMKSA
503 * @details Check if pmksa is cached and set it.
505 * @return int : Return 0 on Success
510 int WILC_WFI_Set_PMKSA(u8 *bssid, struct WILC_WFI_priv *priv)
513 WILC_Sint32 s32Error = WILC_SUCCESS;
516 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
518 if (!WILC_memcmp(bssid, priv->pmkid_list.pmkidlist[i].bssid,
520 PRINT_D(CFG80211_DBG, "PMKID successful comparison");
522 /*If bssid is found, set the values*/
523 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
525 if (s32Error != WILC_SUCCESS)
526 PRINT_ER("Error in pmkid\n");
536 int linux_wlan_set_bssid(struct net_device *wilc_netdev, uint8_t *pBSSID);
540 * @brief CfgConnectResult
542 * @param[in] tenuConnDisconnEvent enuConnDisconnEvent: Type of connection response either
543 * connection response or disconnection notification.
544 * tstrConnectInfo* pstrConnectInfo: COnnection information.
545 * u8 u8MacStatus: Mac Status from firmware
546 * tstrDisconnectNotifInfo* pstrDisconnectNotifInfo: Disconnection Notification
547 * void* pUserVoid: Private data associated with wireless interface
555 static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent,
556 tstrConnectInfo *pstrConnectInfo,
558 tstrDisconnectNotifInfo *pstrDisconnectNotifInfo,
561 struct WILC_WFI_priv *priv;
562 struct net_device *dev;
564 tstrWILC_WFIDrv *pstrWFIDrv;
566 u8 NullBssid[ETH_ALEN] = {0};
569 priv = (struct WILC_WFI_priv *)pUserVoid;
572 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
575 if (enuConnDisconnEvent == CONN_DISCONN_EVENT_CONN_RESP) {
577 WILC_Uint16 u16ConnectStatus = WLAN_STATUS_SUCCESS;
579 u16ConnectStatus = pstrConnectInfo->u16ConnectStatus;
581 PRINT_D(CFG80211_DBG, " Connection response received = %d\n", u8MacStatus);
583 if ((u8MacStatus == MAC_DISCONNECTED) &&
584 (pstrConnectInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
585 /* The case here is that our station was waiting for association response frame and has just received it containing status code
586 * = SUCCESSFUL_STATUSCODE, while mac status is MAC_DISCONNECTED (which means something wrong happened) */
587 u16ConnectStatus = WLAN_STATUS_UNSPECIFIED_FAILURE;
588 linux_wlan_set_bssid(priv->dev, NullBssid);
589 WILC_memset(u8ConnectedSSID, 0, ETH_ALEN);
592 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
594 if (!pstrWFIDrv->u8P2PConnect)
595 u8WLANChannel = INVALID_CHANNEL;
598 PRINT_ER("Unspecified failure: Connection status %d : MAC status = %d \n", u16ConnectStatus, u8MacStatus);
601 if (u16ConnectStatus == WLAN_STATUS_SUCCESS) {
602 WILC_Bool bNeedScanRefresh = WILC_FALSE;
605 PRINT_INFO(CFG80211_DBG, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo->au8bssid[0],
606 pstrConnectInfo->au8bssid[1], pstrConnectInfo->au8bssid[2], pstrConnectInfo->au8bssid[3], pstrConnectInfo->au8bssid[4], pstrConnectInfo->au8bssid[5]);
607 WILC_memcpy(priv->au8AssociatedBss, pstrConnectInfo->au8bssid, ETH_ALEN);
609 /* set bssid in frame filter */
610 /* linux_wlan_set_bssid(dev,pstrConnectInfo->au8bssid); */
612 /* BugID_4209: if this network has expired in the scan results in the above nl80211 layer, refresh them here by calling
613 * cfg80211_inform_bss() with the last Scan results before calling cfg80211_connect_result() to avoid
614 * Linux kernel warning generated at the nl80211 layer */
616 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
617 if (WILC_memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
618 pstrConnectInfo->au8bssid, ETH_ALEN) == 0) {
619 unsigned long now = jiffies;
622 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScanCached + (unsigned long)(nl80211_SCAN_RESULT_EXPIRE - (1 * HZ)))) {
623 bNeedScanRefresh = WILC_TRUE;
630 if (bNeedScanRefresh == WILC_TRUE) {
631 /* RefreshScanResult(priv); */
633 /*Also, refrsh DIRECT- results if */
634 refresh_scan(priv, 1, WILC_TRUE);
641 PRINT_D(CFG80211_DBG, "Association request info elements length = %zu\n", pstrConnectInfo->ReqIEsLen);
643 PRINT_D(CFG80211_DBG, "Association response info elements length = %d\n", pstrConnectInfo->u16RespIEsLen);
645 cfg80211_connect_result(dev, pstrConnectInfo->au8bssid,
646 pstrConnectInfo->pu8ReqIEs, pstrConnectInfo->ReqIEsLen,
647 pstrConnectInfo->pu8RespIEs, pstrConnectInfo->u16RespIEsLen,
648 u16ConnectStatus, GFP_KERNEL); /* TODO: mostafa: u16ConnectStatus to */
649 /* be replaced by pstrConnectInfo->u16ConnectStatus */
650 } else if (enuConnDisconnEvent == CONN_DISCONN_EVENT_DISCONN_NOTIF) {
651 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
652 g_obtainingIP = WILC_FALSE;
654 PRINT_ER("Received MAC_DISCONNECTED from firmware with reason %d on dev [%p]\n",
655 pstrDisconnectNotifInfo->u16reason, priv->dev);
656 u8P2Plocalrandom = 0x01;
657 u8P2Precvrandom = 0x00;
658 bWilc_ie = WILC_FALSE;
659 WILC_memset(priv->au8AssociatedBss, 0, ETH_ALEN);
660 linux_wlan_set_bssid(priv->dev, NullBssid);
661 WILC_memset(u8ConnectedSSID, 0, ETH_ALEN);
664 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
666 if (!pstrWFIDrv->u8P2PConnect)
667 u8WLANChannel = INVALID_CHANNEL;
670 /*Incase "P2P CLIENT Connected" send deauthentication reason by 3 to force the WPA_SUPPLICANT to directly change
671 * virtual interface to station*/
672 if ((pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) {
673 pstrDisconnectNotifInfo->u16reason = 3;
676 /*Incase "P2P CLIENT during connection(not connected)" send deauthentication reason by 1 to force the WPA_SUPPLICANT
677 * to scan again and retry the connection*/
678 else if ((!pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) {
679 pstrDisconnectNotifInfo->u16reason = 1;
681 cfg80211_disconnected(dev, pstrDisconnectNotifInfo->u16reason, pstrDisconnectNotifInfo->ie,
682 pstrDisconnectNotifInfo->ie_len, GFP_KERNEL);
690 * @brief WILC_WFI_CfgSetChannel
691 * @details Set channel for a given wireless interface. Some devices
692 * may support multi-channel operation (by channel hopping) so cfg80211
693 * doesn't verify much. Note, however, that the passed netdev may be
694 * %NULL as well if the user requested changing the channel for the
695 * device itself, or for a monitor interface.
697 * @return int : Return 0 on Success
702 static int WILC_WFI_CfgSetChannel(struct wiphy *wiphy,
703 struct cfg80211_chan_def *chandef)
706 WILC_Uint32 channelnum = 0;
707 struct WILC_WFI_priv *priv;
708 WILC_Sint32 s32Error = WILC_SUCCESS;
709 priv = wiphy_priv(wiphy);
711 channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq);
712 PRINT_D(CFG80211_DBG, "Setting channel %d with frequency %d\n", channelnum, chandef->chan->center_freq);
714 u8CurrChannel = channelnum;
715 s32Error = host_int_set_mac_chnl_num(priv->hWILCWFIDrv, channelnum);
717 if (s32Error != WILC_SUCCESS)
718 PRINT_ER("Error in setting channel %d\n", channelnum);
724 * @brief WILC_WFI_CfgScan
725 * @details Request to do a scan. If returning zero, the scan request is given
726 * the driver, and will be valid until passed to cfg80211_scan_done().
727 * For scan results, call cfg80211_inform_bss(); you can call this outside
728 * the scan/scan_done bracket too.
730 * @return int : Return 0 on Success
737 * kernel version 3.8.8 supported
738 * tony, sswd, WILC-KR, 2013-10-29
740 static int WILC_WFI_CfgScan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
742 struct WILC_WFI_priv *priv;
744 WILC_Sint32 s32Error = WILC_SUCCESS;
745 u8 au8ScanChanList[MAX_NUM_SCANNED_NETWORKS];
746 tstrHiddenNetwork strHiddenNetwork;
748 priv = wiphy_priv(wiphy);
753 /*BugID_4800: if in AP mode, return.*/
754 /*This check is to handle the situation when user*/
755 /*requests "create group" during a running scan*/
756 /* host_int_set_wfi_drv_handler(priv->hWILCWFIDrv); */
758 if (priv->dev->ieee80211_ptr->iftype == NL80211_IFTYPE_AP) {
759 PRINT_D(GENERIC_DBG, "Required scan while in AP mode");
762 #endif /* end of if 0 */
763 priv->pstrScanReq = request;
765 priv->u32RcvdChCount = 0;
767 host_int_set_wfi_drv_handler((WILC_Uint32)priv->hWILCWFIDrv);
770 reset_shadow_found(priv);
772 priv->bCfgScanning = WILC_TRUE;
773 if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
775 for (i = 0; i < request->n_channels; i++) {
776 au8ScanChanList[i] = (u8)ieee80211_frequency_to_channel(request->channels[i]->center_freq);
777 PRINT_INFO(CFG80211_DBG, "ScanChannel List[%d] = %d,", i, au8ScanChanList[i]);
780 PRINT_D(CFG80211_DBG, "Requested num of scan channel %d\n", request->n_channels);
781 PRINT_D(CFG80211_DBG, "Scan Request IE len = %zu\n", request->ie_len);
783 PRINT_D(CFG80211_DBG, "Number of SSIDs %d\n", request->n_ssids);
785 if (request->n_ssids >= 1) {
788 strHiddenNetwork.pstrHiddenNetworkInfo = WILC_MALLOC(request->n_ssids * sizeof(tstrHiddenNetwork));
789 strHiddenNetwork.u8ssidnum = request->n_ssids;
793 for (i = 0; i < request->n_ssids; i++) {
795 if (request->ssids[i].ssid != NULL && request->ssids[i].ssid_len != 0) {
796 strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid = WILC_MALLOC(request->ssids[i].ssid_len);
797 WILC_memcpy(strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, request->ssids[i].ssid, request->ssids[i].ssid_len);
798 strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen = request->ssids[i].ssid_len;
800 PRINT_D(CFG80211_DBG, "Received one NULL SSID \n");
801 strHiddenNetwork.u8ssidnum -= 1;
804 PRINT_D(CFG80211_DBG, "Trigger Scan Request \n");
805 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
806 au8ScanChanList, request->n_channels,
807 (const u8 *)request->ie, request->ie_len,
808 CfgScanResult, (void *)priv, &strHiddenNetwork);
810 PRINT_D(CFG80211_DBG, "Trigger Scan Request \n");
811 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
812 au8ScanChanList, request->n_channels,
813 (const u8 *)request->ie, request->ie_len,
814 CfgScanResult, (void *)priv, NULL);
818 PRINT_ER("Requested num of scanned channels is greater than the max, supported"
822 if (s32Error != WILC_SUCCESS) {
824 PRINT_WRN(CFG80211_DBG, "Device is busy: Error(%d)\n", s32Error);
831 * @brief WILC_WFI_CfgConnect
832 * @details Connect to the ESS with the specified parameters. When connected,
833 * call cfg80211_connect_result() with status code %WLAN_STATUS_SUCCESS.
834 * If the connection fails for some reason, call cfg80211_connect_result()
835 * with the status from the AP.
837 * @return int : Return 0 on Success
842 static int WILC_WFI_CfgConnect(struct wiphy *wiphy, struct net_device *dev,
843 struct cfg80211_connect_params *sme)
845 WILC_Sint32 s32Error = WILC_SUCCESS;
847 /* SECURITY_T tenuSecurity_t = NO_SECURITY; */
848 u8 u8security = NO_ENCRYPT;
849 AUTHTYPE_T tenuAuth_type = ANY;
850 WILC_Char *pcgroup_encrypt_val;
851 WILC_Char *pccipher_group;
852 WILC_Char *pcwpa_version;
854 struct WILC_WFI_priv *priv;
855 tstrWILC_WFIDrv *pstrWFIDrv;
856 tstrNetworkInfo *pstrNetworkInfo = NULL;
860 priv = wiphy_priv(wiphy);
861 pstrWFIDrv = (tstrWILC_WFIDrv *)(priv->hWILCWFIDrv);
863 host_int_set_wfi_drv_handler((WILC_Uint32)priv->hWILCWFIDrv);
865 /* host_int_set_wfi_drv_handler((WILC_Uint32)priv->hWILCWFIDrv); */
866 PRINT_D(CFG80211_DBG, "Connecting to SSID [%s] on netdev [%p] host if [%x]\n", sme->ssid, dev, (WILC_Uint32)priv->hWILCWFIDrv);
868 if (!(WILC_strncmp(sme->ssid, "DIRECT-", 7))) {
869 PRINT_D(CFG80211_DBG, "Connected to Direct network,OBSS disabled\n");
870 pstrWFIDrv->u8P2PConnect = 1;
872 pstrWFIDrv->u8P2PConnect = 0;
874 PRINT_INFO(CFG80211_DBG, "Required SSID = %s\n , AuthType = %d \n", sme->ssid, sme->auth_type);
876 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
877 if ((sme->ssid_len == astrLastScannedNtwrksShadow[i].u8SsidLen) &&
878 WILC_memcmp(astrLastScannedNtwrksShadow[i].au8ssid,
880 sme->ssid_len) == 0) {
881 PRINT_INFO(CFG80211_DBG, "Network with required SSID is found %s\n", sme->ssid);
882 if (sme->bssid == NULL) {
883 /* BSSID is not passed from the user, so decision of matching
884 * is done by SSID only */
885 PRINT_INFO(CFG80211_DBG, "BSSID is not passed from the user\n");
888 /* BSSID is also passed from the user, so decision of matching
889 * should consider also this passed BSSID */
890 if (WILC_memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
893 PRINT_INFO(CFG80211_DBG, "BSSID is passed from the user and matched\n");
900 if (i < u32LastScannedNtwrksCountShadow) {
901 PRINT_D(CFG80211_DBG, "Required bss is in scan results\n");
903 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
905 PRINT_INFO(CFG80211_DBG, "network BSSID to be associated: %x%x%x%x%x%x\n",
906 pstrNetworkInfo->au8bssid[0], pstrNetworkInfo->au8bssid[1],
907 pstrNetworkInfo->au8bssid[2], pstrNetworkInfo->au8bssid[3],
908 pstrNetworkInfo->au8bssid[4], pstrNetworkInfo->au8bssid[5]);
911 if (u32LastScannedNtwrksCountShadow == 0)
912 PRINT_D(CFG80211_DBG, "No Scan results yet\n");
914 PRINT_D(CFG80211_DBG, "Required bss not in scan results: Error(%d)\n", s32Error);
919 priv->WILC_WFI_wep_default = 0;
920 WILC_memset(priv->WILC_WFI_wep_key, 0, sizeof(priv->WILC_WFI_wep_key));
921 WILC_memset(priv->WILC_WFI_wep_key_len, 0, sizeof(priv->WILC_WFI_wep_key_len));
923 PRINT_INFO(CFG80211_DBG, "sme->crypto.wpa_versions=%x\n", sme->crypto.wpa_versions);
924 PRINT_INFO(CFG80211_DBG, "sme->crypto.cipher_group=%x\n", sme->crypto.cipher_group);
926 PRINT_INFO(CFG80211_DBG, "sme->crypto.n_ciphers_pairwise=%d\n", sme->crypto.n_ciphers_pairwise);
929 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++)
930 PRINT_D(CORECONFIG_DBG, "sme->crypto.ciphers_pairwise[%d]=%x\n", i, sme->crypto.ciphers_pairwise[i]);
933 if (sme->crypto.cipher_group != NO_ENCRYPT) {
934 /* To determine the u8security value, first we check the group cipher suite then {in case of WPA or WPA2}
935 * we will add to it the pairwise cipher suite(s) */
936 pcwpa_version = "Default";
937 PRINT_D(CORECONFIG_DBG, ">> sme->crypto.wpa_versions: %x\n", sme->crypto.wpa_versions);
938 /* case NL80211_WPA_VERSION_1: */
939 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) {
940 /* tenuSecurity_t = WEP_40; */
941 u8security = ENCRYPT_ENABLED | WEP;
942 pcgroup_encrypt_val = "WEP40";
943 pccipher_group = "WLAN_CIPHER_SUITE_WEP40";
944 PRINT_INFO(CFG80211_DBG, "WEP Default Key Idx = %d\n", sme->key_idx);
947 for (i = 0; i < sme->key_len; i++)
948 PRINT_D(CORECONFIG_DBG, "WEP Key Value[%d] = %d\n", i, sme->key[i]);
950 priv->WILC_WFI_wep_default = sme->key_idx;
951 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
952 WILC_memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
955 g_key_wep_params.key_len = sme->key_len;
956 g_key_wep_params.key = WILC_MALLOC(sme->key_len);
957 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
958 g_key_wep_params.key_idx = sme->key_idx;
959 g_wep_keys_saved = WILC_TRUE;
961 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
962 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
963 } else if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104) {
964 /* tenuSecurity_t = WEP_104; */
965 u8security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
966 pcgroup_encrypt_val = "WEP104";
967 pccipher_group = "WLAN_CIPHER_SUITE_WEP104";
969 priv->WILC_WFI_wep_default = sme->key_idx;
970 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
971 WILC_memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
974 g_key_wep_params.key_len = sme->key_len;
975 g_key_wep_params.key = WILC_MALLOC(sme->key_len);
976 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
977 g_key_wep_params.key_idx = sme->key_idx;
978 g_wep_keys_saved = WILC_TRUE;
980 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
981 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
982 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) {
983 /* case NL80211_WPA_VERSION_2: */
984 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
985 /* tenuSecurity_t = WPA2_TKIP; */
986 u8security = ENCRYPT_ENABLED | WPA2 | TKIP;
987 pcgroup_encrypt_val = "WPA2_TKIP";
988 pccipher_group = "TKIP";
989 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
990 /* tenuSecurity_t = WPA2_AES; */
991 u8security = ENCRYPT_ENABLED | WPA2 | AES;
992 pcgroup_encrypt_val = "WPA2_AES";
993 pccipher_group = "AES";
995 pcwpa_version = "WPA_VERSION_2";
996 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) {
997 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
998 /* tenuSecurity_t = WPA_TKIP; */
999 u8security = ENCRYPT_ENABLED | WPA | TKIP;
1000 pcgroup_encrypt_val = "WPA_TKIP";
1001 pccipher_group = "TKIP";
1002 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
1003 /* tenuSecurity_t = WPA_AES; */
1004 u8security = ENCRYPT_ENABLED | WPA | AES;
1005 pcgroup_encrypt_val = "WPA_AES";
1006 pccipher_group = "AES";
1009 pcwpa_version = "WPA_VERSION_1";
1013 s32Error = -ENOTSUPP;
1014 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
1021 /* After we set the u8security value from checking the group cipher suite, {in case of WPA or WPA2} we will
1022 * add to it the pairwise cipher suite(s) */
1023 if ((sme->crypto.wpa_versions & NL80211_WPA_VERSION_1)
1024 || (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)) {
1025 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) {
1026 if (sme->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP) {
1027 u8security = u8security | TKIP;
1028 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
1029 u8security = u8security | AES;
1034 PRINT_D(CFG80211_DBG, "Adding key with cipher group = %x\n", sme->crypto.cipher_group);
1036 PRINT_D(CFG80211_DBG, "Authentication Type = %d\n", sme->auth_type);
1037 switch (sme->auth_type) {
1038 case NL80211_AUTHTYPE_OPEN_SYSTEM:
1039 PRINT_D(CFG80211_DBG, "In OPEN SYSTEM\n");
1040 tenuAuth_type = OPEN_SYSTEM;
1043 case NL80211_AUTHTYPE_SHARED_KEY:
1044 tenuAuth_type = SHARED_KEY;
1045 PRINT_D(CFG80211_DBG, "In SHARED KEY\n");
1049 PRINT_D(CFG80211_DBG, "Automatic Authentation type = %d\n", sme->auth_type);
1053 /* ai: key_mgmt: enterprise case */
1054 if (sme->crypto.n_akm_suites) {
1055 switch (sme->crypto.akm_suites[0]) {
1056 case WLAN_AKM_SUITE_8021X:
1057 tenuAuth_type = IEEE8021;
1066 PRINT_INFO(CFG80211_DBG, "Required Channel = %d\n", pstrNetworkInfo->u8channel);
1068 PRINT_INFO(CFG80211_DBG, "Group encryption value = %s\n Cipher Group = %s\n WPA version = %s\n",
1069 pcgroup_encrypt_val, pccipher_group, pcwpa_version);
1072 u8CurrChannel = pstrNetworkInfo->u8channel;
1074 if (!pstrWFIDrv->u8P2PConnect) {
1075 u8WLANChannel = pstrNetworkInfo->u8channel;
1078 linux_wlan_set_bssid(dev, pstrNetworkInfo->au8bssid);
1080 s32Error = host_int_set_join_req(priv->hWILCWFIDrv, pstrNetworkInfo->au8bssid, sme->ssid,
1081 sme->ssid_len, sme->ie, sme->ie_len,
1082 CfgConnectResult, (void *)priv, u8security,
1083 tenuAuth_type, pstrNetworkInfo->u8channel,
1084 pstrNetworkInfo->pJoinParams);
1085 if (s32Error != WILC_SUCCESS) {
1086 PRINT_ER("host_int_set_join_req(): Error(%d) \n", s32Error);
1098 * @brief WILC_WFI_disconnect
1099 * @details Disconnect from the BSS/ESS.
1101 * @return int : Return 0 on Success
1106 static int WILC_WFI_disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code)
1108 WILC_Sint32 s32Error = WILC_SUCCESS;
1109 struct WILC_WFI_priv *priv;
1111 tstrWILC_WFIDrv *pstrWFIDrv;
1113 uint8_t NullBssid[ETH_ALEN] = {0};
1115 priv = wiphy_priv(wiphy);
1118 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
1120 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
1121 if (!pstrWFIDrv->u8P2PConnect)
1122 u8WLANChannel = INVALID_CHANNEL;
1124 linux_wlan_set_bssid(priv->dev, NullBssid);
1126 PRINT_D(CFG80211_DBG, "Disconnecting with reason code(%d)\n", reason_code);
1128 u8P2Plocalrandom = 0x01;
1129 u8P2Precvrandom = 0x00;
1130 bWilc_ie = WILC_FALSE;
1132 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
1135 s32Error = host_int_disconnect(priv->hWILCWFIDrv, reason_code);
1136 if (s32Error != WILC_SUCCESS) {
1137 PRINT_ER("Error in disconnecting: Error(%d)\n", s32Error);
1145 * @brief WILC_WFI_add_key
1146 * @details Add a key with the given parameters. @mac_addr will be %NULL
1147 * when adding a group key.
1148 * @param[in] key : key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key, 8-byte Rx Mic Key
1149 * @return int : Return 0 on Success
1154 static int WILC_WFI_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1156 const u8 *mac_addr, struct key_params *params)
1159 WILC_Sint32 s32Error = WILC_SUCCESS, KeyLen = params->key_len;
1161 struct WILC_WFI_priv *priv;
1162 const u8 *pu8RxMic = NULL;
1163 const u8 *pu8TxMic = NULL;
1164 u8 u8mode = NO_ENCRYPT;
1165 #ifdef WILC_AP_EXTERNAL_MLME
1166 u8 u8gmode = NO_ENCRYPT;
1167 u8 u8pmode = NO_ENCRYPT;
1168 AUTHTYPE_T tenuAuth_type = ANY;
1171 priv = wiphy_priv(wiphy);
1173 PRINT_D(CFG80211_DBG, "Adding key with cipher suite = %x\n", params->cipher);
1176 PRINT_D(CFG80211_DBG, "%x %x %d\n", (WILC_Uint32)wiphy, (WILC_Uint32)netdev, key_index);
1178 PRINT_D(CFG80211_DBG, "key %x %x %x\n", params->key[0],
1183 switch (params->cipher) {
1184 case WLAN_CIPHER_SUITE_WEP40:
1185 case WLAN_CIPHER_SUITE_WEP104:
1186 #ifdef WILC_AP_EXTERNAL_MLME
1187 if (priv->wdev->iftype == NL80211_IFTYPE_AP) {
1189 priv->WILC_WFI_wep_default = key_index;
1190 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
1191 WILC_memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
1193 PRINT_D(CFG80211_DBG, "Adding AP WEP Default key Idx = %d\n", key_index);
1194 PRINT_D(CFG80211_DBG, "Adding AP WEP Key len= %d\n", params->key_len);
1196 for (i = 0; i < params->key_len; i++)
1197 PRINT_D(CFG80211_DBG, "WEP AP key val[%d] = %x\n", i, params->key[i]);
1199 tenuAuth_type = OPEN_SYSTEM;
1201 if (params->cipher == WLAN_CIPHER_SUITE_WEP40)
1202 u8mode = ENCRYPT_ENABLED | WEP;
1204 u8mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
1206 host_int_add_wep_key_bss_ap(priv->hWILCWFIDrv, params->key, params->key_len, key_index, u8mode, tenuAuth_type);
1210 if (WILC_memcmp(params->key, priv->WILC_WFI_wep_key[key_index], params->key_len)) {
1211 priv->WILC_WFI_wep_default = key_index;
1212 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
1213 WILC_memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
1215 PRINT_D(CFG80211_DBG, "Adding WEP Default key Idx = %d\n", key_index);
1216 PRINT_D(CFG80211_DBG, "Adding WEP Key length = %d\n", params->key_len);
1218 for (i = 0; i < params->key_len; i++)
1219 PRINT_INFO(CFG80211_DBG, "WEP key value[%d] = %d\n", i, params->key[i]);
1221 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, params->key, params->key_len, key_index);
1226 case WLAN_CIPHER_SUITE_TKIP:
1227 case WLAN_CIPHER_SUITE_CCMP:
1228 #ifdef WILC_AP_EXTERNAL_MLME
1229 if (priv->wdev->iftype == NL80211_IFTYPE_AP || priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) {
1231 if (priv->wilc_gtk[key_index] == NULL) {
1232 priv->wilc_gtk[key_index] = (struct wilc_wfi_key *)WILC_MALLOC(sizeof(struct wilc_wfi_key));
1233 priv->wilc_gtk[key_index]->key = NULL;
1234 priv->wilc_gtk[key_index]->seq = NULL;
1237 if (priv->wilc_ptk[key_index] == NULL) {
1238 priv->wilc_ptk[key_index] = (struct wilc_wfi_key *)WILC_MALLOC(sizeof(struct wilc_wfi_key));
1239 priv->wilc_ptk[key_index]->key = NULL;
1240 priv->wilc_ptk[key_index]->seq = NULL;
1247 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1248 u8gmode = ENCRYPT_ENABLED | WPA | TKIP;
1250 u8gmode = ENCRYPT_ENABLED | WPA2 | AES;
1252 priv->wilc_groupkey = u8gmode;
1254 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1256 pu8TxMic = params->key + 24;
1257 pu8RxMic = params->key + 16;
1258 KeyLen = params->key_len - 16;
1260 /* if there has been previous allocation for the same index through its key, free that memory and allocate again*/
1261 if (priv->wilc_gtk[key_index]->key)
1262 WILC_FREE(priv->wilc_gtk[key_index]->key);
1264 priv->wilc_gtk[key_index]->key = (u8 *)WILC_MALLOC(params->key_len);
1265 WILC_memcpy(priv->wilc_gtk[key_index]->key, params->key, params->key_len);
1267 /* if there has been previous allocation for the same index through its seq, free that memory and allocate again*/
1268 if (priv->wilc_gtk[key_index]->seq)
1269 WILC_FREE(priv->wilc_gtk[key_index]->seq);
1271 if ((params->seq_len) > 0) {
1272 priv->wilc_gtk[key_index]->seq = (u8 *)WILC_MALLOC(params->seq_len);
1273 WILC_memcpy(priv->wilc_gtk[key_index]->seq, params->seq, params->seq_len);
1276 priv->wilc_gtk[key_index]->cipher = params->cipher;
1277 priv->wilc_gtk[key_index]->key_len = params->key_len;
1278 priv->wilc_gtk[key_index]->seq_len = params->seq_len;
1281 for (i = 0; i < params->key_len; i++)
1282 PRINT_INFO(CFG80211_DBG, "Adding group key value[%d] = %x\n", i, params->key[i]);
1283 for (i = 0; i < params->seq_len; i++)
1284 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1288 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1289 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, AP_MODE, u8gmode);
1292 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]);
1294 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1295 u8pmode = ENCRYPT_ENABLED | WPA | TKIP;
1297 u8pmode = priv->wilc_groupkey | AES;
1300 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1302 pu8TxMic = params->key + 24;
1303 pu8RxMic = params->key + 16;
1304 KeyLen = params->key_len - 16;
1307 if (priv->wilc_ptk[key_index]->key)
1308 WILC_FREE(priv->wilc_ptk[key_index]->key);
1310 priv->wilc_ptk[key_index]->key = (u8 *)WILC_MALLOC(params->key_len);
1312 if (priv->wilc_ptk[key_index]->seq)
1313 WILC_FREE(priv->wilc_ptk[key_index]->seq);
1315 if ((params->seq_len) > 0)
1316 priv->wilc_ptk[key_index]->seq = (u8 *)WILC_MALLOC(params->seq_len);
1319 for (i = 0; i < params->key_len; i++)
1320 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %x\n", i, params->key[i]);
1322 for (i = 0; i < params->seq_len; i++)
1323 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1326 WILC_memcpy(priv->wilc_ptk[key_index]->key, params->key, params->key_len);
1328 if ((params->seq_len) > 0)
1329 WILC_memcpy(priv->wilc_ptk[key_index]->seq, params->seq, params->seq_len);
1331 priv->wilc_ptk[key_index]->cipher = params->cipher;
1332 priv->wilc_ptk[key_index]->key_len = params->key_len;
1333 priv->wilc_ptk[key_index]->seq_len = params->seq_len;
1335 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1336 pu8RxMic, pu8TxMic, AP_MODE, u8pmode, key_index);
1346 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1347 /* swap the tx mic by rx mic */
1348 pu8RxMic = params->key + 24;
1349 pu8TxMic = params->key + 16;
1350 KeyLen = params->key_len - 16;
1354 /*save keys only on interface 0 (wifi interface)*/
1355 if (!g_gtk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1356 g_add_gtk_key_params.key_idx = key_index;
1357 g_add_gtk_key_params.pairwise = pairwise;
1359 g_add_gtk_key_params.mac_addr = NULL;
1361 g_add_gtk_key_params.mac_addr = WILC_MALLOC(ETH_ALEN);
1362 memcpy(g_add_gtk_key_params.mac_addr, mac_addr, ETH_ALEN);
1364 g_key_gtk_params.key_len = params->key_len;
1365 g_key_gtk_params.seq_len = params->seq_len;
1366 g_key_gtk_params.key = WILC_MALLOC(params->key_len);
1367 memcpy(g_key_gtk_params.key, params->key, params->key_len);
1368 if (params->seq_len > 0) {
1369 g_key_gtk_params.seq = WILC_MALLOC(params->seq_len);
1370 memcpy(g_key_gtk_params.seq, params->seq, params->seq_len);
1372 g_key_gtk_params.cipher = params->cipher;
1374 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_gtk_params.key[0],
1375 g_key_gtk_params.key[1],
1376 g_key_gtk_params.key[2]);
1377 g_gtk_keys_saved = WILC_TRUE;
1380 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1381 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, STATION_MODE, u8mode);
1382 /* host_int_add_tx_gtk(priv->hWILCWFIDrv,params->key_len,params->key,key_index); */
1384 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1385 /* swap the tx mic by rx mic */
1386 pu8RxMic = params->key + 24;
1387 pu8TxMic = params->key + 16;
1388 KeyLen = params->key_len - 16;
1392 /*save keys only on interface 0 (wifi interface)*/
1393 if (!g_ptk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1394 g_add_ptk_key_params.key_idx = key_index;
1395 g_add_ptk_key_params.pairwise = pairwise;
1397 g_add_ptk_key_params.mac_addr = NULL;
1399 g_add_ptk_key_params.mac_addr = WILC_MALLOC(ETH_ALEN);
1400 memcpy(g_add_ptk_key_params.mac_addr, mac_addr, ETH_ALEN);
1402 g_key_ptk_params.key_len = params->key_len;
1403 g_key_ptk_params.seq_len = params->seq_len;
1404 g_key_ptk_params.key = WILC_MALLOC(params->key_len);
1405 memcpy(g_key_ptk_params.key, params->key, params->key_len);
1406 if (params->seq_len > 0) {
1407 g_key_ptk_params.seq = WILC_MALLOC(params->seq_len);
1408 memcpy(g_key_ptk_params.seq, params->seq, params->seq_len);
1410 g_key_ptk_params.cipher = params->cipher;
1412 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_ptk_params.key[0],
1413 g_key_ptk_params.key[1],
1414 g_key_ptk_params.key[2]);
1415 g_ptk_keys_saved = WILC_TRUE;
1418 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1419 pu8RxMic, pu8TxMic, STATION_MODE, u8mode, key_index);
1420 PRINT_D(CFG80211_DBG, "Adding pairwise key\n");
1422 for (i = 0; i < params->key_len; i++)
1423 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %d\n", i, params->key[i]);
1430 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
1431 s32Error = -ENOTSUPP;
1439 * @brief WILC_WFI_del_key
1440 * @details Remove a key given the @mac_addr (%NULL for a group key)
1441 * and @key_index, return -ENOENT if the key doesn't exist.
1443 * @return int : Return 0 on Success
1448 static int WILC_WFI_del_key(struct wiphy *wiphy, struct net_device *netdev,
1453 struct WILC_WFI_priv *priv;
1454 WILC_Sint32 s32Error = WILC_SUCCESS;
1456 priv = wiphy_priv(wiphy);
1459 /*delete saved keys, if any*/
1460 if (netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1461 g_ptk_keys_saved = WILC_FALSE;
1462 g_gtk_keys_saved = WILC_FALSE;
1463 g_wep_keys_saved = WILC_FALSE;
1465 /*Delete saved WEP keys params, if any*/
1466 if (g_key_wep_params.key != NULL) {
1467 WILC_FREE(g_key_wep_params.key);
1468 g_key_wep_params.key = NULL;
1471 /*freeing memory allocated by "wilc_gtk" and "wilc_ptk" in "WILC_WIFI_ADD_KEY"*/
1473 #ifdef WILC_AP_EXTERNAL_MLME
1474 if ((priv->wilc_gtk[key_index]) != NULL) {
1476 if (priv->wilc_gtk[key_index]->key != NULL) {
1478 WILC_FREE(priv->wilc_gtk[key_index]->key);
1479 priv->wilc_gtk[key_index]->key = NULL;
1481 if (priv->wilc_gtk[key_index]->seq) {
1483 WILC_FREE(priv->wilc_gtk[key_index]->seq);
1484 priv->wilc_gtk[key_index]->seq = NULL;
1487 WILC_FREE(priv->wilc_gtk[key_index]);
1488 priv->wilc_gtk[key_index] = NULL;
1492 if ((priv->wilc_ptk[key_index]) != NULL) {
1494 if (priv->wilc_ptk[key_index]->key) {
1496 WILC_FREE(priv->wilc_ptk[key_index]->key);
1497 priv->wilc_ptk[key_index]->key = NULL;
1499 if (priv->wilc_ptk[key_index]->seq) {
1501 WILC_FREE(priv->wilc_ptk[key_index]->seq);
1502 priv->wilc_ptk[key_index]->seq = NULL;
1504 WILC_FREE(priv->wilc_ptk[key_index]);
1505 priv->wilc_ptk[key_index] = NULL;
1509 /*Delete saved PTK and GTK keys params, if any*/
1510 if (g_key_ptk_params.key != NULL) {
1511 WILC_FREE(g_key_ptk_params.key);
1512 g_key_ptk_params.key = NULL;
1514 if (g_key_ptk_params.seq != NULL) {
1515 WILC_FREE(g_key_ptk_params.seq);
1516 g_key_ptk_params.seq = NULL;
1519 if (g_key_gtk_params.key != NULL) {
1520 WILC_FREE(g_key_gtk_params.key);
1521 g_key_gtk_params.key = NULL;
1523 if (g_key_gtk_params.seq != NULL) {
1524 WILC_FREE(g_key_gtk_params.seq);
1525 g_key_gtk_params.seq = NULL;
1528 /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/
1529 Set_machw_change_vir_if(WILC_FALSE);
1532 if (key_index >= 0 && key_index <= 3) {
1533 WILC_memset(priv->WILC_WFI_wep_key[key_index], 0, priv->WILC_WFI_wep_key_len[key_index]);
1534 priv->WILC_WFI_wep_key_len[key_index] = 0;
1536 PRINT_D(CFG80211_DBG, "Removing WEP key with index = %d\n", key_index);
1537 host_int_remove_wep_key(priv->hWILCWFIDrv, key_index);
1539 PRINT_D(CFG80211_DBG, "Removing all installed keys\n");
1540 host_int_remove_key(priv->hWILCWFIDrv, mac_addr);
1547 * @brief WILC_WFI_get_key
1548 * @details Get information about the key with the given parameters.
1549 * @mac_addr will be %NULL when requesting information for a group
1550 * key. All pointers given to the @callback function need not be valid
1551 * after it returns. This function should return an error if it is
1552 * not possible to retrieve the key, -ENOENT if it doesn't exist.
1554 * @return int : Return 0 on Success
1559 static int WILC_WFI_get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1561 const u8 *mac_addr, void *cookie, void (*callback)(void *cookie, struct key_params *))
1564 WILC_Sint32 s32Error = WILC_SUCCESS;
1566 struct WILC_WFI_priv *priv;
1567 struct key_params key_params;
1569 priv = wiphy_priv(wiphy);
1574 PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index);
1576 key_params.key = priv->wilc_gtk[key_index]->key;
1577 key_params.cipher = priv->wilc_gtk[key_index]->cipher;
1578 key_params.key_len = priv->wilc_gtk[key_index]->key_len;
1579 key_params.seq = priv->wilc_gtk[key_index]->seq;
1580 key_params.seq_len = priv->wilc_gtk[key_index]->seq_len;
1582 for (i = 0; i < key_params.key_len; i++)
1583 PRINT_INFO(CFG80211_DBG, "Retrieved key value %x\n", key_params.key[i]);
1586 PRINT_D(CFG80211_DBG, "Getting pairwise key\n");
1588 key_params.key = priv->wilc_ptk[key_index]->key;
1589 key_params.cipher = priv->wilc_ptk[key_index]->cipher;
1590 key_params.key_len = priv->wilc_ptk[key_index]->key_len;
1591 key_params.seq = priv->wilc_ptk[key_index]->seq;
1592 key_params.seq_len = priv->wilc_ptk[key_index]->seq_len;
1595 callback(cookie, &key_params);
1597 return s32Error; /* priv->wilc_gtk->key_len ?0 : -ENOENT; */
1601 * @brief WILC_WFI_set_default_key
1602 * @details Set the default management frame key on an interface
1604 * @return int : Return 0 on Success.
1609 static int WILC_WFI_set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1610 bool unicast, bool multicast)
1612 WILC_Sint32 s32Error = WILC_SUCCESS;
1613 struct WILC_WFI_priv *priv;
1616 priv = wiphy_priv(wiphy);
1618 PRINT_D(CFG80211_DBG, "Setting default key with idx = %d \n", key_index);
1620 if (key_index != priv->WILC_WFI_wep_default) {
1622 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, key_index);
1629 * @brief WILC_WFI_dump_survey
1630 * @details Get site survey information
1632 * @return int : Return 0 on Success.
1637 static int WILC_WFI_dump_survey(struct wiphy *wiphy, struct net_device *netdev,
1638 int idx, struct survey_info *info)
1640 WILC_Sint32 s32Error = WILC_SUCCESS;
1645 PRINT_ER("Error Idx value doesn't equal zero: Error(%d)\n", s32Error);
1654 * @brief WILC_WFI_get_station
1655 * @details Get station information for the station identified by @mac
1657 * @return int : Return 0 on Success.
1663 extern uint32_t Statisitcs_totalAcks, Statisitcs_DroppedAcks;
1664 static int WILC_WFI_get_station(struct wiphy *wiphy, struct net_device *dev,
1665 const u8 *mac, struct station_info *sinfo)
1667 WILC_Sint32 s32Error = WILC_SUCCESS;
1668 struct WILC_WFI_priv *priv;
1669 perInterface_wlan_t *nic;
1670 #ifdef WILC_AP_EXTERNAL_MLME
1672 WILC_Uint32 associatedsta = 0;
1673 WILC_Uint32 inactive_time = 0;
1675 priv = wiphy_priv(wiphy);
1676 nic = netdev_priv(dev);
1678 #ifdef WILC_AP_EXTERNAL_MLME
1679 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
1680 PRINT_D(HOSTAPD_DBG, "Getting station parameters\n");
1682 PRINT_INFO(HOSTAPD_DBG, ": %x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4]);
1684 for (i = 0; i < NUM_STA_ASSOCIATED; i++) {
1686 if (!(memcmp(mac, priv->assoc_stainfo.au8Sta_AssociatedBss[i], ETH_ALEN))) {
1693 if (associatedsta == -1) {
1695 PRINT_ER("Station required is not associated : Error(%d)\n", s32Error);
1700 sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME);
1702 host_int_get_inactive_time(priv->hWILCWFIDrv, mac, &(inactive_time));
1703 sinfo->inactive_time = 1000 * inactive_time;
1704 PRINT_D(CFG80211_DBG, "Inactive time %d\n", sinfo->inactive_time);
1709 if (nic->iftype == STATION_MODE) {
1710 tstrStatistics strStatistics;
1711 host_int_get_statistics(priv->hWILCWFIDrv, &strStatistics);
1715 * tx_failed introduced more than
1716 * kernel version 3.0.0
1718 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) |
1719 BIT( NL80211_STA_INFO_RX_PACKETS) |
1720 BIT(NL80211_STA_INFO_TX_PACKETS) |
1721 BIT(NL80211_STA_INFO_TX_FAILED) |
1722 BIT(NL80211_STA_INFO_TX_BITRATE);
1724 sinfo->signal = strStatistics.s8RSSI;
1725 sinfo->rx_packets = strStatistics.u32RxCount;
1726 sinfo->tx_packets = strStatistics.u32TxCount + strStatistics.u32TxFailureCount;
1727 sinfo->tx_failed = strStatistics.u32TxFailureCount;
1728 sinfo->txrate.legacy = strStatistics.u8LinkSpeed * 10;
1730 #ifdef TCP_ENHANCEMENTS
1731 if ((strStatistics.u8LinkSpeed > TCP_ACK_FILTER_LINK_SPEED_THRESH) && (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED)) {
1732 Enable_TCP_ACK_Filter(WILC_TRUE);
1733 } else if (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED) {
1734 Enable_TCP_ACK_Filter(WILC_FALSE);
1738 PRINT_D(CORECONFIG_DBG, "*** stats[%d][%d][%d][%d][%d]\n", sinfo->signal, sinfo->rx_packets, sinfo->tx_packets,
1739 sinfo->tx_failed, sinfo->txrate.legacy);
1746 * @brief WILC_WFI_change_bss
1747 * @details Modify parameters for a given BSS.
1749 * -use_cts_prot: Whether to use CTS protection
1750 * (0 = no, 1 = yes, -1 = do not change)
1751 * -use_short_preamble: Whether the use of short preambles is allowed
1752 * (0 = no, 1 = yes, -1 = do not change)
1753 * -use_short_slot_time: Whether the use of short slot time is allowed
1754 * (0 = no, 1 = yes, -1 = do not change)
1755 * -basic_rates: basic rates in IEEE 802.11 format
1756 * (or NULL for no change)
1757 * -basic_rates_len: number of basic rates
1758 * -ap_isolate: do not forward packets between connected stations
1759 * -ht_opmode: HT Operation mode
1760 * (u16 = opmode, -1 = do not change)
1761 * @return int : Return 0 on Success.
1766 static int WILC_WFI_change_bss(struct wiphy *wiphy, struct net_device *dev,
1767 struct bss_parameters *params)
1769 PRINT_D(CFG80211_DBG, "Changing Bss parametrs\n");
1774 * @brief WILC_WFI_auth
1775 * @details Request to authenticate with the specified peer
1777 * @return int : Return 0 on Success.
1782 static int WILC_WFI_auth(struct wiphy *wiphy, struct net_device *dev,
1783 struct cfg80211_auth_request *req)
1785 PRINT_D(CFG80211_DBG, "In Authentication Function\n");
1790 * @brief WILC_WFI_assoc
1791 * @details Request to (re)associate with the specified peer
1793 * @return int : Return 0 on Success.
1798 static int WILC_WFI_assoc(struct wiphy *wiphy, struct net_device *dev,
1799 struct cfg80211_assoc_request *req)
1801 PRINT_D(CFG80211_DBG, "In Association Function\n");
1806 * @brief WILC_WFI_deauth
1807 * @details Request to deauthenticate from the specified peer
1809 * @return int : Return 0 on Success.
1814 static int WILC_WFI_deauth(struct wiphy *wiphy, struct net_device *dev,
1815 struct cfg80211_deauth_request *req, void *cookie)
1817 PRINT_D(CFG80211_DBG, "In De-authentication Function\n");
1822 * @brief WILC_WFI_disassoc
1823 * @details Request to disassociate from the specified peer
1825 * @return int : Return 0 on Success
1830 static int WILC_WFI_disassoc(struct wiphy *wiphy, struct net_device *dev,
1831 struct cfg80211_disassoc_request *req, void *cookie)
1833 PRINT_D(CFG80211_DBG, "In Disassociation Function\n");
1838 * @brief WILC_WFI_set_wiphy_params
1839 * @details Notify that wiphy parameters have changed;
1840 * @param[in] Changed bitfield (see &enum wiphy_params_flags) describes which values
1842 * @return int : Return 0 on Success
1847 static int WILC_WFI_set_wiphy_params(struct wiphy *wiphy, u32 changed)
1849 WILC_Sint32 s32Error = WILC_SUCCESS;
1850 tstrCfgParamVal pstrCfgParamVal;
1851 struct WILC_WFI_priv *priv;
1853 priv = wiphy_priv(wiphy);
1854 /* priv = netdev_priv(priv->wdev->netdev); */
1856 pstrCfgParamVal.u32SetCfgFlag = 0;
1857 PRINT_D(CFG80211_DBG, "Setting Wiphy params \n");
1859 if (changed & WIPHY_PARAM_RETRY_SHORT) {
1860 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_SHORT %d\n",
1861 priv->dev->ieee80211_ptr->wiphy->retry_short);
1862 pstrCfgParamVal.u32SetCfgFlag |= RETRY_SHORT;
1863 pstrCfgParamVal.short_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_short;
1865 if (changed & WIPHY_PARAM_RETRY_LONG) {
1867 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_LONG %d\n", priv->dev->ieee80211_ptr->wiphy->retry_long);
1868 pstrCfgParamVal.u32SetCfgFlag |= RETRY_LONG;
1869 pstrCfgParamVal.long_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_long;
1872 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
1873 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->frag_threshold);
1874 pstrCfgParamVal.u32SetCfgFlag |= FRAG_THRESHOLD;
1875 pstrCfgParamVal.frag_threshold = priv->dev->ieee80211_ptr->wiphy->frag_threshold;
1879 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
1880 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->rts_threshold);
1882 pstrCfgParamVal.u32SetCfgFlag |= RTS_THRESHOLD;
1883 pstrCfgParamVal.rts_threshold = priv->dev->ieee80211_ptr->wiphy->rts_threshold;
1887 PRINT_D(CFG80211_DBG, "Setting CFG params in the host interface\n");
1888 s32Error = hif_set_cfg(priv->hWILCWFIDrv, &pstrCfgParamVal);
1890 PRINT_ER("Error in setting WIPHY PARAMS\n");
1897 * @brief WILC_WFI_set_bitrate_mask
1898 * @details set the bitrate mask configuration
1900 * @return int : Return 0 on Success
1905 static int WILC_WFI_set_bitrate_mask(struct wiphy *wiphy,
1906 struct net_device *dev, const u8 *peer,
1907 const struct cfg80211_bitrate_mask *mask)
1909 WILC_Sint32 s32Error = WILC_SUCCESS;
1910 /* strCfgParamVal pstrCfgParamVal; */
1911 /* struct WILC_WFI_priv* priv; */
1913 PRINT_D(CFG80211_DBG, "Setting Bitrate mask function\n");
1915 priv = wiphy_priv(wiphy);
1916 /* priv = netdev_priv(priv->wdev->netdev); */
1918 pstrCfgParamVal.curr_tx_rate = mask->control[IEEE80211_BAND_2GHZ].legacy;
1920 PRINT_D(CFG80211_DBG, "Tx rate = %d\n", pstrCfgParamVal.curr_tx_rate);
1921 s32Error = hif_set_cfg(priv->hWILCWFIDrv, &pstrCfgParamVal);
1924 PRINT_ER("Error in setting bitrate\n");
1931 * @brief WILC_WFI_set_pmksa
1932 * @details Cache a PMKID for a BSSID. This is mostly useful for fullmac
1933 * devices running firmwares capable of generating the (re) association
1934 * RSN IE. It allows for faster roaming between WPA2 BSSIDs.
1936 * @return int : Return 0 on Success
1941 static int WILC_WFI_set_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1942 struct cfg80211_pmksa *pmksa)
1945 WILC_Sint32 s32Error = WILC_SUCCESS;
1948 struct WILC_WFI_priv *priv = wiphy_priv(wiphy);
1950 PRINT_D(CFG80211_DBG, "Setting PMKSA\n");
1953 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
1954 if (!WILC_memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
1956 /*If bssid already exists and pmkid value needs to reset*/
1958 PRINT_D(CFG80211_DBG, "PMKID already exists\n");
1962 if (i < WILC_MAX_NUM_PMKIDS) {
1963 PRINT_D(CFG80211_DBG, "Setting PMKID in private structure\n");
1964 WILC_memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid,
1966 WILC_memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid,
1968 if (!(flag == PMKID_FOUND))
1969 priv->pmkid_list.numpmkid++;
1971 PRINT_ER("Invalid PMKID index\n");
1976 PRINT_D(CFG80211_DBG, "Setting pmkid in the host interface\n");
1977 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
1983 * @brief WILC_WFI_del_pmksa
1984 * @details Delete a cached PMKID.
1986 * @return int : Return 0 on Success
1991 static int WILC_WFI_del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1992 struct cfg80211_pmksa *pmksa)
1997 WILC_Sint32 s32Error = WILC_SUCCESS;
1999 struct WILC_WFI_priv *priv = wiphy_priv(wiphy);
2000 /* priv = netdev_priv(priv->wdev->netdev); */
2002 PRINT_D(CFG80211_DBG, "Deleting PMKSA keys\n");
2004 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
2005 if (!WILC_memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
2007 /*If bssid is found, reset the values*/
2008 PRINT_D(CFG80211_DBG, "Reseting PMKID values\n");
2009 WILC_memset(&priv->pmkid_list.pmkidlist[i], 0, sizeof(tstrHostIFpmkid));
2015 if (i < priv->pmkid_list.numpmkid && priv->pmkid_list.numpmkid > 0) {
2016 for (; i < (priv->pmkid_list.numpmkid - 1); i++) {
2017 WILC_memcpy(priv->pmkid_list.pmkidlist[i].bssid,
2018 priv->pmkid_list.pmkidlist[i + 1].bssid,
2020 WILC_memcpy(priv->pmkid_list.pmkidlist[i].pmkid,
2021 priv->pmkid_list.pmkidlist[i].pmkid,
2024 priv->pmkid_list.numpmkid--;
2033 * @brief WILC_WFI_flush_pmksa
2034 * @details Flush all cached PMKIDs.
2036 * @return int : Return 0 on Success
2041 static int WILC_WFI_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev)
2043 struct WILC_WFI_priv *priv = wiphy_priv(wiphy);
2044 /* priv = netdev_priv(priv->wdev->netdev); */
2046 PRINT_D(CFG80211_DBG, "Flushing PMKID key values\n");
2048 /*Get cashed Pmkids and set all with zeros*/
2049 WILC_memset(&priv->pmkid_list, 0, sizeof(tstrHostIFpmkidAttr));
2057 * @brief WILC_WFI_CfgParseRxAction
2058 * @details Function parses the received frames and modifies the following attributes:
2061 * -Operating Channel
2063 * @param[in] u8* Buffer, u32 length
2070 void WILC_WFI_CfgParseRxAction(u8 *buf, WILC_Uint32 len)
2072 WILC_Uint32 index = 0;
2073 WILC_Uint32 i = 0, j = 0;
2076 #ifdef USE_SUPPLICANT_GO_INTENT
2079 WILC_Bool is_wilc_go = WILC_TRUE;
2081 u8 op_channel_attr_index = 0;
2082 u8 channel_list_attr_index = 0;
2084 while (index < len) {
2085 if (buf[index] == GO_INTENT_ATTR_ID) {
2086 #ifdef USE_SUPPLICANT_GO_INTENT
2088 /*Case 1: If we are going to be p2p client, no need to modify channels attributes*/
2089 /*In negotiation frames, go intent attr value determines who will be GO*/
2090 intent = GET_GO_INTENT(buf[index + 3]);
2091 tie_breaker = GET_TIE_BREAKER(buf[index + 3]);
2092 if (intent > SUPPLICANT_GO_INTENT
2093 || (intent == SUPPLICANT_GO_INTENT && tie_breaker == 1)) {
2094 PRINT_D(GENERIC_DBG, "WILC will be client (intent %d tie breaker %d)\n", intent, tie_breaker);
2095 is_wilc_go = WILC_FALSE;
2097 PRINT_D(GENERIC_DBG, "WILC will be GO (intent %d tie breaker %d)\n", intent, tie_breaker);
2098 is_wilc_go = WILC_TRUE;
2101 #else /* USE_SUPPLICANT_GO_INTENT */
2102 #ifdef FORCE_P2P_CLIENT
2103 buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1);
2105 buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1);
2107 #endif /* USE_SUPPLICANT_GO_INTENT */
2110 #ifdef USE_SUPPLICANT_GO_INTENT
2111 /*Case 2: If group bssid attribute is present, no need to modify channels attributes*/
2112 /*In invitation req and rsp, group bssid attr presence determines who will be GO*/
2113 if (buf[index] == GROUP_BSSID_ATTR_ID) {
2114 PRINT_D(GENERIC_DBG, "Group BSSID: %2x:%2x:%2x\n", buf[index + 3]
2117 is_wilc_go = WILC_FALSE;
2119 #endif /* USE_SUPPLICANT_GO_INTENT */
2121 if (buf[index] == CHANLIST_ATTR_ID) {
2122 channel_list_attr_index = index;
2123 } else if (buf[index] == OPERCHAN_ATTR_ID) {
2124 op_channel_attr_index = index;
2126 index += buf[index + 1] + 3; /* ID,Length byte */
2129 #ifdef USE_SUPPLICANT_GO_INTENT
2130 if (u8WLANChannel != INVALID_CHANNEL && is_wilc_go)
2132 if (u8WLANChannel != INVALID_CHANNEL)
2135 /*Modify channel list attribute*/
2136 if (channel_list_attr_index) {
2137 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
2138 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
2139 if (buf[i] == 0x51) {
2140 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
2141 buf[j] = u8WLANChannel;
2147 /*Modify operating channel attribute*/
2148 if (op_channel_attr_index) {
2149 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
2150 buf[op_channel_attr_index + 6] = 0x51;
2151 buf[op_channel_attr_index + 7] = u8WLANChannel;
2157 * @brief WILC_WFI_CfgParseTxAction
2158 * @details Function parses the transmitted action frames and modifies the
2159 * GO Intent attribute
2160 * @param[in] u8* Buffer, u32 length, bool bOperChan, u8 iftype
2166 void WILC_WFI_CfgParseTxAction(u8 *buf, WILC_Uint32 len, WILC_Bool bOperChan, u8 iftype)
2168 WILC_Uint32 index = 0;
2169 WILC_Uint32 i = 0, j = 0;
2171 u8 op_channel_attr_index = 0;
2172 u8 channel_list_attr_index = 0;
2173 #ifdef USE_SUPPLICANT_GO_INTENT
2174 WILC_Bool is_wilc_go = WILC_FALSE;
2177 /*Case 1: If we are already p2p client, no need to modify channels attributes*/
2178 /*This to handle the case of inviting a p2p peer to join an existing group which we are a member in*/
2179 if (iftype == CLIENT_MODE)
2183 while (index < len) {
2184 #ifdef USE_SUPPLICANT_GO_INTENT
2185 /*Case 2: If group bssid attribute is present, no need to modify channels attributes*/
2186 /*In invitation req and rsp, group bssid attr presence determines who will be GO*/
2187 /*Note: If we are already p2p client, group bssid attr may also be present (handled in Case 1)*/
2188 if (buf[index] == GROUP_BSSID_ATTR_ID) {
2189 PRINT_D(GENERIC_DBG, "Group BSSID: %2x:%2x:%2x\n", buf[index + 3]
2192 is_wilc_go = WILC_TRUE;
2195 #else /* USE_SUPPLICANT_GO_INTENT */
2196 if (buf[index] == GO_INTENT_ATTR_ID) {
2197 #ifdef FORCE_P2P_CLIENT
2198 buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1);
2200 buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1);
2207 if (buf[index] == CHANLIST_ATTR_ID) {
2208 channel_list_attr_index = index;
2209 } else if (buf[index] == OPERCHAN_ATTR_ID) {
2210 op_channel_attr_index = index;
2212 index += buf[index + 1] + 3; /* ID,Length byte */
2215 #ifdef USE_SUPPLICANT_GO_INTENT
2216 /*No need to check bOperChan since only transmitted invitation frames are parsed*/
2217 if (u8WLANChannel != INVALID_CHANNEL && is_wilc_go)
2219 if (u8WLANChannel != INVALID_CHANNEL && bOperChan)
2222 /*Modify channel list attribute*/
2223 if (channel_list_attr_index) {
2224 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
2225 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
2226 if (buf[i] == 0x51) {
2227 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
2228 buf[j] = u8WLANChannel;
2234 /*Modify operating channel attribute*/
2235 if (op_channel_attr_index) {
2236 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
2237 buf[op_channel_attr_index + 6] = 0x51;
2238 buf[op_channel_attr_index + 7] = u8WLANChannel;
2243 /* @brief WILC_WFI_p2p_rx
2248 * @author Mai Daftedar
2253 void WILC_WFI_p2p_rx (struct net_device *dev, uint8_t *buff, uint32_t size)
2256 struct WILC_WFI_priv *priv;
2257 WILC_Uint32 header, pkt_offset;
2258 tstrWILC_WFIDrv *pstrWFIDrv;
2260 WILC_Sint32 s32Freq;
2261 priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
2262 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2264 /* Get WILC header */
2265 WILC_memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
2267 /* The packet offset field conain info about what type of managment frame */
2268 /* we are dealing with and ack status */
2269 pkt_offset = GET_PKT_OFFSET(header);
2271 if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
2272 if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP) {
2273 PRINT_D(GENERIC_DBG, "Probe response ACK\n");
2274 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
2277 if (pkt_offset & IS_MGMT_STATUS_SUCCES) {
2278 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],
2279 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
2280 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
2282 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],
2283 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
2284 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, false, GFP_KERNEL);
2290 PRINT_D(GENERIC_DBG, "Rx Frame Type:%x\n", buff[FRAME_TYPE_ID]);
2293 /*Upper layer is informed that the frame is received on this freq*/
2294 s32Freq = ieee80211_channel_to_frequency(u8CurrChannel, IEEE80211_BAND_2GHZ);
2296 if (ieee80211_is_action(buff[FRAME_TYPE_ID])) {
2297 PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]);
2299 if (priv->bCfgScanning == WILC_TRUE && jiffies >= pstrWFIDrv->u64P2p_MgmtTimeout) {
2300 PRINT_D(GENERIC_DBG, "Receiving action frames from wrong channels\n");
2303 if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
2305 switch (buff[ACTION_SUBTYPE_ID]) {
2306 case GAS_INTIAL_REQ:
2307 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buff[ACTION_SUBTYPE_ID]);
2310 case GAS_INTIAL_RSP:
2311 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buff[ACTION_SUBTYPE_ID]);
2314 case PUBLIC_ACT_VENDORSPEC:
2315 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2316 * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/
2317 if (!WILC_memcmp(u8P2P_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) {
2318 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
2320 for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) {
2321 if (!WILC_memcmp(u8P2P_vendorspec, &buff[i], 6)) {
2322 u8P2Precvrandom = buff[i + 6];
2323 bWilc_ie = WILC_TRUE;
2324 PRINT_D(GENERIC_DBG, "WILC Vendor specific IE:%02x\n", u8P2Precvrandom);
2330 if (u8P2Plocalrandom > u8P2Precvrandom) {
2331 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
2332 || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
2333 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) {
2334 if (buff[i] == P2PELEM_ATTR_ID && !(WILC_memcmp(u8P2P_oui, &buff[i + 2], 4))) {
2335 WILC_WFI_CfgParseRxAction(&buff[i + 6], size - (i + 6));
2341 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2345 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP) && (bWilc_ie)) {
2346 PRINT_D(GENERIC_DBG, "Sending P2P to host without extra elemnt\n");
2347 /* extra attribute for sig_dbm: signal strength in mBm, or 0 if unknown */
2348 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
2354 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff[ACTION_SUBTYPE_ID]);
2360 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
2365 * @brief WILC_WFI_mgmt_tx_complete
2366 * @details Returns result of writing mgmt frame to VMM (Tx buffers are freed here)
2368 * transmitting status
2370 * @author Amr Abdelmoghny
2374 static void WILC_WFI_mgmt_tx_complete(void *priv, int status)
2376 struct p2p_mgmt_data *pv_data = (struct p2p_mgmt_data *)priv;
2379 kfree(pv_data->buff);
2384 * @brief WILC_WFI_RemainOnChannelReady
2385 * @details Callback function, called from handle_remain_on_channel on being ready on channel
2388 * @author Amr abdelmoghny
2393 static void WILC_WFI_RemainOnChannelReady(void *pUserVoid)
2395 struct WILC_WFI_priv *priv;
2396 priv = (struct WILC_WFI_priv *)pUserVoid;
2398 PRINT_D(HOSTINF_DBG, "Remain on channel ready \n");
2400 priv->bInP2PlistenState = WILC_TRUE;
2402 cfg80211_ready_on_channel(priv->wdev,
2403 priv->strRemainOnChanParams.u64ListenCookie,
2404 priv->strRemainOnChanParams.pstrListenChan,
2405 priv->strRemainOnChanParams.u32ListenDuration,
2410 * @brief WILC_WFI_RemainOnChannelExpired
2411 * @details Callback function, called on expiration of remain-on-channel duration
2414 * @author Amr abdelmoghny
2419 static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, WILC_Uint32 u32SessionID)
2421 struct WILC_WFI_priv *priv;
2422 priv = (struct WILC_WFI_priv *)pUserVoid;
2425 if (u32SessionID == priv->strRemainOnChanParams.u32ListenSessionID) {
2426 PRINT_D(GENERIC_DBG, "Remain on channel expired \n");
2428 priv->bInP2PlistenState = WILC_FALSE;
2430 /*Inform wpas of remain-on-channel expiration*/
2431 cfg80211_remain_on_channel_expired(priv->wdev,
2432 priv->strRemainOnChanParams.u64ListenCookie,
2433 priv->strRemainOnChanParams.pstrListenChan,
2436 PRINT_D(GENERIC_DBG, "Received ID 0x%x Expected ID 0x%x (No match)\n", u32SessionID
2437 , priv->strRemainOnChanParams.u32ListenSessionID);
2443 * @brief WILC_WFI_remain_on_channel
2444 * @details Request the driver to remain awake on the specified
2445 * channel for the specified duration to complete an off-channel
2446 * operation (e.g., public action frame exchange). When the driver is
2447 * ready on the requested channel, it must indicate this with an event
2448 * notification by calling cfg80211_ready_on_channel().
2450 * @return int : Return 0 on Success
2455 static int WILC_WFI_remain_on_channel(struct wiphy *wiphy,
2456 struct wireless_dev *wdev,
2457 struct ieee80211_channel *chan,
2458 unsigned int duration, u64 *cookie)
2460 WILC_Sint32 s32Error = WILC_SUCCESS;
2461 struct WILC_WFI_priv *priv;
2462 priv = wiphy_priv(wiphy);
2464 PRINT_D(GENERIC_DBG, "Remaining on channel %d\n", chan->hw_value);
2466 /*BugID_4800: if in AP mode, return.*/
2467 /*This check is to handle the situation when user*/
2468 /*requests "create group" during a running scan*/
2470 if (wdev->iftype == NL80211_IFTYPE_AP) {
2471 PRINT_D(GENERIC_DBG, "Required remain-on-channel while in AP mode");
2475 u8CurrChannel = chan->hw_value;
2477 /*Setting params needed by WILC_WFI_RemainOnChannelExpired()*/
2478 priv->strRemainOnChanParams.pstrListenChan = chan;
2479 priv->strRemainOnChanParams.u64ListenCookie = *cookie;
2480 priv->strRemainOnChanParams.u32ListenDuration = duration;
2481 priv->strRemainOnChanParams.u32ListenSessionID++;
2483 s32Error = host_int_remain_on_channel(priv->hWILCWFIDrv
2484 , priv->strRemainOnChanParams.u32ListenSessionID
2487 , WILC_WFI_RemainOnChannelExpired
2488 , WILC_WFI_RemainOnChannelReady
2495 * @brief WILC_WFI_cancel_remain_on_channel
2496 * @details Cancel an on-going remain-on-channel operation.
2497 * This allows the operation to be terminated prior to timeout based on
2498 * the duration value.
2499 * @param[in] struct wiphy *wiphy,
2500 * @param[in] struct net_device *dev
2501 * @param[in] u64 cookie,
2502 * @return int : Return 0 on Success
2507 static int WILC_WFI_cancel_remain_on_channel(struct wiphy *wiphy,
2508 struct wireless_dev *wdev,
2511 WILC_Sint32 s32Error = WILC_SUCCESS;
2512 struct WILC_WFI_priv *priv;
2513 priv = wiphy_priv(wiphy);
2515 PRINT_D(CFG80211_DBG, "Cancel remain on channel\n");
2517 s32Error = host_int_ListenStateExpired(priv->hWILCWFIDrv, priv->strRemainOnChanParams.u32ListenSessionID);
2521 * @brief WILC_WFI_add_wilcvendorspec
2522 * @details Adding WILC information elemet to allow two WILC devices to
2523 * identify each other and connect
2524 * @param[in] u8 * buf
2530 void WILC_WFI_add_wilcvendorspec(u8 *buff)
2532 WILC_memcpy(buff, u8P2P_vendorspec, sizeof(u8P2P_vendorspec));
2535 * @brief WILC_WFI_mgmt_tx_frame
2544 extern linux_wlan_t *g_linux_wlan;
2545 extern WILC_Bool bEnablePS;
2546 int WILC_WFI_mgmt_tx(struct wiphy *wiphy,
2547 struct wireless_dev *wdev,
2548 struct cfg80211_mgmt_tx_params *params,
2551 struct ieee80211_channel *chan = params->chan;
2552 unsigned int wait = params->wait;
2553 const u8 *buf = params->buf;
2554 size_t len = params->len;
2555 const struct ieee80211_mgmt *mgmt;
2556 struct p2p_mgmt_data *mgmt_tx;
2557 struct WILC_WFI_priv *priv;
2558 WILC_Sint32 s32Error = WILC_SUCCESS;
2559 tstrWILC_WFIDrv *pstrWFIDrv;
2561 perInterface_wlan_t *nic;
2562 WILC_Uint32 buf_len = len + sizeof(u8P2P_vendorspec) + sizeof(u8P2Plocalrandom);
2564 nic = netdev_priv(wdev->netdev);
2565 priv = wiphy_priv(wiphy);
2566 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2568 *cookie = (unsigned long)buf;
2569 priv->u64tx_cookie = *cookie;
2570 mgmt = (const struct ieee80211_mgmt *) buf;
2572 if (ieee80211_is_mgmt(mgmt->frame_control)) {
2574 /*mgmt frame allocation*/
2575 mgmt_tx = (struct p2p_mgmt_data *)WILC_MALLOC(sizeof(struct p2p_mgmt_data));
2576 if (mgmt_tx == NULL) {
2577 PRINT_ER("Failed to allocate memory for mgmt_tx structure\n");
2580 mgmt_tx->buff = (char *)WILC_MALLOC(buf_len);
2581 if (mgmt_tx->buff == NULL) {
2582 PRINT_ER("Failed to allocate memory for mgmt_tx buff\n");
2585 WILC_memcpy(mgmt_tx->buff, buf, len);
2586 mgmt_tx->size = len;
2589 if (ieee80211_is_probe_resp(mgmt->frame_control)) {
2590 PRINT_D(GENERIC_DBG, "TX: Probe Response\n");
2591 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2592 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2593 /*Save the current channel after we tune to it*/
2594 u8CurrChannel = chan->hw_value;
2595 } else if (ieee80211_is_action(mgmt->frame_control)) {
2596 PRINT_D(GENERIC_DBG, "ACTION FRAME:%x\n", (WILC_Uint16)mgmt->frame_control);
2600 if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
2602 /*Only set the channel, if not a negotiation confirmation frame
2603 * (If Negotiation confirmation frame, force it
2604 * to be transmitted on the same negotiation channel)*/
2606 if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC ||
2607 buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) {
2608 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2609 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2610 /*Save the current channel after we tune to it*/
2611 u8CurrChannel = chan->hw_value;
2613 switch (buf[ACTION_SUBTYPE_ID]) {
2614 case GAS_INTIAL_REQ:
2616 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buf[ACTION_SUBTYPE_ID]);
2620 case GAS_INTIAL_RSP:
2622 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buf[ACTION_SUBTYPE_ID]);
2626 case PUBLIC_ACT_VENDORSPEC:
2628 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2629 * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/
2630 if (!WILC_memcmp(u8P2P_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) {
2631 /*For the connection of two WILC's connection generate a rand number to determine who will be a GO*/
2632 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
2633 if (u8P2Plocalrandom == 1 && u8P2Precvrandom < u8P2Plocalrandom) {
2634 get_random_bytes(&u8P2Plocalrandom, 1);
2635 /*Increment the number to prevent if its 0*/
2640 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
2641 || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
2642 if (u8P2Plocalrandom > u8P2Precvrandom) {
2643 PRINT_D(GENERIC_DBG, "LOCAL WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2645 /*Search for the p2p information information element , after the Public action subtype theres a byte for teh dialog token, skip that*/
2646 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) {
2647 if (buf[i] == P2PELEM_ATTR_ID && !(WILC_memcmp(u8P2P_oui, &buf[i + 2], 4))) {
2648 if (buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)
2649 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), WILC_TRUE, nic->iftype);
2652 /*If using supplicant go intent, no need at all*/
2653 /*to parse transmitted negotiation frames*/
2654 #ifndef USE_SUPPLICANT_GO_INTENT
2656 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), WILC_FALSE, nic->iftype);
2662 if (buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_REQ && buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_RSP) {
2663 WILC_WFI_add_wilcvendorspec(&mgmt_tx->buff[len]);
2664 mgmt_tx->buff[len + sizeof(u8P2P_vendorspec)] = u8P2Plocalrandom;
2665 mgmt_tx->size = buf_len;
2668 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2672 PRINT_D(GENERIC_DBG, "Not a P2P public action frame\n");
2680 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf[ACTION_SUBTYPE_ID]);
2687 PRINT_D(GENERIC_DBG, "TX: ACTION FRAME Type:%x : Chan:%d\n", buf[ACTION_SUBTYPE_ID], chan->hw_value);
2688 pstrWFIDrv->u64P2p_MgmtTimeout = (jiffies + msecs_to_jiffies(wait));
2690 PRINT_D(GENERIC_DBG, "Current Jiffies: %lu Timeout:%llu\n", jiffies, pstrWFIDrv->u64P2p_MgmtTimeout);
2694 g_linux_wlan->oup.wlan_add_mgmt_to_tx_que(mgmt_tx, mgmt_tx->buff, mgmt_tx->size, WILC_WFI_mgmt_tx_complete);
2696 PRINT_D(GENERIC_DBG, "This function transmits only management frames\n");
2701 int WILC_WFI_mgmt_tx_cancel_wait(struct wiphy *wiphy,
2702 struct wireless_dev *wdev,
2705 struct WILC_WFI_priv *priv;
2706 tstrWILC_WFIDrv *pstrWFIDrv;
2707 priv = wiphy_priv(wiphy);
2708 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2711 PRINT_D(GENERIC_DBG, "Tx Cancel wait :%lu\n", jiffies);
2712 pstrWFIDrv->u64P2p_MgmtTimeout = jiffies;
2714 if (priv->bInP2PlistenState == WILC_FALSE) {
2715 /* Bug 5504: This is just to avoid connection failure when getting stuck when the supplicant
2716 * considers the driver falsely that it is in Listen state */
2717 cfg80211_remain_on_channel_expired(priv->wdev,
2718 priv->strRemainOnChanParams.u64ListenCookie,
2719 priv->strRemainOnChanParams.pstrListenChan,
2727 * @brief WILC_WFI_frame_register
2728 * @details Notify driver that a management frame type was
2729 * registered. Note that this callback may not sleep, and cannot run
2730 * concurrently with itself.
2737 void WILC_WFI_frame_register(struct wiphy *wiphy,
2738 struct wireless_dev *wdev,
2739 u16 frame_type, bool reg)
2742 struct WILC_WFI_priv *priv;
2743 perInterface_wlan_t *nic;
2746 priv = wiphy_priv(wiphy);
2747 nic = netdev_priv(priv->wdev->netdev);
2755 PRINT_D(GENERIC_DBG, "Frame registering Frame Type: %x: Boolean: %d\n", frame_type, reg);
2756 switch (frame_type) {
2759 nic->g_struct_frame_reg[0].frame_type = frame_type;
2760 nic->g_struct_frame_reg[0].reg = reg;
2766 nic->g_struct_frame_reg[1].frame_type = frame_type;
2767 nic->g_struct_frame_reg[1].reg = reg;
2777 /*If mac is closed, then return*/
2778 if (!g_linux_wlan->wilc1000_initialized) {
2779 PRINT_D(GENERIC_DBG, "Return since mac is closed\n");
2782 host_int_frame_register(priv->hWILCWFIDrv, frame_type, reg);
2789 * @brief WILC_WFI_set_cqm_rssi_config
2790 * @details Configure connection quality monitor RSSI threshold.
2791 * @param[in] struct wiphy *wiphy:
2792 * @param[in] struct net_device *dev:
2793 * @param[in] s32 rssi_thold:
2794 * @param[in] u32 rssi_hyst:
2795 * @return int : Return 0 on Success
2800 static int WILC_WFI_set_cqm_rssi_config(struct wiphy *wiphy,
2801 struct net_device *dev, s32 rssi_thold, u32 rssi_hyst)
2803 PRINT_D(CFG80211_DBG, "Setting CQM RSSi Function\n");
2808 * @brief WILC_WFI_dump_station
2809 * @details Configure connection quality monitor RSSI threshold.
2810 * @param[in] struct wiphy *wiphy:
2811 * @param[in] struct net_device *dev
2812 * @param[in] int idx
2813 * @param[in] u8 *mac
2814 * @param[in] struct station_info *sinfo
2815 * @return int : Return 0 on Success
2820 static int WILC_WFI_dump_station(struct wiphy *wiphy, struct net_device *dev,
2821 int idx, u8 *mac, struct station_info *sinfo)
2823 struct WILC_WFI_priv *priv;
2824 PRINT_D(CFG80211_DBG, "Dumping station information\n");
2829 priv = wiphy_priv(wiphy);
2830 /* priv = netdev_priv(priv->wdev->netdev); */
2832 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
2834 host_int_get_rssi(priv->hWILCWFIDrv, &(sinfo->signal));
2837 sinfo->filled |= STATION_INFO_TX_BYTES |
2838 STATION_INFO_TX_PACKETS |
2839 STATION_INFO_RX_BYTES |
2840 STATION_INFO_RX_PACKETS | STATION_INFO_SIGNAL | STATION_INFO_INACTIVE_TIME;
2842 down(&SemHandleUpdateStats);
2843 sinfo->inactive_time = priv->netstats.rx_time > priv->netstats.tx_time ? jiffies_to_msecs(jiffies - priv->netstats.tx_time) : jiffies_to_msecs(jiffies - priv->netstats.rx_time);
2844 sinfo->rx_bytes = priv->netstats.rx_bytes;
2845 sinfo->tx_bytes = priv->netstats.tx_bytes;
2846 sinfo->rx_packets = priv->netstats.rx_packets;
2847 sinfo->tx_packets = priv->netstats.tx_packets;
2848 up(&SemHandleUpdateStats);
2856 * @brief WILC_WFI_set_power_mgmt
2859 * @return int : Return 0 on Success.
2862 * @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
2864 int WILC_WFI_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2865 bool enabled, int timeout)
2867 struct WILC_WFI_priv *priv;
2868 PRINT_D(CFG80211_DBG, " Power save Enabled= %d , TimeOut = %d\n", enabled, timeout);
2873 priv = wiphy_priv(wiphy);
2874 if (priv->hWILCWFIDrv == NULL) {
2875 PRINT_ER("Driver is NULL\n");
2879 if (bEnablePS == WILC_TRUE)
2880 host_int_set_power_mgmt(priv->hWILCWFIDrv, enabled, timeout);
2883 return WILC_SUCCESS;
2886 #ifdef WILC_AP_EXTERNAL_MLME
2888 * @brief WILC_WFI_change_virt_intf
2889 * @details Change type/configuration of virtual interface,
2890 * keep the struct wireless_dev's iftype updated.
2892 * @return int : Return 0 on Success.
2897 void wilc1000_wlan_deinit(linux_wlan_t *nic);
2898 int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic);
2900 static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev,
2901 enum nl80211_iftype type, u32 *flags, struct vif_params *params)
2903 WILC_Sint32 s32Error = WILC_SUCCESS;
2904 struct WILC_WFI_priv *priv;
2905 /* struct WILC_WFI_mon_priv* mon_priv; */
2906 perInterface_wlan_t *nic;
2908 WILC_Uint16 TID = 0;
2913 nic = netdev_priv(dev);
2914 priv = wiphy_priv(wiphy);
2916 PRINT_D(HOSTAPD_DBG, "In Change virtual interface function\n");
2917 PRINT_D(HOSTAPD_DBG, "Wireless interface name =%s\n", dev->name);
2918 u8P2Plocalrandom = 0x01;
2919 u8P2Precvrandom = 0x00;
2921 bWilc_ie = WILC_FALSE;
2923 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2924 g_obtainingIP = WILC_FALSE;
2925 WILC_TimerStop(&hDuringIpTimer, NULL);
2926 PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n");
2929 /*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to CE H/W*/
2930 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2931 Set_machw_change_vir_if(WILC_TRUE);
2935 case NL80211_IFTYPE_STATION:
2937 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_STATION\n");
2938 /* linux_wlan_set_bssid(dev,g_linux_wlan->strInterfaceInfo[0].aSrcAddress); */
2940 /* send delba over wlan interface */
2943 dev->ieee80211_ptr->iftype = type;
2944 priv->wdev->iftype = type;
2945 nic->monitor_flag = 0;
2946 nic->iftype = STATION_MODE;
2948 /*Remove the enteries of the previously connected clients*/
2949 memset(priv->assoc_stainfo.au8Sta_AssociatedBss, 0, MAX_NUM_STA * ETH_ALEN);
2952 interface_type = nic->iftype;
2953 nic->iftype = STATION_MODE;
2955 if (g_linux_wlan->wilc1000_initialized) {
2956 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
2957 /* ensure that the message Q is empty */
2958 host_int_wait_msg_queue_idle();
2961 /*Eliminate host interface blocking state*/
2962 linux_wlan_unlock((void *)&g_linux_wlan->cfg_event);
2964 wilc1000_wlan_deinit(g_linux_wlan);
2965 wilc1000_wlan_init(dev, nic);
2966 g_wilc_initialized = 1;
2967 nic->iftype = interface_type;
2969 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
2970 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
2971 host_int_set_MacAddress((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
2972 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
2973 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2975 /*Add saved WEP keys, if any*/
2976 if (g_wep_keys_saved) {
2977 host_int_set_WEPDefaultKeyID((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
2978 g_key_wep_params.key_idx);
2979 host_int_add_wep_key_bss_sta((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
2980 g_key_wep_params.key,
2981 g_key_wep_params.key_len,
2982 g_key_wep_params.key_idx);
2985 /*No matter the driver handler passed here, it will be overwriiten*/
2986 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2987 host_int_flush_join_req(priv->hWILCWFIDrv);
2989 /*Add saved PTK and GTK keys, if any*/
2990 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2991 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
2992 g_key_ptk_params.key[1],
2993 g_key_ptk_params.key[2]);
2994 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
2995 g_key_gtk_params.key[1],
2996 g_key_gtk_params.key[2]);
2997 WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2998 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2999 g_add_ptk_key_params.key_idx,
3000 g_add_ptk_key_params.pairwise,
3001 g_add_ptk_key_params.mac_addr,
3002 (struct key_params *)(&g_key_ptk_params));
3004 WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3005 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3006 g_add_gtk_key_params.key_idx,
3007 g_add_gtk_key_params.pairwise,
3008 g_add_gtk_key_params.mac_addr,
3009 (struct key_params *)(&g_key_gtk_params));
3012 /*BugID_4847: registered frames in firmware are now*/
3013 /*lost due to mac close. So re-register those frames*/
3014 if (g_linux_wlan->wilc1000_initialized) {
3015 for (i = 0; i < num_reg_frame; i++) {
3016 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
3017 nic->g_struct_frame_reg[i].reg);
3018 host_int_frame_register(priv->hWILCWFIDrv,
3019 nic->g_struct_frame_reg[i].frame_type,
3020 nic->g_struct_frame_reg[i].reg);
3024 bEnablePS = WILC_TRUE;
3025 host_int_set_power_mgmt(priv->hWILCWFIDrv, 1, 0);
3031 case NL80211_IFTYPE_P2P_CLIENT:
3032 bEnablePS = WILC_FALSE;
3033 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
3035 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n");
3036 /* linux_wlan_set_bssid(dev,g_linux_wlan->strInterfaceInfo[0].aSrcAddress); */
3038 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
3040 dev->ieee80211_ptr->iftype = type;
3041 priv->wdev->iftype = type;
3042 nic->monitor_flag = 0;
3047 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
3048 nic->iftype = CLIENT_MODE;
3051 if (g_linux_wlan->wilc1000_initialized) {
3052 /* ensure that the message Q is empty */
3053 host_int_wait_msg_queue_idle();
3055 wilc1000_wlan_deinit(g_linux_wlan);
3056 wilc1000_wlan_init(dev, nic);
3057 g_wilc_initialized = 1;
3059 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
3060 host_int_set_MacAddress((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
3061 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
3062 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
3064 /*Add saved WEP keys, if any*/
3065 if (g_wep_keys_saved) {
3066 host_int_set_WEPDefaultKeyID((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
3067 g_key_wep_params.key_idx);
3068 host_int_add_wep_key_bss_sta((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
3069 g_key_wep_params.key,
3070 g_key_wep_params.key_len,
3071 g_key_wep_params.key_idx);
3074 /*No matter the driver handler passed here, it will be overwriiten*/
3075 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
3076 host_int_flush_join_req(priv->hWILCWFIDrv);
3078 /*Add saved PTK and GTK keys, if any*/
3079 if (g_ptk_keys_saved && g_gtk_keys_saved) {
3080 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
3081 g_key_ptk_params.key[1],
3082 g_key_ptk_params.key[2]);
3083 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
3084 g_key_gtk_params.key[1],
3085 g_key_gtk_params.key[2]);
3086 WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3087 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3088 g_add_ptk_key_params.key_idx,
3089 g_add_ptk_key_params.pairwise,
3090 g_add_ptk_key_params.mac_addr,
3091 (struct key_params *)(&g_key_ptk_params));
3093 WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3094 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3095 g_add_gtk_key_params.key_idx,
3096 g_add_gtk_key_params.pairwise,
3097 g_add_gtk_key_params.mac_addr,
3098 (struct key_params *)(&g_key_gtk_params));
3101 /*Refresh scan, to refresh the scan results to the wpa_supplicant. Set MachHw to false to enable further key installments*/
3102 refresh_scan(priv, 1, WILC_TRUE);
3103 Set_machw_change_vir_if(WILC_FALSE);
3105 /*BugID_4847: registered frames in firmware are now lost
3106 * due to mac close. So re-register those frames */
3107 if (g_linux_wlan->wilc1000_initialized) {
3108 for (i = 0; i < num_reg_frame; i++) {
3109 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
3110 nic->g_struct_frame_reg[i].reg);
3111 host_int_frame_register(priv->hWILCWFIDrv,
3112 nic->g_struct_frame_reg[i].frame_type,
3113 nic->g_struct_frame_reg[i].reg);
3121 case NL80211_IFTYPE_AP:
3122 /* connecting = 1; */
3123 bEnablePS = WILC_FALSE;
3124 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_AP %d\n", type);
3125 /* linux_wlan_set_bssid(dev,g_linux_wlan->strInterfaceInfo[0].aSrcAddress); */
3126 /* mon_priv = netdev_priv(dev); */
3127 /* mon_priv->real_ndev = dev; */
3128 dev->ieee80211_ptr->iftype = type;
3129 priv->wdev->iftype = type;
3130 nic->iftype = AP_MODE;
3131 PRINT_D(CORECONFIG_DBG, "(WILC_Uint32)priv->hWILCWFIDrv[%x]\n", (WILC_Uint32)priv->hWILCWFIDrv);
3134 PRINT_D(HOSTAPD_DBG, "Downloading AP firmware\n");
3135 linux_wlan_get_firmware(nic);
3137 /*If wilc is running, then close-open to actually get new firmware running (serves P2P)*/
3138 if (g_linux_wlan->wilc1000_initialized) {
3139 nic->iftype = AP_MODE;
3140 g_linux_wlan->wilc1000_initialized = 1;
3144 /* wilc1000_wlan_deinit(g_linux_wlan); */
3145 /* wilc1000_wlan_init(dev,nic); */
3146 /* repeat_power_cycle(nic); */
3147 /* nic->iftype = STATION_MODE; */
3149 /*BugID_4847: registered frames in firmware are now lost
3150 * due to mac close. So re-register those frames */
3151 for (i = 0; i < num_reg_frame; i++) {
3152 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
3153 nic->g_struct_frame_reg[i].reg);
3154 host_int_frame_register(priv->hWILCWFIDrv,
3155 nic->g_struct_frame_reg[i].frame_type,
3156 nic->g_struct_frame_reg[i].reg);
3163 case NL80211_IFTYPE_P2P_GO:
3164 PRINT_D(GENERIC_DBG, "start duringIP timer\n");
3166 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3167 g_obtainingIP = WILC_TRUE;
3168 WILC_TimerStart(&hDuringIpTimer, duringIP_TIME, NULL, NULL);
3170 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
3172 /*Delete block ack has to be the latest config packet*/
3173 /*sent before downloading new FW. This is because it blocks on*/
3174 /*hWaitResponse semaphore, which allows previous config*/
3175 /*packets to actually take action on old FW*/
3176 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
3177 bEnablePS = WILC_FALSE;
3178 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n");
3179 /* linux_wlan_set_bssid(dev,g_linux_wlan->strInterfaceInfo[0].aSrcAddress); */
3180 /* mon_priv = netdev_priv(dev); */
3181 /* mon_priv->real_ndev = dev; */
3182 dev->ieee80211_ptr->iftype = type;
3183 priv->wdev->iftype = type;
3185 PRINT_D(CORECONFIG_DBG, "(WILC_Uint32)priv->hWILCWFIDrv[%x]\n", (WILC_Uint32)priv->hWILCWFIDrv);
3186 /* host_int_set_operation_mode((WILC_Uint32)priv->hWILCWFIDrv,AP_MODE); */
3190 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
3194 nic->iftype = GO_MODE;
3196 /* ensure that the message Q is empty */
3197 host_int_wait_msg_queue_idle();
3199 /*while(!g_hif_thread_idle)
3201 * PRINT_D(GENERIC_DBG, "Wait for host IF idle\n");
3204 wilc1000_wlan_deinit(g_linux_wlan);
3205 /* repeat_power_cycle_partially(g_linux_wlan); */
3206 wilc1000_wlan_init(dev, nic);
3207 g_wilc_initialized = 1;
3210 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
3211 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
3212 host_int_set_MacAddress((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
3213 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
3214 host_int_set_operation_mode(priv->hWILCWFIDrv, AP_MODE);
3216 /*Add saved WEP keys, if any*/
3217 if (g_wep_keys_saved) {
3218 host_int_set_WEPDefaultKeyID((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
3219 g_key_wep_params.key_idx);
3220 host_int_add_wep_key_bss_sta((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
3221 g_key_wep_params.key,
3222 g_key_wep_params.key_len,
3223 g_key_wep_params.key_idx);
3226 /*No matter the driver handler passed here, it will be overwriiten*/
3227 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
3228 host_int_flush_join_req(priv->hWILCWFIDrv);
3230 /*Add saved PTK and GTK keys, if any*/
3231 if (g_ptk_keys_saved && g_gtk_keys_saved) {
3232 PRINT_D(CFG80211_DBG, "ptk %x %x %x cipher %x\n", g_key_ptk_params.key[0],
3233 g_key_ptk_params.key[1],
3234 g_key_ptk_params.key[2],
3235 g_key_ptk_params.cipher);
3236 PRINT_D(CFG80211_DBG, "gtk %x %x %x cipher %x\n", g_key_gtk_params.key[0],
3237 g_key_gtk_params.key[1],
3238 g_key_gtk_params.key[2],
3239 g_key_gtk_params.cipher);
3241 WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3242 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3243 g_add_ptk_key_params.key_idx,
3244 g_add_ptk_key_params.pairwise,
3245 g_add_ptk_key_params.mac_addr,
3246 (struct key_params *)(&g_key_ptk_params));
3248 WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3249 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3250 g_add_gtk_key_params.key_idx,
3251 g_add_gtk_key_params.pairwise,
3252 g_add_gtk_key_params.mac_addr,
3253 (struct key_params *)(&g_key_gtk_params));
3258 /*BugID_4847: registered frames in firmware are now*/
3259 /*lost due to mac close. So re-register those frames*/
3260 if (g_linux_wlan->wilc1000_initialized) {
3261 for (i = 0; i < num_reg_frame; i++) {
3262 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
3263 nic->g_struct_frame_reg[i].reg);
3264 host_int_frame_register(priv->hWILCWFIDrv,
3265 nic->g_struct_frame_reg[i].frame_type,
3266 nic->g_struct_frame_reg[i].reg);
3274 PRINT_ER("Unknown interface type= %d\n", type);
3283 /* (austin.2013-07-23)
3285 * To support revised cfg80211_ops
3287 * add_beacon --> start_ap
3288 * set_beacon --> change_beacon
3289 * del_beacon --> stop_ap
3291 * beacon_parameters --> cfg80211_ap_settings
3292 * cfg80211_beacon_data
3294 * applicable for linux kernel 3.4+
3298 * @brief WILC_WFI_start_ap
3299 * @details Add a beacon with given parameters, @head, @interval
3300 * and @dtim_period will be valid, @tail is optional.
3302 * @param[in] dev The net device structure
3303 * @param[in] settings cfg80211_ap_settings parameters for the beacon to be added
3304 * @return int : Return 0 on Success.
3309 static int WILC_WFI_start_ap(struct wiphy *wiphy, struct net_device *dev,
3310 struct cfg80211_ap_settings *settings)
3312 struct cfg80211_beacon_data *beacon = &(settings->beacon);
3313 struct WILC_WFI_priv *priv;
3314 WILC_Sint32 s32Error = WILC_SUCCESS;
3316 priv = wiphy_priv(wiphy);
3317 PRINT_D(HOSTAPD_DBG, "Starting ap\n");
3319 PRINT_D(HOSTAPD_DBG, "Interval = %d \n DTIM period = %d\n Head length = %zu Tail length = %zu\n",
3320 settings->beacon_interval, settings->dtim_period, beacon->head_len, beacon->tail_len);
3322 s32Error = WILC_WFI_CfgSetChannel(wiphy, &settings->chandef);
3324 if (s32Error != WILC_SUCCESS)
3325 PRINT_ER("Error in setting channel\n");
3327 linux_wlan_set_bssid(dev, g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
3329 #ifndef WILC_FULLY_HOSTING_AP
3330 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
3331 settings->beacon_interval,
3332 settings->dtim_period,
3333 beacon->head_len, (u8 *)beacon->head,
3334 beacon->tail_len, (u8 *)beacon->tail);
3336 s32Error = host_add_beacon(priv->hWILCWFIDrv,
3337 settings->beacon_interval,
3338 settings->dtim_period,
3339 beacon->head_len, (u8 *)beacon->head,
3340 beacon->tail_len, (u8 *)beacon->tail);
3347 * @brief WILC_WFI_change_beacon
3348 * @details Add a beacon with given parameters, @head, @interval
3349 * and @dtim_period will be valid, @tail is optional.
3351 * @param[in] dev The net device structure
3352 * @param[in] beacon cfg80211_beacon_data for the beacon to be changed
3353 * @return int : Return 0 on Success.
3358 static int WILC_WFI_change_beacon(struct wiphy *wiphy, struct net_device *dev,
3359 struct cfg80211_beacon_data *beacon)
3361 struct WILC_WFI_priv *priv;
3362 WILC_Sint32 s32Error = WILC_SUCCESS;
3364 priv = wiphy_priv(wiphy);
3365 PRINT_D(HOSTAPD_DBG, "Setting beacon\n");
3368 #ifndef WILC_FULLY_HOSTING_AP
3369 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
3372 beacon->head_len, (u8 *)beacon->head,
3373 beacon->tail_len, (u8 *)beacon->tail);
3375 s32Error = host_add_beacon(priv->hWILCWFIDrv,
3378 beacon->head_len, (u8 *)beacon->head,
3379 beacon->tail_len, (u8 *)beacon->tail);
3386 * @brief WILC_WFI_stop_ap
3387 * @details Remove beacon configuration and stop sending the beacon.
3389 * @return int : Return 0 on Success.
3394 static int WILC_WFI_stop_ap(struct wiphy *wiphy, struct net_device *dev)
3396 WILC_Sint32 s32Error = WILC_SUCCESS;
3397 struct WILC_WFI_priv *priv;
3398 u8 NullBssid[ETH_ALEN] = {0};
3401 WILC_NULLCHECK(s32Error, wiphy);
3403 priv = wiphy_priv(wiphy);
3405 PRINT_D(HOSTAPD_DBG, "Deleting beacon\n");
3408 linux_wlan_set_bssid(dev, NullBssid);
3410 #ifndef WILC_FULLY_HOSTING_AP
3411 s32Error = host_int_del_beacon(priv->hWILCWFIDrv);
3413 s32Error = host_del_beacon(priv->hWILCWFIDrv);
3416 WILC_ERRORCHECK(s32Error);
3418 WILC_CATCH(s32Error)
3425 * @brief WILC_WFI_add_station
3426 * @details Add a new station.
3428 * @return int : Return 0 on Success.
3433 static int WILC_WFI_add_station(struct wiphy *wiphy, struct net_device *dev,
3434 const u8 *mac, struct station_parameters *params)
3436 WILC_Sint32 s32Error = WILC_SUCCESS;
3437 struct WILC_WFI_priv *priv;
3438 tstrWILC_AddStaParam strStaParams = {{0}};
3439 perInterface_wlan_t *nic;
3442 WILC_NULLCHECK(s32Error, wiphy);
3444 priv = wiphy_priv(wiphy);
3445 nic = netdev_priv(dev);
3447 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3448 #ifndef WILC_FULLY_HOSTING_AP
3450 WILC_memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
3451 WILC_memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN);
3452 strStaParams.u16AssocID = params->aid;
3453 strStaParams.u8NumRates = params->supported_rates_len;
3454 strStaParams.pu8Rates = params->supported_rates;
3456 PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid);
3458 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],
3459 priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]);
3460 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3461 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3463 if (params->ht_capa == NULL) {
3464 strStaParams.bIsHTSupported = WILC_FALSE;
3466 strStaParams.bIsHTSupported = WILC_TRUE;
3467 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3468 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
3469 WILC_memcpy(strStaParams.au8SuppMCsSet, ¶ms->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
3470 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3471 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3472 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3475 strStaParams.u16FlagsMask = params->sta_flags_mask;
3476 strStaParams.u16FlagsSet = params->sta_flags_set;
3478 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3479 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3480 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3481 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3482 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3483 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3484 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3485 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3487 s32Error = host_int_add_station(priv->hWILCWFIDrv, &strStaParams);
3488 WILC_ERRORCHECK(s32Error);
3491 PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid);
3492 WILC_memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN);
3494 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],
3495 priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]);
3497 WILC_AP_AddSta(mac, params);
3498 WILC_ERRORCHECK(s32Error);
3499 #endif /* WILC_FULLY_HOSTING_AP */
3503 WILC_CATCH(s32Error)
3510 * @brief WILC_WFI_del_station
3511 * @details Remove a station; @mac may be NULL to remove all stations.
3513 * @return int : Return 0 on Success.
3518 static int WILC_WFI_del_station(struct wiphy *wiphy, struct net_device *dev,
3519 struct station_del_parameters *params)
3521 const u8 *mac = params->mac;
3522 WILC_Sint32 s32Error = WILC_SUCCESS;
3523 struct WILC_WFI_priv *priv;
3524 perInterface_wlan_t *nic;
3525 WILC_NULLCHECK(s32Error, wiphy);
3526 /*BugID_4795: mac may be null pointer to indicate deleting all stations, so avoid null check*/
3527 /* WILC_NULLCHECK(s32Error, mac); */
3529 priv = wiphy_priv(wiphy);
3530 nic = netdev_priv(dev);
3532 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3533 PRINT_D(HOSTAPD_DBG, "Deleting station\n");
3537 PRINT_D(HOSTAPD_DBG, "All associated stations \n");
3538 s32Error = host_int_del_allstation(priv->hWILCWFIDrv, priv->assoc_stainfo.au8Sta_AssociatedBss);
3540 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]);
3543 #ifndef WILC_FULLY_HOSTING_AP
3544 s32Error = host_int_del_station(priv->hWILCWFIDrv, mac);
3546 WILC_AP_RemoveSta(mac);
3547 #endif /* WILC_FULLY_HOSTING_AP */
3549 WILC_ERRORCHECK(s32Error);
3551 WILC_CATCH(s32Error)
3558 * @brief WILC_WFI_change_station
3559 * @details Modify a given station.
3561 * @return int : Return 0 on Success.
3566 static int WILC_WFI_change_station(struct wiphy *wiphy, struct net_device *dev,
3567 const u8 *mac, struct station_parameters *params)
3569 WILC_Sint32 s32Error = WILC_SUCCESS;
3570 struct WILC_WFI_priv *priv;
3571 tstrWILC_AddStaParam strStaParams = {{0}};
3572 perInterface_wlan_t *nic;
3575 PRINT_D(HOSTAPD_DBG, "Change station paramters\n");
3577 WILC_NULLCHECK(s32Error, wiphy);
3579 priv = wiphy_priv(wiphy);
3580 nic = netdev_priv(dev);
3582 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3583 #ifndef WILC_FULLY_HOSTING_AP
3585 WILC_memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
3586 strStaParams.u16AssocID = params->aid;
3587 strStaParams.u8NumRates = params->supported_rates_len;
3588 strStaParams.pu8Rates = params->supported_rates;
3590 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],
3591 strStaParams.au8BSSID[5]);
3592 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3593 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3595 if (params->ht_capa == NULL) {
3596 strStaParams.bIsHTSupported = WILC_FALSE;
3598 strStaParams.bIsHTSupported = WILC_TRUE;
3599 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3600 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
3601 WILC_memcpy(strStaParams.au8SuppMCsSet, ¶ms->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
3602 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3603 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3604 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3608 strStaParams.u16FlagsMask = params->sta_flags_mask;
3609 strStaParams.u16FlagsSet = params->sta_flags_set;
3611 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3612 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3613 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3614 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3615 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3616 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3617 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3618 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3620 s32Error = host_int_edit_station(priv->hWILCWFIDrv, &strStaParams);
3621 WILC_ERRORCHECK(s32Error);
3624 WILC_AP_EditSta(mac, params);
3625 WILC_ERRORCHECK(s32Error);
3626 #endif /* WILC_FULLY_HOSTING_AP */
3629 WILC_CATCH(s32Error)
3637 * @brief WILC_WFI_add_virt_intf
3640 * @return int : Return 0 on Success.
3645 struct wireless_dev *WILC_WFI_add_virt_intf(struct wiphy *wiphy, const char *name,
3646 unsigned char name_assign_type,
3647 enum nl80211_iftype type, u32 *flags,
3648 struct vif_params *params)
3650 perInterface_wlan_t *nic;
3651 struct WILC_WFI_priv *priv;
3652 /* struct WILC_WFI_mon_priv* mon_priv; */
3653 struct net_device *new_ifc = NULL;
3654 priv = wiphy_priv(wiphy);
3658 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", priv->wdev->netdev);
3660 nic = netdev_priv(priv->wdev->netdev);
3663 if (type == NL80211_IFTYPE_MONITOR) {
3664 PRINT_D(HOSTAPD_DBG, "Monitor interface mode: Initializing mon interface virtual device driver\n");
3665 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", nic->wilc_netdev);
3666 new_ifc = WILC_WFI_init_mon_interface(name, nic->wilc_netdev);
3667 if (new_ifc != NULL) {
3668 PRINT_D(HOSTAPD_DBG, "Setting monitor flag in private structure\n");
3670 priv = netdev_priv(priv->wdev->netdev);
3671 priv->monitor_flag = 1;
3673 nic = netdev_priv(priv->wdev->netdev);
3674 nic->monitor_flag = 1;
3677 PRINT_ER("Error in initializing monitor interface\n ");
3683 * @brief WILC_WFI_del_virt_intf
3686 * @return int : Return 0 on Success.
3691 int WILC_WFI_del_virt_intf(struct wiphy *wiphy, struct wireless_dev *wdev) /* tony for v3.8 support */
3693 PRINT_D(HOSTAPD_DBG, "Deleting virtual interface\n");
3694 return WILC_SUCCESS;
3699 #endif /*WILC_AP_EXTERNAL_MLME*/
3700 static struct cfg80211_ops WILC_WFI_cfg80211_ops = {
3702 .set_monitor_channel = WILC_WFI_CfgSetChannel,
3703 .scan = WILC_WFI_CfgScan,
3704 .connect = WILC_WFI_CfgConnect,
3705 .disconnect = WILC_WFI_disconnect,
3706 .add_key = WILC_WFI_add_key,
3707 .del_key = WILC_WFI_del_key,
3708 .get_key = WILC_WFI_get_key,
3709 .set_default_key = WILC_WFI_set_default_key,
3710 /* .dump_survey = WILC_WFI_dump_survey, */
3711 #ifdef WILC_AP_EXTERNAL_MLME
3712 .add_virtual_intf = WILC_WFI_add_virt_intf,
3713 .del_virtual_intf = WILC_WFI_del_virt_intf,
3714 .change_virtual_intf = WILC_WFI_change_virt_intf,
3716 .start_ap = WILC_WFI_start_ap,
3717 .change_beacon = WILC_WFI_change_beacon,
3718 .stop_ap = WILC_WFI_stop_ap,
3719 .add_station = WILC_WFI_add_station,
3720 .del_station = WILC_WFI_del_station,
3721 .change_station = WILC_WFI_change_station,
3722 #endif /* WILC_AP_EXTERNAL_MLME*/
3723 #ifndef WILC_FULLY_HOSTING_AP
3724 .get_station = WILC_WFI_get_station,
3726 .dump_station = WILC_WFI_dump_station,
3727 .change_bss = WILC_WFI_change_bss,
3728 /* .auth = WILC_WFI_auth, */
3729 /* .assoc = WILC_WFI_assoc, */
3730 /* .deauth = WILC_WFI_deauth, */
3731 /* .disassoc = WILC_WFI_disassoc, */
3732 .set_wiphy_params = WILC_WFI_set_wiphy_params,
3734 /* .set_bitrate_mask = WILC_WFI_set_bitrate_mask, */
3735 .set_pmksa = WILC_WFI_set_pmksa,
3736 .del_pmksa = WILC_WFI_del_pmksa,
3737 .flush_pmksa = WILC_WFI_flush_pmksa,
3739 .remain_on_channel = WILC_WFI_remain_on_channel,
3740 .cancel_remain_on_channel = WILC_WFI_cancel_remain_on_channel,
3741 .mgmt_tx_cancel_wait = WILC_WFI_mgmt_tx_cancel_wait,
3742 .mgmt_tx = WILC_WFI_mgmt_tx,
3743 .mgmt_frame_register = WILC_WFI_frame_register,
3744 /* .mgmt_tx_cancel_wait = WILC_WFI_mgmt_tx_cancel_wait, */
3745 .set_power_mgmt = WILC_WFI_set_power_mgmt,
3746 .set_cqm_rssi_config = WILC_WFI_set_cqm_rssi_config,
3756 * @brief WILC_WFI_update_stats
3757 * @details Modify parameters for a given BSS.
3759 * @return int : Return 0 on Success.
3762 * @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
3764 int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed)
3767 struct WILC_WFI_priv *priv;
3769 priv = wiphy_priv(wiphy);
3770 /* down(&SemHandleUpdateStats); */
3774 case WILC_WFI_RX_PKT:
3776 /* MI_PRINTF("In Rx Receive Packet\n"); */
3777 priv->netstats.rx_packets++;
3778 priv->netstats.rx_bytes += pktlen;
3779 priv->netstats.rx_time = get_jiffies_64();
3783 case WILC_WFI_TX_PKT:
3785 priv->netstats.tx_packets++;
3786 priv->netstats.tx_bytes += pktlen;
3787 priv->netstats.tx_time = get_jiffies_64();
3795 /* down(&SemHandleUpdateStats); */
3800 * @brief WILC_WFI_InitPriv
3801 * @details Initialization of the net device, private data
3808 void WILC_WFI_InitPriv(struct net_device *dev)
3811 struct WILC_WFI_priv *priv;
3812 priv = netdev_priv(dev);
3814 priv->netstats.rx_packets = 0;
3815 priv->netstats.tx_packets = 0;
3816 priv->netstats.rx_bytes = 0;
3817 priv->netstats.rx_bytes = 0;
3818 priv->netstats.rx_time = 0;
3819 priv->netstats.tx_time = 0;
3824 * @brief WILC_WFI_CfgAlloc
3825 * @details Allocation of the wireless device structure and assigning it
3826 * to the cfg80211 operations structure.
3828 * @return wireless_dev : Returns pointer to wireless_dev structure.
3833 struct wireless_dev *WILC_WFI_CfgAlloc(void)
3836 struct wireless_dev *wdev;
3839 PRINT_D(CFG80211_DBG, "Allocating wireless device\n");
3840 /*Allocating the wireless device structure*/
3841 wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
3843 PRINT_ER("Cannot allocate wireless device\n");
3847 /*Creating a new wiphy, linking wireless structure with the wiphy structure*/
3848 wdev->wiphy = wiphy_new(&WILC_WFI_cfg80211_ops, sizeof(struct WILC_WFI_priv));
3850 PRINT_ER("Cannot allocate wiphy\n");
3855 #ifdef WILC_AP_EXTERNAL_MLME
3856 /* enable 802.11n HT */
3857 WILC_WFI_band_2ghz.ht_cap.ht_supported = 1;
3858 WILC_WFI_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT);
3859 WILC_WFI_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff;
3860 WILC_WFI_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K;
3861 WILC_WFI_band_2ghz.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE;
3865 wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &WILC_WFI_band_2ghz;
3876 * @brief WILC_WFI_WiphyRegister
3877 * @details Registering of the wiphy structure and interface modes
3884 struct wireless_dev *WILC_WFI_WiphyRegister(struct net_device *net)
3886 struct WILC_WFI_priv *priv;
3887 struct wireless_dev *wdev;
3888 WILC_Sint32 s32Error = WILC_SUCCESS;
3890 PRINT_D(CFG80211_DBG, "Registering wifi device\n");
3892 wdev = WILC_WFI_CfgAlloc();
3894 PRINT_ER("CfgAlloc Failed\n");
3899 /*Return hardware description structure (wiphy)'s priv*/
3900 priv = wdev_priv(wdev);
3901 sema_init(&(priv->SemHandleUpdateStats), 1);
3903 /*Link the wiphy with wireless structure*/
3906 /*Maximum number of probed ssid to be added by user for the scan request*/
3907 wdev->wiphy->max_scan_ssids = MAX_NUM_PROBED_SSID;
3908 /*Maximum number of pmkids to be cashed*/
3909 wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS;
3910 PRINT_INFO(CFG80211_DBG, "Max number of PMKIDs = %d\n", wdev->wiphy->max_num_pmkids);
3912 wdev->wiphy->max_scan_ie_len = 1000;
3914 /*signal strength in mBm (100*dBm) */
3915 wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
3917 /*Set the availaible cipher suites*/
3918 wdev->wiphy->cipher_suites = cipher_suites;
3919 wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
3920 /*Setting default managment types: for register action frame: */
3921 wdev->wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types;
3924 wdev->wiphy->max_remain_on_channel_duration = 500;
3925 /*Setting the wiphy interfcae mode and type before registering the wiphy*/
3926 wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | BIT(NL80211_IFTYPE_P2P_GO) |
3927 BIT(NL80211_IFTYPE_P2P_CLIENT);
3928 wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
3930 wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR);
3932 wdev->iftype = NL80211_IFTYPE_STATION;
3936 PRINT_INFO(CFG80211_DBG, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n",
3937 wdev->wiphy->max_scan_ssids, wdev->wiphy->max_scan_ie_len, wdev->wiphy->signal_type,
3938 wdev->wiphy->interface_modes, wdev->iftype);
3941 set_wiphy_dev(wdev->wiphy, &local_sdio_func->dev); /* tony */
3944 /*Register wiphy structure*/
3945 s32Error = wiphy_register(wdev->wiphy);
3947 PRINT_ER("Cannot register wiphy device\n");
3948 /*should define what action to be taken in such failure*/
3950 PRINT_D(CFG80211_DBG, "Successful Registering\n");
3954 /*wdev[i]->wiphy->interface_modes =
3955 * BIT(NL80211_IFTYPE_AP);
3956 * wdev[i]->iftype = NL80211_IFTYPE_AP;
3959 /*Pointing the priv structure the netdev*/
3960 priv = netdev_priv(net);
3962 /*linking the wireless_dev structure with the netdevice*/
3963 priv->dev->ieee80211_ptr = wdev;
3964 priv->dev->ml_priv = priv;
3965 wdev->netdev = priv->dev;
3969 ret = host_int_init(&priv->hWILCWFIDrv);
3971 PRINT_ER("Error Init Driver\n");
3979 * @brief WILC_WFI_WiphyFree
3980 * @details Freeing allocation of the wireless device structure
3987 int WILC_WFI_InitHostInt(struct net_device *net)
3990 WILC_Sint32 s32Error = WILC_SUCCESS;
3992 struct WILC_WFI_priv *priv;
3994 PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr);
3995 priv = wdev_priv(net->ieee80211_ptr);
3997 s32Error = WILC_TimerCreate(&(hAgingTimer), remove_network_from_shadow, NULL);
3998 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3999 s32Error = WILC_TimerCreate(&(hDuringIpTimer), clear_duringIP, NULL);
4004 PRINT_ER("Failed to creat refresh Timer\n");
4008 priv->gbAutoRateAdjusted = WILC_FALSE;
4010 priv->bInP2PlistenState = WILC_FALSE;
4012 sema_init(&(priv->hSemScanReq), 1);
4013 s32Error = host_int_init(&priv->hWILCWFIDrv);
4014 /* s32Error = host_int_init(&priv->hWILCWFIDrv_2); */
4016 PRINT_ER("Error while initializing hostinterface\n");
4022 * @brief WILC_WFI_WiphyFree
4023 * @details Freeing allocation of the wireless device structure
4030 int WILC_WFI_DeInitHostInt(struct net_device *net)
4032 WILC_Sint32 s32Error = WILC_SUCCESS;
4034 struct WILC_WFI_priv *priv;
4035 priv = wdev_priv(net->ieee80211_ptr);
4037 priv->gbAutoRateAdjusted = WILC_FALSE;
4039 priv->bInP2PlistenState = WILC_FALSE;
4043 s32Error = host_int_deinit(priv->hWILCWFIDrv);
4044 /* s32Error = host_int_deinit(priv->hWILCWFIDrv_2); */
4046 /* Clear the Shadow scan */
4047 clear_shadow_scan(priv);
4048 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
4050 PRINT_D(CORECONFIG_DBG, "destroy during ip\n");
4051 WILC_TimerDestroy(&hDuringIpTimer, NULL);
4056 PRINT_ER("Error while deintializing host interface\n");
4063 * @brief WILC_WFI_WiphyFree
4064 * @details Freeing allocation of the wireless device structure
4071 void WILC_WFI_WiphyFree(struct net_device *net)
4074 PRINT_D(CFG80211_DBG, "Unregistering wiphy\n");
4077 PRINT_D(INIT_DBG, "net_device is NULL\n");
4081 if (net->ieee80211_ptr == NULL) {
4082 PRINT_D(INIT_DBG, "ieee80211_ptr is NULL\n");
4086 if (net->ieee80211_ptr->wiphy == NULL) {
4087 PRINT_D(INIT_DBG, "wiphy is NULL\n");
4091 wiphy_unregister(net->ieee80211_ptr->wiphy);
4093 PRINT_D(INIT_DBG, "Freeing wiphy\n");
4094 wiphy_free(net->ieee80211_ptr->wiphy);
4095 kfree(net->ieee80211_ptr);