Merge 4.2-rc4 into staging-next
[deliverable/linux.git] / drivers / staging / wilc1000 / wilc_wfi_cfgoperations.c
1 /*!
2 * @file wilc_wfi_cfgopertaions.c
3 * @brief CFG80211 Function Implementation functionality
4 * @author aabouzaeid
5 * mabubakr
6 * mdaftedar
7 * zsalah
8 * @sa wilc_wfi_cfgopertaions.h top level OS wrapper file
9 * @date 31 Aug 2010
10 * @version 1.0
11 */
12
13 #include "wilc_wfi_cfgoperations.h"
14 #include "wilc_wlan.c"
15 #ifdef WILC_SDIO
16 #include "linux_wlan_sdio.h" /* tony : for set_wiphy_dev() */
17 #endif
18
19
20 #define IS_MANAGMEMENT 0x100
21 #define IS_MANAGMEMENT_CALLBACK 0x080
22 #define IS_MGMT_STATUS_SUCCES 0x040
23 #define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff)
24
25 extern void linux_wlan_free(void *vp);
26 extern int linux_wlan_get_firmware(perInterface_wlan_t *p_nic);
27 extern void linux_wlan_unlock(void *vp);
28 extern u16 Set_machw_change_vir_if(bool bValue);
29
30 extern int mac_open(struct net_device *ndev);
31 extern int mac_close(struct net_device *ndev);
32
33 tstrNetworkInfo astrLastScannedNtwrksShadow[MAX_NUM_SCANNED_NETWORKS_SHADOW];
34 u32 u32LastScannedNtwrksCountShadow;
35 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
36 WILC_TimerHandle hDuringIpTimer;
37 #endif
38 WILC_TimerHandle hAgingTimer;
39 static u8 op_ifcs;
40 extern u8 u8ConnectedSSID[6];
41
42 /*BugID_5137*/
43 u8 g_wilc_initialized = 1;
44 extern linux_wlan_t *g_linux_wlan;
45 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
46 extern bool g_obtainingIP;
47 #endif
48
49 #define CHAN2G(_channel, _freq, _flags) { \
50 .band = IEEE80211_BAND_2GHZ, \
51 .center_freq = (_freq), \
52 .hw_value = (_channel), \
53 .flags = (_flags), \
54 .max_antenna_gain = 0, \
55 .max_power = 30, \
56 }
57
58 /*Frequency range for channels*/
59 static struct ieee80211_channel WILC_WFI_2ghz_channels[] = {
60 CHAN2G(1, 2412, 0),
61 CHAN2G(2, 2417, 0),
62 CHAN2G(3, 2422, 0),
63 CHAN2G(4, 2427, 0),
64 CHAN2G(5, 2432, 0),
65 CHAN2G(6, 2437, 0),
66 CHAN2G(7, 2442, 0),
67 CHAN2G(8, 2447, 0),
68 CHAN2G(9, 2452, 0),
69 CHAN2G(10, 2457, 0),
70 CHAN2G(11, 2462, 0),
71 CHAN2G(12, 2467, 0),
72 CHAN2G(13, 2472, 0),
73 CHAN2G(14, 2484, 0),
74 };
75
76 #define RATETAB_ENT(_rate, _hw_value, _flags) { \
77 .bitrate = (_rate), \
78 .hw_value = (_hw_value), \
79 .flags = (_flags), \
80 }
81
82
83 /* Table 6 in section 3.2.1.1 */
84 static struct ieee80211_rate WILC_WFI_rates[] = {
85 RATETAB_ENT(10, 0, 0),
86 RATETAB_ENT(20, 1, 0),
87 RATETAB_ENT(55, 2, 0),
88 RATETAB_ENT(110, 3, 0),
89 RATETAB_ENT(60, 9, 0),
90 RATETAB_ENT(90, 6, 0),
91 RATETAB_ENT(120, 7, 0),
92 RATETAB_ENT(180, 8, 0),
93 RATETAB_ENT(240, 9, 0),
94 RATETAB_ENT(360, 10, 0),
95 RATETAB_ENT(480, 11, 0),
96 RATETAB_ENT(540, 12, 0),
97 };
98
99 #ifdef WILC_P2P
100 struct p2p_mgmt_data {
101 int size;
102 u8 *buff;
103 };
104
105 /*Global variable used to state the current connected STA channel*/
106 u8 u8WLANChannel = INVALID_CHANNEL;
107
108 /*BugID_5442*/
109 u8 u8CurrChannel;
110
111 u8 u8P2P_oui[] = {0x50, 0x6f, 0x9A, 0x09};
112 u8 u8P2Plocalrandom = 0x01;
113 u8 u8P2Precvrandom = 0x00;
114 u8 u8P2P_vendorspec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};
115 bool bWilc_ie = false;
116 #endif
117
118 static struct ieee80211_supported_band WILC_WFI_band_2ghz = {
119 .channels = WILC_WFI_2ghz_channels,
120 .n_channels = ARRAY_SIZE(WILC_WFI_2ghz_channels),
121 .bitrates = WILC_WFI_rates,
122 .n_bitrates = ARRAY_SIZE(WILC_WFI_rates),
123 };
124
125
126 /*BugID_5137*/
127 struct add_key_params {
128 u8 key_idx;
129 bool pairwise;
130 u8 *mac_addr;
131 };
132 struct add_key_params g_add_gtk_key_params;
133 struct wilc_wfi_key g_key_gtk_params;
134 struct add_key_params g_add_ptk_key_params;
135 struct wilc_wfi_key g_key_ptk_params;
136 struct wilc_wfi_wep_key g_key_wep_params;
137 u8 g_flushing_in_progress;
138 bool g_ptk_keys_saved = false;
139 bool g_gtk_keys_saved = false;
140 bool g_wep_keys_saved = false;
141
142 #define AGING_TIME (9 * 1000)
143 #define duringIP_TIME 15000
144
145 void clear_shadow_scan(void *pUserVoid)
146 {
147 int i;
148 if (op_ifcs == 0) {
149 WILC_TimerDestroy(&hAgingTimer, NULL);
150 PRINT_INFO(CORECONFIG_DBG, "destroy aging timer\n");
151
152 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
153 if (astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs != NULL) {
154 WILC_FREE(astrLastScannedNtwrksShadow[i].pu8IEs);
155 astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs = NULL;
156 }
157
158 host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
159 astrLastScannedNtwrksShadow[i].pJoinParams = NULL;
160 }
161 u32LastScannedNtwrksCountShadow = 0;
162 }
163
164 }
165
166 uint32_t get_rssi_avg(tstrNetworkInfo *pstrNetworkInfo)
167 {
168 uint8_t i;
169 int rssi_v = 0;
170 uint8_t num_rssi = (pstrNetworkInfo->strRssi.u8Full) ? NUM_RSSI : (pstrNetworkInfo->strRssi.u8Index);
171
172 for (i = 0; i < num_rssi; i++)
173 rssi_v += pstrNetworkInfo->strRssi.as8RSSI[i];
174
175 rssi_v /= num_rssi;
176 return rssi_v;
177 }
178
179 void refresh_scan(void *pUserVoid, uint8_t all, bool bDirectScan)
180 {
181 struct WILC_WFI_priv *priv;
182 struct wiphy *wiphy;
183 struct cfg80211_bss *bss = NULL;
184 int i;
185 int rssi = 0;
186
187 priv = (struct WILC_WFI_priv *)pUserVoid;
188 wiphy = priv->dev->ieee80211_ptr->wiphy;
189
190 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
191 tstrNetworkInfo *pstrNetworkInfo;
192 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
193
194
195 if ((!pstrNetworkInfo->u8Found) || all) {
196 s32 s32Freq;
197 struct ieee80211_channel *channel;
198
199 if (pstrNetworkInfo != NULL) {
200
201 s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
202 channel = ieee80211_get_channel(wiphy, s32Freq);
203
204 rssi = get_rssi_avg(pstrNetworkInfo);
205 if (WILC_memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7) || bDirectScan) {
206 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
207 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
208 (size_t)pstrNetworkInfo->u16IEsLen, (((s32)rssi) * 100), GFP_KERNEL);
209 cfg80211_put_bss(wiphy, bss);
210 }
211 }
212
213 }
214 }
215
216 }
217
218 void reset_shadow_found(void *pUserVoid)
219 {
220 int i;
221 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
222 astrLastScannedNtwrksShadow[i].u8Found = 0;
223
224 }
225 }
226
227 void update_scan_time(void *pUserVoid)
228 {
229 int i;
230 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
231 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
232 }
233 }
234
235 void remove_network_from_shadow(void *pUserVoid)
236 {
237 unsigned long now = jiffies;
238 int i, j;
239
240
241 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
242 if (time_after(now, astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan + (unsigned long)(SCAN_RESULT_EXPIRE))) {
243 PRINT_D(CFG80211_DBG, "Network expired in ScanShadow: %s \n", astrLastScannedNtwrksShadow[i].au8ssid);
244
245 if (astrLastScannedNtwrksShadow[i].pu8IEs != NULL) {
246 WILC_FREE(astrLastScannedNtwrksShadow[i].pu8IEs);
247 astrLastScannedNtwrksShadow[i].pu8IEs = NULL;
248 }
249
250 host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
251
252 for (j = i; (j < u32LastScannedNtwrksCountShadow - 1); j++) {
253 astrLastScannedNtwrksShadow[j] = astrLastScannedNtwrksShadow[j + 1];
254 }
255 u32LastScannedNtwrksCountShadow--;
256 }
257 }
258
259 PRINT_D(CFG80211_DBG, "Number of cached networks: %d\n", u32LastScannedNtwrksCountShadow);
260 if (u32LastScannedNtwrksCountShadow != 0)
261 WILC_TimerStart(&(hAgingTimer), AGING_TIME, pUserVoid, NULL);
262 else
263 PRINT_D(CFG80211_DBG, "No need to restart Aging timer\n");
264 }
265
266 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
267 void clear_duringIP(void *pUserVoid)
268 {
269 PRINT_D(GENERIC_DBG, "GO:IP Obtained , enable scan\n");
270 g_obtainingIP = false;
271 }
272 #endif
273
274 int8_t is_network_in_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid)
275 {
276 int8_t state = -1;
277 int i;
278
279 if (u32LastScannedNtwrksCountShadow == 0) {
280 PRINT_D(CFG80211_DBG, "Starting Aging timer\n");
281 WILC_TimerStart(&(hAgingTimer), AGING_TIME, pUserVoid, NULL);
282 state = -1;
283 } else {
284 /* Linear search for now */
285 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
286 if (WILC_memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
287 pstrNetworkInfo->au8bssid, 6) == 0) {
288 state = i;
289 break;
290 }
291 }
292 }
293 return state;
294 }
295
296 void add_network_to_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
297 {
298 int8_t ap_found = is_network_in_shadow(pstrNetworkInfo, pUserVoid);
299 uint32_t ap_index = 0;
300 uint8_t rssi_index = 0;
301
302 if (u32LastScannedNtwrksCountShadow >= MAX_NUM_SCANNED_NETWORKS_SHADOW) {
303 PRINT_D(CFG80211_DBG, "Shadow network reached its maximum limit\n");
304 return;
305 }
306 if (ap_found == -1) {
307 ap_index = u32LastScannedNtwrksCountShadow;
308 u32LastScannedNtwrksCountShadow++;
309
310 } else {
311 ap_index = ap_found;
312 }
313 rssi_index = astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index;
314 astrLastScannedNtwrksShadow[ap_index].strRssi.as8RSSI[rssi_index++] = pstrNetworkInfo->s8rssi;
315 if (rssi_index == NUM_RSSI) {
316 rssi_index = 0;
317 astrLastScannedNtwrksShadow[ap_index].strRssi.u8Full = 1;
318 }
319 astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index = rssi_index;
320
321 astrLastScannedNtwrksShadow[ap_index].s8rssi = pstrNetworkInfo->s8rssi;
322 astrLastScannedNtwrksShadow[ap_index].u16CapInfo = pstrNetworkInfo->u16CapInfo;
323
324 astrLastScannedNtwrksShadow[ap_index].u8SsidLen = pstrNetworkInfo->u8SsidLen;
325 WILC_memcpy(astrLastScannedNtwrksShadow[ap_index].au8ssid,
326 pstrNetworkInfo->au8ssid, pstrNetworkInfo->u8SsidLen);
327
328 WILC_memcpy(astrLastScannedNtwrksShadow[ap_index].au8bssid,
329 pstrNetworkInfo->au8bssid, ETH_ALEN);
330
331 astrLastScannedNtwrksShadow[ap_index].u16BeaconPeriod = pstrNetworkInfo->u16BeaconPeriod;
332 astrLastScannedNtwrksShadow[ap_index].u8DtimPeriod = pstrNetworkInfo->u8DtimPeriod;
333 astrLastScannedNtwrksShadow[ap_index].u8channel = pstrNetworkInfo->u8channel;
334
335 astrLastScannedNtwrksShadow[ap_index].u16IEsLen = pstrNetworkInfo->u16IEsLen;
336 astrLastScannedNtwrksShadow[ap_index].u64Tsf = pstrNetworkInfo->u64Tsf;
337 if (ap_found != -1)
338 WILC_FREE(astrLastScannedNtwrksShadow[ap_index].pu8IEs);
339 astrLastScannedNtwrksShadow[ap_index].pu8IEs =
340 (u8 *)WILC_MALLOC(pstrNetworkInfo->u16IEsLen); /* will be deallocated by the WILC_WFI_CfgScan() function */
341 WILC_memcpy(astrLastScannedNtwrksShadow[ap_index].pu8IEs,
342 pstrNetworkInfo->pu8IEs, pstrNetworkInfo->u16IEsLen);
343
344 astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScan = jiffies;
345 astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScanCached = jiffies;
346 astrLastScannedNtwrksShadow[ap_index].u8Found = 1;
347 if (ap_found != -1)
348 host_int_freeJoinParams(astrLastScannedNtwrksShadow[ap_index].pJoinParams);
349 astrLastScannedNtwrksShadow[ap_index].pJoinParams = pJoinParams;
350
351 }
352
353
354 /**
355 * @brief CfgScanResult
356 * @details Callback function which returns the scan results found
357 *
358 * @param[in] tenuScanEvent enuScanEvent: enum, indicating the scan event triggered, whether that is
359 * SCAN_EVENT_NETWORK_FOUND or SCAN_EVENT_DONE
360 * tstrNetworkInfo* pstrNetworkInfo: structure holding the scan results information
361 * void* pUserVoid: Private structure associated with the wireless interface
362 * @return NONE
363 * @author mabubakr
364 * @date
365 * @version 1.0
366 */
367 static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
368 {
369 struct WILC_WFI_priv *priv;
370 struct wiphy *wiphy;
371 s32 s32Freq;
372 struct ieee80211_channel *channel;
373 s32 s32Error = WILC_SUCCESS;
374 struct cfg80211_bss *bss = NULL;
375
376 priv = (struct WILC_WFI_priv *)pUserVoid;
377 if (priv->bCfgScanning == true) {
378 if (enuScanEvent == SCAN_EVENT_NETWORK_FOUND) {
379 wiphy = priv->dev->ieee80211_ptr->wiphy;
380 WILC_NULLCHECK(s32Error, wiphy);
381 if (wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC
382 &&
383 ((((s32)pstrNetworkInfo->s8rssi) * 100) < 0
384 ||
385 (((s32)pstrNetworkInfo->s8rssi) * 100) > 100)
386 ) {
387 WILC_ERRORREPORT(s32Error, WILC_FAIL);
388 }
389
390 if (pstrNetworkInfo != NULL) {
391 s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
392 channel = ieee80211_get_channel(wiphy, s32Freq);
393
394 WILC_NULLCHECK(s32Error, channel);
395
396 PRINT_INFO(CFG80211_DBG, "Network Info:: CHANNEL Frequency: %d, RSSI: %d, CapabilityInfo: %d,"
397 "BeaconPeriod: %d \n", channel->center_freq, (((s32)pstrNetworkInfo->s8rssi) * 100),
398 pstrNetworkInfo->u16CapInfo, pstrNetworkInfo->u16BeaconPeriod);
399
400 if (pstrNetworkInfo->bNewNetwork == true) {
401 if (priv->u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
402 /* max_scan_ssids */
403 PRINT_D(CFG80211_DBG, "Network %s found\n", pstrNetworkInfo->au8ssid);
404
405
406 priv->u32RcvdChCount++;
407
408
409
410 if (pJoinParams == NULL) {
411 PRINT_INFO(CORECONFIG_DBG, ">> Something really bad happened\n");
412 }
413 add_network_to_shadow(pstrNetworkInfo, priv, pJoinParams);
414
415 /*P2P peers are sent to WPA supplicant and added to shadow table*/
416
417 if (!(WILC_memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7))) {
418 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
419 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
420 (size_t)pstrNetworkInfo->u16IEsLen, (((s32)pstrNetworkInfo->s8rssi) * 100), GFP_KERNEL);
421 cfg80211_put_bss(wiphy, bss);
422 }
423
424
425 } else {
426 PRINT_ER("Discovered networks exceeded the max limit\n");
427 }
428 } else {
429 u32 i;
430 /* So this network is discovered before, we'll just update its RSSI */
431 for (i = 0; i < priv->u32RcvdChCount; i++) {
432 if (WILC_memcmp(astrLastScannedNtwrksShadow[i].au8bssid, pstrNetworkInfo->au8bssid, 6) == 0) {
433 PRINT_D(CFG80211_DBG, "Update RSSI of %s \n", astrLastScannedNtwrksShadow[i].au8ssid);
434
435 astrLastScannedNtwrksShadow[i].s8rssi = pstrNetworkInfo->s8rssi;
436 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
437 break;
438 }
439 }
440 }
441 }
442 } else if (enuScanEvent == SCAN_EVENT_DONE) {
443 PRINT_D(CFG80211_DBG, "Scan Done[%p] \n", priv->dev);
444 PRINT_D(CFG80211_DBG, "Refreshing Scan ... \n");
445 refresh_scan(priv, 1, false);
446
447 if (priv->u32RcvdChCount > 0) {
448 PRINT_D(CFG80211_DBG, "%d Network(s) found \n", priv->u32RcvdChCount);
449 } else {
450 PRINT_D(CFG80211_DBG, "No networks found \n");
451 }
452
453 down(&(priv->hSemScanReq));
454
455 if (priv->pstrScanReq != NULL) {
456 cfg80211_scan_done(priv->pstrScanReq, false);
457 priv->u32RcvdChCount = 0;
458 priv->bCfgScanning = false;
459 priv->pstrScanReq = NULL;
460 }
461 up(&(priv->hSemScanReq));
462
463 }
464 /*Aborting any scan operation during mac close*/
465 else if (enuScanEvent == SCAN_EVENT_ABORTED) {
466 down(&(priv->hSemScanReq));
467
468 PRINT_D(CFG80211_DBG, "Scan Aborted \n");
469 if (priv->pstrScanReq != NULL) {
470
471 update_scan_time(priv);
472 refresh_scan(priv, 1, false);
473
474 cfg80211_scan_done(priv->pstrScanReq, false);
475 priv->bCfgScanning = false;
476 priv->pstrScanReq = NULL;
477 }
478 up(&(priv->hSemScanReq));
479 }
480 }
481
482
483 WILC_CATCH(s32Error)
484 {
485 }
486 }
487
488
489 /**
490 * @brief WILC_WFI_Set_PMKSA
491 * @details Check if pmksa is cached and set it.
492 * @param[in]
493 * @return int : Return 0 on Success
494 * @author mdaftedar
495 * @date 01 MAR 2012
496 * @version 1.0
497 */
498 int WILC_WFI_Set_PMKSA(u8 *bssid, struct WILC_WFI_priv *priv)
499 {
500 u32 i;
501 s32 s32Error = WILC_SUCCESS;
502
503
504 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
505
506 if (!WILC_memcmp(bssid, priv->pmkid_list.pmkidlist[i].bssid,
507 ETH_ALEN)) {
508 PRINT_D(CFG80211_DBG, "PMKID successful comparison");
509
510 /*If bssid is found, set the values*/
511 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
512
513 if (s32Error != WILC_SUCCESS)
514 PRINT_ER("Error in pmkid\n");
515
516 break;
517 }
518 }
519
520 return s32Error;
521
522
523 }
524 int linux_wlan_set_bssid(struct net_device *wilc_netdev, uint8_t *pBSSID);
525
526
527 /**
528 * @brief CfgConnectResult
529 * @details
530 * @param[in] tenuConnDisconnEvent enuConnDisconnEvent: Type of connection response either
531 * connection response or disconnection notification.
532 * tstrConnectInfo* pstrConnectInfo: COnnection information.
533 * u8 u8MacStatus: Mac Status from firmware
534 * tstrDisconnectNotifInfo* pstrDisconnectNotifInfo: Disconnection Notification
535 * void* pUserVoid: Private data associated with wireless interface
536 * @return NONE
537 * @author mabubakr
538 * @date 01 MAR 2012
539 * @version 1.0
540 */
541 int connecting;
542
543 static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent,
544 tstrConnectInfo *pstrConnectInfo,
545 u8 u8MacStatus,
546 tstrDisconnectNotifInfo *pstrDisconnectNotifInfo,
547 void *pUserVoid)
548 {
549 struct WILC_WFI_priv *priv;
550 struct net_device *dev;
551 #ifdef WILC_P2P
552 tstrWILC_WFIDrv *pstrWFIDrv;
553 #endif
554 u8 NullBssid[ETH_ALEN] = {0};
555 connecting = 0;
556
557 priv = (struct WILC_WFI_priv *)pUserVoid;
558 dev = priv->dev;
559 #ifdef WILC_P2P
560 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
561 #endif
562
563 if (enuConnDisconnEvent == CONN_DISCONN_EVENT_CONN_RESP) {
564 /*Initialization*/
565 u16 u16ConnectStatus = WLAN_STATUS_SUCCESS;
566
567 u16ConnectStatus = pstrConnectInfo->u16ConnectStatus;
568
569 PRINT_D(CFG80211_DBG, " Connection response received = %d\n", u8MacStatus);
570
571 if ((u8MacStatus == MAC_DISCONNECTED) &&
572 (pstrConnectInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
573 /* The case here is that our station was waiting for association response frame and has just received it containing status code
574 * = SUCCESSFUL_STATUSCODE, while mac status is MAC_DISCONNECTED (which means something wrong happened) */
575 u16ConnectStatus = WLAN_STATUS_UNSPECIFIED_FAILURE;
576 linux_wlan_set_bssid(priv->dev, NullBssid);
577 WILC_memset(u8ConnectedSSID, 0, ETH_ALEN);
578
579 /*BugID_5457*/
580 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
581 #ifdef WILC_P2P
582 if (!pstrWFIDrv->u8P2PConnect)
583 u8WLANChannel = INVALID_CHANNEL;
584 #endif
585
586 PRINT_ER("Unspecified failure: Connection status %d : MAC status = %d \n", u16ConnectStatus, u8MacStatus);
587 }
588
589 if (u16ConnectStatus == WLAN_STATUS_SUCCESS) {
590 bool bNeedScanRefresh = false;
591 u32 i;
592
593 PRINT_INFO(CFG80211_DBG, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo->au8bssid[0],
594 pstrConnectInfo->au8bssid[1], pstrConnectInfo->au8bssid[2], pstrConnectInfo->au8bssid[3], pstrConnectInfo->au8bssid[4], pstrConnectInfo->au8bssid[5]);
595 WILC_memcpy(priv->au8AssociatedBss, pstrConnectInfo->au8bssid, ETH_ALEN);
596
597 /* BugID_4209: if this network has expired in the scan results in the above nl80211 layer, refresh them here by calling
598 * cfg80211_inform_bss() with the last Scan results before calling cfg80211_connect_result() to avoid
599 * Linux kernel warning generated at the nl80211 layer */
600
601 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
602 if (WILC_memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
603 pstrConnectInfo->au8bssid, ETH_ALEN) == 0) {
604 unsigned long now = jiffies;
605
606 if (time_after(now,
607 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScanCached + (unsigned long)(nl80211_SCAN_RESULT_EXPIRE - (1 * HZ)))) {
608 bNeedScanRefresh = true;
609 }
610
611 break;
612 }
613 }
614
615 if (bNeedScanRefresh) {
616 /*BugID_5418*/
617 /*Also, refrsh DIRECT- results if */
618 refresh_scan(priv, 1, true);
619
620 }
621
622 }
623
624
625 PRINT_D(CFG80211_DBG, "Association request info elements length = %zu\n", pstrConnectInfo->ReqIEsLen);
626
627 PRINT_D(CFG80211_DBG, "Association response info elements length = %d\n", pstrConnectInfo->u16RespIEsLen);
628
629 cfg80211_connect_result(dev, pstrConnectInfo->au8bssid,
630 pstrConnectInfo->pu8ReqIEs, pstrConnectInfo->ReqIEsLen,
631 pstrConnectInfo->pu8RespIEs, pstrConnectInfo->u16RespIEsLen,
632 u16ConnectStatus, GFP_KERNEL); /* TODO: mostafa: u16ConnectStatus to */
633 /* be replaced by pstrConnectInfo->u16ConnectStatus */
634 } else if (enuConnDisconnEvent == CONN_DISCONN_EVENT_DISCONN_NOTIF) {
635 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
636 g_obtainingIP = false;
637 #endif
638 PRINT_ER("Received MAC_DISCONNECTED from firmware with reason %d on dev [%p]\n",
639 pstrDisconnectNotifInfo->u16reason, priv->dev);
640 u8P2Plocalrandom = 0x01;
641 u8P2Precvrandom = 0x00;
642 bWilc_ie = false;
643 WILC_memset(priv->au8AssociatedBss, 0, ETH_ALEN);
644 linux_wlan_set_bssid(priv->dev, NullBssid);
645 WILC_memset(u8ConnectedSSID, 0, ETH_ALEN);
646
647 /*BugID_5457*/
648 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
649 #ifdef WILC_P2P
650 if (!pstrWFIDrv->u8P2PConnect)
651 u8WLANChannel = INVALID_CHANNEL;
652 #endif
653 /*BugID_5315*/
654 /*Incase "P2P CLIENT Connected" send deauthentication reason by 3 to force the WPA_SUPPLICANT to directly change
655 * virtual interface to station*/
656 if ((pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) {
657 pstrDisconnectNotifInfo->u16reason = 3;
658 }
659 /*BugID_5315*/
660 /*Incase "P2P CLIENT during connection(not connected)" send deauthentication reason by 1 to force the WPA_SUPPLICANT
661 * to scan again and retry the connection*/
662 else if ((!pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) {
663 pstrDisconnectNotifInfo->u16reason = 1;
664 }
665 cfg80211_disconnected(dev, pstrDisconnectNotifInfo->u16reason, pstrDisconnectNotifInfo->ie,
666 pstrDisconnectNotifInfo->ie_len, false,
667 GFP_KERNEL);
668
669 }
670
671 }
672
673
674 /**
675 * @brief WILC_WFI_CfgSetChannel
676 * @details Set channel for a given wireless interface. Some devices
677 * may support multi-channel operation (by channel hopping) so cfg80211
678 * doesn't verify much. Note, however, that the passed netdev may be
679 * %NULL as well if the user requested changing the channel for the
680 * device itself, or for a monitor interface.
681 * @param[in]
682 * @return int : Return 0 on Success
683 * @author mdaftedar
684 * @date 01 MAR 2012
685 * @version 1.0
686 */
687 static int WILC_WFI_CfgSetChannel(struct wiphy *wiphy,
688 struct cfg80211_chan_def *chandef)
689 {
690
691 u32 channelnum = 0;
692 struct WILC_WFI_priv *priv;
693 s32 s32Error = WILC_SUCCESS;
694 priv = wiphy_priv(wiphy);
695
696 channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq);
697 PRINT_D(CFG80211_DBG, "Setting channel %d with frequency %d\n", channelnum, chandef->chan->center_freq);
698
699 u8CurrChannel = channelnum;
700 s32Error = host_int_set_mac_chnl_num(priv->hWILCWFIDrv, channelnum);
701
702 if (s32Error != WILC_SUCCESS)
703 PRINT_ER("Error in setting channel %d\n", channelnum);
704
705 return s32Error;
706 }
707
708 /**
709 * @brief WILC_WFI_CfgScan
710 * @details Request to do a scan. If returning zero, the scan request is given
711 * the driver, and will be valid until passed to cfg80211_scan_done().
712 * For scan results, call cfg80211_inform_bss(); you can call this outside
713 * the scan/scan_done bracket too.
714 * @param[in]
715 * @return int : Return 0 on Success
716 * @author mabubakr
717 * @date 01 MAR 2012
718 * @version 1.0
719 */
720
721 /*
722 * kernel version 3.8.8 supported
723 * tony, sswd, WILC-KR, 2013-10-29
724 */
725 static int WILC_WFI_CfgScan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
726 {
727 struct WILC_WFI_priv *priv;
728 u32 i;
729 s32 s32Error = WILC_SUCCESS;
730 u8 au8ScanChanList[MAX_NUM_SCANNED_NETWORKS];
731 tstrHiddenNetwork strHiddenNetwork;
732
733 priv = wiphy_priv(wiphy);
734
735 priv->pstrScanReq = request;
736
737 priv->u32RcvdChCount = 0;
738
739 host_int_set_wfi_drv_handler((u32)priv->hWILCWFIDrv);
740
741
742 reset_shadow_found(priv);
743
744 priv->bCfgScanning = true;
745 if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
746 /* max_scan_ssids */
747 for (i = 0; i < request->n_channels; i++) {
748 au8ScanChanList[i] = (u8)ieee80211_frequency_to_channel(request->channels[i]->center_freq);
749 PRINT_INFO(CFG80211_DBG, "ScanChannel List[%d] = %d,", i, au8ScanChanList[i]);
750 }
751
752 PRINT_D(CFG80211_DBG, "Requested num of scan channel %d\n", request->n_channels);
753 PRINT_D(CFG80211_DBG, "Scan Request IE len = %zu\n", request->ie_len);
754
755 PRINT_D(CFG80211_DBG, "Number of SSIDs %d\n", request->n_ssids);
756
757 if (request->n_ssids >= 1) {
758
759
760 strHiddenNetwork.pstrHiddenNetworkInfo = WILC_MALLOC(request->n_ssids * sizeof(tstrHiddenNetwork));
761 strHiddenNetwork.u8ssidnum = request->n_ssids;
762
763
764 /*BugID_4156*/
765 for (i = 0; i < request->n_ssids; i++) {
766
767 if (request->ssids[i].ssid != NULL && request->ssids[i].ssid_len != 0) {
768 strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid = WILC_MALLOC(request->ssids[i].ssid_len);
769 WILC_memcpy(strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, request->ssids[i].ssid, request->ssids[i].ssid_len);
770 strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen = request->ssids[i].ssid_len;
771 } else {
772 PRINT_D(CFG80211_DBG, "Received one NULL SSID \n");
773 strHiddenNetwork.u8ssidnum -= 1;
774 }
775 }
776 PRINT_D(CFG80211_DBG, "Trigger Scan Request \n");
777 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
778 au8ScanChanList, request->n_channels,
779 (const u8 *)request->ie, request->ie_len,
780 CfgScanResult, (void *)priv, &strHiddenNetwork);
781 } else {
782 PRINT_D(CFG80211_DBG, "Trigger Scan Request \n");
783 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
784 au8ScanChanList, request->n_channels,
785 (const u8 *)request->ie, request->ie_len,
786 CfgScanResult, (void *)priv, NULL);
787 }
788
789 } else {
790 PRINT_ER("Requested num of scanned channels is greater than the max, supported"
791 " channels \n");
792 }
793
794 if (s32Error != WILC_SUCCESS) {
795 s32Error = -EBUSY;
796 PRINT_WRN(CFG80211_DBG, "Device is busy: Error(%d)\n", s32Error);
797 }
798
799 return s32Error;
800 }
801
802 /**
803 * @brief WILC_WFI_CfgConnect
804 * @details Connect to the ESS with the specified parameters. When connected,
805 * call cfg80211_connect_result() with status code %WLAN_STATUS_SUCCESS.
806 * If the connection fails for some reason, call cfg80211_connect_result()
807 * with the status from the AP.
808 * @param[in]
809 * @return int : Return 0 on Success
810 * @author mabubakr
811 * @date 01 MAR 2012
812 * @version 1.0
813 */
814 static int WILC_WFI_CfgConnect(struct wiphy *wiphy, struct net_device *dev,
815 struct cfg80211_connect_params *sme)
816 {
817 s32 s32Error = WILC_SUCCESS;
818 u32 i;
819 u8 u8security = NO_ENCRYPT;
820 AUTHTYPE_T tenuAuth_type = ANY;
821 char *pcgroup_encrypt_val = NULL;
822 char *pccipher_group = NULL;
823 char *pcwpa_version = NULL;
824
825 struct WILC_WFI_priv *priv;
826 tstrWILC_WFIDrv *pstrWFIDrv;
827 tstrNetworkInfo *pstrNetworkInfo = NULL;
828
829
830 connecting = 1;
831 priv = wiphy_priv(wiphy);
832 pstrWFIDrv = (tstrWILC_WFIDrv *)(priv->hWILCWFIDrv);
833
834 host_int_set_wfi_drv_handler((u32)priv->hWILCWFIDrv);
835
836 PRINT_D(CFG80211_DBG, "Connecting to SSID [%s] on netdev [%p] host if [%p]\n", sme->ssid, dev, priv->hWILCWFIDrv);
837 #ifdef WILC_P2P
838 if (!(WILC_strncmp(sme->ssid, "DIRECT-", 7))) {
839 PRINT_D(CFG80211_DBG, "Connected to Direct network,OBSS disabled\n");
840 pstrWFIDrv->u8P2PConnect = 1;
841 } else
842 pstrWFIDrv->u8P2PConnect = 0;
843 #endif
844 PRINT_INFO(CFG80211_DBG, "Required SSID = %s\n , AuthType = %d \n", sme->ssid, sme->auth_type);
845
846 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
847 if ((sme->ssid_len == astrLastScannedNtwrksShadow[i].u8SsidLen) &&
848 WILC_memcmp(astrLastScannedNtwrksShadow[i].au8ssid,
849 sme->ssid,
850 sme->ssid_len) == 0) {
851 PRINT_INFO(CFG80211_DBG, "Network with required SSID is found %s\n", sme->ssid);
852 if (sme->bssid == NULL) {
853 /* BSSID is not passed from the user, so decision of matching
854 * is done by SSID only */
855 PRINT_INFO(CFG80211_DBG, "BSSID is not passed from the user\n");
856 break;
857 } else {
858 /* BSSID is also passed from the user, so decision of matching
859 * should consider also this passed BSSID */
860 if (WILC_memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
861 sme->bssid,
862 ETH_ALEN) == 0) {
863 PRINT_INFO(CFG80211_DBG, "BSSID is passed from the user and matched\n");
864 break;
865 }
866 }
867 }
868 }
869
870 if (i < u32LastScannedNtwrksCountShadow) {
871 PRINT_D(CFG80211_DBG, "Required bss is in scan results\n");
872
873 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
874
875 PRINT_INFO(CFG80211_DBG, "network BSSID to be associated: %x%x%x%x%x%x\n",
876 pstrNetworkInfo->au8bssid[0], pstrNetworkInfo->au8bssid[1],
877 pstrNetworkInfo->au8bssid[2], pstrNetworkInfo->au8bssid[3],
878 pstrNetworkInfo->au8bssid[4], pstrNetworkInfo->au8bssid[5]);
879 } else {
880 s32Error = -ENOENT;
881 if (u32LastScannedNtwrksCountShadow == 0)
882 PRINT_D(CFG80211_DBG, "No Scan results yet\n");
883 else
884 PRINT_D(CFG80211_DBG, "Required bss not in scan results: Error(%d)\n", s32Error);
885
886 goto done;
887 }
888
889 priv->WILC_WFI_wep_default = 0;
890 WILC_memset(priv->WILC_WFI_wep_key, 0, sizeof(priv->WILC_WFI_wep_key));
891 WILC_memset(priv->WILC_WFI_wep_key_len, 0, sizeof(priv->WILC_WFI_wep_key_len));
892
893 PRINT_INFO(CFG80211_DBG, "sme->crypto.wpa_versions=%x\n", sme->crypto.wpa_versions);
894 PRINT_INFO(CFG80211_DBG, "sme->crypto.cipher_group=%x\n", sme->crypto.cipher_group);
895
896 PRINT_INFO(CFG80211_DBG, "sme->crypto.n_ciphers_pairwise=%d\n", sme->crypto.n_ciphers_pairwise);
897
898 if (INFO) {
899 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++)
900 PRINT_D(CORECONFIG_DBG, "sme->crypto.ciphers_pairwise[%d]=%x\n", i, sme->crypto.ciphers_pairwise[i]);
901 }
902
903 if (sme->crypto.cipher_group != NO_ENCRYPT) {
904 /* To determine the u8security value, first we check the group cipher suite then {in case of WPA or WPA2}
905 * we will add to it the pairwise cipher suite(s) */
906 pcwpa_version = "Default";
907 PRINT_D(CORECONFIG_DBG, ">> sme->crypto.wpa_versions: %x\n", sme->crypto.wpa_versions);
908 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) {
909 u8security = ENCRYPT_ENABLED | WEP;
910 pcgroup_encrypt_val = "WEP40";
911 pccipher_group = "WLAN_CIPHER_SUITE_WEP40";
912 PRINT_INFO(CFG80211_DBG, "WEP Default Key Idx = %d\n", sme->key_idx);
913
914 if (INFO) {
915 for (i = 0; i < sme->key_len; i++)
916 PRINT_D(CORECONFIG_DBG, "WEP Key Value[%d] = %d\n", i, sme->key[i]);
917 }
918 priv->WILC_WFI_wep_default = sme->key_idx;
919 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
920 WILC_memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
921
922 /*BugID_5137*/
923 g_key_wep_params.key_len = sme->key_len;
924 g_key_wep_params.key = WILC_MALLOC(sme->key_len);
925 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
926 g_key_wep_params.key_idx = sme->key_idx;
927 g_wep_keys_saved = true;
928
929 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
930 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
931 } else if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104) {
932 u8security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
933 pcgroup_encrypt_val = "WEP104";
934 pccipher_group = "WLAN_CIPHER_SUITE_WEP104";
935
936 priv->WILC_WFI_wep_default = sme->key_idx;
937 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
938 WILC_memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
939
940 /*BugID_5137*/
941 g_key_wep_params.key_len = sme->key_len;
942 g_key_wep_params.key = WILC_MALLOC(sme->key_len);
943 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
944 g_key_wep_params.key_idx = sme->key_idx;
945 g_wep_keys_saved = true;
946
947 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
948 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
949 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) {
950 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
951 u8security = ENCRYPT_ENABLED | WPA2 | TKIP;
952 pcgroup_encrypt_val = "WPA2_TKIP";
953 pccipher_group = "TKIP";
954 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
955 /* tenuSecurity_t = WPA2_AES; */
956 u8security = ENCRYPT_ENABLED | WPA2 | AES;
957 pcgroup_encrypt_val = "WPA2_AES";
958 pccipher_group = "AES";
959 }
960 pcwpa_version = "WPA_VERSION_2";
961 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) {
962 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
963 u8security = ENCRYPT_ENABLED | WPA | TKIP;
964 pcgroup_encrypt_val = "WPA_TKIP";
965 pccipher_group = "TKIP";
966 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
967 /* tenuSecurity_t = WPA_AES; */
968 u8security = ENCRYPT_ENABLED | WPA | AES;
969 pcgroup_encrypt_val = "WPA_AES";
970 pccipher_group = "AES";
971
972 }
973 pcwpa_version = "WPA_VERSION_1";
974
975 } else {
976 s32Error = -ENOTSUPP;
977 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
978
979 goto done;
980 }
981
982 }
983
984 /* After we set the u8security value from checking the group cipher suite, {in case of WPA or WPA2} we will
985 * add to it the pairwise cipher suite(s) */
986 if ((sme->crypto.wpa_versions & NL80211_WPA_VERSION_1)
987 || (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)) {
988 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) {
989 if (sme->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP) {
990 u8security = u8security | TKIP;
991 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
992 u8security = u8security | AES;
993 }
994 }
995 }
996
997 PRINT_D(CFG80211_DBG, "Adding key with cipher group = %x\n", sme->crypto.cipher_group);
998
999 PRINT_D(CFG80211_DBG, "Authentication Type = %d\n", sme->auth_type);
1000 switch (sme->auth_type) {
1001 case NL80211_AUTHTYPE_OPEN_SYSTEM:
1002 PRINT_D(CFG80211_DBG, "In OPEN SYSTEM\n");
1003 tenuAuth_type = OPEN_SYSTEM;
1004 break;
1005
1006 case NL80211_AUTHTYPE_SHARED_KEY:
1007 tenuAuth_type = SHARED_KEY;
1008 PRINT_D(CFG80211_DBG, "In SHARED KEY\n");
1009 break;
1010
1011 default:
1012 PRINT_D(CFG80211_DBG, "Automatic Authentation type = %d\n", sme->auth_type);
1013 }
1014
1015
1016 /* ai: key_mgmt: enterprise case */
1017 if (sme->crypto.n_akm_suites) {
1018 switch (sme->crypto.akm_suites[0]) {
1019 case WLAN_AKM_SUITE_8021X:
1020 tenuAuth_type = IEEE8021;
1021 break;
1022
1023 default:
1024 break;
1025 }
1026 }
1027
1028
1029 PRINT_INFO(CFG80211_DBG, "Required Channel = %d\n", pstrNetworkInfo->u8channel);
1030
1031 PRINT_INFO(CFG80211_DBG, "Group encryption value = %s\n Cipher Group = %s\n WPA version = %s\n",
1032 pcgroup_encrypt_val, pccipher_group, pcwpa_version);
1033
1034 /*BugID_5442*/
1035 u8CurrChannel = pstrNetworkInfo->u8channel;
1036
1037 if (!pstrWFIDrv->u8P2PConnect) {
1038 u8WLANChannel = pstrNetworkInfo->u8channel;
1039 }
1040
1041 linux_wlan_set_bssid(dev, pstrNetworkInfo->au8bssid);
1042
1043 s32Error = host_int_set_join_req(priv->hWILCWFIDrv, pstrNetworkInfo->au8bssid, sme->ssid,
1044 sme->ssid_len, sme->ie, sme->ie_len,
1045 CfgConnectResult, (void *)priv, u8security,
1046 tenuAuth_type, pstrNetworkInfo->u8channel,
1047 pstrNetworkInfo->pJoinParams);
1048 if (s32Error != WILC_SUCCESS) {
1049 PRINT_ER("host_int_set_join_req(): Error(%d) \n", s32Error);
1050 s32Error = -ENOENT;
1051 goto done;
1052 }
1053
1054 done:
1055
1056 return s32Error;
1057 }
1058
1059
1060 /**
1061 * @brief WILC_WFI_disconnect
1062 * @details Disconnect from the BSS/ESS.
1063 * @param[in]
1064 * @return int : Return 0 on Success
1065 * @author mdaftedar
1066 * @date 01 MAR 2012
1067 * @version 1.0
1068 */
1069 static int WILC_WFI_disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code)
1070 {
1071 s32 s32Error = WILC_SUCCESS;
1072 struct WILC_WFI_priv *priv;
1073 #ifdef WILC_P2P
1074 tstrWILC_WFIDrv *pstrWFIDrv;
1075 #endif
1076 uint8_t NullBssid[ETH_ALEN] = {0};
1077 connecting = 0;
1078 priv = wiphy_priv(wiphy);
1079
1080 /*BugID_5457*/
1081 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
1082 #ifdef WILC_P2P
1083 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
1084 if (!pstrWFIDrv->u8P2PConnect)
1085 u8WLANChannel = INVALID_CHANNEL;
1086 #endif
1087 linux_wlan_set_bssid(priv->dev, NullBssid);
1088
1089 PRINT_D(CFG80211_DBG, "Disconnecting with reason code(%d)\n", reason_code);
1090
1091 u8P2Plocalrandom = 0x01;
1092 u8P2Precvrandom = 0x00;
1093 bWilc_ie = false;
1094 #ifdef WILC_P2P
1095 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
1096 #endif
1097
1098 s32Error = host_int_disconnect(priv->hWILCWFIDrv, reason_code);
1099 if (s32Error != WILC_SUCCESS) {
1100 PRINT_ER("Error in disconnecting: Error(%d)\n", s32Error);
1101 s32Error = -EINVAL;
1102 }
1103
1104 return s32Error;
1105 }
1106
1107 /**
1108 * @brief WILC_WFI_add_key
1109 * @details Add a key with the given parameters. @mac_addr will be %NULL
1110 * when adding a group key.
1111 * @param[in] key : key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key, 8-byte Rx Mic Key
1112 * @return int : Return 0 on Success
1113 * @author mdaftedar
1114 * @date 01 MAR 2012
1115 * @version 1.0
1116 */
1117 static int WILC_WFI_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1118 bool pairwise,
1119 const u8 *mac_addr, struct key_params *params)
1120
1121 {
1122 s32 s32Error = WILC_SUCCESS, KeyLen = params->key_len;
1123 u32 i;
1124 struct WILC_WFI_priv *priv;
1125 const u8 *pu8RxMic = NULL;
1126 const u8 *pu8TxMic = NULL;
1127 u8 u8mode = NO_ENCRYPT;
1128 #ifdef WILC_AP_EXTERNAL_MLME
1129 u8 u8gmode = NO_ENCRYPT;
1130 u8 u8pmode = NO_ENCRYPT;
1131 AUTHTYPE_T tenuAuth_type = ANY;
1132 #endif
1133
1134 priv = wiphy_priv(wiphy);
1135
1136 PRINT_D(CFG80211_DBG, "Adding key with cipher suite = %x\n", params->cipher);
1137
1138 /*BugID_5137*/
1139 PRINT_D(CFG80211_DBG, "%p %p %d\n", wiphy, netdev, key_index);
1140
1141 PRINT_D(CFG80211_DBG, "key %x %x %x\n", params->key[0],
1142 params->key[1],
1143 params->key[2]);
1144
1145
1146 switch (params->cipher) {
1147 case WLAN_CIPHER_SUITE_WEP40:
1148 case WLAN_CIPHER_SUITE_WEP104:
1149 #ifdef WILC_AP_EXTERNAL_MLME
1150 if (priv->wdev->iftype == NL80211_IFTYPE_AP) {
1151
1152 priv->WILC_WFI_wep_default = key_index;
1153 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
1154 WILC_memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
1155
1156 PRINT_D(CFG80211_DBG, "Adding AP WEP Default key Idx = %d\n", key_index);
1157 PRINT_D(CFG80211_DBG, "Adding AP WEP Key len= %d\n", params->key_len);
1158
1159 for (i = 0; i < params->key_len; i++)
1160 PRINT_D(CFG80211_DBG, "WEP AP key val[%d] = %x\n", i, params->key[i]);
1161
1162 tenuAuth_type = OPEN_SYSTEM;
1163
1164 if (params->cipher == WLAN_CIPHER_SUITE_WEP40)
1165 u8mode = ENCRYPT_ENABLED | WEP;
1166 else
1167 u8mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
1168
1169 host_int_add_wep_key_bss_ap(priv->hWILCWFIDrv, params->key, params->key_len, key_index, u8mode, tenuAuth_type);
1170 break;
1171 }
1172 #endif
1173 if (WILC_memcmp(params->key, priv->WILC_WFI_wep_key[key_index], params->key_len)) {
1174 priv->WILC_WFI_wep_default = key_index;
1175 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
1176 WILC_memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
1177
1178 PRINT_D(CFG80211_DBG, "Adding WEP Default key Idx = %d\n", key_index);
1179 PRINT_D(CFG80211_DBG, "Adding WEP Key length = %d\n", params->key_len);
1180 if (INFO) {
1181 for (i = 0; i < params->key_len; i++)
1182 PRINT_INFO(CFG80211_DBG, "WEP key value[%d] = %d\n", i, params->key[i]);
1183 }
1184 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, params->key, params->key_len, key_index);
1185 }
1186
1187 break;
1188
1189 case WLAN_CIPHER_SUITE_TKIP:
1190 case WLAN_CIPHER_SUITE_CCMP:
1191 #ifdef WILC_AP_EXTERNAL_MLME
1192 if (priv->wdev->iftype == NL80211_IFTYPE_AP || priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) {
1193
1194 if (priv->wilc_gtk[key_index] == NULL) {
1195 priv->wilc_gtk[key_index] = (struct wilc_wfi_key *)WILC_MALLOC(sizeof(struct wilc_wfi_key));
1196 priv->wilc_gtk[key_index]->key = NULL;
1197 priv->wilc_gtk[key_index]->seq = NULL;
1198
1199 }
1200 if (priv->wilc_ptk[key_index] == NULL) {
1201 priv->wilc_ptk[key_index] = (struct wilc_wfi_key *)WILC_MALLOC(sizeof(struct wilc_wfi_key));
1202 priv->wilc_ptk[key_index]->key = NULL;
1203 priv->wilc_ptk[key_index]->seq = NULL;
1204 }
1205
1206
1207
1208 if (!pairwise)
1209 {
1210 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1211 u8gmode = ENCRYPT_ENABLED | WPA | TKIP;
1212 else
1213 u8gmode = ENCRYPT_ENABLED | WPA2 | AES;
1214
1215 priv->wilc_groupkey = u8gmode;
1216
1217 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1218
1219 pu8TxMic = params->key + 24;
1220 pu8RxMic = params->key + 16;
1221 KeyLen = params->key_len - 16;
1222 }
1223 /* if there has been previous allocation for the same index through its key, free that memory and allocate again*/
1224 if (priv->wilc_gtk[key_index]->key)
1225 WILC_FREE(priv->wilc_gtk[key_index]->key);
1226
1227 priv->wilc_gtk[key_index]->key = (u8 *)WILC_MALLOC(params->key_len);
1228 WILC_memcpy(priv->wilc_gtk[key_index]->key, params->key, params->key_len);
1229
1230 /* if there has been previous allocation for the same index through its seq, free that memory and allocate again*/
1231 if (priv->wilc_gtk[key_index]->seq)
1232 WILC_FREE(priv->wilc_gtk[key_index]->seq);
1233
1234 if ((params->seq_len) > 0) {
1235 priv->wilc_gtk[key_index]->seq = (u8 *)WILC_MALLOC(params->seq_len);
1236 WILC_memcpy(priv->wilc_gtk[key_index]->seq, params->seq, params->seq_len);
1237 }
1238
1239 priv->wilc_gtk[key_index]->cipher = params->cipher;
1240 priv->wilc_gtk[key_index]->key_len = params->key_len;
1241 priv->wilc_gtk[key_index]->seq_len = params->seq_len;
1242
1243 if (INFO) {
1244 for (i = 0; i < params->key_len; i++)
1245 PRINT_INFO(CFG80211_DBG, "Adding group key value[%d] = %x\n", i, params->key[i]);
1246 for (i = 0; i < params->seq_len; i++)
1247 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1248 }
1249
1250
1251 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1252 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, AP_MODE, u8gmode);
1253
1254 } else {
1255 PRINT_INFO(CFG80211_DBG, "STA Address: %x%x%x%x%x\n", mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4]);
1256
1257 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1258 u8pmode = ENCRYPT_ENABLED | WPA | TKIP;
1259 else
1260 u8pmode = priv->wilc_groupkey | AES;
1261
1262
1263 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1264
1265 pu8TxMic = params->key + 24;
1266 pu8RxMic = params->key + 16;
1267 KeyLen = params->key_len - 16;
1268 }
1269
1270 if (priv->wilc_ptk[key_index]->key)
1271 WILC_FREE(priv->wilc_ptk[key_index]->key);
1272
1273 priv->wilc_ptk[key_index]->key = (u8 *)WILC_MALLOC(params->key_len);
1274
1275 if (priv->wilc_ptk[key_index]->seq)
1276 WILC_FREE(priv->wilc_ptk[key_index]->seq);
1277
1278 if ((params->seq_len) > 0)
1279 priv->wilc_ptk[key_index]->seq = (u8 *)WILC_MALLOC(params->seq_len);
1280
1281 if (INFO) {
1282 for (i = 0; i < params->key_len; i++)
1283 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %x\n", i, params->key[i]);
1284
1285 for (i = 0; i < params->seq_len; i++)
1286 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1287 }
1288
1289 WILC_memcpy(priv->wilc_ptk[key_index]->key, params->key, params->key_len);
1290
1291 if ((params->seq_len) > 0)
1292 WILC_memcpy(priv->wilc_ptk[key_index]->seq, params->seq, params->seq_len);
1293
1294 priv->wilc_ptk[key_index]->cipher = params->cipher;
1295 priv->wilc_ptk[key_index]->key_len = params->key_len;
1296 priv->wilc_ptk[key_index]->seq_len = params->seq_len;
1297
1298 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1299 pu8RxMic, pu8TxMic, AP_MODE, u8pmode, key_index);
1300 }
1301 break;
1302 }
1303 #endif
1304
1305 {
1306 u8mode = 0;
1307 if (!pairwise)
1308 {
1309 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1310 /* swap the tx mic by rx mic */
1311 pu8RxMic = params->key + 24;
1312 pu8TxMic = params->key + 16;
1313 KeyLen = params->key_len - 16;
1314 }
1315
1316 /*BugID_5137*/
1317 /*save keys only on interface 0 (wifi interface)*/
1318 if (!g_gtk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1319 g_add_gtk_key_params.key_idx = key_index;
1320 g_add_gtk_key_params.pairwise = pairwise;
1321 if (!mac_addr) {
1322 g_add_gtk_key_params.mac_addr = NULL;
1323 } else {
1324 g_add_gtk_key_params.mac_addr = WILC_MALLOC(ETH_ALEN);
1325 memcpy(g_add_gtk_key_params.mac_addr, mac_addr, ETH_ALEN);
1326 }
1327 g_key_gtk_params.key_len = params->key_len;
1328 g_key_gtk_params.seq_len = params->seq_len;
1329 g_key_gtk_params.key = WILC_MALLOC(params->key_len);
1330 memcpy(g_key_gtk_params.key, params->key, params->key_len);
1331 if (params->seq_len > 0) {
1332 g_key_gtk_params.seq = WILC_MALLOC(params->seq_len);
1333 memcpy(g_key_gtk_params.seq, params->seq, params->seq_len);
1334 }
1335 g_key_gtk_params.cipher = params->cipher;
1336
1337 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_gtk_params.key[0],
1338 g_key_gtk_params.key[1],
1339 g_key_gtk_params.key[2]);
1340 g_gtk_keys_saved = true;
1341 }
1342
1343 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1344 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, STATION_MODE, u8mode);
1345 } else {
1346 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1347 /* swap the tx mic by rx mic */
1348 pu8RxMic = params->key + 24;
1349 pu8TxMic = params->key + 16;
1350 KeyLen = params->key_len - 16;
1351 }
1352
1353 /*BugID_5137*/
1354 /*save keys only on interface 0 (wifi interface)*/
1355 if (!g_ptk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1356 g_add_ptk_key_params.key_idx = key_index;
1357 g_add_ptk_key_params.pairwise = pairwise;
1358 if (!mac_addr) {
1359 g_add_ptk_key_params.mac_addr = NULL;
1360 } else {
1361 g_add_ptk_key_params.mac_addr = WILC_MALLOC(ETH_ALEN);
1362 memcpy(g_add_ptk_key_params.mac_addr, mac_addr, ETH_ALEN);
1363 }
1364 g_key_ptk_params.key_len = params->key_len;
1365 g_key_ptk_params.seq_len = params->seq_len;
1366 g_key_ptk_params.key = WILC_MALLOC(params->key_len);
1367 memcpy(g_key_ptk_params.key, params->key, params->key_len);
1368 if (params->seq_len > 0) {
1369 g_key_ptk_params.seq = WILC_MALLOC(params->seq_len);
1370 memcpy(g_key_ptk_params.seq, params->seq, params->seq_len);
1371 }
1372 g_key_ptk_params.cipher = params->cipher;
1373
1374 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_ptk_params.key[0],
1375 g_key_ptk_params.key[1],
1376 g_key_ptk_params.key[2]);
1377 g_ptk_keys_saved = true;
1378 }
1379
1380 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1381 pu8RxMic, pu8TxMic, STATION_MODE, u8mode, key_index);
1382 PRINT_D(CFG80211_DBG, "Adding pairwise key\n");
1383 if (INFO) {
1384 for (i = 0; i < params->key_len; i++)
1385 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %d\n", i, params->key[i]);
1386 }
1387 }
1388 }
1389 break;
1390
1391 default:
1392 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
1393 s32Error = -ENOTSUPP;
1394
1395 }
1396
1397 return s32Error;
1398 }
1399
1400 /**
1401 * @brief WILC_WFI_del_key
1402 * @details Remove a key given the @mac_addr (%NULL for a group key)
1403 * and @key_index, return -ENOENT if the key doesn't exist.
1404 * @param[in]
1405 * @return int : Return 0 on Success
1406 * @author mdaftedar
1407 * @date 01 MAR 2012
1408 * @version 1.0
1409 */
1410 static int WILC_WFI_del_key(struct wiphy *wiphy, struct net_device *netdev,
1411 u8 key_index,
1412 bool pairwise,
1413 const u8 *mac_addr)
1414 {
1415 struct WILC_WFI_priv *priv;
1416 s32 s32Error = WILC_SUCCESS;
1417
1418 priv = wiphy_priv(wiphy);
1419
1420 /*BugID_5137*/
1421 /*delete saved keys, if any*/
1422 if (netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1423 g_ptk_keys_saved = false;
1424 g_gtk_keys_saved = false;
1425 g_wep_keys_saved = false;
1426
1427 /*Delete saved WEP keys params, if any*/
1428 if (g_key_wep_params.key != NULL) {
1429 WILC_FREE(g_key_wep_params.key);
1430 g_key_wep_params.key = NULL;
1431 }
1432
1433 /*freeing memory allocated by "wilc_gtk" and "wilc_ptk" in "WILC_WIFI_ADD_KEY"*/
1434
1435 #ifdef WILC_AP_EXTERNAL_MLME
1436 if ((priv->wilc_gtk[key_index]) != NULL) {
1437
1438 if (priv->wilc_gtk[key_index]->key != NULL) {
1439
1440 WILC_FREE(priv->wilc_gtk[key_index]->key);
1441 priv->wilc_gtk[key_index]->key = NULL;
1442 }
1443 if (priv->wilc_gtk[key_index]->seq) {
1444
1445 WILC_FREE(priv->wilc_gtk[key_index]->seq);
1446 priv->wilc_gtk[key_index]->seq = NULL;
1447 }
1448
1449 WILC_FREE(priv->wilc_gtk[key_index]);
1450 priv->wilc_gtk[key_index] = NULL;
1451
1452 }
1453
1454 if ((priv->wilc_ptk[key_index]) != NULL) {
1455
1456 if (priv->wilc_ptk[key_index]->key) {
1457
1458 WILC_FREE(priv->wilc_ptk[key_index]->key);
1459 priv->wilc_ptk[key_index]->key = NULL;
1460 }
1461 if (priv->wilc_ptk[key_index]->seq) {
1462
1463 WILC_FREE(priv->wilc_ptk[key_index]->seq);
1464 priv->wilc_ptk[key_index]->seq = NULL;
1465 }
1466 WILC_FREE(priv->wilc_ptk[key_index]);
1467 priv->wilc_ptk[key_index] = NULL;
1468 }
1469 #endif
1470
1471 /*Delete saved PTK and GTK keys params, if any*/
1472 if (g_key_ptk_params.key != NULL) {
1473 WILC_FREE(g_key_ptk_params.key);
1474 g_key_ptk_params.key = NULL;
1475 }
1476 if (g_key_ptk_params.seq != NULL) {
1477 WILC_FREE(g_key_ptk_params.seq);
1478 g_key_ptk_params.seq = NULL;
1479 }
1480
1481 if (g_key_gtk_params.key != NULL) {
1482 WILC_FREE(g_key_gtk_params.key);
1483 g_key_gtk_params.key = NULL;
1484 }
1485 if (g_key_gtk_params.seq != NULL) {
1486 WILC_FREE(g_key_gtk_params.seq);
1487 g_key_gtk_params.seq = NULL;
1488 }
1489
1490 /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/
1491 Set_machw_change_vir_if(false);
1492 }
1493
1494 if (key_index >= 0 && key_index <= 3) {
1495 WILC_memset(priv->WILC_WFI_wep_key[key_index], 0, priv->WILC_WFI_wep_key_len[key_index]);
1496 priv->WILC_WFI_wep_key_len[key_index] = 0;
1497
1498 PRINT_D(CFG80211_DBG, "Removing WEP key with index = %d\n", key_index);
1499 host_int_remove_wep_key(priv->hWILCWFIDrv, key_index);
1500 } else {
1501 PRINT_D(CFG80211_DBG, "Removing all installed keys\n");
1502 host_int_remove_key(priv->hWILCWFIDrv, mac_addr);
1503 }
1504
1505 return s32Error;
1506 }
1507
1508 /**
1509 * @brief WILC_WFI_get_key
1510 * @details Get information about the key with the given parameters.
1511 * @mac_addr will be %NULL when requesting information for a group
1512 * key. All pointers given to the @callback function need not be valid
1513 * after it returns. This function should return an error if it is
1514 * not possible to retrieve the key, -ENOENT if it doesn't exist.
1515 * @param[in]
1516 * @return int : Return 0 on Success
1517 * @author mdaftedar
1518 * @date 01 MAR 2012
1519 * @version 1.0
1520 */
1521 static int WILC_WFI_get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1522 bool pairwise,
1523 const u8 *mac_addr, void *cookie, void (*callback)(void *cookie, struct key_params *))
1524 {
1525
1526 s32 s32Error = WILC_SUCCESS;
1527
1528 struct WILC_WFI_priv *priv;
1529 struct key_params key_params;
1530 u32 i;
1531 priv = wiphy_priv(wiphy);
1532
1533
1534 if (!pairwise)
1535 {
1536 PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index);
1537
1538 key_params.key = priv->wilc_gtk[key_index]->key;
1539 key_params.cipher = priv->wilc_gtk[key_index]->cipher;
1540 key_params.key_len = priv->wilc_gtk[key_index]->key_len;
1541 key_params.seq = priv->wilc_gtk[key_index]->seq;
1542 key_params.seq_len = priv->wilc_gtk[key_index]->seq_len;
1543 if (INFO) {
1544 for (i = 0; i < key_params.key_len; i++)
1545 PRINT_INFO(CFG80211_DBG, "Retrieved key value %x\n", key_params.key[i]);
1546 }
1547 } else {
1548 PRINT_D(CFG80211_DBG, "Getting pairwise key\n");
1549
1550 key_params.key = priv->wilc_ptk[key_index]->key;
1551 key_params.cipher = priv->wilc_ptk[key_index]->cipher;
1552 key_params.key_len = priv->wilc_ptk[key_index]->key_len;
1553 key_params.seq = priv->wilc_ptk[key_index]->seq;
1554 key_params.seq_len = priv->wilc_ptk[key_index]->seq_len;
1555 }
1556
1557 callback(cookie, &key_params);
1558
1559 return s32Error; /* priv->wilc_gtk->key_len ?0 : -ENOENT; */
1560 }
1561
1562 /**
1563 * @brief WILC_WFI_set_default_key
1564 * @details Set the default management frame key on an interface
1565 * @param[in]
1566 * @return int : Return 0 on Success.
1567 * @author mdaftedar
1568 * @date 01 MAR 2012
1569 * @version 1.0
1570 */
1571 static int WILC_WFI_set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1572 bool unicast, bool multicast)
1573 {
1574 s32 s32Error = WILC_SUCCESS;
1575 struct WILC_WFI_priv *priv;
1576
1577
1578 priv = wiphy_priv(wiphy);
1579
1580 PRINT_D(CFG80211_DBG, "Setting default key with idx = %d \n", key_index);
1581
1582 if (key_index != priv->WILC_WFI_wep_default) {
1583
1584 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, key_index);
1585 }
1586
1587 return s32Error;
1588 }
1589
1590 /**
1591 * @brief WILC_WFI_dump_survey
1592 * @details Get site survey information
1593 * @param[in]
1594 * @return int : Return 0 on Success.
1595 * @author mdaftedar
1596 * @date 01 MAR 2012
1597 * @version 1.0
1598 */
1599 static int WILC_WFI_dump_survey(struct wiphy *wiphy, struct net_device *netdev,
1600 int idx, struct survey_info *info)
1601 {
1602 s32 s32Error = WILC_SUCCESS;
1603
1604
1605 if (idx != 0) {
1606 s32Error = -ENOENT;
1607 PRINT_ER("Error Idx value doesn't equal zero: Error(%d)\n", s32Error);
1608
1609 }
1610
1611 return s32Error;
1612 }
1613
1614
1615 /**
1616 * @brief WILC_WFI_get_station
1617 * @details Get station information for the station identified by @mac
1618 * @param[in] NONE
1619 * @return int : Return 0 on Success.
1620 * @author mdaftedar
1621 * @date 01 MAR 2012
1622 * @version 1.0
1623 */
1624
1625 extern uint32_t Statisitcs_totalAcks, Statisitcs_DroppedAcks;
1626 static int WILC_WFI_get_station(struct wiphy *wiphy, struct net_device *dev,
1627 const u8 *mac, struct station_info *sinfo)
1628 {
1629 s32 s32Error = WILC_SUCCESS;
1630 struct WILC_WFI_priv *priv;
1631 perInterface_wlan_t *nic;
1632 #ifdef WILC_AP_EXTERNAL_MLME
1633 u32 i = 0;
1634 u32 associatedsta = 0;
1635 u32 inactive_time = 0;
1636 #endif
1637 priv = wiphy_priv(wiphy);
1638 nic = netdev_priv(dev);
1639
1640 #ifdef WILC_AP_EXTERNAL_MLME
1641 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
1642 PRINT_D(HOSTAPD_DBG, "Getting station parameters\n");
1643
1644 PRINT_INFO(HOSTAPD_DBG, ": %x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4]);
1645
1646 for (i = 0; i < NUM_STA_ASSOCIATED; i++) {
1647
1648 if (!(memcmp(mac, priv->assoc_stainfo.au8Sta_AssociatedBss[i], ETH_ALEN))) {
1649 associatedsta = i;
1650 break;
1651 }
1652
1653 }
1654
1655 if (associatedsta == -1) {
1656 s32Error = -ENOENT;
1657 PRINT_ER("Station required is not associated : Error(%d)\n", s32Error);
1658
1659 return s32Error;
1660 }
1661
1662 sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME);
1663
1664 host_int_get_inactive_time(priv->hWILCWFIDrv, mac, &(inactive_time));
1665 sinfo->inactive_time = 1000 * inactive_time;
1666 PRINT_D(CFG80211_DBG, "Inactive time %d\n", sinfo->inactive_time);
1667
1668 }
1669 #endif
1670
1671 if (nic->iftype == STATION_MODE) {
1672 tstrStatistics strStatistics;
1673 host_int_get_statistics(priv->hWILCWFIDrv, &strStatistics);
1674
1675 /*
1676 * tony: 2013-11-13
1677 * tx_failed introduced more than
1678 * kernel version 3.0.0
1679 */
1680 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) |
1681 BIT( NL80211_STA_INFO_RX_PACKETS) |
1682 BIT(NL80211_STA_INFO_TX_PACKETS) |
1683 BIT(NL80211_STA_INFO_TX_FAILED) |
1684 BIT(NL80211_STA_INFO_TX_BITRATE);
1685
1686 sinfo->signal = strStatistics.s8RSSI;
1687 sinfo->rx_packets = strStatistics.u32RxCount;
1688 sinfo->tx_packets = strStatistics.u32TxCount + strStatistics.u32TxFailureCount;
1689 sinfo->tx_failed = strStatistics.u32TxFailureCount;
1690 sinfo->txrate.legacy = strStatistics.u8LinkSpeed * 10;
1691
1692 #ifdef TCP_ENHANCEMENTS
1693 if ((strStatistics.u8LinkSpeed > TCP_ACK_FILTER_LINK_SPEED_THRESH) && (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED)) {
1694 Enable_TCP_ACK_Filter(true);
1695 } else if (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED) {
1696 Enable_TCP_ACK_Filter(false);
1697 }
1698 #endif
1699
1700 PRINT_D(CORECONFIG_DBG, "*** stats[%d][%d][%d][%d][%d]\n", sinfo->signal, sinfo->rx_packets, sinfo->tx_packets,
1701 sinfo->tx_failed, sinfo->txrate.legacy);
1702 }
1703 return s32Error;
1704 }
1705
1706
1707 /**
1708 * @brief WILC_WFI_change_bss
1709 * @details Modify parameters for a given BSS.
1710 * @param[in]
1711 * -use_cts_prot: Whether to use CTS protection
1712 * (0 = no, 1 = yes, -1 = do not change)
1713 * -use_short_preamble: Whether the use of short preambles is allowed
1714 * (0 = no, 1 = yes, -1 = do not change)
1715 * -use_short_slot_time: Whether the use of short slot time is allowed
1716 * (0 = no, 1 = yes, -1 = do not change)
1717 * -basic_rates: basic rates in IEEE 802.11 format
1718 * (or NULL for no change)
1719 * -basic_rates_len: number of basic rates
1720 * -ap_isolate: do not forward packets between connected stations
1721 * -ht_opmode: HT Operation mode
1722 * (u16 = opmode, -1 = do not change)
1723 * @return int : Return 0 on Success.
1724 * @author mdaftedar
1725 * @date 01 MAR 2012
1726 * @version 1.0
1727 */
1728 static int WILC_WFI_change_bss(struct wiphy *wiphy, struct net_device *dev,
1729 struct bss_parameters *params)
1730 {
1731 PRINT_D(CFG80211_DBG, "Changing Bss parametrs\n");
1732 return 0;
1733 }
1734
1735 /**
1736 * @brief WILC_WFI_auth
1737 * @details Request to authenticate with the specified peer
1738 * @param[in]
1739 * @return int : Return 0 on Success.
1740 * @author mdaftedar
1741 * @date 01 MAR 2012
1742 * @version 1.0
1743 */
1744 static int WILC_WFI_auth(struct wiphy *wiphy, struct net_device *dev,
1745 struct cfg80211_auth_request *req)
1746 {
1747 PRINT_D(CFG80211_DBG, "In Authentication Function\n");
1748 return 0;
1749 }
1750
1751 /**
1752 * @brief WILC_WFI_assoc
1753 * @details Request to (re)associate with the specified peer
1754 * @param[in]
1755 * @return int : Return 0 on Success.
1756 * @author mdaftedar
1757 * @date 01 MAR 2012
1758 * @version 1.0
1759 */
1760 static int WILC_WFI_assoc(struct wiphy *wiphy, struct net_device *dev,
1761 struct cfg80211_assoc_request *req)
1762 {
1763 PRINT_D(CFG80211_DBG, "In Association Function\n");
1764 return 0;
1765 }
1766
1767 /**
1768 * @brief WILC_WFI_deauth
1769 * @details Request to deauthenticate from the specified peer
1770 * @param[in]
1771 * @return int : Return 0 on Success.
1772 * @author mdaftedar
1773 * @date 01 MAR 2012
1774 * @version 1.0
1775 */
1776 static int WILC_WFI_deauth(struct wiphy *wiphy, struct net_device *dev,
1777 struct cfg80211_deauth_request *req, void *cookie)
1778 {
1779 PRINT_D(CFG80211_DBG, "In De-authentication Function\n");
1780 return 0;
1781 }
1782
1783 /**
1784 * @brief WILC_WFI_disassoc
1785 * @details Request to disassociate from the specified peer
1786 * @param[in]
1787 * @return int : Return 0 on Success
1788 * @author mdaftedar
1789 * @date 01 MAR 2012
1790 * @version 1.0
1791 */
1792 static int WILC_WFI_disassoc(struct wiphy *wiphy, struct net_device *dev,
1793 struct cfg80211_disassoc_request *req, void *cookie)
1794 {
1795 PRINT_D(CFG80211_DBG, "In Disassociation Function\n");
1796 return 0;
1797 }
1798
1799 /**
1800 * @brief WILC_WFI_set_wiphy_params
1801 * @details Notify that wiphy parameters have changed;
1802 * @param[in] Changed bitfield (see &enum wiphy_params_flags) describes which values
1803 * have changed.
1804 * @return int : Return 0 on Success
1805 * @author mdaftedar
1806 * @date 01 MAR 2012
1807 * @version 1.0
1808 */
1809 static int WILC_WFI_set_wiphy_params(struct wiphy *wiphy, u32 changed)
1810 {
1811 s32 s32Error = WILC_SUCCESS;
1812 tstrCfgParamVal pstrCfgParamVal;
1813 struct WILC_WFI_priv *priv;
1814
1815 priv = wiphy_priv(wiphy);
1816
1817 pstrCfgParamVal.u32SetCfgFlag = 0;
1818 PRINT_D(CFG80211_DBG, "Setting Wiphy params \n");
1819
1820 if (changed & WIPHY_PARAM_RETRY_SHORT) {
1821 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_SHORT %d\n",
1822 priv->dev->ieee80211_ptr->wiphy->retry_short);
1823 pstrCfgParamVal.u32SetCfgFlag |= RETRY_SHORT;
1824 pstrCfgParamVal.short_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_short;
1825 }
1826 if (changed & WIPHY_PARAM_RETRY_LONG) {
1827
1828 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_LONG %d\n", priv->dev->ieee80211_ptr->wiphy->retry_long);
1829 pstrCfgParamVal.u32SetCfgFlag |= RETRY_LONG;
1830 pstrCfgParamVal.long_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_long;
1831
1832 }
1833 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
1834 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->frag_threshold);
1835 pstrCfgParamVal.u32SetCfgFlag |= FRAG_THRESHOLD;
1836 pstrCfgParamVal.frag_threshold = priv->dev->ieee80211_ptr->wiphy->frag_threshold;
1837
1838 }
1839
1840 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
1841 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->rts_threshold);
1842
1843 pstrCfgParamVal.u32SetCfgFlag |= RTS_THRESHOLD;
1844 pstrCfgParamVal.rts_threshold = priv->dev->ieee80211_ptr->wiphy->rts_threshold;
1845
1846 }
1847
1848 PRINT_D(CFG80211_DBG, "Setting CFG params in the host interface\n");
1849 s32Error = hif_set_cfg(priv->hWILCWFIDrv, &pstrCfgParamVal);
1850 if (s32Error)
1851 PRINT_ER("Error in setting WIPHY PARAMS\n");
1852
1853
1854 return s32Error;
1855 }
1856
1857 /**
1858 * @brief WILC_WFI_set_bitrate_mask
1859 * @details set the bitrate mask configuration
1860 * @param[in]
1861 * @return int : Return 0 on Success
1862 * @author mdaftedar
1863 * @date 01 MAR 2012
1864 * @version 1.0
1865 */
1866 static int WILC_WFI_set_bitrate_mask(struct wiphy *wiphy,
1867 struct net_device *dev, const u8 *peer,
1868 const struct cfg80211_bitrate_mask *mask)
1869 {
1870 s32 s32Error = WILC_SUCCESS;
1871
1872 PRINT_D(CFG80211_DBG, "Setting Bitrate mask function\n");
1873 return s32Error;
1874
1875 }
1876
1877 /**
1878 * @brief WILC_WFI_set_pmksa
1879 * @details Cache a PMKID for a BSSID. This is mostly useful for fullmac
1880 * devices running firmwares capable of generating the (re) association
1881 * RSN IE. It allows for faster roaming between WPA2 BSSIDs.
1882 * @param[in]
1883 * @return int : Return 0 on Success
1884 * @author mdaftedar
1885 * @date 01 MAR 2012
1886 * @version 1.0
1887 */
1888 static int WILC_WFI_set_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1889 struct cfg80211_pmksa *pmksa)
1890 {
1891 u32 i;
1892 s32 s32Error = WILC_SUCCESS;
1893 u8 flag = 0;
1894
1895 struct WILC_WFI_priv *priv = wiphy_priv(wiphy);
1896
1897 PRINT_D(CFG80211_DBG, "Setting PMKSA\n");
1898
1899
1900 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
1901 if (!WILC_memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
1902 ETH_ALEN)) {
1903 /*If bssid already exists and pmkid value needs to reset*/
1904 flag = PMKID_FOUND;
1905 PRINT_D(CFG80211_DBG, "PMKID already exists\n");
1906 break;
1907 }
1908 }
1909 if (i < WILC_MAX_NUM_PMKIDS) {
1910 PRINT_D(CFG80211_DBG, "Setting PMKID in private structure\n");
1911 WILC_memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid,
1912 ETH_ALEN);
1913 WILC_memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid,
1914 PMKID_LEN);
1915 if (!(flag == PMKID_FOUND))
1916 priv->pmkid_list.numpmkid++;
1917 } else {
1918 PRINT_ER("Invalid PMKID index\n");
1919 s32Error = -EINVAL;
1920 }
1921
1922 if (!s32Error) {
1923 PRINT_D(CFG80211_DBG, "Setting pmkid in the host interface\n");
1924 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
1925 }
1926 return s32Error;
1927 }
1928
1929 /**
1930 * @brief WILC_WFI_del_pmksa
1931 * @details Delete a cached PMKID.
1932 * @param[in]
1933 * @return int : Return 0 on Success
1934 * @author mdaftedar
1935 * @date 01 MAR 2012
1936 * @version 1.0
1937 */
1938 static int WILC_WFI_del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1939 struct cfg80211_pmksa *pmksa)
1940 {
1941
1942 u32 i;
1943 u8 flag = 0;
1944 s32 s32Error = WILC_SUCCESS;
1945
1946 struct WILC_WFI_priv *priv = wiphy_priv(wiphy);
1947
1948 PRINT_D(CFG80211_DBG, "Deleting PMKSA keys\n");
1949
1950 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
1951 if (!WILC_memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
1952 ETH_ALEN)) {
1953 /*If bssid is found, reset the values*/
1954 PRINT_D(CFG80211_DBG, "Reseting PMKID values\n");
1955 WILC_memset(&priv->pmkid_list.pmkidlist[i], 0, sizeof(tstrHostIFpmkid));
1956 flag = PMKID_FOUND;
1957 break;
1958 }
1959 }
1960
1961 if (i < priv->pmkid_list.numpmkid && priv->pmkid_list.numpmkid > 0) {
1962 for (; i < (priv->pmkid_list.numpmkid - 1); i++) {
1963 WILC_memcpy(priv->pmkid_list.pmkidlist[i].bssid,
1964 priv->pmkid_list.pmkidlist[i + 1].bssid,
1965 ETH_ALEN);
1966 WILC_memcpy(priv->pmkid_list.pmkidlist[i].pmkid,
1967 priv->pmkid_list.pmkidlist[i].pmkid,
1968 PMKID_LEN);
1969 }
1970 priv->pmkid_list.numpmkid--;
1971 } else {
1972 s32Error = -EINVAL;
1973 }
1974
1975 return s32Error;
1976 }
1977
1978 /**
1979 * @brief WILC_WFI_flush_pmksa
1980 * @details Flush all cached PMKIDs.
1981 * @param[in]
1982 * @return int : Return 0 on Success
1983 * @author mdaftedar
1984 * @date 01 MAR 2012
1985 * @version 1.0
1986 */
1987 static int WILC_WFI_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev)
1988 {
1989 struct WILC_WFI_priv *priv = wiphy_priv(wiphy);
1990
1991 PRINT_D(CFG80211_DBG, "Flushing PMKID key values\n");
1992
1993 /*Get cashed Pmkids and set all with zeros*/
1994 WILC_memset(&priv->pmkid_list, 0, sizeof(tstrHostIFpmkidAttr));
1995
1996 return 0;
1997 }
1998
1999 #ifdef WILC_P2P
2000
2001 /**
2002 * @brief WILC_WFI_CfgParseRxAction
2003 * @details Function parses the received frames and modifies the following attributes:
2004 * -GO Intent
2005 * -Channel list
2006 * -Operating Channel
2007 *
2008 * @param[in] u8* Buffer, u32 length
2009 * @return NONE.
2010 * @author mdaftedar
2011 * @date 12 DEC 2012
2012 * @version
2013 */
2014
2015 void WILC_WFI_CfgParseRxAction(u8 *buf, u32 len)
2016 {
2017 u32 index = 0;
2018 u32 i = 0, j = 0;
2019
2020 /*BugID_5460*/
2021 #ifdef USE_SUPPLICANT_GO_INTENT
2022 u8 intent;
2023 u8 tie_breaker;
2024 bool is_wilc_go = true;
2025 #endif
2026 u8 op_channel_attr_index = 0;
2027 u8 channel_list_attr_index = 0;
2028
2029 while (index < len) {
2030 if (buf[index] == GO_INTENT_ATTR_ID) {
2031 #ifdef USE_SUPPLICANT_GO_INTENT
2032 /*BugID_5460*/
2033 /*Case 1: If we are going to be p2p client, no need to modify channels attributes*/
2034 /*In negotiation frames, go intent attr value determines who will be GO*/
2035 intent = GET_GO_INTENT(buf[index + 3]);
2036 tie_breaker = GET_TIE_BREAKER(buf[index + 3]);
2037 if (intent > SUPPLICANT_GO_INTENT
2038 || (intent == SUPPLICANT_GO_INTENT && tie_breaker == 1)) {
2039 PRINT_D(GENERIC_DBG, "WILC will be client (intent %d tie breaker %d)\n", intent, tie_breaker);
2040 is_wilc_go = false;
2041 } else {
2042 PRINT_D(GENERIC_DBG, "WILC will be GO (intent %d tie breaker %d)\n", intent, tie_breaker);
2043 is_wilc_go = true;
2044 }
2045
2046 #else /* USE_SUPPLICANT_GO_INTENT */
2047 #ifdef FORCE_P2P_CLIENT
2048 buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1);
2049 #else
2050 buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1);
2051 #endif
2052 #endif /* USE_SUPPLICANT_GO_INTENT */
2053 }
2054
2055 #ifdef USE_SUPPLICANT_GO_INTENT
2056 /*Case 2: If group bssid attribute is present, no need to modify channels attributes*/
2057 /*In invitation req and rsp, group bssid attr presence determines who will be GO*/
2058 if (buf[index] == GROUP_BSSID_ATTR_ID) {
2059 PRINT_D(GENERIC_DBG, "Group BSSID: %2x:%2x:%2x\n", buf[index + 3]
2060 , buf[index + 4]
2061 , buf[index + 5]);
2062 is_wilc_go = false;
2063 }
2064 #endif /* USE_SUPPLICANT_GO_INTENT */
2065
2066 if (buf[index] == CHANLIST_ATTR_ID) {
2067 channel_list_attr_index = index;
2068 } else if (buf[index] == OPERCHAN_ATTR_ID) {
2069 op_channel_attr_index = index;
2070 }
2071 index += buf[index + 1] + 3; /* ID,Length byte */
2072 }
2073
2074 #ifdef USE_SUPPLICANT_GO_INTENT
2075 if (u8WLANChannel != INVALID_CHANNEL && is_wilc_go)
2076 #else
2077 if (u8WLANChannel != INVALID_CHANNEL)
2078 #endif
2079 {
2080 /*Modify channel list attribute*/
2081 if (channel_list_attr_index) {
2082 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
2083 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
2084 if (buf[i] == 0x51) {
2085 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
2086 buf[j] = u8WLANChannel;
2087 }
2088 break;
2089 }
2090 }
2091 }
2092 /*Modify operating channel attribute*/
2093 if (op_channel_attr_index) {
2094 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
2095 buf[op_channel_attr_index + 6] = 0x51;
2096 buf[op_channel_attr_index + 7] = u8WLANChannel;
2097 }
2098 }
2099 }
2100
2101 /**
2102 * @brief WILC_WFI_CfgParseTxAction
2103 * @details Function parses the transmitted action frames and modifies the
2104 * GO Intent attribute
2105 * @param[in] u8* Buffer, u32 length, bool bOperChan, u8 iftype
2106 * @return NONE.
2107 * @author mdaftedar
2108 * @date 12 DEC 2012
2109 * @version
2110 */
2111 void WILC_WFI_CfgParseTxAction(u8 *buf, u32 len, bool bOperChan, u8 iftype)
2112 {
2113 u32 index = 0;
2114 u32 i = 0, j = 0;
2115
2116 u8 op_channel_attr_index = 0;
2117 u8 channel_list_attr_index = 0;
2118 #ifdef USE_SUPPLICANT_GO_INTENT
2119 bool is_wilc_go = false;
2120
2121 /*BugID_5460*/
2122 /*Case 1: If we are already p2p client, no need to modify channels attributes*/
2123 /*This to handle the case of inviting a p2p peer to join an existing group which we are a member in*/
2124 if (iftype == CLIENT_MODE)
2125 return;
2126 #endif
2127
2128 while (index < len) {
2129 #ifdef USE_SUPPLICANT_GO_INTENT
2130 /*Case 2: If group bssid attribute is present, no need to modify channels attributes*/
2131 /*In invitation req and rsp, group bssid attr presence determines who will be GO*/
2132 /*Note: If we are already p2p client, group bssid attr may also be present (handled in Case 1)*/
2133 if (buf[index] == GROUP_BSSID_ATTR_ID) {
2134 PRINT_D(GENERIC_DBG, "Group BSSID: %2x:%2x:%2x\n", buf[index + 3]
2135 , buf[index + 4]
2136 , buf[index + 5]);
2137 is_wilc_go = true;
2138 }
2139
2140 #else /* USE_SUPPLICANT_GO_INTENT */
2141 if (buf[index] == GO_INTENT_ATTR_ID) {
2142 #ifdef FORCE_P2P_CLIENT
2143 buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1);
2144 #else
2145 buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1);
2146 #endif
2147
2148 break;
2149 }
2150 #endif
2151
2152 if (buf[index] == CHANLIST_ATTR_ID) {
2153 channel_list_attr_index = index;
2154 } else if (buf[index] == OPERCHAN_ATTR_ID) {
2155 op_channel_attr_index = index;
2156 }
2157 index += buf[index + 1] + 3; /* ID,Length byte */
2158 }
2159
2160 #ifdef USE_SUPPLICANT_GO_INTENT
2161 /*No need to check bOperChan since only transmitted invitation frames are parsed*/
2162 if (u8WLANChannel != INVALID_CHANNEL && is_wilc_go)
2163 #else
2164 if (u8WLANChannel != INVALID_CHANNEL && bOperChan)
2165 #endif
2166 {
2167 /*Modify channel list attribute*/
2168 if (channel_list_attr_index) {
2169 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
2170 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
2171 if (buf[i] == 0x51) {
2172 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
2173 buf[j] = u8WLANChannel;
2174 }
2175 break;
2176 }
2177 }
2178 }
2179 /*Modify operating channel attribute*/
2180 if (op_channel_attr_index) {
2181 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
2182 buf[op_channel_attr_index + 6] = 0x51;
2183 buf[op_channel_attr_index + 7] = u8WLANChannel;
2184 }
2185 }
2186 }
2187
2188 /* @brief WILC_WFI_p2p_rx
2189 * @details
2190 * @param[in]
2191 *
2192 * @return None
2193 * @author Mai Daftedar
2194 * @date 2 JUN 2013
2195 * @version 1.0
2196 */
2197
2198 void WILC_WFI_p2p_rx (struct net_device *dev, uint8_t *buff, uint32_t size)
2199 {
2200
2201 struct WILC_WFI_priv *priv;
2202 u32 header, pkt_offset;
2203 tstrWILC_WFIDrv *pstrWFIDrv;
2204 u32 i = 0;
2205 s32 s32Freq;
2206 priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
2207 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2208
2209 /* Get WILC header */
2210 WILC_memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
2211
2212 /* The packet offset field conain info about what type of managment frame */
2213 /* we are dealing with and ack status */
2214 pkt_offset = GET_PKT_OFFSET(header);
2215
2216 if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
2217 if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP) {
2218 PRINT_D(GENERIC_DBG, "Probe response ACK\n");
2219 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
2220 return;
2221 } else {
2222 if (pkt_offset & IS_MGMT_STATUS_SUCCES) {
2223 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],
2224 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
2225 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
2226 } else {
2227 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],
2228 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
2229 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, false, GFP_KERNEL);
2230 }
2231 return;
2232 }
2233 } else {
2234
2235 PRINT_D(GENERIC_DBG, "Rx Frame Type:%x\n", buff[FRAME_TYPE_ID]);
2236
2237 /*BugID_5442*/
2238 /*Upper layer is informed that the frame is received on this freq*/
2239 s32Freq = ieee80211_channel_to_frequency(u8CurrChannel, IEEE80211_BAND_2GHZ);
2240
2241 if (ieee80211_is_action(buff[FRAME_TYPE_ID])) {
2242 PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]);
2243
2244 if (priv->bCfgScanning == true && time_after_eq(jiffies, (unsigned long)pstrWFIDrv->u64P2p_MgmtTimeout)) {
2245 PRINT_D(GENERIC_DBG, "Receiving action frames from wrong channels\n");
2246 return;
2247 }
2248 if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
2249
2250 switch (buff[ACTION_SUBTYPE_ID]) {
2251 case GAS_INTIAL_REQ:
2252 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buff[ACTION_SUBTYPE_ID]);
2253 break;
2254
2255 case GAS_INTIAL_RSP:
2256 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buff[ACTION_SUBTYPE_ID]);
2257 break;
2258
2259 case PUBLIC_ACT_VENDORSPEC:
2260 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2261 * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/
2262 if (!WILC_memcmp(u8P2P_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) {
2263 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
2264 if (!bWilc_ie) {
2265 for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) {
2266 if (!WILC_memcmp(u8P2P_vendorspec, &buff[i], 6)) {
2267 u8P2Precvrandom = buff[i + 6];
2268 bWilc_ie = true;
2269 PRINT_D(GENERIC_DBG, "WILC Vendor specific IE:%02x\n", u8P2Precvrandom);
2270 break;
2271 }
2272 }
2273 }
2274 }
2275 if (u8P2Plocalrandom > u8P2Precvrandom) {
2276 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
2277 || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
2278 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) {
2279 if (buff[i] == P2PELEM_ATTR_ID && !(WILC_memcmp(u8P2P_oui, &buff[i + 2], 4))) {
2280 WILC_WFI_CfgParseRxAction(&buff[i + 6], size - (i + 6));
2281 break;
2282 }
2283 }
2284 }
2285 } else
2286 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2287 }
2288
2289
2290 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP) && (bWilc_ie)) {
2291 PRINT_D(GENERIC_DBG, "Sending P2P to host without extra elemnt\n");
2292 /* extra attribute for sig_dbm: signal strength in mBm, or 0 if unknown */
2293 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
2294 return;
2295 }
2296 break;
2297
2298 default:
2299 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff[ACTION_SUBTYPE_ID]);
2300 break;
2301 }
2302 }
2303 }
2304
2305 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
2306 }
2307 }
2308
2309 /**
2310 * @brief WILC_WFI_mgmt_tx_complete
2311 * @details Returns result of writing mgmt frame to VMM (Tx buffers are freed here)
2312 * @param[in] priv
2313 * transmitting status
2314 * @return None
2315 * @author Amr Abdelmoghny
2316 * @date 20 MAY 2013
2317 * @version 1.0
2318 */
2319 static void WILC_WFI_mgmt_tx_complete(void *priv, int status)
2320 {
2321 struct p2p_mgmt_data *pv_data = (struct p2p_mgmt_data *)priv;
2322
2323
2324 kfree(pv_data->buff);
2325 kfree(pv_data);
2326 }
2327
2328 /**
2329 * @brief WILC_WFI_RemainOnChannelReady
2330 * @details Callback function, called from handle_remain_on_channel on being ready on channel
2331 * @param
2332 * @return none
2333 * @author Amr abdelmoghny
2334 * @date 9 JUNE 2013
2335 * @version
2336 */
2337
2338 static void WILC_WFI_RemainOnChannelReady(void *pUserVoid)
2339 {
2340 struct WILC_WFI_priv *priv;
2341 priv = (struct WILC_WFI_priv *)pUserVoid;
2342
2343 PRINT_D(HOSTINF_DBG, "Remain on channel ready \n");
2344
2345 priv->bInP2PlistenState = true;
2346
2347 cfg80211_ready_on_channel(priv->wdev,
2348 priv->strRemainOnChanParams.u64ListenCookie,
2349 priv->strRemainOnChanParams.pstrListenChan,
2350 priv->strRemainOnChanParams.u32ListenDuration,
2351 GFP_KERNEL);
2352 }
2353
2354 /**
2355 * @brief WILC_WFI_RemainOnChannelExpired
2356 * @details Callback function, called on expiration of remain-on-channel duration
2357 * @param
2358 * @return none
2359 * @author Amr abdelmoghny
2360 * @date 15 MAY 2013
2361 * @version
2362 */
2363
2364 static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, u32 u32SessionID)
2365 {
2366 struct WILC_WFI_priv *priv;
2367 priv = (struct WILC_WFI_priv *)pUserVoid;
2368
2369 /*BugID_5477*/
2370 if (u32SessionID == priv->strRemainOnChanParams.u32ListenSessionID) {
2371 PRINT_D(GENERIC_DBG, "Remain on channel expired \n");
2372
2373 priv->bInP2PlistenState = false;
2374
2375 /*Inform wpas of remain-on-channel expiration*/
2376 cfg80211_remain_on_channel_expired(priv->wdev,
2377 priv->strRemainOnChanParams.u64ListenCookie,
2378 priv->strRemainOnChanParams.pstrListenChan,
2379 GFP_KERNEL);
2380 } else {
2381 PRINT_D(GENERIC_DBG, "Received ID 0x%x Expected ID 0x%x (No match)\n", u32SessionID
2382 , priv->strRemainOnChanParams.u32ListenSessionID);
2383 }
2384 }
2385
2386
2387 /**
2388 * @brief WILC_WFI_remain_on_channel
2389 * @details Request the driver to remain awake on the specified
2390 * channel for the specified duration to complete an off-channel
2391 * operation (e.g., public action frame exchange). When the driver is
2392 * ready on the requested channel, it must indicate this with an event
2393 * notification by calling cfg80211_ready_on_channel().
2394 * @param[in]
2395 * @return int : Return 0 on Success
2396 * @author mdaftedar
2397 * @date 01 MAR 2012
2398 * @version 1.0
2399 */
2400 static int WILC_WFI_remain_on_channel(struct wiphy *wiphy,
2401 struct wireless_dev *wdev,
2402 struct ieee80211_channel *chan,
2403 unsigned int duration, u64 *cookie)
2404 {
2405 s32 s32Error = WILC_SUCCESS;
2406 struct WILC_WFI_priv *priv;
2407 priv = wiphy_priv(wiphy);
2408
2409 PRINT_D(GENERIC_DBG, "Remaining on channel %d\n", chan->hw_value);
2410
2411 /*BugID_4800: if in AP mode, return.*/
2412 /*This check is to handle the situation when user*/
2413 /*requests "create group" during a running scan*/
2414
2415 if (wdev->iftype == NL80211_IFTYPE_AP) {
2416 PRINT_D(GENERIC_DBG, "Required remain-on-channel while in AP mode");
2417 return s32Error;
2418 }
2419
2420 u8CurrChannel = chan->hw_value;
2421
2422 /*Setting params needed by WILC_WFI_RemainOnChannelExpired()*/
2423 priv->strRemainOnChanParams.pstrListenChan = chan;
2424 priv->strRemainOnChanParams.u64ListenCookie = *cookie;
2425 priv->strRemainOnChanParams.u32ListenDuration = duration;
2426 priv->strRemainOnChanParams.u32ListenSessionID++;
2427
2428 s32Error = host_int_remain_on_channel(priv->hWILCWFIDrv
2429 , priv->strRemainOnChanParams.u32ListenSessionID
2430 , duration
2431 , chan->hw_value
2432 , WILC_WFI_RemainOnChannelExpired
2433 , WILC_WFI_RemainOnChannelReady
2434 , (void *)priv);
2435
2436 return s32Error;
2437 }
2438
2439 /**
2440 * @brief WILC_WFI_cancel_remain_on_channel
2441 * @details Cancel an on-going remain-on-channel operation.
2442 * This allows the operation to be terminated prior to timeout based on
2443 * the duration value.
2444 * @param[in] struct wiphy *wiphy,
2445 * @param[in] struct net_device *dev
2446 * @param[in] u64 cookie,
2447 * @return int : Return 0 on Success
2448 * @author mdaftedar
2449 * @date 01 MAR 2012
2450 * @version 1.0
2451 */
2452 static int WILC_WFI_cancel_remain_on_channel(struct wiphy *wiphy,
2453 struct wireless_dev *wdev,
2454 u64 cookie)
2455 {
2456 s32 s32Error = WILC_SUCCESS;
2457 struct WILC_WFI_priv *priv;
2458 priv = wiphy_priv(wiphy);
2459
2460 PRINT_D(CFG80211_DBG, "Cancel remain on channel\n");
2461
2462 s32Error = host_int_ListenStateExpired(priv->hWILCWFIDrv, priv->strRemainOnChanParams.u32ListenSessionID);
2463 return s32Error;
2464 }
2465 /**
2466 * @brief WILC_WFI_add_wilcvendorspec
2467 * @details Adding WILC information elemet to allow two WILC devices to
2468 * identify each other and connect
2469 * @param[in] u8 * buf
2470 * @return void
2471 * @author mdaftedar
2472 * @date 01 JAN 2014
2473 * @version 1.0
2474 */
2475 void WILC_WFI_add_wilcvendorspec(u8 *buff)
2476 {
2477 WILC_memcpy(buff, u8P2P_vendorspec, sizeof(u8P2P_vendorspec));
2478 }
2479 /**
2480 * @brief WILC_WFI_mgmt_tx_frame
2481 * @details
2482 *
2483 * @param[in]
2484 * @return NONE.
2485 * @author mdaftedar
2486 * @date 01 JUL 2012
2487 * @version
2488 */
2489 extern linux_wlan_t *g_linux_wlan;
2490 extern bool bEnablePS;
2491 int WILC_WFI_mgmt_tx(struct wiphy *wiphy,
2492 struct wireless_dev *wdev,
2493 struct cfg80211_mgmt_tx_params *params,
2494 u64 *cookie)
2495 {
2496 struct ieee80211_channel *chan = params->chan;
2497 unsigned int wait = params->wait;
2498 const u8 *buf = params->buf;
2499 size_t len = params->len;
2500 const struct ieee80211_mgmt *mgmt;
2501 struct p2p_mgmt_data *mgmt_tx;
2502 struct WILC_WFI_priv *priv;
2503 s32 s32Error = WILC_SUCCESS;
2504 tstrWILC_WFIDrv *pstrWFIDrv;
2505 u32 i;
2506 perInterface_wlan_t *nic;
2507 u32 buf_len = len + sizeof(u8P2P_vendorspec) + sizeof(u8P2Plocalrandom);
2508
2509 nic = netdev_priv(wdev->netdev);
2510 priv = wiphy_priv(wiphy);
2511 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2512
2513 *cookie = (unsigned long)buf;
2514 priv->u64tx_cookie = *cookie;
2515 mgmt = (const struct ieee80211_mgmt *) buf;
2516
2517 if (ieee80211_is_mgmt(mgmt->frame_control)) {
2518
2519 /*mgmt frame allocation*/
2520 mgmt_tx = (struct p2p_mgmt_data *)WILC_MALLOC(sizeof(struct p2p_mgmt_data));
2521 if (mgmt_tx == NULL) {
2522 PRINT_ER("Failed to allocate memory for mgmt_tx structure\n");
2523 return WILC_FAIL;
2524 }
2525 mgmt_tx->buff = (char *)WILC_MALLOC(buf_len);
2526 if (mgmt_tx->buff == NULL) {
2527 PRINT_ER("Failed to allocate memory for mgmt_tx buff\n");
2528 return WILC_FAIL;
2529 }
2530 WILC_memcpy(mgmt_tx->buff, buf, len);
2531 mgmt_tx->size = len;
2532
2533
2534 if (ieee80211_is_probe_resp(mgmt->frame_control)) {
2535 PRINT_D(GENERIC_DBG, "TX: Probe Response\n");
2536 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2537 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2538 /*Save the current channel after we tune to it*/
2539 u8CurrChannel = chan->hw_value;
2540 } else if (ieee80211_is_action(mgmt->frame_control)) {
2541 PRINT_D(GENERIC_DBG, "ACTION FRAME:%x\n", (u16)mgmt->frame_control);
2542
2543
2544 /*BugID_4847*/
2545 if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
2546 /*BugID_4847*/
2547 /*Only set the channel, if not a negotiation confirmation frame
2548 * (If Negotiation confirmation frame, force it
2549 * to be transmitted on the same negotiation channel)*/
2550
2551 if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC ||
2552 buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) {
2553 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2554 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2555 /*Save the current channel after we tune to it*/
2556 u8CurrChannel = chan->hw_value;
2557 }
2558 switch (buf[ACTION_SUBTYPE_ID]) {
2559 case GAS_INTIAL_REQ:
2560 {
2561 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buf[ACTION_SUBTYPE_ID]);
2562 break;
2563 }
2564
2565 case GAS_INTIAL_RSP:
2566 {
2567 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buf[ACTION_SUBTYPE_ID]);
2568 break;
2569 }
2570
2571 case PUBLIC_ACT_VENDORSPEC:
2572 {
2573 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2574 * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/
2575 if (!WILC_memcmp(u8P2P_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) {
2576 /*For the connection of two WILC's connection generate a rand number to determine who will be a GO*/
2577 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
2578 if (u8P2Plocalrandom == 1 && u8P2Precvrandom < u8P2Plocalrandom) {
2579 get_random_bytes(&u8P2Plocalrandom, 1);
2580 /*Increment the number to prevent if its 0*/
2581 u8P2Plocalrandom++;
2582 }
2583 }
2584
2585 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
2586 || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
2587 if (u8P2Plocalrandom > u8P2Precvrandom) {
2588 PRINT_D(GENERIC_DBG, "LOCAL WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2589
2590 /*Search for the p2p information information element , after the Public action subtype theres a byte for teh dialog token, skip that*/
2591 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) {
2592 if (buf[i] == P2PELEM_ATTR_ID && !(WILC_memcmp(u8P2P_oui, &buf[i + 2], 4))) {
2593 if (buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)
2594 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), true, nic->iftype);
2595
2596 /*BugID_5460*/
2597 /*If using supplicant go intent, no need at all*/
2598 /*to parse transmitted negotiation frames*/
2599 #ifndef USE_SUPPLICANT_GO_INTENT
2600 else
2601 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), false, nic->iftype);
2602 #endif
2603 break;
2604 }
2605 }
2606
2607 if (buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_REQ && buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_RSP) {
2608 WILC_WFI_add_wilcvendorspec(&mgmt_tx->buff[len]);
2609 mgmt_tx->buff[len + sizeof(u8P2P_vendorspec)] = u8P2Plocalrandom;
2610 mgmt_tx->size = buf_len;
2611 }
2612 } else
2613 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2614 }
2615
2616 } else {
2617 PRINT_D(GENERIC_DBG, "Not a P2P public action frame\n");
2618 }
2619
2620 break;
2621 }
2622
2623 default:
2624 {
2625 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf[ACTION_SUBTYPE_ID]);
2626 break;
2627 }
2628 }
2629
2630 }
2631
2632 PRINT_D(GENERIC_DBG, "TX: ACTION FRAME Type:%x : Chan:%d\n", buf[ACTION_SUBTYPE_ID], chan->hw_value);
2633 pstrWFIDrv->u64P2p_MgmtTimeout = (jiffies + msecs_to_jiffies(wait));
2634
2635 PRINT_D(GENERIC_DBG, "Current Jiffies: %lu Timeout:%llu\n", jiffies, pstrWFIDrv->u64P2p_MgmtTimeout);
2636
2637 }
2638
2639 g_linux_wlan->oup.wlan_add_mgmt_to_tx_que(mgmt_tx, mgmt_tx->buff, mgmt_tx->size, WILC_WFI_mgmt_tx_complete);
2640 } else {
2641 PRINT_D(GENERIC_DBG, "This function transmits only management frames\n");
2642 }
2643 return s32Error;
2644 }
2645
2646 int WILC_WFI_mgmt_tx_cancel_wait(struct wiphy *wiphy,
2647 struct wireless_dev *wdev,
2648 u64 cookie)
2649 {
2650 struct WILC_WFI_priv *priv;
2651 tstrWILC_WFIDrv *pstrWFIDrv;
2652 priv = wiphy_priv(wiphy);
2653 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2654
2655
2656 PRINT_D(GENERIC_DBG, "Tx Cancel wait :%lu\n", jiffies);
2657 pstrWFIDrv->u64P2p_MgmtTimeout = jiffies;
2658
2659 if (priv->bInP2PlistenState == false) {
2660 /* Bug 5504: This is just to avoid connection failure when getting stuck when the supplicant
2661 * considers the driver falsely that it is in Listen state */
2662 cfg80211_remain_on_channel_expired(priv->wdev,
2663 priv->strRemainOnChanParams.u64ListenCookie,
2664 priv->strRemainOnChanParams.pstrListenChan,
2665 GFP_KERNEL);
2666 }
2667
2668 return 0;
2669 }
2670
2671 /**
2672 * @brief WILC_WFI_frame_register
2673 * @details Notify driver that a management frame type was
2674 * registered. Note that this callback may not sleep, and cannot run
2675 * concurrently with itself.
2676 * @param[in]
2677 * @return NONE.
2678 * @author mdaftedar
2679 * @date 01 JUL 2012
2680 * @version
2681 */
2682 void WILC_WFI_frame_register(struct wiphy *wiphy,
2683 struct wireless_dev *wdev,
2684 u16 frame_type, bool reg)
2685 {
2686
2687 struct WILC_WFI_priv *priv;
2688 perInterface_wlan_t *nic;
2689
2690
2691 priv = wiphy_priv(wiphy);
2692 nic = netdev_priv(priv->wdev->netdev);
2693
2694
2695
2696 /*BugID_5137*/
2697 if (!frame_type)
2698 return;
2699
2700 PRINT_D(GENERIC_DBG, "Frame registering Frame Type: %x: Boolean: %d\n", frame_type, reg);
2701 switch (frame_type) {
2702 case PROBE_REQ:
2703 {
2704 nic->g_struct_frame_reg[0].frame_type = frame_type;
2705 nic->g_struct_frame_reg[0].reg = reg;
2706 }
2707 break;
2708
2709 case ACTION:
2710 {
2711 nic->g_struct_frame_reg[1].frame_type = frame_type;
2712 nic->g_struct_frame_reg[1].reg = reg;
2713 }
2714 break;
2715
2716 default:
2717 {
2718 break;
2719 }
2720
2721 }
2722 /*If mac is closed, then return*/
2723 if (!g_linux_wlan->wilc1000_initialized) {
2724 PRINT_D(GENERIC_DBG, "Return since mac is closed\n");
2725 return;
2726 }
2727 host_int_frame_register(priv->hWILCWFIDrv, frame_type, reg);
2728
2729
2730 }
2731 #endif /*WILC_P2P*/
2732
2733 /**
2734 * @brief WILC_WFI_set_cqm_rssi_config
2735 * @details Configure connection quality monitor RSSI threshold.
2736 * @param[in] struct wiphy *wiphy:
2737 * @param[in] struct net_device *dev:
2738 * @param[in] s32 rssi_thold:
2739 * @param[in] u32 rssi_hyst:
2740 * @return int : Return 0 on Success
2741 * @author mdaftedar
2742 * @date 01 MAR 2012
2743 * @version 1.0
2744 */
2745 static int WILC_WFI_set_cqm_rssi_config(struct wiphy *wiphy,
2746 struct net_device *dev, s32 rssi_thold, u32 rssi_hyst)
2747 {
2748 PRINT_D(CFG80211_DBG, "Setting CQM RSSi Function\n");
2749 return 0;
2750
2751 }
2752 /**
2753 * @brief WILC_WFI_dump_station
2754 * @details Configure connection quality monitor RSSI threshold.
2755 * @param[in] struct wiphy *wiphy:
2756 * @param[in] struct net_device *dev
2757 * @param[in] int idx
2758 * @param[in] u8 *mac
2759 * @param[in] struct station_info *sinfo
2760 * @return int : Return 0 on Success
2761 * @author mdaftedar
2762 * @date 01 MAR 2012
2763 * @version 1.0
2764 */
2765 static int WILC_WFI_dump_station(struct wiphy *wiphy, struct net_device *dev,
2766 int idx, u8 *mac, struct station_info *sinfo)
2767 {
2768 struct WILC_WFI_priv *priv;
2769 PRINT_D(CFG80211_DBG, "Dumping station information\n");
2770
2771 if (idx != 0)
2772 return -ENOENT;
2773
2774 priv = wiphy_priv(wiphy);
2775
2776 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
2777
2778 host_int_get_rssi(priv->hWILCWFIDrv, &(sinfo->signal));
2779
2780 return 0;
2781
2782 }
2783
2784
2785 /**
2786 * @brief WILC_WFI_set_power_mgmt
2787 * @details
2788 * @param[in]
2789 * @return int : Return 0 on Success.
2790 * @author mdaftedar
2791 * @date 01 JUL 2012
2792 * @version 1.0WILC_WFI_set_cqmWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_config_rssi_config
2793 */
2794 int WILC_WFI_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2795 bool enabled, int timeout)
2796 {
2797 struct WILC_WFI_priv *priv;
2798 PRINT_D(CFG80211_DBG, " Power save Enabled= %d , TimeOut = %d\n", enabled, timeout);
2799
2800 if (wiphy == NULL)
2801 return -ENOENT;
2802
2803 priv = wiphy_priv(wiphy);
2804 if (priv->hWILCWFIDrv == NULL) {
2805 PRINT_ER("Driver is NULL\n");
2806 return -EIO;
2807 }
2808
2809 if (bEnablePS)
2810 host_int_set_power_mgmt(priv->hWILCWFIDrv, enabled, timeout);
2811
2812
2813 return WILC_SUCCESS;
2814
2815 }
2816 #ifdef WILC_AP_EXTERNAL_MLME
2817 /**
2818 * @brief WILC_WFI_change_virt_intf
2819 * @details Change type/configuration of virtual interface,
2820 * keep the struct wireless_dev's iftype updated.
2821 * @param[in] NONE
2822 * @return int : Return 0 on Success.
2823 * @author mdaftedar
2824 * @date 01 MAR 2012
2825 * @version 1.0
2826 */
2827 void wilc1000_wlan_deinit(linux_wlan_t *nic);
2828 int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic);
2829
2830 static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev,
2831 enum nl80211_iftype type, u32 *flags, struct vif_params *params)
2832 {
2833 s32 s32Error = WILC_SUCCESS;
2834 struct WILC_WFI_priv *priv;
2835 perInterface_wlan_t *nic;
2836 u8 interface_type;
2837 u16 TID = 0;
2838 #ifdef WILC_P2P
2839 u8 i;
2840 #endif
2841
2842 nic = netdev_priv(dev);
2843 priv = wiphy_priv(wiphy);
2844
2845 PRINT_D(HOSTAPD_DBG, "In Change virtual interface function\n");
2846 PRINT_D(HOSTAPD_DBG, "Wireless interface name =%s\n", dev->name);
2847 u8P2Plocalrandom = 0x01;
2848 u8P2Precvrandom = 0x00;
2849
2850 bWilc_ie = false;
2851
2852 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2853 g_obtainingIP = false;
2854 WILC_TimerStop(&hDuringIpTimer, NULL);
2855 PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n");
2856 #endif
2857 /*BugID_5137*/
2858 /*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to CE H/W*/
2859 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2860 Set_machw_change_vir_if(true);
2861 }
2862
2863 switch (type) {
2864 case NL80211_IFTYPE_STATION:
2865 connecting = 0;
2866 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_STATION\n");
2867
2868 /* send delba over wlan interface */
2869
2870
2871 dev->ieee80211_ptr->iftype = type;
2872 priv->wdev->iftype = type;
2873 nic->monitor_flag = 0;
2874 nic->iftype = STATION_MODE;
2875
2876 /*Remove the enteries of the previously connected clients*/
2877 memset(priv->assoc_stainfo.au8Sta_AssociatedBss, 0, MAX_NUM_STA * ETH_ALEN);
2878 #ifndef SIMULATION
2879 #ifdef WILC_P2P
2880 interface_type = nic->iftype;
2881 nic->iftype = STATION_MODE;
2882
2883 if (g_linux_wlan->wilc1000_initialized) {
2884 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
2885 /* ensure that the message Q is empty */
2886 host_int_wait_msg_queue_idle();
2887
2888 /*BugID_5213*/
2889 /*Eliminate host interface blocking state*/
2890 linux_wlan_unlock((void *)&g_linux_wlan->cfg_event);
2891
2892 wilc1000_wlan_deinit(g_linux_wlan);
2893 wilc1000_wlan_init(dev, nic);
2894 g_wilc_initialized = 1;
2895 nic->iftype = interface_type;
2896
2897 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
2898 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
2899 host_int_set_MacAddress((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
2900 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
2901 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2902
2903 /*Add saved WEP keys, if any*/
2904 if (g_wep_keys_saved) {
2905 host_int_set_WEPDefaultKeyID((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
2906 g_key_wep_params.key_idx);
2907 host_int_add_wep_key_bss_sta((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
2908 g_key_wep_params.key,
2909 g_key_wep_params.key_len,
2910 g_key_wep_params.key_idx);
2911 }
2912
2913 /*No matter the driver handler passed here, it will be overwriiten*/
2914 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2915 host_int_flush_join_req(priv->hWILCWFIDrv);
2916
2917 /*Add saved PTK and GTK keys, if any*/
2918 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2919 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
2920 g_key_ptk_params.key[1],
2921 g_key_ptk_params.key[2]);
2922 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
2923 g_key_gtk_params.key[1],
2924 g_key_gtk_params.key[2]);
2925 WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2926 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2927 g_add_ptk_key_params.key_idx,
2928 g_add_ptk_key_params.pairwise,
2929 g_add_ptk_key_params.mac_addr,
2930 (struct key_params *)(&g_key_ptk_params));
2931
2932 WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2933 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2934 g_add_gtk_key_params.key_idx,
2935 g_add_gtk_key_params.pairwise,
2936 g_add_gtk_key_params.mac_addr,
2937 (struct key_params *)(&g_key_gtk_params));
2938 }
2939
2940 /*BugID_4847: registered frames in firmware are now*/
2941 /*lost due to mac close. So re-register those frames*/
2942 if (g_linux_wlan->wilc1000_initialized) {
2943 for (i = 0; i < num_reg_frame; i++) {
2944 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2945 nic->g_struct_frame_reg[i].reg);
2946 host_int_frame_register(priv->hWILCWFIDrv,
2947 nic->g_struct_frame_reg[i].frame_type,
2948 nic->g_struct_frame_reg[i].reg);
2949 }
2950 }
2951
2952 bEnablePS = true;
2953 host_int_set_power_mgmt(priv->hWILCWFIDrv, 1, 0);
2954 }
2955 #endif
2956 #endif
2957 break;
2958
2959 case NL80211_IFTYPE_P2P_CLIENT:
2960 bEnablePS = false;
2961 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
2962 connecting = 0;
2963 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n");
2964
2965 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
2966
2967 dev->ieee80211_ptr->iftype = type;
2968 priv->wdev->iftype = type;
2969 nic->monitor_flag = 0;
2970
2971 #ifndef SIMULATION
2972 #ifdef WILC_P2P
2973
2974 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
2975 nic->iftype = CLIENT_MODE;
2976
2977
2978 if (g_linux_wlan->wilc1000_initialized) {
2979 /* ensure that the message Q is empty */
2980 host_int_wait_msg_queue_idle();
2981
2982 wilc1000_wlan_deinit(g_linux_wlan);
2983 wilc1000_wlan_init(dev, nic);
2984 g_wilc_initialized = 1;
2985
2986 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
2987 host_int_set_MacAddress((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
2988 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
2989 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2990
2991 /*Add saved WEP keys, if any*/
2992 if (g_wep_keys_saved) {
2993 host_int_set_WEPDefaultKeyID((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
2994 g_key_wep_params.key_idx);
2995 host_int_add_wep_key_bss_sta((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
2996 g_key_wep_params.key,
2997 g_key_wep_params.key_len,
2998 g_key_wep_params.key_idx);
2999 }
3000
3001 /*No matter the driver handler passed here, it will be overwriiten*/
3002 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
3003 host_int_flush_join_req(priv->hWILCWFIDrv);
3004
3005 /*Add saved PTK and GTK keys, if any*/
3006 if (g_ptk_keys_saved && g_gtk_keys_saved) {
3007 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
3008 g_key_ptk_params.key[1],
3009 g_key_ptk_params.key[2]);
3010 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
3011 g_key_gtk_params.key[1],
3012 g_key_gtk_params.key[2]);
3013 WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3014 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3015 g_add_ptk_key_params.key_idx,
3016 g_add_ptk_key_params.pairwise,
3017 g_add_ptk_key_params.mac_addr,
3018 (struct key_params *)(&g_key_ptk_params));
3019
3020 WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3021 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3022 g_add_gtk_key_params.key_idx,
3023 g_add_gtk_key_params.pairwise,
3024 g_add_gtk_key_params.mac_addr,
3025 (struct key_params *)(&g_key_gtk_params));
3026 }
3027
3028 /*Refresh scan, to refresh the scan results to the wpa_supplicant. Set MachHw to false to enable further key installments*/
3029 refresh_scan(priv, 1, true);
3030 Set_machw_change_vir_if(false);
3031
3032 /*BugID_4847: registered frames in firmware are now lost
3033 * due to mac close. So re-register those frames */
3034 if (g_linux_wlan->wilc1000_initialized) {
3035 for (i = 0; i < num_reg_frame; i++) {
3036 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
3037 nic->g_struct_frame_reg[i].reg);
3038 host_int_frame_register(priv->hWILCWFIDrv,
3039 nic->g_struct_frame_reg[i].frame_type,
3040 nic->g_struct_frame_reg[i].reg);
3041 }
3042 }
3043 }
3044 #endif
3045 #endif
3046 break;
3047
3048 case NL80211_IFTYPE_AP:
3049 bEnablePS = false;
3050 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_AP %d\n", type);
3051 dev->ieee80211_ptr->iftype = type;
3052 priv->wdev->iftype = type;
3053 nic->iftype = AP_MODE;
3054 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
3055
3056 #ifndef SIMULATION
3057 PRINT_D(HOSTAPD_DBG, "Downloading AP firmware\n");
3058 linux_wlan_get_firmware(nic);
3059 #ifdef WILC_P2P
3060 /*If wilc is running, then close-open to actually get new firmware running (serves P2P)*/
3061 if (g_linux_wlan->wilc1000_initialized) {
3062 nic->iftype = AP_MODE;
3063 g_linux_wlan->wilc1000_initialized = 1;
3064 mac_close(dev);
3065 mac_open(dev);
3066
3067 /*BugID_4847: registered frames in firmware are now lost
3068 * due to mac close. So re-register those frames */
3069 for (i = 0; i < num_reg_frame; i++) {
3070 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
3071 nic->g_struct_frame_reg[i].reg);
3072 host_int_frame_register(priv->hWILCWFIDrv,
3073 nic->g_struct_frame_reg[i].frame_type,
3074 nic->g_struct_frame_reg[i].reg);
3075 }
3076 }
3077 #endif
3078 #endif
3079 break;
3080
3081 case NL80211_IFTYPE_P2P_GO:
3082 PRINT_D(GENERIC_DBG, "start duringIP timer\n");
3083
3084 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3085 g_obtainingIP = true;
3086 WILC_TimerStart(&hDuringIpTimer, duringIP_TIME, NULL, NULL);
3087 #endif
3088 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
3089 /*BugID_5222*/
3090 /*Delete block ack has to be the latest config packet*/
3091 /*sent before downloading new FW. This is because it blocks on*/
3092 /*hWaitResponse semaphore, which allows previous config*/
3093 /*packets to actually take action on old FW*/
3094 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
3095 bEnablePS = false;
3096 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n");
3097 dev->ieee80211_ptr->iftype = type;
3098 priv->wdev->iftype = type;
3099
3100 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
3101
3102 #ifndef SIMULATION
3103 #ifdef WILC_P2P
3104 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
3105
3106
3107 #if 1
3108 nic->iftype = GO_MODE;
3109
3110 /* ensure that the message Q is empty */
3111 host_int_wait_msg_queue_idle();
3112 wilc1000_wlan_deinit(g_linux_wlan);
3113 wilc1000_wlan_init(dev, nic);
3114 g_wilc_initialized = 1;
3115
3116
3117 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
3118 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
3119 host_int_set_MacAddress((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
3120 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
3121 host_int_set_operation_mode(priv->hWILCWFIDrv, AP_MODE);
3122
3123 /*Add saved WEP keys, if any*/
3124 if (g_wep_keys_saved) {
3125 host_int_set_WEPDefaultKeyID((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
3126 g_key_wep_params.key_idx);
3127 host_int_add_wep_key_bss_sta((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
3128 g_key_wep_params.key,
3129 g_key_wep_params.key_len,
3130 g_key_wep_params.key_idx);
3131 }
3132
3133 /*No matter the driver handler passed here, it will be overwriiten*/
3134 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
3135 host_int_flush_join_req(priv->hWILCWFIDrv);
3136
3137 /*Add saved PTK and GTK keys, if any*/
3138 if (g_ptk_keys_saved && g_gtk_keys_saved) {
3139 PRINT_D(CFG80211_DBG, "ptk %x %x %x cipher %x\n", g_key_ptk_params.key[0],
3140 g_key_ptk_params.key[1],
3141 g_key_ptk_params.key[2],
3142 g_key_ptk_params.cipher);
3143 PRINT_D(CFG80211_DBG, "gtk %x %x %x cipher %x\n", g_key_gtk_params.key[0],
3144 g_key_gtk_params.key[1],
3145 g_key_gtk_params.key[2],
3146 g_key_gtk_params.cipher);
3147 #if 1
3148 WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3149 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3150 g_add_ptk_key_params.key_idx,
3151 g_add_ptk_key_params.pairwise,
3152 g_add_ptk_key_params.mac_addr,
3153 (struct key_params *)(&g_key_ptk_params));
3154
3155 WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3156 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3157 g_add_gtk_key_params.key_idx,
3158 g_add_gtk_key_params.pairwise,
3159 g_add_gtk_key_params.mac_addr,
3160 (struct key_params *)(&g_key_gtk_params));
3161 #endif
3162 }
3163 #endif
3164
3165 /*BugID_4847: registered frames in firmware are now*/
3166 /*lost due to mac close. So re-register those frames*/
3167 if (g_linux_wlan->wilc1000_initialized) {
3168 for (i = 0; i < num_reg_frame; i++) {
3169 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
3170 nic->g_struct_frame_reg[i].reg);
3171 host_int_frame_register(priv->hWILCWFIDrv,
3172 nic->g_struct_frame_reg[i].frame_type,
3173 nic->g_struct_frame_reg[i].reg);
3174 }
3175 }
3176 #endif
3177 #endif
3178 break;
3179
3180 default:
3181 PRINT_ER("Unknown interface type= %d\n", type);
3182 s32Error = -EINVAL;
3183 return s32Error;
3184 break;
3185 }
3186
3187 return s32Error;
3188 }
3189
3190 /* (austin.2013-07-23)
3191 *
3192 * To support revised cfg80211_ops
3193 *
3194 * add_beacon --> start_ap
3195 * set_beacon --> change_beacon
3196 * del_beacon --> stop_ap
3197 *
3198 * beacon_parameters --> cfg80211_ap_settings
3199 * cfg80211_beacon_data
3200 *
3201 * applicable for linux kernel 3.4+
3202 */
3203
3204 /**
3205 * @brief WILC_WFI_start_ap
3206 * @details Add a beacon with given parameters, @head, @interval
3207 * and @dtim_period will be valid, @tail is optional.
3208 * @param[in] wiphy
3209 * @param[in] dev The net device structure
3210 * @param[in] settings cfg80211_ap_settings parameters for the beacon to be added
3211 * @return int : Return 0 on Success.
3212 * @author austin
3213 * @date 23 JUL 2013
3214 * @version 1.0
3215 */
3216 static int WILC_WFI_start_ap(struct wiphy *wiphy, struct net_device *dev,
3217 struct cfg80211_ap_settings *settings)
3218 {
3219 struct cfg80211_beacon_data *beacon = &(settings->beacon);
3220 struct WILC_WFI_priv *priv;
3221 s32 s32Error = WILC_SUCCESS;
3222
3223 priv = wiphy_priv(wiphy);
3224 PRINT_D(HOSTAPD_DBG, "Starting ap\n");
3225
3226 PRINT_D(HOSTAPD_DBG, "Interval = %d \n DTIM period = %d\n Head length = %zu Tail length = %zu\n",
3227 settings->beacon_interval, settings->dtim_period, beacon->head_len, beacon->tail_len);
3228
3229 s32Error = WILC_WFI_CfgSetChannel(wiphy, &settings->chandef);
3230
3231 if (s32Error != WILC_SUCCESS)
3232 PRINT_ER("Error in setting channel\n");
3233
3234 linux_wlan_set_bssid(dev, g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
3235
3236 #ifndef WILC_FULLY_HOSTING_AP
3237 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
3238 settings->beacon_interval,
3239 settings->dtim_period,
3240 beacon->head_len, (u8 *)beacon->head,
3241 beacon->tail_len, (u8 *)beacon->tail);
3242 #else
3243 s32Error = host_add_beacon(priv->hWILCWFIDrv,
3244 settings->beacon_interval,
3245 settings->dtim_period,
3246 beacon->head_len, (u8 *)beacon->head,
3247 beacon->tail_len, (u8 *)beacon->tail);
3248 #endif
3249
3250 return s32Error;
3251 }
3252
3253 /**
3254 * @brief WILC_WFI_change_beacon
3255 * @details Add a beacon with given parameters, @head, @interval
3256 * and @dtim_period will be valid, @tail is optional.
3257 * @param[in] wiphy
3258 * @param[in] dev The net device structure
3259 * @param[in] beacon cfg80211_beacon_data for the beacon to be changed
3260 * @return int : Return 0 on Success.
3261 * @author austin
3262 * @date 23 JUL 2013
3263 * @version 1.0
3264 */
3265 static int WILC_WFI_change_beacon(struct wiphy *wiphy, struct net_device *dev,
3266 struct cfg80211_beacon_data *beacon)
3267 {
3268 struct WILC_WFI_priv *priv;
3269 s32 s32Error = WILC_SUCCESS;
3270
3271 priv = wiphy_priv(wiphy);
3272 PRINT_D(HOSTAPD_DBG, "Setting beacon\n");
3273
3274
3275 #ifndef WILC_FULLY_HOSTING_AP
3276 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
3277 0,
3278 0,
3279 beacon->head_len, (u8 *)beacon->head,
3280 beacon->tail_len, (u8 *)beacon->tail);
3281 #else
3282 s32Error = host_add_beacon(priv->hWILCWFIDrv,
3283 0,
3284 0,
3285 beacon->head_len, (u8 *)beacon->head,
3286 beacon->tail_len, (u8 *)beacon->tail);
3287 #endif
3288
3289 return s32Error;
3290 }
3291
3292 /**
3293 * @brief WILC_WFI_stop_ap
3294 * @details Remove beacon configuration and stop sending the beacon.
3295 * @param[in]
3296 * @return int : Return 0 on Success.
3297 * @author austin
3298 * @date 23 JUL 2013
3299 * @version 1.0
3300 */
3301 static int WILC_WFI_stop_ap(struct wiphy *wiphy, struct net_device *dev)
3302 {
3303 s32 s32Error = WILC_SUCCESS;
3304 struct WILC_WFI_priv *priv;
3305 u8 NullBssid[ETH_ALEN] = {0};
3306
3307
3308 WILC_NULLCHECK(s32Error, wiphy);
3309
3310 priv = wiphy_priv(wiphy);
3311
3312 PRINT_D(HOSTAPD_DBG, "Deleting beacon\n");
3313
3314 /*BugID_5188*/
3315 linux_wlan_set_bssid(dev, NullBssid);
3316
3317 #ifndef WILC_FULLY_HOSTING_AP
3318 s32Error = host_int_del_beacon(priv->hWILCWFIDrv);
3319 #else
3320 s32Error = host_del_beacon(priv->hWILCWFIDrv);
3321 #endif
3322
3323 WILC_ERRORCHECK(s32Error);
3324
3325 WILC_CATCH(s32Error)
3326 {
3327 }
3328 return s32Error;
3329 }
3330
3331 /**
3332 * @brief WILC_WFI_add_station
3333 * @details Add a new station.
3334 * @param[in]
3335 * @return int : Return 0 on Success.
3336 * @author mdaftedar
3337 * @date 01 MAR 2012
3338 * @version 1.0
3339 */
3340 static int WILC_WFI_add_station(struct wiphy *wiphy, struct net_device *dev,
3341 const u8 *mac, struct station_parameters *params)
3342 {
3343 s32 s32Error = WILC_SUCCESS;
3344 struct WILC_WFI_priv *priv;
3345 tstrWILC_AddStaParam strStaParams = {{0}};
3346 perInterface_wlan_t *nic;
3347
3348
3349 WILC_NULLCHECK(s32Error, wiphy);
3350
3351 priv = wiphy_priv(wiphy);
3352 nic = netdev_priv(dev);
3353
3354 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3355 #ifndef WILC_FULLY_HOSTING_AP
3356
3357 WILC_memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
3358 WILC_memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN);
3359 strStaParams.u16AssocID = params->aid;
3360 strStaParams.u8NumRates = params->supported_rates_len;
3361 strStaParams.pu8Rates = params->supported_rates;
3362
3363 PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid);
3364
3365 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],
3366 priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]);
3367 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3368 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3369
3370 if (params->ht_capa == NULL) {
3371 strStaParams.bIsHTSupported = false;
3372 } else {
3373 strStaParams.bIsHTSupported = true;
3374 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3375 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
3376 WILC_memcpy(strStaParams.au8SuppMCsSet, &params->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
3377 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3378 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3379 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3380 }
3381
3382 strStaParams.u16FlagsMask = params->sta_flags_mask;
3383 strStaParams.u16FlagsSet = params->sta_flags_set;
3384
3385 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3386 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3387 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3388 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3389 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3390 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3391 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3392 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3393
3394 s32Error = host_int_add_station(priv->hWILCWFIDrv, &strStaParams);
3395 WILC_ERRORCHECK(s32Error);
3396
3397 #else
3398 PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid);
3399 WILC_memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN);
3400
3401 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],
3402 priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]);
3403
3404 WILC_AP_AddSta(mac, params);
3405 WILC_ERRORCHECK(s32Error);
3406 #endif /* WILC_FULLY_HOSTING_AP */
3407
3408 }
3409
3410 WILC_CATCH(s32Error)
3411 {
3412 }
3413 return s32Error;
3414 }
3415
3416 /**
3417 * @brief WILC_WFI_del_station
3418 * @details Remove a station; @mac may be NULL to remove all stations.
3419 * @param[in]
3420 * @return int : Return 0 on Success.
3421 * @author mdaftedar
3422 * @date 01 MAR 2012
3423 * @version 1.0
3424 */
3425 static int WILC_WFI_del_station(struct wiphy *wiphy, struct net_device *dev,
3426 struct station_del_parameters *params)
3427 {
3428 const u8 *mac = params->mac;
3429 s32 s32Error = WILC_SUCCESS;
3430 struct WILC_WFI_priv *priv;
3431 perInterface_wlan_t *nic;
3432 WILC_NULLCHECK(s32Error, wiphy);
3433
3434 priv = wiphy_priv(wiphy);
3435 nic = netdev_priv(dev);
3436
3437 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3438 PRINT_D(HOSTAPD_DBG, "Deleting station\n");
3439
3440
3441 if (mac == NULL) {
3442 PRINT_D(HOSTAPD_DBG, "All associated stations \n");
3443 s32Error = host_int_del_allstation(priv->hWILCWFIDrv, priv->assoc_stainfo.au8Sta_AssociatedBss);
3444 } else {
3445 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]);
3446 }
3447
3448 #ifndef WILC_FULLY_HOSTING_AP
3449 s32Error = host_int_del_station(priv->hWILCWFIDrv, mac);
3450 #else
3451 WILC_AP_RemoveSta(mac);
3452 #endif /* WILC_FULLY_HOSTING_AP */
3453
3454 WILC_ERRORCHECK(s32Error);
3455 }
3456 WILC_CATCH(s32Error)
3457 {
3458 }
3459 return s32Error;
3460 }
3461
3462 /**
3463 * @brief WILC_WFI_change_station
3464 * @details Modify a given station.
3465 * @param[in]
3466 * @return int : Return 0 on Success.
3467 * @author mdaftedar
3468 * @date 01 MAR 2012
3469 * @version 1.0
3470 */
3471 static int WILC_WFI_change_station(struct wiphy *wiphy, struct net_device *dev,
3472 const u8 *mac, struct station_parameters *params)
3473 {
3474 s32 s32Error = WILC_SUCCESS;
3475 struct WILC_WFI_priv *priv;
3476 tstrWILC_AddStaParam strStaParams = {{0}};
3477 perInterface_wlan_t *nic;
3478
3479
3480 PRINT_D(HOSTAPD_DBG, "Change station paramters\n");
3481
3482 WILC_NULLCHECK(s32Error, wiphy);
3483
3484 priv = wiphy_priv(wiphy);
3485 nic = netdev_priv(dev);
3486
3487 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3488 #ifndef WILC_FULLY_HOSTING_AP
3489
3490 WILC_memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
3491 strStaParams.u16AssocID = params->aid;
3492 strStaParams.u8NumRates = params->supported_rates_len;
3493 strStaParams.pu8Rates = params->supported_rates;
3494
3495 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],
3496 strStaParams.au8BSSID[5]);
3497 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3498 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3499
3500 if (params->ht_capa == NULL) {
3501 strStaParams.bIsHTSupported = false;
3502 } else {
3503 strStaParams.bIsHTSupported = true;
3504 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3505 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
3506 WILC_memcpy(strStaParams.au8SuppMCsSet, &params->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
3507 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3508 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3509 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3510
3511 }
3512
3513 strStaParams.u16FlagsMask = params->sta_flags_mask;
3514 strStaParams.u16FlagsSet = params->sta_flags_set;
3515
3516 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3517 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3518 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3519 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3520 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3521 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3522 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3523 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3524
3525 s32Error = host_int_edit_station(priv->hWILCWFIDrv, &strStaParams);
3526 WILC_ERRORCHECK(s32Error);
3527
3528 #else
3529 WILC_AP_EditSta(mac, params);
3530 WILC_ERRORCHECK(s32Error);
3531 #endif /* WILC_FULLY_HOSTING_AP */
3532
3533 }
3534 WILC_CATCH(s32Error)
3535 {
3536 }
3537 return s32Error;
3538 }
3539
3540
3541 /**
3542 * @brief WILC_WFI_add_virt_intf
3543 * @details
3544 * @param[in]
3545 * @return int : Return 0 on Success.
3546 * @author mdaftedar
3547 * @date 01 JUL 2012
3548 * @version 1.0
3549 */
3550 struct wireless_dev *WILC_WFI_add_virt_intf(struct wiphy *wiphy, const char *name,
3551 unsigned char name_assign_type,
3552 enum nl80211_iftype type, u32 *flags,
3553 struct vif_params *params)
3554 {
3555 perInterface_wlan_t *nic;
3556 struct WILC_WFI_priv *priv;
3557 struct net_device *new_ifc = NULL;
3558 priv = wiphy_priv(wiphy);
3559
3560
3561
3562 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", priv->wdev->netdev);
3563
3564 nic = netdev_priv(priv->wdev->netdev);
3565
3566
3567 if (type == NL80211_IFTYPE_MONITOR) {
3568 PRINT_D(HOSTAPD_DBG, "Monitor interface mode: Initializing mon interface virtual device driver\n");
3569 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", nic->wilc_netdev);
3570 new_ifc = WILC_WFI_init_mon_interface(name, nic->wilc_netdev);
3571 if (new_ifc != NULL) {
3572 PRINT_D(HOSTAPD_DBG, "Setting monitor flag in private structure\n");
3573 #ifdef SIMULATION
3574 priv = netdev_priv(priv->wdev->netdev);
3575 priv->monitor_flag = 1;
3576 #else
3577 nic = netdev_priv(priv->wdev->netdev);
3578 nic->monitor_flag = 1;
3579 #endif
3580 } else
3581 PRINT_ER("Error in initializing monitor interface\n ");
3582 }
3583 return priv->wdev;
3584 }
3585
3586 /**
3587 * @brief WILC_WFI_del_virt_intf
3588 * @details
3589 * @param[in]
3590 * @return int : Return 0 on Success.
3591 * @author mdaftedar
3592 * @date 01 JUL 2012
3593 * @version 1.0
3594 */
3595 int WILC_WFI_del_virt_intf(struct wiphy *wiphy, struct wireless_dev *wdev) /* tony for v3.8 support */
3596 {
3597 PRINT_D(HOSTAPD_DBG, "Deleting virtual interface\n");
3598 return WILC_SUCCESS;
3599 }
3600
3601
3602
3603 #endif /*WILC_AP_EXTERNAL_MLME*/
3604 static struct cfg80211_ops WILC_WFI_cfg80211_ops = {
3605
3606 .set_monitor_channel = WILC_WFI_CfgSetChannel,
3607 .scan = WILC_WFI_CfgScan,
3608 .connect = WILC_WFI_CfgConnect,
3609 .disconnect = WILC_WFI_disconnect,
3610 .add_key = WILC_WFI_add_key,
3611 .del_key = WILC_WFI_del_key,
3612 .get_key = WILC_WFI_get_key,
3613 .set_default_key = WILC_WFI_set_default_key,
3614 #ifdef WILC_AP_EXTERNAL_MLME
3615 .add_virtual_intf = WILC_WFI_add_virt_intf,
3616 .del_virtual_intf = WILC_WFI_del_virt_intf,
3617 .change_virtual_intf = WILC_WFI_change_virt_intf,
3618
3619 .start_ap = WILC_WFI_start_ap,
3620 .change_beacon = WILC_WFI_change_beacon,
3621 .stop_ap = WILC_WFI_stop_ap,
3622 .add_station = WILC_WFI_add_station,
3623 .del_station = WILC_WFI_del_station,
3624 .change_station = WILC_WFI_change_station,
3625 #endif /* WILC_AP_EXTERNAL_MLME*/
3626 #ifndef WILC_FULLY_HOSTING_AP
3627 .get_station = WILC_WFI_get_station,
3628 #endif
3629 .dump_station = WILC_WFI_dump_station,
3630 .change_bss = WILC_WFI_change_bss,
3631 .set_wiphy_params = WILC_WFI_set_wiphy_params,
3632
3633 .set_pmksa = WILC_WFI_set_pmksa,
3634 .del_pmksa = WILC_WFI_del_pmksa,
3635 .flush_pmksa = WILC_WFI_flush_pmksa,
3636 #ifdef WILC_P2P
3637 .remain_on_channel = WILC_WFI_remain_on_channel,
3638 .cancel_remain_on_channel = WILC_WFI_cancel_remain_on_channel,
3639 .mgmt_tx_cancel_wait = WILC_WFI_mgmt_tx_cancel_wait,
3640 .mgmt_tx = WILC_WFI_mgmt_tx,
3641 .mgmt_frame_register = WILC_WFI_frame_register,
3642 .set_power_mgmt = WILC_WFI_set_power_mgmt,
3643 .set_cqm_rssi_config = WILC_WFI_set_cqm_rssi_config,
3644 #endif
3645
3646 };
3647
3648
3649
3650
3651
3652 /**
3653 * @brief WILC_WFI_update_stats
3654 * @details Modify parameters for a given BSS.
3655 * @param[in]
3656 * @return int : Return 0 on Success.
3657 * @author mdaftedar
3658 * @date 01 MAR 2012
3659 * @version 1.0WILC_WFI_set_cqmWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_config_rssi_config
3660 */
3661 int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed)
3662 {
3663
3664 struct WILC_WFI_priv *priv;
3665
3666 priv = wiphy_priv(wiphy);
3667 #if 1
3668 switch (changed) {
3669
3670 case WILC_WFI_RX_PKT:
3671 {
3672 priv->netstats.rx_packets++;
3673 priv->netstats.rx_bytes += pktlen;
3674 priv->netstats.rx_time = get_jiffies_64();
3675 }
3676 break;
3677
3678 case WILC_WFI_TX_PKT:
3679 {
3680 priv->netstats.tx_packets++;
3681 priv->netstats.tx_bytes += pktlen;
3682 priv->netstats.tx_time = get_jiffies_64();
3683
3684 }
3685 break;
3686
3687 default:
3688 break;
3689 }
3690 #endif
3691 return 0;
3692 }
3693
3694 /**
3695 * @brief WILC_WFI_CfgAlloc
3696 * @details Allocation of the wireless device structure and assigning it
3697 * to the cfg80211 operations structure.
3698 * @param[in] NONE
3699 * @return wireless_dev : Returns pointer to wireless_dev structure.
3700 * @author mdaftedar
3701 * @date 01 MAR 2012
3702 * @version 1.0
3703 */
3704 struct wireless_dev *WILC_WFI_CfgAlloc(void)
3705 {
3706
3707 struct wireless_dev *wdev;
3708
3709
3710 PRINT_D(CFG80211_DBG, "Allocating wireless device\n");
3711 /*Allocating the wireless device structure*/
3712 wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
3713 if (!wdev) {
3714 PRINT_ER("Cannot allocate wireless device\n");
3715 goto _fail_;
3716 }
3717
3718 /*Creating a new wiphy, linking wireless structure with the wiphy structure*/
3719 wdev->wiphy = wiphy_new(&WILC_WFI_cfg80211_ops, sizeof(struct WILC_WFI_priv));
3720 if (!wdev->wiphy) {
3721 PRINT_ER("Cannot allocate wiphy\n");
3722 goto _fail_mem_;
3723
3724 }
3725
3726 #ifdef WILC_AP_EXTERNAL_MLME
3727 /* enable 802.11n HT */
3728 WILC_WFI_band_2ghz.ht_cap.ht_supported = 1;
3729 WILC_WFI_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT);
3730 WILC_WFI_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff;
3731 WILC_WFI_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K;
3732 WILC_WFI_band_2ghz.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE;
3733 #endif
3734
3735 /*wiphy bands*/
3736 wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &WILC_WFI_band_2ghz;
3737
3738 return wdev;
3739
3740 _fail_mem_:
3741 kfree(wdev);
3742 _fail_:
3743 return NULL;
3744
3745 }
3746 /**
3747 * @brief WILC_WFI_WiphyRegister
3748 * @details Registering of the wiphy structure and interface modes
3749 * @param[in] NONE
3750 * @return NONE
3751 * @author mdaftedar
3752 * @date 01 MAR 2012
3753 * @version 1.0
3754 */
3755 struct wireless_dev *WILC_WFI_WiphyRegister(struct net_device *net)
3756 {
3757 struct WILC_WFI_priv *priv;
3758 struct wireless_dev *wdev;
3759 s32 s32Error = WILC_SUCCESS;
3760
3761 PRINT_D(CFG80211_DBG, "Registering wifi device\n");
3762
3763 wdev = WILC_WFI_CfgAlloc();
3764 if (wdev == NULL) {
3765 PRINT_ER("CfgAlloc Failed\n");
3766 return NULL;
3767 }
3768
3769
3770 /*Return hardware description structure (wiphy)'s priv*/
3771 priv = wdev_priv(wdev);
3772 sema_init(&(priv->SemHandleUpdateStats), 1);
3773
3774 /*Link the wiphy with wireless structure*/
3775 priv->wdev = wdev;
3776
3777 /*Maximum number of probed ssid to be added by user for the scan request*/
3778 wdev->wiphy->max_scan_ssids = MAX_NUM_PROBED_SSID;
3779 /*Maximum number of pmkids to be cashed*/
3780 wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS;
3781 PRINT_INFO(CFG80211_DBG, "Max number of PMKIDs = %d\n", wdev->wiphy->max_num_pmkids);
3782
3783 wdev->wiphy->max_scan_ie_len = 1000;
3784
3785 /*signal strength in mBm (100*dBm) */
3786 wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
3787
3788 /*Set the availaible cipher suites*/
3789 wdev->wiphy->cipher_suites = cipher_suites;
3790 wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
3791 /*Setting default managment types: for register action frame: */
3792 wdev->wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types;
3793
3794 #ifdef WILC_P2P
3795 wdev->wiphy->max_remain_on_channel_duration = 500;
3796 /*Setting the wiphy interfcae mode and type before registering the wiphy*/
3797 wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | BIT(NL80211_IFTYPE_P2P_GO) |
3798 BIT(NL80211_IFTYPE_P2P_CLIENT);
3799 wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
3800 #else
3801 wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR);
3802 #endif
3803 wdev->iftype = NL80211_IFTYPE_STATION;
3804
3805
3806
3807 PRINT_INFO(CFG80211_DBG, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n",
3808 wdev->wiphy->max_scan_ssids, wdev->wiphy->max_scan_ie_len, wdev->wiphy->signal_type,
3809 wdev->wiphy->interface_modes, wdev->iftype);
3810
3811 #ifdef WILC_SDIO
3812 set_wiphy_dev(wdev->wiphy, &local_sdio_func->dev); /* tony */
3813 #endif
3814
3815 /*Register wiphy structure*/
3816 s32Error = wiphy_register(wdev->wiphy);
3817 if (s32Error) {
3818 PRINT_ER("Cannot register wiphy device\n");
3819 /*should define what action to be taken in such failure*/
3820 } else {
3821 PRINT_D(CFG80211_DBG, "Successful Registering\n");
3822 }
3823
3824 priv->dev = net;
3825 return wdev;
3826
3827
3828 }
3829 /**
3830 * @brief WILC_WFI_WiphyFree
3831 * @details Freeing allocation of the wireless device structure
3832 * @param[in] NONE
3833 * @return NONE
3834 * @author mdaftedar
3835 * @date 01 MAR 2012
3836 * @version 1.0
3837 */
3838 int WILC_WFI_InitHostInt(struct net_device *net)
3839 {
3840
3841 s32 s32Error = WILC_SUCCESS;
3842
3843 struct WILC_WFI_priv *priv;
3844
3845 PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr);
3846 priv = wdev_priv(net->ieee80211_ptr);
3847 if (op_ifcs == 0) {
3848 s32Error = WILC_TimerCreate(&(hAgingTimer), remove_network_from_shadow, NULL);
3849 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3850 s32Error = WILC_TimerCreate(&(hDuringIpTimer), clear_duringIP, NULL);
3851 #endif
3852 }
3853 op_ifcs++;
3854 if (s32Error < 0) {
3855 PRINT_ER("Failed to creat refresh Timer\n");
3856 return s32Error;
3857 }
3858
3859 priv->gbAutoRateAdjusted = false;
3860
3861 priv->bInP2PlistenState = false;
3862
3863 sema_init(&(priv->hSemScanReq), 1);
3864 s32Error = host_int_init(&priv->hWILCWFIDrv);
3865 if (s32Error) {
3866 PRINT_ER("Error while initializing hostinterface\n");
3867 }
3868 return s32Error;
3869 }
3870
3871 /**
3872 * @brief WILC_WFI_WiphyFree
3873 * @details Freeing allocation of the wireless device structure
3874 * @param[in] NONE
3875 * @return NONE
3876 * @author mdaftedar
3877 * @date 01 MAR 2012
3878 * @version 1.0
3879 */
3880 int WILC_WFI_DeInitHostInt(struct net_device *net)
3881 {
3882 s32 s32Error = WILC_SUCCESS;
3883
3884 struct WILC_WFI_priv *priv;
3885 priv = wdev_priv(net->ieee80211_ptr);
3886
3887 priv->gbAutoRateAdjusted = false;
3888
3889 priv->bInP2PlistenState = false;
3890
3891 op_ifcs--;
3892
3893 s32Error = host_int_deinit(priv->hWILCWFIDrv);
3894
3895 /* Clear the Shadow scan */
3896 clear_shadow_scan(priv);
3897 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3898 if (op_ifcs == 0) {
3899 PRINT_D(CORECONFIG_DBG, "destroy during ip\n");
3900 WILC_TimerDestroy(&hDuringIpTimer, NULL);
3901 }
3902 #endif
3903
3904 if (s32Error) {
3905 PRINT_ER("Error while deintializing host interface\n");
3906 }
3907 return s32Error;
3908 }
3909
3910
3911 /**
3912 * @brief WILC_WFI_WiphyFree
3913 * @details Freeing allocation of the wireless device structure
3914 * @param[in] NONE
3915 * @return NONE
3916 * @author mdaftedar
3917 * @date 01 MAR 2012
3918 * @version 1.0
3919 */
3920 void WILC_WFI_WiphyFree(struct net_device *net)
3921 {
3922
3923 PRINT_D(CFG80211_DBG, "Unregistering wiphy\n");
3924
3925 if (net == NULL) {
3926 PRINT_D(INIT_DBG, "net_device is NULL\n");
3927 return;
3928 }
3929
3930 if (net->ieee80211_ptr == NULL) {
3931 PRINT_D(INIT_DBG, "ieee80211_ptr is NULL\n");
3932 return;
3933 }
3934
3935 if (net->ieee80211_ptr->wiphy == NULL) {
3936 PRINT_D(INIT_DBG, "wiphy is NULL\n");
3937 return;
3938 }
3939
3940 wiphy_unregister(net->ieee80211_ptr->wiphy);
3941
3942 PRINT_D(INIT_DBG, "Freeing wiphy\n");
3943 wiphy_free(net->ieee80211_ptr->wiphy);
3944 kfree(net->ieee80211_ptr);
3945
3946 }
This page took 0.125742 seconds and 6 git commands to generate.