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"
15 #include "linux_wlan_sdio.h"
17 #include <linux/errno.h>
19 #define IS_MANAGMEMENT 0x100
20 #define IS_MANAGMEMENT_CALLBACK 0x080
21 #define IS_MGMT_STATUS_SUCCES 0x040
22 #define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff)
24 extern int linux_wlan_get_firmware(perInterface_wlan_t *p_nic);
26 extern int mac_open(struct net_device *ndev);
27 extern int mac_close(struct net_device *ndev);
29 tstrNetworkInfo astrLastScannedNtwrksShadow[MAX_NUM_SCANNED_NETWORKS_SHADOW];
30 u32 u32LastScannedNtwrksCountShadow;
31 struct timer_list hDuringIpTimer;
32 struct timer_list hAgingTimer;
34 extern u8 u8ConnectedSSID[6];
36 u8 g_wilc_initialized = 1;
37 extern bool g_obtainingIP;
39 #define CHAN2G(_channel, _freq, _flags) { \
40 .band = IEEE80211_BAND_2GHZ, \
41 .center_freq = (_freq), \
42 .hw_value = (_channel), \
44 .max_antenna_gain = 0, \
48 /*Frequency range for channels*/
49 static struct ieee80211_channel WILC_WFI_2ghz_channels[] = {
66 #define RATETAB_ENT(_rate, _hw_value, _flags) { \
68 .hw_value = (_hw_value), \
73 /* Table 6 in section 3.2.1.1 */
74 static struct ieee80211_rate WILC_WFI_rates[] = {
75 RATETAB_ENT(10, 0, 0),
76 RATETAB_ENT(20, 1, 0),
77 RATETAB_ENT(55, 2, 0),
78 RATETAB_ENT(110, 3, 0),
79 RATETAB_ENT(60, 9, 0),
80 RATETAB_ENT(90, 6, 0),
81 RATETAB_ENT(120, 7, 0),
82 RATETAB_ENT(180, 8, 0),
83 RATETAB_ENT(240, 9, 0),
84 RATETAB_ENT(360, 10, 0),
85 RATETAB_ENT(480, 11, 0),
86 RATETAB_ENT(540, 12, 0),
89 struct p2p_mgmt_data {
94 /*Global variable used to state the current connected STA channel*/
95 u8 u8WLANChannel = INVALID_CHANNEL;
99 u8 u8P2P_oui[] = {0x50, 0x6f, 0x9A, 0x09};
100 u8 u8P2Plocalrandom = 0x01;
101 u8 u8P2Precvrandom = 0x00;
102 u8 u8P2P_vendorspec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};
105 static struct ieee80211_supported_band WILC_WFI_band_2ghz = {
106 .channels = WILC_WFI_2ghz_channels,
107 .n_channels = ARRAY_SIZE(WILC_WFI_2ghz_channels),
108 .bitrates = WILC_WFI_rates,
109 .n_bitrates = ARRAY_SIZE(WILC_WFI_rates),
113 struct add_key_params {
118 struct add_key_params g_add_gtk_key_params;
119 struct wilc_wfi_key g_key_gtk_params;
120 struct add_key_params g_add_ptk_key_params;
121 struct wilc_wfi_key g_key_ptk_params;
122 struct wilc_wfi_wep_key g_key_wep_params;
123 bool g_ptk_keys_saved;
124 bool g_gtk_keys_saved;
125 bool g_wep_keys_saved;
127 #define AGING_TIME (9 * 1000)
128 #define duringIP_TIME 15000
130 void clear_shadow_scan(void *pUserVoid)
135 del_timer_sync(&hAgingTimer);
136 PRINT_INFO(CORECONFIG_DBG, "destroy aging timer\n");
138 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
139 if (astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs != NULL) {
140 kfree(astrLastScannedNtwrksShadow[i].pu8IEs);
141 astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs = NULL;
144 host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
145 astrLastScannedNtwrksShadow[i].pJoinParams = NULL;
147 u32LastScannedNtwrksCountShadow = 0;
152 u32 get_rssi_avg(tstrNetworkInfo *pstrNetworkInfo)
156 u8 num_rssi = (pstrNetworkInfo->strRssi.u8Full) ? NUM_RSSI : (pstrNetworkInfo->strRssi.u8Index);
158 for (i = 0; i < num_rssi; i++)
159 rssi_v += pstrNetworkInfo->strRssi.as8RSSI[i];
165 void refresh_scan(void *pUserVoid, u8 all, bool bDirectScan)
167 struct wilc_priv *priv;
169 struct cfg80211_bss *bss = NULL;
173 priv = (struct wilc_priv *)pUserVoid;
174 wiphy = priv->dev->ieee80211_ptr->wiphy;
176 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
177 tstrNetworkInfo *pstrNetworkInfo;
179 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
182 if ((!pstrNetworkInfo->u8Found) || all) {
184 struct ieee80211_channel *channel;
186 if (pstrNetworkInfo != NULL) {
188 s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
189 channel = ieee80211_get_channel(wiphy, s32Freq);
191 rssi = get_rssi_avg(pstrNetworkInfo);
192 if (memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7) || bDirectScan) {
193 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
194 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
195 (size_t)pstrNetworkInfo->u16IEsLen, (((s32)rssi) * 100), GFP_KERNEL);
196 cfg80211_put_bss(wiphy, bss);
205 void reset_shadow_found(void *pUserVoid)
209 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
210 astrLastScannedNtwrksShadow[i].u8Found = 0;
215 void update_scan_time(void *pUserVoid)
219 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
220 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
224 static void remove_network_from_shadow(unsigned long arg)
226 unsigned long now = jiffies;
230 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
231 if (time_after(now, astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan + (unsigned long)(SCAN_RESULT_EXPIRE))) {
232 PRINT_D(CFG80211_DBG, "Network expired in ScanShadow: %s\n", astrLastScannedNtwrksShadow[i].au8ssid);
234 kfree(astrLastScannedNtwrksShadow[i].pu8IEs);
235 astrLastScannedNtwrksShadow[i].pu8IEs = NULL;
237 host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
239 for (j = i; (j < u32LastScannedNtwrksCountShadow - 1); j++) {
240 astrLastScannedNtwrksShadow[j] = astrLastScannedNtwrksShadow[j + 1];
242 u32LastScannedNtwrksCountShadow--;
246 PRINT_D(CFG80211_DBG, "Number of cached networks: %d\n", u32LastScannedNtwrksCountShadow);
247 if (u32LastScannedNtwrksCountShadow != 0) {
248 hAgingTimer.data = arg;
249 mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
251 PRINT_D(CFG80211_DBG, "No need to restart Aging timer\n");
255 static void clear_duringIP(unsigned long arg)
257 PRINT_D(GENERIC_DBG, "GO:IP Obtained , enable scan\n");
258 g_obtainingIP = false;
261 int is_network_in_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid)
266 if (u32LastScannedNtwrksCountShadow == 0) {
267 PRINT_D(CFG80211_DBG, "Starting Aging timer\n");
268 hAgingTimer.data = (unsigned long)pUserVoid;
269 mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
272 /* Linear search for now */
273 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
274 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
275 pstrNetworkInfo->au8bssid, 6) == 0) {
284 void add_network_to_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
286 int ap_found = is_network_in_shadow(pstrNetworkInfo, pUserVoid);
290 if (u32LastScannedNtwrksCountShadow >= MAX_NUM_SCANNED_NETWORKS_SHADOW) {
291 PRINT_D(CFG80211_DBG, "Shadow network reached its maximum limit\n");
294 if (ap_found == -1) {
295 ap_index = u32LastScannedNtwrksCountShadow;
296 u32LastScannedNtwrksCountShadow++;
301 rssi_index = astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index;
302 astrLastScannedNtwrksShadow[ap_index].strRssi.as8RSSI[rssi_index++] = pstrNetworkInfo->s8rssi;
303 if (rssi_index == NUM_RSSI) {
305 astrLastScannedNtwrksShadow[ap_index].strRssi.u8Full = 1;
307 astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index = rssi_index;
309 astrLastScannedNtwrksShadow[ap_index].s8rssi = pstrNetworkInfo->s8rssi;
310 astrLastScannedNtwrksShadow[ap_index].u16CapInfo = pstrNetworkInfo->u16CapInfo;
312 astrLastScannedNtwrksShadow[ap_index].u8SsidLen = pstrNetworkInfo->u8SsidLen;
313 memcpy(astrLastScannedNtwrksShadow[ap_index].au8ssid,
314 pstrNetworkInfo->au8ssid, pstrNetworkInfo->u8SsidLen);
316 memcpy(astrLastScannedNtwrksShadow[ap_index].au8bssid,
317 pstrNetworkInfo->au8bssid, ETH_ALEN);
319 astrLastScannedNtwrksShadow[ap_index].u16BeaconPeriod = pstrNetworkInfo->u16BeaconPeriod;
320 astrLastScannedNtwrksShadow[ap_index].u8DtimPeriod = pstrNetworkInfo->u8DtimPeriod;
321 astrLastScannedNtwrksShadow[ap_index].u8channel = pstrNetworkInfo->u8channel;
323 astrLastScannedNtwrksShadow[ap_index].u16IEsLen = pstrNetworkInfo->u16IEsLen;
324 astrLastScannedNtwrksShadow[ap_index].u64Tsf = pstrNetworkInfo->u64Tsf;
326 kfree(astrLastScannedNtwrksShadow[ap_index].pu8IEs);
327 astrLastScannedNtwrksShadow[ap_index].pu8IEs =
328 kmalloc(pstrNetworkInfo->u16IEsLen, GFP_KERNEL); /* will be deallocated by the WILC_WFI_CfgScan() function */
329 memcpy(astrLastScannedNtwrksShadow[ap_index].pu8IEs,
330 pstrNetworkInfo->pu8IEs, pstrNetworkInfo->u16IEsLen);
332 astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScan = jiffies;
333 astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScanCached = jiffies;
334 astrLastScannedNtwrksShadow[ap_index].u8Found = 1;
336 host_int_freeJoinParams(astrLastScannedNtwrksShadow[ap_index].pJoinParams);
337 astrLastScannedNtwrksShadow[ap_index].pJoinParams = pJoinParams;
343 * @brief CfgScanResult
344 * @details Callback function which returns the scan results found
346 * @param[in] tenuScanEvent enuScanEvent: enum, indicating the scan event triggered, whether that is
347 * SCAN_EVENT_NETWORK_FOUND or SCAN_EVENT_DONE
348 * tstrNetworkInfo* pstrNetworkInfo: structure holding the scan results information
349 * void* pUserVoid: Private structure associated with the wireless interface
355 static void CfgScanResult(enum scan_event enuScanEvent, tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
357 struct wilc_priv *priv;
360 struct ieee80211_channel *channel;
361 struct cfg80211_bss *bss = NULL;
363 priv = (struct wilc_priv *)pUserVoid;
364 if (priv->bCfgScanning) {
365 if (enuScanEvent == SCAN_EVENT_NETWORK_FOUND) {
366 wiphy = priv->dev->ieee80211_ptr->wiphy;
371 if (wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC
373 ((((s32)pstrNetworkInfo->s8rssi) * 100) < 0
375 (((s32)pstrNetworkInfo->s8rssi) * 100) > 100)
377 PRINT_ER("wiphy signal type fial\n");
381 if (pstrNetworkInfo != NULL) {
382 s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
383 channel = ieee80211_get_channel(wiphy, s32Freq);
388 PRINT_INFO(CFG80211_DBG, "Network Info:: CHANNEL Frequency: %d, RSSI: %d, CapabilityInfo: %d,"
389 "BeaconPeriod: %d\n", channel->center_freq, (((s32)pstrNetworkInfo->s8rssi) * 100),
390 pstrNetworkInfo->u16CapInfo, pstrNetworkInfo->u16BeaconPeriod);
392 if (pstrNetworkInfo->bNewNetwork) {
393 if (priv->u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
395 PRINT_D(CFG80211_DBG, "Network %s found\n", pstrNetworkInfo->au8ssid);
398 priv->u32RcvdChCount++;
402 if (pJoinParams == NULL) {
403 PRINT_INFO(CORECONFIG_DBG, ">> Something really bad happened\n");
405 add_network_to_shadow(pstrNetworkInfo, priv, pJoinParams);
407 /*P2P peers are sent to WPA supplicant and added to shadow table*/
409 if (!(memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7))) {
410 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
411 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
412 (size_t)pstrNetworkInfo->u16IEsLen, (((s32)pstrNetworkInfo->s8rssi) * 100), GFP_KERNEL);
413 cfg80211_put_bss(wiphy, bss);
418 PRINT_ER("Discovered networks exceeded the max limit\n");
422 /* So this network is discovered before, we'll just update its RSSI */
423 for (i = 0; i < priv->u32RcvdChCount; i++) {
424 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid, pstrNetworkInfo->au8bssid, 6) == 0) {
425 PRINT_D(CFG80211_DBG, "Update RSSI of %s\n", astrLastScannedNtwrksShadow[i].au8ssid);
427 astrLastScannedNtwrksShadow[i].s8rssi = pstrNetworkInfo->s8rssi;
428 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
434 } else if (enuScanEvent == SCAN_EVENT_DONE) {
435 PRINT_D(CFG80211_DBG, "Scan Done[%p]\n", priv->dev);
436 PRINT_D(CFG80211_DBG, "Refreshing Scan ...\n");
437 refresh_scan(priv, 1, false);
439 if (priv->u32RcvdChCount > 0)
440 PRINT_D(CFG80211_DBG, "%d Network(s) found\n", priv->u32RcvdChCount);
442 PRINT_D(CFG80211_DBG, "No networks found\n");
444 down(&(priv->hSemScanReq));
446 if (priv->pstrScanReq != NULL) {
447 cfg80211_scan_done(priv->pstrScanReq, false);
448 priv->u32RcvdChCount = 0;
449 priv->bCfgScanning = false;
450 priv->pstrScanReq = NULL;
452 up(&(priv->hSemScanReq));
455 /*Aborting any scan operation during mac close*/
456 else if (enuScanEvent == SCAN_EVENT_ABORTED) {
457 down(&(priv->hSemScanReq));
459 PRINT_D(CFG80211_DBG, "Scan Aborted\n");
460 if (priv->pstrScanReq != NULL) {
462 update_scan_time(priv);
463 refresh_scan(priv, 1, false);
465 cfg80211_scan_done(priv->pstrScanReq, false);
466 priv->bCfgScanning = false;
467 priv->pstrScanReq = NULL;
469 up(&(priv->hSemScanReq));
476 * @brief WILC_WFI_Set_PMKSA
477 * @details Check if pmksa is cached and set it.
479 * @return int : Return 0 on Success
484 int WILC_WFI_Set_PMKSA(u8 *bssid, struct wilc_priv *priv)
490 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
492 if (!memcmp(bssid, priv->pmkid_list.pmkidlist[i].bssid,
494 PRINT_D(CFG80211_DBG, "PMKID successful comparison");
496 /*If bssid is found, set the values*/
497 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
500 PRINT_ER("Error in pmkid\n");
510 int linux_wlan_set_bssid(struct net_device *wilc_netdev, u8 *pBSSID);
514 * @brief CfgConnectResult
516 * @param[in] tenuConnDisconnEvent enuConnDisconnEvent: Type of connection response either
517 * connection response or disconnection notification.
518 * tstrConnectInfo* pstrConnectInfo: COnnection information.
519 * u8 u8MacStatus: Mac Status from firmware
520 * tstrDisconnectNotifInfo* pstrDisconnectNotifInfo: Disconnection Notification
521 * void* pUserVoid: Private data associated with wireless interface
529 static void CfgConnectResult(enum conn_event enuConnDisconnEvent,
530 tstrConnectInfo *pstrConnectInfo,
532 tstrDisconnectNotifInfo *pstrDisconnectNotifInfo,
535 struct wilc_priv *priv;
536 struct net_device *dev;
537 struct host_if_drv *pstrWFIDrv;
538 u8 NullBssid[ETH_ALEN] = {0};
540 perInterface_wlan_t *nic;
544 priv = (struct wilc_priv *)pUserVoid;
546 nic = netdev_priv(dev);
548 pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
550 if (enuConnDisconnEvent == CONN_DISCONN_EVENT_CONN_RESP) {
552 u16 u16ConnectStatus;
554 u16ConnectStatus = pstrConnectInfo->u16ConnectStatus;
556 PRINT_D(CFG80211_DBG, " Connection response received = %d\n", u8MacStatus);
558 if ((u8MacStatus == MAC_DISCONNECTED) &&
559 (pstrConnectInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
560 /* The case here is that our station was waiting for association response frame and has just received it containing status code
561 * = SUCCESSFUL_STATUSCODE, while mac status is MAC_DISCONNECTED (which means something wrong happened) */
562 u16ConnectStatus = WLAN_STATUS_UNSPECIFIED_FAILURE;
563 linux_wlan_set_bssid(priv->dev, NullBssid);
564 eth_zero_addr(u8ConnectedSSID);
566 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
567 if (!pstrWFIDrv->u8P2PConnect)
568 u8WLANChannel = INVALID_CHANNEL;
570 PRINT_ER("Unspecified failure: Connection status %d : MAC status = %d\n", u16ConnectStatus, u8MacStatus);
573 if (u16ConnectStatus == WLAN_STATUS_SUCCESS) {
574 bool bNeedScanRefresh = false;
577 PRINT_INFO(CFG80211_DBG, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo->au8bssid[0],
578 pstrConnectInfo->au8bssid[1], pstrConnectInfo->au8bssid[2], pstrConnectInfo->au8bssid[3], pstrConnectInfo->au8bssid[4], pstrConnectInfo->au8bssid[5]);
579 memcpy(priv->au8AssociatedBss, pstrConnectInfo->au8bssid, ETH_ALEN);
582 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
583 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
584 pstrConnectInfo->au8bssid, ETH_ALEN) == 0) {
585 unsigned long now = jiffies;
588 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScanCached + (unsigned long)(nl80211_SCAN_RESULT_EXPIRE - (1 * HZ)))) {
589 bNeedScanRefresh = true;
596 if (bNeedScanRefresh) {
597 /*Also, refrsh DIRECT- results if */
598 refresh_scan(priv, 1, true);
605 PRINT_D(CFG80211_DBG, "Association request info elements length = %zu\n", pstrConnectInfo->ReqIEsLen);
607 PRINT_D(CFG80211_DBG, "Association response info elements length = %d\n", pstrConnectInfo->u16RespIEsLen);
609 cfg80211_connect_result(dev, pstrConnectInfo->au8bssid,
610 pstrConnectInfo->pu8ReqIEs, pstrConnectInfo->ReqIEsLen,
611 pstrConnectInfo->pu8RespIEs, pstrConnectInfo->u16RespIEsLen,
612 u16ConnectStatus, GFP_KERNEL); /* TODO: mostafa: u16ConnectStatus to */
613 /* be replaced by pstrConnectInfo->u16ConnectStatus */
614 } else if (enuConnDisconnEvent == CONN_DISCONN_EVENT_DISCONN_NOTIF) {
615 g_obtainingIP = false;
616 PRINT_ER("Received MAC_DISCONNECTED from firmware with reason %d on dev [%p]\n",
617 pstrDisconnectNotifInfo->u16reason, priv->dev);
618 u8P2Plocalrandom = 0x01;
619 u8P2Precvrandom = 0x00;
621 eth_zero_addr(priv->au8AssociatedBss);
622 linux_wlan_set_bssid(priv->dev, NullBssid);
623 eth_zero_addr(u8ConnectedSSID);
625 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
626 if (!pstrWFIDrv->u8P2PConnect)
627 u8WLANChannel = INVALID_CHANNEL;
628 /*Incase "P2P CLIENT Connected" send deauthentication reason by 3 to force the WPA_SUPPLICANT to directly change
629 * virtual interface to station*/
630 if ((pstrWFIDrv->IFC_UP) && (dev == wl->vif[1].ndev)) {
631 pstrDisconnectNotifInfo->u16reason = 3;
633 /*Incase "P2P CLIENT during connection(not connected)" send deauthentication reason by 1 to force the WPA_SUPPLICANT
634 * to scan again and retry the connection*/
635 else if ((!pstrWFIDrv->IFC_UP) && (dev == wl->vif[1].ndev)) {
636 pstrDisconnectNotifInfo->u16reason = 1;
638 cfg80211_disconnected(dev, pstrDisconnectNotifInfo->u16reason, pstrDisconnectNotifInfo->ie,
639 pstrDisconnectNotifInfo->ie_len, false,
649 * @details Set channel for a given wireless interface. Some devices
650 * may support multi-channel operation (by channel hopping) so cfg80211
651 * doesn't verify much. Note, however, that the passed netdev may be
652 * %NULL as well if the user requested changing the channel for the
653 * device itself, or for a monitor interface.
655 * @return int : Return 0 on Success
660 static int set_channel(struct wiphy *wiphy,
661 struct cfg80211_chan_def *chandef)
664 struct wilc_priv *priv;
667 priv = wiphy_priv(wiphy);
669 channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq);
670 PRINT_D(CFG80211_DBG, "Setting channel %d with frequency %d\n", channelnum, chandef->chan->center_freq);
672 curr_channel = channelnum;
673 result = host_int_set_mac_chnl_num(priv->hWILCWFIDrv, channelnum);
676 PRINT_ER("Error in setting channel %d\n", channelnum);
683 * @details Request to do a scan. If returning zero, the scan request is given
684 * the driver, and will be valid until passed to cfg80211_scan_done().
685 * For scan results, call cfg80211_inform_bss(); you can call this outside
686 * the scan/scan_done bracket too.
688 * @return int : Return 0 on Success
694 static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
696 struct wilc_priv *priv;
699 u8 au8ScanChanList[MAX_NUM_SCANNED_NETWORKS];
700 struct hidden_network strHiddenNetwork;
702 priv = wiphy_priv(wiphy);
704 priv->pstrScanReq = request;
706 priv->u32RcvdChCount = 0;
708 host_int_set_wfi_drv_handler(priv->hWILCWFIDrv);
711 reset_shadow_found(priv);
713 priv->bCfgScanning = true;
714 if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
716 for (i = 0; i < request->n_channels; i++) {
717 au8ScanChanList[i] = (u8)ieee80211_frequency_to_channel(request->channels[i]->center_freq);
718 PRINT_INFO(CFG80211_DBG, "ScanChannel List[%d] = %d,", i, au8ScanChanList[i]);
721 PRINT_D(CFG80211_DBG, "Requested num of scan channel %d\n", request->n_channels);
722 PRINT_D(CFG80211_DBG, "Scan Request IE len = %zu\n", request->ie_len);
724 PRINT_D(CFG80211_DBG, "Number of SSIDs %d\n", request->n_ssids);
726 if (request->n_ssids >= 1) {
729 strHiddenNetwork.pstrHiddenNetworkInfo = kmalloc(request->n_ssids * sizeof(struct hidden_network), GFP_KERNEL);
730 strHiddenNetwork.u8ssidnum = request->n_ssids;
733 for (i = 0; i < request->n_ssids; i++) {
735 if (request->ssids[i].ssid != NULL && request->ssids[i].ssid_len != 0) {
736 strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid = kmalloc(request->ssids[i].ssid_len, GFP_KERNEL);
737 memcpy(strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, request->ssids[i].ssid, request->ssids[i].ssid_len);
738 strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen = request->ssids[i].ssid_len;
740 PRINT_D(CFG80211_DBG, "Received one NULL SSID\n");
741 strHiddenNetwork.u8ssidnum -= 1;
744 PRINT_D(CFG80211_DBG, "Trigger Scan Request\n");
745 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
746 au8ScanChanList, request->n_channels,
747 (const u8 *)request->ie, request->ie_len,
748 CfgScanResult, (void *)priv, &strHiddenNetwork);
750 PRINT_D(CFG80211_DBG, "Trigger Scan Request\n");
751 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
752 au8ScanChanList, request->n_channels,
753 (const u8 *)request->ie, request->ie_len,
754 CfgScanResult, (void *)priv, NULL);
758 PRINT_ER("Requested num of scanned channels is greater than the max, supported"
764 PRINT_WRN(CFG80211_DBG, "Device is busy: Error(%d)\n", s32Error);
772 * @details Connect to the ESS with the specified parameters. When connected,
773 * call cfg80211_connect_result() with status code %WLAN_STATUS_SUCCESS.
774 * If the connection fails for some reason, call cfg80211_connect_result()
775 * with the status from the AP.
777 * @return int : Return 0 on Success
782 static int connect(struct wiphy *wiphy, struct net_device *dev,
783 struct cfg80211_connect_params *sme)
787 u8 u8security = NO_ENCRYPT;
788 enum AUTHTYPE tenuAuth_type = ANY;
789 char *pcgroup_encrypt_val = NULL;
790 char *pccipher_group = NULL;
791 char *pcwpa_version = NULL;
793 struct wilc_priv *priv;
794 struct host_if_drv *pstrWFIDrv;
795 tstrNetworkInfo *pstrNetworkInfo = NULL;
799 priv = wiphy_priv(wiphy);
800 pstrWFIDrv = (struct host_if_drv *)(priv->hWILCWFIDrv);
802 host_int_set_wfi_drv_handler(priv->hWILCWFIDrv);
804 PRINT_D(CFG80211_DBG, "Connecting to SSID [%s] on netdev [%p] host if [%p]\n", sme->ssid, dev, priv->hWILCWFIDrv);
805 if (!(strncmp(sme->ssid, "DIRECT-", 7))) {
806 PRINT_D(CFG80211_DBG, "Connected to Direct network,OBSS disabled\n");
807 pstrWFIDrv->u8P2PConnect = 1;
809 pstrWFIDrv->u8P2PConnect = 0;
810 PRINT_INFO(CFG80211_DBG, "Required SSID = %s\n , AuthType = %d\n", sme->ssid, sme->auth_type);
812 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
813 if ((sme->ssid_len == astrLastScannedNtwrksShadow[i].u8SsidLen) &&
814 memcmp(astrLastScannedNtwrksShadow[i].au8ssid,
816 sme->ssid_len) == 0) {
817 PRINT_INFO(CFG80211_DBG, "Network with required SSID is found %s\n", sme->ssid);
818 if (sme->bssid == NULL) {
819 /* BSSID is not passed from the user, so decision of matching
820 * is done by SSID only */
821 PRINT_INFO(CFG80211_DBG, "BSSID is not passed from the user\n");
824 /* BSSID is also passed from the user, so decision of matching
825 * should consider also this passed BSSID */
826 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
829 PRINT_INFO(CFG80211_DBG, "BSSID is passed from the user and matched\n");
836 if (i < u32LastScannedNtwrksCountShadow) {
837 PRINT_D(CFG80211_DBG, "Required bss is in scan results\n");
839 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
841 PRINT_INFO(CFG80211_DBG, "network BSSID to be associated: %x%x%x%x%x%x\n",
842 pstrNetworkInfo->au8bssid[0], pstrNetworkInfo->au8bssid[1],
843 pstrNetworkInfo->au8bssid[2], pstrNetworkInfo->au8bssid[3],
844 pstrNetworkInfo->au8bssid[4], pstrNetworkInfo->au8bssid[5]);
847 if (u32LastScannedNtwrksCountShadow == 0)
848 PRINT_D(CFG80211_DBG, "No Scan results yet\n");
850 PRINT_D(CFG80211_DBG, "Required bss not in scan results: Error(%d)\n", s32Error);
855 priv->WILC_WFI_wep_default = 0;
856 memset(priv->WILC_WFI_wep_key, 0, sizeof(priv->WILC_WFI_wep_key));
857 memset(priv->WILC_WFI_wep_key_len, 0, sizeof(priv->WILC_WFI_wep_key_len));
859 PRINT_INFO(CFG80211_DBG, "sme->crypto.wpa_versions=%x\n", sme->crypto.wpa_versions);
860 PRINT_INFO(CFG80211_DBG, "sme->crypto.cipher_group=%x\n", sme->crypto.cipher_group);
862 PRINT_INFO(CFG80211_DBG, "sme->crypto.n_ciphers_pairwise=%d\n", sme->crypto.n_ciphers_pairwise);
865 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++)
866 PRINT_D(CORECONFIG_DBG, "sme->crypto.ciphers_pairwise[%d]=%x\n", i, sme->crypto.ciphers_pairwise[i]);
869 if (sme->crypto.cipher_group != NO_ENCRYPT) {
870 /* To determine the u8security value, first we check the group cipher suite then {in case of WPA or WPA2}
871 * we will add to it the pairwise cipher suite(s) */
872 pcwpa_version = "Default";
873 PRINT_D(CORECONFIG_DBG, ">> sme->crypto.wpa_versions: %x\n", sme->crypto.wpa_versions);
874 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) {
875 u8security = ENCRYPT_ENABLED | WEP;
876 pcgroup_encrypt_val = "WEP40";
877 pccipher_group = "WLAN_CIPHER_SUITE_WEP40";
878 PRINT_INFO(CFG80211_DBG, "WEP Default Key Idx = %d\n", sme->key_idx);
881 for (i = 0; i < sme->key_len; i++)
882 PRINT_D(CORECONFIG_DBG, "WEP Key Value[%d] = %d\n", i, sme->key[i]);
884 priv->WILC_WFI_wep_default = sme->key_idx;
885 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
886 memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
888 g_key_wep_params.key_len = sme->key_len;
889 g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL);
890 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
891 g_key_wep_params.key_idx = sme->key_idx;
892 g_wep_keys_saved = true;
894 host_int_set_wep_default_key(priv->hWILCWFIDrv, sme->key_idx);
895 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
896 } else if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104) {
897 u8security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
898 pcgroup_encrypt_val = "WEP104";
899 pccipher_group = "WLAN_CIPHER_SUITE_WEP104";
901 priv->WILC_WFI_wep_default = sme->key_idx;
902 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
903 memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
905 g_key_wep_params.key_len = sme->key_len;
906 g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL);
907 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
908 g_key_wep_params.key_idx = sme->key_idx;
909 g_wep_keys_saved = true;
911 host_int_set_wep_default_key(priv->hWILCWFIDrv, sme->key_idx);
912 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
913 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) {
914 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
915 u8security = ENCRYPT_ENABLED | WPA2 | TKIP;
916 pcgroup_encrypt_val = "WPA2_TKIP";
917 pccipher_group = "TKIP";
918 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
919 /* tenuSecurity_t = WPA2_AES; */
920 u8security = ENCRYPT_ENABLED | WPA2 | AES;
921 pcgroup_encrypt_val = "WPA2_AES";
922 pccipher_group = "AES";
924 pcwpa_version = "WPA_VERSION_2";
925 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) {
926 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
927 u8security = ENCRYPT_ENABLED | WPA | TKIP;
928 pcgroup_encrypt_val = "WPA_TKIP";
929 pccipher_group = "TKIP";
930 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
931 /* tenuSecurity_t = WPA_AES; */
932 u8security = ENCRYPT_ENABLED | WPA | AES;
933 pcgroup_encrypt_val = "WPA_AES";
934 pccipher_group = "AES";
937 pcwpa_version = "WPA_VERSION_1";
940 s32Error = -ENOTSUPP;
941 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
948 /* After we set the u8security value from checking the group cipher suite, {in case of WPA or WPA2} we will
949 * add to it the pairwise cipher suite(s) */
950 if ((sme->crypto.wpa_versions & NL80211_WPA_VERSION_1)
951 || (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)) {
952 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) {
953 if (sme->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP) {
954 u8security = u8security | TKIP;
955 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
956 u8security = u8security | AES;
961 PRINT_D(CFG80211_DBG, "Adding key with cipher group = %x\n", sme->crypto.cipher_group);
963 PRINT_D(CFG80211_DBG, "Authentication Type = %d\n", sme->auth_type);
964 switch (sme->auth_type) {
965 case NL80211_AUTHTYPE_OPEN_SYSTEM:
966 PRINT_D(CFG80211_DBG, "In OPEN SYSTEM\n");
967 tenuAuth_type = OPEN_SYSTEM;
970 case NL80211_AUTHTYPE_SHARED_KEY:
971 tenuAuth_type = SHARED_KEY;
972 PRINT_D(CFG80211_DBG, "In SHARED KEY\n");
976 PRINT_D(CFG80211_DBG, "Automatic Authentation type = %d\n", sme->auth_type);
980 /* ai: key_mgmt: enterprise case */
981 if (sme->crypto.n_akm_suites) {
982 switch (sme->crypto.akm_suites[0]) {
983 case WLAN_AKM_SUITE_8021X:
984 tenuAuth_type = IEEE8021;
993 PRINT_INFO(CFG80211_DBG, "Required Channel = %d\n", pstrNetworkInfo->u8channel);
995 PRINT_INFO(CFG80211_DBG, "Group encryption value = %s\n Cipher Group = %s\n WPA version = %s\n",
996 pcgroup_encrypt_val, pccipher_group, pcwpa_version);
998 curr_channel = pstrNetworkInfo->u8channel;
1000 if (!pstrWFIDrv->u8P2PConnect) {
1001 u8WLANChannel = pstrNetworkInfo->u8channel;
1004 linux_wlan_set_bssid(dev, pstrNetworkInfo->au8bssid);
1006 s32Error = host_int_set_join_req(priv->hWILCWFIDrv, pstrNetworkInfo->au8bssid, sme->ssid,
1007 sme->ssid_len, sme->ie, sme->ie_len,
1008 CfgConnectResult, (void *)priv, u8security,
1009 tenuAuth_type, pstrNetworkInfo->u8channel,
1010 pstrNetworkInfo->pJoinParams);
1011 if (s32Error != 0) {
1012 PRINT_ER("host_int_set_join_req(): Error(%d)\n", s32Error);
1025 * @details Disconnect from the BSS/ESS.
1027 * @return int : Return 0 on Success
1032 static int disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code)
1035 struct wilc_priv *priv;
1036 struct host_if_drv *pstrWFIDrv;
1037 u8 NullBssid[ETH_ALEN] = {0};
1040 priv = wiphy_priv(wiphy);
1042 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
1043 pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
1044 if (!pstrWFIDrv->u8P2PConnect)
1045 u8WLANChannel = INVALID_CHANNEL;
1046 linux_wlan_set_bssid(priv->dev, NullBssid);
1048 PRINT_D(CFG80211_DBG, "Disconnecting with reason code(%d)\n", reason_code);
1050 u8P2Plocalrandom = 0x01;
1051 u8P2Precvrandom = 0x00;
1053 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
1055 s32Error = host_int_disconnect(priv->hWILCWFIDrv, reason_code);
1056 if (s32Error != 0) {
1057 PRINT_ER("Error in disconnecting: Error(%d)\n", s32Error);
1066 * @details Add a key with the given parameters. @mac_addr will be %NULL
1067 * when adding a group key.
1068 * @param[in] key : key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key, 8-byte Rx Mic Key
1069 * @return int : Return 0 on Success
1074 static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1076 const u8 *mac_addr, struct key_params *params)
1079 s32 s32Error = 0, KeyLen = params->key_len;
1081 struct wilc_priv *priv;
1082 const u8 *pu8RxMic = NULL;
1083 const u8 *pu8TxMic = NULL;
1084 u8 u8mode = NO_ENCRYPT;
1085 u8 u8gmode = NO_ENCRYPT;
1086 u8 u8pmode = NO_ENCRYPT;
1087 enum AUTHTYPE tenuAuth_type = ANY;
1089 perInterface_wlan_t *nic;
1091 priv = wiphy_priv(wiphy);
1092 nic = netdev_priv(netdev);
1095 PRINT_D(CFG80211_DBG, "Adding key with cipher suite = %x\n", params->cipher);
1097 PRINT_D(CFG80211_DBG, "%p %p %d\n", wiphy, netdev, key_index);
1099 PRINT_D(CFG80211_DBG, "key %x %x %x\n", params->key[0],
1104 switch (params->cipher) {
1105 case WLAN_CIPHER_SUITE_WEP40:
1106 case WLAN_CIPHER_SUITE_WEP104:
1107 if (priv->wdev->iftype == NL80211_IFTYPE_AP) {
1109 priv->WILC_WFI_wep_default = key_index;
1110 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
1111 memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
1113 PRINT_D(CFG80211_DBG, "Adding AP WEP Default key Idx = %d\n", key_index);
1114 PRINT_D(CFG80211_DBG, "Adding AP WEP Key len= %d\n", params->key_len);
1116 for (i = 0; i < params->key_len; i++)
1117 PRINT_D(CFG80211_DBG, "WEP AP key val[%d] = %x\n", i, params->key[i]);
1119 tenuAuth_type = OPEN_SYSTEM;
1121 if (params->cipher == WLAN_CIPHER_SUITE_WEP40)
1122 u8mode = ENCRYPT_ENABLED | WEP;
1124 u8mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
1126 host_int_add_wep_key_bss_ap(priv->hWILCWFIDrv, params->key, params->key_len, key_index, u8mode, tenuAuth_type);
1129 if (memcmp(params->key, priv->WILC_WFI_wep_key[key_index], params->key_len)) {
1130 priv->WILC_WFI_wep_default = key_index;
1131 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
1132 memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
1134 PRINT_D(CFG80211_DBG, "Adding WEP Default key Idx = %d\n", key_index);
1135 PRINT_D(CFG80211_DBG, "Adding WEP Key length = %d\n", params->key_len);
1137 for (i = 0; i < params->key_len; i++)
1138 PRINT_INFO(CFG80211_DBG, "WEP key value[%d] = %d\n", i, params->key[i]);
1140 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, params->key, params->key_len, key_index);
1145 case WLAN_CIPHER_SUITE_TKIP:
1146 case WLAN_CIPHER_SUITE_CCMP:
1147 if (priv->wdev->iftype == NL80211_IFTYPE_AP || priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) {
1149 if (priv->wilc_gtk[key_index] == NULL) {
1150 priv->wilc_gtk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL);
1151 priv->wilc_gtk[key_index]->key = NULL;
1152 priv->wilc_gtk[key_index]->seq = NULL;
1155 if (priv->wilc_ptk[key_index] == NULL) {
1156 priv->wilc_ptk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL);
1157 priv->wilc_ptk[key_index]->key = NULL;
1158 priv->wilc_ptk[key_index]->seq = NULL;
1164 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1165 u8gmode = ENCRYPT_ENABLED | WPA | TKIP;
1167 u8gmode = ENCRYPT_ENABLED | WPA2 | AES;
1169 priv->wilc_groupkey = u8gmode;
1171 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1173 pu8TxMic = params->key + 24;
1174 pu8RxMic = params->key + 16;
1175 KeyLen = params->key_len - 16;
1177 /* if there has been previous allocation for the same index through its key, free that memory and allocate again*/
1178 kfree(priv->wilc_gtk[key_index]->key);
1180 priv->wilc_gtk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
1181 memcpy(priv->wilc_gtk[key_index]->key, params->key, params->key_len);
1183 /* if there has been previous allocation for the same index through its seq, free that memory and allocate again*/
1184 kfree(priv->wilc_gtk[key_index]->seq);
1186 if ((params->seq_len) > 0) {
1187 priv->wilc_gtk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
1188 memcpy(priv->wilc_gtk[key_index]->seq, params->seq, params->seq_len);
1191 priv->wilc_gtk[key_index]->cipher = params->cipher;
1192 priv->wilc_gtk[key_index]->key_len = params->key_len;
1193 priv->wilc_gtk[key_index]->seq_len = params->seq_len;
1196 for (i = 0; i < params->key_len; i++)
1197 PRINT_INFO(CFG80211_DBG, "Adding group key value[%d] = %x\n", i, params->key[i]);
1198 for (i = 0; i < params->seq_len; i++)
1199 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1203 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1204 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, AP_MODE, u8gmode);
1207 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]);
1209 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1210 u8pmode = ENCRYPT_ENABLED | WPA | TKIP;
1212 u8pmode = priv->wilc_groupkey | AES;
1215 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1217 pu8TxMic = params->key + 24;
1218 pu8RxMic = params->key + 16;
1219 KeyLen = params->key_len - 16;
1222 kfree(priv->wilc_ptk[key_index]->key);
1224 priv->wilc_ptk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
1226 kfree(priv->wilc_ptk[key_index]->seq);
1228 if ((params->seq_len) > 0)
1229 priv->wilc_ptk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
1232 for (i = 0; i < params->key_len; i++)
1233 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %x\n", i, params->key[i]);
1235 for (i = 0; i < params->seq_len; i++)
1236 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1239 memcpy(priv->wilc_ptk[key_index]->key, params->key, params->key_len);
1241 if ((params->seq_len) > 0)
1242 memcpy(priv->wilc_ptk[key_index]->seq, params->seq, params->seq_len);
1244 priv->wilc_ptk[key_index]->cipher = params->cipher;
1245 priv->wilc_ptk[key_index]->key_len = params->key_len;
1246 priv->wilc_ptk[key_index]->seq_len = params->seq_len;
1248 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1249 pu8RxMic, pu8TxMic, AP_MODE, u8pmode, key_index);
1257 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1258 /* swap the tx mic by rx mic */
1259 pu8RxMic = params->key + 24;
1260 pu8TxMic = params->key + 16;
1261 KeyLen = params->key_len - 16;
1264 /*save keys only on interface 0 (wifi interface)*/
1265 if (!g_gtk_keys_saved && netdev == wl->vif[0].ndev) {
1266 g_add_gtk_key_params.key_idx = key_index;
1267 g_add_gtk_key_params.pairwise = pairwise;
1269 g_add_gtk_key_params.mac_addr = NULL;
1271 g_add_gtk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL);
1272 memcpy(g_add_gtk_key_params.mac_addr, mac_addr, ETH_ALEN);
1274 g_key_gtk_params.key_len = params->key_len;
1275 g_key_gtk_params.seq_len = params->seq_len;
1276 g_key_gtk_params.key = kmalloc(params->key_len, GFP_KERNEL);
1277 memcpy(g_key_gtk_params.key, params->key, params->key_len);
1278 if (params->seq_len > 0) {
1279 g_key_gtk_params.seq = kmalloc(params->seq_len, GFP_KERNEL);
1280 memcpy(g_key_gtk_params.seq, params->seq, params->seq_len);
1282 g_key_gtk_params.cipher = params->cipher;
1284 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_gtk_params.key[0],
1285 g_key_gtk_params.key[1],
1286 g_key_gtk_params.key[2]);
1287 g_gtk_keys_saved = true;
1290 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1291 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, STATION_MODE, u8mode);
1293 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1294 /* swap the tx mic by rx mic */
1295 pu8RxMic = params->key + 24;
1296 pu8TxMic = params->key + 16;
1297 KeyLen = params->key_len - 16;
1300 /*save keys only on interface 0 (wifi interface)*/
1301 if (!g_ptk_keys_saved && netdev == wl->vif[0].ndev) {
1302 g_add_ptk_key_params.key_idx = key_index;
1303 g_add_ptk_key_params.pairwise = pairwise;
1305 g_add_ptk_key_params.mac_addr = NULL;
1307 g_add_ptk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL);
1308 memcpy(g_add_ptk_key_params.mac_addr, mac_addr, ETH_ALEN);
1310 g_key_ptk_params.key_len = params->key_len;
1311 g_key_ptk_params.seq_len = params->seq_len;
1312 g_key_ptk_params.key = kmalloc(params->key_len, GFP_KERNEL);
1313 memcpy(g_key_ptk_params.key, params->key, params->key_len);
1314 if (params->seq_len > 0) {
1315 g_key_ptk_params.seq = kmalloc(params->seq_len, GFP_KERNEL);
1316 memcpy(g_key_ptk_params.seq, params->seq, params->seq_len);
1318 g_key_ptk_params.cipher = params->cipher;
1320 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_ptk_params.key[0],
1321 g_key_ptk_params.key[1],
1322 g_key_ptk_params.key[2]);
1323 g_ptk_keys_saved = true;
1326 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1327 pu8RxMic, pu8TxMic, STATION_MODE, u8mode, key_index);
1328 PRINT_D(CFG80211_DBG, "Adding pairwise key\n");
1330 for (i = 0; i < params->key_len; i++)
1331 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %d\n", i, params->key[i]);
1338 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
1339 s32Error = -ENOTSUPP;
1348 * @details Remove a key given the @mac_addr (%NULL for a group key)
1349 * and @key_index, return -ENOENT if the key doesn't exist.
1351 * @return int : Return 0 on Success
1356 static int del_key(struct wiphy *wiphy, struct net_device *netdev,
1361 struct wilc_priv *priv;
1363 perInterface_wlan_t *nic;
1365 priv = wiphy_priv(wiphy);
1366 nic = netdev_priv(netdev);
1369 /*delete saved keys, if any*/
1370 if (netdev == wl->vif[0].ndev) {
1371 g_ptk_keys_saved = false;
1372 g_gtk_keys_saved = false;
1373 g_wep_keys_saved = false;
1375 /*Delete saved WEP keys params, if any*/
1376 kfree(g_key_wep_params.key);
1377 g_key_wep_params.key = NULL;
1379 /*freeing memory allocated by "wilc_gtk" and "wilc_ptk" in "WILC_WIFI_ADD_KEY"*/
1381 if ((priv->wilc_gtk[key_index]) != NULL) {
1383 kfree(priv->wilc_gtk[key_index]->key);
1384 priv->wilc_gtk[key_index]->key = NULL;
1385 kfree(priv->wilc_gtk[key_index]->seq);
1386 priv->wilc_gtk[key_index]->seq = NULL;
1388 kfree(priv->wilc_gtk[key_index]);
1389 priv->wilc_gtk[key_index] = NULL;
1393 if ((priv->wilc_ptk[key_index]) != NULL) {
1395 kfree(priv->wilc_ptk[key_index]->key);
1396 priv->wilc_ptk[key_index]->key = NULL;
1397 kfree(priv->wilc_ptk[key_index]->seq);
1398 priv->wilc_ptk[key_index]->seq = NULL;
1399 kfree(priv->wilc_ptk[key_index]);
1400 priv->wilc_ptk[key_index] = NULL;
1403 /*Delete saved PTK and GTK keys params, if any*/
1404 kfree(g_key_ptk_params.key);
1405 g_key_ptk_params.key = NULL;
1406 kfree(g_key_ptk_params.seq);
1407 g_key_ptk_params.seq = NULL;
1409 kfree(g_key_gtk_params.key);
1410 g_key_gtk_params.key = NULL;
1411 kfree(g_key_gtk_params.seq);
1412 g_key_gtk_params.seq = NULL;
1414 /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/
1415 Set_machw_change_vir_if(netdev, false);
1418 if (key_index >= 0 && key_index <= 3) {
1419 memset(priv->WILC_WFI_wep_key[key_index], 0, priv->WILC_WFI_wep_key_len[key_index]);
1420 priv->WILC_WFI_wep_key_len[key_index] = 0;
1422 PRINT_D(CFG80211_DBG, "Removing WEP key with index = %d\n", key_index);
1423 host_int_remove_wep_key(priv->hWILCWFIDrv, key_index);
1425 PRINT_D(CFG80211_DBG, "Removing all installed keys\n");
1426 host_int_remove_key(priv->hWILCWFIDrv, mac_addr);
1434 * @details Get information about the key with the given parameters.
1435 * @mac_addr will be %NULL when requesting information for a group
1436 * key. All pointers given to the @callback function need not be valid
1437 * after it returns. This function should return an error if it is
1438 * not possible to retrieve the key, -ENOENT if it doesn't exist.
1440 * @return int : Return 0 on Success
1445 static int get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1447 const u8 *mac_addr, void *cookie, void (*callback)(void *cookie, struct key_params *))
1449 struct wilc_priv *priv;
1450 struct key_params key_params;
1453 priv = wiphy_priv(wiphy);
1457 PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index);
1459 key_params.key = priv->wilc_gtk[key_index]->key;
1460 key_params.cipher = priv->wilc_gtk[key_index]->cipher;
1461 key_params.key_len = priv->wilc_gtk[key_index]->key_len;
1462 key_params.seq = priv->wilc_gtk[key_index]->seq;
1463 key_params.seq_len = priv->wilc_gtk[key_index]->seq_len;
1465 for (i = 0; i < key_params.key_len; i++)
1466 PRINT_INFO(CFG80211_DBG, "Retrieved key value %x\n", key_params.key[i]);
1469 PRINT_D(CFG80211_DBG, "Getting pairwise key\n");
1471 key_params.key = priv->wilc_ptk[key_index]->key;
1472 key_params.cipher = priv->wilc_ptk[key_index]->cipher;
1473 key_params.key_len = priv->wilc_ptk[key_index]->key_len;
1474 key_params.seq = priv->wilc_ptk[key_index]->seq;
1475 key_params.seq_len = priv->wilc_ptk[key_index]->seq_len;
1478 callback(cookie, &key_params);
1480 return 0; /* priv->wilc_gtk->key_len ?0 : -ENOENT; */
1484 * @brief set_default_key
1485 * @details Set the default management frame key on an interface
1487 * @return int : Return 0 on Success.
1492 static int set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1493 bool unicast, bool multicast)
1495 struct wilc_priv *priv;
1498 priv = wiphy_priv(wiphy);
1500 PRINT_D(CFG80211_DBG, "Setting default key with idx = %d\n", key_index);
1502 if (key_index != priv->WILC_WFI_wep_default) {
1504 host_int_set_wep_default_key(priv->hWILCWFIDrv, key_index);
1511 * @brief get_station
1512 * @details Get station information for the station identified by @mac
1514 * @return int : Return 0 on Success.
1520 static int get_station(struct wiphy *wiphy, struct net_device *dev,
1521 const u8 *mac, struct station_info *sinfo)
1523 struct wilc_priv *priv;
1524 perInterface_wlan_t *nic;
1526 u32 associatedsta = 0;
1527 u32 inactive_time = 0;
1528 priv = wiphy_priv(wiphy);
1529 nic = netdev_priv(dev);
1531 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
1532 PRINT_D(HOSTAPD_DBG, "Getting station parameters\n");
1534 PRINT_INFO(HOSTAPD_DBG, ": %x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4]);
1536 for (i = 0; i < NUM_STA_ASSOCIATED; i++) {
1538 if (!(memcmp(mac, priv->assoc_stainfo.au8Sta_AssociatedBss[i], ETH_ALEN))) {
1545 if (associatedsta == -1) {
1546 PRINT_ER("Station required is not associated\n");
1550 sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME);
1552 host_int_get_inactive_time(priv->hWILCWFIDrv, mac, &(inactive_time));
1553 sinfo->inactive_time = 1000 * inactive_time;
1554 PRINT_D(CFG80211_DBG, "Inactive time %d\n", sinfo->inactive_time);
1558 if (nic->iftype == STATION_MODE) {
1559 struct rf_info strStatistics;
1561 host_int_get_statistics(priv->hWILCWFIDrv, &strStatistics);
1563 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) |
1564 BIT(NL80211_STA_INFO_RX_PACKETS) |
1565 BIT(NL80211_STA_INFO_TX_PACKETS) |
1566 BIT(NL80211_STA_INFO_TX_FAILED) |
1567 BIT(NL80211_STA_INFO_TX_BITRATE);
1569 sinfo->signal = strStatistics.s8RSSI;
1570 sinfo->rx_packets = strStatistics.u32RxCount;
1571 sinfo->tx_packets = strStatistics.u32TxCount + strStatistics.u32TxFailureCount;
1572 sinfo->tx_failed = strStatistics.u32TxFailureCount;
1573 sinfo->txrate.legacy = strStatistics.u8LinkSpeed * 10;
1575 if ((strStatistics.u8LinkSpeed > TCP_ACK_FILTER_LINK_SPEED_THRESH) && (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED))
1576 Enable_TCP_ACK_Filter(true);
1577 else if (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED)
1578 Enable_TCP_ACK_Filter(false);
1580 PRINT_D(CORECONFIG_DBG, "*** stats[%d][%d][%d][%d][%d]\n", sinfo->signal, sinfo->rx_packets, sinfo->tx_packets,
1581 sinfo->tx_failed, sinfo->txrate.legacy);
1589 * @details Modify parameters for a given BSS.
1591 * -use_cts_prot: Whether to use CTS protection
1592 * (0 = no, 1 = yes, -1 = do not change)
1593 * -use_short_preamble: Whether the use of short preambles is allowed
1594 * (0 = no, 1 = yes, -1 = do not change)
1595 * -use_short_slot_time: Whether the use of short slot time is allowed
1596 * (0 = no, 1 = yes, -1 = do not change)
1597 * -basic_rates: basic rates in IEEE 802.11 format
1598 * (or NULL for no change)
1599 * -basic_rates_len: number of basic rates
1600 * -ap_isolate: do not forward packets between connected stations
1601 * -ht_opmode: HT Operation mode
1602 * (u16 = opmode, -1 = do not change)
1603 * @return int : Return 0 on Success.
1608 static int change_bss(struct wiphy *wiphy, struct net_device *dev,
1609 struct bss_parameters *params)
1611 PRINT_D(CFG80211_DBG, "Changing Bss parametrs\n");
1616 * @brief set_wiphy_params
1617 * @details Notify that wiphy parameters have changed;
1618 * @param[in] Changed bitfield (see &enum wiphy_params_flags) describes which values
1620 * @return int : Return 0 on Success
1625 static int set_wiphy_params(struct wiphy *wiphy, u32 changed)
1628 struct cfg_param_val pstrCfgParamVal;
1629 struct wilc_priv *priv;
1631 priv = wiphy_priv(wiphy);
1633 pstrCfgParamVal.flag = 0;
1634 PRINT_D(CFG80211_DBG, "Setting Wiphy params\n");
1636 if (changed & WIPHY_PARAM_RETRY_SHORT) {
1637 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_SHORT %d\n",
1638 priv->dev->ieee80211_ptr->wiphy->retry_short);
1639 pstrCfgParamVal.flag |= RETRY_SHORT;
1640 pstrCfgParamVal.short_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_short;
1642 if (changed & WIPHY_PARAM_RETRY_LONG) {
1644 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_LONG %d\n", priv->dev->ieee80211_ptr->wiphy->retry_long);
1645 pstrCfgParamVal.flag |= RETRY_LONG;
1646 pstrCfgParamVal.long_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_long;
1649 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
1650 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->frag_threshold);
1651 pstrCfgParamVal.flag |= FRAG_THRESHOLD;
1652 pstrCfgParamVal.frag_threshold = priv->dev->ieee80211_ptr->wiphy->frag_threshold;
1656 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
1657 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->rts_threshold);
1659 pstrCfgParamVal.flag |= RTS_THRESHOLD;
1660 pstrCfgParamVal.rts_threshold = priv->dev->ieee80211_ptr->wiphy->rts_threshold;
1664 PRINT_D(CFG80211_DBG, "Setting CFG params in the host interface\n");
1665 s32Error = hif_set_cfg(priv->hWILCWFIDrv, &pstrCfgParamVal);
1667 PRINT_ER("Error in setting WIPHY PARAMS\n");
1675 * @details Cache a PMKID for a BSSID. This is mostly useful for fullmac
1676 * devices running firmwares capable of generating the (re) association
1677 * RSN IE. It allows for faster roaming between WPA2 BSSIDs.
1679 * @return int : Return 0 on Success
1684 static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1685 struct cfg80211_pmksa *pmksa)
1691 struct wilc_priv *priv = wiphy_priv(wiphy);
1693 PRINT_D(CFG80211_DBG, "Setting PMKSA\n");
1696 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
1697 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
1699 /*If bssid already exists and pmkid value needs to reset*/
1701 PRINT_D(CFG80211_DBG, "PMKID already exists\n");
1705 if (i < WILC_MAX_NUM_PMKIDS) {
1706 PRINT_D(CFG80211_DBG, "Setting PMKID in private structure\n");
1707 memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid,
1709 memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid,
1711 if (!(flag == PMKID_FOUND))
1712 priv->pmkid_list.numpmkid++;
1714 PRINT_ER("Invalid PMKID index\n");
1719 PRINT_D(CFG80211_DBG, "Setting pmkid in the host interface\n");
1720 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
1727 * @details Delete a cached PMKID.
1729 * @return int : Return 0 on Success
1734 static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1735 struct cfg80211_pmksa *pmksa)
1741 struct wilc_priv *priv = wiphy_priv(wiphy);
1743 PRINT_D(CFG80211_DBG, "Deleting PMKSA keys\n");
1745 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
1746 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
1748 /*If bssid is found, reset the values*/
1749 PRINT_D(CFG80211_DBG, "Reseting PMKID values\n");
1750 memset(&priv->pmkid_list.pmkidlist[i], 0, sizeof(struct host_if_pmkid));
1755 if (i < priv->pmkid_list.numpmkid && priv->pmkid_list.numpmkid > 0) {
1756 for (; i < (priv->pmkid_list.numpmkid - 1); i++) {
1757 memcpy(priv->pmkid_list.pmkidlist[i].bssid,
1758 priv->pmkid_list.pmkidlist[i + 1].bssid,
1760 memcpy(priv->pmkid_list.pmkidlist[i].pmkid,
1761 priv->pmkid_list.pmkidlist[i].pmkid,
1764 priv->pmkid_list.numpmkid--;
1773 * @brief flush_pmksa
1774 * @details Flush all cached PMKIDs.
1776 * @return int : Return 0 on Success
1781 static int flush_pmksa(struct wiphy *wiphy, struct net_device *netdev)
1783 struct wilc_priv *priv = wiphy_priv(wiphy);
1785 PRINT_D(CFG80211_DBG, "Flushing PMKID key values\n");
1787 /*Get cashed Pmkids and set all with zeros*/
1788 memset(&priv->pmkid_list, 0, sizeof(struct host_if_pmkid_attr));
1795 * @brief WILC_WFI_CfgParseRxAction
1796 * @details Function parses the received frames and modifies the following attributes:
1799 * -Operating Channel
1801 * @param[in] u8* Buffer, u32 length
1808 void WILC_WFI_CfgParseRxAction(u8 *buf, u32 len)
1813 u8 op_channel_attr_index = 0;
1814 u8 channel_list_attr_index = 0;
1816 while (index < len) {
1817 if (buf[index] == GO_INTENT_ATTR_ID) {
1818 buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1);
1821 if (buf[index] == CHANLIST_ATTR_ID)
1822 channel_list_attr_index = index;
1823 else if (buf[index] == OPERCHAN_ATTR_ID)
1824 op_channel_attr_index = index;
1825 index += buf[index + 1] + 3; /* ID,Length byte */
1827 if (u8WLANChannel != INVALID_CHANNEL) {
1829 /*Modify channel list attribute*/
1830 if (channel_list_attr_index) {
1831 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
1832 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
1833 if (buf[i] == 0x51) {
1834 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
1835 buf[j] = u8WLANChannel;
1841 /*Modify operating channel attribute*/
1842 if (op_channel_attr_index) {
1843 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
1844 buf[op_channel_attr_index + 6] = 0x51;
1845 buf[op_channel_attr_index + 7] = u8WLANChannel;
1851 * @brief WILC_WFI_CfgParseTxAction
1852 * @details Function parses the transmitted action frames and modifies the
1853 * GO Intent attribute
1854 * @param[in] u8* Buffer, u32 length, bool bOperChan, u8 iftype
1860 void WILC_WFI_CfgParseTxAction(u8 *buf, u32 len, bool bOperChan, u8 iftype)
1865 u8 op_channel_attr_index = 0;
1866 u8 channel_list_attr_index = 0;
1868 while (index < len) {
1869 if (buf[index] == GO_INTENT_ATTR_ID) {
1870 buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1);
1875 if (buf[index] == CHANLIST_ATTR_ID)
1876 channel_list_attr_index = index;
1877 else if (buf[index] == OPERCHAN_ATTR_ID)
1878 op_channel_attr_index = index;
1879 index += buf[index + 1] + 3; /* ID,Length byte */
1881 if (u8WLANChannel != INVALID_CHANNEL && bOperChan) {
1883 /*Modify channel list attribute*/
1884 if (channel_list_attr_index) {
1885 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
1886 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
1887 if (buf[i] == 0x51) {
1888 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
1889 buf[j] = u8WLANChannel;
1895 /*Modify operating channel attribute*/
1896 if (op_channel_attr_index) {
1897 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
1898 buf[op_channel_attr_index + 6] = 0x51;
1899 buf[op_channel_attr_index + 7] = u8WLANChannel;
1904 /* @brief WILC_WFI_p2p_rx
1909 * @author Mai Daftedar
1914 void WILC_WFI_p2p_rx (struct net_device *dev, u8 *buff, u32 size)
1917 struct wilc_priv *priv;
1918 u32 header, pkt_offset;
1919 struct host_if_drv *pstrWFIDrv;
1923 priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
1924 pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
1926 /* Get WILC header */
1927 memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
1929 /* The packet offset field conain info about what type of managment frame */
1930 /* we are dealing with and ack status */
1931 pkt_offset = GET_PKT_OFFSET(header);
1933 if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
1934 if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP) {
1935 PRINT_D(GENERIC_DBG, "Probe response ACK\n");
1936 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
1939 if (pkt_offset & IS_MGMT_STATUS_SUCCES) {
1940 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],
1941 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
1942 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
1944 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],
1945 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
1946 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, false, GFP_KERNEL);
1952 PRINT_D(GENERIC_DBG, "Rx Frame Type:%x\n", buff[FRAME_TYPE_ID]);
1954 /*Upper layer is informed that the frame is received on this freq*/
1955 s32Freq = ieee80211_channel_to_frequency(curr_channel, IEEE80211_BAND_2GHZ);
1957 if (ieee80211_is_action(buff[FRAME_TYPE_ID])) {
1958 PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]);
1960 if (priv->bCfgScanning && time_after_eq(jiffies, (unsigned long)pstrWFIDrv->u64P2p_MgmtTimeout)) {
1961 PRINT_D(GENERIC_DBG, "Receiving action frames from wrong channels\n");
1964 if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
1966 switch (buff[ACTION_SUBTYPE_ID]) {
1967 case GAS_INTIAL_REQ:
1968 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buff[ACTION_SUBTYPE_ID]);
1971 case GAS_INTIAL_RSP:
1972 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buff[ACTION_SUBTYPE_ID]);
1975 case PUBLIC_ACT_VENDORSPEC:
1976 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
1977 * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/
1978 if (!memcmp(u8P2P_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) {
1979 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
1981 for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) {
1982 if (!memcmp(u8P2P_vendorspec, &buff[i], 6)) {
1983 u8P2Precvrandom = buff[i + 6];
1985 PRINT_D(GENERIC_DBG, "WILC Vendor specific IE:%02x\n", u8P2Precvrandom);
1991 if (u8P2Plocalrandom > u8P2Precvrandom) {
1992 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
1993 || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
1994 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) {
1995 if (buff[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buff[i + 2], 4))) {
1996 WILC_WFI_CfgParseRxAction(&buff[i + 6], size - (i + 6));
2002 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2006 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP) && (bWilc_ie)) {
2007 PRINT_D(GENERIC_DBG, "Sending P2P to host without extra elemnt\n");
2008 /* extra attribute for sig_dbm: signal strength in mBm, or 0 if unknown */
2009 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
2015 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff[ACTION_SUBTYPE_ID]);
2021 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
2026 * @brief WILC_WFI_mgmt_tx_complete
2027 * @details Returns result of writing mgmt frame to VMM (Tx buffers are freed here)
2029 * transmitting status
2031 * @author Amr Abdelmoghny
2035 static void WILC_WFI_mgmt_tx_complete(void *priv, int status)
2037 struct p2p_mgmt_data *pv_data = (struct p2p_mgmt_data *)priv;
2040 kfree(pv_data->buff);
2045 * @brief WILC_WFI_RemainOnChannelReady
2046 * @details Callback function, called from handle_remain_on_channel on being ready on channel
2049 * @author Amr abdelmoghny
2054 static void WILC_WFI_RemainOnChannelReady(void *pUserVoid)
2056 struct wilc_priv *priv;
2058 priv = (struct wilc_priv *)pUserVoid;
2060 PRINT_D(HOSTINF_DBG, "Remain on channel ready\n");
2062 priv->bInP2PlistenState = true;
2064 cfg80211_ready_on_channel(priv->wdev,
2065 priv->strRemainOnChanParams.u64ListenCookie,
2066 priv->strRemainOnChanParams.pstrListenChan,
2067 priv->strRemainOnChanParams.u32ListenDuration,
2072 * @brief WILC_WFI_RemainOnChannelExpired
2073 * @details Callback function, called on expiration of remain-on-channel duration
2076 * @author Amr abdelmoghny
2081 static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, u32 u32SessionID)
2083 struct wilc_priv *priv;
2085 priv = (struct wilc_priv *)pUserVoid;
2087 if (u32SessionID == priv->strRemainOnChanParams.u32ListenSessionID) {
2088 PRINT_D(GENERIC_DBG, "Remain on channel expired\n");
2090 priv->bInP2PlistenState = false;
2092 /*Inform wpas of remain-on-channel expiration*/
2093 cfg80211_remain_on_channel_expired(priv->wdev,
2094 priv->strRemainOnChanParams.u64ListenCookie,
2095 priv->strRemainOnChanParams.pstrListenChan,
2098 PRINT_D(GENERIC_DBG, "Received ID 0x%x Expected ID 0x%x (No match)\n", u32SessionID
2099 , priv->strRemainOnChanParams.u32ListenSessionID);
2105 * @brief remain_on_channel
2106 * @details Request the driver to remain awake on the specified
2107 * channel for the specified duration to complete an off-channel
2108 * operation (e.g., public action frame exchange). When the driver is
2109 * ready on the requested channel, it must indicate this with an event
2110 * notification by calling cfg80211_ready_on_channel().
2112 * @return int : Return 0 on Success
2117 static int remain_on_channel(struct wiphy *wiphy,
2118 struct wireless_dev *wdev,
2119 struct ieee80211_channel *chan,
2120 unsigned int duration, u64 *cookie)
2123 struct wilc_priv *priv;
2125 priv = wiphy_priv(wiphy);
2127 PRINT_D(GENERIC_DBG, "Remaining on channel %d\n", chan->hw_value);
2130 if (wdev->iftype == NL80211_IFTYPE_AP) {
2131 PRINT_D(GENERIC_DBG, "Required remain-on-channel while in AP mode");
2135 curr_channel = chan->hw_value;
2137 /*Setting params needed by WILC_WFI_RemainOnChannelExpired()*/
2138 priv->strRemainOnChanParams.pstrListenChan = chan;
2139 priv->strRemainOnChanParams.u64ListenCookie = *cookie;
2140 priv->strRemainOnChanParams.u32ListenDuration = duration;
2141 priv->strRemainOnChanParams.u32ListenSessionID++;
2143 s32Error = host_int_remain_on_channel(priv->hWILCWFIDrv
2144 , priv->strRemainOnChanParams.u32ListenSessionID
2147 , WILC_WFI_RemainOnChannelExpired
2148 , WILC_WFI_RemainOnChannelReady
2155 * @brief cancel_remain_on_channel
2156 * @details Cancel an on-going remain-on-channel operation.
2157 * This allows the operation to be terminated prior to timeout based on
2158 * the duration value.
2159 * @param[in] struct wiphy *wiphy,
2160 * @param[in] struct net_device *dev
2161 * @param[in] u64 cookie,
2162 * @return int : Return 0 on Success
2167 static int cancel_remain_on_channel(struct wiphy *wiphy,
2168 struct wireless_dev *wdev,
2172 struct wilc_priv *priv;
2174 priv = wiphy_priv(wiphy);
2176 PRINT_D(CFG80211_DBG, "Cancel remain on channel\n");
2178 s32Error = host_int_ListenStateExpired(priv->hWILCWFIDrv, priv->strRemainOnChanParams.u32ListenSessionID);
2182 * @brief WILC_WFI_mgmt_tx_frame
2191 extern bool bEnablePS;
2192 static int mgmt_tx(struct wiphy *wiphy,
2193 struct wireless_dev *wdev,
2194 struct cfg80211_mgmt_tx_params *params,
2197 struct ieee80211_channel *chan = params->chan;
2198 unsigned int wait = params->wait;
2199 const u8 *buf = params->buf;
2200 size_t len = params->len;
2201 const struct ieee80211_mgmt *mgmt;
2202 struct p2p_mgmt_data *mgmt_tx;
2203 struct wilc_priv *priv;
2204 struct host_if_drv *pstrWFIDrv;
2206 perInterface_wlan_t *nic;
2207 u32 buf_len = len + sizeof(u8P2P_vendorspec) + sizeof(u8P2Plocalrandom);
2209 nic = netdev_priv(wdev->netdev);
2210 priv = wiphy_priv(wiphy);
2211 pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
2213 *cookie = (unsigned long)buf;
2214 priv->u64tx_cookie = *cookie;
2215 mgmt = (const struct ieee80211_mgmt *) buf;
2217 if (ieee80211_is_mgmt(mgmt->frame_control)) {
2219 /*mgmt frame allocation*/
2220 mgmt_tx = kmalloc(sizeof(struct p2p_mgmt_data), GFP_KERNEL);
2221 if (mgmt_tx == NULL) {
2222 PRINT_ER("Failed to allocate memory for mgmt_tx structure\n");
2225 mgmt_tx->buff = kmalloc(buf_len, GFP_KERNEL);
2226 if (mgmt_tx->buff == NULL) {
2227 PRINT_ER("Failed to allocate memory for mgmt_tx buff\n");
2231 memcpy(mgmt_tx->buff, buf, len);
2232 mgmt_tx->size = len;
2235 if (ieee80211_is_probe_resp(mgmt->frame_control)) {
2236 PRINT_D(GENERIC_DBG, "TX: Probe Response\n");
2237 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2238 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2239 /*Save the current channel after we tune to it*/
2240 curr_channel = chan->hw_value;
2241 } else if (ieee80211_is_action(mgmt->frame_control)) {
2242 PRINT_D(GENERIC_DBG, "ACTION FRAME:%x\n", (u16)mgmt->frame_control);
2245 if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
2246 /*Only set the channel, if not a negotiation confirmation frame
2247 * (If Negotiation confirmation frame, force it
2248 * to be transmitted on the same negotiation channel)*/
2250 if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC ||
2251 buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) {
2252 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2253 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2254 /*Save the current channel after we tune to it*/
2255 curr_channel = chan->hw_value;
2257 switch (buf[ACTION_SUBTYPE_ID]) {
2258 case GAS_INTIAL_REQ:
2260 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buf[ACTION_SUBTYPE_ID]);
2264 case GAS_INTIAL_RSP:
2266 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buf[ACTION_SUBTYPE_ID]);
2270 case PUBLIC_ACT_VENDORSPEC:
2272 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2273 * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/
2274 if (!memcmp(u8P2P_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) {
2275 /*For the connection of two WILC's connection generate a rand number to determine who will be a GO*/
2276 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
2277 if (u8P2Plocalrandom == 1 && u8P2Precvrandom < u8P2Plocalrandom) {
2278 get_random_bytes(&u8P2Plocalrandom, 1);
2279 /*Increment the number to prevent if its 0*/
2284 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
2285 || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
2286 if (u8P2Plocalrandom > u8P2Precvrandom) {
2287 PRINT_D(GENERIC_DBG, "LOCAL WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2289 /*Search for the p2p information information element , after the Public action subtype theres a byte for teh dialog token, skip that*/
2290 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) {
2291 if (buf[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buf[i + 2], 4))) {
2292 if (buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)
2293 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), true, nic->iftype);
2295 /*If using supplicant go intent, no need at all*/
2296 /*to parse transmitted negotiation frames*/
2298 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), false, nic->iftype);
2303 if (buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_REQ && buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_RSP) {
2305 * Adding WILC information element to allow two WILC devices to
2306 * identify each other and connect
2308 memcpy(&mgmt_tx->buff[len], u8P2P_vendorspec, sizeof(u8P2P_vendorspec));
2309 mgmt_tx->buff[len + sizeof(u8P2P_vendorspec)] = u8P2Plocalrandom;
2310 mgmt_tx->size = buf_len;
2313 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2317 PRINT_D(GENERIC_DBG, "Not a P2P public action frame\n");
2325 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf[ACTION_SUBTYPE_ID]);
2332 PRINT_D(GENERIC_DBG, "TX: ACTION FRAME Type:%x : Chan:%d\n", buf[ACTION_SUBTYPE_ID], chan->hw_value);
2333 pstrWFIDrv->u64P2p_MgmtTimeout = (jiffies + msecs_to_jiffies(wait));
2335 PRINT_D(GENERIC_DBG, "Current Jiffies: %lu Timeout:%llu\n", jiffies, pstrWFIDrv->u64P2p_MgmtTimeout);
2339 wilc_wlan_txq_add_mgmt_pkt(mgmt_tx, mgmt_tx->buff,
2341 WILC_WFI_mgmt_tx_complete);
2343 PRINT_D(GENERIC_DBG, "This function transmits only management frames\n");
2348 static int mgmt_tx_cancel_wait(struct wiphy *wiphy,
2349 struct wireless_dev *wdev,
2352 struct wilc_priv *priv;
2353 struct host_if_drv *pstrWFIDrv;
2355 priv = wiphy_priv(wiphy);
2356 pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
2359 PRINT_D(GENERIC_DBG, "Tx Cancel wait :%lu\n", jiffies);
2360 pstrWFIDrv->u64P2p_MgmtTimeout = jiffies;
2362 if (!priv->bInP2PlistenState) {
2363 cfg80211_remain_on_channel_expired(priv->wdev,
2364 priv->strRemainOnChanParams.u64ListenCookie,
2365 priv->strRemainOnChanParams.pstrListenChan,
2373 * @brief wilc_mgmt_frame_register
2374 * @details Notify driver that a management frame type was
2375 * registered. Note that this callback may not sleep, and cannot run
2376 * concurrently with itself.
2383 void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev,
2384 u16 frame_type, bool reg)
2387 struct wilc_priv *priv;
2388 perInterface_wlan_t *nic;
2391 priv = wiphy_priv(wiphy);
2392 nic = netdev_priv(priv->wdev->netdev);
2398 PRINT_D(GENERIC_DBG, "Frame registering Frame Type: %x: Boolean: %d\n", frame_type, reg);
2399 switch (frame_type) {
2402 nic->g_struct_frame_reg[0].frame_type = frame_type;
2403 nic->g_struct_frame_reg[0].reg = reg;
2409 nic->g_struct_frame_reg[1].frame_type = frame_type;
2410 nic->g_struct_frame_reg[1].reg = reg;
2420 /*If mac is closed, then return*/
2421 if (!wl->initialized) {
2422 PRINT_D(GENERIC_DBG, "Return since mac is closed\n");
2425 host_int_frame_register(priv->hWILCWFIDrv, frame_type, reg);
2431 * @brief set_cqm_rssi_config
2432 * @details Configure connection quality monitor RSSI threshold.
2433 * @param[in] struct wiphy *wiphy:
2434 * @param[in] struct net_device *dev:
2435 * @param[in] s32 rssi_thold:
2436 * @param[in] u32 rssi_hyst:
2437 * @return int : Return 0 on Success
2442 static int set_cqm_rssi_config(struct wiphy *wiphy, struct net_device *dev,
2443 s32 rssi_thold, u32 rssi_hyst)
2445 PRINT_D(CFG80211_DBG, "Setting CQM RSSi Function\n");
2450 * @brief dump_station
2451 * @details Configure connection quality monitor RSSI threshold.
2452 * @param[in] struct wiphy *wiphy:
2453 * @param[in] struct net_device *dev
2454 * @param[in] int idx
2455 * @param[in] u8 *mac
2456 * @param[in] struct station_info *sinfo
2457 * @return int : Return 0 on Success
2462 static int dump_station(struct wiphy *wiphy, struct net_device *dev,
2463 int idx, u8 *mac, struct station_info *sinfo)
2465 struct wilc_priv *priv;
2467 PRINT_D(CFG80211_DBG, "Dumping station information\n");
2472 priv = wiphy_priv(wiphy);
2474 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
2476 host_int_get_rssi(priv->hWILCWFIDrv, &(sinfo->signal));
2484 * @brief set_power_mgmt
2487 * @return int : Return 0 on Success.
2492 static int set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2493 bool enabled, int timeout)
2495 struct wilc_priv *priv;
2497 PRINT_D(CFG80211_DBG, " Power save Enabled= %d , TimeOut = %d\n", enabled, timeout);
2502 priv = wiphy_priv(wiphy);
2503 if (priv->hWILCWFIDrv == NULL) {
2504 PRINT_ER("Driver is NULL\n");
2509 host_int_set_power_mgmt(priv->hWILCWFIDrv, enabled, timeout);
2517 * @brief change_virtual_intf
2518 * @details Change type/configuration of virtual interface,
2519 * keep the struct wireless_dev's iftype updated.
2521 * @return int : Return 0 on Success.
2526 int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic);
2528 static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
2529 enum nl80211_iftype type, u32 *flags, struct vif_params *params)
2531 struct wilc_priv *priv;
2532 perInterface_wlan_t *nic;
2538 nic = netdev_priv(dev);
2539 priv = wiphy_priv(wiphy);
2542 PRINT_D(HOSTAPD_DBG, "In Change virtual interface function\n");
2543 PRINT_D(HOSTAPD_DBG, "Wireless interface name =%s\n", dev->name);
2544 u8P2Plocalrandom = 0x01;
2545 u8P2Precvrandom = 0x00;
2549 g_obtainingIP = false;
2550 del_timer(&hDuringIpTimer);
2551 PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n");
2552 /*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to CE H/W*/
2553 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2554 Set_machw_change_vir_if(dev, true);
2558 case NL80211_IFTYPE_STATION:
2560 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_STATION\n");
2562 /* send delba over wlan interface */
2565 dev->ieee80211_ptr->iftype = type;
2566 priv->wdev->iftype = type;
2567 nic->monitor_flag = 0;
2568 nic->iftype = STATION_MODE;
2570 /*Remove the enteries of the previously connected clients*/
2571 memset(priv->assoc_stainfo.au8Sta_AssociatedBss, 0, MAX_NUM_STA * ETH_ALEN);
2572 interface_type = nic->iftype;
2573 nic->iftype = STATION_MODE;
2575 if (wl->initialized) {
2576 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv,
2577 wl->vif[0].bssid, TID);
2578 /* ensure that the message Q is empty */
2579 host_int_wait_msg_queue_idle();
2581 /*Eliminate host interface blocking state*/
2584 wilc1000_wlan_deinit(dev);
2585 wilc1000_wlan_init(dev, nic);
2586 g_wilc_initialized = 1;
2587 nic->iftype = interface_type;
2589 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
2590 host_int_set_wfi_drv_handler(wl->vif[0].hif_drv);
2591 host_int_set_MacAddress(wl->vif[0].hif_drv,
2592 wl->vif[0].src_addr);
2593 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2595 /*Add saved WEP keys, if any*/
2596 if (g_wep_keys_saved) {
2597 host_int_set_wep_default_key(wl->vif[0].hif_drv,
2598 g_key_wep_params.key_idx);
2599 host_int_add_wep_key_bss_sta(wl->vif[0].hif_drv,
2600 g_key_wep_params.key,
2601 g_key_wep_params.key_len,
2602 g_key_wep_params.key_idx);
2605 /*No matter the driver handler passed here, it will be overwriiten*/
2606 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2607 host_int_flush_join_req(priv->hWILCWFIDrv);
2609 /*Add saved PTK and GTK keys, if any*/
2610 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2611 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
2612 g_key_ptk_params.key[1],
2613 g_key_ptk_params.key[2]);
2614 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
2615 g_key_gtk_params.key[1],
2616 g_key_gtk_params.key[2]);
2617 add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
2619 g_add_ptk_key_params.key_idx,
2620 g_add_ptk_key_params.pairwise,
2621 g_add_ptk_key_params.mac_addr,
2622 (struct key_params *)(&g_key_ptk_params));
2624 add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
2626 g_add_gtk_key_params.key_idx,
2627 g_add_gtk_key_params.pairwise,
2628 g_add_gtk_key_params.mac_addr,
2629 (struct key_params *)(&g_key_gtk_params));
2632 if (wl->initialized) {
2633 for (i = 0; i < num_reg_frame; i++) {
2634 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2635 nic->g_struct_frame_reg[i].reg);
2636 host_int_frame_register(priv->hWILCWFIDrv,
2637 nic->g_struct_frame_reg[i].frame_type,
2638 nic->g_struct_frame_reg[i].reg);
2643 host_int_set_power_mgmt(priv->hWILCWFIDrv, 1, 0);
2647 case NL80211_IFTYPE_P2P_CLIENT:
2649 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
2651 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n");
2653 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv,
2654 wl->vif[0].bssid, TID);
2656 dev->ieee80211_ptr->iftype = type;
2657 priv->wdev->iftype = type;
2658 nic->monitor_flag = 0;
2660 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
2661 nic->iftype = CLIENT_MODE;
2664 if (wl->initialized) {
2665 /* ensure that the message Q is empty */
2666 host_int_wait_msg_queue_idle();
2668 wilc1000_wlan_deinit(dev);
2669 wilc1000_wlan_init(dev, nic);
2670 g_wilc_initialized = 1;
2672 host_int_set_wfi_drv_handler(wl->vif[0].hif_drv);
2673 host_int_set_MacAddress(wl->vif[0].hif_drv,
2674 wl->vif[0].src_addr);
2675 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2677 /*Add saved WEP keys, if any*/
2678 if (g_wep_keys_saved) {
2679 host_int_set_wep_default_key(wl->vif[0].hif_drv,
2680 g_key_wep_params.key_idx);
2681 host_int_add_wep_key_bss_sta(wl->vif[0].hif_drv,
2682 g_key_wep_params.key,
2683 g_key_wep_params.key_len,
2684 g_key_wep_params.key_idx);
2687 /*No matter the driver handler passed here, it will be overwriiten*/
2688 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2689 host_int_flush_join_req(priv->hWILCWFIDrv);
2691 /*Add saved PTK and GTK keys, if any*/
2692 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2693 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
2694 g_key_ptk_params.key[1],
2695 g_key_ptk_params.key[2]);
2696 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
2697 g_key_gtk_params.key[1],
2698 g_key_gtk_params.key[2]);
2699 add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
2701 g_add_ptk_key_params.key_idx,
2702 g_add_ptk_key_params.pairwise,
2703 g_add_ptk_key_params.mac_addr,
2704 (struct key_params *)(&g_key_ptk_params));
2706 add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
2708 g_add_gtk_key_params.key_idx,
2709 g_add_gtk_key_params.pairwise,
2710 g_add_gtk_key_params.mac_addr,
2711 (struct key_params *)(&g_key_gtk_params));
2714 /*Refresh scan, to refresh the scan results to the wpa_supplicant. Set MachHw to false to enable further key installments*/
2715 refresh_scan(priv, 1, true);
2716 Set_machw_change_vir_if(dev, false);
2718 if (wl->initialized) {
2719 for (i = 0; i < num_reg_frame; i++) {
2720 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2721 nic->g_struct_frame_reg[i].reg);
2722 host_int_frame_register(priv->hWILCWFIDrv,
2723 nic->g_struct_frame_reg[i].frame_type,
2724 nic->g_struct_frame_reg[i].reg);
2730 case NL80211_IFTYPE_AP:
2732 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_AP %d\n", type);
2733 dev->ieee80211_ptr->iftype = type;
2734 priv->wdev->iftype = type;
2735 nic->iftype = AP_MODE;
2736 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
2738 PRINT_D(HOSTAPD_DBG, "Downloading AP firmware\n");
2739 linux_wlan_get_firmware(nic);
2740 /*If wilc is running, then close-open to actually get new firmware running (serves P2P)*/
2741 if (wl->initialized) {
2742 nic->iftype = AP_MODE;
2746 for (i = 0; i < num_reg_frame; i++) {
2747 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2748 nic->g_struct_frame_reg[i].reg);
2749 host_int_frame_register(priv->hWILCWFIDrv,
2750 nic->g_struct_frame_reg[i].frame_type,
2751 nic->g_struct_frame_reg[i].reg);
2756 case NL80211_IFTYPE_P2P_GO:
2757 PRINT_D(GENERIC_DBG, "start duringIP timer\n");
2759 g_obtainingIP = true;
2760 mod_timer(&hDuringIpTimer, jiffies + msecs_to_jiffies(duringIP_TIME));
2761 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
2762 /*Delete block ack has to be the latest config packet*/
2763 /*sent before downloading new FW. This is because it blocks on*/
2764 /*hWaitResponse semaphore, which allows previous config*/
2765 /*packets to actually take action on old FW*/
2766 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv,
2767 wl->vif[0].bssid, TID);
2769 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n");
2770 dev->ieee80211_ptr->iftype = type;
2771 priv->wdev->iftype = type;
2773 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
2775 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
2778 nic->iftype = GO_MODE;
2780 /* ensure that the message Q is empty */
2781 host_int_wait_msg_queue_idle();
2782 wilc1000_wlan_deinit(dev);
2783 wilc1000_wlan_init(dev, nic);
2784 g_wilc_initialized = 1;
2787 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
2788 host_int_set_wfi_drv_handler(wl->vif[0].hif_drv);
2789 host_int_set_MacAddress(wl->vif[0].hif_drv,
2790 wl->vif[0].src_addr);
2791 host_int_set_operation_mode(priv->hWILCWFIDrv, AP_MODE);
2793 /*Add saved WEP keys, if any*/
2794 if (g_wep_keys_saved) {
2795 host_int_set_wep_default_key(wl->vif[0].hif_drv,
2796 g_key_wep_params.key_idx);
2797 host_int_add_wep_key_bss_sta(wl->vif[0].hif_drv,
2798 g_key_wep_params.key,
2799 g_key_wep_params.key_len,
2800 g_key_wep_params.key_idx);
2803 /*No matter the driver handler passed here, it will be overwriiten*/
2804 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2805 host_int_flush_join_req(priv->hWILCWFIDrv);
2807 /*Add saved PTK and GTK keys, if any*/
2808 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2809 PRINT_D(CFG80211_DBG, "ptk %x %x %x cipher %x\n", g_key_ptk_params.key[0],
2810 g_key_ptk_params.key[1],
2811 g_key_ptk_params.key[2],
2812 g_key_ptk_params.cipher);
2813 PRINT_D(CFG80211_DBG, "gtk %x %x %x cipher %x\n", g_key_gtk_params.key[0],
2814 g_key_gtk_params.key[1],
2815 g_key_gtk_params.key[2],
2816 g_key_gtk_params.cipher);
2817 add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
2819 g_add_ptk_key_params.key_idx,
2820 g_add_ptk_key_params.pairwise,
2821 g_add_ptk_key_params.mac_addr,
2822 (struct key_params *)(&g_key_ptk_params));
2824 add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
2826 g_add_gtk_key_params.key_idx,
2827 g_add_gtk_key_params.pairwise,
2828 g_add_gtk_key_params.mac_addr,
2829 (struct key_params *)(&g_key_gtk_params));
2832 if (wl->initialized) {
2833 for (i = 0; i < num_reg_frame; i++) {
2834 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2835 nic->g_struct_frame_reg[i].reg);
2836 host_int_frame_register(priv->hWILCWFIDrv,
2837 nic->g_struct_frame_reg[i].frame_type,
2838 nic->g_struct_frame_reg[i].reg);
2844 PRINT_ER("Unknown interface type= %d\n", type);
2851 /* (austin.2013-07-23)
2853 * To support revised cfg80211_ops
2855 * add_beacon --> start_ap
2856 * set_beacon --> change_beacon
2857 * del_beacon --> stop_ap
2859 * beacon_parameters --> cfg80211_ap_settings
2860 * cfg80211_beacon_data
2862 * applicable for linux kernel 3.4+
2867 * @details Add a beacon with given parameters, @head, @interval
2868 * and @dtim_period will be valid, @tail is optional.
2870 * @param[in] dev The net device structure
2871 * @param[in] settings cfg80211_ap_settings parameters for the beacon to be added
2872 * @return int : Return 0 on Success.
2877 static int start_ap(struct wiphy *wiphy, struct net_device *dev,
2878 struct cfg80211_ap_settings *settings)
2880 struct cfg80211_beacon_data *beacon = &(settings->beacon);
2881 struct wilc_priv *priv;
2884 perInterface_wlan_t *nic;
2886 priv = wiphy_priv(wiphy);
2887 nic = netdev_priv(dev);
2889 PRINT_D(HOSTAPD_DBG, "Starting ap\n");
2891 PRINT_D(HOSTAPD_DBG, "Interval = %d\n DTIM period = %d\n Head length = %zu Tail length = %zu\n",
2892 settings->beacon_interval, settings->dtim_period, beacon->head_len, beacon->tail_len);
2894 s32Error = set_channel(wiphy, &settings->chandef);
2897 PRINT_ER("Error in setting channel\n");
2899 linux_wlan_set_bssid(dev, wl->vif[0].src_addr);
2901 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
2902 settings->beacon_interval,
2903 settings->dtim_period,
2904 beacon->head_len, (u8 *)beacon->head,
2905 beacon->tail_len, (u8 *)beacon->tail);
2911 * @brief change_beacon
2912 * @details Add a beacon with given parameters, @head, @interval
2913 * and @dtim_period will be valid, @tail is optional.
2915 * @param[in] dev The net device structure
2916 * @param[in] beacon cfg80211_beacon_data for the beacon to be changed
2917 * @return int : Return 0 on Success.
2922 static int change_beacon(struct wiphy *wiphy, struct net_device *dev,
2923 struct cfg80211_beacon_data *beacon)
2925 struct wilc_priv *priv;
2928 priv = wiphy_priv(wiphy);
2929 PRINT_D(HOSTAPD_DBG, "Setting beacon\n");
2932 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
2935 beacon->head_len, (u8 *)beacon->head,
2936 beacon->tail_len, (u8 *)beacon->tail);
2943 * @details Remove beacon configuration and stop sending the beacon.
2945 * @return int : Return 0 on Success.
2950 static int stop_ap(struct wiphy *wiphy, struct net_device *dev)
2953 struct wilc_priv *priv;
2954 u8 NullBssid[ETH_ALEN] = {0};
2959 priv = wiphy_priv(wiphy);
2961 PRINT_D(HOSTAPD_DBG, "Deleting beacon\n");
2963 linux_wlan_set_bssid(dev, NullBssid);
2965 s32Error = host_int_del_beacon(priv->hWILCWFIDrv);
2968 PRINT_ER("Host delete beacon fail\n");
2974 * @brief add_station
2975 * @details Add a new station.
2977 * @return int : Return 0 on Success.
2982 static int add_station(struct wiphy *wiphy, struct net_device *dev,
2983 const u8 *mac, struct station_parameters *params)
2986 struct wilc_priv *priv;
2987 struct add_sta_param strStaParams = { {0} };
2988 perInterface_wlan_t *nic;
2993 priv = wiphy_priv(wiphy);
2994 nic = netdev_priv(dev);
2996 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
2997 memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
2998 memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN);
2999 strStaParams.u16AssocID = params->aid;
3000 strStaParams.u8NumRates = params->supported_rates_len;
3001 strStaParams.pu8Rates = params->supported_rates;
3003 PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid);
3005 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],
3006 priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]);
3007 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3008 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3010 if (params->ht_capa == NULL) {
3011 strStaParams.bIsHTSupported = false;
3013 strStaParams.bIsHTSupported = true;
3014 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3015 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
3016 memcpy(strStaParams.au8SuppMCsSet, ¶ms->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
3017 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3018 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3019 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3022 strStaParams.u16FlagsMask = params->sta_flags_mask;
3023 strStaParams.u16FlagsSet = params->sta_flags_set;
3025 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3026 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3027 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3028 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3029 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3030 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3031 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3032 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3034 s32Error = host_int_add_station(priv->hWILCWFIDrv, &strStaParams);
3036 PRINT_ER("Host add station fail\n");
3043 * @brief del_station
3044 * @details Remove a station; @mac may be NULL to remove all stations.
3046 * @return int : Return 0 on Success.
3051 static int del_station(struct wiphy *wiphy, struct net_device *dev,
3052 struct station_del_parameters *params)
3054 const u8 *mac = params->mac;
3056 struct wilc_priv *priv;
3057 perInterface_wlan_t *nic;
3062 priv = wiphy_priv(wiphy);
3063 nic = netdev_priv(dev);
3065 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3066 PRINT_D(HOSTAPD_DBG, "Deleting station\n");
3070 PRINT_D(HOSTAPD_DBG, "All associated stations\n");
3071 s32Error = host_int_del_allstation(priv->hWILCWFIDrv, priv->assoc_stainfo.au8Sta_AssociatedBss);
3073 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]);
3076 s32Error = host_int_del_station(priv->hWILCWFIDrv, mac);
3079 PRINT_ER("Host delete station fail\n");
3085 * @brief change_station
3086 * @details Modify a given station.
3088 * @return int : Return 0 on Success.
3093 static int change_station(struct wiphy *wiphy, struct net_device *dev,
3094 const u8 *mac, struct station_parameters *params)
3097 struct wilc_priv *priv;
3098 struct add_sta_param strStaParams = { {0} };
3099 perInterface_wlan_t *nic;
3102 PRINT_D(HOSTAPD_DBG, "Change station paramters\n");
3107 priv = wiphy_priv(wiphy);
3108 nic = netdev_priv(dev);
3110 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3111 memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
3112 strStaParams.u16AssocID = params->aid;
3113 strStaParams.u8NumRates = params->supported_rates_len;
3114 strStaParams.pu8Rates = params->supported_rates;
3116 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],
3117 strStaParams.au8BSSID[5]);
3118 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3119 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3121 if (params->ht_capa == NULL) {
3122 strStaParams.bIsHTSupported = false;
3124 strStaParams.bIsHTSupported = true;
3125 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3126 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
3127 memcpy(strStaParams.au8SuppMCsSet, ¶ms->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
3128 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3129 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3130 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3134 strStaParams.u16FlagsMask = params->sta_flags_mask;
3135 strStaParams.u16FlagsSet = params->sta_flags_set;
3137 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3138 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3139 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3140 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3141 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3142 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3143 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3144 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3146 s32Error = host_int_edit_station(priv->hWILCWFIDrv, &strStaParams);
3148 PRINT_ER("Host edit station fail\n");
3155 * @brief add_virtual_intf
3158 * @return int : Return 0 on Success.
3163 static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy,
3165 unsigned char name_assign_type,
3166 enum nl80211_iftype type,
3168 struct vif_params *params)
3170 perInterface_wlan_t *nic;
3171 struct wilc_priv *priv;
3172 struct net_device *new_ifc = NULL;
3174 priv = wiphy_priv(wiphy);
3178 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", priv->wdev->netdev);
3180 nic = netdev_priv(priv->wdev->netdev);
3183 if (type == NL80211_IFTYPE_MONITOR) {
3184 PRINT_D(HOSTAPD_DBG, "Monitor interface mode: Initializing mon interface virtual device driver\n");
3185 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", nic->wilc_netdev);
3186 new_ifc = WILC_WFI_init_mon_interface(name, nic->wilc_netdev);
3187 if (new_ifc != NULL) {
3188 PRINT_D(HOSTAPD_DBG, "Setting monitor flag in private structure\n");
3189 nic = netdev_priv(priv->wdev->netdev);
3190 nic->monitor_flag = 1;
3192 PRINT_ER("Error in initializing monitor interface\n ");
3198 * @brief del_virtual_intf
3201 * @return int : Return 0 on Success.
3206 static int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev)
3208 PRINT_D(HOSTAPD_DBG, "Deleting virtual interface\n");
3212 static struct cfg80211_ops wilc_cfg80211_ops = {
3214 .set_monitor_channel = set_channel,
3217 .disconnect = disconnect,
3221 .set_default_key = set_default_key,
3222 .add_virtual_intf = add_virtual_intf,
3223 .del_virtual_intf = del_virtual_intf,
3224 .change_virtual_intf = change_virtual_intf,
3226 .start_ap = start_ap,
3227 .change_beacon = change_beacon,
3229 .add_station = add_station,
3230 .del_station = del_station,
3231 .change_station = change_station,
3232 .get_station = get_station,
3233 .dump_station = dump_station,
3234 .change_bss = change_bss,
3235 .set_wiphy_params = set_wiphy_params,
3237 .set_pmksa = set_pmksa,
3238 .del_pmksa = del_pmksa,
3239 .flush_pmksa = flush_pmksa,
3240 .remain_on_channel = remain_on_channel,
3241 .cancel_remain_on_channel = cancel_remain_on_channel,
3242 .mgmt_tx_cancel_wait = mgmt_tx_cancel_wait,
3244 .mgmt_frame_register = wilc_mgmt_frame_register,
3245 .set_power_mgmt = set_power_mgmt,
3246 .set_cqm_rssi_config = set_cqm_rssi_config,
3255 * @brief WILC_WFI_update_stats
3256 * @details Modify parameters for a given BSS.
3258 * @return int : Return 0 on Success.
3263 int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed)
3266 struct wilc_priv *priv;
3268 priv = wiphy_priv(wiphy);
3271 case WILC_WFI_RX_PKT:
3273 priv->netstats.rx_packets++;
3274 priv->netstats.rx_bytes += pktlen;
3275 priv->netstats.rx_time = get_jiffies_64();
3279 case WILC_WFI_TX_PKT:
3281 priv->netstats.tx_packets++;
3282 priv->netstats.tx_bytes += pktlen;
3283 priv->netstats.tx_time = get_jiffies_64();
3295 * @brief WILC_WFI_CfgAlloc
3296 * @details Allocation of the wireless device structure and assigning it
3297 * to the cfg80211 operations structure.
3299 * @return wireless_dev : Returns pointer to wireless_dev structure.
3304 struct wireless_dev *WILC_WFI_CfgAlloc(void)
3307 struct wireless_dev *wdev;
3310 PRINT_D(CFG80211_DBG, "Allocating wireless device\n");
3311 /*Allocating the wireless device structure*/
3312 wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
3314 PRINT_ER("Cannot allocate wireless device\n");
3318 /*Creating a new wiphy, linking wireless structure with the wiphy structure*/
3319 wdev->wiphy = wiphy_new(&wilc_cfg80211_ops, sizeof(struct wilc_priv));
3321 PRINT_ER("Cannot allocate wiphy\n");
3326 /* enable 802.11n HT */
3327 WILC_WFI_band_2ghz.ht_cap.ht_supported = 1;
3328 WILC_WFI_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT);
3329 WILC_WFI_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff;
3330 WILC_WFI_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K;
3331 WILC_WFI_band_2ghz.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE;
3334 wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &WILC_WFI_band_2ghz;
3345 * @brief wilc_create_wiphy
3346 * @details Registering of the wiphy structure and interface modes
3353 struct wireless_dev *wilc_create_wiphy(struct net_device *net)
3355 struct wilc_priv *priv;
3356 struct wireless_dev *wdev;
3359 PRINT_D(CFG80211_DBG, "Registering wifi device\n");
3361 wdev = WILC_WFI_CfgAlloc();
3363 PRINT_ER("CfgAlloc Failed\n");
3368 /*Return hardware description structure (wiphy)'s priv*/
3369 priv = wdev_priv(wdev);
3370 sema_init(&(priv->SemHandleUpdateStats), 1);
3372 /*Link the wiphy with wireless structure*/
3375 /*Maximum number of probed ssid to be added by user for the scan request*/
3376 wdev->wiphy->max_scan_ssids = MAX_NUM_PROBED_SSID;
3377 /*Maximum number of pmkids to be cashed*/
3378 wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS;
3379 PRINT_INFO(CFG80211_DBG, "Max number of PMKIDs = %d\n", wdev->wiphy->max_num_pmkids);
3381 wdev->wiphy->max_scan_ie_len = 1000;
3383 /*signal strength in mBm (100*dBm) */
3384 wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
3386 /*Set the availaible cipher suites*/
3387 wdev->wiphy->cipher_suites = cipher_suites;
3388 wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
3389 /*Setting default managment types: for register action frame: */
3390 wdev->wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types;
3392 wdev->wiphy->max_remain_on_channel_duration = 500;
3393 /*Setting the wiphy interfcae mode and type before registering the wiphy*/
3394 wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | BIT(NL80211_IFTYPE_P2P_GO) |
3395 BIT(NL80211_IFTYPE_P2P_CLIENT);
3396 wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
3397 wdev->iftype = NL80211_IFTYPE_STATION;
3401 PRINT_INFO(CFG80211_DBG, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n",
3402 wdev->wiphy->max_scan_ssids, wdev->wiphy->max_scan_ie_len, wdev->wiphy->signal_type,
3403 wdev->wiphy->interface_modes, wdev->iftype);
3406 set_wiphy_dev(wdev->wiphy, &local_sdio_func->dev);
3409 /*Register wiphy structure*/
3410 s32Error = wiphy_register(wdev->wiphy);
3412 PRINT_ER("Cannot register wiphy device\n");
3413 /*should define what action to be taken in such failure*/
3415 PRINT_D(CFG80211_DBG, "Successful Registering\n");
3424 * @brief WILC_WFI_WiphyFree
3425 * @details Freeing allocation of the wireless device structure
3432 int wilc_init_host_int(struct net_device *net)
3437 struct wilc_priv *priv;
3439 PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr);
3440 priv = wdev_priv(net->ieee80211_ptr);
3442 setup_timer(&hAgingTimer, remove_network_from_shadow, 0);
3443 setup_timer(&hDuringIpTimer, clear_duringIP, 0);
3447 PRINT_ER("Failed to creat refresh Timer\n");
3451 priv->gbAutoRateAdjusted = false;
3453 priv->bInP2PlistenState = false;
3455 sema_init(&(priv->hSemScanReq), 1);
3456 s32Error = host_int_init(net, &priv->hWILCWFIDrv);
3458 PRINT_ER("Error while initializing hostinterface\n");
3464 * @brief WILC_WFI_WiphyFree
3465 * @details Freeing allocation of the wireless device structure
3472 int wilc_deinit_host_int(struct net_device *net)
3476 struct wilc_priv *priv;
3478 priv = wdev_priv(net->ieee80211_ptr);
3480 priv->gbAutoRateAdjusted = false;
3482 priv->bInP2PlistenState = false;
3486 s32Error = host_int_deinit(priv->hWILCWFIDrv);
3488 /* Clear the Shadow scan */
3489 clear_shadow_scan(priv);
3491 PRINT_D(CORECONFIG_DBG, "destroy during ip\n");
3492 del_timer_sync(&hDuringIpTimer);
3496 PRINT_ER("Error while deintializing host interface\n");
3503 * @brief WILC_WFI_WiphyFree
3504 * @details Freeing allocation of the wireless device structure
3511 void wilc_free_wiphy(struct net_device *net)
3513 PRINT_D(CFG80211_DBG, "Unregistering wiphy\n");
3516 PRINT_D(INIT_DBG, "net_device is NULL\n");
3520 if (!net->ieee80211_ptr) {
3521 PRINT_D(INIT_DBG, "ieee80211_ptr is NULL\n");
3525 if (!net->ieee80211_ptr->wiphy) {
3526 PRINT_D(INIT_DBG, "wiphy is NULL\n");
3530 wiphy_unregister(net->ieee80211_ptr->wiphy);
3532 PRINT_D(INIT_DBG, "Freeing wiphy\n");
3533 wiphy_free(net->ieee80211_ptr->wiphy);
3534 kfree(net->ieee80211_ptr);