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