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