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