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() */
18 #include <linux/errno.h>
20 #define IS_MANAGMEMENT 0x100
21 #define IS_MANAGMEMENT_CALLBACK 0x080
22 #define IS_MGMT_STATUS_SUCCES 0x040
23 #define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff)
25 extern int linux_wlan_get_firmware(perInterface_wlan_t *p_nic);
26 extern u16 Set_machw_change_vir_if(bool bValue);
28 extern int mac_open(struct net_device *ndev);
29 extern int mac_close(struct net_device *ndev);
31 tstrNetworkInfo astrLastScannedNtwrksShadow[MAX_NUM_SCANNED_NETWORKS_SHADOW];
32 u32 u32LastScannedNtwrksCountShadow;
33 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
34 struct timer_list hDuringIpTimer;
36 struct timer_list hAgingTimer;
38 extern u8 u8ConnectedSSID[6];
41 u8 g_wilc_initialized = 1;
42 extern linux_wlan_t *g_linux_wlan;
43 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
44 extern bool g_obtainingIP;
47 #define CHAN2G(_channel, _freq, _flags) { \
48 .band = IEEE80211_BAND_2GHZ, \
49 .center_freq = (_freq), \
50 .hw_value = (_channel), \
52 .max_antenna_gain = 0, \
56 /*Frequency range for channels*/
57 static struct ieee80211_channel WILC_WFI_2ghz_channels[] = {
74 #define RATETAB_ENT(_rate, _hw_value, _flags) { \
76 .hw_value = (_hw_value), \
81 /* Table 6 in section 3.2.1.1 */
82 static struct ieee80211_rate WILC_WFI_rates[] = {
83 RATETAB_ENT(10, 0, 0),
84 RATETAB_ENT(20, 1, 0),
85 RATETAB_ENT(55, 2, 0),
86 RATETAB_ENT(110, 3, 0),
87 RATETAB_ENT(60, 9, 0),
88 RATETAB_ENT(90, 6, 0),
89 RATETAB_ENT(120, 7, 0),
90 RATETAB_ENT(180, 8, 0),
91 RATETAB_ENT(240, 9, 0),
92 RATETAB_ENT(360, 10, 0),
93 RATETAB_ENT(480, 11, 0),
94 RATETAB_ENT(540, 12, 0),
97 struct p2p_mgmt_data {
102 /*Global variable used to state the current connected STA channel*/
103 u8 u8WLANChannel = INVALID_CHANNEL;
108 u8 u8P2P_oui[] = {0x50, 0x6f, 0x9A, 0x09};
109 u8 u8P2Plocalrandom = 0x01;
110 u8 u8P2Precvrandom = 0x00;
111 u8 u8P2P_vendorspec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};
114 static struct ieee80211_supported_band WILC_WFI_band_2ghz = {
115 .channels = WILC_WFI_2ghz_channels,
116 .n_channels = ARRAY_SIZE(WILC_WFI_2ghz_channels),
117 .bitrates = WILC_WFI_rates,
118 .n_bitrates = ARRAY_SIZE(WILC_WFI_rates),
123 struct add_key_params {
128 struct add_key_params g_add_gtk_key_params;
129 struct wilc_wfi_key g_key_gtk_params;
130 struct add_key_params g_add_ptk_key_params;
131 struct wilc_wfi_key g_key_ptk_params;
132 struct wilc_wfi_wep_key g_key_wep_params;
133 bool g_ptk_keys_saved;
134 bool g_gtk_keys_saved;
135 bool g_wep_keys_saved;
137 #define AGING_TIME (9 * 1000)
138 #define duringIP_TIME 15000
140 void clear_shadow_scan(void *pUserVoid)
145 del_timer_sync(&hAgingTimer);
146 PRINT_INFO(CORECONFIG_DBG, "destroy aging timer\n");
148 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
149 if (astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs != NULL) {
150 kfree(astrLastScannedNtwrksShadow[i].pu8IEs);
151 astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs = NULL;
154 host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
155 astrLastScannedNtwrksShadow[i].pJoinParams = NULL;
157 u32LastScannedNtwrksCountShadow = 0;
162 u32 get_rssi_avg(tstrNetworkInfo *pstrNetworkInfo)
166 u8 num_rssi = (pstrNetworkInfo->strRssi.u8Full) ? NUM_RSSI : (pstrNetworkInfo->strRssi.u8Index);
168 for (i = 0; i < num_rssi; i++)
169 rssi_v += pstrNetworkInfo->strRssi.as8RSSI[i];
175 void refresh_scan(void *pUserVoid, u8 all, bool bDirectScan)
177 struct wilc_priv *priv;
179 struct cfg80211_bss *bss = NULL;
183 priv = (struct wilc_priv *)pUserVoid;
184 wiphy = priv->dev->ieee80211_ptr->wiphy;
186 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
187 tstrNetworkInfo *pstrNetworkInfo;
189 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
192 if ((!pstrNetworkInfo->u8Found) || all) {
194 struct ieee80211_channel *channel;
196 if (pstrNetworkInfo != NULL) {
198 s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
199 channel = ieee80211_get_channel(wiphy, s32Freq);
201 rssi = get_rssi_avg(pstrNetworkInfo);
202 if (memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7) || bDirectScan) {
203 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
204 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
205 (size_t)pstrNetworkInfo->u16IEsLen, (((s32)rssi) * 100), GFP_KERNEL);
206 cfg80211_put_bss(wiphy, bss);
215 void reset_shadow_found(void *pUserVoid)
219 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
220 astrLastScannedNtwrksShadow[i].u8Found = 0;
225 void update_scan_time(void *pUserVoid)
229 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
230 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
234 static void remove_network_from_shadow(unsigned long arg)
236 unsigned long now = jiffies;
240 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
241 if (time_after(now, astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan + (unsigned long)(SCAN_RESULT_EXPIRE))) {
242 PRINT_D(CFG80211_DBG, "Network expired in ScanShadow: %s\n", astrLastScannedNtwrksShadow[i].au8ssid);
244 if (astrLastScannedNtwrksShadow[i].pu8IEs != NULL) {
245 kfree(astrLastScannedNtwrksShadow[i].pu8IEs);
246 astrLastScannedNtwrksShadow[i].pu8IEs = NULL;
249 host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
251 for (j = i; (j < u32LastScannedNtwrksCountShadow - 1); j++) {
252 astrLastScannedNtwrksShadow[j] = astrLastScannedNtwrksShadow[j + 1];
254 u32LastScannedNtwrksCountShadow--;
258 PRINT_D(CFG80211_DBG, "Number of cached networks: %d\n", u32LastScannedNtwrksCountShadow);
259 if (u32LastScannedNtwrksCountShadow != 0) {
260 hAgingTimer.data = arg;
261 mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
263 PRINT_D(CFG80211_DBG, "No need to restart Aging timer\n");
267 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
268 static void clear_duringIP(unsigned long arg)
270 PRINT_D(GENERIC_DBG, "GO:IP Obtained , enable scan\n");
271 g_obtainingIP = false;
275 int8_t is_network_in_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid)
280 if (u32LastScannedNtwrksCountShadow == 0) {
281 PRINT_D(CFG80211_DBG, "Starting Aging timer\n");
282 hAgingTimer.data = (unsigned long)pUserVoid;
283 mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
286 /* Linear search for now */
287 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
288 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
289 pstrNetworkInfo->au8bssid, 6) == 0) {
298 void add_network_to_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
300 int8_t ap_found = is_network_in_shadow(pstrNetworkInfo, pUserVoid);
304 if (u32LastScannedNtwrksCountShadow >= MAX_NUM_SCANNED_NETWORKS_SHADOW) {
305 PRINT_D(CFG80211_DBG, "Shadow network reached its maximum limit\n");
308 if (ap_found == -1) {
309 ap_index = u32LastScannedNtwrksCountShadow;
310 u32LastScannedNtwrksCountShadow++;
315 rssi_index = astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index;
316 astrLastScannedNtwrksShadow[ap_index].strRssi.as8RSSI[rssi_index++] = pstrNetworkInfo->s8rssi;
317 if (rssi_index == NUM_RSSI) {
319 astrLastScannedNtwrksShadow[ap_index].strRssi.u8Full = 1;
321 astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index = rssi_index;
323 astrLastScannedNtwrksShadow[ap_index].s8rssi = pstrNetworkInfo->s8rssi;
324 astrLastScannedNtwrksShadow[ap_index].u16CapInfo = pstrNetworkInfo->u16CapInfo;
326 astrLastScannedNtwrksShadow[ap_index].u8SsidLen = pstrNetworkInfo->u8SsidLen;
327 memcpy(astrLastScannedNtwrksShadow[ap_index].au8ssid,
328 pstrNetworkInfo->au8ssid, pstrNetworkInfo->u8SsidLen);
330 memcpy(astrLastScannedNtwrksShadow[ap_index].au8bssid,
331 pstrNetworkInfo->au8bssid, ETH_ALEN);
333 astrLastScannedNtwrksShadow[ap_index].u16BeaconPeriod = pstrNetworkInfo->u16BeaconPeriod;
334 astrLastScannedNtwrksShadow[ap_index].u8DtimPeriod = pstrNetworkInfo->u8DtimPeriod;
335 astrLastScannedNtwrksShadow[ap_index].u8channel = pstrNetworkInfo->u8channel;
337 astrLastScannedNtwrksShadow[ap_index].u16IEsLen = pstrNetworkInfo->u16IEsLen;
338 astrLastScannedNtwrksShadow[ap_index].u64Tsf = pstrNetworkInfo->u64Tsf;
340 kfree(astrLastScannedNtwrksShadow[ap_index].pu8IEs);
341 astrLastScannedNtwrksShadow[ap_index].pu8IEs =
342 kmalloc(pstrNetworkInfo->u16IEsLen, GFP_KERNEL); /* will be deallocated by the WILC_WFI_CfgScan() function */
343 memcpy(astrLastScannedNtwrksShadow[ap_index].pu8IEs,
344 pstrNetworkInfo->pu8IEs, pstrNetworkInfo->u16IEsLen);
346 astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScan = jiffies;
347 astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScanCached = jiffies;
348 astrLastScannedNtwrksShadow[ap_index].u8Found = 1;
350 host_int_freeJoinParams(astrLastScannedNtwrksShadow[ap_index].pJoinParams);
351 astrLastScannedNtwrksShadow[ap_index].pJoinParams = pJoinParams;
357 * @brief CfgScanResult
358 * @details Callback function which returns the scan results found
360 * @param[in] tenuScanEvent enuScanEvent: enum, indicating the scan event triggered, whether that is
361 * SCAN_EVENT_NETWORK_FOUND or SCAN_EVENT_DONE
362 * tstrNetworkInfo* pstrNetworkInfo: structure holding the scan results information
363 * void* pUserVoid: Private structure associated with the wireless interface
369 static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
371 struct wilc_priv *priv;
374 struct ieee80211_channel *channel;
375 struct cfg80211_bss *bss = NULL;
377 priv = (struct wilc_priv *)pUserVoid;
378 if (priv->bCfgScanning == true) {
379 if (enuScanEvent == SCAN_EVENT_NETWORK_FOUND) {
380 wiphy = priv->dev->ieee80211_ptr->wiphy;
385 if (wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC
387 ((((s32)pstrNetworkInfo->s8rssi) * 100) < 0
389 (((s32)pstrNetworkInfo->s8rssi) * 100) > 100)
391 PRINT_ER("wiphy signal type fial\n");
395 if (pstrNetworkInfo != NULL) {
396 s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
397 channel = ieee80211_get_channel(wiphy, s32Freq);
402 PRINT_INFO(CFG80211_DBG, "Network Info:: CHANNEL Frequency: %d, RSSI: %d, CapabilityInfo: %d,"
403 "BeaconPeriod: %d\n", channel->center_freq, (((s32)pstrNetworkInfo->s8rssi) * 100),
404 pstrNetworkInfo->u16CapInfo, pstrNetworkInfo->u16BeaconPeriod);
406 if (pstrNetworkInfo->bNewNetwork == true) {
407 if (priv->u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
409 PRINT_D(CFG80211_DBG, "Network %s found\n", pstrNetworkInfo->au8ssid);
412 priv->u32RcvdChCount++;
416 if (pJoinParams == NULL) {
417 PRINT_INFO(CORECONFIG_DBG, ">> Something really bad happened\n");
419 add_network_to_shadow(pstrNetworkInfo, priv, pJoinParams);
421 /*P2P peers are sent to WPA supplicant and added to shadow table*/
423 if (!(memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7))) {
424 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
425 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
426 (size_t)pstrNetworkInfo->u16IEsLen, (((s32)pstrNetworkInfo->s8rssi) * 100), GFP_KERNEL);
427 cfg80211_put_bss(wiphy, bss);
432 PRINT_ER("Discovered networks exceeded the max limit\n");
436 /* So this network is discovered before, we'll just update its RSSI */
437 for (i = 0; i < priv->u32RcvdChCount; i++) {
438 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid, pstrNetworkInfo->au8bssid, 6) == 0) {
439 PRINT_D(CFG80211_DBG, "Update RSSI of %s\n", astrLastScannedNtwrksShadow[i].au8ssid);
441 astrLastScannedNtwrksShadow[i].s8rssi = pstrNetworkInfo->s8rssi;
442 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
448 } else if (enuScanEvent == SCAN_EVENT_DONE) {
449 PRINT_D(CFG80211_DBG, "Scan Done[%p]\n", priv->dev);
450 PRINT_D(CFG80211_DBG, "Refreshing Scan ...\n");
451 refresh_scan(priv, 1, false);
453 if (priv->u32RcvdChCount > 0)
454 PRINT_D(CFG80211_DBG, "%d Network(s) found\n", priv->u32RcvdChCount);
456 PRINT_D(CFG80211_DBG, "No networks found\n");
458 down(&(priv->hSemScanReq));
460 if (priv->pstrScanReq != NULL) {
461 cfg80211_scan_done(priv->pstrScanReq, false);
462 priv->u32RcvdChCount = 0;
463 priv->bCfgScanning = false;
464 priv->pstrScanReq = NULL;
466 up(&(priv->hSemScanReq));
469 /*Aborting any scan operation during mac close*/
470 else if (enuScanEvent == SCAN_EVENT_ABORTED) {
471 down(&(priv->hSemScanReq));
473 PRINT_D(CFG80211_DBG, "Scan Aborted\n");
474 if (priv->pstrScanReq != NULL) {
476 update_scan_time(priv);
477 refresh_scan(priv, 1, false);
479 cfg80211_scan_done(priv->pstrScanReq, false);
480 priv->bCfgScanning = false;
481 priv->pstrScanReq = NULL;
483 up(&(priv->hSemScanReq));
490 * @brief WILC_WFI_Set_PMKSA
491 * @details Check if pmksa is cached and set it.
493 * @return int : Return 0 on Success
498 int WILC_WFI_Set_PMKSA(u8 *bssid, struct wilc_priv *priv)
504 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
506 if (!memcmp(bssid, priv->pmkid_list.pmkidlist[i].bssid,
508 PRINT_D(CFG80211_DBG, "PMKID successful comparison");
510 /*If bssid is found, set the values*/
511 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
514 PRINT_ER("Error in pmkid\n");
524 int linux_wlan_set_bssid(struct net_device *wilc_netdev, u8 *pBSSID);
528 * @brief CfgConnectResult
530 * @param[in] tenuConnDisconnEvent enuConnDisconnEvent: Type of connection response either
531 * connection response or disconnection notification.
532 * tstrConnectInfo* pstrConnectInfo: COnnection information.
533 * u8 u8MacStatus: Mac Status from firmware
534 * tstrDisconnectNotifInfo* pstrDisconnectNotifInfo: Disconnection Notification
535 * void* pUserVoid: Private data associated with wireless interface
543 static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent,
544 tstrConnectInfo *pstrConnectInfo,
546 tstrDisconnectNotifInfo *pstrDisconnectNotifInfo,
549 struct wilc_priv *priv;
550 struct net_device *dev;
551 tstrWILC_WFIDrv *pstrWFIDrv;
552 u8 NullBssid[ETH_ALEN] = {0};
556 priv = (struct wilc_priv *)pUserVoid;
558 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
560 if (enuConnDisconnEvent == CONN_DISCONN_EVENT_CONN_RESP) {
562 u16 u16ConnectStatus = WLAN_STATUS_SUCCESS;
564 u16ConnectStatus = pstrConnectInfo->u16ConnectStatus;
566 PRINT_D(CFG80211_DBG, " Connection response received = %d\n", u8MacStatus);
568 if ((u8MacStatus == MAC_DISCONNECTED) &&
569 (pstrConnectInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
570 /* The case here is that our station was waiting for association response frame and has just received it containing status code
571 * = SUCCESSFUL_STATUSCODE, while mac status is MAC_DISCONNECTED (which means something wrong happened) */
572 u16ConnectStatus = WLAN_STATUS_UNSPECIFIED_FAILURE;
573 linux_wlan_set_bssid(priv->dev, NullBssid);
574 memset(u8ConnectedSSID, 0, ETH_ALEN);
577 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
578 if (!pstrWFIDrv->u8P2PConnect)
579 u8WLANChannel = INVALID_CHANNEL;
581 PRINT_ER("Unspecified failure: Connection status %d : MAC status = %d\n", u16ConnectStatus, u8MacStatus);
584 if (u16ConnectStatus == WLAN_STATUS_SUCCESS) {
585 bool bNeedScanRefresh = false;
588 PRINT_INFO(CFG80211_DBG, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo->au8bssid[0],
589 pstrConnectInfo->au8bssid[1], pstrConnectInfo->au8bssid[2], pstrConnectInfo->au8bssid[3], pstrConnectInfo->au8bssid[4], pstrConnectInfo->au8bssid[5]);
590 memcpy(priv->au8AssociatedBss, pstrConnectInfo->au8bssid, ETH_ALEN);
592 /* BugID_4209: if this network has expired in the scan results in the above nl80211 layer, refresh them here by calling
593 * cfg80211_inform_bss() with the last Scan results before calling cfg80211_connect_result() to avoid
594 * Linux kernel warning generated at the nl80211 layer */
596 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
597 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
598 pstrConnectInfo->au8bssid, ETH_ALEN) == 0) {
599 unsigned long now = jiffies;
602 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScanCached + (unsigned long)(nl80211_SCAN_RESULT_EXPIRE - (1 * HZ)))) {
603 bNeedScanRefresh = true;
610 if (bNeedScanRefresh) {
612 /*Also, refrsh DIRECT- results if */
613 refresh_scan(priv, 1, true);
620 PRINT_D(CFG80211_DBG, "Association request info elements length = %zu\n", pstrConnectInfo->ReqIEsLen);
622 PRINT_D(CFG80211_DBG, "Association response info elements length = %d\n", pstrConnectInfo->u16RespIEsLen);
624 cfg80211_connect_result(dev, pstrConnectInfo->au8bssid,
625 pstrConnectInfo->pu8ReqIEs, pstrConnectInfo->ReqIEsLen,
626 pstrConnectInfo->pu8RespIEs, pstrConnectInfo->u16RespIEsLen,
627 u16ConnectStatus, GFP_KERNEL); /* TODO: mostafa: u16ConnectStatus to */
628 /* be replaced by pstrConnectInfo->u16ConnectStatus */
629 } else if (enuConnDisconnEvent == CONN_DISCONN_EVENT_DISCONN_NOTIF) {
630 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
631 g_obtainingIP = false;
633 PRINT_ER("Received MAC_DISCONNECTED from firmware with reason %d on dev [%p]\n",
634 pstrDisconnectNotifInfo->u16reason, priv->dev);
635 u8P2Plocalrandom = 0x01;
636 u8P2Precvrandom = 0x00;
638 memset(priv->au8AssociatedBss, 0, ETH_ALEN);
639 linux_wlan_set_bssid(priv->dev, NullBssid);
640 memset(u8ConnectedSSID, 0, ETH_ALEN);
643 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
644 if (!pstrWFIDrv->u8P2PConnect)
645 u8WLANChannel = INVALID_CHANNEL;
647 /*Incase "P2P CLIENT Connected" send deauthentication reason by 3 to force the WPA_SUPPLICANT to directly change
648 * virtual interface to station*/
649 if ((pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) {
650 pstrDisconnectNotifInfo->u16reason = 3;
653 /*Incase "P2P CLIENT during connection(not connected)" send deauthentication reason by 1 to force the WPA_SUPPLICANT
654 * to scan again and retry the connection*/
655 else if ((!pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) {
656 pstrDisconnectNotifInfo->u16reason = 1;
658 cfg80211_disconnected(dev, pstrDisconnectNotifInfo->u16reason, pstrDisconnectNotifInfo->ie,
659 pstrDisconnectNotifInfo->ie_len, false,
669 * @details Set channel for a given wireless interface. Some devices
670 * may support multi-channel operation (by channel hopping) so cfg80211
671 * doesn't verify much. Note, however, that the passed netdev may be
672 * %NULL as well if the user requested changing the channel for the
673 * device itself, or for a monitor interface.
675 * @return int : Return 0 on Success
680 static int set_channel(struct wiphy *wiphy,
681 struct cfg80211_chan_def *chandef)
685 struct wilc_priv *priv;
688 priv = wiphy_priv(wiphy);
690 channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq);
691 PRINT_D(CFG80211_DBG, "Setting channel %d with frequency %d\n", channelnum, chandef->chan->center_freq);
693 u8CurrChannel = channelnum;
694 s32Error = host_int_set_mac_chnl_num(priv->hWILCWFIDrv, channelnum);
697 PRINT_ER("Error in setting channel %d\n", channelnum);
704 * @details Request to do a scan. If returning zero, the scan request is given
705 * the driver, and will be valid until passed to cfg80211_scan_done().
706 * For scan results, call cfg80211_inform_bss(); you can call this outside
707 * the scan/scan_done bracket too.
709 * @return int : Return 0 on Success
716 * kernel version 3.8.8 supported
717 * tony, sswd, WILC-KR, 2013-10-29
719 static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
721 struct wilc_priv *priv;
724 u8 au8ScanChanList[MAX_NUM_SCANNED_NETWORKS];
725 tstrHiddenNetwork strHiddenNetwork;
727 priv = wiphy_priv(wiphy);
729 priv->pstrScanReq = request;
731 priv->u32RcvdChCount = 0;
733 host_int_set_wfi_drv_handler(priv->hWILCWFIDrv);
736 reset_shadow_found(priv);
738 priv->bCfgScanning = true;
739 if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
741 for (i = 0; i < request->n_channels; i++) {
742 au8ScanChanList[i] = (u8)ieee80211_frequency_to_channel(request->channels[i]->center_freq);
743 PRINT_INFO(CFG80211_DBG, "ScanChannel List[%d] = %d,", i, au8ScanChanList[i]);
746 PRINT_D(CFG80211_DBG, "Requested num of scan channel %d\n", request->n_channels);
747 PRINT_D(CFG80211_DBG, "Scan Request IE len = %zu\n", request->ie_len);
749 PRINT_D(CFG80211_DBG, "Number of SSIDs %d\n", request->n_ssids);
751 if (request->n_ssids >= 1) {
754 strHiddenNetwork.pstrHiddenNetworkInfo = kmalloc(request->n_ssids * sizeof(tstrHiddenNetwork), GFP_KERNEL);
755 strHiddenNetwork.u8ssidnum = request->n_ssids;
759 for (i = 0; i < request->n_ssids; i++) {
761 if (request->ssids[i].ssid != NULL && request->ssids[i].ssid_len != 0) {
762 strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid = kmalloc(request->ssids[i].ssid_len, GFP_KERNEL);
763 memcpy(strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, request->ssids[i].ssid, request->ssids[i].ssid_len);
764 strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen = request->ssids[i].ssid_len;
766 PRINT_D(CFG80211_DBG, "Received one NULL SSID\n");
767 strHiddenNetwork.u8ssidnum -= 1;
770 PRINT_D(CFG80211_DBG, "Trigger Scan Request\n");
771 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
772 au8ScanChanList, request->n_channels,
773 (const u8 *)request->ie, request->ie_len,
774 CfgScanResult, (void *)priv, &strHiddenNetwork);
776 PRINT_D(CFG80211_DBG, "Trigger Scan Request\n");
777 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
778 au8ScanChanList, request->n_channels,
779 (const u8 *)request->ie, request->ie_len,
780 CfgScanResult, (void *)priv, NULL);
784 PRINT_ER("Requested num of scanned channels is greater than the max, supported"
790 PRINT_WRN(CFG80211_DBG, "Device is busy: Error(%d)\n", s32Error);
798 * @details Connect to the ESS with the specified parameters. When connected,
799 * call cfg80211_connect_result() with status code %WLAN_STATUS_SUCCESS.
800 * If the connection fails for some reason, call cfg80211_connect_result()
801 * with the status from the AP.
803 * @return int : Return 0 on Success
808 static int connect(struct wiphy *wiphy, struct net_device *dev,
809 struct cfg80211_connect_params *sme)
813 u8 u8security = NO_ENCRYPT;
814 AUTHTYPE_T tenuAuth_type = ANY;
815 char *pcgroup_encrypt_val = NULL;
816 char *pccipher_group = NULL;
817 char *pcwpa_version = NULL;
819 struct wilc_priv *priv;
820 tstrWILC_WFIDrv *pstrWFIDrv;
821 tstrNetworkInfo *pstrNetworkInfo = NULL;
825 priv = wiphy_priv(wiphy);
826 pstrWFIDrv = (tstrWILC_WFIDrv *)(priv->hWILCWFIDrv);
828 host_int_set_wfi_drv_handler(priv->hWILCWFIDrv);
830 PRINT_D(CFG80211_DBG, "Connecting to SSID [%s] on netdev [%p] host if [%p]\n", sme->ssid, dev, priv->hWILCWFIDrv);
831 if (!(strncmp(sme->ssid, "DIRECT-", 7))) {
832 PRINT_D(CFG80211_DBG, "Connected to Direct network,OBSS disabled\n");
833 pstrWFIDrv->u8P2PConnect = 1;
835 pstrWFIDrv->u8P2PConnect = 0;
836 PRINT_INFO(CFG80211_DBG, "Required SSID = %s\n , AuthType = %d\n", sme->ssid, sme->auth_type);
838 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
839 if ((sme->ssid_len == astrLastScannedNtwrksShadow[i].u8SsidLen) &&
840 memcmp(astrLastScannedNtwrksShadow[i].au8ssid,
842 sme->ssid_len) == 0) {
843 PRINT_INFO(CFG80211_DBG, "Network with required SSID is found %s\n", sme->ssid);
844 if (sme->bssid == NULL) {
845 /* BSSID is not passed from the user, so decision of matching
846 * is done by SSID only */
847 PRINT_INFO(CFG80211_DBG, "BSSID is not passed from the user\n");
850 /* BSSID is also passed from the user, so decision of matching
851 * should consider also this passed BSSID */
852 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
855 PRINT_INFO(CFG80211_DBG, "BSSID is passed from the user and matched\n");
862 if (i < u32LastScannedNtwrksCountShadow) {
863 PRINT_D(CFG80211_DBG, "Required bss is in scan results\n");
865 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
867 PRINT_INFO(CFG80211_DBG, "network BSSID to be associated: %x%x%x%x%x%x\n",
868 pstrNetworkInfo->au8bssid[0], pstrNetworkInfo->au8bssid[1],
869 pstrNetworkInfo->au8bssid[2], pstrNetworkInfo->au8bssid[3],
870 pstrNetworkInfo->au8bssid[4], pstrNetworkInfo->au8bssid[5]);
873 if (u32LastScannedNtwrksCountShadow == 0)
874 PRINT_D(CFG80211_DBG, "No Scan results yet\n");
876 PRINT_D(CFG80211_DBG, "Required bss not in scan results: Error(%d)\n", s32Error);
881 priv->WILC_WFI_wep_default = 0;
882 memset(priv->WILC_WFI_wep_key, 0, sizeof(priv->WILC_WFI_wep_key));
883 memset(priv->WILC_WFI_wep_key_len, 0, sizeof(priv->WILC_WFI_wep_key_len));
885 PRINT_INFO(CFG80211_DBG, "sme->crypto.wpa_versions=%x\n", sme->crypto.wpa_versions);
886 PRINT_INFO(CFG80211_DBG, "sme->crypto.cipher_group=%x\n", sme->crypto.cipher_group);
888 PRINT_INFO(CFG80211_DBG, "sme->crypto.n_ciphers_pairwise=%d\n", sme->crypto.n_ciphers_pairwise);
891 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++)
892 PRINT_D(CORECONFIG_DBG, "sme->crypto.ciphers_pairwise[%d]=%x\n", i, sme->crypto.ciphers_pairwise[i]);
895 if (sme->crypto.cipher_group != NO_ENCRYPT) {
896 /* To determine the u8security value, first we check the group cipher suite then {in case of WPA or WPA2}
897 * we will add to it the pairwise cipher suite(s) */
898 pcwpa_version = "Default";
899 PRINT_D(CORECONFIG_DBG, ">> sme->crypto.wpa_versions: %x\n", sme->crypto.wpa_versions);
900 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) {
901 u8security = ENCRYPT_ENABLED | WEP;
902 pcgroup_encrypt_val = "WEP40";
903 pccipher_group = "WLAN_CIPHER_SUITE_WEP40";
904 PRINT_INFO(CFG80211_DBG, "WEP Default Key Idx = %d\n", sme->key_idx);
907 for (i = 0; i < sme->key_len; i++)
908 PRINT_D(CORECONFIG_DBG, "WEP Key Value[%d] = %d\n", i, sme->key[i]);
910 priv->WILC_WFI_wep_default = sme->key_idx;
911 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
912 memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
915 g_key_wep_params.key_len = sme->key_len;
916 g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL);
917 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
918 g_key_wep_params.key_idx = sme->key_idx;
919 g_wep_keys_saved = true;
921 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
922 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
923 } else if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104) {
924 u8security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
925 pcgroup_encrypt_val = "WEP104";
926 pccipher_group = "WLAN_CIPHER_SUITE_WEP104";
928 priv->WILC_WFI_wep_default = sme->key_idx;
929 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
930 memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
933 g_key_wep_params.key_len = sme->key_len;
934 g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL);
935 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
936 g_key_wep_params.key_idx = sme->key_idx;
937 g_wep_keys_saved = true;
939 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
940 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
941 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) {
942 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
943 u8security = ENCRYPT_ENABLED | WPA2 | TKIP;
944 pcgroup_encrypt_val = "WPA2_TKIP";
945 pccipher_group = "TKIP";
946 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
947 /* tenuSecurity_t = WPA2_AES; */
948 u8security = ENCRYPT_ENABLED | WPA2 | AES;
949 pcgroup_encrypt_val = "WPA2_AES";
950 pccipher_group = "AES";
952 pcwpa_version = "WPA_VERSION_2";
953 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) {
954 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
955 u8security = ENCRYPT_ENABLED | WPA | TKIP;
956 pcgroup_encrypt_val = "WPA_TKIP";
957 pccipher_group = "TKIP";
958 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
959 /* tenuSecurity_t = WPA_AES; */
960 u8security = ENCRYPT_ENABLED | WPA | AES;
961 pcgroup_encrypt_val = "WPA_AES";
962 pccipher_group = "AES";
965 pcwpa_version = "WPA_VERSION_1";
968 s32Error = -ENOTSUPP;
969 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
976 /* After we set the u8security value from checking the group cipher suite, {in case of WPA or WPA2} we will
977 * add to it the pairwise cipher suite(s) */
978 if ((sme->crypto.wpa_versions & NL80211_WPA_VERSION_1)
979 || (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)) {
980 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) {
981 if (sme->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP) {
982 u8security = u8security | TKIP;
983 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
984 u8security = u8security | AES;
989 PRINT_D(CFG80211_DBG, "Adding key with cipher group = %x\n", sme->crypto.cipher_group);
991 PRINT_D(CFG80211_DBG, "Authentication Type = %d\n", sme->auth_type);
992 switch (sme->auth_type) {
993 case NL80211_AUTHTYPE_OPEN_SYSTEM:
994 PRINT_D(CFG80211_DBG, "In OPEN SYSTEM\n");
995 tenuAuth_type = OPEN_SYSTEM;
998 case NL80211_AUTHTYPE_SHARED_KEY:
999 tenuAuth_type = SHARED_KEY;
1000 PRINT_D(CFG80211_DBG, "In SHARED KEY\n");
1004 PRINT_D(CFG80211_DBG, "Automatic Authentation type = %d\n", sme->auth_type);
1008 /* ai: key_mgmt: enterprise case */
1009 if (sme->crypto.n_akm_suites) {
1010 switch (sme->crypto.akm_suites[0]) {
1011 case WLAN_AKM_SUITE_8021X:
1012 tenuAuth_type = IEEE8021;
1021 PRINT_INFO(CFG80211_DBG, "Required Channel = %d\n", pstrNetworkInfo->u8channel);
1023 PRINT_INFO(CFG80211_DBG, "Group encryption value = %s\n Cipher Group = %s\n WPA version = %s\n",
1024 pcgroup_encrypt_val, pccipher_group, pcwpa_version);
1027 u8CurrChannel = pstrNetworkInfo->u8channel;
1029 if (!pstrWFIDrv->u8P2PConnect) {
1030 u8WLANChannel = pstrNetworkInfo->u8channel;
1033 linux_wlan_set_bssid(dev, pstrNetworkInfo->au8bssid);
1035 s32Error = host_int_set_join_req(priv->hWILCWFIDrv, pstrNetworkInfo->au8bssid, sme->ssid,
1036 sme->ssid_len, sme->ie, sme->ie_len,
1037 CfgConnectResult, (void *)priv, u8security,
1038 tenuAuth_type, pstrNetworkInfo->u8channel,
1039 pstrNetworkInfo->pJoinParams);
1040 if (s32Error != 0) {
1041 PRINT_ER("host_int_set_join_req(): Error(%d)\n", s32Error);
1054 * @details Disconnect from the BSS/ESS.
1056 * @return int : Return 0 on Success
1061 static int disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code)
1064 struct wilc_priv *priv;
1065 tstrWILC_WFIDrv *pstrWFIDrv;
1066 u8 NullBssid[ETH_ALEN] = {0};
1069 priv = wiphy_priv(wiphy);
1072 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
1073 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
1074 if (!pstrWFIDrv->u8P2PConnect)
1075 u8WLANChannel = INVALID_CHANNEL;
1076 linux_wlan_set_bssid(priv->dev, NullBssid);
1078 PRINT_D(CFG80211_DBG, "Disconnecting with reason code(%d)\n", reason_code);
1080 u8P2Plocalrandom = 0x01;
1081 u8P2Precvrandom = 0x00;
1083 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
1085 s32Error = host_int_disconnect(priv->hWILCWFIDrv, reason_code);
1086 if (s32Error != 0) {
1087 PRINT_ER("Error in disconnecting: Error(%d)\n", s32Error);
1096 * @details Add a key with the given parameters. @mac_addr will be %NULL
1097 * when adding a group key.
1098 * @param[in] key : key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key, 8-byte Rx Mic Key
1099 * @return int : Return 0 on Success
1104 static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1106 const u8 *mac_addr, struct key_params *params)
1109 s32 s32Error = 0, KeyLen = params->key_len;
1111 struct wilc_priv *priv;
1112 const u8 *pu8RxMic = NULL;
1113 const u8 *pu8TxMic = NULL;
1114 u8 u8mode = NO_ENCRYPT;
1115 u8 u8gmode = NO_ENCRYPT;
1116 u8 u8pmode = NO_ENCRYPT;
1117 AUTHTYPE_T tenuAuth_type = ANY;
1119 priv = wiphy_priv(wiphy);
1121 PRINT_D(CFG80211_DBG, "Adding key with cipher suite = %x\n", params->cipher);
1124 PRINT_D(CFG80211_DBG, "%p %p %d\n", wiphy, netdev, key_index);
1126 PRINT_D(CFG80211_DBG, "key %x %x %x\n", params->key[0],
1131 switch (params->cipher) {
1132 case WLAN_CIPHER_SUITE_WEP40:
1133 case WLAN_CIPHER_SUITE_WEP104:
1134 if (priv->wdev->iftype == NL80211_IFTYPE_AP) {
1136 priv->WILC_WFI_wep_default = key_index;
1137 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
1138 memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
1140 PRINT_D(CFG80211_DBG, "Adding AP WEP Default key Idx = %d\n", key_index);
1141 PRINT_D(CFG80211_DBG, "Adding AP WEP Key len= %d\n", params->key_len);
1143 for (i = 0; i < params->key_len; i++)
1144 PRINT_D(CFG80211_DBG, "WEP AP key val[%d] = %x\n", i, params->key[i]);
1146 tenuAuth_type = OPEN_SYSTEM;
1148 if (params->cipher == WLAN_CIPHER_SUITE_WEP40)
1149 u8mode = ENCRYPT_ENABLED | WEP;
1151 u8mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
1153 host_int_add_wep_key_bss_ap(priv->hWILCWFIDrv, params->key, params->key_len, key_index, u8mode, tenuAuth_type);
1156 if (memcmp(params->key, priv->WILC_WFI_wep_key[key_index], params->key_len)) {
1157 priv->WILC_WFI_wep_default = key_index;
1158 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
1159 memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
1161 PRINT_D(CFG80211_DBG, "Adding WEP Default key Idx = %d\n", key_index);
1162 PRINT_D(CFG80211_DBG, "Adding WEP Key length = %d\n", params->key_len);
1164 for (i = 0; i < params->key_len; i++)
1165 PRINT_INFO(CFG80211_DBG, "WEP key value[%d] = %d\n", i, params->key[i]);
1167 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, params->key, params->key_len, key_index);
1172 case WLAN_CIPHER_SUITE_TKIP:
1173 case WLAN_CIPHER_SUITE_CCMP:
1174 if (priv->wdev->iftype == NL80211_IFTYPE_AP || priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) {
1176 if (priv->wilc_gtk[key_index] == NULL) {
1177 priv->wilc_gtk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL);
1178 priv->wilc_gtk[key_index]->key = NULL;
1179 priv->wilc_gtk[key_index]->seq = NULL;
1182 if (priv->wilc_ptk[key_index] == NULL) {
1183 priv->wilc_ptk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL);
1184 priv->wilc_ptk[key_index]->key = NULL;
1185 priv->wilc_ptk[key_index]->seq = NULL;
1191 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1192 u8gmode = ENCRYPT_ENABLED | WPA | TKIP;
1194 u8gmode = ENCRYPT_ENABLED | WPA2 | AES;
1196 priv->wilc_groupkey = u8gmode;
1198 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1200 pu8TxMic = params->key + 24;
1201 pu8RxMic = params->key + 16;
1202 KeyLen = params->key_len - 16;
1204 /* if there has been previous allocation for the same index through its key, free that memory and allocate again*/
1205 if (priv->wilc_gtk[key_index]->key)
1206 kfree(priv->wilc_gtk[key_index]->key);
1208 priv->wilc_gtk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
1209 memcpy(priv->wilc_gtk[key_index]->key, params->key, params->key_len);
1211 /* if there has been previous allocation for the same index through its seq, free that memory and allocate again*/
1212 if (priv->wilc_gtk[key_index]->seq)
1213 kfree(priv->wilc_gtk[key_index]->seq);
1215 if ((params->seq_len) > 0) {
1216 priv->wilc_gtk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
1217 memcpy(priv->wilc_gtk[key_index]->seq, params->seq, params->seq_len);
1220 priv->wilc_gtk[key_index]->cipher = params->cipher;
1221 priv->wilc_gtk[key_index]->key_len = params->key_len;
1222 priv->wilc_gtk[key_index]->seq_len = params->seq_len;
1225 for (i = 0; i < params->key_len; i++)
1226 PRINT_INFO(CFG80211_DBG, "Adding group key value[%d] = %x\n", i, params->key[i]);
1227 for (i = 0; i < params->seq_len; i++)
1228 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1232 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1233 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, AP_MODE, u8gmode);
1236 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]);
1238 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1239 u8pmode = ENCRYPT_ENABLED | WPA | TKIP;
1241 u8pmode = priv->wilc_groupkey | AES;
1244 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1246 pu8TxMic = params->key + 24;
1247 pu8RxMic = params->key + 16;
1248 KeyLen = params->key_len - 16;
1251 if (priv->wilc_ptk[key_index]->key)
1252 kfree(priv->wilc_ptk[key_index]->key);
1254 priv->wilc_ptk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
1256 if (priv->wilc_ptk[key_index]->seq)
1257 kfree(priv->wilc_ptk[key_index]->seq);
1259 if ((params->seq_len) > 0)
1260 priv->wilc_ptk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
1263 for (i = 0; i < params->key_len; i++)
1264 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %x\n", i, params->key[i]);
1266 for (i = 0; i < params->seq_len; i++)
1267 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1270 memcpy(priv->wilc_ptk[key_index]->key, params->key, params->key_len);
1272 if ((params->seq_len) > 0)
1273 memcpy(priv->wilc_ptk[key_index]->seq, params->seq, params->seq_len);
1275 priv->wilc_ptk[key_index]->cipher = params->cipher;
1276 priv->wilc_ptk[key_index]->key_len = params->key_len;
1277 priv->wilc_ptk[key_index]->seq_len = params->seq_len;
1279 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1280 pu8RxMic, pu8TxMic, AP_MODE, u8pmode, key_index);
1288 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1289 /* swap the tx mic by rx mic */
1290 pu8RxMic = params->key + 24;
1291 pu8TxMic = params->key + 16;
1292 KeyLen = params->key_len - 16;
1296 /*save keys only on interface 0 (wifi interface)*/
1297 if (!g_gtk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1298 g_add_gtk_key_params.key_idx = key_index;
1299 g_add_gtk_key_params.pairwise = pairwise;
1301 g_add_gtk_key_params.mac_addr = NULL;
1303 g_add_gtk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL);
1304 memcpy(g_add_gtk_key_params.mac_addr, mac_addr, ETH_ALEN);
1306 g_key_gtk_params.key_len = params->key_len;
1307 g_key_gtk_params.seq_len = params->seq_len;
1308 g_key_gtk_params.key = kmalloc(params->key_len, GFP_KERNEL);
1309 memcpy(g_key_gtk_params.key, params->key, params->key_len);
1310 if (params->seq_len > 0) {
1311 g_key_gtk_params.seq = kmalloc(params->seq_len, GFP_KERNEL);
1312 memcpy(g_key_gtk_params.seq, params->seq, params->seq_len);
1314 g_key_gtk_params.cipher = params->cipher;
1316 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_gtk_params.key[0],
1317 g_key_gtk_params.key[1],
1318 g_key_gtk_params.key[2]);
1319 g_gtk_keys_saved = true;
1322 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1323 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, STATION_MODE, u8mode);
1325 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1326 /* swap the tx mic by rx mic */
1327 pu8RxMic = params->key + 24;
1328 pu8TxMic = params->key + 16;
1329 KeyLen = params->key_len - 16;
1333 /*save keys only on interface 0 (wifi interface)*/
1334 if (!g_ptk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1335 g_add_ptk_key_params.key_idx = key_index;
1336 g_add_ptk_key_params.pairwise = pairwise;
1338 g_add_ptk_key_params.mac_addr = NULL;
1340 g_add_ptk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL);
1341 memcpy(g_add_ptk_key_params.mac_addr, mac_addr, ETH_ALEN);
1343 g_key_ptk_params.key_len = params->key_len;
1344 g_key_ptk_params.seq_len = params->seq_len;
1345 g_key_ptk_params.key = kmalloc(params->key_len, GFP_KERNEL);
1346 memcpy(g_key_ptk_params.key, params->key, params->key_len);
1347 if (params->seq_len > 0) {
1348 g_key_ptk_params.seq = kmalloc(params->seq_len, GFP_KERNEL);
1349 memcpy(g_key_ptk_params.seq, params->seq, params->seq_len);
1351 g_key_ptk_params.cipher = params->cipher;
1353 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_ptk_params.key[0],
1354 g_key_ptk_params.key[1],
1355 g_key_ptk_params.key[2]);
1356 g_ptk_keys_saved = true;
1359 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1360 pu8RxMic, pu8TxMic, STATION_MODE, u8mode, key_index);
1361 PRINT_D(CFG80211_DBG, "Adding pairwise key\n");
1363 for (i = 0; i < params->key_len; i++)
1364 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %d\n", i, params->key[i]);
1371 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
1372 s32Error = -ENOTSUPP;
1381 * @details Remove a key given the @mac_addr (%NULL for a group key)
1382 * and @key_index, return -ENOENT if the key doesn't exist.
1384 * @return int : Return 0 on Success
1389 static int del_key(struct wiphy *wiphy, struct net_device *netdev,
1394 struct wilc_priv *priv;
1397 priv = wiphy_priv(wiphy);
1400 /*delete saved keys, if any*/
1401 if (netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1402 g_ptk_keys_saved = false;
1403 g_gtk_keys_saved = false;
1404 g_wep_keys_saved = false;
1406 /*Delete saved WEP keys params, if any*/
1407 if (g_key_wep_params.key != NULL) {
1408 kfree(g_key_wep_params.key);
1409 g_key_wep_params.key = NULL;
1412 /*freeing memory allocated by "wilc_gtk" and "wilc_ptk" in "WILC_WIFI_ADD_KEY"*/
1414 if ((priv->wilc_gtk[key_index]) != NULL) {
1416 if (priv->wilc_gtk[key_index]->key != NULL) {
1418 kfree(priv->wilc_gtk[key_index]->key);
1419 priv->wilc_gtk[key_index]->key = NULL;
1421 if (priv->wilc_gtk[key_index]->seq) {
1423 kfree(priv->wilc_gtk[key_index]->seq);
1424 priv->wilc_gtk[key_index]->seq = NULL;
1427 kfree(priv->wilc_gtk[key_index]);
1428 priv->wilc_gtk[key_index] = NULL;
1432 if ((priv->wilc_ptk[key_index]) != NULL) {
1434 if (priv->wilc_ptk[key_index]->key) {
1436 kfree(priv->wilc_ptk[key_index]->key);
1437 priv->wilc_ptk[key_index]->key = NULL;
1439 if (priv->wilc_ptk[key_index]->seq) {
1441 kfree(priv->wilc_ptk[key_index]->seq);
1442 priv->wilc_ptk[key_index]->seq = NULL;
1444 kfree(priv->wilc_ptk[key_index]);
1445 priv->wilc_ptk[key_index] = NULL;
1448 /*Delete saved PTK and GTK keys params, if any*/
1449 if (g_key_ptk_params.key != NULL) {
1450 kfree(g_key_ptk_params.key);
1451 g_key_ptk_params.key = NULL;
1453 if (g_key_ptk_params.seq != NULL) {
1454 kfree(g_key_ptk_params.seq);
1455 g_key_ptk_params.seq = NULL;
1458 if (g_key_gtk_params.key != NULL) {
1459 kfree(g_key_gtk_params.key);
1460 g_key_gtk_params.key = NULL;
1462 if (g_key_gtk_params.seq != NULL) {
1463 kfree(g_key_gtk_params.seq);
1464 g_key_gtk_params.seq = NULL;
1467 /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/
1468 Set_machw_change_vir_if(false);
1471 if (key_index >= 0 && key_index <= 3) {
1472 memset(priv->WILC_WFI_wep_key[key_index], 0, priv->WILC_WFI_wep_key_len[key_index]);
1473 priv->WILC_WFI_wep_key_len[key_index] = 0;
1475 PRINT_D(CFG80211_DBG, "Removing WEP key with index = %d\n", key_index);
1476 host_int_remove_wep_key(priv->hWILCWFIDrv, key_index);
1478 PRINT_D(CFG80211_DBG, "Removing all installed keys\n");
1479 host_int_remove_key(priv->hWILCWFIDrv, mac_addr);
1487 * @details Get information about the key with the given parameters.
1488 * @mac_addr will be %NULL when requesting information for a group
1489 * key. All pointers given to the @callback function need not be valid
1490 * after it returns. This function should return an error if it is
1491 * not possible to retrieve the key, -ENOENT if it doesn't exist.
1493 * @return int : Return 0 on Success
1498 static int get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1500 const u8 *mac_addr, void *cookie, void (*callback)(void *cookie, struct key_params *))
1505 struct wilc_priv *priv;
1506 struct key_params key_params;
1509 priv = wiphy_priv(wiphy);
1514 PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index);
1516 key_params.key = priv->wilc_gtk[key_index]->key;
1517 key_params.cipher = priv->wilc_gtk[key_index]->cipher;
1518 key_params.key_len = priv->wilc_gtk[key_index]->key_len;
1519 key_params.seq = priv->wilc_gtk[key_index]->seq;
1520 key_params.seq_len = priv->wilc_gtk[key_index]->seq_len;
1522 for (i = 0; i < key_params.key_len; i++)
1523 PRINT_INFO(CFG80211_DBG, "Retrieved key value %x\n", key_params.key[i]);
1526 PRINT_D(CFG80211_DBG, "Getting pairwise key\n");
1528 key_params.key = priv->wilc_ptk[key_index]->key;
1529 key_params.cipher = priv->wilc_ptk[key_index]->cipher;
1530 key_params.key_len = priv->wilc_ptk[key_index]->key_len;
1531 key_params.seq = priv->wilc_ptk[key_index]->seq;
1532 key_params.seq_len = priv->wilc_ptk[key_index]->seq_len;
1535 callback(cookie, &key_params);
1537 return s32Error; /* priv->wilc_gtk->key_len ?0 : -ENOENT; */
1541 * @brief set_default_key
1542 * @details Set the default management frame key on an interface
1544 * @return int : Return 0 on Success.
1549 static int set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1550 bool unicast, bool multicast)
1553 struct wilc_priv *priv;
1556 priv = wiphy_priv(wiphy);
1558 PRINT_D(CFG80211_DBG, "Setting default key with idx = %d\n", key_index);
1560 if (key_index != priv->WILC_WFI_wep_default) {
1562 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, key_index);
1569 * @brief WILC_WFI_dump_survey
1570 * @details Get site survey information
1572 * @return int : Return 0 on Success.
1577 static int WILC_WFI_dump_survey(struct wiphy *wiphy, struct net_device *netdev,
1578 int idx, struct survey_info *info)
1585 PRINT_ER("Error Idx value doesn't equal zero: Error(%d)\n", s32Error);
1594 * @brief get_station
1595 * @details Get station information for the station identified by @mac
1597 * @return int : Return 0 on Success.
1603 static int get_station(struct wiphy *wiphy, struct net_device *dev,
1604 const u8 *mac, struct station_info *sinfo)
1607 struct wilc_priv *priv;
1608 perInterface_wlan_t *nic;
1610 u32 associatedsta = 0;
1611 u32 inactive_time = 0;
1612 priv = wiphy_priv(wiphy);
1613 nic = netdev_priv(dev);
1615 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
1616 PRINT_D(HOSTAPD_DBG, "Getting station parameters\n");
1618 PRINT_INFO(HOSTAPD_DBG, ": %x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4]);
1620 for (i = 0; i < NUM_STA_ASSOCIATED; i++) {
1622 if (!(memcmp(mac, priv->assoc_stainfo.au8Sta_AssociatedBss[i], ETH_ALEN))) {
1629 if (associatedsta == -1) {
1631 PRINT_ER("Station required is not associated : Error(%d)\n", s32Error);
1636 sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME);
1638 host_int_get_inactive_time(priv->hWILCWFIDrv, mac, &(inactive_time));
1639 sinfo->inactive_time = 1000 * inactive_time;
1640 PRINT_D(CFG80211_DBG, "Inactive time %d\n", sinfo->inactive_time);
1644 if (nic->iftype == STATION_MODE) {
1645 tstrStatistics strStatistics;
1647 host_int_get_statistics(priv->hWILCWFIDrv, &strStatistics);
1651 * tx_failed introduced more than
1652 * kernel version 3.0.0
1654 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) |
1655 BIT(NL80211_STA_INFO_RX_PACKETS) |
1656 BIT(NL80211_STA_INFO_TX_PACKETS) |
1657 BIT(NL80211_STA_INFO_TX_FAILED) |
1658 BIT(NL80211_STA_INFO_TX_BITRATE);
1660 sinfo->signal = strStatistics.s8RSSI;
1661 sinfo->rx_packets = strStatistics.u32RxCount;
1662 sinfo->tx_packets = strStatistics.u32TxCount + strStatistics.u32TxFailureCount;
1663 sinfo->tx_failed = strStatistics.u32TxFailureCount;
1664 sinfo->txrate.legacy = strStatistics.u8LinkSpeed * 10;
1666 if ((strStatistics.u8LinkSpeed > TCP_ACK_FILTER_LINK_SPEED_THRESH) && (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED))
1667 Enable_TCP_ACK_Filter(true);
1668 else if (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED)
1669 Enable_TCP_ACK_Filter(false);
1671 PRINT_D(CORECONFIG_DBG, "*** stats[%d][%d][%d][%d][%d]\n", sinfo->signal, sinfo->rx_packets, sinfo->tx_packets,
1672 sinfo->tx_failed, sinfo->txrate.legacy);
1680 * @details Modify parameters for a given BSS.
1682 * -use_cts_prot: Whether to use CTS protection
1683 * (0 = no, 1 = yes, -1 = do not change)
1684 * -use_short_preamble: Whether the use of short preambles is allowed
1685 * (0 = no, 1 = yes, -1 = do not change)
1686 * -use_short_slot_time: Whether the use of short slot time is allowed
1687 * (0 = no, 1 = yes, -1 = do not change)
1688 * -basic_rates: basic rates in IEEE 802.11 format
1689 * (or NULL for no change)
1690 * -basic_rates_len: number of basic rates
1691 * -ap_isolate: do not forward packets between connected stations
1692 * -ht_opmode: HT Operation mode
1693 * (u16 = opmode, -1 = do not change)
1694 * @return int : Return 0 on Success.
1699 static int change_bss(struct wiphy *wiphy, struct net_device *dev,
1700 struct bss_parameters *params)
1702 PRINT_D(CFG80211_DBG, "Changing Bss parametrs\n");
1707 * @brief WILC_WFI_auth
1708 * @details Request to authenticate with the specified peer
1710 * @return int : Return 0 on Success.
1715 static int WILC_WFI_auth(struct wiphy *wiphy, struct net_device *dev,
1716 struct cfg80211_auth_request *req)
1718 PRINT_D(CFG80211_DBG, "In Authentication Function\n");
1723 * @brief WILC_WFI_assoc
1724 * @details Request to (re)associate with the specified peer
1726 * @return int : Return 0 on Success.
1731 static int WILC_WFI_assoc(struct wiphy *wiphy, struct net_device *dev,
1732 struct cfg80211_assoc_request *req)
1734 PRINT_D(CFG80211_DBG, "In Association Function\n");
1739 * @brief WILC_WFI_deauth
1740 * @details Request to deauthenticate from the specified peer
1742 * @return int : Return 0 on Success.
1747 static int WILC_WFI_deauth(struct wiphy *wiphy, struct net_device *dev,
1748 struct cfg80211_deauth_request *req, void *cookie)
1750 PRINT_D(CFG80211_DBG, "In De-authentication Function\n");
1755 * @brief WILC_WFI_disassoc
1756 * @details Request to disassociate from the specified peer
1758 * @return int : Return 0 on Success
1763 static int WILC_WFI_disassoc(struct wiphy *wiphy, struct net_device *dev,
1764 struct cfg80211_disassoc_request *req, void *cookie)
1766 PRINT_D(CFG80211_DBG, "In Disassociation Function\n");
1771 * @brief set_wiphy_params
1772 * @details Notify that wiphy parameters have changed;
1773 * @param[in] Changed bitfield (see &enum wiphy_params_flags) describes which values
1775 * @return int : Return 0 on Success
1780 static int set_wiphy_params(struct wiphy *wiphy, u32 changed)
1783 tstrCfgParamVal pstrCfgParamVal;
1784 struct wilc_priv *priv;
1786 priv = wiphy_priv(wiphy);
1788 pstrCfgParamVal.u32SetCfgFlag = 0;
1789 PRINT_D(CFG80211_DBG, "Setting Wiphy params\n");
1791 if (changed & WIPHY_PARAM_RETRY_SHORT) {
1792 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_SHORT %d\n",
1793 priv->dev->ieee80211_ptr->wiphy->retry_short);
1794 pstrCfgParamVal.u32SetCfgFlag |= RETRY_SHORT;
1795 pstrCfgParamVal.short_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_short;
1797 if (changed & WIPHY_PARAM_RETRY_LONG) {
1799 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_LONG %d\n", priv->dev->ieee80211_ptr->wiphy->retry_long);
1800 pstrCfgParamVal.u32SetCfgFlag |= RETRY_LONG;
1801 pstrCfgParamVal.long_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_long;
1804 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
1805 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->frag_threshold);
1806 pstrCfgParamVal.u32SetCfgFlag |= FRAG_THRESHOLD;
1807 pstrCfgParamVal.frag_threshold = priv->dev->ieee80211_ptr->wiphy->frag_threshold;
1811 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
1812 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->rts_threshold);
1814 pstrCfgParamVal.u32SetCfgFlag |= RTS_THRESHOLD;
1815 pstrCfgParamVal.rts_threshold = priv->dev->ieee80211_ptr->wiphy->rts_threshold;
1819 PRINT_D(CFG80211_DBG, "Setting CFG params in the host interface\n");
1820 s32Error = hif_set_cfg(priv->hWILCWFIDrv, &pstrCfgParamVal);
1822 PRINT_ER("Error in setting WIPHY PARAMS\n");
1829 * @brief WILC_WFI_set_bitrate_mask
1830 * @details set the bitrate mask configuration
1832 * @return int : Return 0 on Success
1837 static int WILC_WFI_set_bitrate_mask(struct wiphy *wiphy,
1838 struct net_device *dev, const u8 *peer,
1839 const struct cfg80211_bitrate_mask *mask)
1843 PRINT_D(CFG80211_DBG, "Setting Bitrate mask function\n");
1850 * @details Cache a PMKID for a BSSID. This is mostly useful for fullmac
1851 * devices running firmwares capable of generating the (re) association
1852 * RSN IE. It allows for faster roaming between WPA2 BSSIDs.
1854 * @return int : Return 0 on Success
1859 static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1860 struct cfg80211_pmksa *pmksa)
1866 struct wilc_priv *priv = wiphy_priv(wiphy);
1868 PRINT_D(CFG80211_DBG, "Setting PMKSA\n");
1871 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
1872 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
1874 /*If bssid already exists and pmkid value needs to reset*/
1876 PRINT_D(CFG80211_DBG, "PMKID already exists\n");
1880 if (i < WILC_MAX_NUM_PMKIDS) {
1881 PRINT_D(CFG80211_DBG, "Setting PMKID in private structure\n");
1882 memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid,
1884 memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid,
1886 if (!(flag == PMKID_FOUND))
1887 priv->pmkid_list.numpmkid++;
1889 PRINT_ER("Invalid PMKID index\n");
1894 PRINT_D(CFG80211_DBG, "Setting pmkid in the host interface\n");
1895 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
1902 * @details Delete a cached PMKID.
1904 * @return int : Return 0 on Success
1909 static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1910 struct cfg80211_pmksa *pmksa)
1917 struct wilc_priv *priv = wiphy_priv(wiphy);
1919 PRINT_D(CFG80211_DBG, "Deleting PMKSA keys\n");
1921 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
1922 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
1924 /*If bssid is found, reset the values*/
1925 PRINT_D(CFG80211_DBG, "Reseting PMKID values\n");
1926 memset(&priv->pmkid_list.pmkidlist[i], 0, sizeof(tstrHostIFpmkid));
1932 if (i < priv->pmkid_list.numpmkid && priv->pmkid_list.numpmkid > 0) {
1933 for (; i < (priv->pmkid_list.numpmkid - 1); i++) {
1934 memcpy(priv->pmkid_list.pmkidlist[i].bssid,
1935 priv->pmkid_list.pmkidlist[i + 1].bssid,
1937 memcpy(priv->pmkid_list.pmkidlist[i].pmkid,
1938 priv->pmkid_list.pmkidlist[i].pmkid,
1941 priv->pmkid_list.numpmkid--;
1950 * @brief flush_pmksa
1951 * @details Flush all cached PMKIDs.
1953 * @return int : Return 0 on Success
1958 static int flush_pmksa(struct wiphy *wiphy, struct net_device *netdev)
1960 struct wilc_priv *priv = wiphy_priv(wiphy);
1962 PRINT_D(CFG80211_DBG, "Flushing PMKID key values\n");
1964 /*Get cashed Pmkids and set all with zeros*/
1965 memset(&priv->pmkid_list, 0, sizeof(tstrHostIFpmkidAttr));
1972 * @brief WILC_WFI_CfgParseRxAction
1973 * @details Function parses the received frames and modifies the following attributes:
1976 * -Operating Channel
1978 * @param[in] u8* Buffer, u32 length
1985 void WILC_WFI_CfgParseRxAction(u8 *buf, u32 len)
1991 u8 op_channel_attr_index = 0;
1992 u8 channel_list_attr_index = 0;
1994 while (index < len) {
1995 if (buf[index] == GO_INTENT_ATTR_ID) {
1996 buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1);
1999 if (buf[index] == CHANLIST_ATTR_ID)
2000 channel_list_attr_index = index;
2001 else if (buf[index] == OPERCHAN_ATTR_ID)
2002 op_channel_attr_index = index;
2003 index += buf[index + 1] + 3; /* ID,Length byte */
2006 if (u8WLANChannel != INVALID_CHANNEL)
2008 /*Modify channel list attribute*/
2009 if (channel_list_attr_index) {
2010 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
2011 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
2012 if (buf[i] == 0x51) {
2013 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
2014 buf[j] = u8WLANChannel;
2020 /*Modify operating channel attribute*/
2021 if (op_channel_attr_index) {
2022 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
2023 buf[op_channel_attr_index + 6] = 0x51;
2024 buf[op_channel_attr_index + 7] = u8WLANChannel;
2030 * @brief WILC_WFI_CfgParseTxAction
2031 * @details Function parses the transmitted action frames and modifies the
2032 * GO Intent attribute
2033 * @param[in] u8* Buffer, u32 length, bool bOperChan, u8 iftype
2039 void WILC_WFI_CfgParseTxAction(u8 *buf, u32 len, bool bOperChan, u8 iftype)
2044 u8 op_channel_attr_index = 0;
2045 u8 channel_list_attr_index = 0;
2047 while (index < len) {
2048 if (buf[index] == GO_INTENT_ATTR_ID) {
2049 buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1);
2054 if (buf[index] == CHANLIST_ATTR_ID)
2055 channel_list_attr_index = index;
2056 else if (buf[index] == OPERCHAN_ATTR_ID)
2057 op_channel_attr_index = index;
2058 index += buf[index + 1] + 3; /* ID,Length byte */
2061 if (u8WLANChannel != INVALID_CHANNEL && bOperChan)
2063 /*Modify channel list attribute*/
2064 if (channel_list_attr_index) {
2065 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
2066 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
2067 if (buf[i] == 0x51) {
2068 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
2069 buf[j] = u8WLANChannel;
2075 /*Modify operating channel attribute*/
2076 if (op_channel_attr_index) {
2077 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
2078 buf[op_channel_attr_index + 6] = 0x51;
2079 buf[op_channel_attr_index + 7] = u8WLANChannel;
2084 /* @brief WILC_WFI_p2p_rx
2089 * @author Mai Daftedar
2094 void WILC_WFI_p2p_rx (struct net_device *dev, u8 *buff, u32 size)
2097 struct wilc_priv *priv;
2098 u32 header, pkt_offset;
2099 tstrWILC_WFIDrv *pstrWFIDrv;
2103 priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
2104 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2106 /* Get WILC header */
2107 memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
2109 /* The packet offset field conain info about what type of managment frame */
2110 /* we are dealing with and ack status */
2111 pkt_offset = GET_PKT_OFFSET(header);
2113 if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
2114 if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP) {
2115 PRINT_D(GENERIC_DBG, "Probe response ACK\n");
2116 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
2119 if (pkt_offset & IS_MGMT_STATUS_SUCCES) {
2120 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],
2121 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
2122 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
2124 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],
2125 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
2126 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, false, GFP_KERNEL);
2132 PRINT_D(GENERIC_DBG, "Rx Frame Type:%x\n", buff[FRAME_TYPE_ID]);
2135 /*Upper layer is informed that the frame is received on this freq*/
2136 s32Freq = ieee80211_channel_to_frequency(u8CurrChannel, IEEE80211_BAND_2GHZ);
2138 if (ieee80211_is_action(buff[FRAME_TYPE_ID])) {
2139 PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]);
2141 if (priv->bCfgScanning == true && time_after_eq(jiffies, (unsigned long)pstrWFIDrv->u64P2p_MgmtTimeout)) {
2142 PRINT_D(GENERIC_DBG, "Receiving action frames from wrong channels\n");
2145 if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
2147 switch (buff[ACTION_SUBTYPE_ID]) {
2148 case GAS_INTIAL_REQ:
2149 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buff[ACTION_SUBTYPE_ID]);
2152 case GAS_INTIAL_RSP:
2153 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buff[ACTION_SUBTYPE_ID]);
2156 case PUBLIC_ACT_VENDORSPEC:
2157 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2158 * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/
2159 if (!memcmp(u8P2P_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) {
2160 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
2162 for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) {
2163 if (!memcmp(u8P2P_vendorspec, &buff[i], 6)) {
2164 u8P2Precvrandom = buff[i + 6];
2166 PRINT_D(GENERIC_DBG, "WILC Vendor specific IE:%02x\n", u8P2Precvrandom);
2172 if (u8P2Plocalrandom > u8P2Precvrandom) {
2173 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
2174 || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
2175 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) {
2176 if (buff[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buff[i + 2], 4))) {
2177 WILC_WFI_CfgParseRxAction(&buff[i + 6], size - (i + 6));
2183 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2187 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP) && (bWilc_ie)) {
2188 PRINT_D(GENERIC_DBG, "Sending P2P to host without extra elemnt\n");
2189 /* extra attribute for sig_dbm: signal strength in mBm, or 0 if unknown */
2190 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
2196 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff[ACTION_SUBTYPE_ID]);
2202 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
2207 * @brief WILC_WFI_mgmt_tx_complete
2208 * @details Returns result of writing mgmt frame to VMM (Tx buffers are freed here)
2210 * transmitting status
2212 * @author Amr Abdelmoghny
2216 static void WILC_WFI_mgmt_tx_complete(void *priv, int status)
2218 struct p2p_mgmt_data *pv_data = (struct p2p_mgmt_data *)priv;
2221 kfree(pv_data->buff);
2226 * @brief WILC_WFI_RemainOnChannelReady
2227 * @details Callback function, called from handle_remain_on_channel on being ready on channel
2230 * @author Amr abdelmoghny
2235 static void WILC_WFI_RemainOnChannelReady(void *pUserVoid)
2237 struct wilc_priv *priv;
2239 priv = (struct wilc_priv *)pUserVoid;
2241 PRINT_D(HOSTINF_DBG, "Remain on channel ready\n");
2243 priv->bInP2PlistenState = true;
2245 cfg80211_ready_on_channel(priv->wdev,
2246 priv->strRemainOnChanParams.u64ListenCookie,
2247 priv->strRemainOnChanParams.pstrListenChan,
2248 priv->strRemainOnChanParams.u32ListenDuration,
2253 * @brief WILC_WFI_RemainOnChannelExpired
2254 * @details Callback function, called on expiration of remain-on-channel duration
2257 * @author Amr abdelmoghny
2262 static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, u32 u32SessionID)
2264 struct wilc_priv *priv;
2266 priv = (struct wilc_priv *)pUserVoid;
2269 if (u32SessionID == priv->strRemainOnChanParams.u32ListenSessionID) {
2270 PRINT_D(GENERIC_DBG, "Remain on channel expired\n");
2272 priv->bInP2PlistenState = false;
2274 /*Inform wpas of remain-on-channel expiration*/
2275 cfg80211_remain_on_channel_expired(priv->wdev,
2276 priv->strRemainOnChanParams.u64ListenCookie,
2277 priv->strRemainOnChanParams.pstrListenChan,
2280 PRINT_D(GENERIC_DBG, "Received ID 0x%x Expected ID 0x%x (No match)\n", u32SessionID
2281 , priv->strRemainOnChanParams.u32ListenSessionID);
2287 * @brief remain_on_channel
2288 * @details Request the driver to remain awake on the specified
2289 * channel for the specified duration to complete an off-channel
2290 * operation (e.g., public action frame exchange). When the driver is
2291 * ready on the requested channel, it must indicate this with an event
2292 * notification by calling cfg80211_ready_on_channel().
2294 * @return int : Return 0 on Success
2299 static int remain_on_channel(struct wiphy *wiphy,
2300 struct wireless_dev *wdev,
2301 struct ieee80211_channel *chan,
2302 unsigned int duration, u64 *cookie)
2305 struct wilc_priv *priv;
2307 priv = wiphy_priv(wiphy);
2309 PRINT_D(GENERIC_DBG, "Remaining on channel %d\n", chan->hw_value);
2311 /*BugID_4800: if in AP mode, return.*/
2312 /*This check is to handle the situation when user*/
2313 /*requests "create group" during a running scan*/
2315 if (wdev->iftype == NL80211_IFTYPE_AP) {
2316 PRINT_D(GENERIC_DBG, "Required remain-on-channel while in AP mode");
2320 u8CurrChannel = chan->hw_value;
2322 /*Setting params needed by WILC_WFI_RemainOnChannelExpired()*/
2323 priv->strRemainOnChanParams.pstrListenChan = chan;
2324 priv->strRemainOnChanParams.u64ListenCookie = *cookie;
2325 priv->strRemainOnChanParams.u32ListenDuration = duration;
2326 priv->strRemainOnChanParams.u32ListenSessionID++;
2328 s32Error = host_int_remain_on_channel(priv->hWILCWFIDrv
2329 , priv->strRemainOnChanParams.u32ListenSessionID
2332 , WILC_WFI_RemainOnChannelExpired
2333 , WILC_WFI_RemainOnChannelReady
2340 * @brief cancel_remain_on_channel
2341 * @details Cancel an on-going remain-on-channel operation.
2342 * This allows the operation to be terminated prior to timeout based on
2343 * the duration value.
2344 * @param[in] struct wiphy *wiphy,
2345 * @param[in] struct net_device *dev
2346 * @param[in] u64 cookie,
2347 * @return int : Return 0 on Success
2352 static int cancel_remain_on_channel(struct wiphy *wiphy,
2353 struct wireless_dev *wdev,
2357 struct wilc_priv *priv;
2359 priv = wiphy_priv(wiphy);
2361 PRINT_D(CFG80211_DBG, "Cancel remain on channel\n");
2363 s32Error = host_int_ListenStateExpired(priv->hWILCWFIDrv, priv->strRemainOnChanParams.u32ListenSessionID);
2367 * @brief WILC_WFI_add_wilcvendorspec
2368 * @details Adding WILC information elemet to allow two WILC devices to
2369 * identify each other and connect
2370 * @param[in] u8 * buf
2376 void WILC_WFI_add_wilcvendorspec(u8 *buff)
2378 memcpy(buff, u8P2P_vendorspec, sizeof(u8P2P_vendorspec));
2381 * @brief WILC_WFI_mgmt_tx_frame
2390 extern linux_wlan_t *g_linux_wlan;
2391 extern bool bEnablePS;
2392 int mgmt_tx(struct wiphy *wiphy,
2393 struct wireless_dev *wdev,
2394 struct cfg80211_mgmt_tx_params *params,
2397 struct ieee80211_channel *chan = params->chan;
2398 unsigned int wait = params->wait;
2399 const u8 *buf = params->buf;
2400 size_t len = params->len;
2401 const struct ieee80211_mgmt *mgmt;
2402 struct p2p_mgmt_data *mgmt_tx;
2403 struct wilc_priv *priv;
2405 tstrWILC_WFIDrv *pstrWFIDrv;
2407 perInterface_wlan_t *nic;
2408 u32 buf_len = len + sizeof(u8P2P_vendorspec) + sizeof(u8P2Plocalrandom);
2410 nic = netdev_priv(wdev->netdev);
2411 priv = wiphy_priv(wiphy);
2412 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2414 *cookie = (unsigned long)buf;
2415 priv->u64tx_cookie = *cookie;
2416 mgmt = (const struct ieee80211_mgmt *) buf;
2418 if (ieee80211_is_mgmt(mgmt->frame_control)) {
2420 /*mgmt frame allocation*/
2421 mgmt_tx = kmalloc(sizeof(struct p2p_mgmt_data), GFP_KERNEL);
2422 if (mgmt_tx == NULL) {
2423 PRINT_ER("Failed to allocate memory for mgmt_tx structure\n");
2426 mgmt_tx->buff = kmalloc(buf_len, GFP_KERNEL);
2427 if (mgmt_tx->buff == NULL) {
2428 PRINT_ER("Failed to allocate memory for mgmt_tx buff\n");
2432 memcpy(mgmt_tx->buff, buf, len);
2433 mgmt_tx->size = len;
2436 if (ieee80211_is_probe_resp(mgmt->frame_control)) {
2437 PRINT_D(GENERIC_DBG, "TX: Probe Response\n");
2438 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2439 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2440 /*Save the current channel after we tune to it*/
2441 u8CurrChannel = chan->hw_value;
2442 } else if (ieee80211_is_action(mgmt->frame_control)) {
2443 PRINT_D(GENERIC_DBG, "ACTION FRAME:%x\n", (u16)mgmt->frame_control);
2447 if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
2449 /*Only set the channel, if not a negotiation confirmation frame
2450 * (If Negotiation confirmation frame, force it
2451 * to be transmitted on the same negotiation channel)*/
2453 if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC ||
2454 buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) {
2455 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2456 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2457 /*Save the current channel after we tune to it*/
2458 u8CurrChannel = chan->hw_value;
2460 switch (buf[ACTION_SUBTYPE_ID]) {
2461 case GAS_INTIAL_REQ:
2463 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buf[ACTION_SUBTYPE_ID]);
2467 case GAS_INTIAL_RSP:
2469 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buf[ACTION_SUBTYPE_ID]);
2473 case PUBLIC_ACT_VENDORSPEC:
2475 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2476 * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/
2477 if (!memcmp(u8P2P_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) {
2478 /*For the connection of two WILC's connection generate a rand number to determine who will be a GO*/
2479 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
2480 if (u8P2Plocalrandom == 1 && u8P2Precvrandom < u8P2Plocalrandom) {
2481 get_random_bytes(&u8P2Plocalrandom, 1);
2482 /*Increment the number to prevent if its 0*/
2487 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
2488 || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
2489 if (u8P2Plocalrandom > u8P2Precvrandom) {
2490 PRINT_D(GENERIC_DBG, "LOCAL WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2492 /*Search for the p2p information information element , after the Public action subtype theres a byte for teh dialog token, skip that*/
2493 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) {
2494 if (buf[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buf[i + 2], 4))) {
2495 if (buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)
2496 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), true, nic->iftype);
2499 /*If using supplicant go intent, no need at all*/
2500 /*to parse transmitted negotiation frames*/
2502 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), false, nic->iftype);
2507 if (buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_REQ && buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_RSP) {
2508 WILC_WFI_add_wilcvendorspec(&mgmt_tx->buff[len]);
2509 mgmt_tx->buff[len + sizeof(u8P2P_vendorspec)] = u8P2Plocalrandom;
2510 mgmt_tx->size = buf_len;
2513 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2517 PRINT_D(GENERIC_DBG, "Not a P2P public action frame\n");
2525 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf[ACTION_SUBTYPE_ID]);
2532 PRINT_D(GENERIC_DBG, "TX: ACTION FRAME Type:%x : Chan:%d\n", buf[ACTION_SUBTYPE_ID], chan->hw_value);
2533 pstrWFIDrv->u64P2p_MgmtTimeout = (jiffies + msecs_to_jiffies(wait));
2535 PRINT_D(GENERIC_DBG, "Current Jiffies: %lu Timeout:%llu\n", jiffies, pstrWFIDrv->u64P2p_MgmtTimeout);
2539 g_linux_wlan->oup.wlan_add_mgmt_to_tx_que(mgmt_tx, mgmt_tx->buff, mgmt_tx->size, WILC_WFI_mgmt_tx_complete);
2541 PRINT_D(GENERIC_DBG, "This function transmits only management frames\n");
2546 int mgmt_tx_cancel_wait(struct wiphy *wiphy,
2547 struct wireless_dev *wdev,
2550 struct wilc_priv *priv;
2551 tstrWILC_WFIDrv *pstrWFIDrv;
2553 priv = wiphy_priv(wiphy);
2554 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2557 PRINT_D(GENERIC_DBG, "Tx Cancel wait :%lu\n", jiffies);
2558 pstrWFIDrv->u64P2p_MgmtTimeout = jiffies;
2560 if (priv->bInP2PlistenState == false) {
2561 /* Bug 5504: This is just to avoid connection failure when getting stuck when the supplicant
2562 * considers the driver falsely that it is in Listen state */
2563 cfg80211_remain_on_channel_expired(priv->wdev,
2564 priv->strRemainOnChanParams.u64ListenCookie,
2565 priv->strRemainOnChanParams.pstrListenChan,
2573 * @brief WILC_WFI_frame_register
2574 * @details Notify driver that a management frame type was
2575 * registered. Note that this callback may not sleep, and cannot run
2576 * concurrently with itself.
2583 void WILC_WFI_frame_register(struct wiphy *wiphy,
2584 struct wireless_dev *wdev,
2585 u16 frame_type, bool reg)
2588 struct wilc_priv *priv;
2589 perInterface_wlan_t *nic;
2592 priv = wiphy_priv(wiphy);
2593 nic = netdev_priv(priv->wdev->netdev);
2601 PRINT_D(GENERIC_DBG, "Frame registering Frame Type: %x: Boolean: %d\n", frame_type, reg);
2602 switch (frame_type) {
2605 nic->g_struct_frame_reg[0].frame_type = frame_type;
2606 nic->g_struct_frame_reg[0].reg = reg;
2612 nic->g_struct_frame_reg[1].frame_type = frame_type;
2613 nic->g_struct_frame_reg[1].reg = reg;
2623 /*If mac is closed, then return*/
2624 if (!g_linux_wlan->wilc1000_initialized) {
2625 PRINT_D(GENERIC_DBG, "Return since mac is closed\n");
2628 host_int_frame_register(priv->hWILCWFIDrv, frame_type, reg);
2634 * @brief WILC_WFI_set_cqm_rssi_config
2635 * @details Configure connection quality monitor RSSI threshold.
2636 * @param[in] struct wiphy *wiphy:
2637 * @param[in] struct net_device *dev:
2638 * @param[in] s32 rssi_thold:
2639 * @param[in] u32 rssi_hyst:
2640 * @return int : Return 0 on Success
2645 static int WILC_WFI_set_cqm_rssi_config(struct wiphy *wiphy,
2646 struct net_device *dev, s32 rssi_thold, u32 rssi_hyst)
2648 PRINT_D(CFG80211_DBG, "Setting CQM RSSi Function\n");
2653 * @brief dump_station
2654 * @details Configure connection quality monitor RSSI threshold.
2655 * @param[in] struct wiphy *wiphy:
2656 * @param[in] struct net_device *dev
2657 * @param[in] int idx
2658 * @param[in] u8 *mac
2659 * @param[in] struct station_info *sinfo
2660 * @return int : Return 0 on Success
2665 static int dump_station(struct wiphy *wiphy, struct net_device *dev,
2666 int idx, u8 *mac, struct station_info *sinfo)
2668 struct wilc_priv *priv;
2670 PRINT_D(CFG80211_DBG, "Dumping station information\n");
2675 priv = wiphy_priv(wiphy);
2677 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
2679 host_int_get_rssi(priv->hWILCWFIDrv, &(sinfo->signal));
2687 * @brief WILC_WFI_set_power_mgmt
2690 * @return int : Return 0 on Success.
2693 * @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
2695 int WILC_WFI_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2696 bool enabled, int timeout)
2698 struct wilc_priv *priv;
2700 PRINT_D(CFG80211_DBG, " Power save Enabled= %d , TimeOut = %d\n", enabled, timeout);
2705 priv = wiphy_priv(wiphy);
2706 if (priv->hWILCWFIDrv == NULL) {
2707 PRINT_ER("Driver is NULL\n");
2712 host_int_set_power_mgmt(priv->hWILCWFIDrv, enabled, timeout);
2720 * @brief change_virtual_intf
2721 * @details Change type/configuration of virtual interface,
2722 * keep the struct wireless_dev's iftype updated.
2724 * @return int : Return 0 on Success.
2729 void wilc1000_wlan_deinit(linux_wlan_t *nic);
2730 int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic);
2732 static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
2733 enum nl80211_iftype type, u32 *flags, struct vif_params *params)
2736 struct wilc_priv *priv;
2737 perInterface_wlan_t *nic;
2742 nic = netdev_priv(dev);
2743 priv = wiphy_priv(wiphy);
2745 PRINT_D(HOSTAPD_DBG, "In Change virtual interface function\n");
2746 PRINT_D(HOSTAPD_DBG, "Wireless interface name =%s\n", dev->name);
2747 u8P2Plocalrandom = 0x01;
2748 u8P2Precvrandom = 0x00;
2752 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2753 g_obtainingIP = false;
2754 del_timer(&hDuringIpTimer);
2755 PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n");
2758 /*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to CE H/W*/
2759 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2760 Set_machw_change_vir_if(true);
2764 case NL80211_IFTYPE_STATION:
2766 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_STATION\n");
2768 /* send delba over wlan interface */
2771 dev->ieee80211_ptr->iftype = type;
2772 priv->wdev->iftype = type;
2773 nic->monitor_flag = 0;
2774 nic->iftype = STATION_MODE;
2776 /*Remove the enteries of the previously connected clients*/
2777 memset(priv->assoc_stainfo.au8Sta_AssociatedBss, 0, MAX_NUM_STA * ETH_ALEN);
2778 interface_type = nic->iftype;
2779 nic->iftype = STATION_MODE;
2781 if (g_linux_wlan->wilc1000_initialized) {
2782 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
2783 /* ensure that the message Q is empty */
2784 host_int_wait_msg_queue_idle();
2787 /*Eliminate host interface blocking state*/
2788 up(&g_linux_wlan->cfg_event);
2790 wilc1000_wlan_deinit(g_linux_wlan);
2791 wilc1000_wlan_init(dev, nic);
2792 g_wilc_initialized = 1;
2793 nic->iftype = interface_type;
2795 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
2796 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
2797 host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler,
2798 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
2799 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2801 /*Add saved WEP keys, if any*/
2802 if (g_wep_keys_saved) {
2803 host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler,
2804 g_key_wep_params.key_idx);
2805 host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler,
2806 g_key_wep_params.key,
2807 g_key_wep_params.key_len,
2808 g_key_wep_params.key_idx);
2811 /*No matter the driver handler passed here, it will be overwriiten*/
2812 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2813 host_int_flush_join_req(priv->hWILCWFIDrv);
2815 /*Add saved PTK and GTK keys, if any*/
2816 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2817 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
2818 g_key_ptk_params.key[1],
2819 g_key_ptk_params.key[2]);
2820 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
2821 g_key_gtk_params.key[1],
2822 g_key_gtk_params.key[2]);
2823 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2824 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2825 g_add_ptk_key_params.key_idx,
2826 g_add_ptk_key_params.pairwise,
2827 g_add_ptk_key_params.mac_addr,
2828 (struct key_params *)(&g_key_ptk_params));
2830 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2831 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2832 g_add_gtk_key_params.key_idx,
2833 g_add_gtk_key_params.pairwise,
2834 g_add_gtk_key_params.mac_addr,
2835 (struct key_params *)(&g_key_gtk_params));
2838 /*BugID_4847: registered frames in firmware are now*/
2839 /*lost due to mac close. So re-register those frames*/
2840 if (g_linux_wlan->wilc1000_initialized) {
2841 for (i = 0; i < num_reg_frame; i++) {
2842 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2843 nic->g_struct_frame_reg[i].reg);
2844 host_int_frame_register(priv->hWILCWFIDrv,
2845 nic->g_struct_frame_reg[i].frame_type,
2846 nic->g_struct_frame_reg[i].reg);
2851 host_int_set_power_mgmt(priv->hWILCWFIDrv, 1, 0);
2855 case NL80211_IFTYPE_P2P_CLIENT:
2857 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
2859 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n");
2861 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
2863 dev->ieee80211_ptr->iftype = type;
2864 priv->wdev->iftype = type;
2865 nic->monitor_flag = 0;
2867 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
2868 nic->iftype = CLIENT_MODE;
2871 if (g_linux_wlan->wilc1000_initialized) {
2872 /* ensure that the message Q is empty */
2873 host_int_wait_msg_queue_idle();
2875 wilc1000_wlan_deinit(g_linux_wlan);
2876 wilc1000_wlan_init(dev, nic);
2877 g_wilc_initialized = 1;
2879 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
2880 host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler,
2881 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
2882 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2884 /*Add saved WEP keys, if any*/
2885 if (g_wep_keys_saved) {
2886 host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler,
2887 g_key_wep_params.key_idx);
2888 host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler,
2889 g_key_wep_params.key,
2890 g_key_wep_params.key_len,
2891 g_key_wep_params.key_idx);
2894 /*No matter the driver handler passed here, it will be overwriiten*/
2895 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2896 host_int_flush_join_req(priv->hWILCWFIDrv);
2898 /*Add saved PTK and GTK keys, if any*/
2899 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2900 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
2901 g_key_ptk_params.key[1],
2902 g_key_ptk_params.key[2]);
2903 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
2904 g_key_gtk_params.key[1],
2905 g_key_gtk_params.key[2]);
2906 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2907 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2908 g_add_ptk_key_params.key_idx,
2909 g_add_ptk_key_params.pairwise,
2910 g_add_ptk_key_params.mac_addr,
2911 (struct key_params *)(&g_key_ptk_params));
2913 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2914 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2915 g_add_gtk_key_params.key_idx,
2916 g_add_gtk_key_params.pairwise,
2917 g_add_gtk_key_params.mac_addr,
2918 (struct key_params *)(&g_key_gtk_params));
2921 /*Refresh scan, to refresh the scan results to the wpa_supplicant. Set MachHw to false to enable further key installments*/
2922 refresh_scan(priv, 1, true);
2923 Set_machw_change_vir_if(false);
2925 /*BugID_4847: registered frames in firmware are now lost
2926 * due to mac close. So re-register those frames */
2927 if (g_linux_wlan->wilc1000_initialized) {
2928 for (i = 0; i < num_reg_frame; i++) {
2929 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2930 nic->g_struct_frame_reg[i].reg);
2931 host_int_frame_register(priv->hWILCWFIDrv,
2932 nic->g_struct_frame_reg[i].frame_type,
2933 nic->g_struct_frame_reg[i].reg);
2939 case NL80211_IFTYPE_AP:
2941 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_AP %d\n", type);
2942 dev->ieee80211_ptr->iftype = type;
2943 priv->wdev->iftype = type;
2944 nic->iftype = AP_MODE;
2945 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
2947 PRINT_D(HOSTAPD_DBG, "Downloading AP firmware\n");
2948 linux_wlan_get_firmware(nic);
2949 /*If wilc is running, then close-open to actually get new firmware running (serves P2P)*/
2950 if (g_linux_wlan->wilc1000_initialized) {
2951 nic->iftype = AP_MODE;
2952 g_linux_wlan->wilc1000_initialized = 1;
2956 /*BugID_4847: registered frames in firmware are now lost
2957 * due to mac close. So re-register those frames */
2958 for (i = 0; i < num_reg_frame; i++) {
2959 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2960 nic->g_struct_frame_reg[i].reg);
2961 host_int_frame_register(priv->hWILCWFIDrv,
2962 nic->g_struct_frame_reg[i].frame_type,
2963 nic->g_struct_frame_reg[i].reg);
2968 case NL80211_IFTYPE_P2P_GO:
2969 PRINT_D(GENERIC_DBG, "start duringIP timer\n");
2971 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2972 g_obtainingIP = true;
2973 mod_timer(&hDuringIpTimer, jiffies + msecs_to_jiffies(duringIP_TIME));
2975 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
2977 /*Delete block ack has to be the latest config packet*/
2978 /*sent before downloading new FW. This is because it blocks on*/
2979 /*hWaitResponse semaphore, which allows previous config*/
2980 /*packets to actually take action on old FW*/
2981 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
2983 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n");
2984 dev->ieee80211_ptr->iftype = type;
2985 priv->wdev->iftype = type;
2987 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
2989 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
2993 nic->iftype = GO_MODE;
2995 /* ensure that the message Q is empty */
2996 host_int_wait_msg_queue_idle();
2997 wilc1000_wlan_deinit(g_linux_wlan);
2998 wilc1000_wlan_init(dev, nic);
2999 g_wilc_initialized = 1;
3002 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
3003 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
3004 host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler,
3005 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
3006 host_int_set_operation_mode(priv->hWILCWFIDrv, AP_MODE);
3008 /*Add saved WEP keys, if any*/
3009 if (g_wep_keys_saved) {
3010 host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler,
3011 g_key_wep_params.key_idx);
3012 host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler,
3013 g_key_wep_params.key,
3014 g_key_wep_params.key_len,
3015 g_key_wep_params.key_idx);
3018 /*No matter the driver handler passed here, it will be overwriiten*/
3019 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
3020 host_int_flush_join_req(priv->hWILCWFIDrv);
3022 /*Add saved PTK and GTK keys, if any*/
3023 if (g_ptk_keys_saved && g_gtk_keys_saved) {
3024 PRINT_D(CFG80211_DBG, "ptk %x %x %x cipher %x\n", g_key_ptk_params.key[0],
3025 g_key_ptk_params.key[1],
3026 g_key_ptk_params.key[2],
3027 g_key_ptk_params.cipher);
3028 PRINT_D(CFG80211_DBG, "gtk %x %x %x cipher %x\n", g_key_gtk_params.key[0],
3029 g_key_gtk_params.key[1],
3030 g_key_gtk_params.key[2],
3031 g_key_gtk_params.cipher);
3033 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3034 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3035 g_add_ptk_key_params.key_idx,
3036 g_add_ptk_key_params.pairwise,
3037 g_add_ptk_key_params.mac_addr,
3038 (struct key_params *)(&g_key_ptk_params));
3040 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3041 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3042 g_add_gtk_key_params.key_idx,
3043 g_add_gtk_key_params.pairwise,
3044 g_add_gtk_key_params.mac_addr,
3045 (struct key_params *)(&g_key_gtk_params));
3050 /*BugID_4847: registered frames in firmware are now*/
3051 /*lost due to mac close. So re-register those frames*/
3052 if (g_linux_wlan->wilc1000_initialized) {
3053 for (i = 0; i < num_reg_frame; i++) {
3054 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
3055 nic->g_struct_frame_reg[i].reg);
3056 host_int_frame_register(priv->hWILCWFIDrv,
3057 nic->g_struct_frame_reg[i].frame_type,
3058 nic->g_struct_frame_reg[i].reg);
3064 PRINT_ER("Unknown interface type= %d\n", type);
3073 /* (austin.2013-07-23)
3075 * To support revised cfg80211_ops
3077 * add_beacon --> start_ap
3078 * set_beacon --> change_beacon
3079 * del_beacon --> stop_ap
3081 * beacon_parameters --> cfg80211_ap_settings
3082 * cfg80211_beacon_data
3084 * applicable for linux kernel 3.4+
3089 * @details Add a beacon with given parameters, @head, @interval
3090 * and @dtim_period will be valid, @tail is optional.
3092 * @param[in] dev The net device structure
3093 * @param[in] settings cfg80211_ap_settings parameters for the beacon to be added
3094 * @return int : Return 0 on Success.
3099 static int start_ap(struct wiphy *wiphy, struct net_device *dev,
3100 struct cfg80211_ap_settings *settings)
3102 struct cfg80211_beacon_data *beacon = &(settings->beacon);
3103 struct wilc_priv *priv;
3106 priv = wiphy_priv(wiphy);
3107 PRINT_D(HOSTAPD_DBG, "Starting ap\n");
3109 PRINT_D(HOSTAPD_DBG, "Interval = %d\n DTIM period = %d\n Head length = %zu Tail length = %zu\n",
3110 settings->beacon_interval, settings->dtim_period, beacon->head_len, beacon->tail_len);
3112 s32Error = set_channel(wiphy, &settings->chandef);
3115 PRINT_ER("Error in setting channel\n");
3117 linux_wlan_set_bssid(dev, g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
3119 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
3120 settings->beacon_interval,
3121 settings->dtim_period,
3122 beacon->head_len, (u8 *)beacon->head,
3123 beacon->tail_len, (u8 *)beacon->tail);
3129 * @brief change_beacon
3130 * @details Add a beacon with given parameters, @head, @interval
3131 * and @dtim_period will be valid, @tail is optional.
3133 * @param[in] dev The net device structure
3134 * @param[in] beacon cfg80211_beacon_data for the beacon to be changed
3135 * @return int : Return 0 on Success.
3140 static int change_beacon(struct wiphy *wiphy, struct net_device *dev,
3141 struct cfg80211_beacon_data *beacon)
3143 struct wilc_priv *priv;
3146 priv = wiphy_priv(wiphy);
3147 PRINT_D(HOSTAPD_DBG, "Setting beacon\n");
3150 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
3153 beacon->head_len, (u8 *)beacon->head,
3154 beacon->tail_len, (u8 *)beacon->tail);
3161 * @details Remove beacon configuration and stop sending the beacon.
3163 * @return int : Return 0 on Success.
3168 static int stop_ap(struct wiphy *wiphy, struct net_device *dev)
3171 struct wilc_priv *priv;
3172 u8 NullBssid[ETH_ALEN] = {0};
3177 priv = wiphy_priv(wiphy);
3179 PRINT_D(HOSTAPD_DBG, "Deleting beacon\n");
3182 linux_wlan_set_bssid(dev, NullBssid);
3184 s32Error = host_int_del_beacon(priv->hWILCWFIDrv);
3187 PRINT_ER("Host delete beacon fail\n");
3193 * @brief add_station
3194 * @details Add a new station.
3196 * @return int : Return 0 on Success.
3201 static int add_station(struct wiphy *wiphy, struct net_device *dev,
3202 const u8 *mac, struct station_parameters *params)
3205 struct wilc_priv *priv;
3206 tstrWILC_AddStaParam strStaParams = { {0} };
3207 perInterface_wlan_t *nic;
3212 priv = wiphy_priv(wiphy);
3213 nic = netdev_priv(dev);
3215 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3216 memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
3217 memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN);
3218 strStaParams.u16AssocID = params->aid;
3219 strStaParams.u8NumRates = params->supported_rates_len;
3220 strStaParams.pu8Rates = params->supported_rates;
3222 PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid);
3224 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],
3225 priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]);
3226 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3227 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3229 if (params->ht_capa == NULL) {
3230 strStaParams.bIsHTSupported = false;
3232 strStaParams.bIsHTSupported = true;
3233 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3234 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
3235 memcpy(strStaParams.au8SuppMCsSet, ¶ms->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
3236 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3237 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3238 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3241 strStaParams.u16FlagsMask = params->sta_flags_mask;
3242 strStaParams.u16FlagsSet = params->sta_flags_set;
3244 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3245 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3246 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3247 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3248 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3249 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3250 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3251 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3253 s32Error = host_int_add_station(priv->hWILCWFIDrv, &strStaParams);
3255 PRINT_ER("Host add station fail\n");
3262 * @brief del_station
3263 * @details Remove a station; @mac may be NULL to remove all stations.
3265 * @return int : Return 0 on Success.
3270 static int del_station(struct wiphy *wiphy, struct net_device *dev,
3271 struct station_del_parameters *params)
3273 const u8 *mac = params->mac;
3275 struct wilc_priv *priv;
3276 perInterface_wlan_t *nic;
3281 priv = wiphy_priv(wiphy);
3282 nic = netdev_priv(dev);
3284 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3285 PRINT_D(HOSTAPD_DBG, "Deleting station\n");
3289 PRINT_D(HOSTAPD_DBG, "All associated stations\n");
3290 s32Error = host_int_del_allstation(priv->hWILCWFIDrv, priv->assoc_stainfo.au8Sta_AssociatedBss);
3292 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]);
3295 s32Error = host_int_del_station(priv->hWILCWFIDrv, mac);
3298 PRINT_ER("Host delete station fail\n");
3304 * @brief change_station
3305 * @details Modify a given station.
3307 * @return int : Return 0 on Success.
3312 static int change_station(struct wiphy *wiphy, struct net_device *dev,
3313 const u8 *mac, struct station_parameters *params)
3316 struct wilc_priv *priv;
3317 tstrWILC_AddStaParam strStaParams = { {0} };
3318 perInterface_wlan_t *nic;
3321 PRINT_D(HOSTAPD_DBG, "Change station paramters\n");
3326 priv = wiphy_priv(wiphy);
3327 nic = netdev_priv(dev);
3329 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3330 memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
3331 strStaParams.u16AssocID = params->aid;
3332 strStaParams.u8NumRates = params->supported_rates_len;
3333 strStaParams.pu8Rates = params->supported_rates;
3335 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],
3336 strStaParams.au8BSSID[5]);
3337 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3338 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3340 if (params->ht_capa == NULL) {
3341 strStaParams.bIsHTSupported = false;
3343 strStaParams.bIsHTSupported = true;
3344 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3345 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
3346 memcpy(strStaParams.au8SuppMCsSet, ¶ms->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
3347 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3348 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3349 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3353 strStaParams.u16FlagsMask = params->sta_flags_mask;
3354 strStaParams.u16FlagsSet = params->sta_flags_set;
3356 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3357 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3358 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3359 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3360 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3361 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3362 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3363 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3365 s32Error = host_int_edit_station(priv->hWILCWFIDrv, &strStaParams);
3367 PRINT_ER("Host edit station fail\n");
3374 * @brief add_virtual_intf
3377 * @return int : Return 0 on Success.
3382 struct wireless_dev *add_virtual_intf(struct wiphy *wiphy, const char *name,
3383 unsigned char name_assign_type,
3384 enum nl80211_iftype type, u32 *flags,
3385 struct vif_params *params)
3387 perInterface_wlan_t *nic;
3388 struct wilc_priv *priv;
3389 struct net_device *new_ifc = NULL;
3391 priv = wiphy_priv(wiphy);
3395 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", priv->wdev->netdev);
3397 nic = netdev_priv(priv->wdev->netdev);
3400 if (type == NL80211_IFTYPE_MONITOR) {
3401 PRINT_D(HOSTAPD_DBG, "Monitor interface mode: Initializing mon interface virtual device driver\n");
3402 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", nic->wilc_netdev);
3403 new_ifc = WILC_WFI_init_mon_interface(name, nic->wilc_netdev);
3404 if (new_ifc != NULL) {
3405 PRINT_D(HOSTAPD_DBG, "Setting monitor flag in private structure\n");
3406 nic = netdev_priv(priv->wdev->netdev);
3407 nic->monitor_flag = 1;
3409 PRINT_ER("Error in initializing monitor interface\n ");
3415 * @brief del_virtual_intf
3418 * @return int : Return 0 on Success.
3423 int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) /* tony for v3.8 support */
3425 PRINT_D(HOSTAPD_DBG, "Deleting virtual interface\n");
3429 static struct cfg80211_ops wilc_cfg80211_ops = {
3431 .set_monitor_channel = set_channel,
3434 .disconnect = disconnect,
3438 .set_default_key = set_default_key,
3439 .add_virtual_intf = add_virtual_intf,
3440 .del_virtual_intf = del_virtual_intf,
3441 .change_virtual_intf = change_virtual_intf,
3443 .start_ap = start_ap,
3444 .change_beacon = change_beacon,
3446 .add_station = add_station,
3447 .del_station = del_station,
3448 .change_station = change_station,
3449 .get_station = get_station,
3450 .dump_station = dump_station,
3451 .change_bss = change_bss,
3452 .set_wiphy_params = set_wiphy_params,
3454 .set_pmksa = set_pmksa,
3455 .del_pmksa = del_pmksa,
3456 .flush_pmksa = flush_pmksa,
3457 .remain_on_channel = remain_on_channel,
3458 .cancel_remain_on_channel = cancel_remain_on_channel,
3459 .mgmt_tx_cancel_wait = mgmt_tx_cancel_wait,
3461 .mgmt_frame_register = WILC_WFI_frame_register,
3462 .set_power_mgmt = WILC_WFI_set_power_mgmt,
3463 .set_cqm_rssi_config = WILC_WFI_set_cqm_rssi_config,
3472 * @brief WILC_WFI_update_stats
3473 * @details Modify parameters for a given BSS.
3475 * @return int : Return 0 on Success.
3478 * @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
3480 int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed)
3483 struct wilc_priv *priv;
3485 priv = wiphy_priv(wiphy);
3489 case WILC_WFI_RX_PKT:
3491 priv->netstats.rx_packets++;
3492 priv->netstats.rx_bytes += pktlen;
3493 priv->netstats.rx_time = get_jiffies_64();
3497 case WILC_WFI_TX_PKT:
3499 priv->netstats.tx_packets++;
3500 priv->netstats.tx_bytes += pktlen;
3501 priv->netstats.tx_time = get_jiffies_64();
3514 * @brief WILC_WFI_CfgAlloc
3515 * @details Allocation of the wireless device structure and assigning it
3516 * to the cfg80211 operations structure.
3518 * @return wireless_dev : Returns pointer to wireless_dev structure.
3523 struct wireless_dev *WILC_WFI_CfgAlloc(void)
3526 struct wireless_dev *wdev;
3529 PRINT_D(CFG80211_DBG, "Allocating wireless device\n");
3530 /*Allocating the wireless device structure*/
3531 wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
3533 PRINT_ER("Cannot allocate wireless device\n");
3537 /*Creating a new wiphy, linking wireless structure with the wiphy structure*/
3538 wdev->wiphy = wiphy_new(&wilc_cfg80211_ops, sizeof(struct wilc_priv));
3540 PRINT_ER("Cannot allocate wiphy\n");
3545 /* enable 802.11n HT */
3546 WILC_WFI_band_2ghz.ht_cap.ht_supported = 1;
3547 WILC_WFI_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT);
3548 WILC_WFI_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff;
3549 WILC_WFI_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K;
3550 WILC_WFI_band_2ghz.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE;
3553 wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &WILC_WFI_band_2ghz;
3564 * @brief WILC_WFI_WiphyRegister
3565 * @details Registering of the wiphy structure and interface modes
3572 struct wireless_dev *WILC_WFI_WiphyRegister(struct net_device *net)
3574 struct wilc_priv *priv;
3575 struct wireless_dev *wdev;
3578 PRINT_D(CFG80211_DBG, "Registering wifi device\n");
3580 wdev = WILC_WFI_CfgAlloc();
3582 PRINT_ER("CfgAlloc Failed\n");
3587 /*Return hardware description structure (wiphy)'s priv*/
3588 priv = wdev_priv(wdev);
3589 sema_init(&(priv->SemHandleUpdateStats), 1);
3591 /*Link the wiphy with wireless structure*/
3594 /*Maximum number of probed ssid to be added by user for the scan request*/
3595 wdev->wiphy->max_scan_ssids = MAX_NUM_PROBED_SSID;
3596 /*Maximum number of pmkids to be cashed*/
3597 wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS;
3598 PRINT_INFO(CFG80211_DBG, "Max number of PMKIDs = %d\n", wdev->wiphy->max_num_pmkids);
3600 wdev->wiphy->max_scan_ie_len = 1000;
3602 /*signal strength in mBm (100*dBm) */
3603 wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
3605 /*Set the availaible cipher suites*/
3606 wdev->wiphy->cipher_suites = cipher_suites;
3607 wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
3608 /*Setting default managment types: for register action frame: */
3609 wdev->wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types;
3611 wdev->wiphy->max_remain_on_channel_duration = 500;
3612 /*Setting the wiphy interfcae mode and type before registering the wiphy*/
3613 wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | BIT(NL80211_IFTYPE_P2P_GO) |
3614 BIT(NL80211_IFTYPE_P2P_CLIENT);
3615 wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
3616 wdev->iftype = NL80211_IFTYPE_STATION;
3620 PRINT_INFO(CFG80211_DBG, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n",
3621 wdev->wiphy->max_scan_ssids, wdev->wiphy->max_scan_ie_len, wdev->wiphy->signal_type,
3622 wdev->wiphy->interface_modes, wdev->iftype);
3625 set_wiphy_dev(wdev->wiphy, &local_sdio_func->dev); /* tony */
3628 /*Register wiphy structure*/
3629 s32Error = wiphy_register(wdev->wiphy);
3631 PRINT_ER("Cannot register wiphy device\n");
3632 /*should define what action to be taken in such failure*/
3634 PRINT_D(CFG80211_DBG, "Successful Registering\n");
3643 * @brief WILC_WFI_WiphyFree
3644 * @details Freeing allocation of the wireless device structure
3651 int WILC_WFI_InitHostInt(struct net_device *net)
3656 struct wilc_priv *priv;
3658 PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr);
3659 priv = wdev_priv(net->ieee80211_ptr);
3661 setup_timer(&hAgingTimer, remove_network_from_shadow, 0);
3662 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3663 setup_timer(&hDuringIpTimer, clear_duringIP, 0);
3668 PRINT_ER("Failed to creat refresh Timer\n");
3672 priv->gbAutoRateAdjusted = false;
3674 priv->bInP2PlistenState = false;
3676 sema_init(&(priv->hSemScanReq), 1);
3677 s32Error = host_int_init(&priv->hWILCWFIDrv);
3679 PRINT_ER("Error while initializing hostinterface\n");
3685 * @brief WILC_WFI_WiphyFree
3686 * @details Freeing allocation of the wireless device structure
3693 int WILC_WFI_DeInitHostInt(struct net_device *net)
3697 struct wilc_priv *priv;
3699 priv = wdev_priv(net->ieee80211_ptr);
3701 priv->gbAutoRateAdjusted = false;
3703 priv->bInP2PlistenState = false;
3707 s32Error = host_int_deinit(priv->hWILCWFIDrv);
3709 /* Clear the Shadow scan */
3710 clear_shadow_scan(priv);
3711 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3713 PRINT_D(CORECONFIG_DBG, "destroy during ip\n");
3714 del_timer_sync(&hDuringIpTimer);
3719 PRINT_ER("Error while deintializing host interface\n");
3726 * @brief WILC_WFI_WiphyFree
3727 * @details Freeing allocation of the wireless device structure
3734 void WILC_WFI_WiphyFree(struct net_device *net)
3737 PRINT_D(CFG80211_DBG, "Unregistering wiphy\n");
3740 PRINT_D(INIT_DBG, "net_device is NULL\n");
3744 if (net->ieee80211_ptr == NULL) {
3745 PRINT_D(INIT_DBG, "ieee80211_ptr is NULL\n");
3749 if (net->ieee80211_ptr->wiphy == NULL) {
3750 PRINT_D(INIT_DBG, "wiphy is NULL\n");
3754 wiphy_unregister(net->ieee80211_ptr->wiphy);
3756 PRINT_D(INIT_DBG, "Freeing wiphy\n");
3757 wiphy_free(net->ieee80211_ptr->wiphy);
3758 kfree(net->ieee80211_ptr);