blob: 2361a80857cdaefa172a6a34346f5dd14ddd1206 [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
Johnny Kimc5c77ba2015-05-11 14:30:56 +090025extern int linux_wlan_get_firmware(perInterface_wlan_t *p_nic);
26extern void linux_wlan_unlock(void *vp);
Dean Lee72ed4dc2015-06-12 14:11:44 +090027extern u16 Set_machw_change_vir_if(bool bValue);
Johnny Kimc5c77ba2015-05-11 14:30:56 +090028
29extern int mac_open(struct net_device *ndev);
30extern int mac_close(struct net_device *ndev);
31
32tstrNetworkInfo astrLastScannedNtwrksShadow[MAX_NUM_SCANNED_NETWORKS_SHADOW];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +090033u32 u32LastScannedNtwrksCountShadow;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090034#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
35WILC_TimerHandle hDuringIpTimer;
36#endif
37WILC_TimerHandle hAgingTimer;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090038static u8 op_ifcs;
39extern u8 u8ConnectedSSID[6];
Johnny Kimc5c77ba2015-05-11 14:30:56 +090040
41/*BugID_5137*/
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090042u8 g_wilc_initialized = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090043extern linux_wlan_t *g_linux_wlan;
44#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Dean Lee72ed4dc2015-06-12 14:11:44 +090045extern bool g_obtainingIP;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090046#endif
47
48#define CHAN2G(_channel, _freq, _flags) { \
49 .band = IEEE80211_BAND_2GHZ, \
50 .center_freq = (_freq), \
51 .hw_value = (_channel), \
52 .flags = (_flags), \
53 .max_antenna_gain = 0, \
54 .max_power = 30, \
55}
56
57/*Frequency range for channels*/
58static struct ieee80211_channel WILC_WFI_2ghz_channels[] = {
59 CHAN2G(1, 2412, 0),
60 CHAN2G(2, 2417, 0),
61 CHAN2G(3, 2422, 0),
62 CHAN2G(4, 2427, 0),
63 CHAN2G(5, 2432, 0),
64 CHAN2G(6, 2437, 0),
65 CHAN2G(7, 2442, 0),
66 CHAN2G(8, 2447, 0),
67 CHAN2G(9, 2452, 0),
68 CHAN2G(10, 2457, 0),
69 CHAN2G(11, 2462, 0),
70 CHAN2G(12, 2467, 0),
71 CHAN2G(13, 2472, 0),
72 CHAN2G(14, 2484, 0),
73};
74
75#define RATETAB_ENT(_rate, _hw_value, _flags) { \
76 .bitrate = (_rate), \
77 .hw_value = (_hw_value), \
78 .flags = (_flags), \
79}
80
81
82/* Table 6 in section 3.2.1.1 */
83static struct ieee80211_rate WILC_WFI_rates[] = {
84 RATETAB_ENT(10, 0, 0),
85 RATETAB_ENT(20, 1, 0),
86 RATETAB_ENT(55, 2, 0),
87 RATETAB_ENT(110, 3, 0),
88 RATETAB_ENT(60, 9, 0),
89 RATETAB_ENT(90, 6, 0),
90 RATETAB_ENT(120, 7, 0),
91 RATETAB_ENT(180, 8, 0),
92 RATETAB_ENT(240, 9, 0),
93 RATETAB_ENT(360, 10, 0),
94 RATETAB_ENT(480, 11, 0),
95 RATETAB_ENT(540, 12, 0),
96};
97
98#ifdef WILC_P2P
99struct p2p_mgmt_data {
100 int size;
101 u8 *buff;
102};
103
104/*Global variable used to state the current connected STA channel*/
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900105u8 u8WLANChannel = INVALID_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900106
107/*BugID_5442*/
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900108u8 u8CurrChannel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900109
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900110u8 u8P2P_oui[] = {0x50, 0x6f, 0x9A, 0x09};
111u8 u8P2Plocalrandom = 0x01;
112u8 u8P2Precvrandom = 0x00;
113u8 u8P2P_vendorspec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};
Daniel Machon7fc80962015-08-05 00:09:35 +0200114bool bWilc_ie;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900115#endif
116
117static struct ieee80211_supported_band WILC_WFI_band_2ghz = {
118 .channels = WILC_WFI_2ghz_channels,
119 .n_channels = ARRAY_SIZE(WILC_WFI_2ghz_channels),
120 .bitrates = WILC_WFI_rates,
121 .n_bitrates = ARRAY_SIZE(WILC_WFI_rates),
122};
123
124
125/*BugID_5137*/
126struct add_key_params {
127 u8 key_idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900128 bool pairwise;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900129 u8 *mac_addr;
130};
131struct add_key_params g_add_gtk_key_params;
132struct wilc_wfi_key g_key_gtk_params;
133struct add_key_params g_add_ptk_key_params;
134struct wilc_wfi_key g_key_ptk_params;
135struct wilc_wfi_wep_key g_key_wep_params;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900136u8 g_flushing_in_progress;
Daniel Machon7fc80962015-08-05 00:09:35 +0200137bool g_ptk_keys_saved;
138bool g_gtk_keys_saved;
139bool g_wep_keys_saved;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900140
141#define AGING_TIME (9 * 1000)
142#define duringIP_TIME 15000
143
144void clear_shadow_scan(void *pUserVoid)
145{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900146 int i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900147 if (op_ifcs == 0) {
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900148 WILC_TimerDestroy(&hAgingTimer, NULL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900149 PRINT_INFO(CORECONFIG_DBG, "destroy aging timer\n");
150
151 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
152 if (astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs != NULL) {
153 WILC_FREE(astrLastScannedNtwrksShadow[i].pu8IEs);
154 astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs = NULL;
155 }
156
157 host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
158 astrLastScannedNtwrksShadow[i].pJoinParams = NULL;
159 }
160 u32LastScannedNtwrksCountShadow = 0;
161 }
162
163}
164
165uint32_t get_rssi_avg(tstrNetworkInfo *pstrNetworkInfo)
166{
167 uint8_t i;
168 int rssi_v = 0;
169 uint8_t num_rssi = (pstrNetworkInfo->strRssi.u8Full) ? NUM_RSSI : (pstrNetworkInfo->strRssi.u8Index);
170
171 for (i = 0; i < num_rssi; i++)
172 rssi_v += pstrNetworkInfo->strRssi.as8RSSI[i];
173
174 rssi_v /= num_rssi;
175 return rssi_v;
176}
177
Dean Lee72ed4dc2015-06-12 14:11:44 +0900178void refresh_scan(void *pUserVoid, uint8_t all, bool bDirectScan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900179{
180 struct WILC_WFI_priv *priv;
181 struct wiphy *wiphy;
182 struct cfg80211_bss *bss = NULL;
183 int i;
184 int rssi = 0;
185
186 priv = (struct WILC_WFI_priv *)pUserVoid;
187 wiphy = priv->dev->ieee80211_ptr->wiphy;
188
189 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
190 tstrNetworkInfo *pstrNetworkInfo;
191 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
192
193
194 if ((!pstrNetworkInfo->u8Found) || all) {
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900195 s32 s32Freq;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900196 struct ieee80211_channel *channel;
197
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900198 if (pstrNetworkInfo != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900199
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900200 s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900201 channel = ieee80211_get_channel(wiphy, s32Freq);
202
203 rssi = get_rssi_avg(pstrNetworkInfo);
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900204 if (memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7) || bDirectScan) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900205 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
206 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900207 (size_t)pstrNetworkInfo->u16IEsLen, (((s32)rssi) * 100), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900208 cfg80211_put_bss(wiphy, bss);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900209 }
210 }
211
212 }
213 }
214
215}
216
217void reset_shadow_found(void *pUserVoid)
218{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900219 int i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900220 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
221 astrLastScannedNtwrksShadow[i].u8Found = 0;
222
223 }
224}
225
226void update_scan_time(void *pUserVoid)
227{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900228 int i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900229 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
230 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
231 }
232}
233
234void remove_network_from_shadow(void *pUserVoid)
235{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900236 unsigned long now = jiffies;
237 int i, j;
238
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900239
240 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
241 if (time_after(now, astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan + (unsigned long)(SCAN_RESULT_EXPIRE))) {
242 PRINT_D(CFG80211_DBG, "Network expired in ScanShadow: %s \n", astrLastScannedNtwrksShadow[i].au8ssid);
243
244 if (astrLastScannedNtwrksShadow[i].pu8IEs != NULL) {
245 WILC_FREE(astrLastScannedNtwrksShadow[i].pu8IEs);
246 astrLastScannedNtwrksShadow[i].pu8IEs = NULL;
247 }
248
249 host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
250
251 for (j = i; (j < u32LastScannedNtwrksCountShadow - 1); j++) {
252 astrLastScannedNtwrksShadow[j] = astrLastScannedNtwrksShadow[j + 1];
253 }
254 u32LastScannedNtwrksCountShadow--;
255 }
256 }
257
258 PRINT_D(CFG80211_DBG, "Number of cached networks: %d\n", u32LastScannedNtwrksCountShadow);
259 if (u32LastScannedNtwrksCountShadow != 0)
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900260 WILC_TimerStart(&(hAgingTimer), AGING_TIME, pUserVoid, NULL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900261 else
262 PRINT_D(CFG80211_DBG, "No need to restart Aging timer\n");
263}
264
265#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
266void clear_duringIP(void *pUserVoid)
267{
268 PRINT_D(GENERIC_DBG, "GO:IP Obtained , enable scan\n");
Dean Lee72ed4dc2015-06-12 14:11:44 +0900269 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900270}
271#endif
272
273int8_t is_network_in_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid)
274{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900275 int8_t state = -1;
276 int i;
277
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900278 if (u32LastScannedNtwrksCountShadow == 0) {
279 PRINT_D(CFG80211_DBG, "Starting Aging timer\n");
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900280 WILC_TimerStart(&(hAgingTimer), AGING_TIME, pUserVoid, NULL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900281 state = -1;
282 } else {
283 /* Linear search for now */
284 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900285 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900286 pstrNetworkInfo->au8bssid, 6) == 0) {
287 state = i;
288 break;
289 }
290 }
291 }
292 return state;
293}
294
295void add_network_to_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
296{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900297 int8_t ap_found = is_network_in_shadow(pstrNetworkInfo, pUserVoid);
298 uint32_t ap_index = 0;
299 uint8_t rssi_index = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900300
301 if (u32LastScannedNtwrksCountShadow >= MAX_NUM_SCANNED_NETWORKS_SHADOW) {
302 PRINT_D(CFG80211_DBG, "Shadow network reached its maximum limit\n");
303 return;
304 }
305 if (ap_found == -1) {
306 ap_index = u32LastScannedNtwrksCountShadow;
307 u32LastScannedNtwrksCountShadow++;
308
309 } else {
310 ap_index = ap_found;
311 }
312 rssi_index = astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index;
313 astrLastScannedNtwrksShadow[ap_index].strRssi.as8RSSI[rssi_index++] = pstrNetworkInfo->s8rssi;
314 if (rssi_index == NUM_RSSI) {
315 rssi_index = 0;
316 astrLastScannedNtwrksShadow[ap_index].strRssi.u8Full = 1;
317 }
318 astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index = rssi_index;
319
320 astrLastScannedNtwrksShadow[ap_index].s8rssi = pstrNetworkInfo->s8rssi;
321 astrLastScannedNtwrksShadow[ap_index].u16CapInfo = pstrNetworkInfo->u16CapInfo;
322
323 astrLastScannedNtwrksShadow[ap_index].u8SsidLen = pstrNetworkInfo->u8SsidLen;
324 WILC_memcpy(astrLastScannedNtwrksShadow[ap_index].au8ssid,
325 pstrNetworkInfo->au8ssid, pstrNetworkInfo->u8SsidLen);
326
327 WILC_memcpy(astrLastScannedNtwrksShadow[ap_index].au8bssid,
328 pstrNetworkInfo->au8bssid, ETH_ALEN);
329
330 astrLastScannedNtwrksShadow[ap_index].u16BeaconPeriod = pstrNetworkInfo->u16BeaconPeriod;
331 astrLastScannedNtwrksShadow[ap_index].u8DtimPeriod = pstrNetworkInfo->u8DtimPeriod;
332 astrLastScannedNtwrksShadow[ap_index].u8channel = pstrNetworkInfo->u8channel;
333
334 astrLastScannedNtwrksShadow[ap_index].u16IEsLen = pstrNetworkInfo->u16IEsLen;
335 astrLastScannedNtwrksShadow[ap_index].u64Tsf = pstrNetworkInfo->u64Tsf;
336 if (ap_found != -1)
337 WILC_FREE(astrLastScannedNtwrksShadow[ap_index].pu8IEs);
338 astrLastScannedNtwrksShadow[ap_index].pu8IEs =
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900339 (u8 *)WILC_MALLOC(pstrNetworkInfo->u16IEsLen); /* will be deallocated by the WILC_WFI_CfgScan() function */
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900340 WILC_memcpy(astrLastScannedNtwrksShadow[ap_index].pu8IEs,
341 pstrNetworkInfo->pu8IEs, pstrNetworkInfo->u16IEsLen);
342
343 astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScan = jiffies;
344 astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScanCached = jiffies;
345 astrLastScannedNtwrksShadow[ap_index].u8Found = 1;
346 if (ap_found != -1)
347 host_int_freeJoinParams(astrLastScannedNtwrksShadow[ap_index].pJoinParams);
348 astrLastScannedNtwrksShadow[ap_index].pJoinParams = pJoinParams;
349
350}
351
352
353/**
354 * @brief CfgScanResult
355 * @details Callback function which returns the scan results found
356 *
357 * @param[in] tenuScanEvent enuScanEvent: enum, indicating the scan event triggered, whether that is
358 * SCAN_EVENT_NETWORK_FOUND or SCAN_EVENT_DONE
359 * tstrNetworkInfo* pstrNetworkInfo: structure holding the scan results information
360 * void* pUserVoid: Private structure associated with the wireless interface
361 * @return NONE
362 * @author mabubakr
363 * @date
364 * @version 1.0
365 */
366static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
367{
368 struct WILC_WFI_priv *priv;
369 struct wiphy *wiphy;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900370 s32 s32Freq;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900371 struct ieee80211_channel *channel;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900372 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900373 struct cfg80211_bss *bss = NULL;
374
375 priv = (struct WILC_WFI_priv *)pUserVoid;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900376 if (priv->bCfgScanning == true) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900377 if (enuScanEvent == SCAN_EVENT_NETWORK_FOUND) {
378 wiphy = priv->dev->ieee80211_ptr->wiphy;
379 WILC_NULLCHECK(s32Error, wiphy);
380 if (wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC
381 &&
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900382 ((((s32)pstrNetworkInfo->s8rssi) * 100) < 0
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900383 ||
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900384 (((s32)pstrNetworkInfo->s8rssi) * 100) > 100)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900385 ) {
386 WILC_ERRORREPORT(s32Error, WILC_FAIL);
387 }
388
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900389 if (pstrNetworkInfo != NULL) {
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900390 s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900391 channel = ieee80211_get_channel(wiphy, s32Freq);
392
393 WILC_NULLCHECK(s32Error, channel);
394
395 PRINT_INFO(CFG80211_DBG, "Network Info:: CHANNEL Frequency: %d, RSSI: %d, CapabilityInfo: %d,"
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900396 "BeaconPeriod: %d \n", channel->center_freq, (((s32)pstrNetworkInfo->s8rssi) * 100),
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900397 pstrNetworkInfo->u16CapInfo, pstrNetworkInfo->u16BeaconPeriod);
398
Dean Lee72ed4dc2015-06-12 14:11:44 +0900399 if (pstrNetworkInfo->bNewNetwork == true) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900400 if (priv->u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
401 /* max_scan_ssids */
402 PRINT_D(CFG80211_DBG, "Network %s found\n", pstrNetworkInfo->au8ssid);
403
404
405 priv->u32RcvdChCount++;
406
407
408
409 if (pJoinParams == NULL) {
410 PRINT_INFO(CORECONFIG_DBG, ">> Something really bad happened\n");
411 }
412 add_network_to_shadow(pstrNetworkInfo, priv, pJoinParams);
413
414 /*P2P peers are sent to WPA supplicant and added to shadow table*/
415
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900416 if (!(memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900417 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
418 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900419 (size_t)pstrNetworkInfo->u16IEsLen, (((s32)pstrNetworkInfo->s8rssi) * 100), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900420 cfg80211_put_bss(wiphy, bss);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900421 }
422
423
424 } else {
425 PRINT_ER("Discovered networks exceeded the max limit\n");
426 }
427 } else {
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900428 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900429 /* So this network is discovered before, we'll just update its RSSI */
430 for (i = 0; i < priv->u32RcvdChCount; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900431 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid, pstrNetworkInfo->au8bssid, 6) == 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900432 PRINT_D(CFG80211_DBG, "Update RSSI of %s \n", astrLastScannedNtwrksShadow[i].au8ssid);
433
434 astrLastScannedNtwrksShadow[i].s8rssi = pstrNetworkInfo->s8rssi;
435 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
436 break;
437 }
438 }
439 }
440 }
441 } else if (enuScanEvent == SCAN_EVENT_DONE) {
442 PRINT_D(CFG80211_DBG, "Scan Done[%p] \n", priv->dev);
443 PRINT_D(CFG80211_DBG, "Refreshing Scan ... \n");
Dean Lee72ed4dc2015-06-12 14:11:44 +0900444 refresh_scan(priv, 1, false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900445
446 if (priv->u32RcvdChCount > 0) {
447 PRINT_D(CFG80211_DBG, "%d Network(s) found \n", priv->u32RcvdChCount);
448 } else {
449 PRINT_D(CFG80211_DBG, "No networks found \n");
450 }
451
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200452 down(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900453
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900454 if (priv->pstrScanReq != NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900455 cfg80211_scan_done(priv->pstrScanReq, false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900456 priv->u32RcvdChCount = 0;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900457 priv->bCfgScanning = false;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900458 priv->pstrScanReq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900459 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200460 up(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900461
462 }
463 /*Aborting any scan operation during mac close*/
464 else if (enuScanEvent == SCAN_EVENT_ABORTED) {
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200465 down(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900466
467 PRINT_D(CFG80211_DBG, "Scan Aborted \n");
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900468 if (priv->pstrScanReq != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900469
470 update_scan_time(priv);
Dean Lee72ed4dc2015-06-12 14:11:44 +0900471 refresh_scan(priv, 1, false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900472
Dean Lee72ed4dc2015-06-12 14:11:44 +0900473 cfg80211_scan_done(priv->pstrScanReq, false);
474 priv->bCfgScanning = false;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900475 priv->pstrScanReq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900476 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200477 up(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900478 }
479 }
480
481
482 WILC_CATCH(s32Error)
483 {
484 }
485}
486
487
488/**
489 * @brief WILC_WFI_Set_PMKSA
490 * @details Check if pmksa is cached and set it.
491 * @param[in]
492 * @return int : Return 0 on Success
493 * @author mdaftedar
494 * @date 01 MAR 2012
495 * @version 1.0
496 */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900497int WILC_WFI_Set_PMKSA(u8 *bssid, struct WILC_WFI_priv *priv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900498{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900499 u32 i;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900500 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900501
502
503 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
504
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900505 if (!memcmp(bssid, priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900506 ETH_ALEN)) {
507 PRINT_D(CFG80211_DBG, "PMKID successful comparison");
508
509 /*If bssid is found, set the values*/
510 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
511
512 if (s32Error != WILC_SUCCESS)
513 PRINT_ER("Error in pmkid\n");
514
515 break;
516 }
517 }
518
519 return s32Error;
520
521
522}
523int linux_wlan_set_bssid(struct net_device *wilc_netdev, uint8_t *pBSSID);
524
525
526/**
527 * @brief CfgConnectResult
528 * @details
529 * @param[in] tenuConnDisconnEvent enuConnDisconnEvent: Type of connection response either
530 * connection response or disconnection notification.
531 * tstrConnectInfo* pstrConnectInfo: COnnection information.
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900532 * u8 u8MacStatus: Mac Status from firmware
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900533 * tstrDisconnectNotifInfo* pstrDisconnectNotifInfo: Disconnection Notification
534 * void* pUserVoid: Private data associated with wireless interface
535 * @return NONE
536 * @author mabubakr
537 * @date 01 MAR 2012
538 * @version 1.0
539 */
540int connecting;
541
542static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent,
543 tstrConnectInfo *pstrConnectInfo,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900544 u8 u8MacStatus,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900545 tstrDisconnectNotifInfo *pstrDisconnectNotifInfo,
546 void *pUserVoid)
547{
548 struct WILC_WFI_priv *priv;
549 struct net_device *dev;
550 #ifdef WILC_P2P
551 tstrWILC_WFIDrv *pstrWFIDrv;
552 #endif
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900553 u8 NullBssid[ETH_ALEN] = {0};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900554 connecting = 0;
555
556 priv = (struct WILC_WFI_priv *)pUserVoid;
557 dev = priv->dev;
558 #ifdef WILC_P2P
559 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
560 #endif
561
562 if (enuConnDisconnEvent == CONN_DISCONN_EVENT_CONN_RESP) {
563 /*Initialization*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900564 u16 u16ConnectStatus = WLAN_STATUS_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900565
566 u16ConnectStatus = pstrConnectInfo->u16ConnectStatus;
567
568 PRINT_D(CFG80211_DBG, " Connection response received = %d\n", u8MacStatus);
569
570 if ((u8MacStatus == MAC_DISCONNECTED) &&
571 (pstrConnectInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
572 /* The case here is that our station was waiting for association response frame and has just received it containing status code
573 * = SUCCESSFUL_STATUSCODE, while mac status is MAC_DISCONNECTED (which means something wrong happened) */
574 u16ConnectStatus = WLAN_STATUS_UNSPECIFIED_FAILURE;
575 linux_wlan_set_bssid(priv->dev, NullBssid);
Chaehyun Lim2cc46832015-08-07 09:02:01 +0900576 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900577
578 /*BugID_5457*/
579 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
580 #ifdef WILC_P2P
581 if (!pstrWFIDrv->u8P2PConnect)
582 u8WLANChannel = INVALID_CHANNEL;
583 #endif
584
585 PRINT_ER("Unspecified failure: Connection status %d : MAC status = %d \n", u16ConnectStatus, u8MacStatus);
586 }
587
588 if (u16ConnectStatus == WLAN_STATUS_SUCCESS) {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900589 bool bNeedScanRefresh = false;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900590 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900591
592 PRINT_INFO(CFG80211_DBG, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo->au8bssid[0],
593 pstrConnectInfo->au8bssid[1], pstrConnectInfo->au8bssid[2], pstrConnectInfo->au8bssid[3], pstrConnectInfo->au8bssid[4], pstrConnectInfo->au8bssid[5]);
594 WILC_memcpy(priv->au8AssociatedBss, pstrConnectInfo->au8bssid, ETH_ALEN);
595
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900596 /* BugID_4209: if this network has expired in the scan results in the above nl80211 layer, refresh them here by calling
597 * cfg80211_inform_bss() with the last Scan results before calling cfg80211_connect_result() to avoid
598 * Linux kernel warning generated at the nl80211 layer */
599
600 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900601 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900602 pstrConnectInfo->au8bssid, ETH_ALEN) == 0) {
603 unsigned long now = jiffies;
604
605 if (time_after(now,
606 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScanCached + (unsigned long)(nl80211_SCAN_RESULT_EXPIRE - (1 * HZ)))) {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900607 bNeedScanRefresh = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900608 }
609
610 break;
611 }
612 }
613
Abdul Hussain5a66bf22015-06-16 09:44:06 +0000614 if (bNeedScanRefresh) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900615 /*BugID_5418*/
616 /*Also, refrsh DIRECT- results if */
Dean Lee72ed4dc2015-06-12 14:11:44 +0900617 refresh_scan(priv, 1, true);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900618
619 }
620
621 }
622
623
Sudip Mukherjee52db75202015-06-02 14:28:17 +0530624 PRINT_D(CFG80211_DBG, "Association request info elements length = %zu\n", pstrConnectInfo->ReqIEsLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900625
626 PRINT_D(CFG80211_DBG, "Association response info elements length = %d\n", pstrConnectInfo->u16RespIEsLen);
627
628 cfg80211_connect_result(dev, pstrConnectInfo->au8bssid,
629 pstrConnectInfo->pu8ReqIEs, pstrConnectInfo->ReqIEsLen,
630 pstrConnectInfo->pu8RespIEs, pstrConnectInfo->u16RespIEsLen,
631 u16ConnectStatus, GFP_KERNEL); /* TODO: mostafa: u16ConnectStatus to */
632 /* be replaced by pstrConnectInfo->u16ConnectStatus */
633 } else if (enuConnDisconnEvent == CONN_DISCONN_EVENT_DISCONN_NOTIF) {
634 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Dean Lee72ed4dc2015-06-12 14:11:44 +0900635 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900636 #endif
637 PRINT_ER("Received MAC_DISCONNECTED from firmware with reason %d on dev [%p]\n",
638 pstrDisconnectNotifInfo->u16reason, priv->dev);
639 u8P2Plocalrandom = 0x01;
640 u8P2Precvrandom = 0x00;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900641 bWilc_ie = false;
Chaehyun Lim2cc46832015-08-07 09:02:01 +0900642 memset(priv->au8AssociatedBss, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900643 linux_wlan_set_bssid(priv->dev, NullBssid);
Chaehyun Lim2cc46832015-08-07 09:02:01 +0900644 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900645
646 /*BugID_5457*/
647 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
648 #ifdef WILC_P2P
649 if (!pstrWFIDrv->u8P2PConnect)
650 u8WLANChannel = INVALID_CHANNEL;
651 #endif
652 /*BugID_5315*/
653 /*Incase "P2P CLIENT Connected" send deauthentication reason by 3 to force the WPA_SUPPLICANT to directly change
654 * virtual interface to station*/
655 if ((pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) {
656 pstrDisconnectNotifInfo->u16reason = 3;
657 }
658 /*BugID_5315*/
659 /*Incase "P2P CLIENT during connection(not connected)" send deauthentication reason by 1 to force the WPA_SUPPLICANT
660 * to scan again and retry the connection*/
661 else if ((!pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) {
662 pstrDisconnectNotifInfo->u16reason = 1;
663 }
664 cfg80211_disconnected(dev, pstrDisconnectNotifInfo->u16reason, pstrDisconnectNotifInfo->ie,
Sudip Mukherjeee26bb712015-06-30 13:51:51 +0530665 pstrDisconnectNotifInfo->ie_len, false,
666 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900667
668 }
669
670}
671
672
673/**
674 * @brief WILC_WFI_CfgSetChannel
675 * @details Set channel for a given wireless interface. Some devices
676 * may support multi-channel operation (by channel hopping) so cfg80211
677 * doesn't verify much. Note, however, that the passed netdev may be
678 * %NULL as well if the user requested changing the channel for the
679 * device itself, or for a monitor interface.
680 * @param[in]
681 * @return int : Return 0 on Success
682 * @author mdaftedar
683 * @date 01 MAR 2012
684 * @version 1.0
685 */
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900686static int WILC_WFI_CfgSetChannel(struct wiphy *wiphy,
687 struct cfg80211_chan_def *chandef)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900688{
689
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900690 u32 channelnum = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900691 struct WILC_WFI_priv *priv;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900692 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900693 priv = wiphy_priv(wiphy);
694
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900695 channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq);
696 PRINT_D(CFG80211_DBG, "Setting channel %d with frequency %d\n", channelnum, chandef->chan->center_freq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900697
698 u8CurrChannel = channelnum;
699 s32Error = host_int_set_mac_chnl_num(priv->hWILCWFIDrv, channelnum);
700
701 if (s32Error != WILC_SUCCESS)
702 PRINT_ER("Error in setting channel %d\n", channelnum);
703
704 return s32Error;
705}
706
707/**
708 * @brief WILC_WFI_CfgScan
709 * @details Request to do a scan. If returning zero, the scan request is given
710 * the driver, and will be valid until passed to cfg80211_scan_done().
711 * For scan results, call cfg80211_inform_bss(); you can call this outside
712 * the scan/scan_done bracket too.
713 * @param[in]
714 * @return int : Return 0 on Success
715 * @author mabubakr
716 * @date 01 MAR 2012
717 * @version 1.0
718 */
719
720/*
721 * kernel version 3.8.8 supported
722 * tony, sswd, WILC-KR, 2013-10-29
723 */
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900724static int WILC_WFI_CfgScan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900725{
726 struct WILC_WFI_priv *priv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900727 u32 i;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900728 s32 s32Error = WILC_SUCCESS;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900729 u8 au8ScanChanList[MAX_NUM_SCANNED_NETWORKS];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900730 tstrHiddenNetwork strHiddenNetwork;
731
732 priv = wiphy_priv(wiphy);
733
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900734 priv->pstrScanReq = request;
735
736 priv->u32RcvdChCount = 0;
737
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900738 host_int_set_wfi_drv_handler((u32)priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900739
740
741 reset_shadow_found(priv);
742
Dean Lee72ed4dc2015-06-12 14:11:44 +0900743 priv->bCfgScanning = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900744 if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
745 /* max_scan_ssids */
746 for (i = 0; i < request->n_channels; i++) {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900747 au8ScanChanList[i] = (u8)ieee80211_frequency_to_channel(request->channels[i]->center_freq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900748 PRINT_INFO(CFG80211_DBG, "ScanChannel List[%d] = %d,", i, au8ScanChanList[i]);
749 }
750
751 PRINT_D(CFG80211_DBG, "Requested num of scan channel %d\n", request->n_channels);
Sudip Mukherjee52db75202015-06-02 14:28:17 +0530752 PRINT_D(CFG80211_DBG, "Scan Request IE len = %zu\n", request->ie_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900753
754 PRINT_D(CFG80211_DBG, "Number of SSIDs %d\n", request->n_ssids);
755
756 if (request->n_ssids >= 1) {
757
758
759 strHiddenNetwork.pstrHiddenNetworkInfo = WILC_MALLOC(request->n_ssids * sizeof(tstrHiddenNetwork));
760 strHiddenNetwork.u8ssidnum = request->n_ssids;
761
762
763 /*BugID_4156*/
764 for (i = 0; i < request->n_ssids; i++) {
765
766 if (request->ssids[i].ssid != NULL && request->ssids[i].ssid_len != 0) {
767 strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid = WILC_MALLOC(request->ssids[i].ssid_len);
768 WILC_memcpy(strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, request->ssids[i].ssid, request->ssids[i].ssid_len);
769 strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen = request->ssids[i].ssid_len;
770 } else {
771 PRINT_D(CFG80211_DBG, "Received one NULL SSID \n");
772 strHiddenNetwork.u8ssidnum -= 1;
773 }
774 }
775 PRINT_D(CFG80211_DBG, "Trigger Scan Request \n");
776 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
777 au8ScanChanList, request->n_channels,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900778 (const u8 *)request->ie, request->ie_len,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900779 CfgScanResult, (void *)priv, &strHiddenNetwork);
780 } else {
781 PRINT_D(CFG80211_DBG, "Trigger Scan Request \n");
782 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
783 au8ScanChanList, request->n_channels,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900784 (const u8 *)request->ie, request->ie_len,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900785 CfgScanResult, (void *)priv, NULL);
786 }
787
788 } else {
789 PRINT_ER("Requested num of scanned channels is greater than the max, supported"
790 " channels \n");
791 }
792
793 if (s32Error != WILC_SUCCESS) {
794 s32Error = -EBUSY;
795 PRINT_WRN(CFG80211_DBG, "Device is busy: Error(%d)\n", s32Error);
796 }
797
798 return s32Error;
799}
800
801/**
802 * @brief WILC_WFI_CfgConnect
803 * @details Connect to the ESS with the specified parameters. When connected,
804 * call cfg80211_connect_result() with status code %WLAN_STATUS_SUCCESS.
805 * If the connection fails for some reason, call cfg80211_connect_result()
806 * with the status from the AP.
807 * @param[in]
808 * @return int : Return 0 on Success
809 * @author mabubakr
810 * @date 01 MAR 2012
811 * @version 1.0
812 */
813static int WILC_WFI_CfgConnect(struct wiphy *wiphy, struct net_device *dev,
814 struct cfg80211_connect_params *sme)
815{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900816 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900817 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900818 u8 u8security = NO_ENCRYPT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900819 AUTHTYPE_T tenuAuth_type = ANY;
Dean Lee576917a2015-06-15 11:58:57 +0900820 char *pcgroup_encrypt_val = NULL;
821 char *pccipher_group = NULL;
822 char *pcwpa_version = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900823
824 struct WILC_WFI_priv *priv;
825 tstrWILC_WFIDrv *pstrWFIDrv;
826 tstrNetworkInfo *pstrNetworkInfo = NULL;
827
828
829 connecting = 1;
830 priv = wiphy_priv(wiphy);
831 pstrWFIDrv = (tstrWILC_WFIDrv *)(priv->hWILCWFIDrv);
832
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900833 host_int_set_wfi_drv_handler((u32)priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900834
Johnny Kim8a143302015-06-10 17:06:46 +0900835 PRINT_D(CFG80211_DBG, "Connecting to SSID [%s] on netdev [%p] host if [%p]\n", sme->ssid, dev, priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900836 #ifdef WILC_P2P
837 if (!(WILC_strncmp(sme->ssid, "DIRECT-", 7))) {
838 PRINT_D(CFG80211_DBG, "Connected to Direct network,OBSS disabled\n");
839 pstrWFIDrv->u8P2PConnect = 1;
840 } else
841 pstrWFIDrv->u8P2PConnect = 0;
842 #endif
843 PRINT_INFO(CFG80211_DBG, "Required SSID = %s\n , AuthType = %d \n", sme->ssid, sme->auth_type);
844
845 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
846 if ((sme->ssid_len == astrLastScannedNtwrksShadow[i].u8SsidLen) &&
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900847 memcmp(astrLastScannedNtwrksShadow[i].au8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900848 sme->ssid,
849 sme->ssid_len) == 0) {
850 PRINT_INFO(CFG80211_DBG, "Network with required SSID is found %s\n", sme->ssid);
851 if (sme->bssid == NULL) {
852 /* BSSID is not passed from the user, so decision of matching
853 * is done by SSID only */
854 PRINT_INFO(CFG80211_DBG, "BSSID is not passed from the user\n");
855 break;
856 } else {
857 /* BSSID is also passed from the user, so decision of matching
858 * should consider also this passed BSSID */
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900859 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900860 sme->bssid,
861 ETH_ALEN) == 0) {
862 PRINT_INFO(CFG80211_DBG, "BSSID is passed from the user and matched\n");
863 break;
864 }
865 }
866 }
867 }
868
869 if (i < u32LastScannedNtwrksCountShadow) {
870 PRINT_D(CFG80211_DBG, "Required bss is in scan results\n");
871
872 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
873
874 PRINT_INFO(CFG80211_DBG, "network BSSID to be associated: %x%x%x%x%x%x\n",
875 pstrNetworkInfo->au8bssid[0], pstrNetworkInfo->au8bssid[1],
876 pstrNetworkInfo->au8bssid[2], pstrNetworkInfo->au8bssid[3],
877 pstrNetworkInfo->au8bssid[4], pstrNetworkInfo->au8bssid[5]);
878 } else {
879 s32Error = -ENOENT;
880 if (u32LastScannedNtwrksCountShadow == 0)
881 PRINT_D(CFG80211_DBG, "No Scan results yet\n");
882 else
883 PRINT_D(CFG80211_DBG, "Required bss not in scan results: Error(%d)\n", s32Error);
884
885 goto done;
886 }
887
888 priv->WILC_WFI_wep_default = 0;
Chaehyun Lim2cc46832015-08-07 09:02:01 +0900889 memset(priv->WILC_WFI_wep_key, 0, sizeof(priv->WILC_WFI_wep_key));
890 memset(priv->WILC_WFI_wep_key_len, 0, sizeof(priv->WILC_WFI_wep_key_len));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900891
892 PRINT_INFO(CFG80211_DBG, "sme->crypto.wpa_versions=%x\n", sme->crypto.wpa_versions);
893 PRINT_INFO(CFG80211_DBG, "sme->crypto.cipher_group=%x\n", sme->crypto.cipher_group);
894
895 PRINT_INFO(CFG80211_DBG, "sme->crypto.n_ciphers_pairwise=%d\n", sme->crypto.n_ciphers_pairwise);
896
897 if (INFO) {
898 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++)
899 PRINT_D(CORECONFIG_DBG, "sme->crypto.ciphers_pairwise[%d]=%x\n", i, sme->crypto.ciphers_pairwise[i]);
900 }
901
902 if (sme->crypto.cipher_group != NO_ENCRYPT) {
903 /* To determine the u8security value, first we check the group cipher suite then {in case of WPA or WPA2}
904 * we will add to it the pairwise cipher suite(s) */
905 pcwpa_version = "Default";
906 PRINT_D(CORECONFIG_DBG, ">> sme->crypto.wpa_versions: %x\n", sme->crypto.wpa_versions);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900907 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900908 u8security = ENCRYPT_ENABLED | WEP;
909 pcgroup_encrypt_val = "WEP40";
910 pccipher_group = "WLAN_CIPHER_SUITE_WEP40";
911 PRINT_INFO(CFG80211_DBG, "WEP Default Key Idx = %d\n", sme->key_idx);
912
913 if (INFO) {
914 for (i = 0; i < sme->key_len; i++)
915 PRINT_D(CORECONFIG_DBG, "WEP Key Value[%d] = %d\n", i, sme->key[i]);
916 }
917 priv->WILC_WFI_wep_default = sme->key_idx;
918 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
919 WILC_memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
920
921 /*BugID_5137*/
922 g_key_wep_params.key_len = sme->key_len;
923 g_key_wep_params.key = WILC_MALLOC(sme->key_len);
924 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
925 g_key_wep_params.key_idx = sme->key_idx;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900926 g_wep_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900927
928 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
929 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
930 } else if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900931 u8security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
932 pcgroup_encrypt_val = "WEP104";
933 pccipher_group = "WLAN_CIPHER_SUITE_WEP104";
934
935 priv->WILC_WFI_wep_default = sme->key_idx;
936 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
937 WILC_memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
938
939 /*BugID_5137*/
940 g_key_wep_params.key_len = sme->key_len;
941 g_key_wep_params.key = WILC_MALLOC(sme->key_len);
942 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
943 g_key_wep_params.key_idx = sme->key_idx;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900944 g_wep_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900945
946 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
947 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
948 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900949 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900950 u8security = ENCRYPT_ENABLED | WPA2 | TKIP;
951 pcgroup_encrypt_val = "WPA2_TKIP";
952 pccipher_group = "TKIP";
953 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
954 /* tenuSecurity_t = WPA2_AES; */
955 u8security = ENCRYPT_ENABLED | WPA2 | AES;
956 pcgroup_encrypt_val = "WPA2_AES";
957 pccipher_group = "AES";
958 }
959 pcwpa_version = "WPA_VERSION_2";
960 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) {
961 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900962 u8security = ENCRYPT_ENABLED | WPA | TKIP;
963 pcgroup_encrypt_val = "WPA_TKIP";
964 pccipher_group = "TKIP";
965 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
966 /* tenuSecurity_t = WPA_AES; */
967 u8security = ENCRYPT_ENABLED | WPA | AES;
968 pcgroup_encrypt_val = "WPA_AES";
969 pccipher_group = "AES";
970
971 }
972 pcwpa_version = "WPA_VERSION_1";
973
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900974 } else {
975 s32Error = -ENOTSUPP;
976 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
977
978 goto done;
979 }
980
981 }
982
983 /* After we set the u8security value from checking the group cipher suite, {in case of WPA or WPA2} we will
984 * add to it the pairwise cipher suite(s) */
985 if ((sme->crypto.wpa_versions & NL80211_WPA_VERSION_1)
986 || (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)) {
987 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) {
988 if (sme->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP) {
989 u8security = u8security | TKIP;
990 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
991 u8security = u8security | AES;
992 }
993 }
994 }
995
996 PRINT_D(CFG80211_DBG, "Adding key with cipher group = %x\n", sme->crypto.cipher_group);
997
998 PRINT_D(CFG80211_DBG, "Authentication Type = %d\n", sme->auth_type);
999 switch (sme->auth_type) {
1000 case NL80211_AUTHTYPE_OPEN_SYSTEM:
1001 PRINT_D(CFG80211_DBG, "In OPEN SYSTEM\n");
1002 tenuAuth_type = OPEN_SYSTEM;
1003 break;
1004
1005 case NL80211_AUTHTYPE_SHARED_KEY:
1006 tenuAuth_type = SHARED_KEY;
1007 PRINT_D(CFG80211_DBG, "In SHARED KEY\n");
1008 break;
1009
1010 default:
1011 PRINT_D(CFG80211_DBG, "Automatic Authentation type = %d\n", sme->auth_type);
1012 }
1013
1014
1015 /* ai: key_mgmt: enterprise case */
1016 if (sme->crypto.n_akm_suites) {
1017 switch (sme->crypto.akm_suites[0]) {
1018 case WLAN_AKM_SUITE_8021X:
1019 tenuAuth_type = IEEE8021;
1020 break;
1021
1022 default:
1023 break;
1024 }
1025 }
1026
1027
1028 PRINT_INFO(CFG80211_DBG, "Required Channel = %d\n", pstrNetworkInfo->u8channel);
1029
1030 PRINT_INFO(CFG80211_DBG, "Group encryption value = %s\n Cipher Group = %s\n WPA version = %s\n",
1031 pcgroup_encrypt_val, pccipher_group, pcwpa_version);
1032
1033 /*BugID_5442*/
1034 u8CurrChannel = pstrNetworkInfo->u8channel;
1035
1036 if (!pstrWFIDrv->u8P2PConnect) {
1037 u8WLANChannel = pstrNetworkInfo->u8channel;
1038 }
1039
1040 linux_wlan_set_bssid(dev, pstrNetworkInfo->au8bssid);
1041
1042 s32Error = host_int_set_join_req(priv->hWILCWFIDrv, pstrNetworkInfo->au8bssid, sme->ssid,
1043 sme->ssid_len, sme->ie, sme->ie_len,
1044 CfgConnectResult, (void *)priv, u8security,
1045 tenuAuth_type, pstrNetworkInfo->u8channel,
1046 pstrNetworkInfo->pJoinParams);
1047 if (s32Error != WILC_SUCCESS) {
1048 PRINT_ER("host_int_set_join_req(): Error(%d) \n", s32Error);
1049 s32Error = -ENOENT;
1050 goto done;
1051 }
1052
1053done:
1054
1055 return s32Error;
1056}
1057
1058
1059/**
1060 * @brief WILC_WFI_disconnect
1061 * @details Disconnect from the BSS/ESS.
1062 * @param[in]
1063 * @return int : Return 0 on Success
1064 * @author mdaftedar
1065 * @date 01 MAR 2012
1066 * @version 1.0
1067 */
1068static int WILC_WFI_disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code)
1069{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001070 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001071 struct WILC_WFI_priv *priv;
1072 #ifdef WILC_P2P
1073 tstrWILC_WFIDrv *pstrWFIDrv;
1074 #endif
1075 uint8_t NullBssid[ETH_ALEN] = {0};
1076 connecting = 0;
1077 priv = wiphy_priv(wiphy);
1078
1079 /*BugID_5457*/
1080 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
1081 #ifdef WILC_P2P
1082 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
1083 if (!pstrWFIDrv->u8P2PConnect)
1084 u8WLANChannel = INVALID_CHANNEL;
1085 #endif
1086 linux_wlan_set_bssid(priv->dev, NullBssid);
1087
1088 PRINT_D(CFG80211_DBG, "Disconnecting with reason code(%d)\n", reason_code);
1089
1090 u8P2Plocalrandom = 0x01;
1091 u8P2Precvrandom = 0x00;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001092 bWilc_ie = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001093 #ifdef WILC_P2P
1094 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
1095 #endif
1096
1097 s32Error = host_int_disconnect(priv->hWILCWFIDrv, reason_code);
1098 if (s32Error != WILC_SUCCESS) {
1099 PRINT_ER("Error in disconnecting: Error(%d)\n", s32Error);
1100 s32Error = -EINVAL;
1101 }
1102
1103 return s32Error;
1104}
1105
1106/**
1107 * @brief WILC_WFI_add_key
1108 * @details Add a key with the given parameters. @mac_addr will be %NULL
1109 * when adding a group key.
1110 * @param[in] key : key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key, 8-byte Rx Mic Key
1111 * @return int : Return 0 on Success
1112 * @author mdaftedar
1113 * @date 01 MAR 2012
1114 * @version 1.0
1115 */
1116static int WILC_WFI_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001117 bool pairwise,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001118 const u8 *mac_addr, struct key_params *params)
1119
1120{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001121 s32 s32Error = WILC_SUCCESS, KeyLen = params->key_len;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001122 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001123 struct WILC_WFI_priv *priv;
Arnd Bergmann057d1e92015-06-01 21:06:44 +02001124 const u8 *pu8RxMic = NULL;
1125 const u8 *pu8TxMic = NULL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001126 u8 u8mode = NO_ENCRYPT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001127 #ifdef WILC_AP_EXTERNAL_MLME
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001128 u8 u8gmode = NO_ENCRYPT;
1129 u8 u8pmode = NO_ENCRYPT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001130 AUTHTYPE_T tenuAuth_type = ANY;
1131 #endif
1132
1133 priv = wiphy_priv(wiphy);
1134
1135 PRINT_D(CFG80211_DBG, "Adding key with cipher suite = %x\n", params->cipher);
1136
1137 /*BugID_5137*/
Johnny Kim8a143302015-06-10 17:06:46 +09001138 PRINT_D(CFG80211_DBG, "%p %p %d\n", wiphy, netdev, key_index);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001139
1140 PRINT_D(CFG80211_DBG, "key %x %x %x\n", params->key[0],
1141 params->key[1],
1142 params->key[2]);
1143
1144
1145 switch (params->cipher) {
1146 case WLAN_CIPHER_SUITE_WEP40:
1147 case WLAN_CIPHER_SUITE_WEP104:
1148 #ifdef WILC_AP_EXTERNAL_MLME
1149 if (priv->wdev->iftype == NL80211_IFTYPE_AP) {
1150
1151 priv->WILC_WFI_wep_default = key_index;
1152 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
1153 WILC_memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
1154
1155 PRINT_D(CFG80211_DBG, "Adding AP WEP Default key Idx = %d\n", key_index);
1156 PRINT_D(CFG80211_DBG, "Adding AP WEP Key len= %d\n", params->key_len);
1157
1158 for (i = 0; i < params->key_len; i++)
1159 PRINT_D(CFG80211_DBG, "WEP AP key val[%d] = %x\n", i, params->key[i]);
1160
1161 tenuAuth_type = OPEN_SYSTEM;
1162
1163 if (params->cipher == WLAN_CIPHER_SUITE_WEP40)
1164 u8mode = ENCRYPT_ENABLED | WEP;
1165 else
1166 u8mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
1167
1168 host_int_add_wep_key_bss_ap(priv->hWILCWFIDrv, params->key, params->key_len, key_index, u8mode, tenuAuth_type);
1169 break;
1170 }
1171 #endif
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001172 if (memcmp(params->key, priv->WILC_WFI_wep_key[key_index], params->key_len)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001173 priv->WILC_WFI_wep_default = key_index;
1174 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
1175 WILC_memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
1176
1177 PRINT_D(CFG80211_DBG, "Adding WEP Default key Idx = %d\n", key_index);
1178 PRINT_D(CFG80211_DBG, "Adding WEP Key length = %d\n", params->key_len);
1179 if (INFO) {
1180 for (i = 0; i < params->key_len; i++)
1181 PRINT_INFO(CFG80211_DBG, "WEP key value[%d] = %d\n", i, params->key[i]);
1182 }
1183 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, params->key, params->key_len, key_index);
1184 }
1185
1186 break;
1187
1188 case WLAN_CIPHER_SUITE_TKIP:
1189 case WLAN_CIPHER_SUITE_CCMP:
1190 #ifdef WILC_AP_EXTERNAL_MLME
1191 if (priv->wdev->iftype == NL80211_IFTYPE_AP || priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) {
1192
1193 if (priv->wilc_gtk[key_index] == NULL) {
1194 priv->wilc_gtk[key_index] = (struct wilc_wfi_key *)WILC_MALLOC(sizeof(struct wilc_wfi_key));
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001195 priv->wilc_gtk[key_index]->key = NULL;
1196 priv->wilc_gtk[key_index]->seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001197
1198 }
1199 if (priv->wilc_ptk[key_index] == NULL) {
1200 priv->wilc_ptk[key_index] = (struct wilc_wfi_key *)WILC_MALLOC(sizeof(struct wilc_wfi_key));
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001201 priv->wilc_ptk[key_index]->key = NULL;
1202 priv->wilc_ptk[key_index]->seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001203 }
1204
1205
1206
Daniel Machon19132212015-08-05 08:18:31 +02001207 if (!pairwise) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001208 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1209 u8gmode = ENCRYPT_ENABLED | WPA | TKIP;
1210 else
1211 u8gmode = ENCRYPT_ENABLED | WPA2 | AES;
1212
1213 priv->wilc_groupkey = u8gmode;
1214
1215 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1216
1217 pu8TxMic = params->key + 24;
1218 pu8RxMic = params->key + 16;
1219 KeyLen = params->key_len - 16;
1220 }
1221 /* if there has been previous allocation for the same index through its key, free that memory and allocate again*/
1222 if (priv->wilc_gtk[key_index]->key)
1223 WILC_FREE(priv->wilc_gtk[key_index]->key);
1224
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001225 priv->wilc_gtk[key_index]->key = (u8 *)WILC_MALLOC(params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001226 WILC_memcpy(priv->wilc_gtk[key_index]->key, params->key, params->key_len);
1227
1228 /* if there has been previous allocation for the same index through its seq, free that memory and allocate again*/
1229 if (priv->wilc_gtk[key_index]->seq)
1230 WILC_FREE(priv->wilc_gtk[key_index]->seq);
1231
1232 if ((params->seq_len) > 0) {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001233 priv->wilc_gtk[key_index]->seq = (u8 *)WILC_MALLOC(params->seq_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001234 WILC_memcpy(priv->wilc_gtk[key_index]->seq, params->seq, params->seq_len);
1235 }
1236
1237 priv->wilc_gtk[key_index]->cipher = params->cipher;
1238 priv->wilc_gtk[key_index]->key_len = params->key_len;
1239 priv->wilc_gtk[key_index]->seq_len = params->seq_len;
1240
1241 if (INFO) {
1242 for (i = 0; i < params->key_len; i++)
1243 PRINT_INFO(CFG80211_DBG, "Adding group key value[%d] = %x\n", i, params->key[i]);
1244 for (i = 0; i < params->seq_len; i++)
1245 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1246 }
1247
1248
1249 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1250 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, AP_MODE, u8gmode);
1251
1252 } else {
1253 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]);
1254
1255 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1256 u8pmode = ENCRYPT_ENABLED | WPA | TKIP;
1257 else
1258 u8pmode = priv->wilc_groupkey | AES;
1259
1260
1261 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1262
1263 pu8TxMic = params->key + 24;
1264 pu8RxMic = params->key + 16;
1265 KeyLen = params->key_len - 16;
1266 }
1267
1268 if (priv->wilc_ptk[key_index]->key)
1269 WILC_FREE(priv->wilc_ptk[key_index]->key);
1270
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001271 priv->wilc_ptk[key_index]->key = (u8 *)WILC_MALLOC(params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001272
1273 if (priv->wilc_ptk[key_index]->seq)
1274 WILC_FREE(priv->wilc_ptk[key_index]->seq);
1275
1276 if ((params->seq_len) > 0)
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001277 priv->wilc_ptk[key_index]->seq = (u8 *)WILC_MALLOC(params->seq_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001278
1279 if (INFO) {
1280 for (i = 0; i < params->key_len; i++)
1281 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %x\n", i, params->key[i]);
1282
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 WILC_memcpy(priv->wilc_ptk[key_index]->key, params->key, params->key_len);
1288
1289 if ((params->seq_len) > 0)
1290 WILC_memcpy(priv->wilc_ptk[key_index]->seq, params->seq, params->seq_len);
1291
1292 priv->wilc_ptk[key_index]->cipher = params->cipher;
1293 priv->wilc_ptk[key_index]->key_len = params->key_len;
1294 priv->wilc_ptk[key_index]->seq_len = params->seq_len;
1295
1296 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1297 pu8RxMic, pu8TxMic, AP_MODE, u8pmode, key_index);
1298 }
1299 break;
1300 }
1301 #endif
1302
1303 {
1304 u8mode = 0;
Daniel Machon19132212015-08-05 08:18:31 +02001305 if (!pairwise) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001306 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1307 /* swap the tx mic by rx mic */
1308 pu8RxMic = params->key + 24;
1309 pu8TxMic = params->key + 16;
1310 KeyLen = params->key_len - 16;
1311 }
1312
1313 /*BugID_5137*/
1314 /*save keys only on interface 0 (wifi interface)*/
1315 if (!g_gtk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1316 g_add_gtk_key_params.key_idx = key_index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001317 g_add_gtk_key_params.pairwise = pairwise;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001318 if (!mac_addr) {
1319 g_add_gtk_key_params.mac_addr = NULL;
1320 } else {
1321 g_add_gtk_key_params.mac_addr = WILC_MALLOC(ETH_ALEN);
1322 memcpy(g_add_gtk_key_params.mac_addr, mac_addr, ETH_ALEN);
1323 }
1324 g_key_gtk_params.key_len = params->key_len;
1325 g_key_gtk_params.seq_len = params->seq_len;
1326 g_key_gtk_params.key = WILC_MALLOC(params->key_len);
1327 memcpy(g_key_gtk_params.key, params->key, params->key_len);
1328 if (params->seq_len > 0) {
1329 g_key_gtk_params.seq = WILC_MALLOC(params->seq_len);
1330 memcpy(g_key_gtk_params.seq, params->seq, params->seq_len);
1331 }
1332 g_key_gtk_params.cipher = params->cipher;
1333
1334 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_gtk_params.key[0],
1335 g_key_gtk_params.key[1],
1336 g_key_gtk_params.key[2]);
Dean Lee72ed4dc2015-06-12 14:11:44 +09001337 g_gtk_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001338 }
1339
1340 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1341 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, STATION_MODE, u8mode);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001342 } else {
1343 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1344 /* swap the tx mic by rx mic */
1345 pu8RxMic = params->key + 24;
1346 pu8TxMic = params->key + 16;
1347 KeyLen = params->key_len - 16;
1348 }
1349
1350 /*BugID_5137*/
1351 /*save keys only on interface 0 (wifi interface)*/
1352 if (!g_ptk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1353 g_add_ptk_key_params.key_idx = key_index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001354 g_add_ptk_key_params.pairwise = pairwise;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001355 if (!mac_addr) {
1356 g_add_ptk_key_params.mac_addr = NULL;
1357 } else {
1358 g_add_ptk_key_params.mac_addr = WILC_MALLOC(ETH_ALEN);
1359 memcpy(g_add_ptk_key_params.mac_addr, mac_addr, ETH_ALEN);
1360 }
1361 g_key_ptk_params.key_len = params->key_len;
1362 g_key_ptk_params.seq_len = params->seq_len;
1363 g_key_ptk_params.key = WILC_MALLOC(params->key_len);
1364 memcpy(g_key_ptk_params.key, params->key, params->key_len);
1365 if (params->seq_len > 0) {
1366 g_key_ptk_params.seq = WILC_MALLOC(params->seq_len);
1367 memcpy(g_key_ptk_params.seq, params->seq, params->seq_len);
1368 }
1369 g_key_ptk_params.cipher = params->cipher;
1370
1371 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_ptk_params.key[0],
1372 g_key_ptk_params.key[1],
1373 g_key_ptk_params.key[2]);
Dean Lee72ed4dc2015-06-12 14:11:44 +09001374 g_ptk_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001375 }
1376
1377 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1378 pu8RxMic, pu8TxMic, STATION_MODE, u8mode, key_index);
1379 PRINT_D(CFG80211_DBG, "Adding pairwise key\n");
1380 if (INFO) {
1381 for (i = 0; i < params->key_len; i++)
1382 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %d\n", i, params->key[i]);
1383 }
1384 }
1385 }
1386 break;
1387
1388 default:
1389 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
1390 s32Error = -ENOTSUPP;
1391
1392 }
1393
1394 return s32Error;
1395}
1396
1397/**
1398 * @brief WILC_WFI_del_key
1399 * @details Remove a key given the @mac_addr (%NULL for a group key)
1400 * and @key_index, return -ENOENT if the key doesn't exist.
1401 * @param[in]
1402 * @return int : Return 0 on Success
1403 * @author mdaftedar
1404 * @date 01 MAR 2012
1405 * @version 1.0
1406 */
1407static int WILC_WFI_del_key(struct wiphy *wiphy, struct net_device *netdev,
1408 u8 key_index,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001409 bool pairwise,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001410 const u8 *mac_addr)
1411{
1412 struct WILC_WFI_priv *priv;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001413 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001414
1415 priv = wiphy_priv(wiphy);
1416
1417 /*BugID_5137*/
1418 /*delete saved keys, if any*/
1419 if (netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09001420 g_ptk_keys_saved = false;
1421 g_gtk_keys_saved = false;
1422 g_wep_keys_saved = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001423
1424 /*Delete saved WEP keys params, if any*/
1425 if (g_key_wep_params.key != NULL) {
1426 WILC_FREE(g_key_wep_params.key);
1427 g_key_wep_params.key = NULL;
1428 }
1429
1430 /*freeing memory allocated by "wilc_gtk" and "wilc_ptk" in "WILC_WIFI_ADD_KEY"*/
1431
1432 #ifdef WILC_AP_EXTERNAL_MLME
1433 if ((priv->wilc_gtk[key_index]) != NULL) {
1434
1435 if (priv->wilc_gtk[key_index]->key != NULL) {
1436
1437 WILC_FREE(priv->wilc_gtk[key_index]->key);
1438 priv->wilc_gtk[key_index]->key = NULL;
1439 }
1440 if (priv->wilc_gtk[key_index]->seq) {
1441
1442 WILC_FREE(priv->wilc_gtk[key_index]->seq);
1443 priv->wilc_gtk[key_index]->seq = NULL;
1444 }
1445
1446 WILC_FREE(priv->wilc_gtk[key_index]);
1447 priv->wilc_gtk[key_index] = NULL;
1448
1449 }
1450
1451 if ((priv->wilc_ptk[key_index]) != NULL) {
1452
1453 if (priv->wilc_ptk[key_index]->key) {
1454
1455 WILC_FREE(priv->wilc_ptk[key_index]->key);
1456 priv->wilc_ptk[key_index]->key = NULL;
1457 }
1458 if (priv->wilc_ptk[key_index]->seq) {
1459
1460 WILC_FREE(priv->wilc_ptk[key_index]->seq);
1461 priv->wilc_ptk[key_index]->seq = NULL;
1462 }
1463 WILC_FREE(priv->wilc_ptk[key_index]);
1464 priv->wilc_ptk[key_index] = NULL;
1465 }
1466 #endif
1467
1468 /*Delete saved PTK and GTK keys params, if any*/
1469 if (g_key_ptk_params.key != NULL) {
1470 WILC_FREE(g_key_ptk_params.key);
1471 g_key_ptk_params.key = NULL;
1472 }
1473 if (g_key_ptk_params.seq != NULL) {
1474 WILC_FREE(g_key_ptk_params.seq);
1475 g_key_ptk_params.seq = NULL;
1476 }
1477
1478 if (g_key_gtk_params.key != NULL) {
1479 WILC_FREE(g_key_gtk_params.key);
1480 g_key_gtk_params.key = NULL;
1481 }
1482 if (g_key_gtk_params.seq != NULL) {
1483 WILC_FREE(g_key_gtk_params.seq);
1484 g_key_gtk_params.seq = NULL;
1485 }
1486
1487 /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/
Dean Lee72ed4dc2015-06-12 14:11:44 +09001488 Set_machw_change_vir_if(false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001489 }
1490
1491 if (key_index >= 0 && key_index <= 3) {
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001492 memset(priv->WILC_WFI_wep_key[key_index], 0, priv->WILC_WFI_wep_key_len[key_index]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001493 priv->WILC_WFI_wep_key_len[key_index] = 0;
1494
1495 PRINT_D(CFG80211_DBG, "Removing WEP key with index = %d\n", key_index);
1496 host_int_remove_wep_key(priv->hWILCWFIDrv, key_index);
1497 } else {
1498 PRINT_D(CFG80211_DBG, "Removing all installed keys\n");
1499 host_int_remove_key(priv->hWILCWFIDrv, mac_addr);
1500 }
1501
1502 return s32Error;
1503}
1504
1505/**
1506 * @brief WILC_WFI_get_key
1507 * @details Get information about the key with the given parameters.
1508 * @mac_addr will be %NULL when requesting information for a group
1509 * key. All pointers given to the @callback function need not be valid
1510 * after it returns. This function should return an error if it is
1511 * not possible to retrieve the key, -ENOENT if it doesn't exist.
1512 * @param[in]
1513 * @return int : Return 0 on Success
1514 * @author mdaftedar
1515 * @date 01 MAR 2012
1516 * @version 1.0
1517 */
1518static int WILC_WFI_get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001519 bool pairwise,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001520 const u8 *mac_addr, void *cookie, void (*callback)(void *cookie, struct key_params *))
1521{
1522
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001523 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001524
1525 struct WILC_WFI_priv *priv;
1526 struct key_params key_params;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001527 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001528 priv = wiphy_priv(wiphy);
1529
1530
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001531 if (!pairwise)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001532 {
1533 PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index);
1534
1535 key_params.key = priv->wilc_gtk[key_index]->key;
1536 key_params.cipher = priv->wilc_gtk[key_index]->cipher;
1537 key_params.key_len = priv->wilc_gtk[key_index]->key_len;
1538 key_params.seq = priv->wilc_gtk[key_index]->seq;
1539 key_params.seq_len = priv->wilc_gtk[key_index]->seq_len;
1540 if (INFO) {
1541 for (i = 0; i < key_params.key_len; i++)
1542 PRINT_INFO(CFG80211_DBG, "Retrieved key value %x\n", key_params.key[i]);
1543 }
1544 } else {
1545 PRINT_D(CFG80211_DBG, "Getting pairwise key\n");
1546
1547 key_params.key = priv->wilc_ptk[key_index]->key;
1548 key_params.cipher = priv->wilc_ptk[key_index]->cipher;
1549 key_params.key_len = priv->wilc_ptk[key_index]->key_len;
1550 key_params.seq = priv->wilc_ptk[key_index]->seq;
1551 key_params.seq_len = priv->wilc_ptk[key_index]->seq_len;
1552 }
1553
1554 callback(cookie, &key_params);
1555
1556 return s32Error; /* priv->wilc_gtk->key_len ?0 : -ENOENT; */
1557}
1558
1559/**
1560 * @brief WILC_WFI_set_default_key
1561 * @details Set the default management frame key on an interface
1562 * @param[in]
1563 * @return int : Return 0 on Success.
1564 * @author mdaftedar
1565 * @date 01 MAR 2012
1566 * @version 1.0
1567 */
Arnd Bergmanne5af0562015-05-29 22:52:12 +02001568static int WILC_WFI_set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1569 bool unicast, bool multicast)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001570{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001571 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001572 struct WILC_WFI_priv *priv;
1573
1574
1575 priv = wiphy_priv(wiphy);
1576
1577 PRINT_D(CFG80211_DBG, "Setting default key with idx = %d \n", key_index);
1578
1579 if (key_index != priv->WILC_WFI_wep_default) {
1580
1581 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, key_index);
1582 }
1583
1584 return s32Error;
1585}
1586
1587/**
1588 * @brief WILC_WFI_dump_survey
1589 * @details Get site survey information
1590 * @param[in]
1591 * @return int : Return 0 on Success.
1592 * @author mdaftedar
1593 * @date 01 MAR 2012
1594 * @version 1.0
1595 */
1596static int WILC_WFI_dump_survey(struct wiphy *wiphy, struct net_device *netdev,
1597 int idx, struct survey_info *info)
1598{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001599 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001600
1601
1602 if (idx != 0) {
1603 s32Error = -ENOENT;
1604 PRINT_ER("Error Idx value doesn't equal zero: Error(%d)\n", s32Error);
1605
1606 }
1607
1608 return s32Error;
1609}
1610
1611
1612/**
1613 * @brief WILC_WFI_get_station
1614 * @details Get station information for the station identified by @mac
1615 * @param[in] NONE
1616 * @return int : Return 0 on Success.
1617 * @author mdaftedar
1618 * @date 01 MAR 2012
1619 * @version 1.0
1620 */
1621
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001622static int WILC_WFI_get_station(struct wiphy *wiphy, struct net_device *dev,
Arnd Bergmann057d1e92015-06-01 21:06:44 +02001623 const u8 *mac, struct station_info *sinfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001624{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001625 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001626 struct WILC_WFI_priv *priv;
1627 perInterface_wlan_t *nic;
1628 #ifdef WILC_AP_EXTERNAL_MLME
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001629 u32 i = 0;
1630 u32 associatedsta = 0;
1631 u32 inactive_time = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001632 #endif
1633 priv = wiphy_priv(wiphy);
1634 nic = netdev_priv(dev);
1635
1636 #ifdef WILC_AP_EXTERNAL_MLME
1637 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
1638 PRINT_D(HOSTAPD_DBG, "Getting station parameters\n");
1639
1640 PRINT_INFO(HOSTAPD_DBG, ": %x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4]);
1641
1642 for (i = 0; i < NUM_STA_ASSOCIATED; i++) {
1643
1644 if (!(memcmp(mac, priv->assoc_stainfo.au8Sta_AssociatedBss[i], ETH_ALEN))) {
1645 associatedsta = i;
1646 break;
1647 }
1648
1649 }
1650
1651 if (associatedsta == -1) {
1652 s32Error = -ENOENT;
1653 PRINT_ER("Station required is not associated : Error(%d)\n", s32Error);
1654
1655 return s32Error;
1656 }
1657
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001658 sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001659
1660 host_int_get_inactive_time(priv->hWILCWFIDrv, mac, &(inactive_time));
1661 sinfo->inactive_time = 1000 * inactive_time;
1662 PRINT_D(CFG80211_DBG, "Inactive time %d\n", sinfo->inactive_time);
1663
1664 }
1665 #endif
1666
1667 if (nic->iftype == STATION_MODE) {
1668 tstrStatistics strStatistics;
1669 host_int_get_statistics(priv->hWILCWFIDrv, &strStatistics);
1670
1671 /*
1672 * tony: 2013-11-13
1673 * tx_failed introduced more than
1674 * kernel version 3.0.0
1675 */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001676 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) |
Chandra S Gorentla62129902015-08-05 22:11:57 +05301677 BIT(NL80211_STA_INFO_RX_PACKETS) |
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001678 BIT(NL80211_STA_INFO_TX_PACKETS) |
1679 BIT(NL80211_STA_INFO_TX_FAILED) |
1680 BIT(NL80211_STA_INFO_TX_BITRATE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001681
1682 sinfo->signal = strStatistics.s8RSSI;
1683 sinfo->rx_packets = strStatistics.u32RxCount;
1684 sinfo->tx_packets = strStatistics.u32TxCount + strStatistics.u32TxFailureCount;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001685 sinfo->tx_failed = strStatistics.u32TxFailureCount;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001686 sinfo->txrate.legacy = strStatistics.u8LinkSpeed * 10;
1687
1688#ifdef TCP_ENHANCEMENTS
1689 if ((strStatistics.u8LinkSpeed > TCP_ACK_FILTER_LINK_SPEED_THRESH) && (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED)) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09001690 Enable_TCP_ACK_Filter(true);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001691 } else if (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09001692 Enable_TCP_ACK_Filter(false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001693 }
1694#endif
1695
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001696 PRINT_D(CORECONFIG_DBG, "*** stats[%d][%d][%d][%d][%d]\n", sinfo->signal, sinfo->rx_packets, sinfo->tx_packets,
1697 sinfo->tx_failed, sinfo->txrate.legacy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001698 }
1699 return s32Error;
1700}
1701
1702
1703/**
1704 * @brief WILC_WFI_change_bss
1705 * @details Modify parameters for a given BSS.
1706 * @param[in]
1707 * -use_cts_prot: Whether to use CTS protection
1708 * (0 = no, 1 = yes, -1 = do not change)
1709 * -use_short_preamble: Whether the use of short preambles is allowed
1710 * (0 = no, 1 = yes, -1 = do not change)
1711 * -use_short_slot_time: Whether the use of short slot time is allowed
1712 * (0 = no, 1 = yes, -1 = do not change)
1713 * -basic_rates: basic rates in IEEE 802.11 format
1714 * (or NULL for no change)
1715 * -basic_rates_len: number of basic rates
1716 * -ap_isolate: do not forward packets between connected stations
1717 * -ht_opmode: HT Operation mode
1718 * (u16 = opmode, -1 = do not change)
1719 * @return int : Return 0 on Success.
1720 * @author mdaftedar
1721 * @date 01 MAR 2012
1722 * @version 1.0
1723 */
1724static int WILC_WFI_change_bss(struct wiphy *wiphy, struct net_device *dev,
1725 struct bss_parameters *params)
1726{
1727 PRINT_D(CFG80211_DBG, "Changing Bss parametrs\n");
1728 return 0;
1729}
1730
1731/**
1732 * @brief WILC_WFI_auth
1733 * @details Request to authenticate with the specified peer
1734 * @param[in]
1735 * @return int : Return 0 on Success.
1736 * @author mdaftedar
1737 * @date 01 MAR 2012
1738 * @version 1.0
1739 */
1740static int WILC_WFI_auth(struct wiphy *wiphy, struct net_device *dev,
1741 struct cfg80211_auth_request *req)
1742{
1743 PRINT_D(CFG80211_DBG, "In Authentication Function\n");
1744 return 0;
1745}
1746
1747/**
1748 * @brief WILC_WFI_assoc
1749 * @details Request to (re)associate with the specified peer
1750 * @param[in]
1751 * @return int : Return 0 on Success.
1752 * @author mdaftedar
1753 * @date 01 MAR 2012
1754 * @version 1.0
1755 */
1756static int WILC_WFI_assoc(struct wiphy *wiphy, struct net_device *dev,
1757 struct cfg80211_assoc_request *req)
1758{
1759 PRINT_D(CFG80211_DBG, "In Association Function\n");
1760 return 0;
1761}
1762
1763/**
1764 * @brief WILC_WFI_deauth
1765 * @details Request to deauthenticate from the specified peer
1766 * @param[in]
1767 * @return int : Return 0 on Success.
1768 * @author mdaftedar
1769 * @date 01 MAR 2012
1770 * @version 1.0
1771 */
1772static int WILC_WFI_deauth(struct wiphy *wiphy, struct net_device *dev,
1773 struct cfg80211_deauth_request *req, void *cookie)
1774{
1775 PRINT_D(CFG80211_DBG, "In De-authentication Function\n");
1776 return 0;
1777}
1778
1779/**
1780 * @brief WILC_WFI_disassoc
1781 * @details Request to disassociate from the specified peer
1782 * @param[in]
1783 * @return int : Return 0 on Success
1784 * @author mdaftedar
1785 * @date 01 MAR 2012
1786 * @version 1.0
1787 */
1788static int WILC_WFI_disassoc(struct wiphy *wiphy, struct net_device *dev,
1789 struct cfg80211_disassoc_request *req, void *cookie)
1790{
1791 PRINT_D(CFG80211_DBG, "In Disassociation Function\n");
1792 return 0;
1793}
1794
1795/**
1796 * @brief WILC_WFI_set_wiphy_params
1797 * @details Notify that wiphy parameters have changed;
1798 * @param[in] Changed bitfield (see &enum wiphy_params_flags) describes which values
1799 * have changed.
1800 * @return int : Return 0 on Success
1801 * @author mdaftedar
1802 * @date 01 MAR 2012
1803 * @version 1.0
1804 */
1805static int WILC_WFI_set_wiphy_params(struct wiphy *wiphy, u32 changed)
1806{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001807 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001808 tstrCfgParamVal pstrCfgParamVal;
1809 struct WILC_WFI_priv *priv;
1810
1811 priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001812
1813 pstrCfgParamVal.u32SetCfgFlag = 0;
1814 PRINT_D(CFG80211_DBG, "Setting Wiphy params \n");
1815
1816 if (changed & WIPHY_PARAM_RETRY_SHORT) {
1817 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_SHORT %d\n",
1818 priv->dev->ieee80211_ptr->wiphy->retry_short);
1819 pstrCfgParamVal.u32SetCfgFlag |= RETRY_SHORT;
1820 pstrCfgParamVal.short_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_short;
1821 }
1822 if (changed & WIPHY_PARAM_RETRY_LONG) {
1823
1824 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_LONG %d\n", priv->dev->ieee80211_ptr->wiphy->retry_long);
1825 pstrCfgParamVal.u32SetCfgFlag |= RETRY_LONG;
1826 pstrCfgParamVal.long_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_long;
1827
1828 }
1829 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
1830 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->frag_threshold);
1831 pstrCfgParamVal.u32SetCfgFlag |= FRAG_THRESHOLD;
1832 pstrCfgParamVal.frag_threshold = priv->dev->ieee80211_ptr->wiphy->frag_threshold;
1833
1834 }
1835
1836 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
1837 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->rts_threshold);
1838
1839 pstrCfgParamVal.u32SetCfgFlag |= RTS_THRESHOLD;
1840 pstrCfgParamVal.rts_threshold = priv->dev->ieee80211_ptr->wiphy->rts_threshold;
1841
1842 }
1843
1844 PRINT_D(CFG80211_DBG, "Setting CFG params in the host interface\n");
1845 s32Error = hif_set_cfg(priv->hWILCWFIDrv, &pstrCfgParamVal);
1846 if (s32Error)
1847 PRINT_ER("Error in setting WIPHY PARAMS\n");
1848
1849
1850 return s32Error;
1851}
Arnd Bergmanne5af0562015-05-29 22:52:12 +02001852
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001853/**
1854 * @brief WILC_WFI_set_bitrate_mask
1855 * @details set the bitrate mask configuration
1856 * @param[in]
1857 * @return int : Return 0 on Success
1858 * @author mdaftedar
1859 * @date 01 MAR 2012
1860 * @version 1.0
1861 */
1862static int WILC_WFI_set_bitrate_mask(struct wiphy *wiphy,
1863 struct net_device *dev, const u8 *peer,
1864 const struct cfg80211_bitrate_mask *mask)
1865{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001866 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001867
1868 PRINT_D(CFG80211_DBG, "Setting Bitrate mask function\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001869 return s32Error;
1870
1871}
1872
1873/**
1874 * @brief WILC_WFI_set_pmksa
1875 * @details Cache a PMKID for a BSSID. This is mostly useful for fullmac
1876 * devices running firmwares capable of generating the (re) association
1877 * RSN IE. It allows for faster roaming between WPA2 BSSIDs.
1878 * @param[in]
1879 * @return int : Return 0 on Success
1880 * @author mdaftedar
1881 * @date 01 MAR 2012
1882 * @version 1.0
1883 */
1884static int WILC_WFI_set_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1885 struct cfg80211_pmksa *pmksa)
1886{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001887 u32 i;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001888 s32 s32Error = WILC_SUCCESS;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001889 u8 flag = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001890
1891 struct WILC_WFI_priv *priv = wiphy_priv(wiphy);
1892
1893 PRINT_D(CFG80211_DBG, "Setting PMKSA\n");
1894
1895
1896 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001897 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001898 ETH_ALEN)) {
1899 /*If bssid already exists and pmkid value needs to reset*/
1900 flag = PMKID_FOUND;
1901 PRINT_D(CFG80211_DBG, "PMKID already exists\n");
1902 break;
1903 }
1904 }
1905 if (i < WILC_MAX_NUM_PMKIDS) {
1906 PRINT_D(CFG80211_DBG, "Setting PMKID in private structure\n");
1907 WILC_memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid,
1908 ETH_ALEN);
1909 WILC_memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid,
1910 PMKID_LEN);
1911 if (!(flag == PMKID_FOUND))
1912 priv->pmkid_list.numpmkid++;
1913 } else {
1914 PRINT_ER("Invalid PMKID index\n");
1915 s32Error = -EINVAL;
1916 }
1917
1918 if (!s32Error) {
1919 PRINT_D(CFG80211_DBG, "Setting pmkid in the host interface\n");
1920 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
1921 }
1922 return s32Error;
1923}
1924
1925/**
1926 * @brief WILC_WFI_del_pmksa
1927 * @details Delete a cached PMKID.
1928 * @param[in]
1929 * @return int : Return 0 on Success
1930 * @author mdaftedar
1931 * @date 01 MAR 2012
1932 * @version 1.0
1933 */
1934static int WILC_WFI_del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1935 struct cfg80211_pmksa *pmksa)
1936{
1937
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001938 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001939 u8 flag = 0;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001940 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001941
1942 struct WILC_WFI_priv *priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001943
1944 PRINT_D(CFG80211_DBG, "Deleting PMKSA keys\n");
1945
1946 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001947 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001948 ETH_ALEN)) {
1949 /*If bssid is found, reset the values*/
1950 PRINT_D(CFG80211_DBG, "Reseting PMKID values\n");
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001951 memset(&priv->pmkid_list.pmkidlist[i], 0, sizeof(tstrHostIFpmkid));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001952 flag = PMKID_FOUND;
1953 break;
1954 }
1955 }
1956
1957 if (i < priv->pmkid_list.numpmkid && priv->pmkid_list.numpmkid > 0) {
1958 for (; i < (priv->pmkid_list.numpmkid - 1); i++) {
1959 WILC_memcpy(priv->pmkid_list.pmkidlist[i].bssid,
1960 priv->pmkid_list.pmkidlist[i + 1].bssid,
1961 ETH_ALEN);
1962 WILC_memcpy(priv->pmkid_list.pmkidlist[i].pmkid,
1963 priv->pmkid_list.pmkidlist[i].pmkid,
1964 PMKID_LEN);
1965 }
1966 priv->pmkid_list.numpmkid--;
1967 } else {
1968 s32Error = -EINVAL;
1969 }
1970
1971 return s32Error;
1972}
1973
1974/**
1975 * @brief WILC_WFI_flush_pmksa
1976 * @details Flush all cached PMKIDs.
1977 * @param[in]
1978 * @return int : Return 0 on Success
1979 * @author mdaftedar
1980 * @date 01 MAR 2012
1981 * @version 1.0
1982 */
1983static int WILC_WFI_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev)
1984{
1985 struct WILC_WFI_priv *priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001986
1987 PRINT_D(CFG80211_DBG, "Flushing PMKID key values\n");
1988
1989 /*Get cashed Pmkids and set all with zeros*/
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001990 memset(&priv->pmkid_list, 0, sizeof(tstrHostIFpmkidAttr));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001991
1992 return 0;
1993}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001994
1995#ifdef WILC_P2P
1996
1997/**
1998 * @brief WILC_WFI_CfgParseRxAction
1999 * @details Function parses the received frames and modifies the following attributes:
2000 * -GO Intent
2001 * -Channel list
2002 * -Operating Channel
2003 *
2004 * @param[in] u8* Buffer, u32 length
2005 * @return NONE.
2006 * @author mdaftedar
2007 * @date 12 DEC 2012
2008 * @version
2009 */
2010
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002011void WILC_WFI_CfgParseRxAction(u8 *buf, u32 len)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002012{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002013 u32 index = 0;
2014 u32 i = 0, j = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002015
2016 /*BugID_5460*/
2017 #ifdef USE_SUPPLICANT_GO_INTENT
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002018 u8 intent;
2019 u8 tie_breaker;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002020 bool is_wilc_go = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002021 #endif
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002022 u8 op_channel_attr_index = 0;
2023 u8 channel_list_attr_index = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002024
2025 while (index < len) {
2026 if (buf[index] == GO_INTENT_ATTR_ID) {
2027 #ifdef USE_SUPPLICANT_GO_INTENT
2028 /*BugID_5460*/
2029 /*Case 1: If we are going to be p2p client, no need to modify channels attributes*/
2030 /*In negotiation frames, go intent attr value determines who will be GO*/
2031 intent = GET_GO_INTENT(buf[index + 3]);
2032 tie_breaker = GET_TIE_BREAKER(buf[index + 3]);
2033 if (intent > SUPPLICANT_GO_INTENT
2034 || (intent == SUPPLICANT_GO_INTENT && tie_breaker == 1)) {
2035 PRINT_D(GENERIC_DBG, "WILC will be client (intent %d tie breaker %d)\n", intent, tie_breaker);
Dean Lee72ed4dc2015-06-12 14:11:44 +09002036 is_wilc_go = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002037 } else {
2038 PRINT_D(GENERIC_DBG, "WILC will be GO (intent %d tie breaker %d)\n", intent, tie_breaker);
Dean Lee72ed4dc2015-06-12 14:11:44 +09002039 is_wilc_go = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002040 }
2041
2042 #else /* USE_SUPPLICANT_GO_INTENT */
2043 #ifdef FORCE_P2P_CLIENT
2044 buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1);
2045 #else
2046 buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1);
2047 #endif
2048 #endif /* USE_SUPPLICANT_GO_INTENT */
2049 }
2050
2051 #ifdef USE_SUPPLICANT_GO_INTENT
2052 /*Case 2: If group bssid attribute is present, no need to modify channels attributes*/
2053 /*In invitation req and rsp, group bssid attr presence determines who will be GO*/
2054 if (buf[index] == GROUP_BSSID_ATTR_ID) {
2055 PRINT_D(GENERIC_DBG, "Group BSSID: %2x:%2x:%2x\n", buf[index + 3]
2056 , buf[index + 4]
2057 , buf[index + 5]);
Dean Lee72ed4dc2015-06-12 14:11:44 +09002058 is_wilc_go = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002059 }
2060 #endif /* USE_SUPPLICANT_GO_INTENT */
2061
2062 if (buf[index] == CHANLIST_ATTR_ID) {
2063 channel_list_attr_index = index;
2064 } else if (buf[index] == OPERCHAN_ATTR_ID) {
2065 op_channel_attr_index = index;
2066 }
2067 index += buf[index + 1] + 3; /* ID,Length byte */
2068 }
2069
2070 #ifdef USE_SUPPLICANT_GO_INTENT
2071 if (u8WLANChannel != INVALID_CHANNEL && is_wilc_go)
2072 #else
2073 if (u8WLANChannel != INVALID_CHANNEL)
2074 #endif
2075 {
2076 /*Modify channel list attribute*/
2077 if (channel_list_attr_index) {
2078 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
2079 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
2080 if (buf[i] == 0x51) {
2081 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
2082 buf[j] = u8WLANChannel;
2083 }
2084 break;
2085 }
2086 }
2087 }
2088 /*Modify operating channel attribute*/
2089 if (op_channel_attr_index) {
2090 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
2091 buf[op_channel_attr_index + 6] = 0x51;
2092 buf[op_channel_attr_index + 7] = u8WLANChannel;
2093 }
2094 }
2095}
2096
2097/**
2098 * @brief WILC_WFI_CfgParseTxAction
2099 * @details Function parses the transmitted action frames and modifies the
2100 * GO Intent attribute
2101 * @param[in] u8* Buffer, u32 length, bool bOperChan, u8 iftype
2102 * @return NONE.
2103 * @author mdaftedar
2104 * @date 12 DEC 2012
2105 * @version
2106 */
Dean Lee72ed4dc2015-06-12 14:11:44 +09002107void WILC_WFI_CfgParseTxAction(u8 *buf, u32 len, bool bOperChan, u8 iftype)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002108{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002109 u32 index = 0;
2110 u32 i = 0, j = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002111
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002112 u8 op_channel_attr_index = 0;
2113 u8 channel_list_attr_index = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002114 #ifdef USE_SUPPLICANT_GO_INTENT
Dean Lee72ed4dc2015-06-12 14:11:44 +09002115 bool is_wilc_go = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002116
2117 /*BugID_5460*/
2118 /*Case 1: If we are already p2p client, no need to modify channels attributes*/
2119 /*This to handle the case of inviting a p2p peer to join an existing group which we are a member in*/
2120 if (iftype == CLIENT_MODE)
2121 return;
2122 #endif
2123
2124 while (index < len) {
2125 #ifdef USE_SUPPLICANT_GO_INTENT
2126 /*Case 2: If group bssid attribute is present, no need to modify channels attributes*/
2127 /*In invitation req and rsp, group bssid attr presence determines who will be GO*/
2128 /*Note: If we are already p2p client, group bssid attr may also be present (handled in Case 1)*/
2129 if (buf[index] == GROUP_BSSID_ATTR_ID) {
2130 PRINT_D(GENERIC_DBG, "Group BSSID: %2x:%2x:%2x\n", buf[index + 3]
2131 , buf[index + 4]
2132 , buf[index + 5]);
Dean Lee72ed4dc2015-06-12 14:11:44 +09002133 is_wilc_go = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002134 }
2135
2136 #else /* USE_SUPPLICANT_GO_INTENT */
2137 if (buf[index] == GO_INTENT_ATTR_ID) {
2138 #ifdef FORCE_P2P_CLIENT
2139 buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1);
2140 #else
2141 buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1);
2142 #endif
2143
2144 break;
2145 }
2146 #endif
2147
2148 if (buf[index] == CHANLIST_ATTR_ID) {
2149 channel_list_attr_index = index;
2150 } else if (buf[index] == OPERCHAN_ATTR_ID) {
2151 op_channel_attr_index = index;
2152 }
2153 index += buf[index + 1] + 3; /* ID,Length byte */
2154 }
2155
2156 #ifdef USE_SUPPLICANT_GO_INTENT
2157 /*No need to check bOperChan since only transmitted invitation frames are parsed*/
2158 if (u8WLANChannel != INVALID_CHANNEL && is_wilc_go)
2159 #else
2160 if (u8WLANChannel != INVALID_CHANNEL && bOperChan)
2161 #endif
2162 {
2163 /*Modify channel list attribute*/
2164 if (channel_list_attr_index) {
2165 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
2166 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
2167 if (buf[i] == 0x51) {
2168 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
2169 buf[j] = u8WLANChannel;
2170 }
2171 break;
2172 }
2173 }
2174 }
2175 /*Modify operating channel attribute*/
2176 if (op_channel_attr_index) {
2177 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
2178 buf[op_channel_attr_index + 6] = 0x51;
2179 buf[op_channel_attr_index + 7] = u8WLANChannel;
2180 }
2181 }
2182}
2183
2184/* @brief WILC_WFI_p2p_rx
2185 * @details
2186 * @param[in]
2187 *
2188 * @return None
2189 * @author Mai Daftedar
2190 * @date 2 JUN 2013
2191 * @version 1.0
2192 */
2193
2194void WILC_WFI_p2p_rx (struct net_device *dev, uint8_t *buff, uint32_t size)
2195{
2196
2197 struct WILC_WFI_priv *priv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002198 u32 header, pkt_offset;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002199 tstrWILC_WFIDrv *pstrWFIDrv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002200 u32 i = 0;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002201 s32 s32Freq;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002202 priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
2203 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2204
2205 /* Get WILC header */
2206 WILC_memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
2207
2208 /* The packet offset field conain info about what type of managment frame */
2209 /* we are dealing with and ack status */
2210 pkt_offset = GET_PKT_OFFSET(header);
2211
2212 if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
2213 if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP) {
2214 PRINT_D(GENERIC_DBG, "Probe response ACK\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002215 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002216 return;
2217 } else {
2218 if (pkt_offset & IS_MGMT_STATUS_SUCCES) {
2219 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],
2220 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002221 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002222 } else {
2223 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],
2224 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002225 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, false, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002226 }
2227 return;
2228 }
2229 } else {
2230
2231 PRINT_D(GENERIC_DBG, "Rx Frame Type:%x\n", buff[FRAME_TYPE_ID]);
2232
2233 /*BugID_5442*/
2234 /*Upper layer is informed that the frame is received on this freq*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002235 s32Freq = ieee80211_channel_to_frequency(u8CurrChannel, IEEE80211_BAND_2GHZ);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002236
2237 if (ieee80211_is_action(buff[FRAME_TYPE_ID])) {
2238 PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]);
2239
Dean Lee72ed4dc2015-06-12 14:11:44 +09002240 if (priv->bCfgScanning == true && time_after_eq(jiffies, (unsigned long)pstrWFIDrv->u64P2p_MgmtTimeout)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002241 PRINT_D(GENERIC_DBG, "Receiving action frames from wrong channels\n");
2242 return;
2243 }
2244 if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
2245
2246 switch (buff[ACTION_SUBTYPE_ID]) {
2247 case GAS_INTIAL_REQ:
2248 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buff[ACTION_SUBTYPE_ID]);
2249 break;
2250
2251 case GAS_INTIAL_RSP:
2252 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buff[ACTION_SUBTYPE_ID]);
2253 break;
2254
2255 case PUBLIC_ACT_VENDORSPEC:
2256 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2257 * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002258 if (!memcmp(u8P2P_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002259 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
2260 if (!bWilc_ie) {
2261 for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002262 if (!memcmp(u8P2P_vendorspec, &buff[i], 6)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002263 u8P2Precvrandom = buff[i + 6];
Dean Lee72ed4dc2015-06-12 14:11:44 +09002264 bWilc_ie = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002265 PRINT_D(GENERIC_DBG, "WILC Vendor specific IE:%02x\n", u8P2Precvrandom);
2266 break;
2267 }
2268 }
2269 }
2270 }
2271 if (u8P2Plocalrandom > u8P2Precvrandom) {
2272 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
2273 || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
2274 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002275 if (buff[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buff[i + 2], 4))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002276 WILC_WFI_CfgParseRxAction(&buff[i + 6], size - (i + 6));
2277 break;
2278 }
2279 }
2280 }
2281 } else
2282 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2283 }
2284
2285
2286 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP) && (bWilc_ie)) {
2287 PRINT_D(GENERIC_DBG, "Sending P2P to host without extra elemnt\n");
2288 /* extra attribute for sig_dbm: signal strength in mBm, or 0 if unknown */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002289 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002290 return;
2291 }
2292 break;
2293
2294 default:
2295 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff[ACTION_SUBTYPE_ID]);
2296 break;
2297 }
2298 }
2299 }
2300
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002301 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002302 }
2303}
2304
2305/**
2306 * @brief WILC_WFI_mgmt_tx_complete
2307 * @details Returns result of writing mgmt frame to VMM (Tx buffers are freed here)
2308 * @param[in] priv
2309 * transmitting status
2310 * @return None
2311 * @author Amr Abdelmoghny
2312 * @date 20 MAY 2013
2313 * @version 1.0
2314 */
2315static void WILC_WFI_mgmt_tx_complete(void *priv, int status)
2316{
2317 struct p2p_mgmt_data *pv_data = (struct p2p_mgmt_data *)priv;
2318
2319
2320 kfree(pv_data->buff);
2321 kfree(pv_data);
2322}
2323
2324/**
2325 * @brief WILC_WFI_RemainOnChannelReady
2326 * @details Callback function, called from handle_remain_on_channel on being ready on channel
2327 * @param
2328 * @return none
2329 * @author Amr abdelmoghny
2330 * @date 9 JUNE 2013
2331 * @version
2332 */
2333
2334static void WILC_WFI_RemainOnChannelReady(void *pUserVoid)
2335{
2336 struct WILC_WFI_priv *priv;
2337 priv = (struct WILC_WFI_priv *)pUserVoid;
2338
2339 PRINT_D(HOSTINF_DBG, "Remain on channel ready \n");
2340
Dean Lee72ed4dc2015-06-12 14:11:44 +09002341 priv->bInP2PlistenState = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002342
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002343 cfg80211_ready_on_channel(priv->wdev,
2344 priv->strRemainOnChanParams.u64ListenCookie,
2345 priv->strRemainOnChanParams.pstrListenChan,
2346 priv->strRemainOnChanParams.u32ListenDuration,
2347 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002348}
2349
2350/**
2351 * @brief WILC_WFI_RemainOnChannelExpired
2352 * @details Callback function, called on expiration of remain-on-channel duration
2353 * @param
2354 * @return none
2355 * @author Amr abdelmoghny
2356 * @date 15 MAY 2013
2357 * @version
2358 */
2359
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002360static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, u32 u32SessionID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002361{
2362 struct WILC_WFI_priv *priv;
2363 priv = (struct WILC_WFI_priv *)pUserVoid;
2364
2365 /*BugID_5477*/
2366 if (u32SessionID == priv->strRemainOnChanParams.u32ListenSessionID) {
2367 PRINT_D(GENERIC_DBG, "Remain on channel expired \n");
2368
Dean Lee72ed4dc2015-06-12 14:11:44 +09002369 priv->bInP2PlistenState = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002370
2371 /*Inform wpas of remain-on-channel expiration*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002372 cfg80211_remain_on_channel_expired(priv->wdev,
2373 priv->strRemainOnChanParams.u64ListenCookie,
2374 priv->strRemainOnChanParams.pstrListenChan,
2375 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002376 } else {
2377 PRINT_D(GENERIC_DBG, "Received ID 0x%x Expected ID 0x%x (No match)\n", u32SessionID
2378 , priv->strRemainOnChanParams.u32ListenSessionID);
2379 }
2380}
2381
2382
2383/**
2384 * @brief WILC_WFI_remain_on_channel
2385 * @details Request the driver to remain awake on the specified
2386 * channel for the specified duration to complete an off-channel
2387 * operation (e.g., public action frame exchange). When the driver is
2388 * ready on the requested channel, it must indicate this with an event
2389 * notification by calling cfg80211_ready_on_channel().
2390 * @param[in]
2391 * @return int : Return 0 on Success
2392 * @author mdaftedar
2393 * @date 01 MAR 2012
2394 * @version 1.0
2395 */
2396static int WILC_WFI_remain_on_channel(struct wiphy *wiphy,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002397 struct wireless_dev *wdev,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002398 struct ieee80211_channel *chan,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002399 unsigned int duration, u64 *cookie)
2400{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002401 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002402 struct WILC_WFI_priv *priv;
2403 priv = wiphy_priv(wiphy);
2404
2405 PRINT_D(GENERIC_DBG, "Remaining on channel %d\n", chan->hw_value);
2406
2407 /*BugID_4800: if in AP mode, return.*/
2408 /*This check is to handle the situation when user*/
2409 /*requests "create group" during a running scan*/
2410
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002411 if (wdev->iftype == NL80211_IFTYPE_AP) {
2412 PRINT_D(GENERIC_DBG, "Required remain-on-channel while in AP mode");
2413 return s32Error;
2414 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002415
2416 u8CurrChannel = chan->hw_value;
2417
2418 /*Setting params needed by WILC_WFI_RemainOnChannelExpired()*/
2419 priv->strRemainOnChanParams.pstrListenChan = chan;
2420 priv->strRemainOnChanParams.u64ListenCookie = *cookie;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002421 priv->strRemainOnChanParams.u32ListenDuration = duration;
2422 priv->strRemainOnChanParams.u32ListenSessionID++;
2423
2424 s32Error = host_int_remain_on_channel(priv->hWILCWFIDrv
2425 , priv->strRemainOnChanParams.u32ListenSessionID
2426 , duration
2427 , chan->hw_value
2428 , WILC_WFI_RemainOnChannelExpired
2429 , WILC_WFI_RemainOnChannelReady
2430 , (void *)priv);
2431
2432 return s32Error;
2433}
2434
2435/**
2436 * @brief WILC_WFI_cancel_remain_on_channel
2437 * @details Cancel an on-going remain-on-channel operation.
2438 * This allows the operation to be terminated prior to timeout based on
2439 * the duration value.
2440 * @param[in] struct wiphy *wiphy,
2441 * @param[in] struct net_device *dev
2442 * @param[in] u64 cookie,
2443 * @return int : Return 0 on Success
2444 * @author mdaftedar
2445 * @date 01 MAR 2012
2446 * @version 1.0
2447 */
2448static int WILC_WFI_cancel_remain_on_channel(struct wiphy *wiphy,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002449 struct wireless_dev *wdev,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002450 u64 cookie)
2451{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002452 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002453 struct WILC_WFI_priv *priv;
2454 priv = wiphy_priv(wiphy);
2455
2456 PRINT_D(CFG80211_DBG, "Cancel remain on channel\n");
2457
2458 s32Error = host_int_ListenStateExpired(priv->hWILCWFIDrv, priv->strRemainOnChanParams.u32ListenSessionID);
2459 return s32Error;
2460}
2461/**
2462 * @brief WILC_WFI_add_wilcvendorspec
2463 * @details Adding WILC information elemet to allow two WILC devices to
2464 * identify each other and connect
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002465 * @param[in] u8 * buf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002466 * @return void
2467 * @author mdaftedar
2468 * @date 01 JAN 2014
2469 * @version 1.0
2470 */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002471void WILC_WFI_add_wilcvendorspec(u8 *buff)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002472{
2473 WILC_memcpy(buff, u8P2P_vendorspec, sizeof(u8P2P_vendorspec));
2474}
2475/**
2476 * @brief WILC_WFI_mgmt_tx_frame
2477 * @details
2478 *
2479 * @param[in]
2480 * @return NONE.
2481 * @author mdaftedar
2482 * @date 01 JUL 2012
2483 * @version
2484 */
2485extern linux_wlan_t *g_linux_wlan;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002486extern bool bEnablePS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002487int WILC_WFI_mgmt_tx(struct wiphy *wiphy,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002488 struct wireless_dev *wdev,
2489 struct cfg80211_mgmt_tx_params *params,
2490 u64 *cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002491{
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002492 struct ieee80211_channel *chan = params->chan;
2493 unsigned int wait = params->wait;
2494 const u8 *buf = params->buf;
2495 size_t len = params->len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002496 const struct ieee80211_mgmt *mgmt;
2497 struct p2p_mgmt_data *mgmt_tx;
2498 struct WILC_WFI_priv *priv;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002499 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002500 tstrWILC_WFIDrv *pstrWFIDrv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002501 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002502 perInterface_wlan_t *nic;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002503 u32 buf_len = len + sizeof(u8P2P_vendorspec) + sizeof(u8P2Plocalrandom);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002504
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002505 nic = netdev_priv(wdev->netdev);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002506 priv = wiphy_priv(wiphy);
2507 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2508
2509 *cookie = (unsigned long)buf;
2510 priv->u64tx_cookie = *cookie;
2511 mgmt = (const struct ieee80211_mgmt *) buf;
2512
2513 if (ieee80211_is_mgmt(mgmt->frame_control)) {
2514
2515 /*mgmt frame allocation*/
2516 mgmt_tx = (struct p2p_mgmt_data *)WILC_MALLOC(sizeof(struct p2p_mgmt_data));
2517 if (mgmt_tx == NULL) {
2518 PRINT_ER("Failed to allocate memory for mgmt_tx structure\n");
2519 return WILC_FAIL;
2520 }
2521 mgmt_tx->buff = (char *)WILC_MALLOC(buf_len);
2522 if (mgmt_tx->buff == NULL) {
2523 PRINT_ER("Failed to allocate memory for mgmt_tx buff\n");
2524 return WILC_FAIL;
2525 }
2526 WILC_memcpy(mgmt_tx->buff, buf, len);
2527 mgmt_tx->size = len;
2528
2529
2530 if (ieee80211_is_probe_resp(mgmt->frame_control)) {
2531 PRINT_D(GENERIC_DBG, "TX: Probe Response\n");
2532 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2533 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2534 /*Save the current channel after we tune to it*/
2535 u8CurrChannel = chan->hw_value;
2536 } else if (ieee80211_is_action(mgmt->frame_control)) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09002537 PRINT_D(GENERIC_DBG, "ACTION FRAME:%x\n", (u16)mgmt->frame_control);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002538
2539
2540 /*BugID_4847*/
2541 if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
2542 /*BugID_4847*/
2543 /*Only set the channel, if not a negotiation confirmation frame
2544 * (If Negotiation confirmation frame, force it
2545 * to be transmitted on the same negotiation channel)*/
2546
2547 if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC ||
2548 buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) {
2549 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2550 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2551 /*Save the current channel after we tune to it*/
2552 u8CurrChannel = chan->hw_value;
2553 }
2554 switch (buf[ACTION_SUBTYPE_ID]) {
2555 case GAS_INTIAL_REQ:
2556 {
2557 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buf[ACTION_SUBTYPE_ID]);
2558 break;
2559 }
2560
2561 case GAS_INTIAL_RSP:
2562 {
2563 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buf[ACTION_SUBTYPE_ID]);
2564 break;
2565 }
2566
2567 case PUBLIC_ACT_VENDORSPEC:
2568 {
2569 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2570 * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002571 if (!memcmp(u8P2P_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002572 /*For the connection of two WILC's connection generate a rand number to determine who will be a GO*/
2573 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
2574 if (u8P2Plocalrandom == 1 && u8P2Precvrandom < u8P2Plocalrandom) {
2575 get_random_bytes(&u8P2Plocalrandom, 1);
2576 /*Increment the number to prevent if its 0*/
2577 u8P2Plocalrandom++;
2578 }
2579 }
2580
2581 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
2582 || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
2583 if (u8P2Plocalrandom > u8P2Precvrandom) {
2584 PRINT_D(GENERIC_DBG, "LOCAL WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2585
2586 /*Search for the p2p information information element , after the Public action subtype theres a byte for teh dialog token, skip that*/
2587 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002588 if (buf[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buf[i + 2], 4))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002589 if (buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)
Dean Lee72ed4dc2015-06-12 14:11:44 +09002590 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), true, nic->iftype);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002591
2592 /*BugID_5460*/
2593 /*If using supplicant go intent, no need at all*/
2594 /*to parse transmitted negotiation frames*/
2595 #ifndef USE_SUPPLICANT_GO_INTENT
2596 else
Dean Lee72ed4dc2015-06-12 14:11:44 +09002597 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), false, nic->iftype);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002598 #endif
2599 break;
2600 }
2601 }
2602
2603 if (buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_REQ && buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_RSP) {
2604 WILC_WFI_add_wilcvendorspec(&mgmt_tx->buff[len]);
2605 mgmt_tx->buff[len + sizeof(u8P2P_vendorspec)] = u8P2Plocalrandom;
2606 mgmt_tx->size = buf_len;
2607 }
2608 } else
2609 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2610 }
2611
2612 } else {
2613 PRINT_D(GENERIC_DBG, "Not a P2P public action frame\n");
2614 }
2615
2616 break;
2617 }
2618
2619 default:
2620 {
2621 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf[ACTION_SUBTYPE_ID]);
2622 break;
2623 }
2624 }
2625
2626 }
2627
2628 PRINT_D(GENERIC_DBG, "TX: ACTION FRAME Type:%x : Chan:%d\n", buf[ACTION_SUBTYPE_ID], chan->hw_value);
2629 pstrWFIDrv->u64P2p_MgmtTimeout = (jiffies + msecs_to_jiffies(wait));
2630
2631 PRINT_D(GENERIC_DBG, "Current Jiffies: %lu Timeout:%llu\n", jiffies, pstrWFIDrv->u64P2p_MgmtTimeout);
2632
2633 }
2634
2635 g_linux_wlan->oup.wlan_add_mgmt_to_tx_que(mgmt_tx, mgmt_tx->buff, mgmt_tx->size, WILC_WFI_mgmt_tx_complete);
2636 } else {
2637 PRINT_D(GENERIC_DBG, "This function transmits only management frames\n");
2638 }
2639 return s32Error;
2640}
2641
2642int WILC_WFI_mgmt_tx_cancel_wait(struct wiphy *wiphy,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002643 struct wireless_dev *wdev,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002644 u64 cookie)
2645{
2646 struct WILC_WFI_priv *priv;
2647 tstrWILC_WFIDrv *pstrWFIDrv;
2648 priv = wiphy_priv(wiphy);
2649 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2650
2651
2652 PRINT_D(GENERIC_DBG, "Tx Cancel wait :%lu\n", jiffies);
2653 pstrWFIDrv->u64P2p_MgmtTimeout = jiffies;
2654
Dean Lee72ed4dc2015-06-12 14:11:44 +09002655 if (priv->bInP2PlistenState == false) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002656 /* Bug 5504: This is just to avoid connection failure when getting stuck when the supplicant
2657 * considers the driver falsely that it is in Listen state */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002658 cfg80211_remain_on_channel_expired(priv->wdev,
2659 priv->strRemainOnChanParams.u64ListenCookie,
2660 priv->strRemainOnChanParams.pstrListenChan,
2661 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002662 }
2663
2664 return 0;
2665}
2666
2667/**
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002668 * @brief WILC_WFI_frame_register
2669 * @details Notify driver that a management frame type was
2670 * registered. Note that this callback may not sleep, and cannot run
2671 * concurrently with itself.
2672 * @param[in]
2673 * @return NONE.
2674 * @author mdaftedar
2675 * @date 01 JUL 2012
2676 * @version
2677 */
2678void WILC_WFI_frame_register(struct wiphy *wiphy,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002679 struct wireless_dev *wdev,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002680 u16 frame_type, bool reg)
2681{
2682
2683 struct WILC_WFI_priv *priv;
2684 perInterface_wlan_t *nic;
2685
2686
2687 priv = wiphy_priv(wiphy);
2688 nic = netdev_priv(priv->wdev->netdev);
2689
2690
2691
2692 /*BugID_5137*/
2693 if (!frame_type)
2694 return;
2695
2696 PRINT_D(GENERIC_DBG, "Frame registering Frame Type: %x: Boolean: %d\n", frame_type, reg);
2697 switch (frame_type) {
2698 case PROBE_REQ:
2699 {
2700 nic->g_struct_frame_reg[0].frame_type = frame_type;
2701 nic->g_struct_frame_reg[0].reg = reg;
2702 }
2703 break;
2704
2705 case ACTION:
2706 {
2707 nic->g_struct_frame_reg[1].frame_type = frame_type;
2708 nic->g_struct_frame_reg[1].reg = reg;
2709 }
2710 break;
2711
2712 default:
2713 {
2714 break;
2715 }
2716
2717 }
2718 /*If mac is closed, then return*/
2719 if (!g_linux_wlan->wilc1000_initialized) {
2720 PRINT_D(GENERIC_DBG, "Return since mac is closed\n");
2721 return;
2722 }
2723 host_int_frame_register(priv->hWILCWFIDrv, frame_type, reg);
2724
2725
2726}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002727#endif /*WILC_P2P*/
2728
2729/**
2730 * @brief WILC_WFI_set_cqm_rssi_config
2731 * @details Configure connection quality monitor RSSI threshold.
2732 * @param[in] struct wiphy *wiphy:
2733 * @param[in] struct net_device *dev:
2734 * @param[in] s32 rssi_thold:
2735 * @param[in] u32 rssi_hyst:
2736 * @return int : Return 0 on Success
2737 * @author mdaftedar
2738 * @date 01 MAR 2012
2739 * @version 1.0
2740 */
2741static int WILC_WFI_set_cqm_rssi_config(struct wiphy *wiphy,
2742 struct net_device *dev, s32 rssi_thold, u32 rssi_hyst)
2743{
2744 PRINT_D(CFG80211_DBG, "Setting CQM RSSi Function\n");
2745 return 0;
2746
2747}
2748/**
2749 * @brief WILC_WFI_dump_station
2750 * @details Configure connection quality monitor RSSI threshold.
2751 * @param[in] struct wiphy *wiphy:
2752 * @param[in] struct net_device *dev
2753 * @param[in] int idx
2754 * @param[in] u8 *mac
2755 * @param[in] struct station_info *sinfo
2756 * @return int : Return 0 on Success
2757 * @author mdaftedar
2758 * @date 01 MAR 2012
2759 * @version 1.0
2760 */
2761static int WILC_WFI_dump_station(struct wiphy *wiphy, struct net_device *dev,
2762 int idx, u8 *mac, struct station_info *sinfo)
2763{
2764 struct WILC_WFI_priv *priv;
2765 PRINT_D(CFG80211_DBG, "Dumping station information\n");
2766
2767 if (idx != 0)
2768 return -ENOENT;
2769
2770 priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002771
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002772 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002773
2774 host_int_get_rssi(priv->hWILCWFIDrv, &(sinfo->signal));
2775
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002776 return 0;
2777
2778}
2779
2780
2781/**
2782 * @brief WILC_WFI_set_power_mgmt
2783 * @details
2784 * @param[in]
2785 * @return int : Return 0 on Success.
2786 * @author mdaftedar
2787 * @date 01 JUL 2012
2788 * @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
2789 */
2790int WILC_WFI_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2791 bool enabled, int timeout)
2792{
2793 struct WILC_WFI_priv *priv;
2794 PRINT_D(CFG80211_DBG, " Power save Enabled= %d , TimeOut = %d\n", enabled, timeout);
2795
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002796 if (wiphy == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002797 return -ENOENT;
2798
2799 priv = wiphy_priv(wiphy);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002800 if (priv->hWILCWFIDrv == NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002801 PRINT_ER("Driver is NULL\n");
2802 return -EIO;
2803 }
2804
Abdul Hussain5a66bf22015-06-16 09:44:06 +00002805 if (bEnablePS)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002806 host_int_set_power_mgmt(priv->hWILCWFIDrv, enabled, timeout);
2807
2808
2809 return WILC_SUCCESS;
2810
2811}
2812#ifdef WILC_AP_EXTERNAL_MLME
2813/**
2814 * @brief WILC_WFI_change_virt_intf
2815 * @details Change type/configuration of virtual interface,
2816 * keep the struct wireless_dev's iftype updated.
2817 * @param[in] NONE
2818 * @return int : Return 0 on Success.
2819 * @author mdaftedar
2820 * @date 01 MAR 2012
2821 * @version 1.0
2822 */
2823void wilc1000_wlan_deinit(linux_wlan_t *nic);
2824int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic);
2825
2826static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev,
2827 enum nl80211_iftype type, u32 *flags, struct vif_params *params)
2828{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002829 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002830 struct WILC_WFI_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002831 perInterface_wlan_t *nic;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002832 u8 interface_type;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002833 u16 TID = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002834 #ifdef WILC_P2P
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002835 u8 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002836 #endif
2837
2838 nic = netdev_priv(dev);
2839 priv = wiphy_priv(wiphy);
2840
2841 PRINT_D(HOSTAPD_DBG, "In Change virtual interface function\n");
2842 PRINT_D(HOSTAPD_DBG, "Wireless interface name =%s\n", dev->name);
2843 u8P2Plocalrandom = 0x01;
2844 u8P2Precvrandom = 0x00;
2845
Dean Lee72ed4dc2015-06-12 14:11:44 +09002846 bWilc_ie = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002847
2848 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Dean Lee72ed4dc2015-06-12 14:11:44 +09002849 g_obtainingIP = false;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002850 WILC_TimerStop(&hDuringIpTimer, NULL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002851 PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n");
2852 #endif
2853 /*BugID_5137*/
2854 /*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to CE H/W*/
2855 if (g_ptk_keys_saved && g_gtk_keys_saved) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002856 Set_machw_change_vir_if(true);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002857 }
2858
2859 switch (type) {
2860 case NL80211_IFTYPE_STATION:
2861 connecting = 0;
2862 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_STATION\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002863
2864 /* send delba over wlan interface */
2865
2866
2867 dev->ieee80211_ptr->iftype = type;
2868 priv->wdev->iftype = type;
2869 nic->monitor_flag = 0;
2870 nic->iftype = STATION_MODE;
2871
2872 /*Remove the enteries of the previously connected clients*/
2873 memset(priv->assoc_stainfo.au8Sta_AssociatedBss, 0, MAX_NUM_STA * ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002874 #ifdef WILC_P2P
2875 interface_type = nic->iftype;
2876 nic->iftype = STATION_MODE;
2877
2878 if (g_linux_wlan->wilc1000_initialized) {
2879 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
2880 /* ensure that the message Q is empty */
2881 host_int_wait_msg_queue_idle();
2882
2883 /*BugID_5213*/
2884 /*Eliminate host interface blocking state*/
2885 linux_wlan_unlock((void *)&g_linux_wlan->cfg_event);
2886
2887 wilc1000_wlan_deinit(g_linux_wlan);
2888 wilc1000_wlan_init(dev, nic);
2889 g_wilc_initialized = 1;
2890 nic->iftype = interface_type;
2891
2892 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
2893 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
2894 host_int_set_MacAddress((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
2895 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
2896 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2897
2898 /*Add saved WEP keys, if any*/
2899 if (g_wep_keys_saved) {
2900 host_int_set_WEPDefaultKeyID((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
2901 g_key_wep_params.key_idx);
2902 host_int_add_wep_key_bss_sta((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
2903 g_key_wep_params.key,
2904 g_key_wep_params.key_len,
2905 g_key_wep_params.key_idx);
2906 }
2907
2908 /*No matter the driver handler passed here, it will be overwriiten*/
2909 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2910 host_int_flush_join_req(priv->hWILCWFIDrv);
2911
2912 /*Add saved PTK and GTK keys, if any*/
2913 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2914 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
2915 g_key_ptk_params.key[1],
2916 g_key_ptk_params.key[2]);
2917 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
2918 g_key_gtk_params.key[1],
2919 g_key_gtk_params.key[2]);
2920 WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2921 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2922 g_add_ptk_key_params.key_idx,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002923 g_add_ptk_key_params.pairwise,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002924 g_add_ptk_key_params.mac_addr,
2925 (struct key_params *)(&g_key_ptk_params));
2926
2927 WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2928 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2929 g_add_gtk_key_params.key_idx,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002930 g_add_gtk_key_params.pairwise,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002931 g_add_gtk_key_params.mac_addr,
2932 (struct key_params *)(&g_key_gtk_params));
2933 }
2934
2935 /*BugID_4847: registered frames in firmware are now*/
2936 /*lost due to mac close. So re-register those frames*/
2937 if (g_linux_wlan->wilc1000_initialized) {
2938 for (i = 0; i < num_reg_frame; i++) {
2939 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2940 nic->g_struct_frame_reg[i].reg);
2941 host_int_frame_register(priv->hWILCWFIDrv,
2942 nic->g_struct_frame_reg[i].frame_type,
2943 nic->g_struct_frame_reg[i].reg);
2944 }
2945 }
2946
Dean Lee72ed4dc2015-06-12 14:11:44 +09002947 bEnablePS = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002948 host_int_set_power_mgmt(priv->hWILCWFIDrv, 1, 0);
2949 }
2950 #endif
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002951 break;
2952
2953 case NL80211_IFTYPE_P2P_CLIENT:
Dean Lee72ed4dc2015-06-12 14:11:44 +09002954 bEnablePS = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002955 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
2956 connecting = 0;
2957 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002958
2959 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
2960
2961 dev->ieee80211_ptr->iftype = type;
2962 priv->wdev->iftype = type;
2963 nic->monitor_flag = 0;
2964
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002965 #ifdef WILC_P2P
2966
2967 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
2968 nic->iftype = CLIENT_MODE;
2969
2970
2971 if (g_linux_wlan->wilc1000_initialized) {
2972 /* ensure that the message Q is empty */
2973 host_int_wait_msg_queue_idle();
2974
2975 wilc1000_wlan_deinit(g_linux_wlan);
2976 wilc1000_wlan_init(dev, nic);
2977 g_wilc_initialized = 1;
2978
2979 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
2980 host_int_set_MacAddress((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
2981 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
2982 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2983
2984 /*Add saved WEP keys, if any*/
2985 if (g_wep_keys_saved) {
2986 host_int_set_WEPDefaultKeyID((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
2987 g_key_wep_params.key_idx);
2988 host_int_add_wep_key_bss_sta((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
2989 g_key_wep_params.key,
2990 g_key_wep_params.key_len,
2991 g_key_wep_params.key_idx);
2992 }
2993
2994 /*No matter the driver handler passed here, it will be overwriiten*/
2995 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2996 host_int_flush_join_req(priv->hWILCWFIDrv);
2997
2998 /*Add saved PTK and GTK keys, if any*/
2999 if (g_ptk_keys_saved && g_gtk_keys_saved) {
3000 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
3001 g_key_ptk_params.key[1],
3002 g_key_ptk_params.key[2]);
3003 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
3004 g_key_gtk_params.key[1],
3005 g_key_gtk_params.key[2]);
3006 WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3007 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3008 g_add_ptk_key_params.key_idx,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003009 g_add_ptk_key_params.pairwise,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003010 g_add_ptk_key_params.mac_addr,
3011 (struct key_params *)(&g_key_ptk_params));
3012
3013 WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3014 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3015 g_add_gtk_key_params.key_idx,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003016 g_add_gtk_key_params.pairwise,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003017 g_add_gtk_key_params.mac_addr,
3018 (struct key_params *)(&g_key_gtk_params));
3019 }
3020
3021 /*Refresh scan, to refresh the scan results to the wpa_supplicant. Set MachHw to false to enable further key installments*/
Dean Lee72ed4dc2015-06-12 14:11:44 +09003022 refresh_scan(priv, 1, true);
3023 Set_machw_change_vir_if(false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003024
3025 /*BugID_4847: registered frames in firmware are now lost
3026 * due to mac close. So re-register those frames */
3027 if (g_linux_wlan->wilc1000_initialized) {
3028 for (i = 0; i < num_reg_frame; i++) {
3029 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
3030 nic->g_struct_frame_reg[i].reg);
3031 host_int_frame_register(priv->hWILCWFIDrv,
3032 nic->g_struct_frame_reg[i].frame_type,
3033 nic->g_struct_frame_reg[i].reg);
3034 }
3035 }
3036 }
3037 #endif
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003038 break;
3039
3040 case NL80211_IFTYPE_AP:
Dean Lee72ed4dc2015-06-12 14:11:44 +09003041 bEnablePS = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003042 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_AP %d\n", type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003043 dev->ieee80211_ptr->iftype = type;
3044 priv->wdev->iftype = type;
3045 nic->iftype = AP_MODE;
Johnny Kim8a143302015-06-10 17:06:46 +09003046 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003047
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003048 PRINT_D(HOSTAPD_DBG, "Downloading AP firmware\n");
3049 linux_wlan_get_firmware(nic);
3050 #ifdef WILC_P2P
3051 /*If wilc is running, then close-open to actually get new firmware running (serves P2P)*/
3052 if (g_linux_wlan->wilc1000_initialized) {
3053 nic->iftype = AP_MODE;
3054 g_linux_wlan->wilc1000_initialized = 1;
3055 mac_close(dev);
3056 mac_open(dev);
3057
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003058 /*BugID_4847: registered frames in firmware are now lost
3059 * due to mac close. So re-register those frames */
3060 for (i = 0; i < num_reg_frame; i++) {
3061 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
3062 nic->g_struct_frame_reg[i].reg);
3063 host_int_frame_register(priv->hWILCWFIDrv,
3064 nic->g_struct_frame_reg[i].frame_type,
3065 nic->g_struct_frame_reg[i].reg);
3066 }
3067 }
3068 #endif
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003069 break;
3070
3071 case NL80211_IFTYPE_P2P_GO:
3072 PRINT_D(GENERIC_DBG, "start duringIP timer\n");
3073
3074 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Dean Lee72ed4dc2015-06-12 14:11:44 +09003075 g_obtainingIP = true;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003076 WILC_TimerStart(&hDuringIpTimer, duringIP_TIME, NULL, NULL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003077 #endif
3078 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
3079 /*BugID_5222*/
3080 /*Delete block ack has to be the latest config packet*/
3081 /*sent before downloading new FW. This is because it blocks on*/
3082 /*hWaitResponse semaphore, which allows previous config*/
3083 /*packets to actually take action on old FW*/
3084 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
Dean Lee72ed4dc2015-06-12 14:11:44 +09003085 bEnablePS = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003086 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003087 dev->ieee80211_ptr->iftype = type;
3088 priv->wdev->iftype = type;
3089
Johnny Kim8a143302015-06-10 17:06:46 +09003090 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003091
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003092 #ifdef WILC_P2P
3093 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
3094
3095
3096 #if 1
3097 nic->iftype = GO_MODE;
3098
3099 /* ensure that the message Q is empty */
3100 host_int_wait_msg_queue_idle();
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003101 wilc1000_wlan_deinit(g_linux_wlan);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003102 wilc1000_wlan_init(dev, nic);
3103 g_wilc_initialized = 1;
3104
3105
3106 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
3107 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
3108 host_int_set_MacAddress((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
3109 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
3110 host_int_set_operation_mode(priv->hWILCWFIDrv, AP_MODE);
3111
3112 /*Add saved WEP keys, if any*/
3113 if (g_wep_keys_saved) {
3114 host_int_set_WEPDefaultKeyID((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
3115 g_key_wep_params.key_idx);
3116 host_int_add_wep_key_bss_sta((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
3117 g_key_wep_params.key,
3118 g_key_wep_params.key_len,
3119 g_key_wep_params.key_idx);
3120 }
3121
3122 /*No matter the driver handler passed here, it will be overwriiten*/
3123 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
3124 host_int_flush_join_req(priv->hWILCWFIDrv);
3125
3126 /*Add saved PTK and GTK keys, if any*/
3127 if (g_ptk_keys_saved && g_gtk_keys_saved) {
3128 PRINT_D(CFG80211_DBG, "ptk %x %x %x cipher %x\n", g_key_ptk_params.key[0],
3129 g_key_ptk_params.key[1],
3130 g_key_ptk_params.key[2],
3131 g_key_ptk_params.cipher);
3132 PRINT_D(CFG80211_DBG, "gtk %x %x %x cipher %x\n", g_key_gtk_params.key[0],
3133 g_key_gtk_params.key[1],
3134 g_key_gtk_params.key[2],
3135 g_key_gtk_params.cipher);
3136 #if 1
3137 WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3138 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3139 g_add_ptk_key_params.key_idx,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003140 g_add_ptk_key_params.pairwise,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003141 g_add_ptk_key_params.mac_addr,
3142 (struct key_params *)(&g_key_ptk_params));
3143
3144 WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3145 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3146 g_add_gtk_key_params.key_idx,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003147 g_add_gtk_key_params.pairwise,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003148 g_add_gtk_key_params.mac_addr,
3149 (struct key_params *)(&g_key_gtk_params));
3150 #endif
3151 }
3152 #endif
3153
3154 /*BugID_4847: registered frames in firmware are now*/
3155 /*lost due to mac close. So re-register those frames*/
3156 if (g_linux_wlan->wilc1000_initialized) {
3157 for (i = 0; i < num_reg_frame; i++) {
3158 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
3159 nic->g_struct_frame_reg[i].reg);
3160 host_int_frame_register(priv->hWILCWFIDrv,
3161 nic->g_struct_frame_reg[i].frame_type,
3162 nic->g_struct_frame_reg[i].reg);
3163 }
3164 }
3165 #endif
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003166 break;
3167
3168 default:
3169 PRINT_ER("Unknown interface type= %d\n", type);
3170 s32Error = -EINVAL;
3171 return s32Error;
3172 break;
3173 }
3174
3175 return s32Error;
3176}
3177
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003178/* (austin.2013-07-23)
3179 *
3180 * To support revised cfg80211_ops
3181 *
3182 * add_beacon --> start_ap
3183 * set_beacon --> change_beacon
3184 * del_beacon --> stop_ap
3185 *
3186 * beacon_parameters --> cfg80211_ap_settings
3187 * cfg80211_beacon_data
3188 *
3189 * applicable for linux kernel 3.4+
3190 */
3191
3192/**
3193 * @brief WILC_WFI_start_ap
3194 * @details Add a beacon with given parameters, @head, @interval
3195 * and @dtim_period will be valid, @tail is optional.
3196 * @param[in] wiphy
3197 * @param[in] dev The net device structure
3198 * @param[in] settings cfg80211_ap_settings parameters for the beacon to be added
3199 * @return int : Return 0 on Success.
3200 * @author austin
3201 * @date 23 JUL 2013
3202 * @version 1.0
3203 */
3204static int WILC_WFI_start_ap(struct wiphy *wiphy, struct net_device *dev,
3205 struct cfg80211_ap_settings *settings)
3206{
3207 struct cfg80211_beacon_data *beacon = &(settings->beacon);
3208 struct WILC_WFI_priv *priv;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003209 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003210
3211 priv = wiphy_priv(wiphy);
3212 PRINT_D(HOSTAPD_DBG, "Starting ap\n");
3213
Sudip Mukherjee52db75202015-06-02 14:28:17 +05303214 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 +09003215 settings->beacon_interval, settings->dtim_period, beacon->head_len, beacon->tail_len);
3216
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003217 s32Error = WILC_WFI_CfgSetChannel(wiphy, &settings->chandef);
3218
3219 if (s32Error != WILC_SUCCESS)
3220 PRINT_ER("Error in setting channel\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003221
3222 linux_wlan_set_bssid(dev, g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
3223
3224 #ifndef WILC_FULLY_HOSTING_AP
3225 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
3226 settings->beacon_interval,
3227 settings->dtim_period,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003228 beacon->head_len, (u8 *)beacon->head,
3229 beacon->tail_len, (u8 *)beacon->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003230 #else
3231 s32Error = host_add_beacon(priv->hWILCWFIDrv,
3232 settings->beacon_interval,
3233 settings->dtim_period,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003234 beacon->head_len, (u8 *)beacon->head,
3235 beacon->tail_len, (u8 *)beacon->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003236 #endif
3237
3238 return s32Error;
3239}
3240
3241/**
3242 * @brief WILC_WFI_change_beacon
3243 * @details Add a beacon with given parameters, @head, @interval
3244 * and @dtim_period will be valid, @tail is optional.
3245 * @param[in] wiphy
3246 * @param[in] dev The net device structure
3247 * @param[in] beacon cfg80211_beacon_data for the beacon to be changed
3248 * @return int : Return 0 on Success.
3249 * @author austin
3250 * @date 23 JUL 2013
3251 * @version 1.0
3252 */
3253static int WILC_WFI_change_beacon(struct wiphy *wiphy, struct net_device *dev,
3254 struct cfg80211_beacon_data *beacon)
3255{
3256 struct WILC_WFI_priv *priv;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003257 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003258
3259 priv = wiphy_priv(wiphy);
3260 PRINT_D(HOSTAPD_DBG, "Setting beacon\n");
3261
3262
3263#ifndef WILC_FULLY_HOSTING_AP
3264 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
3265 0,
3266 0,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003267 beacon->head_len, (u8 *)beacon->head,
3268 beacon->tail_len, (u8 *)beacon->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003269#else
3270 s32Error = host_add_beacon(priv->hWILCWFIDrv,
3271 0,
3272 0,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003273 beacon->head_len, (u8 *)beacon->head,
3274 beacon->tail_len, (u8 *)beacon->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003275#endif
3276
3277 return s32Error;
3278}
3279
3280/**
3281 * @brief WILC_WFI_stop_ap
3282 * @details Remove beacon configuration and stop sending the beacon.
3283 * @param[in]
3284 * @return int : Return 0 on Success.
3285 * @author austin
3286 * @date 23 JUL 2013
3287 * @version 1.0
3288 */
3289static int WILC_WFI_stop_ap(struct wiphy *wiphy, struct net_device *dev)
3290{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003291 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003292 struct WILC_WFI_priv *priv;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003293 u8 NullBssid[ETH_ALEN] = {0};
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003294
3295
3296 WILC_NULLCHECK(s32Error, wiphy);
3297
3298 priv = wiphy_priv(wiphy);
3299
3300 PRINT_D(HOSTAPD_DBG, "Deleting beacon\n");
3301
3302 /*BugID_5188*/
3303 linux_wlan_set_bssid(dev, NullBssid);
3304
3305 #ifndef WILC_FULLY_HOSTING_AP
3306 s32Error = host_int_del_beacon(priv->hWILCWFIDrv);
3307 #else
3308 s32Error = host_del_beacon(priv->hWILCWFIDrv);
3309 #endif
3310
3311 WILC_ERRORCHECK(s32Error);
3312
3313 WILC_CATCH(s32Error)
3314 {
3315 }
3316 return s32Error;
3317}
3318
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003319/**
3320 * @brief WILC_WFI_add_station
3321 * @details Add a new station.
3322 * @param[in]
3323 * @return int : Return 0 on Success.
3324 * @author mdaftedar
3325 * @date 01 MAR 2012
3326 * @version 1.0
3327 */
3328static int WILC_WFI_add_station(struct wiphy *wiphy, struct net_device *dev,
Arnd Bergmann057d1e92015-06-01 21:06:44 +02003329 const u8 *mac, struct station_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003330{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003331 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003332 struct WILC_WFI_priv *priv;
Chandra S Gorentlaa2b40412015-08-08 17:41:33 +05303333 tstrWILC_AddStaParam strStaParams = { {0} };
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003334 perInterface_wlan_t *nic;
3335
3336
3337 WILC_NULLCHECK(s32Error, wiphy);
3338
3339 priv = wiphy_priv(wiphy);
3340 nic = netdev_priv(dev);
3341
3342 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3343 #ifndef WILC_FULLY_HOSTING_AP
3344
3345 WILC_memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
3346 WILC_memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN);
3347 strStaParams.u16AssocID = params->aid;
3348 strStaParams.u8NumRates = params->supported_rates_len;
3349 strStaParams.pu8Rates = params->supported_rates;
3350
3351 PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid);
3352
3353 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],
3354 priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]);
3355 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3356 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3357
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003358 if (params->ht_capa == NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003359 strStaParams.bIsHTSupported = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003360 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003361 strStaParams.bIsHTSupported = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003362 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3363 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
3364 WILC_memcpy(strStaParams.au8SuppMCsSet, &params->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
3365 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3366 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3367 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3368 }
3369
3370 strStaParams.u16FlagsMask = params->sta_flags_mask;
3371 strStaParams.u16FlagsSet = params->sta_flags_set;
3372
3373 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3374 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3375 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3376 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3377 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3378 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3379 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3380 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3381
3382 s32Error = host_int_add_station(priv->hWILCWFIDrv, &strStaParams);
3383 WILC_ERRORCHECK(s32Error);
3384
3385 #else
3386 PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid);
3387 WILC_memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN);
3388
3389 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],
3390 priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]);
3391
3392 WILC_AP_AddSta(mac, params);
3393 WILC_ERRORCHECK(s32Error);
3394 #endif /* WILC_FULLY_HOSTING_AP */
3395
3396 }
3397
3398 WILC_CATCH(s32Error)
3399 {
3400 }
3401 return s32Error;
3402}
3403
3404/**
3405 * @brief WILC_WFI_del_station
3406 * @details Remove a station; @mac may be NULL to remove all stations.
3407 * @param[in]
3408 * @return int : Return 0 on Success.
3409 * @author mdaftedar
3410 * @date 01 MAR 2012
3411 * @version 1.0
3412 */
3413static int WILC_WFI_del_station(struct wiphy *wiphy, struct net_device *dev,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003414 struct station_del_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003415{
Arnd Bergmann057d1e92015-06-01 21:06:44 +02003416 const u8 *mac = params->mac;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003417 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003418 struct WILC_WFI_priv *priv;
3419 perInterface_wlan_t *nic;
3420 WILC_NULLCHECK(s32Error, wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003421
3422 priv = wiphy_priv(wiphy);
3423 nic = netdev_priv(dev);
3424
3425 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3426 PRINT_D(HOSTAPD_DBG, "Deleting station\n");
3427
3428
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003429 if (mac == NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003430 PRINT_D(HOSTAPD_DBG, "All associated stations \n");
3431 s32Error = host_int_del_allstation(priv->hWILCWFIDrv, priv->assoc_stainfo.au8Sta_AssociatedBss);
3432 } else {
3433 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]);
3434 }
3435
3436 #ifndef WILC_FULLY_HOSTING_AP
3437 s32Error = host_int_del_station(priv->hWILCWFIDrv, mac);
3438 #else
3439 WILC_AP_RemoveSta(mac);
3440 #endif /* WILC_FULLY_HOSTING_AP */
3441
3442 WILC_ERRORCHECK(s32Error);
3443 }
3444 WILC_CATCH(s32Error)
3445 {
3446 }
3447 return s32Error;
3448}
3449
3450/**
3451 * @brief WILC_WFI_change_station
3452 * @details Modify a given station.
3453 * @param[in]
3454 * @return int : Return 0 on Success.
3455 * @author mdaftedar
3456 * @date 01 MAR 2012
3457 * @version 1.0
3458 */
3459static int WILC_WFI_change_station(struct wiphy *wiphy, struct net_device *dev,
Arnd Bergmann057d1e92015-06-01 21:06:44 +02003460 const u8 *mac, struct station_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003461{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003462 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003463 struct WILC_WFI_priv *priv;
Chandra S Gorentlaa2b40412015-08-08 17:41:33 +05303464 tstrWILC_AddStaParam strStaParams = { {0} };
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003465 perInterface_wlan_t *nic;
3466
3467
3468 PRINT_D(HOSTAPD_DBG, "Change station paramters\n");
3469
3470 WILC_NULLCHECK(s32Error, wiphy);
3471
3472 priv = wiphy_priv(wiphy);
3473 nic = netdev_priv(dev);
3474
3475 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3476 #ifndef WILC_FULLY_HOSTING_AP
3477
3478 WILC_memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
3479 strStaParams.u16AssocID = params->aid;
3480 strStaParams.u8NumRates = params->supported_rates_len;
3481 strStaParams.pu8Rates = params->supported_rates;
3482
3483 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],
3484 strStaParams.au8BSSID[5]);
3485 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3486 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3487
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003488 if (params->ht_capa == NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003489 strStaParams.bIsHTSupported = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003490 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003491 strStaParams.bIsHTSupported = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003492 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3493 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
3494 WILC_memcpy(strStaParams.au8SuppMCsSet, &params->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
3495 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3496 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3497 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3498
3499 }
3500
3501 strStaParams.u16FlagsMask = params->sta_flags_mask;
3502 strStaParams.u16FlagsSet = params->sta_flags_set;
3503
3504 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3505 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3506 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3507 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3508 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3509 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3510 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3511 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3512
3513 s32Error = host_int_edit_station(priv->hWILCWFIDrv, &strStaParams);
3514 WILC_ERRORCHECK(s32Error);
3515
3516 #else
3517 WILC_AP_EditSta(mac, params);
3518 WILC_ERRORCHECK(s32Error);
3519 #endif /* WILC_FULLY_HOSTING_AP */
3520
3521 }
3522 WILC_CATCH(s32Error)
3523 {
3524 }
3525 return s32Error;
3526}
3527
3528
3529/**
3530 * @brief WILC_WFI_add_virt_intf
3531 * @details
3532 * @param[in]
3533 * @return int : Return 0 on Success.
3534 * @author mdaftedar
3535 * @date 01 JUL 2012
3536 * @version 1.0
3537 */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003538struct wireless_dev *WILC_WFI_add_virt_intf(struct wiphy *wiphy, const char *name,
3539 unsigned char name_assign_type,
3540 enum nl80211_iftype type, u32 *flags,
3541 struct vif_params *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003542{
3543 perInterface_wlan_t *nic;
3544 struct WILC_WFI_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003545 struct net_device *new_ifc = NULL;
3546 priv = wiphy_priv(wiphy);
3547
3548
3549
3550 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", priv->wdev->netdev);
3551
3552 nic = netdev_priv(priv->wdev->netdev);
3553
3554
3555 if (type == NL80211_IFTYPE_MONITOR) {
3556 PRINT_D(HOSTAPD_DBG, "Monitor interface mode: Initializing mon interface virtual device driver\n");
3557 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", nic->wilc_netdev);
3558 new_ifc = WILC_WFI_init_mon_interface(name, nic->wilc_netdev);
3559 if (new_ifc != NULL) {
3560 PRINT_D(HOSTAPD_DBG, "Setting monitor flag in private structure\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003561 nic = netdev_priv(priv->wdev->netdev);
3562 nic->monitor_flag = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003563 } else
3564 PRINT_ER("Error in initializing monitor interface\n ");
3565 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003566 return priv->wdev;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003567}
3568
3569/**
3570 * @brief WILC_WFI_del_virt_intf
3571 * @details
3572 * @param[in]
3573 * @return int : Return 0 on Success.
3574 * @author mdaftedar
3575 * @date 01 JUL 2012
3576 * @version 1.0
3577 */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003578int WILC_WFI_del_virt_intf(struct wiphy *wiphy, struct wireless_dev *wdev) /* tony for v3.8 support */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003579{
3580 PRINT_D(HOSTAPD_DBG, "Deleting virtual interface\n");
3581 return WILC_SUCCESS;
3582}
3583
3584
3585
3586#endif /*WILC_AP_EXTERNAL_MLME*/
3587static struct cfg80211_ops WILC_WFI_cfg80211_ops = {
3588
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003589 .set_monitor_channel = WILC_WFI_CfgSetChannel,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003590 .scan = WILC_WFI_CfgScan,
3591 .connect = WILC_WFI_CfgConnect,
3592 .disconnect = WILC_WFI_disconnect,
3593 .add_key = WILC_WFI_add_key,
3594 .del_key = WILC_WFI_del_key,
3595 .get_key = WILC_WFI_get_key,
3596 .set_default_key = WILC_WFI_set_default_key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003597 #ifdef WILC_AP_EXTERNAL_MLME
3598 .add_virtual_intf = WILC_WFI_add_virt_intf,
3599 .del_virtual_intf = WILC_WFI_del_virt_intf,
3600 .change_virtual_intf = WILC_WFI_change_virt_intf,
3601
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003602 .start_ap = WILC_WFI_start_ap,
3603 .change_beacon = WILC_WFI_change_beacon,
3604 .stop_ap = WILC_WFI_stop_ap,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003605 .add_station = WILC_WFI_add_station,
3606 .del_station = WILC_WFI_del_station,
3607 .change_station = WILC_WFI_change_station,
3608 #endif /* WILC_AP_EXTERNAL_MLME*/
3609 #ifndef WILC_FULLY_HOSTING_AP
3610 .get_station = WILC_WFI_get_station,
3611 #endif
3612 .dump_station = WILC_WFI_dump_station,
3613 .change_bss = WILC_WFI_change_bss,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003614 .set_wiphy_params = WILC_WFI_set_wiphy_params,
3615
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003616 .set_pmksa = WILC_WFI_set_pmksa,
3617 .del_pmksa = WILC_WFI_del_pmksa,
3618 .flush_pmksa = WILC_WFI_flush_pmksa,
3619#ifdef WILC_P2P
3620 .remain_on_channel = WILC_WFI_remain_on_channel,
3621 .cancel_remain_on_channel = WILC_WFI_cancel_remain_on_channel,
3622 .mgmt_tx_cancel_wait = WILC_WFI_mgmt_tx_cancel_wait,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003623 .mgmt_tx = WILC_WFI_mgmt_tx,
3624 .mgmt_frame_register = WILC_WFI_frame_register,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003625 .set_power_mgmt = WILC_WFI_set_power_mgmt,
3626 .set_cqm_rssi_config = WILC_WFI_set_cqm_rssi_config,
3627#endif
3628
3629};
3630
3631
3632
3633
3634
3635/**
3636 * @brief WILC_WFI_update_stats
3637 * @details Modify parameters for a given BSS.
3638 * @param[in]
3639 * @return int : Return 0 on Success.
3640 * @author mdaftedar
3641 * @date 01 MAR 2012
3642 * @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
3643 */
3644int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed)
3645{
3646
3647 struct WILC_WFI_priv *priv;
3648
3649 priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003650#if 1
3651 switch (changed) {
3652
3653 case WILC_WFI_RX_PKT:
3654 {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003655 priv->netstats.rx_packets++;
3656 priv->netstats.rx_bytes += pktlen;
3657 priv->netstats.rx_time = get_jiffies_64();
3658 }
3659 break;
3660
3661 case WILC_WFI_TX_PKT:
3662 {
3663 priv->netstats.tx_packets++;
3664 priv->netstats.tx_bytes += pktlen;
3665 priv->netstats.tx_time = get_jiffies_64();
3666
3667 }
3668 break;
3669
3670 default:
3671 break;
3672 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003673#endif
3674 return 0;
3675}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003676
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003677/**
3678 * @brief WILC_WFI_CfgAlloc
3679 * @details Allocation of the wireless device structure and assigning it
3680 * to the cfg80211 operations structure.
3681 * @param[in] NONE
3682 * @return wireless_dev : Returns pointer to wireless_dev structure.
3683 * @author mdaftedar
3684 * @date 01 MAR 2012
3685 * @version 1.0
3686 */
3687struct wireless_dev *WILC_WFI_CfgAlloc(void)
3688{
3689
3690 struct wireless_dev *wdev;
3691
3692
3693 PRINT_D(CFG80211_DBG, "Allocating wireless device\n");
3694 /*Allocating the wireless device structure*/
3695 wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
3696 if (!wdev) {
3697 PRINT_ER("Cannot allocate wireless device\n");
3698 goto _fail_;
3699 }
3700
3701 /*Creating a new wiphy, linking wireless structure with the wiphy structure*/
3702 wdev->wiphy = wiphy_new(&WILC_WFI_cfg80211_ops, sizeof(struct WILC_WFI_priv));
3703 if (!wdev->wiphy) {
3704 PRINT_ER("Cannot allocate wiphy\n");
3705 goto _fail_mem_;
3706
3707 }
3708
3709 #ifdef WILC_AP_EXTERNAL_MLME
3710 /* enable 802.11n HT */
3711 WILC_WFI_band_2ghz.ht_cap.ht_supported = 1;
3712 WILC_WFI_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT);
3713 WILC_WFI_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff;
3714 WILC_WFI_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K;
3715 WILC_WFI_band_2ghz.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE;
3716 #endif
3717
3718 /*wiphy bands*/
3719 wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &WILC_WFI_band_2ghz;
3720
3721 return wdev;
3722
3723_fail_mem_:
3724 kfree(wdev);
3725_fail_:
3726 return NULL;
3727
3728}
3729/**
3730 * @brief WILC_WFI_WiphyRegister
3731 * @details Registering of the wiphy structure and interface modes
3732 * @param[in] NONE
3733 * @return NONE
3734 * @author mdaftedar
3735 * @date 01 MAR 2012
3736 * @version 1.0
3737 */
3738struct wireless_dev *WILC_WFI_WiphyRegister(struct net_device *net)
3739{
3740 struct WILC_WFI_priv *priv;
3741 struct wireless_dev *wdev;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003742 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003743
3744 PRINT_D(CFG80211_DBG, "Registering wifi device\n");
3745
3746 wdev = WILC_WFI_CfgAlloc();
3747 if (wdev == NULL) {
3748 PRINT_ER("CfgAlloc Failed\n");
3749 return NULL;
3750 }
3751
3752
3753 /*Return hardware description structure (wiphy)'s priv*/
3754 priv = wdev_priv(wdev);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003755 sema_init(&(priv->SemHandleUpdateStats), 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003756
3757 /*Link the wiphy with wireless structure*/
3758 priv->wdev = wdev;
3759
3760 /*Maximum number of probed ssid to be added by user for the scan request*/
3761 wdev->wiphy->max_scan_ssids = MAX_NUM_PROBED_SSID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003762 /*Maximum number of pmkids to be cashed*/
3763 wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS;
3764 PRINT_INFO(CFG80211_DBG, "Max number of PMKIDs = %d\n", wdev->wiphy->max_num_pmkids);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003765
3766 wdev->wiphy->max_scan_ie_len = 1000;
3767
3768 /*signal strength in mBm (100*dBm) */
3769 wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
3770
3771 /*Set the availaible cipher suites*/
3772 wdev->wiphy->cipher_suites = cipher_suites;
3773 wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003774 /*Setting default managment types: for register action frame: */
3775 wdev->wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003776
3777#ifdef WILC_P2P
3778 wdev->wiphy->max_remain_on_channel_duration = 500;
3779 /*Setting the wiphy interfcae mode and type before registering the wiphy*/
3780 wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | BIT(NL80211_IFTYPE_P2P_GO) |
3781 BIT(NL80211_IFTYPE_P2P_CLIENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003782 wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003783#else
3784 wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR);
3785#endif
3786 wdev->iftype = NL80211_IFTYPE_STATION;
3787
3788
3789
3790 PRINT_INFO(CFG80211_DBG, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n",
3791 wdev->wiphy->max_scan_ssids, wdev->wiphy->max_scan_ie_len, wdev->wiphy->signal_type,
3792 wdev->wiphy->interface_modes, wdev->iftype);
3793
3794 #ifdef WILC_SDIO
3795 set_wiphy_dev(wdev->wiphy, &local_sdio_func->dev); /* tony */
3796 #endif
3797
3798 /*Register wiphy structure*/
3799 s32Error = wiphy_register(wdev->wiphy);
3800 if (s32Error) {
3801 PRINT_ER("Cannot register wiphy device\n");
3802 /*should define what action to be taken in such failure*/
3803 } else {
3804 PRINT_D(CFG80211_DBG, "Successful Registering\n");
3805 }
3806
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003807 priv->dev = net;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003808 return wdev;
3809
3810
3811}
3812/**
3813 * @brief WILC_WFI_WiphyFree
3814 * @details Freeing allocation of the wireless device structure
3815 * @param[in] NONE
3816 * @return NONE
3817 * @author mdaftedar
3818 * @date 01 MAR 2012
3819 * @version 1.0
3820 */
3821int WILC_WFI_InitHostInt(struct net_device *net)
3822{
3823
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003824 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003825
3826 struct WILC_WFI_priv *priv;
3827
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003828 PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr);
3829 priv = wdev_priv(net->ieee80211_ptr);
3830 if (op_ifcs == 0) {
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003831 s32Error = WILC_TimerCreate(&(hAgingTimer), remove_network_from_shadow, NULL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003832 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003833 s32Error = WILC_TimerCreate(&(hDuringIpTimer), clear_duringIP, NULL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003834 #endif
3835 }
3836 op_ifcs++;
3837 if (s32Error < 0) {
3838 PRINT_ER("Failed to creat refresh Timer\n");
3839 return s32Error;
3840 }
3841
Dean Lee72ed4dc2015-06-12 14:11:44 +09003842 priv->gbAutoRateAdjusted = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003843
Dean Lee72ed4dc2015-06-12 14:11:44 +09003844 priv->bInP2PlistenState = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003845
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003846 sema_init(&(priv->hSemScanReq), 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003847 s32Error = host_int_init(&priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003848 if (s32Error) {
3849 PRINT_ER("Error while initializing hostinterface\n");
3850 }
3851 return s32Error;
3852}
3853
3854/**
3855 * @brief WILC_WFI_WiphyFree
3856 * @details Freeing allocation of the wireless device structure
3857 * @param[in] NONE
3858 * @return NONE
3859 * @author mdaftedar
3860 * @date 01 MAR 2012
3861 * @version 1.0
3862 */
3863int WILC_WFI_DeInitHostInt(struct net_device *net)
3864{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003865 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003866
3867 struct WILC_WFI_priv *priv;
3868 priv = wdev_priv(net->ieee80211_ptr);
3869
Dean Lee72ed4dc2015-06-12 14:11:44 +09003870 priv->gbAutoRateAdjusted = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003871
Dean Lee72ed4dc2015-06-12 14:11:44 +09003872 priv->bInP2PlistenState = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003873
3874 op_ifcs--;
3875
3876 s32Error = host_int_deinit(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003877
3878 /* Clear the Shadow scan */
3879 clear_shadow_scan(priv);
3880 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3881 if (op_ifcs == 0) {
3882 PRINT_D(CORECONFIG_DBG, "destroy during ip\n");
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003883 WILC_TimerDestroy(&hDuringIpTimer, NULL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003884 }
3885 #endif
3886
3887 if (s32Error) {
3888 PRINT_ER("Error while deintializing host interface\n");
3889 }
3890 return s32Error;
3891}
3892
3893
3894/**
3895 * @brief WILC_WFI_WiphyFree
3896 * @details Freeing allocation of the wireless device structure
3897 * @param[in] NONE
3898 * @return NONE
3899 * @author mdaftedar
3900 * @date 01 MAR 2012
3901 * @version 1.0
3902 */
3903void WILC_WFI_WiphyFree(struct net_device *net)
3904{
3905
3906 PRINT_D(CFG80211_DBG, "Unregistering wiphy\n");
3907
3908 if (net == NULL) {
3909 PRINT_D(INIT_DBG, "net_device is NULL\n");
3910 return;
3911 }
3912
3913 if (net->ieee80211_ptr == NULL) {
3914 PRINT_D(INIT_DBG, "ieee80211_ptr is NULL\n");
3915 return;
3916 }
3917
3918 if (net->ieee80211_ptr->wiphy == NULL) {
3919 PRINT_D(INIT_DBG, "wiphy is NULL\n");
3920 return;
3921 }
3922
3923 wiphy_unregister(net->ieee80211_ptr->wiphy);
3924
3925 PRINT_D(INIT_DBG, "Freeing wiphy\n");
3926 wiphy_free(net->ieee80211_ptr->wiphy);
3927 kfree(net->ieee80211_ptr);
3928
3929}