Commit | Line | Data |
---|---|---|
c5c77ba1 | 1 | #include "host_interface.h" |
c5c77ba1 | 2 | #include "coreconfigurator.h" |
5366012d | 3 | #include "wilc_wlan_if.h" |
c5c77ba1 | 4 | |
63d03e47 | 5 | extern u8 connecting; |
c5c77ba1 JK |
6 | |
7 | #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP | |
da711eb6 | 8 | extern struct timer_list hDuringIpTimer; |
c5c77ba1 JK |
9 | #endif |
10 | ||
63d03e47 | 11 | extern u8 g_wilc_initialized; |
c5c77ba1 JK |
12 | /*****************************************************************************/ |
13 | /* Macros */ | |
14 | /*****************************************************************************/ | |
15 | ||
16 | /* Message types of the Host IF Message Queue*/ | |
9eac3a15 CL |
17 | #define HOST_IF_MSG_SCAN 0 |
18 | #define HOST_IF_MSG_CONNECT 1 | |
19 | #define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2 | |
20 | #define HOST_IF_MSG_KEY 3 | |
21 | #define HOST_IF_MSG_RCVD_NTWRK_INFO 4 | |
22 | #define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5 | |
23 | #define HOST_IF_MSG_CFG_PARAMS 6 | |
24 | #define HOST_IF_MSG_SET_CHANNEL 7 | |
25 | #define HOST_IF_MSG_DISCONNECT 8 | |
26 | #define HOST_IF_MSG_GET_RSSI 9 | |
27 | #define HOST_IF_MSG_GET_CHNL 10 | |
28 | #define HOST_IF_MSG_ADD_BEACON 11 | |
29 | #define HOST_IF_MSG_DEL_BEACON 12 | |
30 | #define HOST_IF_MSG_ADD_STATION 13 | |
31 | #define HOST_IF_MSG_DEL_STATION 14 | |
32 | #define HOST_IF_MSG_EDIT_STATION 15 | |
33 | #define HOST_IF_MSG_SCAN_TIMER_FIRED 16 | |
34 | #define HOST_IF_MSG_CONNECT_TIMER_FIRED 17 | |
35 | #define HOST_IF_MSG_POWER_MGMT 18 | |
36 | #define HOST_IF_MSG_GET_INACTIVETIME 19 | |
37 | #define HOST_IF_MSG_REMAIN_ON_CHAN 20 | |
38 | #define HOST_IF_MSG_REGISTER_FRAME 21 | |
39 | #define HOST_IF_MSG_LISTEN_TIMER_FIRED 22 | |
40 | #define HOST_IF_MSG_GET_LINKSPEED 23 | |
41 | #define HOST_IF_MSG_SET_WFIDRV_HANDLER 24 | |
42 | #define HOST_IF_MSG_SET_MAC_ADDRESS 25 | |
43 | #define HOST_IF_MSG_GET_MAC_ADDRESS 26 | |
44 | #define HOST_IF_MSG_SET_OPERATION_MODE 27 | |
45 | #define HOST_IF_MSG_SET_IPADDRESS 28 | |
46 | #define HOST_IF_MSG_GET_IPADDRESS 29 | |
47 | #define HOST_IF_MSG_FLUSH_CONNECT 30 | |
48 | #define HOST_IF_MSG_GET_STATISTICS 31 | |
49 | #define HOST_IF_MSG_SET_MULTICAST_FILTER 32 | |
50 | #define HOST_IF_MSG_ADD_BA_SESSION 33 | |
51 | #define HOST_IF_MSG_DEL_BA_SESSION 34 | |
52 | #define HOST_IF_MSG_Q_IDLE 35 | |
53 | #define HOST_IF_MSG_DEL_ALL_STA 36 | |
54 | #define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34 | |
55 | #define HOST_IF_MSG_EXIT 100 | |
d85f5326 | 56 | |
e54d5b75 CL |
57 | #define HOST_IF_SCAN_TIMEOUT 4000 |
58 | #define HOST_IF_CONNECT_TIMEOUT 9500 | |
c5c77ba1 | 59 | |
e54d5b75 CL |
60 | #define BA_SESSION_DEFAULT_BUFFER_SIZE 16 |
61 | #define BA_SESSION_DEFAULT_TIMEOUT 1000 | |
62 | #define BLOCK_ACK_REQ_SIZE 0x14 | |
c5c77ba1 JK |
63 | /*****************************************************************************/ |
64 | /* Type Definitions */ | |
65 | /*****************************************************************************/ | |
66 | ||
67 | /*! | |
361ff841 | 68 | * @struct cfg_param_attr |
c5c77ba1 JK |
69 | * @brief Structure to hold Host IF CFG Params Attributes |
70 | * @details | |
71 | * @todo | |
72 | * @sa | |
73 | * @author Mai Daftedar | |
74 | * @date 02 April 2012 | |
75 | * @version 1.0 | |
76 | */ | |
361ff841 | 77 | struct cfg_param_attr { |
c5c77ba1 | 78 | tstrCfgParamVal pstrCfgParamVal; |
361ff841 | 79 | }; |
c5c77ba1 JK |
80 | |
81 | /*! | |
82 | * @struct tstrHostIFwpaAttr | |
83 | * @brief Structure to hold Host IF Scan Attributes | |
84 | * @details | |
85 | * @todo | |
86 | * @sa | |
87 | * @author Mai Daftedar | |
88 | * @date 25 March 2012 | |
89 | * @version 1.0 | |
90 | */ | |
91 | typedef struct _tstrHostIFwpaAttr { | |
63d03e47 GKH |
92 | u8 *pu8key; |
93 | const u8 *pu8macaddr; | |
94 | u8 *pu8seq; | |
95 | u8 u8seqlen; | |
96 | u8 u8keyidx; | |
97 | u8 u8Keylen; | |
98 | u8 u8Ciphermode; | |
c5c77ba1 JK |
99 | } tstrHostIFwpaAttr; |
100 | ||
101 | ||
102 | /*! | |
103 | * @struct tstrHostIFwepAttr | |
104 | * @brief Structure to hold Host IF Scan Attributes | |
105 | * @details | |
106 | * @todo | |
107 | * @sa | |
108 | * @author Mai Daftedar | |
109 | * @date 25 March 2012 | |
110 | * @version 1.0 | |
111 | */ | |
112 | typedef struct _tstrHostIFwepAttr { | |
63d03e47 GKH |
113 | u8 *pu8WepKey; |
114 | u8 u8WepKeylen; | |
115 | u8 u8Wepidx; | |
116 | u8 u8mode; | |
c5c77ba1 JK |
117 | AUTHTYPE_T tenuAuth_type; |
118 | ||
119 | } tstrHostIFwepAttr; | |
120 | ||
121 | /*! | |
122 | * @struct tuniHostIFkeyAttr | |
123 | * @brief Structure to hold Host IF Scan Attributes | |
124 | * @details | |
125 | * @todo | |
126 | * @sa | |
127 | * @author Mai Daftedar | |
128 | * @date 25 March 2012 | |
129 | * @version 1.0 | |
130 | */ | |
131 | typedef union _tuniHostIFkeyAttr { | |
132 | tstrHostIFwepAttr strHostIFwepAttr; | |
133 | tstrHostIFwpaAttr strHostIFwpaAttr; | |
134 | tstrHostIFpmkidAttr strHostIFpmkidAttr; | |
135 | } tuniHostIFkeyAttr; | |
136 | ||
137 | /*! | |
c98387a5 | 138 | * @struct key_attr |
c5c77ba1 JK |
139 | * @brief Structure to hold Host IF Scan Attributes |
140 | * @details | |
141 | * @todo | |
142 | * @sa | |
143 | * @author Mai Daftedar | |
144 | * @date 25 March 2012 | |
145 | * @version 1.0 | |
146 | */ | |
c98387a5 | 147 | struct key_attr { |
c5c77ba1 | 148 | tenuKeyType enuKeyType; |
63d03e47 | 149 | u8 u8KeyAction; |
c5c77ba1 | 150 | tuniHostIFkeyAttr uniHostIFkeyAttr; |
c98387a5 | 151 | }; |
c5c77ba1 JK |
152 | |
153 | ||
154 | ||
155 | ||
156 | /*! | |
c476feb8 | 157 | * @struct scan_attr |
c5c77ba1 JK |
158 | * @brief Structure to hold Host IF Scan Attributes |
159 | * @details | |
160 | * @todo | |
161 | * @sa | |
162 | * @author Mostafa Abu Bakr | |
163 | * @date 25 March 2012 | |
164 | * @version 1.0 | |
165 | */ | |
c476feb8 | 166 | struct scan_attr { |
63d03e47 GKH |
167 | u8 u8ScanSource; |
168 | u8 u8ScanType; | |
169 | u8 *pu8ChnlFreqList; | |
170 | u8 u8ChnlListLen; | |
171 | u8 *pu8IEs; | |
c5c77ba1 JK |
172 | size_t IEsLen; |
173 | tWILCpfScanResult pfScanResult; | |
174 | void *pvUserArg; | |
c5c77ba1 | 175 | tstrHiddenNetwork strHiddenNetwork; |
c476feb8 | 176 | }; |
c5c77ba1 JK |
177 | |
178 | /*! | |
120ae593 | 179 | * @struct connect_attr |
c5c77ba1 JK |
180 | * @brief Structure to hold Host IF Connect Attributes |
181 | * @details | |
182 | * @todo | |
183 | * @sa | |
184 | * @author Mostafa Abu Bakr | |
185 | * @date 25 March 2012 | |
186 | * @version 1.0 | |
187 | */ | |
120ae593 | 188 | struct connect_attr { |
63d03e47 GKH |
189 | u8 *pu8bssid; |
190 | u8 *pu8ssid; | |
c5c77ba1 | 191 | size_t ssidLen; |
63d03e47 | 192 | u8 *pu8IEs; |
c5c77ba1 | 193 | size_t IEsLen; |
63d03e47 | 194 | u8 u8security; |
c5c77ba1 JK |
195 | tWILCpfConnectResult pfConnectResult; |
196 | void *pvUserArg; | |
197 | AUTHTYPE_T tenuAuth_type; | |
63d03e47 | 198 | u8 u8channel; |
c5c77ba1 | 199 | void *pJoinParams; |
120ae593 | 200 | }; |
c5c77ba1 JK |
201 | |
202 | /*! | |
f23a9eab | 203 | * @struct rcvd_async_info |
c5c77ba1 JK |
204 | * @brief Structure to hold Received General Asynchronous info |
205 | * @details | |
206 | * @todo | |
207 | * @sa | |
208 | * @author Mostafa Abu Bakr | |
209 | * @date 25 March 2012 | |
210 | * @version 1.0 | |
211 | */ | |
f23a9eab | 212 | struct rcvd_async_info { |
63d03e47 | 213 | u8 *pu8Buffer; |
4e4467fd | 214 | u32 u32Length; |
f23a9eab | 215 | }; |
c5c77ba1 JK |
216 | |
217 | /*! | |
326b323d | 218 | * @struct set_channel |
c5c77ba1 JK |
219 | * @brief Set Channel message body |
220 | * @details | |
221 | * @todo | |
222 | * @sa | |
223 | * @author Mai Daftedar | |
224 | * @date 25 March 2012 | |
225 | * @version 1.0 | |
226 | */ | |
326b323d | 227 | struct set_channel { |
63d03e47 | 228 | u8 u8SetChan; |
326b323d | 229 | }; |
c5c77ba1 JK |
230 | |
231 | /*! | |
29f84000 | 232 | * @struct get_channel |
c5c77ba1 JK |
233 | * @brief Get Channel message body |
234 | * @details | |
235 | * @todo | |
236 | * @sa | |
237 | * @author Mai Daftedar | |
238 | * @date 01 Jule 2012 | |
239 | * @version 1.0 | |
240 | */ | |
29f84000 | 241 | struct get_channel { |
63d03e47 | 242 | u8 u8GetChan; |
29f84000 | 243 | }; |
c5c77ba1 | 244 | |
c5c77ba1 JK |
245 | /*! |
246 | * @struct tstrScanComplete | |
247 | * @brief hold received Async. Scan Complete message body | |
248 | * @details | |
249 | * @todo | |
250 | * @sa | |
251 | * @author zsalah | |
252 | * @date 25 March 2012 | |
253 | * @version 1.0 | |
254 | */ | |
255 | /*typedef struct _tstrScanComplete | |
256 | * { | |
63d03e47 | 257 | * u8* pu8Buffer; |
4e4467fd | 258 | * u32 u32Length; |
c5c77ba1 JK |
259 | * } tstrScanComplete;*/ |
260 | ||
261 | /*! | |
902362b1 | 262 | * @struct set_beacon |
c5c77ba1 JK |
263 | * @brief Set Beacon message body |
264 | * @details | |
265 | * @todo | |
266 | * @sa | |
267 | * @author Adham Abozaeid | |
268 | * @date 10 July 2012 | |
269 | * @version 1.0 | |
270 | */ | |
902362b1 | 271 | struct set_beacon { |
4e4467fd CL |
272 | u32 u32Interval; /*!< Beacon Interval. Period between two successive beacons on air */ |
273 | u32 u32DTIMPeriod; /*!< DTIM Period. Indicates how many Beacon frames | |
c5c77ba1 | 274 | * (including the current frame) appear before the next DTIM */ |
4e4467fd | 275 | u32 u32HeadLen; /*!< Length of the head buffer in bytes */ |
63d03e47 | 276 | u8 *pu8Head; /*!< Pointer to the beacon's head buffer. Beacon's head is the part |
c5c77ba1 | 277 | * from the beacon's start till the TIM element, NOT including the TIM */ |
4e4467fd | 278 | u32 u32TailLen; /*!< Length of the tail buffer in bytes */ |
63d03e47 | 279 | u8 *pu8Tail; /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just |
c5c77ba1 | 280 | * after the TIM inormation element */ |
902362b1 | 281 | }; |
c5c77ba1 JK |
282 | |
283 | ||
284 | ||
285 | /*! | |
d0227fcb | 286 | * @struct del_beacon |
c5c77ba1 JK |
287 | * @brief Del Beacon message body |
288 | * @details | |
289 | * @todo | |
290 | * @sa | |
291 | * @author Adham Abozaeid | |
292 | * @date 15 July 2012 | |
293 | * @version 1.0 | |
294 | */ | |
d0227fcb | 295 | struct del_beacon { |
63d03e47 | 296 | u8 u8dummy; |
d0227fcb | 297 | }; |
c5c77ba1 JK |
298 | |
299 | /*! | |
641210ac | 300 | * @struct set_multicast |
c5c77ba1 JK |
301 | * @brief set Multicast filter Address |
302 | * @details | |
303 | * @todo | |
304 | * @sa | |
305 | * @author Abdelrahman Sobhy | |
306 | * @date 30 August 2013 | |
307 | * @version 1.0 Description | |
308 | */ | |
309 | ||
641210ac | 310 | struct set_multicast { |
72ed4dc7 | 311 | bool bIsEnabled; |
4e4467fd | 312 | u32 u32count; |
641210ac | 313 | }; |
c5c77ba1 JK |
314 | |
315 | /*! | |
b4e644e4 | 316 | * @struct del_all_sta |
c5c77ba1 JK |
317 | * @brief Deauth station message body |
318 | * @details | |
319 | * @todo | |
320 | * @sa | |
321 | * @author Mai Daftedar | |
322 | * @date 09 April 2014 | |
323 | * @version 1.0 Description | |
324 | */ | |
b4e644e4 | 325 | struct del_all_sta { |
63d03e47 GKH |
326 | u8 au8Sta_DelAllSta[MAX_NUM_STA][ETH_ALEN]; |
327 | u8 u8Num_AssocSta; | |
b4e644e4 | 328 | }; |
c5c77ba1 JK |
329 | |
330 | /*! | |
fb93a1e1 | 331 | * @struct del_sta |
c5c77ba1 JK |
332 | * @brief Delete station message body |
333 | * @details | |
334 | * @todo | |
335 | * @sa | |
336 | * @author Adham Abozaeid | |
337 | * @date 15 July 2012 | |
338 | * @version 1.0 Description | |
339 | */ | |
fb93a1e1 | 340 | struct del_sta { |
63d03e47 | 341 | u8 au8MacAddr[ETH_ALEN]; |
fb93a1e1 | 342 | }; |
c5c77ba1 JK |
343 | |
344 | /*! | |
52581934 | 345 | * @struct timer_cb |
c5c77ba1 JK |
346 | * @brief Timer callback message body |
347 | * @details | |
348 | * @todo | |
349 | * @sa | |
350 | * @author Mostafa Abu Bakr | |
351 | * @date 25 March 2012 | |
352 | * @version 1.0 | |
353 | */ | |
52581934 | 354 | struct timer_cb { |
c5c77ba1 | 355 | void *pvUsrArg; /*!< Private data passed at timer start */ |
52581934 | 356 | }; |
c5c77ba1 JK |
357 | |
358 | /*! | |
5a008f1c | 359 | * @struct power_mgmt_param |
c5c77ba1 JK |
360 | * @brief Power management message body |
361 | * @details | |
362 | * @todo | |
363 | * @sa | |
364 | * @author Adham Abozaeid | |
365 | * @date 24 November 2012 | |
366 | * @version 1.0 | |
367 | */ | |
5a008f1c | 368 | struct power_mgmt_param { |
c5c77ba1 | 369 | |
72ed4dc7 | 370 | bool bIsEnabled; |
4e4467fd | 371 | u32 u32Timeout; |
5a008f1c | 372 | }; |
c5c77ba1 JK |
373 | |
374 | /*! | |
15191eaf | 375 | * @struct set_ip_addr |
c5c77ba1 JK |
376 | * @brief set IP Address message body |
377 | * @details | |
378 | * @todo | |
379 | * @sa | |
380 | * @author Abdelrahman Sobhy | |
381 | * @date 30 August 2013 | |
382 | * @version 1.0 Description | |
383 | */ | |
15191eaf | 384 | struct set_ip_addr { |
63d03e47 GKH |
385 | u8 *au8IPAddr; |
386 | u8 idx; | |
15191eaf | 387 | }; |
c5c77ba1 JK |
388 | |
389 | /*! | |
3d1eac04 | 390 | * @struct sta_inactive_t |
c5c77ba1 JK |
391 | * @brief Get station message body |
392 | * @details | |
393 | * @todo | |
394 | * @sa | |
395 | * @author Mai Daftedar | |
396 | * @date 16 April 2013 | |
397 | * @version 1.0 | |
398 | */ | |
3d1eac04 | 399 | struct sta_inactive_t { |
63d03e47 | 400 | u8 mac[6]; |
3d1eac04 | 401 | }; |
c5c77ba1 JK |
402 | /**/ |
403 | /*! | |
dfc7663b | 404 | * @union message_body |
c5c77ba1 JK |
405 | * @brief Message body for the Host Interface message_q |
406 | * @details | |
407 | * @todo | |
408 | * @sa | |
409 | * @author Mostafa Abu Bakr | |
410 | * @date 25 March 2012 | |
411 | * @version 1.0 | |
412 | */ | |
dfc7663b | 413 | union message_body { |
a5a45ba2 TC |
414 | struct scan_attr strHostIFscanAttr; |
415 | struct connect_attr strHostIFconnectAttr; | |
416 | struct rcvd_net_info strRcvdNetworkInfo; | |
417 | struct rcvd_async_info strRcvdGnrlAsyncInfo; | |
418 | struct key_attr strHostIFkeyAttr; | |
419 | struct cfg_param_attr strHostIFCfgParamAttr; | |
326b323d | 420 | struct set_channel strHostIFSetChan; |
29f84000 | 421 | struct get_channel strHostIFGetChan; |
a5a45ba2 TC |
422 | struct set_beacon strHostIFSetBeacon; |
423 | struct del_beacon strHostIFDelBeacon; | |
424 | struct add_sta_param strAddStaParam; | |
425 | struct del_sta strDelStaParam; | |
426 | struct add_sta_param strEditStaParam; | |
427 | struct timer_cb strTimerCb; | |
428 | struct power_mgmt_param strPowerMgmtparam; | |
3d1eac04 | 429 | struct sta_inactive_t strHostIfStaInactiveT; |
15191eaf | 430 | struct set_ip_addr strHostIfSetIP; |
127f9d94 | 431 | struct drv_handler strHostIfSetDrvHandler; |
641210ac | 432 | struct set_multicast strHostIfSetMulti; |
801bee52 | 433 | struct op_mode strHostIfSetOperationMode; |
b7611a87 | 434 | struct set_mac_addr strHostIfSetMacAddress; |
fcd27c5f | 435 | struct get_mac_addr strHostIfGetMacAddress; |
54265472 | 436 | struct ba_session_info strHostIfBASessionInfo; |
2f9c03f5 | 437 | struct remain_ch strHostIfRemainOnChan; |
bc37c5df | 438 | struct reg_frame strHostIfRegisterFrame; |
576917ad | 439 | char *pUserData; |
b4e644e4 | 440 | struct del_all_sta strHostIFDelAllSta; |
dfc7663b | 441 | }; |
c5c77ba1 JK |
442 | |
443 | /*! | |
3a8c41b5 | 444 | * @struct struct host_if_msg |
c5c77ba1 JK |
445 | * @brief Host Interface message |
446 | * @details | |
447 | * @todo | |
448 | * @sa | |
449 | * @author Mostafa Abu Bakr | |
450 | * @date 25 March 2012 | |
451 | * @version 1.0 | |
452 | */ | |
3a8c41b5 | 453 | struct host_if_msg { |
a9f812a6 | 454 | u16 id; /*!< Message ID */ |
410c2489 | 455 | union message_body body; /*!< Message body */ |
11f58c88 | 456 | tstrWILC_WFIDrv *drvHandler; |
3a8c41b5 | 457 | }; |
c5c77ba1 JK |
458 | |
459 | #ifdef CONNECT_DIRECT | |
460 | typedef struct _tstrWidJoinReqExt { | |
576917ad | 461 | char SSID[MAX_SSID_LEN]; |
63d03e47 GKH |
462 | u8 u8channel; |
463 | u8 BSSID[6]; | |
c5c77ba1 JK |
464 | } tstrWidJoinReqExt; |
465 | #endif | |
466 | ||
c5c77ba1 JK |
467 | #ifdef WILC_PARSE_SCAN_IN_HOST |
468 | /*Struct containg joinParam of each AP*/ | |
469 | typedef struct _tstrJoinBssParam { | |
470 | BSSTYPE_T bss_type; | |
63d03e47 | 471 | u8 dtim_period; |
d85f5326 CL |
472 | u16 beacon_period; |
473 | u16 cap_info; | |
63d03e47 | 474 | u8 au8bssid[6]; |
576917ad | 475 | char ssid[MAX_SSID_LEN]; |
63d03e47 GKH |
476 | u8 ssidLen; |
477 | u8 supp_rates[MAX_RATES_SUPPORTED + 1]; | |
478 | u8 ht_capable; | |
479 | u8 wmm_cap; | |
480 | u8 uapsd_cap; | |
72ed4dc7 | 481 | bool rsn_found; |
63d03e47 GKH |
482 | u8 rsn_grp_policy; |
483 | u8 mode_802_11i; | |
484 | u8 rsn_pcip_policy[3]; | |
485 | u8 rsn_auth_policy[3]; | |
486 | u8 rsn_cap[2]; | |
c5c77ba1 | 487 | struct _tstrJoinParam *nextJoinBss; |
4e4467fd | 488 | u32 tsf; |
63d03e47 GKH |
489 | u8 u8NoaEnbaled; |
490 | u8 u8OppEnable; | |
491 | u8 u8CtWindow; | |
492 | u8 u8Count; | |
493 | u8 u8Index; | |
494 | u8 au8Duration[4]; | |
495 | u8 au8Interval[4]; | |
496 | u8 au8StartTime[4]; | |
c5c77ba1 | 497 | } tstrJoinBssParam; |
c5c77ba1 JK |
498 | /*a linked list table containing needed join parameters entries for each AP found in most recent scan*/ |
499 | typedef struct _tstrBssTable { | |
63d03e47 | 500 | u8 u8noBssEntries; |
c5c77ba1 JK |
501 | tstrJoinBssParam *head; |
502 | tstrJoinBssParam *tail; | |
503 | } tstrBssTable; | |
504 | #endif /*WILC_PARSE_SCAN_IN_HOST*/ | |
505 | ||
506 | typedef enum { | |
507 | SCAN_TIMER = 0, | |
508 | CONNECT_TIMER = 1, | |
509 | SCAN_CONNECT_TIMER_FORCE_32BIT = 0xFFFFFFFF | |
510 | } tenuScanConnTimer; | |
511 | ||
512 | /*****************************************************************************/ | |
513 | /* */ | |
514 | /* Global Variabls */ | |
515 | /* */ | |
516 | /*****************************************************************************/ | |
d42ab083 JK |
517 | /* Zero is not used, because a zero ID means termination */ |
518 | static tstrWILC_WFIDrv *wfidrv_list[NUM_CONCURRENT_IFC + 1]; | |
6fdb302c DM |
519 | tstrWILC_WFIDrv *terminated_handle; |
520 | tstrWILC_WFIDrv *gWFiDrvHandle; | |
c5c77ba1 | 521 | #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP |
72ed4dc7 | 522 | bool g_obtainingIP = false; |
c5c77ba1 | 523 | #endif |
63d03e47 | 524 | u8 P2P_LISTEN_STATE; |
1999bd52 | 525 | static struct task_struct *HostIFthreadHandler; |
c5c77ba1 | 526 | static WILC_MsgQueueHandle gMsgQHostIF; |
83383ea3 | 527 | static struct semaphore hSemHostIFthrdEnd; |
c5c77ba1 | 528 | |
83383ea3 AB |
529 | struct semaphore hSemDeinitDrvHandle; |
530 | static struct semaphore hWaitResponse; | |
531 | struct semaphore hSemHostIntDeinit; | |
da711eb6 | 532 | struct timer_list g_hPeriodicRSSI; |
c5c77ba1 JK |
533 | |
534 | ||
535 | ||
63d03e47 | 536 | u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN]; |
c5c77ba1 JK |
537 | |
538 | #ifndef CONNECT_DIRECT | |
63d03e47 | 539 | static u8 gapu8RcvdSurveyResults[2][MAX_SURVEY_RESULT_FRAG_SIZE]; |
c5c77ba1 JK |
540 | #endif |
541 | ||
63d03e47 | 542 | static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE]; |
c5c77ba1 | 543 | |
72ed4dc7 | 544 | bool gbScanWhileConnected = false; |
c5c77ba1 | 545 | |
ca356ada CL |
546 | static s8 gs8Rssi; |
547 | static s8 gs8lnkspd; | |
63d03e47 GKH |
548 | static u8 gu8Chnl; |
549 | static u8 gs8SetIP[2][4]; | |
550 | static u8 gs8GetIP[2][4]; | |
4e4467fd | 551 | static u32 gu32InactiveTime; |
63d03e47 | 552 | static u8 gu8DelBcn; |
4e4467fd | 553 | static u32 gu32WidConnRstHack; |
c5c77ba1 | 554 | |
63d03e47 GKH |
555 | u8 *gu8FlushedJoinReq; |
556 | u8 *gu8FlushedInfoElemAsoc; | |
557 | u8 gu8Flushed11iMode; | |
558 | u8 gu8FlushedAuthType; | |
4e4467fd CL |
559 | u32 gu32FlushedJoinReqSize; |
560 | u32 gu32FlushedInfoElemAsocSize; | |
8a625cad | 561 | tstrWILC_WFIDrv *gu8FlushedJoinReqDrvHandler; |
c5c77ba1 JK |
562 | #define REAL_JOIN_REQ 0 |
563 | #define FLUSHED_JOIN_REQ 1 | |
564 | #define FLUSHED_BYTE_POS 79 /* Position the byte indicating flushing in the flushed request */ | |
565 | ||
c5c77ba1 | 566 | #ifdef WILC_PARSE_SCAN_IN_HOST |
c5c77ba1 JK |
567 | static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo); |
568 | #endif /*WILC_PARSE_SCAN_IN_HOST*/ | |
569 | ||
4e4467fd | 570 | extern void chip_sleep_manually(u32 u32SleepTime); |
c5c77ba1 JK |
571 | extern int linux_wlan_get_num_conn_ifcs(void); |
572 | ||
d42ab083 JK |
573 | static int add_handler_in_list(tstrWILC_WFIDrv *handler) |
574 | { | |
575 | int i; | |
576 | ||
577 | for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) { | |
578 | if (!wfidrv_list[i]) { | |
579 | wfidrv_list[i] = handler; | |
580 | return 0; | |
581 | } | |
582 | } | |
583 | ||
584 | return -ENOBUFS; | |
585 | } | |
586 | ||
587 | static int remove_handler_in_list(tstrWILC_WFIDrv *handler) | |
588 | { | |
589 | int i; | |
590 | ||
591 | for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) { | |
592 | if (wfidrv_list[i] == handler) { | |
593 | wfidrv_list[i] = NULL; | |
594 | return 0; | |
595 | } | |
596 | } | |
597 | ||
598 | return -EINVAL; | |
599 | } | |
600 | ||
601 | static int get_id_from_handler(tstrWILC_WFIDrv *handler) | |
602 | { | |
603 | int i; | |
604 | ||
605 | if (!handler) | |
606 | return 0; | |
607 | ||
608 | for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) { | |
609 | if (wfidrv_list[i] == handler) | |
610 | return i; | |
611 | } | |
612 | ||
613 | return 0; | |
614 | } | |
615 | ||
616 | static tstrWILC_WFIDrv *get_handler_from_id(int id) | |
617 | { | |
6ae9ac0b | 618 | if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list)) |
d42ab083 JK |
619 | return NULL; |
620 | return wfidrv_list[id]; | |
621 | } | |
622 | ||
c5c77ba1 JK |
623 | /** |
624 | * @brief Handle_SetChannel | |
625 | * @details Sending config packet to firmware to set channel | |
326b323d | 626 | * @param[in] struct set_channel *pstrHostIFSetChan |
c5c77ba1 JK |
627 | * @return Error code. |
628 | * @author | |
629 | * @date | |
630 | * @version 1.0 | |
631 | */ | |
326b323d TC |
632 | static s32 Handle_SetChannel(tstrWILC_WFIDrv *drvHandler, |
633 | struct set_channel *pstrHostIFSetChan) | |
c5c77ba1 JK |
634 | { |
635 | ||
e6e12661 | 636 | s32 s32Error = 0; |
c5c77ba1 JK |
637 | tstrWID strWID; |
638 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; | |
639 | ||
640 | /*prepare configuration packet*/ | |
d85f5326 | 641 | strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL; |
c5c77ba1 | 642 | strWID.enuWIDtype = WID_CHAR; |
576917ad DL |
643 | strWID.ps8WidVal = (char *)&(pstrHostIFSetChan->u8SetChan); |
644 | strWID.s32ValueSize = sizeof(char); | |
c5c77ba1 JK |
645 | |
646 | PRINT_D(HOSTINF_DBG, "Setting channel\n"); | |
647 | /*Sending Cfg*/ | |
d42ab083 JK |
648 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
649 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 JK |
650 | if (s32Error) { |
651 | PRINT_ER("Failed to set channel\n"); | |
24db713f | 652 | return -EINVAL; |
c5c77ba1 JK |
653 | } |
654 | ||
655 | return s32Error; | |
656 | } | |
657 | /** | |
658 | * @brief Handle_SetWfiDrvHandler | |
659 | * @details Sending config packet to firmware to set driver handler | |
127f9d94 TC |
660 | * @param[in] void * drvHandler, |
661 | * struct drv_handler *pstrHostIfSetDrvHandler | |
c5c77ba1 JK |
662 | * @return Error code. |
663 | * @author | |
664 | * @date | |
665 | * @version 1.0 | |
666 | */ | |
53a84401 | 667 | static s32 Handle_SetWfiDrvHandler(tstrWILC_WFIDrv *drvHandler, |
127f9d94 | 668 | struct drv_handler *pstrHostIfSetDrvHandler) |
c5c77ba1 JK |
669 | { |
670 | ||
e6e12661 | 671 | s32 s32Error = 0; |
c5c77ba1 | 672 | tstrWID strWID; |
53a84401 | 673 | tstrWILC_WFIDrv *pstrWFIDrv = drvHandler; |
c5c77ba1 JK |
674 | |
675 | ||
676 | /*prepare configuration packet*/ | |
d85f5326 | 677 | strWID.u16WIDid = (u16)WID_SET_DRV_HANDLER; |
c5c77ba1 | 678 | strWID.enuWIDtype = WID_INT; |
ca356ada | 679 | strWID.ps8WidVal = (s8 *)&(pstrHostIfSetDrvHandler->u32Address); |
4e4467fd | 680 | strWID.s32ValueSize = sizeof(u32); |
c5c77ba1 JK |
681 | |
682 | /*Sending Cfg*/ | |
683 | ||
d42ab083 JK |
684 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
685 | pstrHostIfSetDrvHandler->u32Address); | |
c5c77ba1 | 686 | |
53a84401 | 687 | if (pstrWFIDrv == NULL) |
83383ea3 | 688 | up(&hSemDeinitDrvHandle); |
c5c77ba1 JK |
689 | |
690 | ||
691 | if (s32Error) { | |
692 | PRINT_ER("Failed to set driver handler\n"); | |
24db713f | 693 | return -EINVAL; |
c5c77ba1 JK |
694 | } |
695 | ||
696 | return s32Error; | |
697 | } | |
698 | ||
699 | /** | |
700 | * @brief Handle_SetWfiAPDrvHandler | |
701 | * @details Sending config packet to firmware to set driver handler | |
702 | * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler | |
703 | * @return Error code. | |
704 | * @author | |
705 | * @date | |
706 | * @version 1.0 | |
707 | */ | |
801bee52 TC |
708 | static s32 Handle_SetOperationMode(tstrWILC_WFIDrv *drvHandler, |
709 | struct op_mode *pstrHostIfSetOperationMode) | |
c5c77ba1 JK |
710 | { |
711 | ||
e6e12661 | 712 | s32 s32Error = 0; |
c5c77ba1 JK |
713 | tstrWID strWID; |
714 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; | |
715 | ||
716 | ||
717 | /*prepare configuration packet*/ | |
d85f5326 | 718 | strWID.u16WIDid = (u16)WID_SET_OPERATION_MODE; |
c5c77ba1 | 719 | strWID.enuWIDtype = WID_INT; |
ca356ada | 720 | strWID.ps8WidVal = (s8 *)&(pstrHostIfSetOperationMode->u32Mode); |
4e4467fd | 721 | strWID.s32ValueSize = sizeof(u32); |
c5c77ba1 JK |
722 | |
723 | /*Sending Cfg*/ | |
03b2d5e7 | 724 | PRINT_INFO(HOSTINF_DBG, "pstrWFIDrv= %p\n", pstrWFIDrv); |
c5c77ba1 | 725 | |
d42ab083 JK |
726 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
727 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 JK |
728 | |
729 | ||
c590b9a4 | 730 | if ((pstrHostIfSetOperationMode->u32Mode) == IDLE_MODE) |
83383ea3 | 731 | up(&hSemDeinitDrvHandle); |
c5c77ba1 JK |
732 | |
733 | ||
734 | if (s32Error) { | |
735 | PRINT_ER("Failed to set driver handler\n"); | |
24db713f | 736 | return -EINVAL; |
c5c77ba1 JK |
737 | } |
738 | ||
739 | return s32Error; | |
740 | } | |
741 | ||
742 | /** | |
743 | * @brief host_int_set_IPAddress | |
744 | * @details Setting IP address params in message queue | |
63d03e47 | 745 | * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr |
c5c77ba1 JK |
746 | * @return Error code. |
747 | * @author | |
748 | * @date | |
749 | * @version 1.0 | |
750 | */ | |
2b05df55 | 751 | s32 Handle_set_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 *pu8IPAddr, u8 idx) |
c5c77ba1 JK |
752 | { |
753 | ||
e6e12661 | 754 | s32 s32Error = 0; |
c5c77ba1 JK |
755 | tstrWID strWID; |
756 | char firmwareIPAddress[4] = {0}; | |
757 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; | |
758 | ||
759 | if (pu8IPAddr[0] < 192) | |
760 | pu8IPAddr[0] = 0; | |
761 | ||
b3a02832 | 762 | PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n", idx, pu8IPAddr); |
c5c77ba1 | 763 | |
d00d2ba3 | 764 | memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN); |
c5c77ba1 JK |
765 | |
766 | /*prepare configuration packet*/ | |
d85f5326 | 767 | strWID.u16WIDid = (u16)WID_IP_ADDRESS; |
c5c77ba1 | 768 | strWID.enuWIDtype = WID_STR; |
63d03e47 | 769 | strWID.ps8WidVal = (u8 *)pu8IPAddr; |
c5c77ba1 JK |
770 | strWID.s32ValueSize = IP_ALEN; |
771 | ||
d42ab083 JK |
772 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
773 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 JK |
774 | |
775 | ||
218dc407 | 776 | host_int_get_ipaddress(drvHandler, firmwareIPAddress, idx); |
c5c77ba1 JK |
777 | |
778 | if (s32Error) { | |
24db713f LK |
779 | PRINT_ER("Failed to set IP address\n"); |
780 | return -EINVAL; | |
c5c77ba1 JK |
781 | } |
782 | ||
24db713f | 783 | PRINT_INFO(HOSTINF_DBG, "IP address set\n"); |
c5c77ba1 JK |
784 | |
785 | return s32Error; | |
786 | } | |
787 | ||
788 | ||
789 | /** | |
790 | * @brief Handle_get_IPAddress | |
791 | * @details Setting IP address params in message queue | |
63d03e47 | 792 | * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr |
c5c77ba1 JK |
793 | * @return Error code. |
794 | * @author | |
795 | * @date | |
796 | * @version 1.0 | |
797 | */ | |
2b05df55 | 798 | s32 Handle_get_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 *pu8IPAddr, u8 idx) |
c5c77ba1 JK |
799 | { |
800 | ||
e6e12661 | 801 | s32 s32Error = 0; |
c5c77ba1 JK |
802 | tstrWID strWID; |
803 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; | |
804 | ||
805 | /*prepare configuration packet*/ | |
d85f5326 | 806 | strWID.u16WIDid = (u16)WID_IP_ADDRESS; |
c5c77ba1 | 807 | strWID.enuWIDtype = WID_STR; |
f3052587 | 808 | strWID.ps8WidVal = kmalloc(IP_ALEN, GFP_KERNEL); |
c5c77ba1 JK |
809 | strWID.s32ValueSize = IP_ALEN; |
810 | ||
d42ab083 JK |
811 | s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, |
812 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 | 813 | |
b3a02832 | 814 | PRINT_INFO(HOSTINF_DBG, "%pI4\n", strWID.ps8WidVal); |
c5c77ba1 | 815 | |
d00d2ba3 | 816 | memcpy(gs8GetIP[idx], strWID.ps8WidVal, IP_ALEN); |
c5c77ba1 JK |
817 | |
818 | /*get the value by searching the local copy*/ | |
49188af2 | 819 | kfree(strWID.ps8WidVal); |
c5c77ba1 | 820 | |
1a646e7e | 821 | if (memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0) |
218dc407 | 822 | host_int_setup_ipaddress(pstrWFIDrv, gs8SetIP[idx], idx); |
c5c77ba1 | 823 | |
e6e12661 | 824 | if (s32Error != 0) { |
c5c77ba1 | 825 | PRINT_ER("Failed to get IP address\n"); |
24db713f | 826 | return -EINVAL; |
c5c77ba1 JK |
827 | } |
828 | ||
24db713f LK |
829 | PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx); |
830 | PRINT_INFO(HOSTINF_DBG, "%pI4\n", gs8GetIP[idx]); | |
831 | PRINT_INFO(HOSTINF_DBG, "\n"); | |
c5c77ba1 JK |
832 | |
833 | return s32Error; | |
834 | } | |
835 | ||
836 | ||
c5c77ba1 JK |
837 | /** |
838 | * @brief Handle_SetMacAddress | |
839 | * @details Setting mac address | |
840 | * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler | |
841 | * @return Error code. | |
842 | * @author Amr Abdel-Moghny | |
843 | * @date November 2013 | |
844 | * @version 7.0 | |
845 | */ | |
b7611a87 TC |
846 | static s32 Handle_SetMacAddress(tstrWILC_WFIDrv *drvHandler, |
847 | struct set_mac_addr *pstrHostIfSetMacAddress) | |
c5c77ba1 JK |
848 | { |
849 | ||
e6e12661 | 850 | s32 s32Error = 0; |
c5c77ba1 JK |
851 | tstrWID strWID; |
852 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; | |
f3052587 | 853 | u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL); |
78c87591 | 854 | |
c5c77ba1 JK |
855 | if (mac_buf == NULL) { |
856 | PRINT_ER("No buffer to send mac address\n"); | |
e6e12661 | 857 | return -EFAULT; |
c5c77ba1 | 858 | } |
d00d2ba3 | 859 | memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN); |
c5c77ba1 JK |
860 | |
861 | /*prepare configuration packet*/ | |
d85f5326 | 862 | strWID.u16WIDid = (u16)WID_MAC_ADDR; |
c5c77ba1 JK |
863 | strWID.enuWIDtype = WID_STR; |
864 | strWID.ps8WidVal = mac_buf; | |
865 | strWID.s32ValueSize = ETH_ALEN; | |
310a28fd | 866 | PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", strWID.ps8WidVal); |
c5c77ba1 | 867 | /*Sending Cfg*/ |
d42ab083 JK |
868 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
869 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 JK |
870 | if (s32Error) { |
871 | PRINT_ER("Failed to set mac address\n"); | |
24db713f | 872 | s32Error = -EFAULT; |
c5c77ba1 JK |
873 | } |
874 | ||
49188af2 | 875 | kfree(mac_buf); |
c5c77ba1 JK |
876 | return s32Error; |
877 | } | |
878 | ||
879 | ||
c5c77ba1 JK |
880 | /** |
881 | * @brief Handle_GetMacAddress | |
882 | * @details Getting mac address | |
883 | * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler | |
884 | * @return Error code. | |
885 | * @author Amr Abdel-Moghny | |
886 | * @date JAN 2013 | |
887 | * @version 8.0 | |
888 | */ | |
fcd27c5f TC |
889 | static s32 Handle_GetMacAddress(tstrWILC_WFIDrv *drvHandler, |
890 | struct get_mac_addr *pstrHostIfGetMacAddress) | |
c5c77ba1 JK |
891 | { |
892 | ||
e6e12661 | 893 | s32 s32Error = 0; |
c5c77ba1 JK |
894 | tstrWID strWID; |
895 | ||
896 | /*prepare configuration packet*/ | |
d85f5326 | 897 | strWID.u16WIDid = (u16)WID_MAC_ADDR; |
c5c77ba1 JK |
898 | strWID.enuWIDtype = WID_STR; |
899 | strWID.ps8WidVal = pstrHostIfGetMacAddress->u8MacAddress; | |
900 | strWID.s32ValueSize = ETH_ALEN; | |
901 | ||
902 | /*Sending Cfg*/ | |
d42ab083 JK |
903 | s32Error = SendConfigPkt(GET_CFG, &strWID, 1, false, |
904 | get_id_from_handler(drvHandler)); | |
c5c77ba1 JK |
905 | if (s32Error) { |
906 | PRINT_ER("Failed to get mac address\n"); | |
24db713f | 907 | s32Error = -EFAULT; |
c5c77ba1 | 908 | } |
83383ea3 | 909 | up(&hWaitResponse); |
c5c77ba1 JK |
910 | |
911 | return s32Error; | |
912 | } | |
913 | ||
914 | ||
915 | /** | |
916 | * @brief Handle_CfgParam | |
917 | * @details Sending config packet to firmware to set CFG params | |
361ff841 | 918 | * @param[in] struct cfg_param_attr *strHostIFCfgParamAttr |
c5c77ba1 JK |
919 | * @return Error code. |
920 | * @author | |
921 | * @date | |
922 | * @version 1.0 | |
923 | */ | |
361ff841 TC |
924 | static s32 Handle_CfgParam(tstrWILC_WFIDrv *drvHandler, |
925 | struct cfg_param_attr *strHostIFCfgParamAttr) | |
c5c77ba1 | 926 | { |
e6e12661 | 927 | s32 s32Error = 0; |
c5c77ba1 | 928 | tstrWID strWIDList[32]; |
63d03e47 | 929 | u8 u8WidCnt = 0; |
c5c77ba1 JK |
930 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; |
931 | ||
932 | ||
83383ea3 | 933 | down(&(pstrWFIDrv->gtOsCfgValuesSem)); |
c5c77ba1 JK |
934 | |
935 | ||
936 | PRINT_D(HOSTINF_DBG, "Setting CFG params\n"); | |
937 | ||
938 | if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BSS_TYPE) { | |
939 | /*----------------------------------------------------------*/ | |
940 | /*Input Value: INFRASTRUCTURE = 1, */ | |
941 | /* INDEPENDENT= 2, */ | |
942 | /* ANY_BSS= 3 */ | |
943 | /*----------------------------------------------------------*/ | |
944 | /* validate input then copy>> need to check value 4 and 5 */ | |
945 | if (strHostIFCfgParamAttr->pstrCfgParamVal.bss_type < 6) { | |
946 | strWIDList[u8WidCnt].u16WIDid = WID_BSS_TYPE; | |
ca356ada | 947 | strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.bss_type; |
c5c77ba1 | 948 | strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; |
576917ad | 949 | strWIDList[u8WidCnt].s32ValueSize = sizeof(char); |
63d03e47 | 950 | pstrWFIDrv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.bss_type; |
c5c77ba1 | 951 | } else { |
24db713f LK |
952 | PRINT_ER("check value 6 over\n"); |
953 | s32Error = -EINVAL; | |
954 | goto ERRORHANDLER; | |
c5c77ba1 JK |
955 | } |
956 | u8WidCnt++; | |
957 | } | |
958 | if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTH_TYPE) { | |
959 | /*------------------------------------------------------*/ | |
960 | /*Input Values: OPEN_SYSTEM = 0, */ | |
961 | /* SHARED_KEY = 1, */ | |
962 | /* ANY = 2 */ | |
963 | /*------------------------------------------------------*/ | |
964 | /*validate Possible values*/ | |
965 | if ((strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 1 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 2 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 5) { | |
966 | strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TYPE; | |
ca356ada | 967 | strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_type; |
c5c77ba1 | 968 | strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; |
576917ad | 969 | strWIDList[u8WidCnt].s32ValueSize = sizeof(char); |
63d03e47 | 970 | pstrWFIDrv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.auth_type; |
c5c77ba1 | 971 | } else { |
24db713f LK |
972 | PRINT_ER("Impossible value \n"); |
973 | s32Error = -EINVAL; | |
974 | goto ERRORHANDLER; | |
c5c77ba1 JK |
975 | } |
976 | u8WidCnt++; | |
977 | } | |
978 | if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTHEN_TIMEOUT) { | |
979 | /* range is 1 to 65535. */ | |
980 | if (strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout < 65536) { | |
981 | strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TIMEOUT; | |
ca356ada | 982 | strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout; |
c5c77ba1 | 983 | strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; |
d85f5326 | 984 | strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); |
c5c77ba1 JK |
985 | pstrWFIDrv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout; |
986 | } else { | |
24db713f LK |
987 | PRINT_ER("Range(1 ~ 65535) over\n"); |
988 | s32Error = -EINVAL; | |
989 | goto ERRORHANDLER; | |
c5c77ba1 JK |
990 | } |
991 | u8WidCnt++; | |
992 | } | |
993 | if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & POWER_MANAGEMENT) { | |
994 | /*-----------------------------------------------------------*/ | |
995 | /*Input Values: NO_POWERSAVE = 0, */ | |
996 | /* MIN_FAST_PS = 1, */ | |
997 | /* MAX_FAST_PS = 2, */ | |
998 | /* MIN_PSPOLL_PS = 3, */ | |
999 | /* MAX_PSPOLL_PS = 4 */ | |
1000 | /*----------------------------------------------------------*/ | |
1001 | if (strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode < 5) { | |
1002 | strWIDList[u8WidCnt].u16WIDid = WID_POWER_MANAGEMENT; | |
ca356ada | 1003 | strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode; |
c5c77ba1 | 1004 | strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; |
576917ad | 1005 | strWIDList[u8WidCnt].s32ValueSize = sizeof(char); |
63d03e47 | 1006 | pstrWFIDrv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode; |
c5c77ba1 | 1007 | } else { |
24db713f LK |
1008 | PRINT_ER("Invalide power mode\n"); |
1009 | s32Error = -EINVAL; | |
1010 | goto ERRORHANDLER; | |
c5c77ba1 JK |
1011 | } |
1012 | u8WidCnt++; | |
1013 | } | |
1014 | if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_SHORT) { | |
1015 | /* range from 1 to 256 */ | |
1016 | if ((strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit < 256)) { | |
1017 | strWIDList[u8WidCnt].u16WIDid = WID_SHORT_RETRY_LIMIT; | |
ca356ada | 1018 | strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit; |
c5c77ba1 | 1019 | strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; |
d85f5326 | 1020 | strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); |
c5c77ba1 JK |
1021 | pstrWFIDrv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit; |
1022 | } else { | |
24db713f LK |
1023 | PRINT_ER("Range(1~256) over\n"); |
1024 | s32Error = -EINVAL; | |
1025 | goto ERRORHANDLER; | |
c5c77ba1 JK |
1026 | } |
1027 | u8WidCnt++; | |
1028 | } | |
1029 | if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_LONG) { | |
1030 | /* range from 1 to 256 */ | |
1031 | if ((strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit < 256)) { | |
1032 | strWIDList[u8WidCnt].u16WIDid = WID_LONG_RETRY_LIMIT; | |
ca356ada | 1033 | strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit; |
c5c77ba1 JK |
1034 | |
1035 | strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; | |
d85f5326 | 1036 | strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); |
c5c77ba1 JK |
1037 | pstrWFIDrv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit; |
1038 | } else { | |
24db713f LK |
1039 | PRINT_ER("Range(1~256) over\n"); |
1040 | s32Error = -EINVAL; | |
1041 | goto ERRORHANDLER; | |
c5c77ba1 JK |
1042 | } |
1043 | u8WidCnt++; | |
1044 | } | |
1045 | if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & FRAG_THRESHOLD) { | |
1046 | ||
1047 | if (strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold < 7937) { | |
1048 | strWIDList[u8WidCnt].u16WIDid = WID_FRAG_THRESHOLD; | |
ca356ada | 1049 | strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold; |
c5c77ba1 | 1050 | strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; |
d85f5326 | 1051 | strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); |
c5c77ba1 JK |
1052 | pstrWFIDrv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold; |
1053 | } else { | |
24db713f LK |
1054 | PRINT_ER("Threshold Range fail\n"); |
1055 | s32Error = -EINVAL; | |
1056 | goto ERRORHANDLER; | |
c5c77ba1 JK |
1057 | } |
1058 | u8WidCnt++; | |
1059 | } | |
1060 | if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RTS_THRESHOLD) { | |
1061 | /* range 256 to 65535 */ | |
1062 | if (strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold < 65536) { | |
1063 | strWIDList[u8WidCnt].u16WIDid = WID_RTS_THRESHOLD; | |
ca356ada | 1064 | strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold; |
c5c77ba1 | 1065 | strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; |
d85f5326 | 1066 | strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); |
c5c77ba1 JK |
1067 | pstrWFIDrv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold; |
1068 | } else { | |
24db713f LK |
1069 | PRINT_ER("Threshold Range fail\n"); |
1070 | s32Error = -EINVAL; | |
1071 | goto ERRORHANDLER; | |
c5c77ba1 JK |
1072 | } |
1073 | u8WidCnt++; | |
1074 | } | |
1075 | if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PREAMBLE) { | |
1076 | /*-----------------------------------------------------*/ | |
1077 | /*Input Values: Short= 0, */ | |
1078 | /* Long= 1, */ | |
1079 | /* Auto= 2 */ | |
1080 | /*------------------------------------------------------*/ | |
1081 | if (strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type < 3) { | |
1082 | strWIDList[u8WidCnt].u16WIDid = WID_PREAMBLE; | |
ca356ada | 1083 | strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type; |
c5c77ba1 | 1084 | strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; |
576917ad | 1085 | strWIDList[u8WidCnt].s32ValueSize = sizeof(char); |
c5c77ba1 JK |
1086 | pstrWFIDrv->strCfgValues.preamble_type = strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type; |
1087 | } else { | |
24db713f LK |
1088 | PRINT_ER("Preamle Range(0~2) over\n"); |
1089 | s32Error = -EINVAL; | |
1090 | goto ERRORHANDLER; | |
c5c77ba1 JK |
1091 | } |
1092 | u8WidCnt++; | |
1093 | } | |
1094 | if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SHORT_SLOT_ALLOWED) { | |
1095 | if (strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed < 2) { | |
1096 | strWIDList[u8WidCnt].u16WIDid = WID_SHORT_SLOT_ALLOWED; | |
ca356ada | 1097 | strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed; |
c5c77ba1 | 1098 | strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; |
576917ad | 1099 | strWIDList[u8WidCnt].s32ValueSize = sizeof(char); |
63d03e47 | 1100 | pstrWFIDrv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed; |
c5c77ba1 | 1101 | } else { |
24db713f LK |
1102 | PRINT_ER("Short slot(2) over\n"); |
1103 | s32Error = -EINVAL; | |
1104 | goto ERRORHANDLER; | |
c5c77ba1 JK |
1105 | } |
1106 | u8WidCnt++; | |
1107 | } | |
1108 | if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & TXOP_PROT_DISABLE) { | |
1109 | /*Description: used to Disable RTS-CTS protection for TXOP burst*/ | |
1110 | /*transmission when the acknowledgement policy is No-Ack or Block-Ack */ | |
1111 | /* this information is useful for external supplicant */ | |
1112 | /*Input Values: 1 for enable and 0 for disable. */ | |
1113 | if (strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled < 2) { | |
1114 | strWIDList[u8WidCnt].u16WIDid = WID_11N_TXOP_PROT_DISABLE; | |
ca356ada | 1115 | strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled; |
c5c77ba1 | 1116 | strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; |
576917ad | 1117 | strWIDList[u8WidCnt].s32ValueSize = sizeof(char); |
63d03e47 | 1118 | pstrWFIDrv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled; |
c5c77ba1 | 1119 | } else { |
24db713f LK |
1120 | PRINT_ER("TXOP prot disable\n"); |
1121 | s32Error = -EINVAL; | |
1122 | goto ERRORHANDLER; | |
c5c77ba1 JK |
1123 | } |
1124 | u8WidCnt++; | |
1125 | } | |
1126 | if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BEACON_INTERVAL) { | |
1127 | /* range is 1 to 65535. */ | |
1128 | if (strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval < 65536) { | |
1129 | strWIDList[u8WidCnt].u16WIDid = WID_BEACON_INTERVAL; | |
ca356ada | 1130 | strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval; |
c5c77ba1 | 1131 | strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; |
d85f5326 | 1132 | strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); |
c5c77ba1 JK |
1133 | pstrWFIDrv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval; |
1134 | } else { | |
24db713f LK |
1135 | PRINT_ER("Beacon interval(1~65535) fail\n"); |
1136 | s32Error = -EINVAL; | |
1137 | goto ERRORHANDLER; | |
c5c77ba1 JK |
1138 | } |
1139 | u8WidCnt++; | |
1140 | } | |
1141 | if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & DTIM_PERIOD) { | |
1142 | /* range is 1 to 255. */ | |
1143 | if (strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period < 256) { | |
1144 | strWIDList[u8WidCnt].u16WIDid = WID_DTIM_PERIOD; | |
ca356ada | 1145 | strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period; |
c5c77ba1 | 1146 | strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; |
576917ad | 1147 | strWIDList[u8WidCnt].s32ValueSize = sizeof(char); |
c5c77ba1 JK |
1148 | pstrWFIDrv->strCfgValues.dtim_period = strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period; |
1149 | } else { | |
24db713f LK |
1150 | PRINT_ER("DTIM range(1~255) fail\n"); |
1151 | s32Error = -EINVAL; | |
1152 | goto ERRORHANDLER; | |
c5c77ba1 JK |
1153 | } |
1154 | u8WidCnt++; | |
1155 | } | |
1156 | if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY) { | |
1157 | /*----------------------------------------------------------------------*/ | |
1158 | /*Input Values: SITE_SURVEY_1CH = 0, i.e.: currently set channel */ | |
1159 | /* SITE_SURVEY_ALL_CH = 1, */ | |
1160 | /* SITE_SURVEY_OFF = 2 */ | |
1161 | /*----------------------------------------------------------------------*/ | |
1162 | if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled < 3) { | |
1163 | strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY; | |
ca356ada | 1164 | strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled; |
c5c77ba1 | 1165 | strWIDList[u8WidCnt].enuWIDtype = WID_CHAR; |
576917ad | 1166 | strWIDList[u8WidCnt].s32ValueSize = sizeof(char); |
63d03e47 | 1167 | pstrWFIDrv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled; |
c5c77ba1 | 1168 | } else { |
24db713f LK |
1169 | PRINT_ER("Site survey disable\n"); |
1170 | s32Error = -EINVAL; | |
1171 | goto ERRORHANDLER; | |
c5c77ba1 JK |
1172 | } |
1173 | u8WidCnt++; | |
1174 | } | |
1175 | if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY_SCAN_TIME) { | |
1176 | /* range is 1 to 65535. */ | |
1177 | if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time < 65536) { | |
1178 | strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY_SCAN_TIME; | |
ca356ada | 1179 | strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time; |
c5c77ba1 | 1180 | strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; |
d85f5326 | 1181 | strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); |
c5c77ba1 JK |
1182 | pstrWFIDrv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time; |
1183 | } else { | |
24db713f LK |
1184 | PRINT_ER("Site survey scan time(1~65535) over\n"); |
1185 | s32Error = -EINVAL; | |
1186 | goto ERRORHANDLER; | |
c5c77ba1 JK |
1187 | } |
1188 | u8WidCnt++; | |
1189 | } | |
1190 | if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & ACTIVE_SCANTIME) { | |
1191 | /* range is 1 to 65535. */ | |
1192 | if (strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time < 65536) { | |
1193 | strWIDList[u8WidCnt].u16WIDid = WID_ACTIVE_SCAN_TIME; | |
ca356ada | 1194 | strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time; |
c5c77ba1 | 1195 | strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; |
d85f5326 | 1196 | strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); |
c5c77ba1 JK |
1197 | pstrWFIDrv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time; |
1198 | } else { | |
24db713f LK |
1199 | PRINT_ER("Active scan time(1~65535) over\n"); |
1200 | s32Error = -EINVAL; | |
1201 | goto ERRORHANDLER; | |
c5c77ba1 JK |
1202 | } |
1203 | u8WidCnt++; | |
1204 | } | |
1205 | if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PASSIVE_SCANTIME) { | |
1206 | /* range is 1 to 65535. */ | |
1207 | if (strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time < 65536) { | |
1208 | strWIDList[u8WidCnt].u16WIDid = WID_PASSIVE_SCAN_TIME; | |
ca356ada | 1209 | strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time; |
c5c77ba1 | 1210 | strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; |
d85f5326 | 1211 | strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); |
c5c77ba1 JK |
1212 | pstrWFIDrv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time; |
1213 | } else { | |
24db713f LK |
1214 | PRINT_ER("Passive scan time(1~65535) over\n"); |
1215 | s32Error = -EINVAL; | |
1216 | goto ERRORHANDLER; | |
c5c77ba1 JK |
1217 | } |
1218 | u8WidCnt++; | |
1219 | } | |
1220 | if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & CURRENT_TX_RATE) { | |
1221 | CURRENT_TX_RATE_T curr_tx_rate = strHostIFCfgParamAttr->pstrCfgParamVal.curr_tx_rate; | |
1222 | /*----------------------------------------------------------------------*/ | |
1223 | /*Rates: 1 2 5.5 11 6 9 12 18 24 36 48 54 Auto */ | |
1224 | /*InputValues: 1 2 3 4 5 6 7 8 9 10 11 12 0 */ | |
1225 | /*----------------------------------------------------------------------*/ | |
1226 | /* validate rate */ | |
1227 | if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1 | |
1228 | || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5 | |
1229 | || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6 | |
1230 | || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12 | |
1231 | || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24 | |
1232 | || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) { | |
1233 | strWIDList[u8WidCnt].u16WIDid = WID_CURRENT_TX_RATE; | |
ca356ada | 1234 | strWIDList[u8WidCnt].ps8WidVal = (s8 *)&curr_tx_rate; |
c5c77ba1 | 1235 | strWIDList[u8WidCnt].enuWIDtype = WID_SHORT; |
d85f5326 | 1236 | strWIDList[u8WidCnt].s32ValueSize = sizeof(u16); |
63d03e47 | 1237 | pstrWFIDrv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate; |
c5c77ba1 | 1238 | } else { |
24db713f LK |
1239 | PRINT_ER("out of TX rate\n"); |
1240 | s32Error = -EINVAL; | |
1241 | goto ERRORHANDLER; | |
c5c77ba1 JK |
1242 | } |
1243 | u8WidCnt++; | |
1244 | } | |
d42ab083 JK |
1245 | s32Error = SendConfigPkt(SET_CFG, strWIDList, u8WidCnt, false, |
1246 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 | 1247 | |
2b9d5b48 | 1248 | if (s32Error) |
c5c77ba1 JK |
1249 | PRINT_ER("Error in setting CFG params\n"); |
1250 | ||
24db713f | 1251 | ERRORHANDLER: |
83383ea3 | 1252 | up(&(pstrWFIDrv->gtOsCfgValuesSem)); |
c5c77ba1 JK |
1253 | return s32Error; |
1254 | } | |
1255 | ||
1256 | ||
1257 | /** | |
1258 | * @brief Handle_wait_msg_q_empty | |
1259 | * @details this should be the last msg and then the msg Q becomes idle | |
1260 | * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr | |
1261 | * @return Error code. | |
1262 | * @author | |
1263 | * @date | |
1264 | * @version 1.0 | |
1265 | */ | |
fb4ec9ca | 1266 | static s32 Handle_wait_msg_q_empty(void) |
c5c77ba1 | 1267 | { |
e6e12661 | 1268 | s32 s32Error = 0; |
78c87591 | 1269 | |
c5c77ba1 | 1270 | g_wilc_initialized = 0; |
83383ea3 | 1271 | up(&hWaitResponse); |
c5c77ba1 JK |
1272 | return s32Error; |
1273 | } | |
1274 | ||
1275 | /** | |
1276 | * @brief Handle_Scan | |
1277 | * @details Sending config packet to firmware to set the scan params | |
c476feb8 | 1278 | * @param[in] struct scan_attr *pstrHostIFscanAttr |
c5c77ba1 JK |
1279 | * @return Error code. |
1280 | * @author | |
1281 | * @date | |
1282 | * @version 1.0 | |
1283 | */ | |
c476feb8 TC |
1284 | static s32 Handle_Scan(tstrWILC_WFIDrv *drvHandler, |
1285 | struct scan_attr *pstrHostIFscanAttr) | |
c5c77ba1 | 1286 | { |
e6e12661 | 1287 | s32 s32Error = 0; |
c5c77ba1 | 1288 | tstrWID strWIDList[5]; |
4e4467fd CL |
1289 | u32 u32WidsCount = 0; |
1290 | u32 i; | |
63d03e47 GKH |
1291 | u8 *pu8Buffer; |
1292 | u8 valuesize = 0; | |
1293 | u8 *pu8HdnNtwrksWidVal = NULL; | |
c5c77ba1 JK |
1294 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler; |
1295 | ||
1296 | PRINT_D(HOSTINF_DBG, "Setting SCAN params\n"); | |
03b2d5e7 | 1297 | PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", pstrWFIDrv->enuHostIFstate); |
c5c77ba1 JK |
1298 | |
1299 | pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->pfScanResult; | |
1300 | pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->pvUserArg; | |
1301 | ||
c5c77ba1 JK |
1302 | if ((pstrWFIDrv->enuHostIFstate >= HOST_IF_SCANNING) && (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTED)) { |
1303 | /* here we either in HOST_IF_SCANNING, HOST_IF_WAITING_CONN_REQ or HOST_IF_WAITING_CONN_RESP */ | |
1304 | PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", pstrWFIDrv->enuHostIFstate); | |
24db713f LK |
1305 | PRINT_ER("Already scan\n"); |
1306 | s32Error = -EBUSY; | |
1307 | goto ERRORHANDLER; | |
c5c77ba1 JK |
1308 | } |
1309 | ||
1310 | #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP | |
1311 | if (g_obtainingIP || connecting) { | |
1312 | PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n"); | |
24db713f LK |
1313 | PRINT_ER("Don't do obss scan\n"); |
1314 | s32Error = -EBUSY; | |
1315 | goto ERRORHANDLER; | |
c5c77ba1 JK |
1316 | } |
1317 | #endif | |
1318 | ||
1319 | PRINT_D(HOSTINF_DBG, "Setting SCAN params\n"); | |
1320 | ||
1321 | ||
1322 | pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount = 0; | |
1323 | ||
d85f5326 | 1324 | strWIDList[u32WidsCount].u16WIDid = (u16)WID_SSID_PROBE_REQ; |
c5c77ba1 JK |
1325 | strWIDList[u32WidsCount].enuWIDtype = WID_STR; |
1326 | ||
2b9d5b48 | 1327 | for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) |
c5c77ba1 | 1328 | valuesize += ((pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen) + 1); |
f3052587 | 1329 | pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL); |
c5c77ba1 | 1330 | strWIDList[u32WidsCount].ps8WidVal = pu8HdnNtwrksWidVal; |
b1413b60 | 1331 | if (strWIDList[u32WidsCount].ps8WidVal != NULL) { |
c5c77ba1 JK |
1332 | pu8Buffer = strWIDList[u32WidsCount].ps8WidVal; |
1333 | ||
1334 | *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; | |
1335 | ||
1336 | PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum); | |
1337 | ||
1338 | for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) { | |
1339 | *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen; | |
d00d2ba3 | 1340 | memcpy(pu8Buffer, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen); |
c5c77ba1 JK |
1341 | pu8Buffer += pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen; |
1342 | } | |
1343 | ||
1344 | ||
1345 | ||
fb4ec9ca | 1346 | strWIDList[u32WidsCount].s32ValueSize = (s32)(valuesize + 1); |
c5c77ba1 JK |
1347 | u32WidsCount++; |
1348 | } | |
1349 | ||
1350 | /*filling cfg param array*/ | |
1351 | ||
1352 | /* if((pstrHostIFscanAttr->pu8IEs != NULL) && (pstrHostIFscanAttr->IEsLen != 0)) */ | |
1353 | { | |
1354 | /* IEs to be inserted in Probe Request */ | |
1355 | strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_PROBE; | |
1356 | strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA; | |
1357 | strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8IEs; | |
1358 | strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->IEsLen; | |
1359 | u32WidsCount++; | |
1360 | } | |
1361 | ||
1362 | /*Scan Type*/ | |
1363 | strWIDList[u32WidsCount].u16WIDid = WID_SCAN_TYPE; | |
1364 | strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; | |
576917ad | 1365 | strWIDList[u32WidsCount].s32ValueSize = sizeof(char); |
ca356ada | 1366 | strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanType)); |
c5c77ba1 JK |
1367 | u32WidsCount++; |
1368 | ||
1369 | /*list of channels to be scanned*/ | |
1370 | strWIDList[u32WidsCount].u16WIDid = WID_SCAN_CHANNEL_LIST; | |
1371 | strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA; | |
1372 | ||
c5c77ba1 JK |
1373 | if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL && pstrHostIFscanAttr->u8ChnlListLen > 0) { |
1374 | int i; | |
1375 | ||
1376 | for (i = 0; i < pstrHostIFscanAttr->u8ChnlListLen; i++) { | |
2b9d5b48 | 1377 | if (pstrHostIFscanAttr->pu8ChnlFreqList[i] > 0) |
c5c77ba1 | 1378 | pstrHostIFscanAttr->pu8ChnlFreqList[i] = pstrHostIFscanAttr->pu8ChnlFreqList[i] - 1; |
c5c77ba1 JK |
1379 | } |
1380 | } | |
1381 | ||
1382 | strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8ChnlFreqList; | |
1383 | strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->u8ChnlListLen; | |
1384 | u32WidsCount++; | |
1385 | ||
1386 | /*Scan Request*/ | |
1387 | strWIDList[u32WidsCount].u16WIDid = WID_START_SCAN_REQ; | |
1388 | strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; | |
576917ad | 1389 | strWIDList[u32WidsCount].s32ValueSize = sizeof(char); |
ca356ada | 1390 | strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanSource)); |
c5c77ba1 JK |
1391 | u32WidsCount++; |
1392 | ||
1393 | /*keep the state as is , no need to change it*/ | |
1394 | /* gWFiDrvHandle->enuHostIFstate = HOST_IF_SCANNING; */ | |
1395 | ||
78174ada | 1396 | if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) |
72ed4dc7 | 1397 | gbScanWhileConnected = true; |
78174ada | 1398 | else if (pstrWFIDrv->enuHostIFstate == HOST_IF_IDLE) |
72ed4dc7 | 1399 | gbScanWhileConnected = false; |
c5c77ba1 | 1400 | |
d42ab083 JK |
1401 | s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, |
1402 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 | 1403 | |
24db713f | 1404 | if (s32Error) |
c5c77ba1 | 1405 | PRINT_ER("Failed to send scan paramters config packet\n"); |
24db713f | 1406 | else |
c5c77ba1 | 1407 | PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n"); |
c5c77ba1 | 1408 | |
24db713f LK |
1409 | ERRORHANDLER: |
1410 | if (s32Error) { | |
8972d0fe | 1411 | del_timer(&pstrWFIDrv->hScanTimer); |
c5c77ba1 JK |
1412 | /*if there is an ongoing scan request*/ |
1413 | Handle_ScanDone(drvHandler, SCAN_EVENT_ABORTED); | |
1414 | } | |
1415 | ||
1416 | /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */ | |
1417 | if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) { | |
49188af2 | 1418 | kfree(pstrHostIFscanAttr->pu8ChnlFreqList); |
c5c77ba1 JK |
1419 | pstrHostIFscanAttr->pu8ChnlFreqList = NULL; |
1420 | } | |
1421 | ||
1422 | /* Deallocate pstrHostIFscanAttr->pu8IEs which was previously allocated by the sending thread */ | |
1423 | if (pstrHostIFscanAttr->pu8IEs != NULL) { | |
49188af2 | 1424 | kfree(pstrHostIFscanAttr->pu8IEs); |
c5c77ba1 JK |
1425 | pstrHostIFscanAttr->pu8IEs = NULL; |
1426 | } | |
1427 | if (pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo != NULL) { | |
49188af2 | 1428 | kfree(pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo); |
c5c77ba1 JK |
1429 | pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo = NULL; |
1430 | } | |
1431 | ||
1432 | /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */ | |
1433 | if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) { | |
49188af2 | 1434 | kfree(pstrHostIFscanAttr->pu8ChnlFreqList); |
c5c77ba1 JK |
1435 | pstrHostIFscanAttr->pu8ChnlFreqList = NULL; |
1436 | } | |
1437 | ||
2b9d5b48 | 1438 | if (pu8HdnNtwrksWidVal != NULL) |
49188af2 | 1439 | kfree(pu8HdnNtwrksWidVal); |
c5c77ba1 JK |
1440 | |
1441 | return s32Error; | |
1442 | } | |
1443 | ||
1444 | /** | |
1445 | * @brief Handle_ScanDone | |
1446 | * @details Call scan notification callback function | |
1447 | * @param[in] NONE | |
1448 | * @return Error code. | |
1449 | * @author | |
1450 | * @date | |
1451 | * @version 1.0 | |
1452 | */ | |
2b05df55 | 1453 | static s32 Handle_ScanDone(tstrWILC_WFIDrv *drvHandler, tenuScanEvent enuEvent) |
c5c77ba1 | 1454 | { |
e6e12661 | 1455 | s32 s32Error = 0; |
c5c77ba1 JK |
1456 | |
1457 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; | |
1458 | ||
1459 | ||
63d03e47 | 1460 | u8 u8abort_running_scan; |
c5c77ba1 JK |
1461 | tstrWID strWID; |
1462 | ||
1463 | ||
1464 | PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n"); | |
1465 | ||
c5c77ba1 JK |
1466 | /*Ask FW to abort the running scan, if any*/ |
1467 | if (enuEvent == SCAN_EVENT_ABORTED) { | |
1468 | PRINT_D(GENERIC_DBG, "Abort running scan\n"); | |
1469 | u8abort_running_scan = 1; | |
d85f5326 | 1470 | strWID.u16WIDid = (u16)WID_ABORT_RUNNING_SCAN; |
c5c77ba1 | 1471 | strWID.enuWIDtype = WID_CHAR; |
ca356ada | 1472 | strWID.ps8WidVal = (s8 *)&u8abort_running_scan; |
576917ad | 1473 | strWID.s32ValueSize = sizeof(char); |
c5c77ba1 JK |
1474 | |
1475 | /*Sending Cfg*/ | |
d42ab083 JK |
1476 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
1477 | get_id_from_handler(pstrWFIDrv)); | |
24db713f | 1478 | if (s32Error) { |
c5c77ba1 | 1479 | PRINT_ER("Failed to set abort running scan\n"); |
24db713f | 1480 | s32Error = -EFAULT; |
c5c77ba1 JK |
1481 | } |
1482 | } | |
1483 | ||
1484 | if (pstrWFIDrv == NULL) { | |
1485 | PRINT_ER("Driver handler is NULL\n"); | |
1486 | return s32Error; | |
1487 | } | |
1488 | ||
1489 | /*if there is an ongoing scan request*/ | |
1490 | if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) { | |
b1413b60 | 1491 | pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL, |
c5c77ba1 JK |
1492 | pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL); |
1493 | /*delete current scan request*/ | |
1494 | pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL; | |
1495 | } | |
1496 | ||
1497 | return s32Error; | |
1498 | } | |
1499 | ||
1500 | /** | |
1501 | * @brief Handle_Connect | |
1502 | * @details Sending config packet to firmware to starting connection | |
120ae593 | 1503 | * @param[in] struct connect_attr *pstrHostIFconnectAttr |
c5c77ba1 JK |
1504 | * @return Error code. |
1505 | * @author | |
1506 | * @date | |
1507 | * @version 1.0 | |
1508 | */ | |
63d03e47 | 1509 | u8 u8ConnectedSSID[6] = {0}; |
120ae593 TC |
1510 | static s32 Handle_Connect(tstrWILC_WFIDrv *drvHandler, |
1511 | struct connect_attr *pstrHostIFconnectAttr) | |
c5c77ba1 JK |
1512 | { |
1513 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler; | |
e6e12661 | 1514 | s32 s32Error = 0; |
c5c77ba1 | 1515 | tstrWID strWIDList[8]; |
4e4467fd | 1516 | u32 u32WidsCount = 0, dummyval = 0; |
c5c77ba1 JK |
1517 | /* char passphrase[] = "12345678"; */ |
1518 | #ifndef CONNECT_DIRECT | |
e6e12661 | 1519 | s32 s32Err = 0; |
4e4467fd | 1520 | u32 i; |
63d03e47 | 1521 | u8 u8bssDscListIndex; |
b1413b60 | 1522 | wid_site_survey_reslts_s *pstrSurveyResults = NULL; |
c5c77ba1 | 1523 | #else |
63d03e47 | 1524 | u8 *pu8CurrByte = NULL; |
c5c77ba1 JK |
1525 | #ifdef WILC_PARSE_SCAN_IN_HOST |
1526 | tstrJoinBssParam *ptstrJoinBssParam; | |
1527 | #endif /*WILC_PARSE_SCAN_IN_HOST*/ | |
1528 | ||
1529 | #endif | |
1530 | ||
1531 | PRINT_D(GENERIC_DBG, "Handling connect request\n"); | |
1532 | ||
1533 | #ifndef CONNECT_DIRECT | |
3a79a7f7 | 1534 | memset(gapu8RcvdSurveyResults, 0, sizeof(gapu8RcvdSurveyResults)); |
c5c77ba1 JK |
1535 | |
1536 | ||
1537 | PRINT_D(HOSTINF_DBG, "Getting site survey results\n"); | |
218dc407 | 1538 | s32Err = host_int_get_site_survey_results(pstrWFIDrv, |
c5c77ba1 JK |
1539 | gapu8RcvdSurveyResults, |
1540 | MAX_SURVEY_RESULT_FRAG_SIZE); | |
1541 | if (s32Err) { | |
1542 | PRINT_ER("Failed to get site survey results\n"); | |
24db713f LK |
1543 | s32Error = -EFAULT; |
1544 | goto ERRORHANDLER; | |
c5c77ba1 JK |
1545 | } |
1546 | s32Err = ParseSurveyResults(gapu8RcvdSurveyResults, &pstrSurveyResults, | |
1547 | &pstrWFIDrv->u32SurveyResultsCount); | |
1548 | ||
1549 | ||
e6e12661 | 1550 | if (s32Err == 0) { |
c5c77ba1 JK |
1551 | /* use the parsed info in pstrSurveyResults, then deallocate it */ |
1552 | PRINT_D(HOSTINF_DBG, "Copying site survey results in global structure, then deallocate\n"); | |
1553 | for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) { | |
d00d2ba3 | 1554 | memcpy(&pstrWFIDrv->astrSurveyResults[i], &pstrSurveyResults[i], |
c5c77ba1 JK |
1555 | sizeof(wid_site_survey_reslts_s)); |
1556 | } | |
1557 | ||
1558 | DeallocateSurveyResults(pstrSurveyResults); | |
1559 | } else { | |
24db713f LK |
1560 | PRINT_ER("ParseSurveyResults() Error\n"); |
1561 | s32Error = -EFAULT; | |
1562 | goto ERRORHANDLER; | |
c5c77ba1 JK |
1563 | } |
1564 | ||
1565 | ||
1566 | for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) { | |
1a646e7e | 1567 | if (memcmp(pstrWFIDrv->astrSurveyResults[i].SSID, |
c5c77ba1 JK |
1568 | pstrHostIFconnectAttr->pu8ssid, |
1569 | pstrHostIFconnectAttr->ssidLen) == 0) { | |
1570 | PRINT_INFO(HOSTINF_DBG, "Network with required SSID is found %s\n", pstrHostIFconnectAttr->pu8ssid); | |
1571 | if (pstrHostIFconnectAttr->pu8bssid == NULL) { | |
1572 | /* BSSID is not passed from the user, so decision of matching | |
1573 | * is done by SSID only */ | |
1574 | PRINT_INFO(HOSTINF_DBG, "BSSID is not passed from the user\n"); | |
1575 | break; | |
1576 | } else { | |
1577 | /* BSSID is also passed from the user, so decision of matching | |
1578 | * should consider also this passed BSSID */ | |
1579 | ||
1a646e7e | 1580 | if (memcmp(pstrWFIDrv->astrSurveyResults[i].BSSID, |
c5c77ba1 JK |
1581 | pstrHostIFconnectAttr->pu8bssid, |
1582 | 6) == 0) { | |
1583 | PRINT_INFO(HOSTINF_DBG, "BSSID is passed from the user and matched\n"); | |
1584 | break; | |
1585 | } | |
1586 | } | |
1587 | } | |
1588 | } | |
1589 | ||
1590 | if (i < pstrWFIDrv->u32SurveyResultsCount) { | |
1591 | u8bssDscListIndex = i; | |
1592 | ||
03b2d5e7 | 1593 | PRINT_INFO(HOSTINF_DBG, "Connecting to network of Bss Idx%d and SSID %s and channel%d\n", |
c5c77ba1 JK |
1594 | u8bssDscListIndex, pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].SSID, |
1595 | pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].Channel); | |
1596 | ||
1597 | PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n"); | |
1598 | ||
1599 | if (pstrHostIFconnectAttr->pu8bssid != NULL) { | |
f3052587 | 1600 | pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = kmalloc(6, GFP_KERNEL); |
d00d2ba3 | 1601 | memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6); |
c5c77ba1 JK |
1602 | } |
1603 | ||
1604 | pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen; | |
1605 | if (pstrHostIFconnectAttr->pu8ssid != NULL) { | |
f3052587 | 1606 | pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssidLen + 1, GFP_KERNEL); |
d00d2ba3 | 1607 | memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid, |
c5c77ba1 JK |
1608 | pstrHostIFconnectAttr->ssidLen); |
1609 | pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0'; | |
1610 | } | |
1611 | ||
1612 | pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen; | |
1613 | if (pstrHostIFconnectAttr->pu8IEs != NULL) { | |
f3052587 | 1614 | pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL); |
d00d2ba3 | 1615 | memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs, |
c5c77ba1 JK |
1616 | pstrHostIFconnectAttr->IEsLen); |
1617 | } | |
1618 | ||
1619 | pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security; | |
1620 | pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type; | |
1621 | pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult; | |
1622 | pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg; | |
1623 | ||
1624 | ||
1625 | /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */ | |
1626 | /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */ | |
1627 | { | |
1628 | /* IEs to be inserted in Association Request */ | |
1629 | strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE; | |
1630 | strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA; | |
1631 | strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs; | |
1632 | strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen; | |
1633 | u32WidsCount++; | |
1634 | } | |
d85f5326 | 1635 | strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE; |
c5c77ba1 | 1636 | strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; |
576917ad | 1637 | strWIDList[u32WidsCount].s32ValueSize = sizeof(char); |
ca356ada | 1638 | strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security)); |
c5c77ba1 JK |
1639 | u32WidsCount++; |
1640 | ||
1641 | PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security); | |
1642 | ||
d85f5326 | 1643 | strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE; |
c5c77ba1 | 1644 | strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; |
576917ad | 1645 | strWIDList[u32WidsCount].s32ValueSize = sizeof(char); |
ca356ada | 1646 | strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type); |
c5c77ba1 JK |
1647 | u32WidsCount++; |
1648 | ||
1649 | PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type); | |
1650 | /* | |
d85f5326 | 1651 | * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK; |
c5c77ba1 JK |
1652 | * strWIDList[u32WidsCount].enuWIDtype = WID_STR; |
1653 | * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase); | |
ca356ada | 1654 | * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase); |
c5c77ba1 JK |
1655 | * u32WidsCount++; |
1656 | */ | |
1657 | ||
d85f5326 | 1658 | strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ; |
c5c77ba1 | 1659 | strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; |
576917ad | 1660 | strWIDList[u32WidsCount].s32ValueSize = sizeof(char); |
ca356ada | 1661 | strWIDList[u32WidsCount].ps8WidVal = (s8 *)&u8bssDscListIndex; |
c5c77ba1 JK |
1662 | u32WidsCount++; |
1663 | ||
c5c77ba1 JK |
1664 | /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the |
1665 | * firmware at chip reset when processing the WIDs of the Connect Request. | |
1666 | * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */ | |
1667 | /* ////////////////////// */ | |
1668 | gu32WidConnRstHack = 0; | |
1669 | /* ////////////////////// */ | |
c5c77ba1 | 1670 | |
d42ab083 JK |
1671 | s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, |
1672 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 | 1673 | if (s32Error) { |
24db713f LK |
1674 | PRINT_ER("failed to send config packet\n"); |
1675 | s32Error = -EINVAL; | |
1676 | goto ERRORHANDLER; | |
c5c77ba1 JK |
1677 | } else { |
1678 | pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP; | |
1679 | } | |
1680 | ||
1681 | } else { | |
1682 | PRINT_ER("Required BSSID not found\n"); | |
24db713f LK |
1683 | s32Error = -ENOENT; |
1684 | goto ERRORHANDLER; | |
c5c77ba1 JK |
1685 | } |
1686 | ||
1687 | #else | |
1688 | ||
1689 | /* if we try to connect to an already connected AP then discard the request */ | |
1690 | ||
1a646e7e | 1691 | if (memcmp(pstrHostIFconnectAttr->pu8bssid, u8ConnectedSSID, ETH_ALEN) == 0) { |
c5c77ba1 | 1692 | |
e6e12661 | 1693 | s32Error = 0; |
c5c77ba1 JK |
1694 | PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n"); |
1695 | return s32Error; | |
1696 | } | |
1697 | ||
1698 | PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n"); | |
1699 | ||
c5c77ba1 JK |
1700 | #ifdef WILC_PARSE_SCAN_IN_HOST |
1701 | ptstrJoinBssParam = (tstrJoinBssParam *)pstrHostIFconnectAttr->pJoinParams; | |
1702 | if (ptstrJoinBssParam == NULL) { | |
1703 | PRINT_ER("Required BSSID not found\n"); | |
24db713f LK |
1704 | s32Error = -ENOENT; |
1705 | goto ERRORHANDLER; | |
c5c77ba1 JK |
1706 | } |
1707 | #endif /*WILC_PARSE_SCAN_IN_HOST*/ | |
1708 | ||
c5c77ba1 | 1709 | if (pstrHostIFconnectAttr->pu8bssid != NULL) { |
f3052587 | 1710 | pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = kmalloc(6, GFP_KERNEL); |
d00d2ba3 | 1711 | memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6); |
c5c77ba1 JK |
1712 | } |
1713 | ||
1714 | pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen; | |
1715 | if (pstrHostIFconnectAttr->pu8ssid != NULL) { | |
f3052587 | 1716 | pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssidLen + 1, GFP_KERNEL); |
d00d2ba3 | 1717 | memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid, |
c5c77ba1 JK |
1718 | pstrHostIFconnectAttr->ssidLen); |
1719 | pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0'; | |
1720 | } | |
1721 | ||
1722 | pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen; | |
1723 | if (pstrHostIFconnectAttr->pu8IEs != NULL) { | |
f3052587 | 1724 | pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL); |
d00d2ba3 | 1725 | memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs, |
c5c77ba1 JK |
1726 | pstrHostIFconnectAttr->IEsLen); |
1727 | } | |
1728 | ||
1729 | pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security; | |
1730 | pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type; | |
1731 | pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult; | |
1732 | pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg; | |
1733 | ||
1734 | strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT; | |
1735 | strWIDList[u32WidsCount].enuWIDtype = WID_INT; | |
4e4467fd | 1736 | strWIDList[u32WidsCount].s32ValueSize = sizeof(u32); |
ca356ada | 1737 | strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval)); |
c5c77ba1 JK |
1738 | u32WidsCount++; |
1739 | ||
1740 | strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT; | |
1741 | strWIDList[u32WidsCount].enuWIDtype = WID_INT; | |
4e4467fd | 1742 | strWIDList[u32WidsCount].s32ValueSize = sizeof(u32); |
ca356ada | 1743 | strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval)); |
c5c77ba1 JK |
1744 | u32WidsCount++; |
1745 | ||
1746 | strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT; | |
1747 | strWIDList[u32WidsCount].enuWIDtype = WID_INT; | |
4e4467fd | 1748 | strWIDList[u32WidsCount].s32ValueSize = sizeof(u32); |
ca356ada | 1749 | strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval)); |
c5c77ba1 JK |
1750 | u32WidsCount++; |
1751 | ||
1752 | /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */ | |
1753 | /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */ | |
1754 | { | |
1755 | /* IEs to be inserted in Association Request */ | |
1756 | strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE; | |
1757 | strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA; | |
1758 | strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs; | |
1759 | strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen; | |
1760 | u32WidsCount++; | |
1761 | ||
1a646e7e | 1762 | if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) { |
c5c77ba1 JK |
1763 | |
1764 | gu32FlushedInfoElemAsocSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen; | |
f3052587 | 1765 | gu8FlushedInfoElemAsoc = kmalloc(gu32FlushedInfoElemAsocSize, GFP_KERNEL); |
c5c77ba1 JK |
1766 | memcpy(gu8FlushedInfoElemAsoc, pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, |
1767 | gu32FlushedInfoElemAsocSize); | |
1768 | } | |
1769 | } | |
d85f5326 | 1770 | strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE; |
c5c77ba1 | 1771 | strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; |
576917ad | 1772 | strWIDList[u32WidsCount].s32ValueSize = sizeof(char); |
ca356ada | 1773 | strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security)); |
c5c77ba1 JK |
1774 | u32WidsCount++; |
1775 | ||
1a646e7e | 1776 | if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) |
c5c77ba1 JK |
1777 | gu8Flushed11iMode = pstrWFIDrv->strWILC_UsrConnReq.u8security; |
1778 | ||
1779 | PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security); | |
1780 | ||
1781 | ||
d85f5326 | 1782 | strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE; |
c5c77ba1 | 1783 | strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; |
576917ad | 1784 | strWIDList[u32WidsCount].s32ValueSize = sizeof(char); |
ca356ada | 1785 | strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type); |
c5c77ba1 JK |
1786 | u32WidsCount++; |
1787 | ||
1a646e7e | 1788 | if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) |
63d03e47 | 1789 | gu8FlushedAuthType = (u8)pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type; |
c5c77ba1 JK |
1790 | |
1791 | PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type); | |
1792 | /* | |
d85f5326 | 1793 | * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK; |
c5c77ba1 JK |
1794 | * strWIDList[u32WidsCount].enuWIDtype = WID_STR; |
1795 | * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase); | |
ca356ada | 1796 | * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase); |
c5c77ba1 JK |
1797 | * u32WidsCount++; |
1798 | */ | |
1799 | ||
1800 | PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n", | |
1801 | pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->u8channel); | |
1802 | ||
1803 | ||
1804 | #ifndef WILC_PARSE_SCAN_IN_HOST | |
d85f5326 | 1805 | strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED; |
c5c77ba1 JK |
1806 | strWIDList[u32WidsCount].enuWIDtype = WID_STR; |
1807 | strWIDList[u32WidsCount].s32ValueSize = MAX_SSID_LEN + 7; | |
f3052587 | 1808 | strWIDList[u32WidsCount].ps8WidVal = kmalloc(strWIDList[u32WidsCount].s32ValueSize, GFP_KERNEL); |
c5c77ba1 | 1809 | |
24db713f LK |
1810 | if (strWIDList[u32WidsCount].ps8WidVal == NULL) { |
1811 | s32Error = -EFAULT; | |
1812 | goto ERRORHANDLER; | |
1813 | } | |
c5c77ba1 JK |
1814 | |
1815 | pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal; | |
1816 | ||
1817 | if (pstrHostIFconnectAttr->pu8ssid != NULL) { | |
d00d2ba3 | 1818 | memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen); |
c5c77ba1 JK |
1819 | pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0'; |
1820 | } | |
1821 | pu8CurrByte += MAX_SSID_LEN; | |
1822 | if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) { | |
1823 | *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel; | |
1824 | } else { | |
1825 | PRINT_ER("Channel out of range\n"); | |
1826 | *(pu8CurrByte++) = 0xFF; | |
1827 | } | |
2b9d5b48 | 1828 | if (pstrHostIFconnectAttr->pu8bssid != NULL) |
d00d2ba3 | 1829 | memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6); |
c5c77ba1 JK |
1830 | pu8CurrByte += 6; |
1831 | ||
1832 | /* keep the buffer at the start of the allocated pointer to use it with the free*/ | |
1833 | pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal; | |
1834 | ||
1835 | #else | |
1836 | ||
d85f5326 | 1837 | strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED; |
c5c77ba1 JK |
1838 | strWIDList[u32WidsCount].enuWIDtype = WID_STR; |
1839 | ||
1840 | /*Sending NoA attributes during connection*/ | |
1841 | strWIDList[u32WidsCount].s32ValueSize = 112; /* 79; */ | |
f3052587 | 1842 | strWIDList[u32WidsCount].ps8WidVal = kmalloc(strWIDList[u32WidsCount].s32ValueSize, GFP_KERNEL); |
c5c77ba1 | 1843 | |
1a646e7e | 1844 | if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) { |
c5c77ba1 | 1845 | gu32FlushedJoinReqSize = strWIDList[u32WidsCount].s32ValueSize; |
f3052587 | 1846 | gu8FlushedJoinReq = kmalloc(gu32FlushedJoinReqSize, GFP_KERNEL); |
c5c77ba1 | 1847 | } |
24db713f LK |
1848 | if (strWIDList[u32WidsCount].ps8WidVal == NULL) { |
1849 | s32Error = -EFAULT; | |
1850 | goto ERRORHANDLER; | |
1851 | } | |
c5c77ba1 JK |
1852 | |
1853 | pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal; | |
1854 | ||
1855 | ||
1856 | if (pstrHostIFconnectAttr->pu8ssid != NULL) { | |
d00d2ba3 | 1857 | memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen); |
c5c77ba1 JK |
1858 | pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0'; |
1859 | } | |
1860 | pu8CurrByte += MAX_SSID_LEN; | |
1861 | ||
1862 | /* BSS type*/ | |
1863 | *(pu8CurrByte++) = INFRASTRUCTURE; | |
1864 | /* Channel*/ | |
1865 | if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) { | |
1866 | *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel; | |
1867 | } else { | |
1868 | PRINT_ER("Channel out of range\n"); | |
1869 | *(pu8CurrByte++) = 0xFF; | |
1870 | } | |
1871 | /* Cap Info*/ | |
1872 | *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF; | |
1873 | *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF; | |
1874 | PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8))); | |
1875 | ||
1876 | /* sa*/ | |
2b9d5b48 | 1877 | if (pstrHostIFconnectAttr->pu8bssid != NULL) |
d00d2ba3 | 1878 | memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6); |
c5c77ba1 JK |
1879 | pu8CurrByte += 6; |
1880 | ||
1881 | /* bssid*/ | |
2b9d5b48 | 1882 | if (pstrHostIFconnectAttr->pu8bssid != NULL) |
d00d2ba3 | 1883 | memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6); |
c5c77ba1 JK |
1884 | pu8CurrByte += 6; |
1885 | ||
1886 | /* Beacon Period*/ | |
1887 | *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF; | |
1888 | *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF; | |
1889 | PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8))); | |
1890 | /* DTIM Period*/ | |
1891 | *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period; | |
1892 | PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1))); | |
1893 | /* Supported rates*/ | |
d00d2ba3 | 1894 | memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1); |
c5c77ba1 JK |
1895 | pu8CurrByte += (MAX_RATES_SUPPORTED + 1); |
1896 | ||
1897 | /* wmm cap*/ | |
1898 | *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap; | |
1899 | PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1))); | |
1900 | /* uapsd cap*/ | |
1901 | *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap; | |
1902 | ||
1903 | /* ht cap*/ | |
1904 | *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable; | |
1905 | /* copy this information to the user request */ | |
1906 | pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable; | |
1907 | ||
1908 | /* rsn found*/ | |
1909 | *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found; | |
1910 | PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1)); | |
1911 | /* rsn group policy*/ | |
1912 | *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy; | |
1913 | PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1))); | |
1914 | /* mode_802_11i*/ | |
1915 | *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i; | |
1916 | PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1))); | |
1917 | /* rsn pcip policy*/ | |
d00d2ba3 | 1918 | memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy)); |
c5c77ba1 JK |
1919 | pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy); |
1920 | ||
1921 | /* rsn auth policy*/ | |
d00d2ba3 | 1922 | memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy)); |
c5c77ba1 JK |
1923 | pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy); |
1924 | ||
1925 | /* rsn auth policy*/ | |
d00d2ba3 | 1926 | memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap)); |
c5c77ba1 JK |
1927 | pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap); |
1928 | ||
c5c77ba1 JK |
1929 | *(pu8CurrByte++) = REAL_JOIN_REQ; |
1930 | ||
c5c77ba1 JK |
1931 | *(pu8CurrByte++) = ptstrJoinBssParam->u8NoaEnbaled; |
1932 | if (ptstrJoinBssParam->u8NoaEnbaled) { | |
1933 | PRINT_D(HOSTINF_DBG, "NOA present\n"); | |
1934 | ||
1935 | *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF; | |
1936 | *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF; | |
1937 | *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF; | |
1938 | *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF; | |
1939 | ||
1940 | *(pu8CurrByte++) = ptstrJoinBssParam->u8Index; | |
1941 | ||
1942 | *(pu8CurrByte++) = ptstrJoinBssParam->u8OppEnable; | |
1943 | ||
1944 | if (ptstrJoinBssParam->u8OppEnable) | |
1945 | *(pu8CurrByte++) = ptstrJoinBssParam->u8CtWindow; | |
1946 | ||
1947 | *(pu8CurrByte++) = ptstrJoinBssParam->u8Count; | |
1948 | ||
d00d2ba3 | 1949 | memcpy(pu8CurrByte, ptstrJoinBssParam->au8Duration, sizeof(ptstrJoinBssParam->au8Duration)); |
c5c77ba1 JK |
1950 | |
1951 | pu8CurrByte += sizeof(ptstrJoinBssParam->au8Duration); | |
1952 | ||
d00d2ba3 | 1953 | memcpy(pu8CurrByte, ptstrJoinBssParam->au8Interval, sizeof(ptstrJoinBssParam->au8Interval)); |
c5c77ba1 JK |
1954 | |
1955 | pu8CurrByte += sizeof(ptstrJoinBssParam->au8Interval); | |
1956 | ||
d00d2ba3 | 1957 | memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime)); |
c5c77ba1 JK |
1958 | |
1959 | pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime); | |
1960 | ||
1961 | } else | |
1962 | PRINT_D(HOSTINF_DBG, "NOA not present\n"); | |
c5c77ba1 JK |
1963 | |
1964 | /* keep the buffer at the start of the allocated pointer to use it with the free*/ | |
1965 | pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal; | |
1966 | ||
1967 | ||
1968 | #endif /* #ifdef WILC_PARSE_SCAN_IN_HOST*/ | |
1969 | u32WidsCount++; | |
1970 | ||
c5c77ba1 JK |
1971 | /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the |
1972 | * firmware at chip reset when processing the WIDs of the Connect Request. | |
1973 | * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */ | |
1974 | /* ////////////////////// */ | |
1975 | gu32WidConnRstHack = 0; | |
1976 | /* ////////////////////// */ | |
c5c77ba1 | 1977 | |
1a646e7e | 1978 | if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) { |
c5c77ba1 | 1979 | memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize); |
8a625cad | 1980 | gu8FlushedJoinReqDrvHandler = pstrWFIDrv; |
c5c77ba1 JK |
1981 | } |
1982 | ||
1983 | PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n"); | |
1984 | ||
1985 | if (pstrHostIFconnectAttr->pu8bssid != NULL) { | |
d00d2ba3 | 1986 | memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->pu8bssid, ETH_ALEN); |
c5c77ba1 | 1987 | |
310a28fd AK |
1988 | PRINT_D(GENERIC_DBG, "save Bssid = %pM\n", pstrHostIFconnectAttr->pu8bssid); |
1989 | PRINT_D(GENERIC_DBG, "save bssid = %pM\n", u8ConnectedSSID); | |
c5c77ba1 JK |
1990 | } |
1991 | ||
d42ab083 JK |
1992 | s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, |
1993 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 | 1994 | if (s32Error) { |
24db713f LK |
1995 | PRINT_ER("failed to send config packet\n"); |
1996 | s32Error = -EFAULT; | |
1997 | goto ERRORHANDLER; | |
c5c77ba1 JK |
1998 | } else { |
1999 | PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n"); | |
2000 | pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP; | |
2001 | } | |
2002 | #endif | |
2003 | ||
24db713f LK |
2004 | ERRORHANDLER: |
2005 | if (s32Error) { | |
c5c77ba1 JK |
2006 | tstrConnectInfo strConnectInfo; |
2007 | ||
8972d0fe | 2008 | del_timer(&pstrWFIDrv->hConnectTimer); |
c5c77ba1 JK |
2009 | |
2010 | PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n"); | |
2011 | ||
2cc46837 | 2012 | memset(&strConnectInfo, 0, sizeof(tstrConnectInfo)); |
c5c77ba1 JK |
2013 | |
2014 | if (pstrHostIFconnectAttr->pfConnectResult != NULL) { | |
2b9d5b48 | 2015 | if (pstrHostIFconnectAttr->pu8bssid != NULL) |
d00d2ba3 | 2016 | memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->pu8bssid, 6); |
c5c77ba1 JK |
2017 | |
2018 | if (pstrHostIFconnectAttr->pu8IEs != NULL) { | |
2019 | strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->IEsLen; | |
f3052587 | 2020 | strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL); |
d00d2ba3 | 2021 | memcpy(strConnectInfo.pu8ReqIEs, |
c5c77ba1 JK |
2022 | pstrHostIFconnectAttr->pu8IEs, |
2023 | pstrHostIFconnectAttr->IEsLen); | |
2024 | } | |
2025 | ||
2026 | pstrHostIFconnectAttr->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP, | |
2027 | &strConnectInfo, | |
2028 | MAC_DISCONNECTED, | |
2029 | NULL, | |
2030 | pstrHostIFconnectAttr->pvUserArg); | |
2031 | /*Change state to idle*/ | |
2032 | pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE; | |
2033 | /* Deallocation */ | |
2034 | if (strConnectInfo.pu8ReqIEs != NULL) { | |
49188af2 | 2035 | kfree(strConnectInfo.pu8ReqIEs); |
c5c77ba1 JK |
2036 | strConnectInfo.pu8ReqIEs = NULL; |
2037 | } | |
2038 | ||
2039 | } else { | |
03b2d5e7 | 2040 | PRINT_ER("Connect callback function pointer is NULL\n"); |
c5c77ba1 JK |
2041 | } |
2042 | } | |
2043 | ||
2044 | PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n"); | |
2045 | /* Deallocate pstrHostIFconnectAttr->pu8bssid which was prevoisuly allocated by the sending thread */ | |
2046 | if (pstrHostIFconnectAttr->pu8bssid != NULL) { | |
49188af2 | 2047 | kfree(pstrHostIFconnectAttr->pu8bssid); |
c5c77ba1 JK |
2048 | pstrHostIFconnectAttr->pu8bssid = NULL; |
2049 | } | |
2050 | ||
2051 | /* Deallocate pstrHostIFconnectAttr->pu8ssid which was prevoisuly allocated by the sending thread */ | |
2052 | if (pstrHostIFconnectAttr->pu8ssid != NULL) { | |
49188af2 | 2053 | kfree(pstrHostIFconnectAttr->pu8ssid); |
c5c77ba1 JK |
2054 | pstrHostIFconnectAttr->pu8ssid = NULL; |
2055 | } | |
2056 | ||
2057 | /* Deallocate pstrHostIFconnectAttr->pu8IEs which was prevoisuly allocated by the sending thread */ | |
2058 | if (pstrHostIFconnectAttr->pu8IEs != NULL) { | |
49188af2 | 2059 | kfree(pstrHostIFconnectAttr->pu8IEs); |
c5c77ba1 JK |
2060 | pstrHostIFconnectAttr->pu8IEs = NULL; |
2061 | } | |
2062 | ||
2b9d5b48 | 2063 | if (pu8CurrByte != NULL) |
49188af2 | 2064 | kfree(pu8CurrByte); |
c5c77ba1 JK |
2065 | return s32Error; |
2066 | } | |
2067 | ||
2068 | /** | |
2069 | * @brief Handle_FlushConnect | |
2070 | * @details Sending config packet to firmware to flush an old connection | |
2071 | * after switching FW from station one to hybrid one | |
2072 | * @param[in] void * drvHandler | |
2073 | * @return Error code. | |
2074 | * @author Amr Abdel-Moghny | |
2075 | * @date 19 DEC 2013 | |
2076 | * @version 8.0 | |
2077 | */ | |
2078 | ||
2b05df55 | 2079 | static s32 Handle_FlushConnect(tstrWILC_WFIDrv *drvHandler) |
c5c77ba1 | 2080 | { |
e6e12661 | 2081 | s32 s32Error = 0; |
c5c77ba1 | 2082 | tstrWID strWIDList[5]; |
4e4467fd | 2083 | u32 u32WidsCount = 0; |
63d03e47 | 2084 | u8 *pu8CurrByte = NULL; |
c5c77ba1 JK |
2085 | |
2086 | ||
2087 | /* IEs to be inserted in Association Request */ | |
2088 | strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE; | |
2089 | strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA; | |
2090 | strWIDList[u32WidsCount].ps8WidVal = gu8FlushedInfoElemAsoc; | |
2091 | strWIDList[u32WidsCount].s32ValueSize = gu32FlushedInfoElemAsocSize; | |
2092 | u32WidsCount++; | |
2093 | ||
d85f5326 | 2094 | strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE; |
c5c77ba1 | 2095 | strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; |
576917ad | 2096 | strWIDList[u32WidsCount].s32ValueSize = sizeof(char); |
ca356ada | 2097 | strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(gu8Flushed11iMode)); |
c5c77ba1 JK |
2098 | u32WidsCount++; |
2099 | ||
2100 | ||
2101 | ||
d85f5326 | 2102 | strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE; |
c5c77ba1 | 2103 | strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; |
576917ad | 2104 | strWIDList[u32WidsCount].s32ValueSize = sizeof(char); |
ca356ada | 2105 | strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&gu8FlushedAuthType); |
c5c77ba1 JK |
2106 | u32WidsCount++; |
2107 | ||
2108 | ||
2109 | #ifdef WILC_PARSE_SCAN_IN_HOST | |
d85f5326 | 2110 | strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED; |
c5c77ba1 JK |
2111 | strWIDList[u32WidsCount].enuWIDtype = WID_STR; |
2112 | strWIDList[u32WidsCount].s32ValueSize = gu32FlushedJoinReqSize; | |
ca356ada | 2113 | strWIDList[u32WidsCount].ps8WidVal = (s8 *)gu8FlushedJoinReq; |
c5c77ba1 JK |
2114 | pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal; |
2115 | ||
2116 | pu8CurrByte += FLUSHED_BYTE_POS; | |
2117 | *(pu8CurrByte) = FLUSHED_JOIN_REQ; | |
2118 | ||
2119 | u32WidsCount++; | |
2120 | ||
2121 | #endif | |
2122 | ||
d42ab083 JK |
2123 | s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, |
2124 | get_id_from_handler(gu8FlushedJoinReqDrvHandler)); | |
c5c77ba1 | 2125 | if (s32Error) { |
24db713f LK |
2126 | PRINT_ER("failed to send config packet\n"); |
2127 | s32Error = -EINVAL; | |
c5c77ba1 JK |
2128 | } |
2129 | ||
2130 | return s32Error; | |
2131 | } | |
2132 | ||
2133 | /** | |
2134 | * @brief Handle_ConnectTimeout | |
2135 | * @details Call connect notification callback function indicating connection failure | |
2136 | * @param[in] NONE | |
2137 | * @return Error code. | |
2138 | * @author | |
2139 | * @date | |
2140 | * @version 1.0 | |
2141 | */ | |
2b05df55 | 2142 | static s32 Handle_ConnectTimeout(tstrWILC_WFIDrv *drvHandler) |
c5c77ba1 | 2143 | { |
e6e12661 | 2144 | s32 s32Error = 0; |
c5c77ba1 JK |
2145 | tstrConnectInfo strConnectInfo; |
2146 | tstrWID strWID; | |
d85f5326 | 2147 | u16 u16DummyReasonCode = 0; |
c5c77ba1 JK |
2148 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler; |
2149 | ||
2150 | if (pstrWFIDrv == NULL) { | |
2151 | PRINT_ER("Driver handler is NULL\n"); | |
2152 | return s32Error; | |
2153 | } | |
2154 | ||
2155 | pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE; | |
2156 | ||
72ed4dc7 | 2157 | gbScanWhileConnected = false; |
c5c77ba1 JK |
2158 | |
2159 | ||
2cc46837 | 2160 | memset(&strConnectInfo, 0, sizeof(tstrConnectInfo)); |
c5c77ba1 JK |
2161 | |
2162 | ||
2163 | /* First, we will notify the upper layer with the Connection failure {through the Connect Callback function}, | |
2164 | * then we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying | |
2165 | * WID_DISCONNECT} */ | |
2166 | if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) { | |
2167 | if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) { | |
d00d2ba3 | 2168 | memcpy(strConnectInfo.au8bssid, |
c5c77ba1 JK |
2169 | pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6); |
2170 | } | |
2171 | ||
2172 | if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) { | |
2173 | strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen; | |
f3052587 | 2174 | strConnectInfo.pu8ReqIEs = kmalloc(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL); |
d00d2ba3 | 2175 | memcpy(strConnectInfo.pu8ReqIEs, |
c5c77ba1 JK |
2176 | pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, |
2177 | pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen); | |
2178 | } | |
2179 | ||
2180 | pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP, | |
2181 | &strConnectInfo, | |
2182 | MAC_DISCONNECTED, | |
2183 | NULL, | |
2184 | pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid); | |
2185 | ||
2186 | /* Deallocation of strConnectInfo.pu8ReqIEs */ | |
2187 | if (strConnectInfo.pu8ReqIEs != NULL) { | |
49188af2 | 2188 | kfree(strConnectInfo.pu8ReqIEs); |
c5c77ba1 JK |
2189 | strConnectInfo.pu8ReqIEs = NULL; |
2190 | } | |
2191 | } else { | |
03b2d5e7 | 2192 | PRINT_ER("Connect callback function pointer is NULL\n"); |
c5c77ba1 JK |
2193 | } |
2194 | ||
2195 | /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying | |
2196 | * WID_DISCONNECT} */ | |
d85f5326 | 2197 | strWID.u16WIDid = (u16)WID_DISCONNECT; |
c5c77ba1 | 2198 | strWID.enuWIDtype = WID_CHAR; |
ca356ada | 2199 | strWID.ps8WidVal = (s8 *)&u16DummyReasonCode; |
576917ad | 2200 | strWID.s32ValueSize = sizeof(char); |
c5c77ba1 JK |
2201 | |
2202 | PRINT_D(HOSTINF_DBG, "Sending disconnect request\n"); | |
2203 | ||
d42ab083 JK |
2204 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, |
2205 | get_id_from_handler(pstrWFIDrv)); | |
2b9d5b48 | 2206 | if (s32Error) |
c5c77ba1 | 2207 | PRINT_ER("Failed to send dissconect config packet\n"); |
c5c77ba1 JK |
2208 | |
2209 | /* Deallocation of the Saved Connect Request in the global Handle */ | |
2210 | pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0; | |
2211 | if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) { | |
49188af2 | 2212 | kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid); |
c5c77ba1 JK |
2213 | pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL; |
2214 | } | |
2215 | ||
2216 | if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) { | |
49188af2 | 2217 | kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid); |
c5c77ba1 JK |
2218 | pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL; |
2219 | } | |
2220 | ||
2221 | pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0; | |
2222 | if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) { | |
49188af2 | 2223 | kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs); |
c5c77ba1 JK |
2224 | pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL; |
2225 | } | |
2226 | ||
2cc46837 | 2227 | memset(u8ConnectedSSID, 0, ETH_ALEN); |
c5c77ba1 | 2228 | /*Freeing flushed join request params on connect timeout*/ |
8a625cad | 2229 | if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) { |
49188af2 | 2230 | kfree(gu8FlushedJoinReq); |
c5c77ba1 JK |
2231 | gu8FlushedJoinReq = NULL; |
2232 | } | |
8a625cad | 2233 | if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) { |
49188af2 | 2234 | kfree(gu8FlushedInfoElemAsoc); |
c5c77ba1 JK |
2235 | gu8FlushedInfoElemAsoc = NULL; |
2236 | } | |
2237 | ||
2238 | return s32Error; | |
2239 | } | |
2240 | ||
2241 | /** | |
2242 | * @brief Handle_RcvdNtwrkInfo | |
2243 | * @details Handling received network information | |
3bbd59f5 | 2244 | * @param[in] struct rcvd_net_info *pstrRcvdNetworkInfo |
c5c77ba1 JK |
2245 | * @return Error code. |
2246 | * @author | |
2247 | * @date | |
2248 | * @version 1.0 | |
2249 | */ | |
3bbd59f5 TC |
2250 | static s32 Handle_RcvdNtwrkInfo(tstrWILC_WFIDrv *drvHandler, |
2251 | struct rcvd_net_info *pstrRcvdNetworkInfo) | |
c5c77ba1 | 2252 | { |
4e4467fd | 2253 | u32 i; |
72ed4dc7 | 2254 | bool bNewNtwrkFound; |
c5c77ba1 JK |
2255 | |
2256 | ||
2257 | ||
e6e12661 | 2258 | s32 s32Error = 0; |
c5c77ba1 JK |
2259 | tstrNetworkInfo *pstrNetworkInfo = NULL; |
2260 | void *pJoinParams = NULL; | |
2261 | ||
2262 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; | |
2263 | ||
2264 | ||
2265 | ||
72ed4dc7 | 2266 | bNewNtwrkFound = true; |
c5c77ba1 JK |
2267 | PRINT_INFO(HOSTINF_DBG, "Handling received network info\n"); |
2268 | ||
2269 | /*if there is a an ongoing scan request*/ | |
2270 | if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) { | |
2271 | PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n"); | |
2272 | ParseNetworkInfo(pstrRcvdNetworkInfo->pu8Buffer, &pstrNetworkInfo); | |
2273 | if ((pstrNetworkInfo == NULL) | |
b1413b60 | 2274 | || (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult == NULL)) { |
24db713f LK |
2275 | PRINT_ER("driver is null\n"); |
2276 | s32Error = -EINVAL; | |
2277 | goto done; | |
c5c77ba1 JK |
2278 | } |
2279 | ||
2280 | /* check whether this network is discovered before */ | |
2281 | for (i = 0; i < pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount; i++) { | |
2282 | ||
2283 | if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) && | |
2284 | (pstrNetworkInfo->au8bssid != NULL)) { | |
1a646e7e | 2285 | if (memcmp(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid, |
c5c77ba1 JK |
2286 | pstrNetworkInfo->au8bssid, 6) == 0) { |
2287 | if (pstrNetworkInfo->s8rssi <= pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) { | |
2288 | /*we have already found this network with better rssi, so keep the old cached one and don't | |
2289 | * send anything to the upper layer */ | |
2290 | PRINT_D(HOSTINF_DBG, "Network previously discovered\n"); | |
2291 | goto done; | |
2292 | } else { | |
2293 | /* here the same already found network is found again but with a better rssi, so just update | |
2294 | * the rssi for this cached network and send this updated network to the upper layer but | |
2295 | * don't add a new record for it */ | |
2296 | pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi; | |
72ed4dc7 | 2297 | bNewNtwrkFound = false; |
c5c77ba1 JK |
2298 | break; |
2299 | } | |
2300 | } | |
2301 | } | |
2302 | } | |
2303 | ||
72ed4dc7 | 2304 | if (bNewNtwrkFound == true) { |
c5c77ba1 JK |
2305 | /* here it is confirmed that it is a new discovered network, |
2306 | * so add its record then call the User CallBack function */ | |
2307 | ||
2308 | PRINT_D(HOSTINF_DBG, "New network found\n"); | |
2309 | ||
2310 | if (pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) { | |
2311 | pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi; | |
2312 | ||
2313 | if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL) | |
2314 | && (pstrNetworkInfo->au8bssid != NULL)) { | |
d00d2ba3 | 2315 | memcpy(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid, |
c5c77ba1 JK |
2316 | pstrNetworkInfo->au8bssid, 6); |
2317 | ||
2318 | pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount++; | |
2319 | ||
72ed4dc7 | 2320 | pstrNetworkInfo->bNewNetwork = true; |
c5c77ba1 JK |
2321 | /* add new BSS to JoinBssTable */ |
2322 | #ifdef WILC_PARSE_SCAN_IN_HOST | |
2323 | pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo); | |
2324 | #endif /*WILC_PARSE_SCAN_IN_HOST*/ | |
2325 | ||
2326 | pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo, | |
2327 | pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, | |
2328 | pJoinParams); | |
2329 | ||
2330 | ||
2331 | } | |
2332 | } else { | |
03b2d5e7 | 2333 | PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n"); |
c5c77ba1 JK |
2334 | } |
2335 | } else { | |
72ed4dc7 | 2336 | pstrNetworkInfo->bNewNetwork = false; |
c5c77ba1 JK |
2337 | /* just call the User CallBack function to send the same discovered network with its updated RSSI */ |
2338 | pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo, | |
2339 | pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL); | |
2340 | } | |
2341 | } | |
2342 | ||
c5c77ba1 JK |
2343 | done: |
2344 | /* Deallocate pstrRcvdNetworkInfo->pu8Buffer which was prevoisuly allocated by the sending thread */ | |
2345 | if (pstrRcvdNetworkInfo->pu8Buffer != NULL) { | |
49188af2 | 2346 | kfree(pstrRcvdNetworkInfo->pu8Buffer); |
c5c77ba1 JK |
2347 | pstrRcvdNetworkInfo->pu8Buffer = NULL; |
2348 | } | |
2349 | ||
2350 | /*free structure allocated*/ | |
b1413b60 | 2351 | if (pstrNetworkInfo != NULL) { |
c5c77ba1 | 2352 | DeallocateNetworkInfo(pstrNetworkInfo); |
b1413b60 | 2353 | pstrNetworkInfo = NULL; |
c5c77ba1 JK |
2354 | } |
2355 | ||
2356 | return s32Error; | |
2357 | } | |
2358 | ||
2359 | /** | |
2360 | * @brief Handle_RcvdGnrlAsyncInfo | |
2361 | * @details Handling received asynchrous general network information | |
f23a9eab | 2362 | * @param[in] struct rcvd_async_info *pstrRcvdGnrlAsyncInfo |
c5c77ba1 JK |
2363 | * @return Error code. |
2364 | * @author | |
2365 | * @date | |
2366 | * @version 1.0 | |
2367 | */ | |
f23a9eab TC |
2368 | static s32 Handle_RcvdGnrlAsyncInfo(tstrWILC_WFIDrv *drvHandler, |
2369 | struct rcvd_async_info *pstrRcvdGnrlAsyncInfo) | |
c5c77ba1 JK |
2370 | { |
2371 | /* TODO: mostafa: till now, this function just handles only the received mac status msg, */ | |
2372 | /* which carries only 1 WID which have WID ID = WID_STATUS */ | |
e6e12661 | 2373 | s32 s32Error = 0; |
63d03e47 GKH |
2374 | u8 u8MsgType = 0; |
2375 | u8 u8MsgID = 0; | |
d85f5326 CL |
2376 | u16 u16MsgLen = 0; |
2377 | u16 u16WidID = (u16)WID_NIL; | |
63d03e47 GKH |
2378 | u8 u8WidLen = 0; |
2379 | u8 u8MacStatus; | |
2380 | u8 u8MacStatusReasonCode; | |
2381 | u8 u8MacStatusAdditionalInfo; | |
c5c77ba1 JK |
2382 | tstrConnectInfo strConnectInfo; |
2383 | tstrDisconnectNotifInfo strDisconnectNotifInfo; | |
e6e12661 | 2384 | s32 s32Err = 0; |
c5c77ba1 | 2385 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler; |
78c87591 | 2386 | |
2b9d5b48 | 2387 | if (pstrWFIDrv == NULL) |
c5c77ba1 | 2388 | PRINT_ER("Driver handler is NULL\n"); |
c5c77ba1 JK |
2389 | PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", pstrWFIDrv->enuHostIFstate, |
2390 | pstrRcvdGnrlAsyncInfo->pu8Buffer[7]); | |
2391 | ||
2392 | if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || | |
2393 | (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) || | |
2394 | pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) { | |
2395 | if ((pstrRcvdGnrlAsyncInfo->pu8Buffer == NULL) || | |
b1413b60 | 2396 | (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) { |
24db713f LK |
2397 | PRINT_ER("driver is null\n"); |
2398 | return -EINVAL; | |
c5c77ba1 JK |
2399 | } |
2400 | ||
2401 | u8MsgType = pstrRcvdGnrlAsyncInfo->pu8Buffer[0]; | |
2402 | ||
2403 | /* Check whether the received message type is 'I' */ | |
2404 | if ('I' != u8MsgType) { | |
2405 | PRINT_ER("Received Message format incorrect.\n"); | |
24db713f | 2406 | return -EFAULT; |
c5c77ba1 JK |
2407 | } |
2408 | ||
2409 | /* Extract message ID */ | |
2410 | u8MsgID = pstrRcvdGnrlAsyncInfo->pu8Buffer[1]; | |
2411 | ||
2412 | /* Extract message Length */ | |
2413 | u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[2], pstrRcvdGnrlAsyncInfo->pu8Buffer[3]); | |
2414 | ||
2415 | /* Extract WID ID [expected to be = WID_STATUS] */ | |
2416 | u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[4], pstrRcvdGnrlAsyncInfo->pu8Buffer[5]); | |
2417 | ||
2418 | /* Extract WID Length [expected to be = 1] */ | |
2419 | u8WidLen = pstrRcvdGnrlAsyncInfo->pu8Buffer[6]; | |
2420 | ||
2421 | /* get the WID value [expected to be one of two values: either MAC_CONNECTED = (1) or MAC_DISCONNECTED = (0)] */ | |
2422 | u8MacStatus = pstrRcvdGnrlAsyncInfo->pu8Buffer[7]; | |
2423 | u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->pu8Buffer[8]; | |
2424 | u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->pu8Buffer[9]; | |
2425 | PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo); | |
2426 | if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) { | |
2427 | /* our station had sent Association Request frame, so here it will get the Association Response frame then parse it */ | |
4e4467fd | 2428 | u32 u32RcvdAssocRespInfoLen; |
c5c77ba1 JK |
2429 | tstrConnectRespInfo *pstrConnectRespInfo = NULL; |
2430 | ||
2431 | PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo); | |
2432 | ||
2cc46837 | 2433 | memset(&strConnectInfo, 0, sizeof(tstrConnectInfo)); |
c5c77ba1 JK |
2434 | |
2435 | if (u8MacStatus == MAC_CONNECTED) { | |
2cc46837 | 2436 | memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE); |
c5c77ba1 | 2437 | |
218dc407 | 2438 | host_int_get_assoc_res_info(pstrWFIDrv, |
c5c77ba1 JK |
2439 | gapu8RcvdAssocResp, |
2440 | MAX_ASSOC_RESP_FRAME_SIZE, | |
2441 | &u32RcvdAssocRespInfoLen); | |
2442 | ||
2443 | PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen); | |
2444 | ||
2445 | if (u32RcvdAssocRespInfoLen != 0) { | |
2446 | ||
2447 | PRINT_D(HOSTINF_DBG, "Parsing association response\n"); | |
2448 | s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen, | |
2449 | &pstrConnectRespInfo); | |
2450 | if (s32Err) { | |
03b2d5e7 | 2451 | PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err); |
c5c77ba1 JK |
2452 | } else { |
2453 | /* use the necessary parsed Info from the Received Association Response */ | |
2454 | strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus; | |
2455 | ||
2456 | if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) { | |
2457 | PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n"); | |
2458 | if (pstrConnectRespInfo->pu8RespIEs != NULL) { | |
2459 | strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen; | |
2460 | ||
2461 | ||
f3052587 | 2462 | strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL); |
d00d2ba3 | 2463 | memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs, |
c5c77ba1 JK |
2464 | pstrConnectRespInfo->u16RespIEsLen); |
2465 | } | |
2466 | } | |
2467 | ||
2468 | /* deallocate the Assoc. Resp. parsed structure as it is not needed anymore */ | |
2469 | if (pstrConnectRespInfo != NULL) { | |
2470 | DeallocateAssocRespInfo(pstrConnectRespInfo); | |
2471 | pstrConnectRespInfo = NULL; | |
2472 | } | |
2473 | } | |
2474 | } | |
2475 | } | |
2476 | ||
2477 | /* The station has just received mac status and it also received assoc. response which | |
2478 | * it was waiting for. | |
2479 | * So check first the matching between the received mac status and the received status code in Asoc Resp */ | |
2480 | if ((u8MacStatus == MAC_CONNECTED) && | |
2481 | (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) { | |
03b2d5e7 | 2482 | PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n"); |
2cc46837 | 2483 | memset(u8ConnectedSSID, 0, ETH_ALEN); |
c5c77ba1 JK |
2484 | |
2485 | } else if (u8MacStatus == MAC_DISCONNECTED) { | |
2486 | PRINT_ER("Received MAC status is MAC_DISCONNECTED\n"); | |
2cc46837 | 2487 | memset(u8ConnectedSSID, 0, ETH_ALEN); |
c5c77ba1 JK |
2488 | } |
2489 | ||
2490 | /* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */ | |
2491 | /* through a structure of type tstrConnectRespInfo */ | |
2492 | if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) { | |
2493 | PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n"); | |
d00d2ba3 | 2494 | memcpy(strConnectInfo.au8bssid, pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6); |
c5c77ba1 JK |
2495 | |
2496 | if ((u8MacStatus == MAC_CONNECTED) && | |
2497 | (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) { | |
d00d2ba3 | 2498 | memcpy(pstrWFIDrv->au8AssociatedBSSID, |
c5c77ba1 JK |
2499 | pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN); |
2500 | } | |
2501 | } | |
2502 | ||
2503 | ||
2504 | if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) { | |
2505 | strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen; | |
f3052587 | 2506 | strConnectInfo.pu8ReqIEs = kmalloc(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL); |
d00d2ba3 | 2507 | memcpy(strConnectInfo.pu8ReqIEs, |
c5c77ba1 JK |
2508 | pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, |
2509 | pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen); | |
2510 | } | |
2511 | ||
2512 | ||
8972d0fe | 2513 | del_timer(&pstrWFIDrv->hConnectTimer); |
c5c77ba1 JK |
2514 | pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP, |
2515 | &strConnectInfo, | |
2516 | u8MacStatus, | |
2517 | NULL, | |
2518 | pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid); | |
2519 | ||
2520 | ||
2521 | /* if received mac status is MAC_CONNECTED and | |
2522 | * received status code in Asoc Resp is SUCCESSFUL_STATUSCODE, change state to CONNECTED | |
2523 | * else change state to IDLE */ | |
2524 | if ((u8MacStatus == MAC_CONNECTED) && | |
2525 | (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) { | |
2526 | #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP | |
2527 | ||
218dc407 | 2528 | host_int_set_power_mgmt(pstrWFIDrv, 0, 0); |
c5c77ba1 JK |
2529 | #endif |
2530 | ||
2531 | PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n"); | |
2532 | pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTED; | |
2533 | ||
2534 | #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP | |
2535 | PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n"); | |
72ed4dc7 | 2536 | g_obtainingIP = true; |
9eb06643 GKH |
2537 | mod_timer(&hDuringIpTimer, |
2538 | jiffies + msecs_to_jiffies(10000)); | |
c5c77ba1 JK |
2539 | #endif |
2540 | ||
2541 | #ifdef WILC_PARSE_SCAN_IN_HOST | |
2542 | /* open a BA session if possible */ | |
2543 | /* if(pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable) */ | |
2544 | ||
2545 | #endif | |
2546 | ||
2547 | /* host_int_addBASession(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid,0, */ | |
2548 | /* BA_SESSION_DEFAULT_BUFFER_SIZE,BA_SESSION_DEFAULT_TIMEOUT); */ | |
2549 | } else { | |
2550 | PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus); | |
2551 | pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE; | |
72ed4dc7 | 2552 | gbScanWhileConnected = false; |
c5c77ba1 JK |
2553 | } |
2554 | ||
2555 | /* Deallocation */ | |
2556 | if (strConnectInfo.pu8RespIEs != NULL) { | |
49188af2 | 2557 | kfree(strConnectInfo.pu8RespIEs); |
c5c77ba1 JK |
2558 | strConnectInfo.pu8RespIEs = NULL; |
2559 | } | |
2560 | ||
2561 | if (strConnectInfo.pu8ReqIEs != NULL) { | |
49188af2 | 2562 | kfree(strConnectInfo.pu8ReqIEs); |
c5c77ba1 JK |
2563 | strConnectInfo.pu8ReqIEs = NULL; |
2564 | } | |
2565 | ||
2566 | ||
2567 | pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0; | |
2568 | if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) { | |
49188af2 | 2569 | kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid); |
c5c77ba1 JK |
2570 | pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL; |
2571 | } | |
2572 | ||
2573 | if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) { | |
49188af2 | 2574 | kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid); |
c5c77ba1 JK |
2575 | pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL; |
2576 | } | |
2577 | ||
2578 | pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0; | |
2579 | if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) { | |
49188af2 | 2580 | kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs); |
c5c77ba1 JK |
2581 | pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL; |
2582 | } | |
2583 | ||
2584 | } else if ((u8MacStatus == MAC_DISCONNECTED) && | |
2585 | (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)) { | |
2586 | /* Disassociation or Deauthentication frame has been received */ | |
2587 | PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n"); | |
2588 | ||
2cc46837 | 2589 | memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo)); |
c5c77ba1 JK |
2590 | |
2591 | if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) { | |
03b2d5e7 | 2592 | PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n"); |
8972d0fe | 2593 | del_timer(&pstrWFIDrv->hScanTimer); |
c5c77ba1 JK |
2594 | Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED); |
2595 | } | |
2596 | ||
2597 | strDisconnectNotifInfo.u16reason = 0; | |
2598 | strDisconnectNotifInfo.ie = NULL; | |
2599 | strDisconnectNotifInfo.ie_len = 0; | |
2600 | ||
2601 | if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) { | |
2602 | #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP | |
2603 | ||
72ed4dc7 | 2604 | g_obtainingIP = false; |
218dc407 | 2605 | host_int_set_power_mgmt(pstrWFIDrv, 0, 0); |
c5c77ba1 JK |
2606 | #endif |
2607 | ||
2608 | pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, | |
2609 | NULL, | |
2610 | 0, | |
2611 | &strDisconnectNotifInfo, | |
2612 | pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid); | |
2613 | ||
2614 | } else { | |
03b2d5e7 | 2615 | PRINT_ER("Connect result callback function is NULL\n"); |
c5c77ba1 JK |
2616 | } |
2617 | ||
2cc46837 | 2618 | memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN); |
c5c77ba1 JK |
2619 | |
2620 | ||
2621 | /* Deallocation */ | |
2622 | ||
2623 | /* if Information Elements were retrieved from the Received deauth/disassoc frame, then they | |
2624 | * should be deallocated here */ | |
2625 | /* | |
2626 | * if(strDisconnectNotifInfo.ie != NULL) | |
2627 | * { | |
49188af2 | 2628 | * kfree(strDisconnectNotifInfo.ie); |
c5c77ba1 JK |
2629 | * strDisconnectNotifInfo.ie = NULL; |
2630 | * } | |
2631 | */ | |
2632 | ||
2633 | pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0; | |
2634 | if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) { | |
49188af2 | 2635 | kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid); |
c5c77ba1 JK |
2636 | pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL; |
2637 | } | |
2638 | ||
2639 | if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) { | |
49188af2 | 2640 | kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid); |
c5c77ba1 JK |
2641 | pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL; |
2642 | } | |
2643 | ||
2644 | pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0; | |
2645 | if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) { | |
49188af2 | 2646 | kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs); |
c5c77ba1 JK |
2647 | pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL; |
2648 | } | |
2649 | ||
c5c77ba1 JK |
2650 | /*Freeing flushed join request params on receiving*/ |
2651 | /*MAC_DISCONNECTED while connected*/ | |
8a625cad | 2652 | if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) { |
49188af2 | 2653 | kfree(gu8FlushedJoinReq); |
c5c77ba1 JK |
2654 | gu8FlushedJoinReq = NULL; |
2655 | } | |
8a625cad | 2656 | if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) { |
49188af2 | 2657 | kfree(gu8FlushedInfoElemAsoc); |
c5c77ba1 JK |
2658 | gu8FlushedInfoElemAsoc = NULL; |
2659 | } | |
2660 | ||
2661 | pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE; | |
72ed4dc7 | 2662 | gbScanWhileConnected = false; |
c5c77ba1 JK |
2663 | |
2664 | } else if ((u8MacStatus == MAC_DISCONNECTED) && | |
2665 | (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL)) { | |
2666 | PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n"); | |
03b2d5e7 | 2667 | PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n"); |
c5c77ba1 | 2668 | /*Abort the running scan*/ |
8972d0fe | 2669 | del_timer(&pstrWFIDrv->hScanTimer); |
2b9d5b48 | 2670 | if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) |
2b05df55 | 2671 | Handle_ScanDone(pstrWFIDrv, SCAN_EVENT_ABORTED); |
c5c77ba1 | 2672 | |
c5c77ba1 JK |
2673 | } |
2674 | ||
2675 | } | |
2676 | ||
c5c77ba1 JK |
2677 | /* Deallocate pstrRcvdGnrlAsyncInfo->pu8Buffer which was prevoisuly allocated by the sending thread */ |
2678 | if (pstrRcvdGnrlAsyncInfo->pu8Buffer != NULL) { | |
49188af2 | 2679 | kfree(pstrRcvdGnrlAsyncInfo->pu8Buffer); |
c5c77ba1 JK |
2680 | pstrRcvdGnrlAsyncInfo->pu8Buffer = NULL; |
2681 | } | |
2682 | ||
2683 | return s32Error; | |
2684 | } | |
2685 | ||
2686 | /** | |
2687 | * @brief Handle_Key | |
2688 | * @details Sending config packet to firmware to set key | |
c98387a5 | 2689 | * @param[in] struct key_attr *pstrHostIFkeyAttr |
c5c77ba1 JK |
2690 | * @return Error code. |
2691 | * @author | |
2692 | * @date | |
2693 | * @version 1.0 | |
2694 | */ | |
c98387a5 TC |
2695 | static int Handle_Key(tstrWILC_WFIDrv *drvHandler, |
2696 | struct key_attr *pstrHostIFkeyAttr) | |
c5c77ba1 | 2697 | { |
e6e12661 | 2698 | s32 s32Error = 0; |
c5c77ba1 | 2699 | tstrWID strWID; |
c5c77ba1 | 2700 | tstrWID strWIDList[5]; |
63d03e47 GKH |
2701 | u8 i; |
2702 | u8 *pu8keybuf; | |
ca356ada CL |
2703 | s8 s8idxarray[1]; |
2704 | s8 ret = 0; | |
c5c77ba1 JK |
2705 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; |
2706 | ||
2707 | ||
2708 | switch (pstrHostIFkeyAttr->enuKeyType) { | |
2709 | ||
2710 | ||
2711 | case WEP: | |
2712 | ||
c5c77ba1 JK |
2713 | if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) { |
2714 | ||
2715 | PRINT_D(HOSTINF_DBG, "Handling WEP key\n"); | |
2716 | PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx)); | |
d85f5326 | 2717 | strWIDList[0].u16WIDid = (u16)WID_11I_MODE; |
c5c77ba1 | 2718 | strWIDList[0].enuWIDtype = WID_CHAR; |
576917ad | 2719 | strWIDList[0].s32ValueSize = sizeof(char); |
ca356ada | 2720 | strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8mode)); |
c5c77ba1 JK |
2721 | |
2722 | strWIDList[1].u16WIDid = WID_AUTH_TYPE; | |
2723 | strWIDList[1].enuWIDtype = WID_CHAR; | |
576917ad | 2724 | strWIDList[1].s32ValueSize = sizeof(char); |
ca356ada | 2725 | strWIDList[1].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type)); |
c5c77ba1 | 2726 | |
d85f5326 | 2727 | strWIDList[2].u16WIDid = (u16)WID_KEY_ID; |
c5c77ba1 JK |
2728 | strWIDList[2].enuWIDtype = WID_CHAR; |
2729 | ||
ca356ada | 2730 | strWIDList[2].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx)); |
576917ad | 2731 | strWIDList[2].s32ValueSize = sizeof(char); |
c5c77ba1 JK |
2732 | |
2733 | ||
f3052587 | 2734 | pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, GFP_KERNEL); |
c5c77ba1 JK |
2735 | |
2736 | ||
2737 | if (pu8keybuf == NULL) { | |
2738 | PRINT_ER("No buffer to send Key\n"); | |
2739 | return -1; | |
2740 | } | |
2741 | ||
d00d2ba3 | 2742 | memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey, |
c5c77ba1 JK |
2743 | pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen); |
2744 | ||
2745 | ||
49188af2 | 2746 | kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey); |
c5c77ba1 | 2747 | |
d85f5326 | 2748 | strWIDList[3].u16WIDid = (u16)WID_WEP_KEY_VALUE; |
c5c77ba1 JK |
2749 | strWIDList[3].enuWIDtype = WID_STR; |
2750 | strWIDList[3].s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen; | |
ca356ada | 2751 | strWIDList[3].ps8WidVal = (s8 *)pu8keybuf; |
c5c77ba1 JK |
2752 | |
2753 | ||
d42ab083 JK |
2754 | s32Error = SendConfigPkt(SET_CFG, strWIDList, 4, true, |
2755 | get_id_from_handler(pstrWFIDrv)); | |
49188af2 | 2756 | kfree(pu8keybuf); |
c5c77ba1 JK |
2757 | |
2758 | ||
2759 | } | |
c5c77ba1 JK |
2760 | |
2761 | if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) { | |
2762 | PRINT_D(HOSTINF_DBG, "Handling WEP key\n"); | |
f3052587 | 2763 | pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2, GFP_KERNEL); |
c5c77ba1 JK |
2764 | if (pu8keybuf == NULL) { |
2765 | PRINT_ER("No buffer to send Key\n"); | |
2766 | return -1; | |
2767 | } | |
2768 | pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx; | |
2769 | ||
d00d2ba3 | 2770 | memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, 1); |
c5c77ba1 | 2771 | |
d00d2ba3 | 2772 | memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey, |
c5c77ba1 JK |
2773 | pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen); |
2774 | ||
49188af2 | 2775 | kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey); |
c5c77ba1 | 2776 | |
d85f5326 | 2777 | strWID.u16WIDid = (u16)WID_ADD_WEP_KEY; |
c5c77ba1 | 2778 | strWID.enuWIDtype = WID_STR; |
ca356ada | 2779 | strWID.ps8WidVal = (s8 *)pu8keybuf; |
c5c77ba1 JK |
2780 | strWID.s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2; |
2781 | ||
d42ab083 JK |
2782 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
2783 | get_id_from_handler(pstrWFIDrv)); | |
49188af2 | 2784 | kfree(pu8keybuf); |
c5c77ba1 JK |
2785 | } else if (pstrHostIFkeyAttr->u8KeyAction & REMOVEKEY) { |
2786 | ||
2787 | PRINT_D(HOSTINF_DBG, "Removing key\n"); | |
d85f5326 | 2788 | strWID.u16WIDid = (u16)WID_REMOVE_WEP_KEY; |
c5c77ba1 JK |
2789 | strWID.enuWIDtype = WID_STR; |
2790 | ||
ca356ada | 2791 | s8idxarray[0] = (s8)pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx; |
c5c77ba1 JK |
2792 | strWID.ps8WidVal = s8idxarray; |
2793 | strWID.s32ValueSize = 1; | |
2794 | ||
d42ab083 JK |
2795 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
2796 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 | 2797 | } else { |
d85f5326 | 2798 | strWID.u16WIDid = (u16)WID_KEY_ID; |
c5c77ba1 | 2799 | strWID.enuWIDtype = WID_CHAR; |
ca356ada | 2800 | strWID.ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx)); |
576917ad | 2801 | strWID.s32ValueSize = sizeof(char); |
c5c77ba1 JK |
2802 | |
2803 | PRINT_D(HOSTINF_DBG, "Setting default key index\n"); | |
2804 | ||
d42ab083 JK |
2805 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
2806 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 | 2807 | } |
83383ea3 | 2808 | up(&(pstrWFIDrv->hSemTestKeyBlock)); |
c5c77ba1 JK |
2809 | break; |
2810 | ||
2811 | case WPARxGtk: | |
c5c77ba1 | 2812 | if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) { |
f3052587 | 2813 | pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL); |
c5c77ba1 JK |
2814 | if (pu8keybuf == NULL) { |
2815 | PRINT_ER("No buffer to send RxGTK Key\n"); | |
2816 | ret = -1; | |
2817 | goto _WPARxGtk_end_case_; | |
2818 | } | |
2819 | ||
2cc46837 | 2820 | memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN); |
c5c77ba1 JK |
2821 | |
2822 | ||
2823 | /*|----------------------------------------------------------------------------| | |
2824 | * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key | | |
2825 | * |------------|---------|-------|------------|---------------|----------------| | |
2826 | | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/ | |
2827 | ||
2828 | ||
2829 | ||
2830 | if (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq != NULL) | |
d00d2ba3 | 2831 | memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8); |
c5c77ba1 JK |
2832 | |
2833 | ||
d00d2ba3 | 2834 | memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1); |
c5c77ba1 | 2835 | |
d00d2ba3 | 2836 | memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1); |
c5c77ba1 | 2837 | |
d00d2ba3 | 2838 | memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key, |
c5c77ba1 JK |
2839 | pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen); |
2840 | /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */ | |
d85f5326 | 2841 | strWIDList[0].u16WIDid = (u16)WID_11I_MODE; |
c5c77ba1 | 2842 | strWIDList[0].enuWIDtype = WID_CHAR; |
576917ad | 2843 | strWIDList[0].s32ValueSize = sizeof(char); |
ca356ada | 2844 | strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode)); |
c5c77ba1 | 2845 | |
d85f5326 | 2846 | strWIDList[1].u16WIDid = (u16)WID_ADD_RX_GTK; |
c5c77ba1 | 2847 | strWIDList[1].enuWIDtype = WID_STR; |
ca356ada | 2848 | strWIDList[1].ps8WidVal = (s8 *)pu8keybuf; |
c5c77ba1 JK |
2849 | strWIDList[1].s32ValueSize = RX_MIC_KEY_MSG_LEN; |
2850 | ||
d42ab083 JK |
2851 | s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, true, |
2852 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 | 2853 | |
49188af2 | 2854 | kfree(pu8keybuf); |
c5c77ba1 JK |
2855 | |
2856 | /* ////////////////////////// */ | |
83383ea3 | 2857 | up(&(pstrWFIDrv->hSemTestKeyBlock)); |
c5c77ba1 JK |
2858 | /* ///////////////////////// */ |
2859 | } | |
2860 | ||
c5c77ba1 JK |
2861 | if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) { |
2862 | PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n"); | |
2863 | ||
f3052587 | 2864 | pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL); |
c5c77ba1 JK |
2865 | if (pu8keybuf == NULL) { |
2866 | PRINT_ER("No buffer to send RxGTK Key\n"); | |
2867 | ret = -1; | |
2868 | goto _WPARxGtk_end_case_; | |
2869 | } | |
2870 | ||
2cc46837 | 2871 | memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN); |
c5c77ba1 JK |
2872 | |
2873 | ||
2874 | /*|----------------------------------------------------------------------------| | |
2875 | * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key | | |
2876 | * |------------|---------|-------|------------|---------------|----------------| | |
2877 | | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/ | |
2878 | ||
78174ada | 2879 | if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) |
d00d2ba3 | 2880 | memcpy(pu8keybuf, pstrWFIDrv->au8AssociatedBSSID, ETH_ALEN); |
78174ada | 2881 | else |
03b2d5e7 | 2882 | PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n"); |
c5c77ba1 | 2883 | |
d00d2ba3 | 2884 | memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8); |
c5c77ba1 | 2885 | |
d00d2ba3 | 2886 | memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1); |
c5c77ba1 | 2887 | |
d00d2ba3 CL |
2888 | memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1); |
2889 | memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key, | |
c5c77ba1 JK |
2890 | pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen); |
2891 | ||
d85f5326 | 2892 | strWID.u16WIDid = (u16)WID_ADD_RX_GTK; |
c5c77ba1 | 2893 | strWID.enuWIDtype = WID_STR; |
ca356ada | 2894 | strWID.ps8WidVal = (s8 *)pu8keybuf; |
c5c77ba1 JK |
2895 | strWID.s32ValueSize = RX_MIC_KEY_MSG_LEN; |
2896 | ||
d42ab083 JK |
2897 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
2898 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 | 2899 | |
49188af2 | 2900 | kfree(pu8keybuf); |
c5c77ba1 JK |
2901 | |
2902 | /* ////////////////////////// */ | |
83383ea3 | 2903 | up(&(pstrWFIDrv->hSemTestKeyBlock)); |
c5c77ba1 JK |
2904 | /* ///////////////////////// */ |
2905 | } | |
2906 | _WPARxGtk_end_case_: | |
49188af2 CL |
2907 | kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key); |
2908 | kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq); | |
c5c77ba1 JK |
2909 | if (ret == -1) |
2910 | return ret; | |
2911 | ||
2912 | break; | |
2913 | ||
2914 | case WPAPtk: | |
c5c77ba1 JK |
2915 | if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) { |
2916 | ||
2917 | ||
f3052587 | 2918 | pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL); |
c5c77ba1 JK |
2919 | |
2920 | ||
2921 | ||
2922 | if (pu8keybuf == NULL) { | |
2923 | PRINT_ER("No buffer to send PTK Key\n"); | |
2924 | ret = -1; | |
2925 | goto _WPAPtk_end_case_; | |
2926 | ||
2927 | } | |
2928 | ||
2929 | /*|-----------------------------------------------------------------------------| | |
2930 | * |Station address | keyidx |Key Length |Temporal Key | Rx Michael Key |Tx Michael Key | | |
2931 | * |----------------|------------ |--------------|----------------|---------------| | |
2932 | | 6 bytes | 1 byte | 1byte | 16 bytes | 8 bytes | 8 bytes | | |
2933 | |-----------------------------------------------------------------------------|*/ | |
2934 | ||
d00d2ba3 | 2935 | memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */ |
c5c77ba1 | 2936 | |
d00d2ba3 CL |
2937 | memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1); |
2938 | memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1); | |
c5c77ba1 | 2939 | /*16 byte TK*/ |
d00d2ba3 | 2940 | memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key, |
c5c77ba1 JK |
2941 | pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen); |
2942 | ||
2943 | ||
d85f5326 | 2944 | strWIDList[0].u16WIDid = (u16)WID_11I_MODE; |
c5c77ba1 | 2945 | strWIDList[0].enuWIDtype = WID_CHAR; |
576917ad | 2946 | strWIDList[0].s32ValueSize = sizeof(char); |
ca356ada | 2947 | strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode)); |
c5c77ba1 | 2948 | |
d85f5326 | 2949 | strWIDList[1].u16WIDid = (u16)WID_ADD_PTK; |
c5c77ba1 | 2950 | strWIDList[1].enuWIDtype = WID_STR; |
ca356ada | 2951 | strWIDList[1].ps8WidVal = (s8 *)pu8keybuf; |
c5c77ba1 JK |
2952 | strWIDList[1].s32ValueSize = PTK_KEY_MSG_LEN + 1; |
2953 | ||
d42ab083 JK |
2954 | s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, true, |
2955 | get_id_from_handler(pstrWFIDrv)); | |
49188af2 | 2956 | kfree(pu8keybuf); |
c5c77ba1 JK |
2957 | |
2958 | /* ////////////////////////// */ | |
83383ea3 | 2959 | up(&(pstrWFIDrv->hSemTestKeyBlock)); |
c5c77ba1 JK |
2960 | /* ///////////////////////// */ |
2961 | } | |
c5c77ba1 JK |
2962 | if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) { |
2963 | ||
2964 | ||
f3052587 | 2965 | pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL); |
c5c77ba1 JK |
2966 | |
2967 | ||
2968 | ||
2969 | if (pu8keybuf == NULL) { | |
2970 | PRINT_ER("No buffer to send PTK Key\n"); | |
2971 | ret = -1; | |
2972 | goto _WPAPtk_end_case_; | |
2973 | ||
2974 | } | |
2975 | ||
2976 | /*|-----------------------------------------------------------------------------| | |
2977 | * |Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key | | |
2978 | * |----------------|------------|--------------|----------------|---------------| | |
2979 | | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes | | |
2980 | |-----------------------------------------------------------------------------|*/ | |
2981 | ||
d00d2ba3 | 2982 | memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */ |
c5c77ba1 | 2983 | |
d00d2ba3 | 2984 | memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1); |
c5c77ba1 | 2985 | /*16 byte TK*/ |
d00d2ba3 | 2986 | memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key, |
c5c77ba1 JK |
2987 | pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen); |
2988 | ||
2989 | ||
d85f5326 | 2990 | strWID.u16WIDid = (u16)WID_ADD_PTK; |
c5c77ba1 | 2991 | strWID.enuWIDtype = WID_STR; |
ca356ada | 2992 | strWID.ps8WidVal = (s8 *)pu8keybuf; |
c5c77ba1 JK |
2993 | strWID.s32ValueSize = PTK_KEY_MSG_LEN; |
2994 | ||
d42ab083 JK |
2995 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
2996 | get_id_from_handler(pstrWFIDrv)); | |
49188af2 | 2997 | kfree(pu8keybuf); |
c5c77ba1 JK |
2998 | |
2999 | /* ////////////////////////// */ | |
83383ea3 | 3000 | up(&(pstrWFIDrv->hSemTestKeyBlock)); |
c5c77ba1 JK |
3001 | /* ///////////////////////// */ |
3002 | } | |
3003 | ||
3004 | _WPAPtk_end_case_: | |
49188af2 | 3005 | kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key); |
c5c77ba1 JK |
3006 | if (ret == -1) |
3007 | return ret; | |
3008 | ||
3009 | break; | |
3010 | ||
3011 | ||
3012 | case PMKSA: | |
3013 | ||
3014 | PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n"); | |
3015 | ||
f3052587 | 3016 | pu8keybuf = kmalloc((pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL); |
c5c77ba1 JK |
3017 | if (pu8keybuf == NULL) { |
3018 | PRINT_ER("No buffer to send PMKSA Key\n"); | |
3019 | return -1; | |
3020 | } | |
3021 | ||
3022 | pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid; | |
3023 | ||
3024 | for (i = 0; i < pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid; i++) { | |
3025 | ||
d00d2ba3 CL |
3026 | memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, ETH_ALEN); |
3027 | memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, PMKID_LEN); | |
c5c77ba1 JK |
3028 | } |
3029 | ||
d85f5326 | 3030 | strWID.u16WIDid = (u16)WID_PMKID_INFO; |
c5c77ba1 | 3031 | strWID.enuWIDtype = WID_STR; |
ca356ada | 3032 | strWID.ps8WidVal = (s8 *)pu8keybuf; |
c5c77ba1 JK |
3033 | strWID.s32ValueSize = (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1; |
3034 | ||
d42ab083 JK |
3035 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
3036 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 | 3037 | |
49188af2 | 3038 | kfree(pu8keybuf); |
c5c77ba1 JK |
3039 | break; |
3040 | } | |
3041 | ||
3042 | if (s32Error) | |
3043 | PRINT_ER("Failed to send key config packet\n"); | |
3044 | ||
3045 | ||
3046 | return s32Error; | |
3047 | } | |
3048 | ||
3049 | ||
3050 | /** | |
3051 | * @brief Handle_Disconnect | |
3052 | * @details Sending config packet to firmware to disconnect | |
3053 | * @param[in] NONE | |
3054 | * @return NONE | |
3055 | * @author | |
3056 | * @date | |
3057 | * @version 1.0 | |
3058 | */ | |
2b05df55 | 3059 | static void Handle_Disconnect(tstrWILC_WFIDrv *drvHandler) |
c5c77ba1 JK |
3060 | { |
3061 | tstrWID strWID; | |
3062 | ||
e6e12661 | 3063 | s32 s32Error = 0; |
d85f5326 | 3064 | u16 u16DummyReasonCode = 0; |
c5c77ba1 JK |
3065 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; |
3066 | ||
3067 | ||
d85f5326 | 3068 | strWID.u16WIDid = (u16)WID_DISCONNECT; |
c5c77ba1 | 3069 | strWID.enuWIDtype = WID_CHAR; |
ca356ada | 3070 | strWID.ps8WidVal = (s8 *)&u16DummyReasonCode; |
576917ad | 3071 | strWID.s32ValueSize = sizeof(char); |
c5c77ba1 JK |
3072 | |
3073 | ||
3074 | ||
3075 | PRINT_D(HOSTINF_DBG, "Sending disconnect request\n"); | |
3076 | ||
3077 | #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP | |
3078 | ||
72ed4dc7 | 3079 | g_obtainingIP = false; |
218dc407 | 3080 | host_int_set_power_mgmt(pstrWFIDrv, 0, 0); |
c5c77ba1 JK |
3081 | #endif |
3082 | ||
2cc46837 | 3083 | memset(u8ConnectedSSID, 0, ETH_ALEN); |
c5c77ba1 | 3084 | |
d42ab083 JK |
3085 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, |
3086 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 JK |
3087 | |
3088 | if (s32Error) { | |
3089 | PRINT_ER("Failed to send dissconect config packet\n"); | |
c5c77ba1 JK |
3090 | } else { |
3091 | tstrDisconnectNotifInfo strDisconnectNotifInfo; | |
3092 | ||
2cc46837 | 3093 | memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo)); |
c5c77ba1 JK |
3094 | |
3095 | strDisconnectNotifInfo.u16reason = 0; | |
3096 | strDisconnectNotifInfo.ie = NULL; | |
3097 | strDisconnectNotifInfo.ie_len = 0; | |
3098 | ||
3099 | if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) { | |
8972d0fe | 3100 | del_timer(&pstrWFIDrv->hScanTimer); |
b1413b60 | 3101 | pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL, |
c5c77ba1 JK |
3102 | pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL); |
3103 | ||
b1413b60 | 3104 | pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL; |
c5c77ba1 JK |
3105 | } |
3106 | ||
3107 | if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) { | |
3108 | ||
c5c77ba1 JK |
3109 | /*Stop connect timer, if connection in progress*/ |
3110 | if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) { | |
3111 | PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n"); | |
8972d0fe | 3112 | del_timer(&pstrWFIDrv->hConnectTimer); |
c5c77ba1 JK |
3113 | } |
3114 | ||
3115 | pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL, | |
3116 | 0, &strDisconnectNotifInfo, pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid); | |
3117 | } else { | |
03b2d5e7 | 3118 | PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n"); |
c5c77ba1 JK |
3119 | } |
3120 | ||
72ed4dc7 | 3121 | gbScanWhileConnected = false; |
c5c77ba1 JK |
3122 | |
3123 | pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE; | |
3124 | ||
2cc46837 | 3125 | memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN); |
c5c77ba1 JK |
3126 | |
3127 | ||
3128 | /* Deallocation */ | |
3129 | pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0; | |
3130 | if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) { | |
49188af2 | 3131 | kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid); |
c5c77ba1 JK |
3132 | pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL; |
3133 | } | |
3134 | ||
3135 | if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) { | |
49188af2 | 3136 | kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid); |
c5c77ba1 JK |
3137 | pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL; |
3138 | } | |
3139 | ||
3140 | pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0; | |
3141 | if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) { | |
49188af2 | 3142 | kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs); |
c5c77ba1 JK |
3143 | pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL; |
3144 | } | |
3145 | ||
3146 | ||
8a625cad | 3147 | if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) { |
49188af2 | 3148 | kfree(gu8FlushedJoinReq); |
c5c77ba1 JK |
3149 | gu8FlushedJoinReq = NULL; |
3150 | } | |
8a625cad | 3151 | if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) { |
49188af2 | 3152 | kfree(gu8FlushedInfoElemAsoc); |
c5c77ba1 JK |
3153 | gu8FlushedInfoElemAsoc = NULL; |
3154 | } | |
3155 | ||
3156 | } | |
3157 | ||
c5c77ba1 | 3158 | /* ////////////////////////// */ |
83383ea3 | 3159 | up(&(pstrWFIDrv->hSemTestDisconnectBlock)); |
c5c77ba1 JK |
3160 | /* ///////////////////////// */ |
3161 | ||
3162 | } | |
3163 | ||
3164 | ||
2b05df55 | 3165 | void resolve_disconnect_aberration(tstrWILC_WFIDrv *drvHandler) |
c5c77ba1 JK |
3166 | { |
3167 | tstrWILC_WFIDrv *pstrWFIDrv; | |
3168 | ||
3169 | pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; | |
b1413b60 | 3170 | if (pstrWFIDrv == NULL) |
c5c77ba1 JK |
3171 | return; |
3172 | if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTING)) { | |
3173 | PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n"); | |
218dc407 | 3174 | host_int_disconnect(pstrWFIDrv, 1); |
c5c77ba1 JK |
3175 | } |
3176 | } | |
2b05df55 | 3177 | static s32 Switch_Log_Terminal(tstrWILC_WFIDrv *drvHandler) |
c5c77ba1 JK |
3178 | { |
3179 | ||
3180 | ||
e6e12661 | 3181 | s32 s32Error = 0; |
c5c77ba1 JK |
3182 | tstrWID strWID; |
3183 | static char dummy = 9; | |
3184 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; | |
3185 | ||
d85f5326 | 3186 | strWID.u16WIDid = (u16)WID_LOGTerminal_Switch; |
c5c77ba1 JK |
3187 | strWID.enuWIDtype = WID_CHAR; |
3188 | strWID.ps8WidVal = &dummy; | |
576917ad | 3189 | strWID.s32ValueSize = sizeof(char); |
c5c77ba1 | 3190 | |
d42ab083 JK |
3191 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
3192 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 JK |
3193 | |
3194 | ||
3195 | if (s32Error) { | |
3196 | PRINT_D(HOSTINF_DBG, "Failed to switch log terminal\n"); | |
24db713f LK |
3197 | PRINT_ER("Failed to switch log terminal\n"); |
3198 | return -EINVAL; | |
c5c77ba1 JK |
3199 | } |
3200 | ||
24db713f | 3201 | PRINT_INFO(HOSTINF_DBG, "MAC address set ::\n"); |
c5c77ba1 JK |
3202 | |
3203 | return s32Error; | |
3204 | } | |
3205 | ||
3206 | /** | |
3207 | * @brief Handle_GetChnl | |
3208 | * @details Sending config packet to get channel | |
3209 | * @param[in] NONE | |
3210 | * @return NONE | |
3211 | * | |
3212 | * @author | |
3213 | * @date | |
3214 | * @version 1.0 | |
3215 | */ | |
2b05df55 | 3216 | static s32 Handle_GetChnl(tstrWILC_WFIDrv *drvHandler) |
c5c77ba1 JK |
3217 | { |
3218 | ||
e6e12661 | 3219 | s32 s32Error = 0; |
c5c77ba1 JK |
3220 | tstrWID strWID; |
3221 | /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ | |
3222 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; | |
78c87591 | 3223 | |
d85f5326 | 3224 | strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL; |
c5c77ba1 | 3225 | strWID.enuWIDtype = WID_CHAR; |
ca356ada | 3226 | strWID.ps8WidVal = (s8 *)&gu8Chnl; |
576917ad | 3227 | strWID.s32ValueSize = sizeof(char); |
c5c77ba1 JK |
3228 | |
3229 | PRINT_D(HOSTINF_DBG, "Getting channel value\n"); | |
3230 | ||
d42ab083 JK |
3231 | s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, |
3232 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 JK |
3233 | /*get the value by searching the local copy*/ |
3234 | if (s32Error) { | |
3235 | PRINT_ER("Failed to get channel number\n"); | |
24db713f | 3236 | s32Error = -EFAULT; |
c5c77ba1 JK |
3237 | } |
3238 | ||
83383ea3 | 3239 | up(&(pstrWFIDrv->hSemGetCHNL)); |
c5c77ba1 JK |
3240 | |
3241 | return s32Error; | |
3242 | ||
3243 | ||
3244 | ||
3245 | } | |
3246 | ||
3247 | ||
3248 | /** | |
3249 | * @brief Handle_GetRssi | |
3250 | * @details Sending config packet to get RSSI | |
3251 | * @param[in] NONE | |
3252 | * @return NONE | |
3253 | * @author | |
3254 | * @date | |
3255 | * @version 1.0 | |
3256 | */ | |
2b05df55 | 3257 | static void Handle_GetRssi(tstrWILC_WFIDrv *drvHandler) |
c5c77ba1 | 3258 | { |
e6e12661 | 3259 | s32 s32Error = 0; |
c5c77ba1 JK |
3260 | tstrWID strWID; |
3261 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; | |
3262 | ||
d85f5326 | 3263 | strWID.u16WIDid = (u16)WID_RSSI; |
c5c77ba1 JK |
3264 | strWID.enuWIDtype = WID_CHAR; |
3265 | strWID.ps8WidVal = &gs8Rssi; | |
576917ad | 3266 | strWID.s32ValueSize = sizeof(char); |
c5c77ba1 JK |
3267 | |
3268 | /*Sending Cfg*/ | |
3269 | PRINT_D(HOSTINF_DBG, "Getting RSSI value\n"); | |
3270 | ||
d42ab083 JK |
3271 | s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, |
3272 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 JK |
3273 | if (s32Error) { |
3274 | PRINT_ER("Failed to get RSSI value\n"); | |
24db713f | 3275 | s32Error = -EFAULT; |
c5c77ba1 JK |
3276 | } |
3277 | ||
83383ea3 | 3278 | up(&(pstrWFIDrv->hSemGetRSSI)); |
c5c77ba1 JK |
3279 | |
3280 | ||
3281 | } | |
3282 | ||
3283 | ||
2b05df55 | 3284 | static void Handle_GetLinkspeed(tstrWILC_WFIDrv *drvHandler) |
c5c77ba1 | 3285 | { |
e6e12661 | 3286 | s32 s32Error = 0; |
c5c77ba1 JK |
3287 | tstrWID strWID; |
3288 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; | |
3289 | ||
3290 | gs8lnkspd = 0; | |
3291 | ||
d85f5326 | 3292 | strWID.u16WIDid = (u16)WID_LINKSPEED; |
c5c77ba1 JK |
3293 | strWID.enuWIDtype = WID_CHAR; |
3294 | strWID.ps8WidVal = &gs8lnkspd; | |
576917ad | 3295 | strWID.s32ValueSize = sizeof(char); |
c5c77ba1 JK |
3296 | /*Sending Cfg*/ |
3297 | PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n"); | |
3298 | ||
d42ab083 JK |
3299 | s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, |
3300 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 JK |
3301 | if (s32Error) { |
3302 | PRINT_ER("Failed to get LINKSPEED value\n"); | |
24db713f | 3303 | s32Error = -EFAULT; |
c5c77ba1 JK |
3304 | } |
3305 | ||
83383ea3 | 3306 | up(&(pstrWFIDrv->hSemGetLINKSPEED)); |
c5c77ba1 JK |
3307 | |
3308 | ||
3309 | } | |
3310 | ||
2b05df55 | 3311 | s32 Handle_GetStatistics(tstrWILC_WFIDrv *drvHandler, tstrStatistics *pstrStatistics) |
c5c77ba1 JK |
3312 | { |
3313 | tstrWID strWIDList[5]; | |
fbc2fe16 | 3314 | u32 u32WidsCount = 0, s32Error = 0; |
c5c77ba1 JK |
3315 | |
3316 | strWIDList[u32WidsCount].u16WIDid = WID_LINKSPEED; | |
3317 | strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; | |
576917ad | 3318 | strWIDList[u32WidsCount].s32ValueSize = sizeof(char); |
ca356ada | 3319 | strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u8LinkSpeed)); |
c5c77ba1 JK |
3320 | u32WidsCount++; |
3321 | ||
3322 | strWIDList[u32WidsCount].u16WIDid = WID_RSSI; | |
3323 | strWIDList[u32WidsCount].enuWIDtype = WID_CHAR; | |
576917ad | 3324 | strWIDList[u32WidsCount].s32ValueSize = sizeof(char); |
ca356ada | 3325 | strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->s8RSSI)); |
c5c77ba1 JK |
3326 | u32WidsCount++; |
3327 | ||
3328 | strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT; | |
3329 | strWIDList[u32WidsCount].enuWIDtype = WID_INT; | |
4e4467fd | 3330 | strWIDList[u32WidsCount].s32ValueSize = sizeof(u32); |
ca356ada | 3331 | strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxCount)); |
c5c77ba1 JK |
3332 | u32WidsCount++; |
3333 | ||
3334 | strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT; | |
3335 | strWIDList[u32WidsCount].enuWIDtype = WID_INT; | |
4e4467fd | 3336 | strWIDList[u32WidsCount].s32ValueSize = sizeof(u32); |
ca356ada | 3337 | strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32RxCount)); |
c5c77ba1 JK |
3338 | u32WidsCount++; |
3339 | ||
3340 | strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT; | |
3341 | strWIDList[u32WidsCount].enuWIDtype = WID_INT; | |
4e4467fd | 3342 | strWIDList[u32WidsCount].s32ValueSize = sizeof(u32); |
ca356ada | 3343 | strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxFailureCount)); |
c5c77ba1 JK |
3344 | u32WidsCount++; |
3345 | ||
d42ab083 JK |
3346 | s32Error = SendConfigPkt(GET_CFG, strWIDList, u32WidsCount, false, |
3347 | get_id_from_handler(drvHandler)); | |
c5c77ba1 | 3348 | |
24db713f | 3349 | if (s32Error) |
c5c77ba1 | 3350 | PRINT_ER("Failed to send scan paramters config packet\n"); |
24db713f | 3351 | |
83383ea3 | 3352 | up(&hWaitResponse); |
c5c77ba1 JK |
3353 | return 0; |
3354 | ||
3355 | } | |
3356 | ||
c5c77ba1 JK |
3357 | /** |
3358 | * @brief Handle_Get_InActiveTime | |
3359 | * @details Sending config packet to set mac adddress for station and | |
3360 | * get inactive time | |
3361 | * @param[in] NONE | |
3362 | * @return NONE | |
3363 | * | |
3364 | * @author | |
3365 | * @date | |
3366 | * @version 1.0 | |
3367 | */ | |
3d1eac04 TC |
3368 | static s32 Handle_Get_InActiveTime(tstrWILC_WFIDrv *drvHandler, |
3369 | struct sta_inactive_t *strHostIfStaInactiveT) | |
c5c77ba1 JK |
3370 | { |
3371 | ||
e6e12661 | 3372 | s32 s32Error = 0; |
63d03e47 | 3373 | u8 *stamac; |
c5c77ba1 JK |
3374 | tstrWID strWID; |
3375 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; | |
3376 | ||
3377 | ||
d85f5326 | 3378 | strWID.u16WIDid = (u16)WID_SET_STA_MAC_INACTIVE_TIME; |
c5c77ba1 JK |
3379 | strWID.enuWIDtype = WID_STR; |
3380 | strWID.s32ValueSize = ETH_ALEN; | |
f3052587 | 3381 | strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL); |
c5c77ba1 JK |
3382 | |
3383 | ||
3384 | stamac = strWID.ps8WidVal; | |
d00d2ba3 | 3385 | memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN); |
c5c77ba1 JK |
3386 | |
3387 | ||
3388 | PRINT_D(CFG80211_DBG, "SETING STA inactive time\n"); | |
3389 | ||
3390 | ||
d42ab083 JK |
3391 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
3392 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 JK |
3393 | /*get the value by searching the local copy*/ |
3394 | if (s32Error) { | |
3395 | PRINT_ER("Failed to SET incative time\n"); | |
24db713f | 3396 | return -EFAULT; |
c5c77ba1 JK |
3397 | } |
3398 | ||
3399 | ||
d85f5326 | 3400 | strWID.u16WIDid = (u16)WID_GET_INACTIVE_TIME; |
c5c77ba1 | 3401 | strWID.enuWIDtype = WID_INT; |
ca356ada | 3402 | strWID.ps8WidVal = (s8 *)&gu32InactiveTime; |
4e4467fd | 3403 | strWID.s32ValueSize = sizeof(u32); |
c5c77ba1 JK |
3404 | |
3405 | ||
d42ab083 JK |
3406 | s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, |
3407 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 JK |
3408 | /*get the value by searching the local copy*/ |
3409 | if (s32Error) { | |
3410 | PRINT_ER("Failed to get incative time\n"); | |
24db713f | 3411 | return -EFAULT; |
c5c77ba1 JK |
3412 | } |
3413 | ||
3414 | ||
3415 | PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime); | |
3416 | ||
83383ea3 | 3417 | up(&(pstrWFIDrv->hSemInactiveTime)); |
c5c77ba1 JK |
3418 | |
3419 | return s32Error; | |
3420 | ||
3421 | ||
3422 | ||
3423 | } | |
3424 | ||
3425 | ||
3426 | /** | |
3427 | * @brief Handle_AddBeacon | |
3428 | * @details Sending config packet to add beacon | |
902362b1 | 3429 | * @param[in] struct set_beacon *pstrSetBeaconParam |
c5c77ba1 JK |
3430 | * @return NONE |
3431 | * @author | |
3432 | * @date | |
3433 | * @version 1.0 | |
3434 | */ | |
902362b1 TC |
3435 | static void Handle_AddBeacon(tstrWILC_WFIDrv *drvHandler, |
3436 | struct set_beacon *pstrSetBeaconParam) | |
c5c77ba1 | 3437 | { |
e6e12661 | 3438 | s32 s32Error = 0; |
c5c77ba1 | 3439 | tstrWID strWID; |
63d03e47 | 3440 | u8 *pu8CurrByte; |
c5c77ba1 | 3441 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; |
78c87591 | 3442 | |
c5c77ba1 JK |
3443 | PRINT_D(HOSTINF_DBG, "Adding BEACON\n"); |
3444 | ||
d85f5326 | 3445 | strWID.u16WIDid = (u16)WID_ADD_BEACON; |
c5c77ba1 JK |
3446 | strWID.enuWIDtype = WID_BIN; |
3447 | strWID.s32ValueSize = pstrSetBeaconParam->u32HeadLen + pstrSetBeaconParam->u32TailLen + 16; | |
f3052587 | 3448 | strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL); |
2b9d5b48 | 3449 | if (strWID.ps8WidVal == NULL) |
24db713f | 3450 | goto ERRORHANDLER; |
c5c77ba1 JK |
3451 | |
3452 | pu8CurrByte = strWID.ps8WidVal; | |
3453 | *pu8CurrByte++ = (pstrSetBeaconParam->u32Interval & 0xFF); | |
3454 | *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 8) & 0xFF); | |
3455 | *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 16) & 0xFF); | |
3456 | *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 24) & 0xFF); | |
3457 | ||
3458 | *pu8CurrByte++ = (pstrSetBeaconParam->u32DTIMPeriod & 0xFF); | |
3459 | *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 8) & 0xFF); | |
3460 | *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 16) & 0xFF); | |
3461 | *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 24) & 0xFF); | |
3462 | ||
3463 | *pu8CurrByte++ = (pstrSetBeaconParam->u32HeadLen & 0xFF); | |
3464 | *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 8) & 0xFF); | |
3465 | *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 16) & 0xFF); | |
3466 | *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 24) & 0xFF); | |
3467 | ||
3468 | memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Head, pstrSetBeaconParam->u32HeadLen); | |
3469 | pu8CurrByte += pstrSetBeaconParam->u32HeadLen; | |
3470 | ||
3471 | *pu8CurrByte++ = (pstrSetBeaconParam->u32TailLen & 0xFF); | |
3472 | *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 8) & 0xFF); | |
3473 | *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 16) & 0xFF); | |
3474 | *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 24) & 0xFF); | |
3475 | ||
c5c77ba1 JK |
3476 | if (pstrSetBeaconParam->pu8Tail > 0) |
3477 | memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Tail, pstrSetBeaconParam->u32TailLen); | |
3478 | pu8CurrByte += pstrSetBeaconParam->u32TailLen; | |
3479 | ||
3480 | ||
3481 | ||
3482 | /*Sending Cfg*/ | |
d42ab083 JK |
3483 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, |
3484 | get_id_from_handler(pstrWFIDrv)); | |
24db713f | 3485 | if (s32Error) |
c5c77ba1 | 3486 | PRINT_ER("Failed to send add beacon config packet\n"); |
c5c77ba1 | 3487 | |
24db713f | 3488 | ERRORHANDLER: |
969effe9 GKH |
3489 | kfree(strWID.ps8WidVal); |
3490 | kfree(pstrSetBeaconParam->pu8Head); | |
3491 | kfree(pstrSetBeaconParam->pu8Tail); | |
c5c77ba1 JK |
3492 | } |
3493 | ||
3494 | ||
3495 | /** | |
3496 | * @brief Handle_AddBeacon | |
3497 | * @details Sending config packet to delete beacon | |
d0227fcb | 3498 | * @param[in] struct del_beacon *pstrDelBeacon |
c5c77ba1 JK |
3499 | * @return NONE |
3500 | * @author | |
3501 | * @date | |
3502 | * @version 1.0 | |
3503 | */ | |
d0227fcb TC |
3504 | static void Handle_DelBeacon(tstrWILC_WFIDrv *drvHandler, |
3505 | struct del_beacon *pstrDelBeacon) | |
c5c77ba1 | 3506 | { |
e6e12661 | 3507 | s32 s32Error = 0; |
c5c77ba1 | 3508 | tstrWID strWID; |
63d03e47 | 3509 | u8 *pu8CurrByte; |
c5c77ba1 | 3510 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; |
78c87591 | 3511 | |
d85f5326 | 3512 | strWID.u16WIDid = (u16)WID_DEL_BEACON; |
c5c77ba1 | 3513 | strWID.enuWIDtype = WID_CHAR; |
576917ad | 3514 | strWID.s32ValueSize = sizeof(char); |
c5c77ba1 JK |
3515 | strWID.ps8WidVal = &gu8DelBcn; |
3516 | ||
2b9d5b48 | 3517 | if (strWID.ps8WidVal == NULL) |
24db713f | 3518 | return; |
c5c77ba1 JK |
3519 | |
3520 | pu8CurrByte = strWID.ps8WidVal; | |
3521 | ||
3522 | PRINT_D(HOSTINF_DBG, "Deleting BEACON\n"); | |
3523 | /* TODO: build del beacon message*/ | |
3524 | ||
3525 | /*Sending Cfg*/ | |
d42ab083 JK |
3526 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, |
3527 | get_id_from_handler(pstrWFIDrv)); | |
24db713f | 3528 | if (s32Error) |
c5c77ba1 | 3529 | PRINT_ER("Failed to send delete beacon config packet\n"); |
c5c77ba1 JK |
3530 | } |
3531 | ||
3532 | ||
3533 | /** | |
3534 | * @brief WILC_HostIf_PackStaParam | |
3535 | * @details Handling packing of the station params in a buffer | |
6a89ba9c | 3536 | * @param[in] u8* pu8Buffer, struct add_sta_param *pstrStationParam |
c5c77ba1 JK |
3537 | * @return NONE |
3538 | * @author | |
3539 | * @date | |
3540 | * @version 1.0 | |
3541 | */ | |
6a89ba9c TC |
3542 | static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer, |
3543 | struct add_sta_param *pstrStationParam) | |
c5c77ba1 | 3544 | { |
63d03e47 | 3545 | u8 *pu8CurrByte; |
c5c77ba1 JK |
3546 | |
3547 | pu8CurrByte = pu8Buffer; | |
3548 | ||
3549 | PRINT_D(HOSTINF_DBG, "Packing STA params\n"); | |
d00d2ba3 | 3550 | memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN); |
c5c77ba1 JK |
3551 | pu8CurrByte += ETH_ALEN; |
3552 | ||
3553 | *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF; | |
3554 | *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF; | |
3555 | ||
3556 | *pu8CurrByte++ = pstrStationParam->u8NumRates; | |
2b9d5b48 | 3557 | if (pstrStationParam->u8NumRates > 0) |
d00d2ba3 | 3558 | memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates); |
c5c77ba1 JK |
3559 | pu8CurrByte += pstrStationParam->u8NumRates; |
3560 | ||
3561 | *pu8CurrByte++ = pstrStationParam->bIsHTSupported; | |
3562 | *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF; | |
3563 | *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF; | |
3564 | ||
3565 | *pu8CurrByte++ = pstrStationParam->u8AmpduParams; | |
d00d2ba3 | 3566 | memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE); |
c5c77ba1 JK |
3567 | pu8CurrByte += WILC_SUPP_MCS_SET_SIZE; |
3568 | ||
3569 | *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF; | |
3570 | *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF; | |
3571 | ||
3572 | *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF; | |
3573 | *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF; | |
3574 | *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF; | |
3575 | *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF; | |
3576 | ||
3577 | *pu8CurrByte++ = pstrStationParam->u8ASELCap; | |
3578 | ||
3579 | *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF; | |
3580 | *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF; | |
3581 | ||
3582 | *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF; | |
3583 | *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF; | |
3584 | ||
3585 | return pu8CurrByte - pu8Buffer; | |
3586 | } | |
3587 | ||
3588 | /** | |
3589 | * @brief Handle_AddStation | |
3590 | * @details Sending config packet to add station | |
6a89ba9c | 3591 | * @param[in] struct add_sta_param *pstrStationParam |
c5c77ba1 JK |
3592 | * @return NONE |
3593 | * @author | |
3594 | * @date | |
3595 | * @version 1.0 | |
3596 | */ | |
6a89ba9c TC |
3597 | static void Handle_AddStation(tstrWILC_WFIDrv *drvHandler, |
3598 | struct add_sta_param *pstrStationParam) | |
c5c77ba1 | 3599 | { |
e6e12661 | 3600 | s32 s32Error = 0; |
c5c77ba1 | 3601 | tstrWID strWID; |
63d03e47 | 3602 | u8 *pu8CurrByte; |
c5c77ba1 | 3603 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; |
78c87591 | 3604 | |
c5c77ba1 | 3605 | PRINT_D(HOSTINF_DBG, "Handling add station\n"); |
d85f5326 | 3606 | strWID.u16WIDid = (u16)WID_ADD_STA; |
c5c77ba1 JK |
3607 | strWID.enuWIDtype = WID_BIN; |
3608 | strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates; | |
3609 | ||
f3052587 | 3610 | strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL); |
2b9d5b48 | 3611 | if (strWID.ps8WidVal == NULL) |
24db713f | 3612 | goto ERRORHANDLER; |
c5c77ba1 JK |
3613 | |
3614 | pu8CurrByte = strWID.ps8WidVal; | |
3615 | pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam); | |
3616 | ||
3617 | /*Sending Cfg*/ | |
d42ab083 JK |
3618 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, |
3619 | get_id_from_handler(pstrWFIDrv)); | |
e6e12661 | 3620 | if (s32Error != 0) |
c5c77ba1 | 3621 | PRINT_ER("Failed to send add station config packet\n"); |
c5c77ba1 | 3622 | |
24db713f | 3623 | ERRORHANDLER: |
969effe9 GKH |
3624 | kfree(pstrStationParam->pu8Rates); |
3625 | kfree(strWID.ps8WidVal); | |
c5c77ba1 JK |
3626 | } |
3627 | ||
3628 | /** | |
3629 | * @brief Handle_DelAllSta | |
3630 | * @details Sending config packet to delete station | |
3631 | * @param[in] tstrHostIFDelSta* pstrDelStaParam | |
3632 | * @return NONE | |
3633 | * @author | |
3634 | * @date | |
3635 | * @version 1.0 | |
3636 | */ | |
b4e644e4 TC |
3637 | static void Handle_DelAllSta(tstrWILC_WFIDrv *drvHandler, |
3638 | struct del_all_sta *pstrDelAllStaParam) | |
c5c77ba1 | 3639 | { |
e6e12661 | 3640 | s32 s32Error = 0; |
78c87591 | 3641 | |
c5c77ba1 | 3642 | tstrWID strWID; |
63d03e47 | 3643 | u8 *pu8CurrByte; |
c5c77ba1 | 3644 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; |
63d03e47 | 3645 | u8 i; |
3703480b | 3646 | u8 au8Zero_Buff[6] = {0}; |
78c87591 | 3647 | |
d85f5326 | 3648 | strWID.u16WIDid = (u16)WID_DEL_ALL_STA; |
c5c77ba1 JK |
3649 | strWID.enuWIDtype = WID_STR; |
3650 | strWID.s32ValueSize = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1; | |
3651 | ||
03b2d5e7 | 3652 | PRINT_D(HOSTINF_DBG, "Handling delete station\n"); |
c5c77ba1 | 3653 | |
f3052587 | 3654 | strWID.ps8WidVal = kmalloc((pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1, GFP_KERNEL); |
2b9d5b48 | 3655 | if (strWID.ps8WidVal == NULL) |
24db713f | 3656 | goto ERRORHANDLER; |
c5c77ba1 JK |
3657 | |
3658 | pu8CurrByte = strWID.ps8WidVal; | |
3659 | ||
3660 | *(pu8CurrByte++) = pstrDelAllStaParam->u8Num_AssocSta; | |
3661 | ||
3662 | for (i = 0; i < MAX_NUM_STA; i++) { | |
3663 | if (memcmp(pstrDelAllStaParam->au8Sta_DelAllSta[i], au8Zero_Buff, ETH_ALEN)) | |
d00d2ba3 | 3664 | memcpy(pu8CurrByte, pstrDelAllStaParam->au8Sta_DelAllSta[i], ETH_ALEN); |
c5c77ba1 JK |
3665 | else |
3666 | continue; | |
3667 | ||
3668 | pu8CurrByte += ETH_ALEN; | |
3669 | } | |
3670 | ||
3671 | /*Sending Cfg*/ | |
d42ab083 JK |
3672 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
3673 | get_id_from_handler(pstrWFIDrv)); | |
24db713f | 3674 | if (s32Error) |
83cc9be5 | 3675 | PRINT_ER("Failed to send add station config packet\n"); |
c5c77ba1 | 3676 | |
24db713f | 3677 | ERRORHANDLER: |
969effe9 | 3678 | kfree(strWID.ps8WidVal); |
c5c77ba1 | 3679 | |
83383ea3 | 3680 | up(&hWaitResponse); |
c5c77ba1 JK |
3681 | } |
3682 | ||
3683 | ||
3684 | /** | |
3685 | * @brief Handle_DelStation | |
3686 | * @details Sending config packet to delete station | |
fb93a1e1 | 3687 | * @param[in] struct del_sta *pstrDelStaParam |
c5c77ba1 JK |
3688 | * @return NONE |
3689 | * @author | |
3690 | * @date | |
3691 | * @version 1.0 | |
3692 | */ | |
fb93a1e1 TC |
3693 | static void Handle_DelStation(tstrWILC_WFIDrv *drvHandler, |
3694 | struct del_sta *pstrDelStaParam) | |
c5c77ba1 | 3695 | { |
e6e12661 | 3696 | s32 s32Error = 0; |
c5c77ba1 | 3697 | tstrWID strWID; |
63d03e47 | 3698 | u8 *pu8CurrByte; |
c5c77ba1 JK |
3699 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; |
3700 | ||
d85f5326 | 3701 | strWID.u16WIDid = (u16)WID_REMOVE_STA; |
c5c77ba1 JK |
3702 | strWID.enuWIDtype = WID_BIN; |
3703 | strWID.s32ValueSize = ETH_ALEN; | |
3704 | ||
03b2d5e7 | 3705 | PRINT_D(HOSTINF_DBG, "Handling delete station\n"); |
c5c77ba1 | 3706 | |
f3052587 | 3707 | strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL); |
2b9d5b48 | 3708 | if (strWID.ps8WidVal == NULL) |
24db713f | 3709 | goto ERRORHANDLER; |
c5c77ba1 JK |
3710 | |
3711 | pu8CurrByte = strWID.ps8WidVal; | |
3712 | ||
d00d2ba3 | 3713 | memcpy(pu8CurrByte, pstrDelStaParam->au8MacAddr, ETH_ALEN); |
c5c77ba1 JK |
3714 | |
3715 | /*Sending Cfg*/ | |
d42ab083 JK |
3716 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, |
3717 | get_id_from_handler(pstrWFIDrv)); | |
24db713f | 3718 | if (s32Error) |
83cc9be5 | 3719 | PRINT_ER("Failed to send add station config packet\n"); |
c5c77ba1 | 3720 | |
24db713f | 3721 | ERRORHANDLER: |
969effe9 | 3722 | kfree(strWID.ps8WidVal); |
c5c77ba1 JK |
3723 | } |
3724 | ||
3725 | ||
3726 | /** | |
3727 | * @brief Handle_EditStation | |
3728 | * @details Sending config packet to edit station | |
6a89ba9c | 3729 | * @param[in] struct add_sta_param *pstrStationParam |
c5c77ba1 JK |
3730 | * @return NONE |
3731 | * @author | |
3732 | * @date | |
3733 | * @version 1.0 | |
3734 | */ | |
6a89ba9c TC |
3735 | static void Handle_EditStation(tstrWILC_WFIDrv *drvHandler, |
3736 | struct add_sta_param *pstrStationParam) | |
c5c77ba1 | 3737 | { |
e6e12661 | 3738 | s32 s32Error = 0; |
c5c77ba1 | 3739 | tstrWID strWID; |
63d03e47 | 3740 | u8 *pu8CurrByte; |
c5c77ba1 JK |
3741 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; |
3742 | ||
d85f5326 | 3743 | strWID.u16WIDid = (u16)WID_EDIT_STA; |
c5c77ba1 JK |
3744 | strWID.enuWIDtype = WID_BIN; |
3745 | strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates; | |
3746 | ||
3747 | PRINT_D(HOSTINF_DBG, "Handling edit station\n"); | |
f3052587 | 3748 | strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL); |
2b9d5b48 | 3749 | if (strWID.ps8WidVal == NULL) |
24db713f | 3750 | goto ERRORHANDLER; |
c5c77ba1 JK |
3751 | |
3752 | pu8CurrByte = strWID.ps8WidVal; | |
3753 | pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam); | |
3754 | ||
3755 | /*Sending Cfg*/ | |
d42ab083 JK |
3756 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, |
3757 | get_id_from_handler(pstrWFIDrv)); | |
24db713f | 3758 | if (s32Error) |
c5c77ba1 | 3759 | PRINT_ER("Failed to send edit station config packet\n"); |
c5c77ba1 | 3760 | |
24db713f | 3761 | ERRORHANDLER: |
969effe9 GKH |
3762 | kfree(pstrStationParam->pu8Rates); |
3763 | kfree(strWID.ps8WidVal); | |
c5c77ba1 | 3764 | } |
c5c77ba1 | 3765 | |
c5c77ba1 JK |
3766 | /** |
3767 | * @brief Handle_RemainOnChan | |
3768 | * @details Sending config packet to edit station | |
3769 | * @param[in] tstrWILC_AddStaParam* pstrStationParam | |
3770 | * @return NONE | |
3771 | * @author | |
3772 | * @date | |
3773 | * @version 1.0 | |
3774 | */ | |
2f9c03f5 TC |
3775 | static int Handle_RemainOnChan(tstrWILC_WFIDrv *drvHandler, |
3776 | struct remain_ch *pstrHostIfRemainOnChan) | |
c5c77ba1 | 3777 | { |
e6e12661 | 3778 | s32 s32Error = 0; |
63d03e47 | 3779 | u8 u8remain_on_chan_flag; |
c5c77ba1 JK |
3780 | tstrWID strWID; |
3781 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler; | |
3782 | ||
3783 | /*If it's a pendig remain-on-channel, don't overwrite gWFiDrvHandle values (since incoming msg is garbbage)*/ | |
3784 | if (!pstrWFIDrv->u8RemainOnChan_pendingreq) { | |
3785 | pstrWFIDrv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid; | |
3786 | pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired; | |
3787 | pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady; | |
3788 | pstrWFIDrv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel; | |
3789 | pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID; | |
3790 | } else { | |
3791 | /*Set the channel to use it as a wid val*/ | |
3792 | pstrHostIfRemainOnChan->u16Channel = pstrWFIDrv->strHostIfRemainOnChan.u16Channel; | |
3793 | } | |
3794 | ||
3795 | if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) { | |
3796 | PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n"); | |
3797 | pstrWFIDrv->u8RemainOnChan_pendingreq = 1; | |
24db713f LK |
3798 | s32Error = -EBUSY; |
3799 | goto ERRORHANDLER; | |
c5c77ba1 JK |
3800 | } |
3801 | if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) { | |
3802 | PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n"); | |
24db713f LK |
3803 | s32Error = -EBUSY; |
3804 | goto ERRORHANDLER; | |
c5c77ba1 JK |
3805 | } |
3806 | ||
3807 | #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP | |
3808 | if (g_obtainingIP || connecting) { | |
3809 | PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n"); | |
24db713f LK |
3810 | s32Error = -EBUSY; |
3811 | goto ERRORHANDLER; | |
c5c77ba1 JK |
3812 | } |
3813 | #endif | |
3814 | ||
3815 | PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel); | |
3816 | ||
72ed4dc7 | 3817 | u8remain_on_chan_flag = true; |
d85f5326 | 3818 | strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN; |
c5c77ba1 JK |
3819 | strWID.enuWIDtype = WID_STR; |
3820 | strWID.s32ValueSize = 2; | |
f3052587 | 3821 | strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL); |
c5c77ba1 | 3822 | |
24db713f LK |
3823 | if (strWID.ps8WidVal == NULL) { |
3824 | s32Error = -ENOMEM; | |
3825 | goto ERRORHANDLER; | |
3826 | } | |
c5c77ba1 JK |
3827 | |
3828 | strWID.ps8WidVal[0] = u8remain_on_chan_flag; | |
ca356ada | 3829 | strWID.ps8WidVal[1] = (s8)pstrHostIfRemainOnChan->u16Channel; |
c5c77ba1 JK |
3830 | |
3831 | /*Sending Cfg*/ | |
d42ab083 JK |
3832 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
3833 | get_id_from_handler(pstrWFIDrv)); | |
e6e12661 | 3834 | if (s32Error != 0) |
c5c77ba1 | 3835 | PRINT_ER("Failed to set remain on channel\n"); |
c5c77ba1 | 3836 | |
24db713f | 3837 | ERRORHANDLER: |
c5c77ba1 JK |
3838 | { |
3839 | P2P_LISTEN_STATE = 1; | |
9eb06643 GKH |
3840 | pstrWFIDrv->hRemainOnChannel.data = (unsigned long)pstrWFIDrv; |
3841 | mod_timer(&pstrWFIDrv->hRemainOnChannel, | |
3842 | jiffies + | |
3843 | msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration)); | |
c5c77ba1 JK |
3844 | |
3845 | /*Calling CFG ready_on_channel*/ | |
2b9d5b48 | 3846 | if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady) |
c5c77ba1 | 3847 | pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady(pstrWFIDrv->strHostIfRemainOnChan.pVoid); |
c5c77ba1 JK |
3848 | |
3849 | if (pstrWFIDrv->u8RemainOnChan_pendingreq) | |
3850 | pstrWFIDrv->u8RemainOnChan_pendingreq = 0; | |
3851 | } | |
3852 | return s32Error; | |
3853 | } | |
3854 | ||
3855 | /** | |
3856 | * @brief Handle_RegisterFrame | |
3857 | * @details | |
3858 | * @param[in] | |
3859 | * @return NONE | |
3860 | * @author | |
3861 | * @date | |
3862 | * @version 1.0 | |
3863 | */ | |
bc37c5df TC |
3864 | static int Handle_RegisterFrame(tstrWILC_WFIDrv *drvHandler, |
3865 | struct reg_frame *pstrHostIfRegisterFrame) | |
c5c77ba1 | 3866 | { |
e6e12661 | 3867 | s32 s32Error = 0; |
c5c77ba1 | 3868 | tstrWID strWID; |
63d03e47 | 3869 | u8 *pu8CurrByte; |
c5c77ba1 JK |
3870 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; |
3871 | ||
3872 | PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType); | |
3873 | ||
3874 | /*prepare configuration packet*/ | |
d85f5326 | 3875 | strWID.u16WIDid = (u16)WID_REGISTER_FRAME; |
c5c77ba1 | 3876 | strWID.enuWIDtype = WID_STR; |
f3052587 | 3877 | strWID.ps8WidVal = kmalloc(sizeof(u16) + 2, GFP_KERNEL); |
2b9d5b48 | 3878 | if (strWID.ps8WidVal == NULL) |
24db713f | 3879 | return -ENOMEM; |
c5c77ba1 JK |
3880 | |
3881 | pu8CurrByte = strWID.ps8WidVal; | |
3882 | ||
3883 | *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg; | |
3884 | *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid; | |
d00d2ba3 | 3885 | memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16)); |
c5c77ba1 JK |
3886 | |
3887 | ||
d85f5326 | 3888 | strWID.s32ValueSize = sizeof(u16) + 2; |
c5c77ba1 JK |
3889 | |
3890 | ||
3891 | /*Sending Cfg*/ | |
d42ab083 JK |
3892 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
3893 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 JK |
3894 | if (s32Error) { |
3895 | PRINT_ER("Failed to frame register config packet\n"); | |
24db713f | 3896 | s32Error = -EINVAL; |
c5c77ba1 JK |
3897 | } |
3898 | ||
3899 | return s32Error; | |
3900 | ||
3901 | } | |
3902 | ||
3903 | /** | |
3904 | * @brief Handle_ListenStateExpired | |
3905 | * @details Handle of listen state expiration | |
3906 | * @param[in] NONE | |
3907 | * @return Error code. | |
3908 | * @author | |
3909 | * @date | |
3910 | * @version 1.0 | |
3911 | */ | |
3912 | #define FALSE_FRMWR_CHANNEL 100 | |
2f9c03f5 TC |
3913 | static u32 Handle_ListenStateExpired(tstrWILC_WFIDrv *drvHandler, |
3914 | struct remain_ch *pstrHostIfRemainOnChan) | |
c5c77ba1 | 3915 | { |
63d03e47 | 3916 | u8 u8remain_on_chan_flag; |
c5c77ba1 | 3917 | tstrWID strWID; |
e6e12661 | 3918 | s32 s32Error = 0; |
c5c77ba1 JK |
3919 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler; |
3920 | ||
3921 | PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n"); | |
3922 | ||
c5c77ba1 JK |
3923 | /*Make sure we are already in listen state*/ |
3924 | /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/ | |
3925 | if (P2P_LISTEN_STATE) { | |
72ed4dc7 | 3926 | u8remain_on_chan_flag = false; |
d85f5326 | 3927 | strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN; |
c5c77ba1 JK |
3928 | strWID.enuWIDtype = WID_STR; |
3929 | strWID.s32ValueSize = 2; | |
f3052587 | 3930 | strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL); |
c5c77ba1 | 3931 | |
2b9d5b48 | 3932 | if (strWID.ps8WidVal == NULL) |
c5c77ba1 | 3933 | PRINT_ER("Failed to allocate memory\n"); |
c5c77ba1 JK |
3934 | |
3935 | strWID.ps8WidVal[0] = u8remain_on_chan_flag; | |
3936 | strWID.ps8WidVal[1] = FALSE_FRMWR_CHANNEL; | |
3937 | ||
3938 | /*Sending Cfg*/ | |
d42ab083 JK |
3939 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
3940 | get_id_from_handler(pstrWFIDrv)); | |
e6e12661 | 3941 | if (s32Error != 0) { |
c5c77ba1 JK |
3942 | PRINT_ER("Failed to set remain on channel\n"); |
3943 | goto _done_; | |
3944 | } | |
3945 | ||
3946 | if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired) { | |
3947 | pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired(pstrWFIDrv->strHostIfRemainOnChan.pVoid | |
3948 | , pstrHostIfRemainOnChan->u32ListenSessionID); | |
3949 | } | |
3950 | P2P_LISTEN_STATE = 0; | |
3951 | } else { | |
3952 | PRINT_D(GENERIC_DBG, "Not in listen state\n"); | |
e6e12661 | 3953 | s32Error = -EFAULT; |
c5c77ba1 JK |
3954 | } |
3955 | ||
3956 | _done_: | |
3957 | return s32Error; | |
3958 | } | |
3959 | ||
3960 | ||
3961 | /** | |
3962 | * @brief ListenTimerCB | |
3963 | * @details Callback function of remain-on-channel timer | |
3964 | * @param[in] NONE | |
3965 | * @return Error code. | |
3966 | * @author | |
3967 | * @date | |
3968 | * @version 1.0 | |
3969 | */ | |
93dee8ee | 3970 | static void ListenTimerCB(unsigned long arg) |
c5c77ba1 | 3971 | { |
e6e12661 | 3972 | s32 s32Error = 0; |
143eb95a | 3973 | struct host_if_msg msg; |
93dee8ee | 3974 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)arg; |
c5c77ba1 | 3975 | /*Stopping remain-on-channel timer*/ |
8972d0fe | 3976 | del_timer(&pstrWFIDrv->hRemainOnChannel); |
c5c77ba1 JK |
3977 | |
3978 | /* prepare the Timer Callback message */ | |
143eb95a | 3979 | memset(&msg, 0, sizeof(struct host_if_msg)); |
a9f812a6 | 3980 | msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED; |
143eb95a | 3981 | msg.drvHandler = pstrWFIDrv; |
410c2489 | 3982 | msg.body.strHostIfRemainOnChan.u32ListenSessionID = pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID; |
c5c77ba1 JK |
3983 | |
3984 | /* send the message */ | |
143eb95a | 3985 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
2b9d5b48 | 3986 | if (s32Error) |
24db713f | 3987 | PRINT_ER("wilc_mq_send fail\n"); |
c5c77ba1 | 3988 | } |
c5c77ba1 JK |
3989 | |
3990 | /** | |
3991 | * @brief Handle_EditStation | |
3992 | * @details Sending config packet to edit station | |
3993 | * @param[in] tstrWILC_AddStaParam* pstrStationParam | |
3994 | * @return NONE | |
3995 | * @author | |
3996 | * @date | |
3997 | * @version 1.0 | |
3998 | */ | |
5a008f1c TC |
3999 | static void Handle_PowerManagement(tstrWILC_WFIDrv *drvHandler, |
4000 | struct power_mgmt_param *strPowerMgmtParam) | |
c5c77ba1 | 4001 | { |
e6e12661 | 4002 | s32 s32Error = 0; |
c5c77ba1 | 4003 | tstrWID strWID; |
ca356ada | 4004 | s8 s8PowerMode; |
c5c77ba1 | 4005 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; |
78c87591 | 4006 | |
d85f5326 | 4007 | strWID.u16WIDid = (u16)WID_POWER_MANAGEMENT; |
c5c77ba1 | 4008 | |
78174ada | 4009 | if (strPowerMgmtParam->bIsEnabled == true) |
c5c77ba1 | 4010 | s8PowerMode = MIN_FAST_PS; |
78174ada | 4011 | else |
c5c77ba1 | 4012 | s8PowerMode = NO_POWERSAVE; |
c5c77ba1 JK |
4013 | PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode); |
4014 | strWID.ps8WidVal = &s8PowerMode; | |
576917ad | 4015 | strWID.s32ValueSize = sizeof(char); |
c5c77ba1 JK |
4016 | |
4017 | PRINT_D(HOSTINF_DBG, "Handling Power Management\n"); | |
4018 | ||
4019 | /*Sending Cfg*/ | |
d42ab083 JK |
4020 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
4021 | get_id_from_handler(pstrWFIDrv)); | |
24db713f | 4022 | if (s32Error) |
c5c77ba1 | 4023 | PRINT_ER("Failed to send power management config packet\n"); |
c5c77ba1 JK |
4024 | } |
4025 | ||
4026 | /** | |
4027 | * @brief Handle_SetMulticastFilter | |
4028 | * @details Set Multicast filter in firmware | |
641210ac | 4029 | * @param[in] struct set_multicast *strHostIfSetMulti |
c5c77ba1 JK |
4030 | * @return NONE |
4031 | * @author asobhy | |
4032 | * @date | |
4033 | * @version 1.0 | |
4034 | */ | |
641210ac TC |
4035 | static void Handle_SetMulticastFilter(tstrWILC_WFIDrv *drvHandler, |
4036 | struct set_multicast *strHostIfSetMulti) | |
c5c77ba1 | 4037 | { |
e6e12661 | 4038 | s32 s32Error = 0; |
c5c77ba1 | 4039 | tstrWID strWID; |
63d03e47 | 4040 | u8 *pu8CurrByte; |
c5c77ba1 JK |
4041 | |
4042 | PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n"); | |
4043 | ||
d85f5326 | 4044 | strWID.u16WIDid = (u16)WID_SETUP_MULTICAST_FILTER; |
c5c77ba1 | 4045 | strWID.enuWIDtype = WID_BIN; |
641210ac | 4046 | strWID.s32ValueSize = sizeof(struct set_multicast) + ((strHostIfSetMulti->u32count) * ETH_ALEN); |
f3052587 | 4047 | strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL); |
2b9d5b48 | 4048 | if (strWID.ps8WidVal == NULL) |
24db713f | 4049 | goto ERRORHANDLER; |
c5c77ba1 JK |
4050 | |
4051 | pu8CurrByte = strWID.ps8WidVal; | |
4052 | *pu8CurrByte++ = (strHostIfSetMulti->bIsEnabled & 0xFF); | |
4053 | *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 8) & 0xFF); | |
4054 | *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 16) & 0xFF); | |
4055 | *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 24) & 0xFF); | |
4056 | ||
4057 | *pu8CurrByte++ = (strHostIfSetMulti->u32count & 0xFF); | |
4058 | *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 8) & 0xFF); | |
4059 | *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 16) & 0xFF); | |
4060 | *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 24) & 0xFF); | |
4061 | ||
4062 | if ((strHostIfSetMulti->u32count) > 0) | |
4063 | memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->u32count) * ETH_ALEN)); | |
4064 | ||
4065 | /*Sending Cfg*/ | |
d42ab083 JK |
4066 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, |
4067 | get_id_from_handler(drvHandler)); | |
24db713f | 4068 | if (s32Error) |
c5c77ba1 | 4069 | PRINT_ER("Failed to send setup multicast config packet\n"); |
c5c77ba1 | 4070 | |
24db713f | 4071 | ERRORHANDLER: |
969effe9 | 4072 | kfree(strWID.ps8WidVal); |
c5c77ba1 JK |
4073 | |
4074 | } | |
4075 | ||
4076 | ||
c5c77ba1 JK |
4077 | /** |
4078 | * @brief Handle_AddBASession | |
4079 | * @details Add block ack session | |
4080 | * @param[in] tstrHostIFSetMulti* strHostIfSetMulti | |
4081 | * @return NONE | |
4082 | * @author Amr Abdel-Moghny | |
4083 | * @date Feb. 2014 | |
4084 | * @version 9.0 | |
4085 | */ | |
54265472 TC |
4086 | static s32 Handle_AddBASession(tstrWILC_WFIDrv *drvHandler, |
4087 | struct ba_session_info *strHostIfBASessionInfo) | |
c5c77ba1 | 4088 | { |
e6e12661 | 4089 | s32 s32Error = 0; |
c5c77ba1 JK |
4090 | tstrWID strWID; |
4091 | int AddbaTimeout = 100; | |
4092 | char *ptr = NULL; | |
4093 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; | |
4094 | ||
03b2d5e7 | 4095 | PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\nBufferSize == %d\nSessionTimeOut = %d\n", |
c5c77ba1 JK |
4096 | strHostIfBASessionInfo->au8Bssid[0], |
4097 | strHostIfBASessionInfo->au8Bssid[1], | |
4098 | strHostIfBASessionInfo->au8Bssid[2], | |
4099 | strHostIfBASessionInfo->u16BufferSize, | |
4100 | strHostIfBASessionInfo->u16SessionTimeout, | |
4101 | strHostIfBASessionInfo->u8Ted); | |
4102 | ||
d85f5326 | 4103 | strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ; |
c5c77ba1 | 4104 | strWID.enuWIDtype = WID_STR; |
f3052587 | 4105 | strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL); |
c5c77ba1 JK |
4106 | strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE; |
4107 | ptr = strWID.ps8WidVal; | |
4108 | /* *ptr++ = 0x14; */ | |
4109 | *ptr++ = 0x14; | |
4110 | *ptr++ = 0x3; | |
4111 | *ptr++ = 0x0; | |
d00d2ba3 | 4112 | memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN); |
c5c77ba1 JK |
4113 | ptr += ETH_ALEN; |
4114 | *ptr++ = strHostIfBASessionInfo->u8Ted; | |
4115 | /* BA Policy*/ | |
4116 | *ptr++ = 1; | |
4117 | /* Buffer size*/ | |
4118 | *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF); | |
4119 | *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF); | |
4120 | /* BA timeout*/ | |
4121 | *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF); | |
4122 | *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF); | |
4123 | /* ADDBA timeout*/ | |
4124 | *ptr++ = (AddbaTimeout & 0xFF); | |
4125 | *ptr++ = ((AddbaTimeout >> 16) & 0xFF); | |
4126 | /* Group Buffer Max Frames*/ | |
4127 | *ptr++ = 8; | |
4128 | /* Group Buffer Timeout */ | |
4129 | *ptr++ = 0; | |
4130 | ||
d42ab083 JK |
4131 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
4132 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 JK |
4133 | if (s32Error) |
4134 | PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n"); | |
4135 | ||
4136 | ||
d85f5326 | 4137 | strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ; |
c5c77ba1 JK |
4138 | strWID.enuWIDtype = WID_STR; |
4139 | strWID.s32ValueSize = 15; | |
4140 | ptr = strWID.ps8WidVal; | |
4141 | /* *ptr++ = 0x14; */ | |
4142 | *ptr++ = 15; | |
4143 | *ptr++ = 7; | |
4144 | *ptr++ = 0x2; | |
d00d2ba3 | 4145 | memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN); |
c5c77ba1 JK |
4146 | ptr += ETH_ALEN; |
4147 | /* TID*/ | |
4148 | *ptr++ = strHostIfBASessionInfo->u8Ted; | |
4149 | /* Max Num MSDU */ | |
4150 | *ptr++ = 8; | |
4151 | /* BA timeout*/ | |
4152 | *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF); | |
4153 | *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF); | |
4154 | /*Ack-Policy */ | |
4155 | *ptr++ = 3; | |
d42ab083 JK |
4156 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
4157 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 JK |
4158 | |
4159 | if (strWID.ps8WidVal != NULL) | |
49188af2 | 4160 | kfree(strWID.ps8WidVal); |
c5c77ba1 JK |
4161 | |
4162 | return s32Error; | |
4163 | ||
4164 | } | |
4165 | ||
4166 | ||
c5c77ba1 JK |
4167 | /** |
4168 | * @brief Handle_DelBASession | |
4169 | * @details Delete block ack session | |
4170 | * @param[in] tstrHostIFSetMulti* strHostIfSetMulti | |
4171 | * @return NONE | |
4172 | * @author Amr Abdel-Moghny | |
4173 | * @date Feb. 2013 | |
4174 | * @version 9.0 | |
4175 | */ | |
54265472 TC |
4176 | static s32 Handle_DelBASession(tstrWILC_WFIDrv *drvHandler, |
4177 | struct ba_session_info *strHostIfBASessionInfo) | |
c5c77ba1 | 4178 | { |
e6e12661 | 4179 | s32 s32Error = 0; |
c5c77ba1 JK |
4180 | tstrWID strWID; |
4181 | char *ptr = NULL; | |
4182 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; | |
4183 | ||
03b2d5e7 | 4184 | PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n", |
c5c77ba1 JK |
4185 | strHostIfBASessionInfo->au8Bssid[0], |
4186 | strHostIfBASessionInfo->au8Bssid[1], | |
4187 | strHostIfBASessionInfo->au8Bssid[2], | |
4188 | strHostIfBASessionInfo->u8Ted); | |
4189 | ||
d85f5326 | 4190 | strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ; |
c5c77ba1 | 4191 | strWID.enuWIDtype = WID_STR; |
f3052587 | 4192 | strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL); |
c5c77ba1 JK |
4193 | strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE; |
4194 | ptr = strWID.ps8WidVal; | |
4195 | /* *ptr++ = 0x14; */ | |
4196 | *ptr++ = 0x14; | |
4197 | *ptr++ = 0x3; | |
4198 | *ptr++ = 0x2; | |
d00d2ba3 | 4199 | memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN); |
c5c77ba1 JK |
4200 | ptr += ETH_ALEN; |
4201 | *ptr++ = strHostIfBASessionInfo->u8Ted; | |
4202 | /* BA direction = recipent*/ | |
4203 | *ptr++ = 0; | |
4204 | /* Delba Reason */ | |
4205 | *ptr++ = 32; /* Unspecific QOS reason */ | |
4206 | ||
d42ab083 JK |
4207 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
4208 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 JK |
4209 | if (s32Error) |
4210 | PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n"); | |
4211 | ||
4212 | ||
d85f5326 | 4213 | strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ; |
c5c77ba1 JK |
4214 | strWID.enuWIDtype = WID_STR; |
4215 | strWID.s32ValueSize = 15; | |
4216 | ptr = strWID.ps8WidVal; | |
4217 | /* *ptr++ = 0x14; */ | |
4218 | *ptr++ = 15; | |
4219 | *ptr++ = 7; | |
4220 | *ptr++ = 0x3; | |
d00d2ba3 | 4221 | memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN); |
c5c77ba1 JK |
4222 | ptr += ETH_ALEN; |
4223 | /* TID*/ | |
4224 | *ptr++ = strHostIfBASessionInfo->u8Ted; | |
4225 | ||
d42ab083 JK |
4226 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
4227 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 JK |
4228 | |
4229 | if (strWID.ps8WidVal != NULL) | |
49188af2 | 4230 | kfree(strWID.ps8WidVal); |
c5c77ba1 | 4231 | |
83383ea3 | 4232 | up(&hWaitResponse); |
c5c77ba1 JK |
4233 | |
4234 | return s32Error; | |
4235 | ||
4236 | } | |
4237 | ||
4238 | ||
4239 | /** | |
4240 | * @brief Handle_DelAllRxBASessions | |
4241 | * @details Delete all Rx BA sessions | |
4242 | * @param[in] tstrHostIFSetMulti* strHostIfSetMulti | |
4243 | * @return NONE | |
4244 | * @author Abdelrahman Sobhy | |
4245 | * @date Feb. 2013 | |
4246 | * @version 9.0 | |
4247 | */ | |
54265472 TC |
4248 | static s32 Handle_DelAllRxBASessions(tstrWILC_WFIDrv *drvHandler, |
4249 | struct ba_session_info *strHostIfBASessionInfo) | |
c5c77ba1 | 4250 | { |
e6e12661 | 4251 | s32 s32Error = 0; |
c5c77ba1 JK |
4252 | tstrWID strWID; |
4253 | char *ptr = NULL; | |
4254 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler; | |
4255 | ||
03b2d5e7 | 4256 | PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n", |
c5c77ba1 JK |
4257 | strHostIfBASessionInfo->au8Bssid[0], |
4258 | strHostIfBASessionInfo->au8Bssid[1], | |
4259 | strHostIfBASessionInfo->au8Bssid[2], | |
4260 | strHostIfBASessionInfo->u8Ted); | |
4261 | ||
d85f5326 | 4262 | strWID.u16WIDid = (u16)WID_DEL_ALL_RX_BA; |
c5c77ba1 | 4263 | strWID.enuWIDtype = WID_STR; |
f3052587 | 4264 | strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL); |
c5c77ba1 JK |
4265 | strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE; |
4266 | ptr = strWID.ps8WidVal; | |
4267 | *ptr++ = 0x14; | |
4268 | *ptr++ = 0x3; | |
4269 | *ptr++ = 0x2; | |
d00d2ba3 | 4270 | memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN); |
c5c77ba1 JK |
4271 | ptr += ETH_ALEN; |
4272 | *ptr++ = strHostIfBASessionInfo->u8Ted; | |
4273 | /* BA direction = recipent*/ | |
4274 | *ptr++ = 0; | |
4275 | /* Delba Reason */ | |
4276 | *ptr++ = 32; /* Unspecific QOS reason */ | |
4277 | ||
d42ab083 JK |
4278 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
4279 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 JK |
4280 | if (s32Error) |
4281 | PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n"); | |
4282 | ||
4283 | ||
4284 | if (strWID.ps8WidVal != NULL) | |
49188af2 | 4285 | kfree(strWID.ps8WidVal); |
c5c77ba1 | 4286 | |
83383ea3 | 4287 | up(&hWaitResponse); |
c5c77ba1 JK |
4288 | |
4289 | return s32Error; | |
4290 | ||
4291 | } | |
4292 | ||
4293 | /** | |
4294 | * @brief hostIFthread | |
4295 | * @details Main thread to handle message queue requests | |
4296 | * @param[in] void* pvArg | |
4297 | * @return NONE | |
4298 | * @author | |
4299 | * @date | |
4300 | * @version 1.0 | |
4301 | */ | |
1999bd52 | 4302 | static int hostIFthread(void *pvArg) |
c5c77ba1 | 4303 | { |
4e4467fd | 4304 | u32 u32Ret; |
143eb95a | 4305 | struct host_if_msg msg; |
c5c77ba1 JK |
4306 | tstrWILC_WFIDrv *pstrWFIDrv; |
4307 | ||
143eb95a | 4308 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
4309 | |
4310 | while (1) { | |
143eb95a TC |
4311 | wilc_mq_recv(&gMsgQHostIF, &msg, sizeof(struct host_if_msg), &u32Ret); |
4312 | pstrWFIDrv = (tstrWILC_WFIDrv *)msg.drvHandler; | |
a9f812a6 | 4313 | if (msg.id == HOST_IF_MSG_EXIT) { |
c5c77ba1 JK |
4314 | PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n"); |
4315 | break; | |
4316 | } | |
4317 | ||
4318 | ||
4319 | /*Re-Queue HIF message*/ | |
4320 | if ((!g_wilc_initialized)) { | |
4321 | PRINT_D(GENERIC_DBG, "--WAIT--"); | |
80e29c7a | 4322 | usleep_range(200 * 1000, 200 * 1000); |
143eb95a | 4323 | wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
4324 | continue; |
4325 | } | |
4326 | ||
a9f812a6 | 4327 | if (msg.id == HOST_IF_MSG_CONNECT && pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) { |
c5c77ba1 | 4328 | PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n"); |
143eb95a | 4329 | wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
80e29c7a | 4330 | usleep_range(2 * 1000, 2 * 1000); |
c5c77ba1 JK |
4331 | continue; |
4332 | } | |
4333 | ||
a9f812a6 | 4334 | switch (msg.id) { |
c5c77ba1 JK |
4335 | case HOST_IF_MSG_Q_IDLE: |
4336 | Handle_wait_msg_q_empty(); | |
4337 | break; | |
4338 | ||
4339 | case HOST_IF_MSG_SCAN: | |
410c2489 | 4340 | Handle_Scan(msg.drvHandler, &msg.body.strHostIFscanAttr); |
c5c77ba1 JK |
4341 | break; |
4342 | ||
4343 | case HOST_IF_MSG_CONNECT: | |
410c2489 | 4344 | Handle_Connect(msg.drvHandler, &msg.body.strHostIFconnectAttr); |
c5c77ba1 JK |
4345 | break; |
4346 | ||
c5c77ba1 | 4347 | case HOST_IF_MSG_FLUSH_CONNECT: |
143eb95a | 4348 | Handle_FlushConnect(msg.drvHandler); |
c5c77ba1 JK |
4349 | break; |
4350 | ||
4351 | case HOST_IF_MSG_RCVD_NTWRK_INFO: | |
410c2489 | 4352 | Handle_RcvdNtwrkInfo(msg.drvHandler, &msg.body.strRcvdNetworkInfo); |
c5c77ba1 JK |
4353 | break; |
4354 | ||
4355 | case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO: | |
410c2489 | 4356 | Handle_RcvdGnrlAsyncInfo(msg.drvHandler, &msg.body.strRcvdGnrlAsyncInfo); |
c5c77ba1 JK |
4357 | break; |
4358 | ||
4359 | case HOST_IF_MSG_KEY: | |
410c2489 | 4360 | Handle_Key(msg.drvHandler, &msg.body.strHostIFkeyAttr); |
c5c77ba1 JK |
4361 | break; |
4362 | ||
4363 | case HOST_IF_MSG_CFG_PARAMS: | |
4364 | ||
410c2489 | 4365 | Handle_CfgParam(msg.drvHandler, &msg.body.strHostIFCfgParamAttr); |
c5c77ba1 JK |
4366 | break; |
4367 | ||
4368 | case HOST_IF_MSG_SET_CHANNEL: | |
410c2489 | 4369 | Handle_SetChannel(msg.drvHandler, &msg.body.strHostIFSetChan); |
c5c77ba1 JK |
4370 | break; |
4371 | ||
4372 | case HOST_IF_MSG_DISCONNECT: | |
143eb95a | 4373 | Handle_Disconnect(msg.drvHandler); |
c5c77ba1 JK |
4374 | break; |
4375 | ||
4376 | case HOST_IF_MSG_RCVD_SCAN_COMPLETE: | |
8972d0fe | 4377 | del_timer(&pstrWFIDrv->hScanTimer); |
c5c77ba1 JK |
4378 | PRINT_D(HOSTINF_DBG, "scan completed successfully\n"); |
4379 | ||
c5c77ba1 | 4380 | /*Allow chip sleep, only if both interfaces are not connected*/ |
2b9d5b48 | 4381 | if (!linux_wlan_get_num_conn_ifcs()) |
c5c77ba1 | 4382 | chip_sleep_manually(INFINITE_SLEEP_TIME); |
c5c77ba1 | 4383 | |
143eb95a | 4384 | Handle_ScanDone(msg.drvHandler, SCAN_EVENT_DONE); |
c5c77ba1 | 4385 | |
c5c77ba1 | 4386 | if (pstrWFIDrv->u8RemainOnChan_pendingreq) |
410c2489 | 4387 | Handle_RemainOnChan(msg.drvHandler, &msg.body.strHostIfRemainOnChan); |
c5c77ba1 JK |
4388 | |
4389 | break; | |
4390 | ||
4391 | case HOST_IF_MSG_GET_RSSI: | |
143eb95a | 4392 | Handle_GetRssi(msg.drvHandler); |
c5c77ba1 JK |
4393 | break; |
4394 | ||
4395 | case HOST_IF_MSG_GET_LINKSPEED: | |
143eb95a | 4396 | Handle_GetLinkspeed(msg.drvHandler); |
c5c77ba1 JK |
4397 | break; |
4398 | ||
4399 | case HOST_IF_MSG_GET_STATISTICS: | |
410c2489 | 4400 | Handle_GetStatistics(msg.drvHandler, (tstrStatistics *)msg.body.pUserData); |
c5c77ba1 JK |
4401 | break; |
4402 | ||
4403 | case HOST_IF_MSG_GET_CHNL: | |
143eb95a | 4404 | Handle_GetChnl(msg.drvHandler); |
c5c77ba1 JK |
4405 | break; |
4406 | ||
c5c77ba1 | 4407 | case HOST_IF_MSG_ADD_BEACON: |
410c2489 | 4408 | Handle_AddBeacon(msg.drvHandler, &msg.body.strHostIFSetBeacon); |
c5c77ba1 JK |
4409 | break; |
4410 | ||
4411 | case HOST_IF_MSG_DEL_BEACON: | |
410c2489 | 4412 | Handle_DelBeacon(msg.drvHandler, &msg.body.strHostIFDelBeacon); |
c5c77ba1 JK |
4413 | break; |
4414 | ||
4415 | case HOST_IF_MSG_ADD_STATION: | |
410c2489 | 4416 | Handle_AddStation(msg.drvHandler, &msg.body.strAddStaParam); |
c5c77ba1 JK |
4417 | break; |
4418 | ||
4419 | case HOST_IF_MSG_DEL_STATION: | |
410c2489 | 4420 | Handle_DelStation(msg.drvHandler, &msg.body.strDelStaParam); |
c5c77ba1 JK |
4421 | break; |
4422 | ||
4423 | case HOST_IF_MSG_EDIT_STATION: | |
410c2489 | 4424 | Handle_EditStation(msg.drvHandler, &msg.body.strEditStaParam); |
c5c77ba1 JK |
4425 | break; |
4426 | ||
4427 | case HOST_IF_MSG_GET_INACTIVETIME: | |
410c2489 | 4428 | Handle_Get_InActiveTime(msg.drvHandler, &msg.body.strHostIfStaInactiveT); |
c5c77ba1 JK |
4429 | break; |
4430 | ||
c5c77ba1 JK |
4431 | case HOST_IF_MSG_SCAN_TIMER_FIRED: |
4432 | PRINT_D(HOSTINF_DBG, "Scan Timeout\n"); | |
4433 | ||
143eb95a | 4434 | Handle_ScanDone(msg.drvHandler, SCAN_EVENT_ABORTED); |
c5c77ba1 JK |
4435 | break; |
4436 | ||
4437 | case HOST_IF_MSG_CONNECT_TIMER_FIRED: | |
03b2d5e7 | 4438 | PRINT_D(HOSTINF_DBG, "Connect Timeout\n"); |
143eb95a | 4439 | Handle_ConnectTimeout(msg.drvHandler); |
c5c77ba1 JK |
4440 | break; |
4441 | ||
4442 | case HOST_IF_MSG_POWER_MGMT: | |
410c2489 | 4443 | Handle_PowerManagement(msg.drvHandler, &msg.body.strPowerMgmtparam); |
c5c77ba1 JK |
4444 | break; |
4445 | ||
4446 | case HOST_IF_MSG_SET_WFIDRV_HANDLER: | |
143eb95a | 4447 | Handle_SetWfiDrvHandler(msg.drvHandler, |
410c2489 | 4448 | &msg.body.strHostIfSetDrvHandler); |
c5c77ba1 JK |
4449 | break; |
4450 | ||
4451 | case HOST_IF_MSG_SET_OPERATION_MODE: | |
410c2489 | 4452 | Handle_SetOperationMode(msg.drvHandler, &msg.body.strHostIfSetOperationMode); |
c5c77ba1 JK |
4453 | break; |
4454 | ||
4455 | case HOST_IF_MSG_SET_IPADDRESS: | |
4456 | PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n"); | |
410c2489 | 4457 | Handle_set_IPAddress(msg.drvHandler, msg.body.strHostIfSetIP.au8IPAddr, msg.body.strHostIfSetIP.idx); |
c5c77ba1 JK |
4458 | break; |
4459 | ||
4460 | case HOST_IF_MSG_GET_IPADDRESS: | |
4461 | PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n"); | |
410c2489 | 4462 | Handle_get_IPAddress(msg.drvHandler, msg.body.strHostIfSetIP.au8IPAddr, msg.body.strHostIfSetIP.idx); |
c5c77ba1 JK |
4463 | break; |
4464 | ||
c5c77ba1 | 4465 | case HOST_IF_MSG_SET_MAC_ADDRESS: |
410c2489 | 4466 | Handle_SetMacAddress(msg.drvHandler, &msg.body.strHostIfSetMacAddress); |
c5c77ba1 JK |
4467 | break; |
4468 | ||
c5c77ba1 | 4469 | case HOST_IF_MSG_GET_MAC_ADDRESS: |
410c2489 | 4470 | Handle_GetMacAddress(msg.drvHandler, &msg.body.strHostIfGetMacAddress); |
c5c77ba1 JK |
4471 | break; |
4472 | ||
c5c77ba1 JK |
4473 | case HOST_IF_MSG_REMAIN_ON_CHAN: |
4474 | PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n"); | |
410c2489 | 4475 | Handle_RemainOnChan(msg.drvHandler, &msg.body.strHostIfRemainOnChan); |
c5c77ba1 JK |
4476 | break; |
4477 | ||
4478 | case HOST_IF_MSG_REGISTER_FRAME: | |
4479 | PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n"); | |
410c2489 | 4480 | Handle_RegisterFrame(msg.drvHandler, &msg.body.strHostIfRegisterFrame); |
c5c77ba1 JK |
4481 | break; |
4482 | ||
4483 | case HOST_IF_MSG_LISTEN_TIMER_FIRED: | |
410c2489 | 4484 | Handle_ListenStateExpired(msg.drvHandler, &msg.body.strHostIfRemainOnChan); |
c5c77ba1 JK |
4485 | break; |
4486 | ||
c5c77ba1 JK |
4487 | case HOST_IF_MSG_SET_MULTICAST_FILTER: |
4488 | PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n"); | |
410c2489 | 4489 | Handle_SetMulticastFilter(msg.drvHandler, &msg.body.strHostIfSetMulti); |
c5c77ba1 JK |
4490 | break; |
4491 | ||
c5c77ba1 | 4492 | case HOST_IF_MSG_ADD_BA_SESSION: |
410c2489 | 4493 | Handle_AddBASession(msg.drvHandler, &msg.body.strHostIfBASessionInfo); |
c5c77ba1 JK |
4494 | break; |
4495 | ||
4496 | case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS: | |
410c2489 | 4497 | Handle_DelAllRxBASessions(msg.drvHandler, &msg.body.strHostIfBASessionInfo); |
c5c77ba1 JK |
4498 | break; |
4499 | ||
4500 | case HOST_IF_MSG_DEL_ALL_STA: | |
410c2489 | 4501 | Handle_DelAllSta(msg.drvHandler, &msg.body.strHostIFDelAllSta); |
c5c77ba1 JK |
4502 | break; |
4503 | ||
4504 | default: | |
03b2d5e7 | 4505 | PRINT_ER("[Host Interface] undefined Received Msg ID\n"); |
c5c77ba1 JK |
4506 | break; |
4507 | } | |
4508 | } | |
4509 | ||
4510 | PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n"); | |
83383ea3 | 4511 | up(&hSemHostIFthrdEnd); |
1999bd52 | 4512 | return 0; |
c5c77ba1 JK |
4513 | } |
4514 | ||
93dee8ee | 4515 | static void TimerCB_Scan(unsigned long arg) |
c5c77ba1 | 4516 | { |
93dee8ee | 4517 | void *pvArg = (void *)arg; |
143eb95a | 4518 | struct host_if_msg msg; |
c5c77ba1 JK |
4519 | |
4520 | /* prepare the Timer Callback message */ | |
143eb95a TC |
4521 | memset(&msg, 0, sizeof(struct host_if_msg)); |
4522 | msg.drvHandler = pvArg; | |
a9f812a6 | 4523 | msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED; |
c5c77ba1 JK |
4524 | |
4525 | /* send the message */ | |
143eb95a | 4526 | wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
4527 | } |
4528 | ||
93dee8ee | 4529 | static void TimerCB_Connect(unsigned long arg) |
c5c77ba1 | 4530 | { |
93dee8ee | 4531 | void *pvArg = (void *)arg; |
143eb95a | 4532 | struct host_if_msg msg; |
c5c77ba1 JK |
4533 | |
4534 | /* prepare the Timer Callback message */ | |
143eb95a TC |
4535 | memset(&msg, 0, sizeof(struct host_if_msg)); |
4536 | msg.drvHandler = pvArg; | |
a9f812a6 | 4537 | msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED; |
c5c77ba1 JK |
4538 | |
4539 | /* send the message */ | |
143eb95a | 4540 | wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
4541 | } |
4542 | ||
4543 | ||
4544 | /** | |
4545 | * @brief removes wpa/wpa2 keys | |
4546 | * @details only in BSS STA mode if External Supplicant support is enabled. | |
4547 | * removes all WPA/WPA2 station key entries from MAC hardware. | |
4548 | * @param[in,out] handle to the wifi driver | |
4549 | * @param[in] 6 bytes of Station Adress in the station entry table | |
4550 | * @return Error code indicating success/failure | |
4551 | * @note | |
4552 | * @author zsalah | |
4553 | * @date 8 March 2012 | |
4554 | * @version 1.0 | |
4555 | */ | |
4556 | /* Check implementation in core adding 9 bytes to the input! */ | |
218dc407 | 4557 | s32 host_int_remove_key(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8StaAddress) |
c5c77ba1 | 4558 | { |
e6e12661 | 4559 | s32 s32Error = 0; |
c5c77ba1 JK |
4560 | tstrWID strWID; |
4561 | /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ | |
4562 | ||
d85f5326 | 4563 | strWID.u16WIDid = (u16)WID_REMOVE_KEY; |
c5c77ba1 | 4564 | strWID.enuWIDtype = WID_STR; |
ca356ada | 4565 | strWID.ps8WidVal = (s8 *)pu8StaAddress; |
c5c77ba1 JK |
4566 | strWID.s32ValueSize = 6; |
4567 | ||
4568 | return s32Error; | |
4569 | ||
4570 | } | |
4571 | ||
4572 | /** | |
4573 | * @brief removes WEP key | |
4574 | * @details valid only in BSS STA mode if External Supplicant support is enabled. | |
4575 | * remove a WEP key entry from MAC HW. | |
4576 | * The BSS Station automatically finds the index of the entry using its | |
4577 | * BSS ID and removes that entry from the MAC hardware. | |
4578 | * @param[in,out] handle to the wifi driver | |
4579 | * @param[in] 6 bytes of Station Adress in the station entry table | |
4580 | * @return Error code indicating success/failure | |
4581 | * @note NO need for the STA add since it is not used for processing | |
4582 | * @author zsalah | |
4583 | * @date 8 March 2012 | |
4584 | * @version 1.0 | |
4585 | */ | |
218dc407 | 4586 | s32 host_int_remove_wep_key(tstrWILC_WFIDrv *hWFIDrv, u8 u8keyIdx) |
c5c77ba1 | 4587 | { |
e6e12661 | 4588 | s32 s32Error = 0; |
c5c77ba1 | 4589 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 4590 | struct host_if_msg msg; |
c5c77ba1 JK |
4591 | |
4592 | ||
24db713f LK |
4593 | if (pstrWFIDrv == NULL) { |
4594 | s32Error = -EFAULT; | |
4595 | PRINT_ER("Failed to send setup multicast config packet\n"); | |
4596 | return s32Error; | |
4597 | } | |
c5c77ba1 JK |
4598 | |
4599 | /* prepare the Remove Wep Key Message */ | |
143eb95a | 4600 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
4601 | |
4602 | ||
a9f812a6 | 4603 | msg.id = HOST_IF_MSG_KEY; |
410c2489 TC |
4604 | msg.body.strHostIFkeyAttr.enuKeyType = WEP; |
4605 | msg.body.strHostIFkeyAttr.u8KeyAction = REMOVEKEY; | |
143eb95a | 4606 | msg.drvHandler = hWFIDrv; |
c5c77ba1 JK |
4607 | |
4608 | ||
4609 | ||
410c2489 | 4610 | msg.body.strHostIFkeyAttr. |
c5c77ba1 JK |
4611 | uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8keyIdx; |
4612 | ||
4613 | /* send the message */ | |
143eb95a | 4614 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
c5c77ba1 | 4615 | if (s32Error) |
03b2d5e7 | 4616 | PRINT_ER("Error in sending message queue : Request to remove WEP key\n"); |
83383ea3 | 4617 | down(&(pstrWFIDrv->hSemTestKeyBlock)); |
c5c77ba1 | 4618 | |
c5c77ba1 JK |
4619 | return s32Error; |
4620 | } | |
4621 | ||
4622 | /** | |
4623 | * @brief sets WEP default key | |
4624 | * @details Sets the index of the WEP encryption key in use, | |
4625 | * in the key table | |
4626 | * @param[in,out] handle to the wifi driver | |
4627 | * @param[in] key index ( 0, 1, 2, 3) | |
4628 | * @return Error code indicating success/failure | |
4629 | * @note | |
4630 | * @author zsalah | |
4631 | * @date 8 March 2012 | |
4632 | * @version 1.0 | |
4633 | */ | |
218dc407 | 4634 | s32 host_int_set_WEPDefaultKeyID(tstrWILC_WFIDrv *hWFIDrv, u8 u8Index) |
c5c77ba1 | 4635 | { |
e6e12661 | 4636 | s32 s32Error = 0; |
c5c77ba1 | 4637 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 4638 | struct host_if_msg msg; |
c5c77ba1 JK |
4639 | |
4640 | ||
24db713f LK |
4641 | if (pstrWFIDrv == NULL) { |
4642 | s32Error = -EFAULT; | |
4643 | PRINT_ER("driver is null\n"); | |
4644 | return s32Error; | |
4645 | } | |
c5c77ba1 JK |
4646 | |
4647 | /* prepare the Key Message */ | |
143eb95a | 4648 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
4649 | |
4650 | ||
a9f812a6 | 4651 | msg.id = HOST_IF_MSG_KEY; |
410c2489 TC |
4652 | msg.body.strHostIFkeyAttr.enuKeyType = WEP; |
4653 | msg.body.strHostIFkeyAttr.u8KeyAction = DEFAULTKEY; | |
143eb95a | 4654 | msg.drvHandler = hWFIDrv; |
c5c77ba1 JK |
4655 | |
4656 | ||
410c2489 | 4657 | msg.body.strHostIFkeyAttr. |
c5c77ba1 JK |
4658 | uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Index; |
4659 | ||
4660 | /* send the message */ | |
143eb95a | 4661 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
4662 | if (s32Error) |
4663 | PRINT_ER("Error in sending message queue : Default key index\n"); | |
83383ea3 | 4664 | down(&(pstrWFIDrv->hSemTestKeyBlock)); |
c5c77ba1 | 4665 | |
c5c77ba1 JK |
4666 | return s32Error; |
4667 | } | |
4668 | ||
4669 | /** | |
4670 | * @brief sets WEP deafault key | |
4671 | * @details valid only in BSS STA mode if External Supplicant support is enabled. | |
4672 | * sets WEP key entry into MAC hardware when it receives the | |
4673 | * corresponding request from NDIS. | |
4674 | * @param[in,out] handle to the wifi driver | |
4675 | * @param[in] message containing WEP Key in the following format | |
4676 | *|---------------------------------------| | |
4677 | *|Key ID Value | Key Length | Key | | |
4678 | *|-------------|------------|------------| | |
4679 | | 1byte | 1byte | Key Length | | |
4680 | ||---------------------------------------| | |
4681 | | | |
4682 | * @return Error code indicating success/failure | |
4683 | * @note | |
4684 | * @author zsalah | |
4685 | * @date 8 March 2012 | |
4686 | * @version 1.0 | |
4687 | */ | |
218dc407 | 4688 | s32 host_int_add_wep_key_bss_sta(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx) |
c5c77ba1 JK |
4689 | { |
4690 | ||
e6e12661 | 4691 | s32 s32Error = 0; |
c5c77ba1 | 4692 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 4693 | struct host_if_msg msg; |
c5c77ba1 | 4694 | |
24db713f LK |
4695 | if (pstrWFIDrv == NULL) { |
4696 | s32Error = -EFAULT; | |
4697 | PRINT_ER("driver is null\n"); | |
4698 | return s32Error; | |
4699 | } | |
c5c77ba1 JK |
4700 | |
4701 | /* prepare the Key Message */ | |
143eb95a | 4702 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
4703 | |
4704 | ||
a9f812a6 | 4705 | msg.id = HOST_IF_MSG_KEY; |
410c2489 TC |
4706 | msg.body.strHostIFkeyAttr.enuKeyType = WEP; |
4707 | msg.body.strHostIFkeyAttr.u8KeyAction = ADDKEY; | |
143eb95a | 4708 | msg.drvHandler = hWFIDrv; |
c5c77ba1 JK |
4709 | |
4710 | ||
410c2489 | 4711 | msg.body.strHostIFkeyAttr. |
f3052587 | 4712 | uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = kmalloc(u8WepKeylen, GFP_KERNEL); |
c5c77ba1 | 4713 | |
410c2489 | 4714 | memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey, |
c5c77ba1 JK |
4715 | pu8WepKey, u8WepKeylen); |
4716 | ||
4717 | ||
410c2489 | 4718 | msg.body.strHostIFkeyAttr. |
c5c77ba1 JK |
4719 | uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen); |
4720 | ||
410c2489 | 4721 | msg.body.strHostIFkeyAttr. |
c5c77ba1 JK |
4722 | uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx; |
4723 | ||
4724 | /* send the message */ | |
143eb95a | 4725 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
4726 | if (s32Error) |
4727 | PRINT_ER("Error in sending message queue :WEP Key\n"); | |
83383ea3 | 4728 | down(&(pstrWFIDrv->hSemTestKeyBlock)); |
c5c77ba1 | 4729 | |
c5c77ba1 JK |
4730 | return s32Error; |
4731 | ||
4732 | } | |
4733 | ||
c5c77ba1 JK |
4734 | /** |
4735 | * | |
4736 | * @brief host_int_add_wep_key_bss_ap | |
4737 | * @details valid only in BSS AP mode if External Supplicant support is enabled. | |
4738 | * sets WEP key entry into MAC hardware when it receives the | |
4739 | * | |
4740 | * corresponding request from NDIS. | |
4741 | * @param[in,out] handle to the wifi driver | |
4742 | * | |
4743 | * | |
4744 | * @return Error code indicating success/failure | |
4745 | * @note | |
4746 | * @author mdaftedar | |
4747 | * @date 28 FEB 2013 | |
4748 | * @version 1.0 | |
4749 | */ | |
218dc407 | 4750 | s32 host_int_add_wep_key_bss_ap(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx, u8 u8mode, AUTHTYPE_T tenuAuth_type) |
c5c77ba1 JK |
4751 | { |
4752 | ||
e6e12661 | 4753 | s32 s32Error = 0; |
c5c77ba1 | 4754 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 4755 | struct host_if_msg msg; |
63d03e47 | 4756 | u8 i; |
c5c77ba1 | 4757 | |
24db713f LK |
4758 | if (pstrWFIDrv == NULL) { |
4759 | s32Error = -EFAULT; | |
4760 | PRINT_ER("driver is null\n"); | |
4761 | return s32Error; | |
4762 | } | |
c5c77ba1 JK |
4763 | |
4764 | /* prepare the Key Message */ | |
143eb95a | 4765 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
4766 | |
4767 | if (INFO) { | |
4768 | for (i = 0; i < u8WepKeylen; i++) | |
4769 | PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]); | |
4770 | } | |
a9f812a6 | 4771 | msg.id = HOST_IF_MSG_KEY; |
410c2489 TC |
4772 | msg.body.strHostIFkeyAttr.enuKeyType = WEP; |
4773 | msg.body.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP; | |
143eb95a | 4774 | msg.drvHandler = hWFIDrv; |
c5c77ba1 JK |
4775 | |
4776 | ||
410c2489 | 4777 | msg.body.strHostIFkeyAttr. |
f3052587 | 4778 | uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = kmalloc(u8WepKeylen, GFP_KERNEL); |
c5c77ba1 JK |
4779 | |
4780 | ||
410c2489 | 4781 | memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey, |
c5c77ba1 JK |
4782 | pu8WepKey, (u8WepKeylen)); |
4783 | ||
4784 | ||
410c2489 | 4785 | msg.body.strHostIFkeyAttr. |
c5c77ba1 JK |
4786 | uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen); |
4787 | ||
410c2489 | 4788 | msg.body.strHostIFkeyAttr. |
c5c77ba1 JK |
4789 | uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx; |
4790 | ||
410c2489 | 4791 | msg.body.strHostIFkeyAttr. |
c5c77ba1 JK |
4792 | uniHostIFkeyAttr.strHostIFwepAttr.u8mode = u8mode; |
4793 | ||
410c2489 | 4794 | msg.body.strHostIFkeyAttr. |
c5c77ba1 JK |
4795 | uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type = tenuAuth_type; |
4796 | /* send the message */ | |
143eb95a | 4797 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
4798 | |
4799 | if (s32Error) | |
4800 | PRINT_ER("Error in sending message queue :WEP Key\n"); | |
83383ea3 | 4801 | down(&(pstrWFIDrv->hSemTestKeyBlock)); |
c5c77ba1 | 4802 | |
c5c77ba1 JK |
4803 | return s32Error; |
4804 | ||
4805 | } | |
108b3439 | 4806 | |
c5c77ba1 JK |
4807 | /** |
4808 | * @brief adds ptk Key | |
4809 | * @details | |
4810 | * @param[in,out] handle to the wifi driver | |
4811 | * @param[in] message containing PTK Key in the following format | |
4812 | *|-----------------------------------------------------------------------------| | |
4813 | *|Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key | | |
4814 | *|----------------|------------|--------------|----------------|---------------| | |
4815 | | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes | | |
4816 | ||-----------------------------------------------------------------------------| | |
4817 | * @return Error code indicating success/failure | |
4818 | * @note | |
4819 | * @author zsalah | |
4820 | * @date 8 March 2012 | |
4821 | * @version 1.0 | |
4822 | */ | |
218dc407 | 4823 | s32 host_int_add_ptk(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen, |
63d03e47 | 4824 | const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode, u8 u8Idx) |
c5c77ba1 | 4825 | { |
e6e12661 | 4826 | s32 s32Error = 0; |
c5c77ba1 | 4827 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 4828 | struct host_if_msg msg; |
63d03e47 | 4829 | u8 u8KeyLen = u8PtkKeylen; |
4e4467fd | 4830 | u32 i; |
78c87591 | 4831 | |
24db713f LK |
4832 | if (pstrWFIDrv == NULL) { |
4833 | s32Error = -EFAULT; | |
4834 | PRINT_ER("driver is null\n"); | |
4835 | return s32Error; | |
4836 | } | |
2b9d5b48 | 4837 | if (pu8RxMic != NULL) |
c5c77ba1 | 4838 | u8KeyLen += RX_MIC_KEY_LEN; |
2b9d5b48 | 4839 | if (pu8TxMic != NULL) |
c5c77ba1 | 4840 | u8KeyLen += TX_MIC_KEY_LEN; |
c5c77ba1 JK |
4841 | |
4842 | /* prepare the Key Message */ | |
143eb95a | 4843 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
4844 | |
4845 | ||
a9f812a6 | 4846 | msg.id = HOST_IF_MSG_KEY; |
410c2489 | 4847 | msg.body.strHostIFkeyAttr.enuKeyType = WPAPtk; |
c5c77ba1 | 4848 | if (mode == AP_MODE) { |
410c2489 TC |
4849 | msg.body.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP; |
4850 | msg.body.strHostIFkeyAttr. | |
c5c77ba1 JK |
4851 | uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8Idx; |
4852 | } | |
c5c77ba1 | 4853 | if (mode == STATION_MODE) |
410c2489 | 4854 | msg.body.strHostIFkeyAttr.u8KeyAction = ADDKEY; |
c5c77ba1 JK |
4855 | |
4856 | ||
410c2489 | 4857 | msg.body.strHostIFkeyAttr. |
f3052587 | 4858 | uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = kmalloc(u8PtkKeylen, GFP_KERNEL); |
c5c77ba1 JK |
4859 | |
4860 | ||
410c2489 | 4861 | memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key, |
c5c77ba1 JK |
4862 | pu8Ptk, u8PtkKeylen); |
4863 | ||
4864 | if (pu8RxMic != NULL) { | |
4865 | ||
410c2489 | 4866 | memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16, |
c5c77ba1 JK |
4867 | pu8RxMic, RX_MIC_KEY_LEN); |
4868 | if (INFO) { | |
4869 | for (i = 0; i < RX_MIC_KEY_LEN; i++) | |
4870 | PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]); | |
4871 | } | |
4872 | } | |
4873 | if (pu8TxMic != NULL) { | |
4874 | ||
410c2489 | 4875 | memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24, |
c5c77ba1 JK |
4876 | pu8TxMic, TX_MIC_KEY_LEN); |
4877 | if (INFO) { | |
4878 | for (i = 0; i < TX_MIC_KEY_LEN; i++) | |
4879 | PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]); | |
4880 | } | |
4881 | } | |
4882 | ||
410c2489 | 4883 | msg.body.strHostIFkeyAttr. |
c5c77ba1 JK |
4884 | uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen; |
4885 | ||
410c2489 | 4886 | msg.body.strHostIFkeyAttr. |
c5c77ba1 | 4887 | uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode; |
410c2489 | 4888 | msg.body.strHostIFkeyAttr. |
c5c77ba1 | 4889 | uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr = mac_addr; |
143eb95a | 4890 | msg.drvHandler = hWFIDrv; |
c5c77ba1 JK |
4891 | |
4892 | /* send the message */ | |
143eb95a | 4893 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
4894 | |
4895 | if (s32Error) | |
4896 | PRINT_ER("Error in sending message queue: PTK Key\n"); | |
4897 | ||
4898 | /* ////////////// */ | |
83383ea3 | 4899 | down(&(pstrWFIDrv->hSemTestKeyBlock)); |
c5c77ba1 JK |
4900 | /* /////// */ |
4901 | ||
c5c77ba1 JK |
4902 | return s32Error; |
4903 | } | |
4904 | ||
4905 | /** | |
4906 | * @brief adds Rx GTk Key | |
4907 | * @details | |
4908 | * @param[in,out] handle to the wifi driver | |
4909 | * @param[in] pu8RxGtk : contains temporal key | Rx Mic | Tx Mic | |
4910 | * u8GtkKeylen :The total key length | |
4911 | * | |
4912 | * @return Error code indicating success/failure | |
4913 | * @note | |
4914 | * @author zsalah | |
4915 | * @date 8 March 2012 | |
4916 | * @version 1.0 | |
4917 | */ | |
218dc407 | 4918 | s32 host_int_add_rx_gtk(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen, |
4e4467fd | 4919 | u8 u8KeyIdx, u32 u32KeyRSClen, const u8 *KeyRSC, |
63d03e47 | 4920 | const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode) |
c5c77ba1 | 4921 | { |
e6e12661 | 4922 | s32 s32Error = 0; |
c5c77ba1 | 4923 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 4924 | struct host_if_msg msg; |
63d03e47 | 4925 | u8 u8KeyLen = u8GtkKeylen; |
c5c77ba1 | 4926 | |
24db713f LK |
4927 | if (pstrWFIDrv == NULL) { |
4928 | s32Error = -EFAULT; | |
4929 | PRINT_ER("driver is null\n"); | |
4930 | return s32Error; | |
4931 | } | |
c5c77ba1 | 4932 | /* prepare the Key Message */ |
143eb95a | 4933 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
4934 | |
4935 | ||
2b9d5b48 | 4936 | if (pu8RxMic != NULL) |
c5c77ba1 | 4937 | u8KeyLen += RX_MIC_KEY_LEN; |
2b9d5b48 | 4938 | if (pu8TxMic != NULL) |
c5c77ba1 | 4939 | u8KeyLen += TX_MIC_KEY_LEN; |
c5c77ba1 | 4940 | if (KeyRSC != NULL) { |
410c2489 | 4941 | msg.body.strHostIFkeyAttr. |
f3052587 | 4942 | uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq = kmalloc(u32KeyRSClen, GFP_KERNEL); |
c5c77ba1 | 4943 | |
410c2489 | 4944 | memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, |
c5c77ba1 JK |
4945 | KeyRSC, u32KeyRSClen); |
4946 | } | |
4947 | ||
4948 | ||
a9f812a6 | 4949 | msg.id = HOST_IF_MSG_KEY; |
410c2489 | 4950 | msg.body.strHostIFkeyAttr.enuKeyType = WPARxGtk; |
143eb95a | 4951 | msg.drvHandler = hWFIDrv; |
c5c77ba1 | 4952 | |
c5c77ba1 | 4953 | if (mode == AP_MODE) { |
410c2489 TC |
4954 | msg.body.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP; |
4955 | msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode; | |
c5c77ba1 | 4956 | } |
c5c77ba1 | 4957 | if (mode == STATION_MODE) |
410c2489 | 4958 | msg.body.strHostIFkeyAttr.u8KeyAction = ADDKEY; |
c5c77ba1 JK |
4959 | |
4960 | ||
410c2489 | 4961 | msg.body.strHostIFkeyAttr. |
f3052587 | 4962 | uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = kmalloc(u8KeyLen, GFP_KERNEL); |
c5c77ba1 | 4963 | |
410c2489 | 4964 | memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key, |
c5c77ba1 JK |
4965 | pu8RxGtk, u8GtkKeylen); |
4966 | ||
4967 | if (pu8RxMic != NULL) { | |
4968 | ||
410c2489 | 4969 | memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16, |
c5c77ba1 JK |
4970 | pu8RxMic, RX_MIC_KEY_LEN); |
4971 | ||
4972 | } | |
4973 | if (pu8TxMic != NULL) { | |
4974 | ||
410c2489 | 4975 | memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24, |
c5c77ba1 JK |
4976 | pu8TxMic, TX_MIC_KEY_LEN); |
4977 | ||
4978 | } | |
4979 | ||
410c2489 | 4980 | msg.body.strHostIFkeyAttr. |
c5c77ba1 | 4981 | uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8KeyIdx; |
410c2489 | 4982 | msg.body.strHostIFkeyAttr. |
c5c77ba1 JK |
4983 | uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen; |
4984 | ||
410c2489 | 4985 | msg.body.strHostIFkeyAttr. |
c5c77ba1 JK |
4986 | uniHostIFkeyAttr.strHostIFwpaAttr.u8seqlen = u32KeyRSClen; |
4987 | ||
4988 | ||
4989 | ||
4990 | /* send the message */ | |
143eb95a | 4991 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
4992 | if (s32Error) |
4993 | PRINT_ER("Error in sending message queue: RX GTK\n"); | |
4994 | /* ////////////// */ | |
83383ea3 | 4995 | down(&(pstrWFIDrv->hSemTestKeyBlock)); |
c5c77ba1 JK |
4996 | /* /////// */ |
4997 | ||
c5c77ba1 JK |
4998 | return s32Error; |
4999 | } | |
c5c77ba1 | 5000 | |
c5c77ba1 JK |
5001 | /** |
5002 | * @brief host_int_set_pmkid_info | |
5003 | * @details caches the pmkid valid only in BSS STA mode if External Supplicant | |
5004 | * support is enabled. This Function sets the PMKID in firmware | |
5005 | * when host drivr receives the corresponding request from NDIS. | |
5006 | * The firmware then includes theset PMKID in the appropriate | |
5007 | * management frames | |
5008 | * @param[in,out] handle to the wifi driver | |
5009 | * @param[in] message containing PMKID Info in the following format | |
5010 | *|-----------------------------------------------------------------| | |
5011 | *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] | | |
5012 | *|-----------|------------|----------|-------|----------|----------| | |
5013 | | 1 | 6 | 16 | ... | 6 | 16 | | |
5014 | ||-----------------------------------------------------------------| | |
5015 | * @return Error code indicating success/failure | |
5016 | * @note | |
5017 | * @author zsalah | |
5018 | * @date 8 March 2012 | |
5019 | * @version 1.0 | |
5020 | */ | |
218dc407 | 5021 | s32 host_int_set_pmkid_info(tstrWILC_WFIDrv *hWFIDrv, tstrHostIFpmkidAttr *pu8PmkidInfoArray) |
c5c77ba1 | 5022 | { |
e6e12661 | 5023 | s32 s32Error = 0; |
c5c77ba1 | 5024 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 5025 | struct host_if_msg msg; |
4e4467fd | 5026 | u32 i; |
c5c77ba1 JK |
5027 | |
5028 | ||
24db713f LK |
5029 | if (pstrWFIDrv == NULL) { |
5030 | s32Error = -EFAULT; | |
5031 | PRINT_ER("driver is null\n"); | |
5032 | return s32Error; | |
5033 | } | |
c5c77ba1 JK |
5034 | |
5035 | /* prepare the Key Message */ | |
143eb95a | 5036 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 | 5037 | |
a9f812a6 | 5038 | msg.id = HOST_IF_MSG_KEY; |
410c2489 TC |
5039 | msg.body.strHostIFkeyAttr.enuKeyType = PMKSA; |
5040 | msg.body.strHostIFkeyAttr.u8KeyAction = ADDKEY; | |
143eb95a | 5041 | msg.drvHandler = hWFIDrv; |
c5c77ba1 JK |
5042 | |
5043 | for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) { | |
5044 | ||
410c2489 | 5045 | memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid, |
c5c77ba1 JK |
5046 | ETH_ALEN); |
5047 | ||
410c2489 | 5048 | memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid, |
c5c77ba1 JK |
5049 | PMKID_LEN); |
5050 | } | |
5051 | ||
5052 | /* send the message */ | |
143eb95a | 5053 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
5054 | if (s32Error) |
5055 | PRINT_ER(" Error in sending messagequeue: PMKID Info\n"); | |
5056 | ||
c5c77ba1 JK |
5057 | return s32Error; |
5058 | } | |
5059 | ||
5060 | /** | |
5061 | * @brief gets the cached the pmkid info | |
5062 | * @details valid only in BSS STA mode if External Supplicant | |
5063 | * support is enabled. This Function sets the PMKID in firmware | |
5064 | * when host drivr receives the corresponding request from NDIS. | |
5065 | * The firmware then includes theset PMKID in the appropriate | |
5066 | * management frames | |
5067 | * @param[in,out] handle to the wifi driver, | |
5068 | * message containing PMKID Info in the following format | |
5069 | *|-----------------------------------------------------------------| | |
5070 | *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] | | |
5071 | *|-----------|------------|----------|-------|----------|----------| | |
5072 | | 1 | 6 | 16 | ... | 6 | 16 | | |
5073 | ||-----------------------------------------------------------------| | |
5074 | * @param[in] | |
5075 | * @return Error code indicating success/failure | |
5076 | * @note | |
5077 | * @author zsalah | |
5078 | * @date 8 March 2012 | |
5079 | * @version 1.0 | |
5080 | */ | |
218dc407 | 5081 | s32 host_int_get_pmkid_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8PmkidInfoArray, |
4e4467fd | 5082 | u32 u32PmkidInfoLen) |
c5c77ba1 | 5083 | { |
e6e12661 | 5084 | s32 s32Error = 0; |
c5c77ba1 JK |
5085 | tstrWID strWID; |
5086 | /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ | |
5087 | ||
d85f5326 | 5088 | strWID.u16WIDid = (u16)WID_PMKID_INFO; |
c5c77ba1 JK |
5089 | strWID.enuWIDtype = WID_STR; |
5090 | strWID.s32ValueSize = u32PmkidInfoLen; | |
5091 | strWID.ps8WidVal = pu8PmkidInfoArray; | |
5092 | ||
5093 | return s32Error; | |
5094 | } | |
5095 | ||
5096 | /** | |
5097 | * @brief sets the pass phrase | |
5098 | * @details AP/STA mode. This function gives the pass phrase used to | |
5099 | * generate the Pre-Shared Key when WPA/WPA2 is enabled | |
5100 | * The length of the field can vary from 8 to 64 bytes, | |
5101 | * the lower layer should get the | |
5102 | * @param[in,out] handle to the wifi driver, | |
5103 | * @param[in] String containing PSK | |
5104 | * @return Error code indicating success/failure | |
5105 | * @note | |
5106 | * @author zsalah | |
5107 | * @date 8 March 2012 | |
5108 | * @version 1.0 | |
5109 | */ | |
218dc407 | 5110 | s32 host_int_set_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8PassPhrase, |
63d03e47 | 5111 | u8 u8Psklength) |
c5c77ba1 | 5112 | { |
e6e12661 | 5113 | s32 s32Error = 0; |
c5c77ba1 | 5114 | tstrWID strWID; |
c5c77ba1 | 5115 | |
c5c77ba1 JK |
5116 | /*validating psk length*/ |
5117 | if ((u8Psklength > 7) && (u8Psklength < 65)) { | |
d85f5326 | 5118 | strWID.u16WIDid = (u16)WID_11I_PSK; |
c5c77ba1 JK |
5119 | strWID.enuWIDtype = WID_STR; |
5120 | strWID.ps8WidVal = pu8PassPhrase; | |
5121 | strWID.s32ValueSize = u8Psklength; | |
5122 | } | |
5123 | ||
5124 | return s32Error; | |
5125 | } | |
5126 | /** | |
5127 | * @brief host_int_get_MacAddress | |
5128 | * @details gets mac address | |
5129 | * @param[in,out] handle to the wifi driver, | |
5130 | * | |
5131 | * @return Error code indicating success/failure | |
5132 | * @note | |
5133 | * @author mdaftedar | |
5134 | * @date 19 April 2012 | |
5135 | * @version 1.0 | |
5136 | */ | |
218dc407 | 5137 | s32 host_int_get_MacAddress(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8MacAddress) |
c5c77ba1 | 5138 | { |
e6e12661 | 5139 | s32 s32Error = 0; |
143eb95a | 5140 | struct host_if_msg msg; |
c5c77ba1 JK |
5141 | |
5142 | ||
5143 | /* prepare the Message */ | |
143eb95a | 5144 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 | 5145 | |
a9f812a6 | 5146 | msg.id = HOST_IF_MSG_GET_MAC_ADDRESS; |
410c2489 | 5147 | msg.body.strHostIfGetMacAddress.u8MacAddress = pu8MacAddress; |
143eb95a | 5148 | msg.drvHandler = hWFIDrv; |
c5c77ba1 | 5149 | /* send the message */ |
143eb95a | 5150 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
5151 | if (s32Error) { |
5152 | PRINT_ER("Failed to send get mac address\n"); | |
e6e12661 | 5153 | return -EFAULT; |
c5c77ba1 JK |
5154 | } |
5155 | ||
83383ea3 | 5156 | down(&hWaitResponse); |
c5c77ba1 JK |
5157 | return s32Error; |
5158 | } | |
5159 | ||
5160 | /** | |
5161 | * @brief host_int_set_MacAddress | |
5162 | * @details sets mac address | |
5163 | * @param[in,out] handle to the wifi driver, | |
5164 | * | |
5165 | * @return Error code indicating success/failure | |
5166 | * @note | |
5167 | * @author mabubakr | |
5168 | * @date 16 July 2012 | |
5169 | * @version 1.0 | |
5170 | */ | |
218dc407 | 5171 | s32 host_int_set_MacAddress(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8MacAddress) |
c5c77ba1 | 5172 | { |
e6e12661 | 5173 | s32 s32Error = 0; |
143eb95a | 5174 | struct host_if_msg msg; |
c5c77ba1 JK |
5175 | |
5176 | PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]); | |
5177 | ||
5178 | /* prepare setting mac address message */ | |
143eb95a | 5179 | memset(&msg, 0, sizeof(struct host_if_msg)); |
a9f812a6 | 5180 | msg.id = HOST_IF_MSG_SET_MAC_ADDRESS; |
410c2489 | 5181 | memcpy(msg.body.strHostIfSetMacAddress.u8MacAddress, pu8MacAddress, ETH_ALEN); |
143eb95a | 5182 | msg.drvHandler = hWFIDrv; |
c5c77ba1 | 5183 | |
143eb95a | 5184 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
24db713f | 5185 | if (s32Error) |
c5c77ba1 | 5186 | PRINT_ER("Failed to send message queue: Set mac address\n"); |
c5c77ba1 JK |
5187 | |
5188 | return s32Error; | |
5189 | ||
5190 | } | |
5191 | ||
5192 | /** | |
5193 | * @brief host_int_get_RSNAConfigPSKPassPhrase | |
5194 | * @details gets the pass phrase:AP/STA mode. This function gets the pass phrase used to | |
5195 | * generate the Pre-Shared Key when WPA/WPA2 is enabled | |
5196 | * The length of the field can vary from 8 to 64 bytes, | |
5197 | * the lower layer should get the | |
5198 | * @param[in,out] handle to the wifi driver, | |
5199 | * String containing PSK | |
5200 | * @return Error code indicating success/failure | |
5201 | * @note | |
5202 | * @author zsalah | |
5203 | * @date 8 March 2012 | |
5204 | * @version 1.0 | |
5205 | */ | |
218dc407 | 5206 | s32 host_int_get_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv *hWFIDrv, |
63d03e47 | 5207 | u8 *pu8PassPhrase, u8 u8Psklength) |
c5c77ba1 | 5208 | { |
e6e12661 | 5209 | s32 s32Error = 0; |
c5c77ba1 JK |
5210 | tstrWID strWID; |
5211 | /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ | |
5212 | ||
d85f5326 | 5213 | strWID.u16WIDid = (u16)WID_11I_PSK; |
c5c77ba1 JK |
5214 | strWID.enuWIDtype = WID_STR; |
5215 | strWID.s32ValueSize = u8Psklength; | |
5216 | strWID.ps8WidVal = pu8PassPhrase; | |
5217 | ||
5218 | return s32Error; | |
5219 | } | |
5220 | ||
5221 | /** | |
5222 | * @brief host_int_get_site_survey_results | |
5223 | * @details gets the site survey results | |
5224 | * @param[in,out] handle to the wifi driver, | |
5225 | * Message containing site survey results in the | |
5226 | * following format | |
5227 | *|---------------------------------------------------| | |
5228 | | MsgLength | fragNo. | MsgBodyLength | MsgBody | | |
5229 | ||-----------|-----------|---------------|-----------| | |
5230 | | 1 | 1 | 1 | 1 | | |
5231 | | ----------------------------------------- | ---------------- | |
5232 | | | |
5233 | ||---------------------------------------| | |
5234 | | Network1 | Netweork2 | ... | Network5 | | |
5235 | ||---------------------------------------| | |
5236 | | 44 | 44 | ... | 44 | | |
5237 | | -------------------------- | --------------------------------------- | |
5238 | | | |
5239 | ||---------------------------------------------------------------------| | |
5240 | | SSID | BSS Type | Channel | Security Status| BSSID | RSSI |Reserved | | |
5241 | | | |
5242 | | | |
5243 | ||------|----------|---------|----------------|-------|------|---------| | |
5244 | | 33 | 1 | 1 | 1 | 6 | 1 | 1 | | |
5245 | ||---------------------------------------------------------------------| | |
5246 | * @return Error code indicating success/failure | |
5247 | * @note | |
5248 | * @author zsalah | |
5249 | * @date 8 March 2012 | |
5250 | * @version 1.0 | |
5251 | */ | |
5252 | #ifndef CONNECT_DIRECT | |
218dc407 | 5253 | s32 host_int_get_site_survey_results(tstrWILC_WFIDrv *hWFIDrv, |
63d03e47 | 5254 | u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE], |
4e4467fd | 5255 | u32 u32MaxSiteSrvyFragLen) |
c5c77ba1 | 5256 | { |
e6e12661 | 5257 | s32 s32Error = 0; |
c5c77ba1 JK |
5258 | tstrWID astrWIDList[2]; |
5259 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; | |
5260 | ||
d85f5326 | 5261 | astrWIDList[0].u16WIDid = (u16)WID_SITE_SURVEY_RESULTS; |
c5c77ba1 JK |
5262 | astrWIDList[0].enuWIDtype = WID_STR; |
5263 | astrWIDList[0].ps8WidVal = ppu8RcvdSiteSurveyResults[0]; | |
5264 | astrWIDList[0].s32ValueSize = u32MaxSiteSrvyFragLen; | |
5265 | ||
d85f5326 | 5266 | astrWIDList[1].u16WIDid = (u16)WID_SITE_SURVEY_RESULTS; |
c5c77ba1 JK |
5267 | astrWIDList[1].enuWIDtype = WID_STR; |
5268 | astrWIDList[1].ps8WidVal = ppu8RcvdSiteSurveyResults[1]; | |
5269 | astrWIDList[1].s32ValueSize = u32MaxSiteSrvyFragLen; | |
5270 | ||
d42ab083 JK |
5271 | s32Error = SendConfigPkt(GET_CFG, astrWIDList, 2, true, |
5272 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 JK |
5273 | |
5274 | /*get the value by searching the local copy*/ | |
5275 | if (s32Error) { | |
5276 | PRINT_ER("Failed to send config packet to get survey results\n"); | |
24db713f | 5277 | s32Error = -EINVAL; |
c5c77ba1 JK |
5278 | } |
5279 | ||
5280 | return s32Error; | |
5281 | } | |
5282 | #endif | |
5283 | ||
5284 | /** | |
5285 | * @brief sets a start scan request | |
5286 | * @details | |
5287 | * @param[in,out] handle to the wifi driver, | |
5288 | * @param[in] Scan Source one of the following values | |
5289 | * DEFAULT_SCAN 0 | |
5290 | * USER_SCAN BIT0 | |
5291 | * OBSS_PERIODIC_SCAN BIT1 | |
5292 | * OBSS_ONETIME_SCAN BIT2 | |
5293 | * @return Error code indicating success/failure | |
5294 | * @note | |
5295 | * @author zsalah | |
5296 | * @date 8 March 2012 | |
5297 | * @version 1.0 | |
5298 | */ | |
218dc407 | 5299 | s32 host_int_set_start_scan_req(tstrWILC_WFIDrv *hWFIDrv, u8 scanSource) |
c5c77ba1 | 5300 | { |
e6e12661 | 5301 | s32 s32Error = 0; |
c5c77ba1 JK |
5302 | tstrWID strWID; |
5303 | /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ | |
5304 | ||
d85f5326 | 5305 | strWID.u16WIDid = (u16)WID_START_SCAN_REQ; |
c5c77ba1 | 5306 | strWID.enuWIDtype = WID_CHAR; |
ca356ada | 5307 | strWID.ps8WidVal = (s8 *)&scanSource; |
576917ad | 5308 | strWID.s32ValueSize = sizeof(char); |
c5c77ba1 JK |
5309 | |
5310 | return s32Error; | |
5311 | } | |
5312 | ||
5313 | /** | |
5314 | * @brief host_int_get_start_scan_req | |
5315 | * @details gets a start scan request | |
5316 | * @param[in,out] handle to the wifi driver, | |
5317 | * @param[in] Scan Source one of the following values | |
5318 | * DEFAULT_SCAN 0 | |
5319 | * USER_SCAN BIT0 | |
5320 | * OBSS_PERIODIC_SCAN BIT1 | |
5321 | * OBSS_ONETIME_SCAN BIT2 | |
5322 | * @return Error code indicating success/failure | |
5323 | * @note | |
5324 | * @author zsalah | |
5325 | * @date 8 March 2012 | |
5326 | * @version 1.0 | |
5327 | */ | |
5328 | ||
218dc407 | 5329 | s32 host_int_get_start_scan_req(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8ScanSource) |
c5c77ba1 | 5330 | { |
e6e12661 | 5331 | s32 s32Error = 0; |
c5c77ba1 JK |
5332 | tstrWID strWID; |
5333 | /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ | |
5334 | ||
d85f5326 | 5335 | strWID.u16WIDid = (u16)WID_START_SCAN_REQ; |
c5c77ba1 | 5336 | strWID.enuWIDtype = WID_CHAR; |
ca356ada | 5337 | strWID.ps8WidVal = (s8 *)pu8ScanSource; |
576917ad | 5338 | strWID.s32ValueSize = sizeof(char); |
c5c77ba1 JK |
5339 | |
5340 | return s32Error; | |
5341 | } | |
5342 | ||
5343 | /** | |
5344 | * @brief host_int_set_join_req | |
5345 | * @details sets a join request | |
5346 | * @param[in,out] handle to the wifi driver, | |
5347 | * @param[in] Index of the bss descriptor | |
5348 | * @return Error code indicating success/failure | |
5349 | * @note | |
5350 | * @author zsalah | |
5351 | * @date 8 March 2012 | |
5352 | * @version 1.0 | |
5353 | */ | |
218dc407 | 5354 | s32 host_int_set_join_req(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8bssid, |
057d1e97 | 5355 | const u8 *pu8ssid, size_t ssidLen, |
63d03e47 | 5356 | const u8 *pu8IEs, size_t IEsLen, |
c5c77ba1 | 5357 | tWILCpfConnectResult pfConnectResult, void *pvUserArg, |
63d03e47 GKH |
5358 | u8 u8security, AUTHTYPE_T tenuAuth_type, |
5359 | u8 u8channel, | |
c5c77ba1 JK |
5360 | void *pJoinParams) |
5361 | { | |
e6e12661 | 5362 | s32 s32Error = 0; |
c5c77ba1 | 5363 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 5364 | struct host_if_msg msg; |
c5c77ba1 JK |
5365 | tenuScanConnTimer enuScanConnTimer; |
5366 | ||
24db713f LK |
5367 | if (pstrWFIDrv == NULL || pfConnectResult == NULL) { |
5368 | s32Error = -EFAULT; | |
5369 | PRINT_ER("Driver is null\n"); | |
5370 | return s32Error; | |
5371 | } | |
c5c77ba1 JK |
5372 | |
5373 | if (hWFIDrv == NULL) { | |
24db713f LK |
5374 | PRINT_ER("Driver is null\n"); |
5375 | return -EFAULT; | |
c5c77ba1 JK |
5376 | } |
5377 | ||
5378 | if (pJoinParams == NULL) { | |
5379 | PRINT_ER("Unable to Join - JoinParams is NULL\n"); | |
24db713f | 5380 | return -EFAULT; |
c5c77ba1 | 5381 | } |
24db713f | 5382 | |
c5c77ba1 | 5383 | /* prepare the Connect Message */ |
143eb95a | 5384 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 | 5385 | |
a9f812a6 | 5386 | msg.id = HOST_IF_MSG_CONNECT; |
c5c77ba1 | 5387 | |
410c2489 TC |
5388 | msg.body.strHostIFconnectAttr.u8security = u8security; |
5389 | msg.body.strHostIFconnectAttr.tenuAuth_type = tenuAuth_type; | |
5390 | msg.body.strHostIFconnectAttr.u8channel = u8channel; | |
5391 | msg.body.strHostIFconnectAttr.pfConnectResult = pfConnectResult; | |
5392 | msg.body.strHostIFconnectAttr.pvUserArg = pvUserArg; | |
5393 | msg.body.strHostIFconnectAttr.pJoinParams = pJoinParams; | |
143eb95a | 5394 | msg.drvHandler = hWFIDrv; |
c5c77ba1 JK |
5395 | |
5396 | if (pu8bssid != NULL) { | |
410c2489 TC |
5397 | msg.body.strHostIFconnectAttr.pu8bssid = kmalloc(6, GFP_KERNEL); /* will be deallocated by the receiving thread */ |
5398 | memcpy(msg.body.strHostIFconnectAttr.pu8bssid, | |
c5c77ba1 JK |
5399 | pu8bssid, 6); |
5400 | } | |
5401 | ||
5402 | if (pu8ssid != NULL) { | |
410c2489 TC |
5403 | msg.body.strHostIFconnectAttr.ssidLen = ssidLen; |
5404 | msg.body.strHostIFconnectAttr.pu8ssid = kmalloc(ssidLen, GFP_KERNEL); /* will be deallocated by the receiving thread */ | |
5405 | memcpy(msg.body.strHostIFconnectAttr.pu8ssid, | |
c5c77ba1 JK |
5406 | |
5407 | pu8ssid, ssidLen); | |
5408 | } | |
5409 | ||
5410 | if (pu8IEs != NULL) { | |
410c2489 TC |
5411 | msg.body.strHostIFconnectAttr.IEsLen = IEsLen; |
5412 | msg.body.strHostIFconnectAttr.pu8IEs = kmalloc(IEsLen, GFP_KERNEL); /* will be deallocated by the receiving thread */ | |
5413 | memcpy(msg.body.strHostIFconnectAttr.pu8IEs, | |
c5c77ba1 JK |
5414 | pu8IEs, IEsLen); |
5415 | } | |
78174ada | 5416 | if (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTING) |
c5c77ba1 | 5417 | pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTING; |
78174ada | 5418 | else |
c5c77ba1 JK |
5419 | PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", pstrWFIDrv->enuHostIFstate); |
5420 | ||
5421 | /* send the message */ | |
143eb95a | 5422 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
5423 | if (s32Error) { |
5424 | PRINT_ER("Failed to send message queue: Set join request\n"); | |
24db713f | 5425 | return -EFAULT; |
c5c77ba1 JK |
5426 | } |
5427 | ||
5428 | enuScanConnTimer = CONNECT_TIMER; | |
9eb06643 GKH |
5429 | pstrWFIDrv->hConnectTimer.data = (unsigned long)hWFIDrv; |
5430 | mod_timer(&pstrWFIDrv->hConnectTimer, | |
5431 | jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT)); | |
c5c77ba1 | 5432 | |
c5c77ba1 JK |
5433 | return s32Error; |
5434 | } | |
5435 | ||
5436 | /** | |
5437 | * @brief Flush a join request parameters to FW, but actual connection | |
5438 | * @details The function is called in situation where WILC is connected to AP and | |
5439 | * required to switch to hybrid FW for P2P connection | |
5440 | * @param[in] handle to the wifi driver, | |
5441 | * @return Error code indicating success/failure | |
5442 | * @note | |
5443 | * @author Amr Abdel-Moghny | |
5444 | * @date 19 DEC 2013 | |
5445 | * @version 8.0 | |
5446 | */ | |
5447 | ||
218dc407 | 5448 | s32 host_int_flush_join_req(tstrWILC_WFIDrv *hWFIDrv) |
c5c77ba1 | 5449 | { |
e6e12661 | 5450 | s32 s32Error = 0; |
143eb95a | 5451 | struct host_if_msg msg; |
c5c77ba1 JK |
5452 | |
5453 | if (!gu8FlushedJoinReq) { | |
e6e12661 | 5454 | s32Error = -EFAULT; |
c5c77ba1 JK |
5455 | return s32Error; |
5456 | } | |
5457 | ||
5458 | ||
24db713f LK |
5459 | if (hWFIDrv == NULL) { |
5460 | s32Error = -EFAULT; | |
5461 | PRINT_ER("Driver is null\n"); | |
5462 | return s32Error; | |
5463 | } | |
c5c77ba1 | 5464 | |
a9f812a6 | 5465 | msg.id = HOST_IF_MSG_FLUSH_CONNECT; |
143eb95a | 5466 | msg.drvHandler = hWFIDrv; |
c5c77ba1 JK |
5467 | |
5468 | /* send the message */ | |
143eb95a | 5469 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
5470 | if (s32Error) { |
5471 | PRINT_ER("Failed to send message queue: Flush join request\n"); | |
24db713f | 5472 | return -EFAULT; |
c5c77ba1 JK |
5473 | } |
5474 | ||
c5c77ba1 JK |
5475 | return s32Error; |
5476 | } | |
5477 | ||
5478 | /** | |
5479 | * @brief host_int_disconnect | |
5480 | * @details disconnects from the currently associated network | |
5481 | * @param[in,out] handle to the wifi driver, | |
5482 | * @param[in] Reason Code of the Disconnection | |
5483 | * @return Error code indicating success/failure | |
5484 | * @note | |
5485 | * @author zsalah | |
5486 | * @date 8 March 2012 | |
5487 | * @version 1.0 | |
5488 | */ | |
218dc407 | 5489 | s32 host_int_disconnect(tstrWILC_WFIDrv *hWFIDrv, u16 u16ReasonCode) |
c5c77ba1 | 5490 | { |
e6e12661 | 5491 | s32 s32Error = 0; |
143eb95a | 5492 | struct host_if_msg msg; |
c5c77ba1 JK |
5493 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
5494 | ||
b1413b60 | 5495 | if (pstrWFIDrv == NULL) { |
24db713f LK |
5496 | PRINT_ER("Driver is null\n"); |
5497 | return -EFAULT; | |
c5c77ba1 JK |
5498 | } |
5499 | ||
5500 | /* prepare the Disconnect Message */ | |
143eb95a | 5501 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 | 5502 | |
a9f812a6 | 5503 | msg.id = HOST_IF_MSG_DISCONNECT; |
143eb95a | 5504 | msg.drvHandler = hWFIDrv; |
c5c77ba1 JK |
5505 | |
5506 | /* send the message */ | |
143eb95a | 5507 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
5508 | if (s32Error) |
5509 | PRINT_ER("Failed to send message queue: disconnect\n"); | |
5510 | /* ////////////// */ | |
83383ea3 | 5511 | down(&(pstrWFIDrv->hSemTestDisconnectBlock)); |
c5c77ba1 JK |
5512 | /* /////// */ |
5513 | ||
c5c77ba1 JK |
5514 | return s32Error; |
5515 | } | |
5516 | ||
5517 | /** | |
5518 | * @brief host_int_disconnect_station | |
5519 | * @details disconnects a sta | |
5520 | * @param[in,out] handle to the wifi driver, | |
5521 | * @param[in] Association Id of the station to be disconnected | |
5522 | * @return Error code indicating success/failure | |
5523 | * @note | |
5524 | * @author zsalah | |
5525 | * @date 8 March 2012 | |
5526 | * @version 1.0 | |
5527 | */ | |
218dc407 | 5528 | s32 host_int_disconnect_station(tstrWILC_WFIDrv *hWFIDrv, u8 assoc_id) |
c5c77ba1 | 5529 | { |
e6e12661 | 5530 | s32 s32Error = 0; |
c5c77ba1 JK |
5531 | tstrWID strWID; |
5532 | /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ | |
5533 | ||
d85f5326 | 5534 | strWID.u16WIDid = (u16)WID_DISCONNECT; |
c5c77ba1 | 5535 | strWID.enuWIDtype = WID_CHAR; |
ca356ada | 5536 | strWID.ps8WidVal = (s8 *)&assoc_id; |
576917ad | 5537 | strWID.s32ValueSize = sizeof(char); |
c5c77ba1 JK |
5538 | |
5539 | return s32Error; | |
5540 | } | |
5541 | ||
5542 | /** | |
5543 | * @brief host_int_get_assoc_req_info | |
5544 | * @details gets a Association request info | |
5545 | * @param[in,out] handle to the wifi driver, | |
5546 | * Message containg assoc. req info in the following format | |
5547 | * ------------------------------------------------------------------------ | |
5548 | | Management Frame Format | | |
5549 | ||-------------------------------------------------------------------| | |
5550 | ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS | | |
5551 | ||-------------|--------|--|--|-----|----------------|----------|----| | |
5552 | | 2 |2 |6 |6 |6 | 2 |0 - 2312 | 4 | | |
5553 | ||-------------------------------------------------------------------| | |
5554 | | | | |
5555 | | Association Request Frame - Frame Body | | |
5556 | ||-------------------------------------------------------------------| | |
5557 | | Capability Information | Listen Interval | SSID | Supported Rates | | |
5558 | ||------------------------|-----------------|------|-----------------| | |
5559 | | 2 | 2 | 2-34 | 3-10 | | |
5560 | | --------------------------------------------------------------------- | |
5561 | * @return Error code indicating success/failure | |
5562 | * @note | |
5563 | * @author zsalah | |
5564 | * @date 8 March 2012 | |
5565 | * @version 1.0 | |
5566 | */ | |
5567 | ||
218dc407 | 5568 | s32 host_int_get_assoc_req_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8AssocReqInfo, |
4e4467fd | 5569 | u32 u32AssocReqInfoLen) |
c5c77ba1 | 5570 | { |
e6e12661 | 5571 | s32 s32Error = 0; |
c5c77ba1 JK |
5572 | tstrWID strWID; |
5573 | /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ | |
5574 | ||
d85f5326 | 5575 | strWID.u16WIDid = (u16)WID_ASSOC_REQ_INFO; |
c5c77ba1 JK |
5576 | strWID.enuWIDtype = WID_STR; |
5577 | strWID.ps8WidVal = pu8AssocReqInfo; | |
5578 | strWID.s32ValueSize = u32AssocReqInfoLen; | |
5579 | ||
5580 | ||
5581 | return s32Error; | |
5582 | } | |
5583 | ||
5584 | /** | |
5585 | * @brief gets a Association Response info | |
5586 | * @details | |
5587 | * @param[in,out] handle to the wifi driver, | |
5588 | * Message containg assoc. resp info | |
5589 | * @return Error code indicating success/failure | |
5590 | * @note | |
5591 | * @author zsalah | |
5592 | * @date 8 March 2012 | |
5593 | * @version 1.0 | |
5594 | */ | |
218dc407 | 5595 | s32 host_int_get_assoc_res_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8AssocRespInfo, |
4e4467fd | 5596 | u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen) |
c5c77ba1 | 5597 | { |
e6e12661 | 5598 | s32 s32Error = 0; |
c5c77ba1 JK |
5599 | tstrWID strWID; |
5600 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; | |
5601 | ||
b1413b60 | 5602 | if (pstrWFIDrv == NULL) { |
24db713f LK |
5603 | PRINT_ER("Driver is null\n"); |
5604 | return -EFAULT; | |
c5c77ba1 JK |
5605 | } |
5606 | ||
d85f5326 | 5607 | strWID.u16WIDid = (u16)WID_ASSOC_RES_INFO; |
c5c77ba1 JK |
5608 | strWID.enuWIDtype = WID_STR; |
5609 | strWID.ps8WidVal = pu8AssocRespInfo; | |
5610 | strWID.s32ValueSize = u32MaxAssocRespInfoLen; | |
5611 | ||
5612 | ||
5613 | /* Sending Configuration packet */ | |
d42ab083 JK |
5614 | s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, |
5615 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 | 5616 | if (s32Error) { |
c5c77ba1 | 5617 | *pu32RcvdAssocRespInfoLen = 0; |
24db713f LK |
5618 | PRINT_ER("Failed to send association response config packet\n"); |
5619 | return -EINVAL; | |
c5c77ba1 JK |
5620 | } else { |
5621 | *pu32RcvdAssocRespInfoLen = strWID.s32ValueSize; | |
5622 | } | |
5623 | ||
c5c77ba1 JK |
5624 | return s32Error; |
5625 | } | |
5626 | ||
5627 | /** | |
5628 | * @brief gets a Association Response info | |
5629 | * @details Valid only in STA mode. This function gives the RSSI | |
5630 | * values observed in all the channels at the time of scanning. | |
5631 | * The length of the field is 1 greater that the total number of | |
5632 | * channels supported. Byte 0 contains the number of channels while | |
5633 | * each of Byte N contains the observed RSSI value for the channel index N. | |
5634 | * @param[in,out] handle to the wifi driver, | |
5635 | * array of scanned channels' RSSI | |
5636 | * @return Error code indicating success/failure | |
5637 | * @note | |
5638 | * @author zsalah | |
5639 | * @date 8 March 2012 | |
5640 | * @version 1.0 | |
5641 | */ | |
218dc407 | 5642 | s32 host_int_get_rx_power_level(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8RxPowerLevel, |
4e4467fd | 5643 | u32 u32RxPowerLevelLen) |
c5c77ba1 | 5644 | { |
e6e12661 | 5645 | s32 s32Error = 0; |
c5c77ba1 JK |
5646 | tstrWID strWID; |
5647 | /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */ | |
5648 | ||
d85f5326 | 5649 | strWID.u16WIDid = (u16)WID_RX_POWER_LEVEL; |
c5c77ba1 JK |
5650 | strWID.enuWIDtype = WID_STR; |
5651 | strWID.ps8WidVal = pu8RxPowerLevel; | |
5652 | strWID.s32ValueSize = u32RxPowerLevelLen; | |
5653 | ||
5654 | ||
5655 | return s32Error; | |
5656 | } | |
5657 | ||
5658 | /** | |
5659 | * @brief sets a channel | |
5660 | * @details | |
5661 | * @param[in,out] handle to the wifi driver, | |
5662 | * @param[in] Index of the channel to be set | |
5663 | *|-------------------------------------------------------------------| | |
5664 | | CHANNEL1 CHANNEL2 .... CHANNEL14 | | |
5665 | | Input: 1 2 14 | | |
5666 | ||-------------------------------------------------------------------| | |
5667 | * @return Error code indicating success/failure | |
5668 | * @note | |
5669 | * @author zsalah | |
5670 | * @date 8 March 2012 | |
5671 | * @version 1.0 | |
5672 | */ | |
218dc407 | 5673 | s32 host_int_set_mac_chnl_num(tstrWILC_WFIDrv *hWFIDrv, u8 u8ChNum) |
c5c77ba1 | 5674 | { |
e6e12661 | 5675 | s32 s32Error = 0; |
c5c77ba1 | 5676 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 5677 | struct host_if_msg msg; |
c5c77ba1 | 5678 | |
24db713f LK |
5679 | if (pstrWFIDrv == NULL) { |
5680 | PRINT_ER("driver is null\n"); | |
5681 | return -EFAULT; | |
5682 | } | |
c5c77ba1 JK |
5683 | |
5684 | /* prepare the set channel message */ | |
143eb95a | 5685 | memset(&msg, 0, sizeof(struct host_if_msg)); |
a9f812a6 | 5686 | msg.id = HOST_IF_MSG_SET_CHANNEL; |
410c2489 | 5687 | msg.body.strHostIFSetChan.u8SetChan = u8ChNum; |
143eb95a | 5688 | msg.drvHandler = hWFIDrv; |
c5c77ba1 | 5689 | |
143eb95a | 5690 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
24db713f LK |
5691 | if (s32Error) { |
5692 | PRINT_ER("wilc mq send fail\n"); | |
5693 | s32Error = -EINVAL; | |
c5c77ba1 JK |
5694 | } |
5695 | ||
5696 | return s32Error; | |
5697 | } | |
5698 | ||
5699 | ||
fb4ec9ca | 5700 | s32 host_int_wait_msg_queue_idle(void) |
c5c77ba1 | 5701 | { |
e6e12661 | 5702 | s32 s32Error = 0; |
c5c77ba1 | 5703 | |
143eb95a | 5704 | struct host_if_msg msg; |
c5c77ba1 JK |
5705 | |
5706 | /* prepare the set driver handler message */ | |
5707 | ||
143eb95a | 5708 | memset(&msg, 0, sizeof(struct host_if_msg)); |
a9f812a6 | 5709 | msg.id = HOST_IF_MSG_Q_IDLE; |
143eb95a | 5710 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
24db713f LK |
5711 | if (s32Error) { |
5712 | PRINT_ER("wilc mq send fail\n"); | |
5713 | s32Error = -EINVAL; | |
c5c77ba1 JK |
5714 | } |
5715 | ||
5716 | /* wait untill MSG Q is empty */ | |
83383ea3 | 5717 | down(&hWaitResponse); |
c5c77ba1 JK |
5718 | |
5719 | return s32Error; | |
5720 | ||
5721 | } | |
5722 | ||
218dc407 | 5723 | s32 host_int_set_wfi_drv_handler(tstrWILC_WFIDrv *u32address) |
c5c77ba1 | 5724 | { |
e6e12661 | 5725 | s32 s32Error = 0; |
c5c77ba1 | 5726 | |
143eb95a | 5727 | struct host_if_msg msg; |
c5c77ba1 JK |
5728 | |
5729 | ||
5730 | /* prepare the set driver handler message */ | |
5731 | ||
143eb95a | 5732 | memset(&msg, 0, sizeof(struct host_if_msg)); |
a9f812a6 | 5733 | msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER; |
410c2489 | 5734 | msg.body.strHostIfSetDrvHandler.u32Address = get_id_from_handler(u32address); |
143eb95a | 5735 | msg.drvHandler = u32address; |
c5c77ba1 | 5736 | |
143eb95a | 5737 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
24db713f LK |
5738 | if (s32Error) { |
5739 | PRINT_ER("wilc mq send fail\n"); | |
5740 | s32Error = -EINVAL; | |
c5c77ba1 JK |
5741 | } |
5742 | ||
5743 | return s32Error; | |
5744 | } | |
5745 | ||
5746 | ||
5747 | ||
218dc407 | 5748 | s32 host_int_set_operation_mode(tstrWILC_WFIDrv *hWFIDrv, u32 u32mode) |
c5c77ba1 | 5749 | { |
e6e12661 | 5750 | s32 s32Error = 0; |
c5c77ba1 | 5751 | |
143eb95a | 5752 | struct host_if_msg msg; |
c5c77ba1 JK |
5753 | |
5754 | ||
5755 | /* prepare the set driver handler message */ | |
5756 | ||
143eb95a | 5757 | memset(&msg, 0, sizeof(struct host_if_msg)); |
a9f812a6 | 5758 | msg.id = HOST_IF_MSG_SET_OPERATION_MODE; |
410c2489 | 5759 | msg.body.strHostIfSetOperationMode.u32Mode = u32mode; |
143eb95a | 5760 | msg.drvHandler = hWFIDrv; |
c5c77ba1 | 5761 | |
143eb95a | 5762 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
24db713f LK |
5763 | if (s32Error) { |
5764 | PRINT_ER("wilc mq send fail\n"); | |
5765 | s32Error = -EINVAL; | |
c5c77ba1 JK |
5766 | } |
5767 | ||
5768 | return s32Error; | |
5769 | } | |
5770 | ||
5771 | /** | |
5772 | * @brief gets the current channel index | |
5773 | * @details | |
5774 | * @param[in,out] handle to the wifi driver, | |
5775 | * current channel index | |
5776 | *|-----------------------------------------------------------------------| | |
5777 | | CHANNEL1 CHANNEL2 .... CHANNEL14 | | |
5778 | | Input: 1 2 14 | | |
5779 | ||-----------------------------------------------------------------------| | |
5780 | * @return Error code indicating success/failure | |
5781 | * @note | |
5782 | * @author zsalah | |
5783 | * @date 8 March 2012 | |
5784 | * @version 1.0 | |
5785 | */ | |
218dc407 | 5786 | s32 host_int_get_host_chnl_num(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8ChNo) |
c5c77ba1 | 5787 | { |
e6e12661 | 5788 | s32 s32Error = 0; |
c5c77ba1 | 5789 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 5790 | struct host_if_msg msg; |
c5c77ba1 | 5791 | |
b1413b60 | 5792 | if (pstrWFIDrv == NULL) { |
24db713f LK |
5793 | PRINT_ER("driver is null\n"); |
5794 | return -EFAULT; | |
c5c77ba1 JK |
5795 | } |
5796 | ||
5797 | /* prepare the Get Channel Message */ | |
143eb95a | 5798 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 | 5799 | |
a9f812a6 | 5800 | msg.id = HOST_IF_MSG_GET_CHNL; |
143eb95a | 5801 | msg.drvHandler = hWFIDrv; |
c5c77ba1 JK |
5802 | |
5803 | /* send the message */ | |
143eb95a | 5804 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
c5c77ba1 | 5805 | if (s32Error) |
24db713f | 5806 | PRINT_ER("wilc mq send fail\n"); |
83383ea3 | 5807 | down(&(pstrWFIDrv->hSemGetCHNL)); |
c5c77ba1 JK |
5808 | /* gu8Chnl = 11; */ |
5809 | ||
5810 | *pu8ChNo = gu8Chnl; | |
5811 | ||
c5c77ba1 JK |
5812 | return s32Error; |
5813 | ||
5814 | ||
5815 | } | |
5816 | ||
5817 | ||
5818 | /** | |
5819 | * @brief host_int_test_set_int_wid | |
5820 | * @details Test function for setting wids | |
4e4467fd | 5821 | * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr |
c5c77ba1 JK |
5822 | * @return Error code indicating success/failure |
5823 | * @note | |
5824 | * @author zsalah | |
5825 | * @date 8 March 2012 | |
5826 | * @version 1.0 | |
5827 | */ | |
218dc407 | 5828 | s32 host_int_test_set_int_wid(tstrWILC_WFIDrv *hWFIDrv, u32 u32TestMemAddr) |
c5c77ba1 | 5829 | { |
e6e12661 | 5830 | s32 s32Error = 0; |
c5c77ba1 JK |
5831 | tstrWID strWID; |
5832 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; | |
5833 | ||
5834 | ||
b1413b60 | 5835 | if (pstrWFIDrv == NULL) { |
24db713f LK |
5836 | PRINT_ER("driver is null\n"); |
5837 | return -EFAULT; | |
c5c77ba1 JK |
5838 | } |
5839 | ||
5840 | /*prepare configuration packet*/ | |
d85f5326 | 5841 | strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS; |
c5c77ba1 | 5842 | strWID.enuWIDtype = WID_INT; |
576917ad | 5843 | strWID.ps8WidVal = (char *)&u32TestMemAddr; |
4e4467fd | 5844 | strWID.s32ValueSize = sizeof(u32); |
c5c77ba1 JK |
5845 | |
5846 | /*Sending Cfg*/ | |
d42ab083 JK |
5847 | s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, |
5848 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 | 5849 | if (s32Error) { |
24db713f LK |
5850 | PRINT_ER("Failed to set wid value\n"); |
5851 | return -EINVAL; | |
c5c77ba1 JK |
5852 | } else { |
5853 | PRINT_D(HOSTINF_DBG, "Successfully set wid value\n"); | |
5854 | ||
5855 | } | |
5856 | ||
c5c77ba1 JK |
5857 | return s32Error; |
5858 | } | |
5859 | ||
c5c77ba1 JK |
5860 | /** |
5861 | * @brief host_int_get_inactive_time | |
5862 | * @details | |
5863 | * @param[in,out] handle to the wifi driver, | |
5864 | * current sta macaddress, inactive_time | |
5865 | * @return | |
5866 | * @note | |
5867 | * @author | |
5868 | * @date | |
5869 | * @version 1.0 | |
5870 | */ | |
218dc407 | 5871 | s32 host_int_get_inactive_time(tstrWILC_WFIDrv *hWFIDrv, const u8 *mac, u32 *pu32InactiveTime) |
c5c77ba1 | 5872 | { |
e6e12661 | 5873 | s32 s32Error = 0; |
c5c77ba1 | 5874 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 5875 | struct host_if_msg msg; |
c5c77ba1 | 5876 | |
b1413b60 | 5877 | if (pstrWFIDrv == NULL) { |
24db713f LK |
5878 | PRINT_ER("driver is null\n"); |
5879 | return -EFAULT; | |
c5c77ba1 JK |
5880 | } |
5881 | ||
143eb95a | 5882 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
5883 | |
5884 | ||
410c2489 | 5885 | memcpy(msg.body.strHostIfStaInactiveT.mac, |
c5c77ba1 JK |
5886 | mac, ETH_ALEN); |
5887 | ||
a9f812a6 | 5888 | msg.id = HOST_IF_MSG_GET_INACTIVETIME; |
143eb95a | 5889 | msg.drvHandler = hWFIDrv; |
c5c77ba1 JK |
5890 | |
5891 | /* send the message */ | |
143eb95a | 5892 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
5893 | if (s32Error) |
5894 | PRINT_ER("Failed to send get host channel param's message queue "); | |
5895 | ||
83383ea3 | 5896 | down(&(pstrWFIDrv->hSemInactiveTime)); |
c5c77ba1 JK |
5897 | |
5898 | *pu32InactiveTime = gu32InactiveTime; | |
5899 | ||
c5c77ba1 JK |
5900 | return s32Error; |
5901 | } | |
108b3439 | 5902 | |
c5c77ba1 JK |
5903 | /** |
5904 | * @brief host_int_test_get_int_wid | |
5905 | * @details Test function for getting wids | |
4e4467fd | 5906 | * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32* pu32TestMemAddr |
c5c77ba1 JK |
5907 | * @return Error code indicating success/failure |
5908 | * @note | |
5909 | * @author zsalah | |
5910 | * @date 8 March 2012 | |
5911 | * @version 1.0 | |
5912 | */ | |
218dc407 | 5913 | s32 host_int_test_get_int_wid(tstrWILC_WFIDrv *hWFIDrv, u32 *pu32TestMemAddr) |
c5c77ba1 JK |
5914 | { |
5915 | ||
e6e12661 | 5916 | s32 s32Error = 0; |
c5c77ba1 JK |
5917 | tstrWID strWID; |
5918 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; | |
5919 | ||
5920 | ||
b1413b60 | 5921 | if (pstrWFIDrv == NULL) { |
24db713f LK |
5922 | PRINT_ER("driver is null\n"); |
5923 | return -EFAULT; | |
c5c77ba1 JK |
5924 | } |
5925 | ||
d85f5326 | 5926 | strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS; |
c5c77ba1 | 5927 | strWID.enuWIDtype = WID_INT; |
ca356ada | 5928 | strWID.ps8WidVal = (s8 *)pu32TestMemAddr; |
4e4467fd | 5929 | strWID.s32ValueSize = sizeof(u32); |
c5c77ba1 | 5930 | |
d42ab083 JK |
5931 | s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, |
5932 | get_id_from_handler(pstrWFIDrv)); | |
c5c77ba1 JK |
5933 | /*get the value by searching the local copy*/ |
5934 | if (s32Error) { | |
24db713f LK |
5935 | PRINT_ER("Failed to get wid value\n"); |
5936 | return -EINVAL; | |
c5c77ba1 JK |
5937 | } else { |
5938 | PRINT_D(HOSTINF_DBG, "Successfully got wid value\n"); | |
5939 | ||
5940 | } | |
5941 | ||
c5c77ba1 JK |
5942 | return s32Error; |
5943 | } | |
5944 | ||
5945 | ||
5946 | /** | |
5947 | * @brief host_int_get_rssi | |
5948 | * @details gets the currently maintained RSSI value for the station. | |
5949 | * The received signal strength value in dB. | |
5950 | * The range of valid values is -128 to 0. | |
5951 | * @param[in,out] handle to the wifi driver, | |
5952 | * rssi value in dB | |
5953 | * @return Error code indicating success/failure | |
5954 | * @note | |
5955 | * @author zsalah | |
5956 | * @date 8 March 2012 | |
5957 | * @version 1.0 | |
5958 | */ | |
218dc407 | 5959 | s32 host_int_get_rssi(tstrWILC_WFIDrv *hWFIDrv, s8 *ps8Rssi) |
c5c77ba1 | 5960 | { |
e6e12661 | 5961 | s32 s32Error = 0; |
143eb95a | 5962 | struct host_if_msg msg; |
c5c77ba1 JK |
5963 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
5964 | ||
5965 | ||
5966 | /* prepare the Get RSSI Message */ | |
143eb95a | 5967 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 | 5968 | |
a9f812a6 | 5969 | msg.id = HOST_IF_MSG_GET_RSSI; |
143eb95a | 5970 | msg.drvHandler = hWFIDrv; |
c5c77ba1 JK |
5971 | |
5972 | /* send the message */ | |
143eb95a | 5973 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
5974 | if (s32Error) { |
5975 | PRINT_ER("Failed to send get host channel param's message queue "); | |
e6e12661 | 5976 | return -EFAULT; |
c5c77ba1 JK |
5977 | } |
5978 | ||
83383ea3 | 5979 | down(&(pstrWFIDrv->hSemGetRSSI)); |
c5c77ba1 JK |
5980 | |
5981 | ||
5982 | if (ps8Rssi == NULL) { | |
5983 | PRINT_ER("RSS pointer value is null"); | |
e6e12661 | 5984 | return -EFAULT; |
c5c77ba1 JK |
5985 | } |
5986 | ||
5987 | ||
5988 | *ps8Rssi = gs8Rssi; | |
5989 | ||
5990 | ||
5991 | return s32Error; | |
5992 | } | |
5993 | ||
218dc407 | 5994 | s32 host_int_get_link_speed(tstrWILC_WFIDrv *hWFIDrv, s8 *ps8lnkspd) |
c5c77ba1 | 5995 | { |
143eb95a | 5996 | struct host_if_msg msg; |
e6e12661 | 5997 | s32 s32Error = 0; |
c5c77ba1 JK |
5998 | |
5999 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; | |
6000 | ||
6001 | ||
6002 | ||
6003 | /* prepare the Get LINKSPEED Message */ | |
143eb95a | 6004 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 | 6005 | |
a9f812a6 | 6006 | msg.id = HOST_IF_MSG_GET_LINKSPEED; |
143eb95a | 6007 | msg.drvHandler = hWFIDrv; |
c5c77ba1 JK |
6008 | |
6009 | /* send the message */ | |
143eb95a | 6010 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
6011 | if (s32Error) { |
6012 | PRINT_ER("Failed to send GET_LINKSPEED to message queue "); | |
e6e12661 | 6013 | return -EFAULT; |
c5c77ba1 JK |
6014 | } |
6015 | ||
83383ea3 | 6016 | down(&(pstrWFIDrv->hSemGetLINKSPEED)); |
c5c77ba1 JK |
6017 | |
6018 | ||
6019 | if (ps8lnkspd == NULL) { | |
6020 | PRINT_ER("LINKSPEED pointer value is null"); | |
e6e12661 | 6021 | return -EFAULT; |
c5c77ba1 JK |
6022 | } |
6023 | ||
6024 | ||
6025 | *ps8lnkspd = gs8lnkspd; | |
6026 | ||
6027 | ||
6028 | return s32Error; | |
6029 | } | |
6030 | ||
218dc407 | 6031 | s32 host_int_get_statistics(tstrWILC_WFIDrv *hWFIDrv, tstrStatistics *pstrStatistics) |
c5c77ba1 | 6032 | { |
e6e12661 | 6033 | s32 s32Error = 0; |
143eb95a | 6034 | struct host_if_msg msg; |
c5c77ba1 JK |
6035 | |
6036 | ||
6037 | /* prepare the Get RSSI Message */ | |
143eb95a | 6038 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 | 6039 | |
a9f812a6 | 6040 | msg.id = HOST_IF_MSG_GET_STATISTICS; |
410c2489 | 6041 | msg.body.pUserData = (char *)pstrStatistics; |
143eb95a | 6042 | msg.drvHandler = hWFIDrv; |
c5c77ba1 | 6043 | /* send the message */ |
143eb95a | 6044 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
6045 | if (s32Error) { |
6046 | PRINT_ER("Failed to send get host channel param's message queue "); | |
e6e12661 | 6047 | return -EFAULT; |
c5c77ba1 JK |
6048 | } |
6049 | ||
83383ea3 | 6050 | down(&hWaitResponse); |
c5c77ba1 JK |
6051 | return s32Error; |
6052 | } | |
6053 | ||
6054 | ||
6055 | /** | |
6056 | * @brief host_int_scan | |
6057 | * @details scans a set of channels | |
6058 | * @param[in,out] handle to the wifi driver, | |
6059 | * @param[in] Scan source | |
6060 | * Scan Type PASSIVE_SCAN = 0, | |
6061 | * ACTIVE_SCAN = 1 | |
6062 | * Channels Array | |
6063 | * Channels Array length | |
6064 | * Scan Callback function | |
6065 | * @return Error code indicating success/failure | |
6066 | * @note | |
6067 | * @author zsalah | |
6068 | * @date 8 March 2012 | |
6069 | * @version 1.0 | |
6070 | */ | |
218dc407 | 6071 | s32 host_int_scan(tstrWILC_WFIDrv *hWFIDrv, u8 u8ScanSource, |
63d03e47 GKH |
6072 | u8 u8ScanType, u8 *pu8ChnlFreqList, |
6073 | u8 u8ChnlListLen, const u8 *pu8IEs, | |
c5c77ba1 JK |
6074 | size_t IEsLen, tWILCpfScanResult ScanResult, |
6075 | void *pvUserArg, tstrHiddenNetwork *pstrHiddenNetwork) | |
6076 | { | |
e6e12661 | 6077 | s32 s32Error = 0; |
c5c77ba1 | 6078 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 6079 | struct host_if_msg msg; |
c5c77ba1 JK |
6080 | tenuScanConnTimer enuScanConnTimer; |
6081 | ||
24db713f LK |
6082 | if (pstrWFIDrv == NULL || ScanResult == NULL) { |
6083 | PRINT_ER("pstrWFIDrv or ScanResult = NULL\n"); | |
6084 | return -EFAULT; | |
6085 | } | |
c5c77ba1 JK |
6086 | |
6087 | /* prepare the Scan Message */ | |
143eb95a | 6088 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 | 6089 | |
a9f812a6 | 6090 | msg.id = HOST_IF_MSG_SCAN; |
c5c77ba1 JK |
6091 | |
6092 | if (pstrHiddenNetwork != NULL) { | |
410c2489 TC |
6093 | msg.body.strHostIFscanAttr.strHiddenNetwork.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo; |
6094 | msg.body.strHostIFscanAttr.strHiddenNetwork.u8ssidnum = pstrHiddenNetwork->u8ssidnum; | |
c5c77ba1 JK |
6095 | |
6096 | } else | |
6097 | PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n"); | |
6098 | ||
143eb95a | 6099 | msg.drvHandler = hWFIDrv; |
410c2489 TC |
6100 | msg.body.strHostIFscanAttr.u8ScanSource = u8ScanSource; |
6101 | msg.body.strHostIFscanAttr.u8ScanType = u8ScanType; | |
6102 | msg.body.strHostIFscanAttr.pfScanResult = ScanResult; | |
6103 | msg.body.strHostIFscanAttr.pvUserArg = pvUserArg; | |
6104 | ||
6105 | msg.body.strHostIFscanAttr.u8ChnlListLen = u8ChnlListLen; | |
6106 | msg.body.strHostIFscanAttr.pu8ChnlFreqList = kmalloc(u8ChnlListLen, GFP_KERNEL); /* will be deallocated by the receiving thread */ | |
6107 | memcpy(msg.body.strHostIFscanAttr.pu8ChnlFreqList, | |
c5c77ba1 JK |
6108 | pu8ChnlFreqList, u8ChnlListLen); |
6109 | ||
410c2489 TC |
6110 | msg.body.strHostIFscanAttr.IEsLen = IEsLen; |
6111 | msg.body.strHostIFscanAttr.pu8IEs = kmalloc(IEsLen, GFP_KERNEL); /* will be deallocated by the receiving thread */ | |
6112 | memcpy(msg.body.strHostIFscanAttr.pu8IEs, | |
c5c77ba1 JK |
6113 | pu8IEs, IEsLen); |
6114 | ||
6115 | /* send the message */ | |
143eb95a | 6116 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
c5c77ba1 | 6117 | if (s32Error) { |
24db713f LK |
6118 | PRINT_ER("Error in sending message queue\n"); |
6119 | return -EINVAL; | |
c5c77ba1 JK |
6120 | } |
6121 | ||
6122 | enuScanConnTimer = SCAN_TIMER; | |
6123 | PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n"); | |
9eb06643 GKH |
6124 | pstrWFIDrv->hScanTimer.data = (unsigned long)hWFIDrv; |
6125 | mod_timer(&pstrWFIDrv->hScanTimer, | |
6126 | jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT)); | |
c5c77ba1 | 6127 | |
c5c77ba1 JK |
6128 | return s32Error; |
6129 | ||
6130 | } | |
6131 | /** | |
6132 | * @brief hif_set_cfg | |
6133 | * @details sets configuration wids values | |
6134 | * @param[in,out] handle to the wifi driver, | |
6135 | * @param[in] WID, WID value | |
6136 | * @return Error code indicating success/failure | |
6137 | * @note | |
6138 | * @author zsalah | |
6139 | * @date 8 March 2012 | |
6140 | * @version 1.0 | |
6141 | */ | |
218dc407 | 6142 | s32 hif_set_cfg(tstrWILC_WFIDrv *hWFIDrv, tstrCfgParamVal *pstrCfgParamVal) |
c5c77ba1 JK |
6143 | { |
6144 | ||
e6e12661 | 6145 | s32 s32Error = 0; |
c5c77ba1 JK |
6146 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
6147 | ||
143eb95a | 6148 | struct host_if_msg msg; |
c5c77ba1 JK |
6149 | |
6150 | ||
24db713f LK |
6151 | if (pstrWFIDrv == NULL) { |
6152 | PRINT_ER("pstrWFIDrv NULL\n"); | |
6153 | return -EFAULT; | |
6154 | } | |
c5c77ba1 | 6155 | /* prepare the WiphyParams Message */ |
143eb95a | 6156 | memset(&msg, 0, sizeof(struct host_if_msg)); |
a9f812a6 | 6157 | msg.id = HOST_IF_MSG_CFG_PARAMS; |
410c2489 | 6158 | msg.body.strHostIFCfgParamAttr.pstrCfgParamVal = *pstrCfgParamVal; |
143eb95a | 6159 | msg.drvHandler = hWFIDrv; |
c5c77ba1 | 6160 | |
143eb95a | 6161 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
c5c77ba1 | 6162 | |
c5c77ba1 JK |
6163 | return s32Error; |
6164 | ||
6165 | } | |
6166 | ||
6167 | ||
6168 | /** | |
6169 | * @brief hif_get_cfg | |
6170 | * @details gets configuration wids values | |
6171 | * @param[in,out] handle to the wifi driver, | |
6172 | * WID value | |
6173 | * @param[in] WID, | |
6174 | * @return Error code indicating success/failure | |
6175 | * @note | |
6176 | * @author zsalah | |
6177 | * | |
6178 | * @date 8 March 2012 | |
6179 | * @version 1.0 | |
6180 | */ | |
218dc407 | 6181 | s32 hif_get_cfg(tstrWILC_WFIDrv *hWFIDrv, u16 u16WID, u16 *pu16WID_Value) |
c5c77ba1 | 6182 | { |
e6e12661 | 6183 | s32 s32Error = 0; |
c5c77ba1 JK |
6184 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
6185 | ||
83383ea3 | 6186 | down(&(pstrWFIDrv->gtOsCfgValuesSem)); |
c5c77ba1 | 6187 | |
b1413b60 | 6188 | if (pstrWFIDrv == NULL) { |
24db713f LK |
6189 | PRINT_ER("pstrWFIDrv NULL\n"); |
6190 | return -EFAULT; | |
c5c77ba1 JK |
6191 | } |
6192 | PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n"); | |
6193 | switch (u16WID) { | |
6194 | ||
6195 | case WID_BSS_TYPE: | |
d85f5326 | 6196 | *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.bss_type; |
c5c77ba1 JK |
6197 | break; |
6198 | ||
6199 | case WID_AUTH_TYPE: | |
d85f5326 | 6200 | *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.auth_type; |
c5c77ba1 JK |
6201 | break; |
6202 | ||
6203 | case WID_AUTH_TIMEOUT: | |
6204 | *pu16WID_Value = pstrWFIDrv->strCfgValues.auth_timeout; | |
6205 | break; | |
6206 | ||
6207 | case WID_POWER_MANAGEMENT: | |
d85f5326 | 6208 | *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.power_mgmt_mode; |
c5c77ba1 JK |
6209 | break; |
6210 | ||
6211 | case WID_SHORT_RETRY_LIMIT: | |
6212 | *pu16WID_Value = pstrWFIDrv->strCfgValues.short_retry_limit; | |
6213 | break; | |
6214 | ||
6215 | case WID_LONG_RETRY_LIMIT: | |
6216 | *pu16WID_Value = pstrWFIDrv->strCfgValues.long_retry_limit; | |
6217 | break; | |
6218 | ||
6219 | case WID_FRAG_THRESHOLD: | |
6220 | *pu16WID_Value = pstrWFIDrv->strCfgValues.frag_threshold; | |
6221 | break; | |
6222 | ||
6223 | case WID_RTS_THRESHOLD: | |
6224 | *pu16WID_Value = pstrWFIDrv->strCfgValues.rts_threshold; | |
6225 | break; | |
6226 | ||
6227 | case WID_PREAMBLE: | |
d85f5326 | 6228 | *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.preamble_type; |
c5c77ba1 JK |
6229 | break; |
6230 | ||
6231 | case WID_SHORT_SLOT_ALLOWED: | |
d85f5326 | 6232 | *pu16WID_Value = (u16) pstrWFIDrv->strCfgValues.short_slot_allowed; |
c5c77ba1 JK |
6233 | break; |
6234 | ||
6235 | case WID_11N_TXOP_PROT_DISABLE: | |
d85f5326 | 6236 | *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.txop_prot_disabled; |
c5c77ba1 JK |
6237 | break; |
6238 | ||
6239 | case WID_BEACON_INTERVAL: | |
6240 | *pu16WID_Value = pstrWFIDrv->strCfgValues.beacon_interval; | |
6241 | break; | |
6242 | ||
6243 | case WID_DTIM_PERIOD: | |
d85f5326 | 6244 | *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.dtim_period; |
c5c77ba1 JK |
6245 | break; |
6246 | ||
6247 | case WID_SITE_SURVEY: | |
d85f5326 | 6248 | *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.site_survey_enabled; |
c5c77ba1 JK |
6249 | break; |
6250 | ||
6251 | case WID_SITE_SURVEY_SCAN_TIME: | |
6252 | *pu16WID_Value = pstrWFIDrv->strCfgValues.site_survey_scan_time; | |
6253 | break; | |
6254 | ||
6255 | case WID_ACTIVE_SCAN_TIME: | |
6256 | *pu16WID_Value = pstrWFIDrv->strCfgValues.active_scan_time; | |
6257 | break; | |
6258 | ||
6259 | case WID_PASSIVE_SCAN_TIME: | |
6260 | *pu16WID_Value = pstrWFIDrv->strCfgValues.passive_scan_time; | |
6261 | break; | |
6262 | ||
6263 | case WID_CURRENT_TX_RATE: | |
6264 | *pu16WID_Value = pstrWFIDrv->strCfgValues.curr_tx_rate; | |
6265 | break; | |
6266 | ||
6267 | default: | |
6268 | break; | |
6269 | } | |
6270 | ||
83383ea3 | 6271 | up(&(pstrWFIDrv->gtOsCfgValuesSem)); |
c5c77ba1 | 6272 | |
c5c77ba1 JK |
6273 | return s32Error; |
6274 | ||
6275 | } | |
6276 | ||
6277 | /*****************************************************************************/ | |
6278 | /* Notification Functions */ | |
6279 | /*****************************************************************************/ | |
6280 | /** | |
6281 | * @brief notifies host with join and leave requests | |
6282 | * @details This function prepares an Information frame having the | |
6283 | * information about a joining/leaving station. | |
6284 | * @param[in,out] handle to the wifi driver, | |
6285 | * @param[in] 6 byte Sta Adress | |
6286 | * Join or leave flag: | |
6287 | * Join = 1, | |
6288 | * Leave =0 | |
6289 | * @return Error code indicating success/failure | |
6290 | * @note | |
6291 | * @author zsalah | |
6292 | * @date 8 March 2012 | |
6293 | * @version 1.0 | |
6294 | */ | |
6295 | void host_int_send_join_leave_info_to_host | |
72ed4dc7 | 6296 | (u16 assocId, u8 *stationAddr, bool joining) |
c5c77ba1 JK |
6297 | { |
6298 | } | |
6299 | /** | |
6300 | * @brief notifies host with stations found in scan | |
6301 | * @details sends the beacon/probe response from scan | |
6302 | * @param[in,out] handle to the wifi driver, | |
6303 | * @param[in] Sta Address, | |
6304 | * Frame length, | |
6305 | * Rssi of the Station found | |
6306 | * @return Error code indicating success/failure | |
6307 | * @note | |
6308 | * @author zsalah | |
6309 | * @date 8 March 2012 | |
6310 | * @version 1.0 | |
6311 | */ | |
6312 | ||
93dee8ee | 6313 | static void GetPeriodicRSSI(unsigned long arg) |
c5c77ba1 | 6314 | { |
93dee8ee | 6315 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)arg; |
78c87591 | 6316 | |
c5c77ba1 JK |
6317 | if (pstrWFIDrv == NULL) { |
6318 | PRINT_ER("Driver handler is NULL\n"); | |
6319 | return; | |
6320 | } | |
6321 | ||
6322 | if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) { | |
e6e12661 | 6323 | s32 s32Error = 0; |
143eb95a | 6324 | struct host_if_msg msg; |
c5c77ba1 JK |
6325 | |
6326 | /* prepare the Get RSSI Message */ | |
143eb95a | 6327 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 | 6328 | |
a9f812a6 | 6329 | msg.id = HOST_IF_MSG_GET_RSSI; |
143eb95a | 6330 | msg.drvHandler = pstrWFIDrv; |
c5c77ba1 JK |
6331 | |
6332 | /* send the message */ | |
143eb95a | 6333 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
6334 | if (s32Error) { |
6335 | PRINT_ER("Failed to send get host channel param's message queue "); | |
6336 | return; | |
6337 | } | |
6338 | } | |
9eb06643 GKH |
6339 | g_hPeriodicRSSI.data = (unsigned long)pstrWFIDrv; |
6340 | mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000)); | |
c5c77ba1 JK |
6341 | } |
6342 | ||
6343 | ||
6344 | void host_int_send_network_info_to_host | |
ca356ada | 6345 | (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi) |
c5c77ba1 JK |
6346 | { |
6347 | } | |
6348 | /** | |
6349 | * @brief host_int_init | |
6350 | * @details host interface initialization function | |
6351 | * @param[in,out] handle to the wifi driver, | |
6352 | * @note | |
6353 | * @author zsalah | |
6354 | * @date 8 March 2012 | |
6355 | * @version 1.0 | |
6356 | */ | |
4e4467fd | 6357 | static u32 clients_count; |
c5c77ba1 | 6358 | |
218dc407 | 6359 | s32 host_int_init(tstrWILC_WFIDrv **phWFIDrv) |
c5c77ba1 | 6360 | { |
e6e12661 | 6361 | s32 s32Error = 0; |
c5c77ba1 | 6362 | tstrWILC_WFIDrv *pstrWFIDrv; |
d42ab083 | 6363 | int err; |
c5c77ba1 | 6364 | |
c5c77ba1 JK |
6365 | PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1); |
6366 | ||
72ed4dc7 | 6367 | gbScanWhileConnected = false; |
c5c77ba1 | 6368 | |
83383ea3 | 6369 | sema_init(&hWaitResponse, 0); |
c5c77ba1 JK |
6370 | |
6371 | ||
6372 | ||
6373 | /*Allocate host interface private structure*/ | |
f3052587 | 6374 | pstrWFIDrv = kmalloc(sizeof(tstrWILC_WFIDrv), GFP_KERNEL); |
b1413b60 | 6375 | if (pstrWFIDrv == NULL) { |
e6e12661 | 6376 | s32Error = -ENOMEM; |
c5c77ba1 JK |
6377 | PRINT_ER("Failed to allocate memory\n"); |
6378 | goto _fail_timer_2; | |
6379 | } | |
2cc46837 | 6380 | memset(pstrWFIDrv, 0, sizeof(tstrWILC_WFIDrv)); |
c5c77ba1 | 6381 | /*return driver handle to user*/ |
218dc407 | 6382 | *phWFIDrv = pstrWFIDrv; |
c5c77ba1 | 6383 | /*save into globl handle*/ |
d42ab083 JK |
6384 | err = add_handler_in_list(pstrWFIDrv); |
6385 | if (err) { | |
e6e12661 | 6386 | s32Error = -EFAULT; |
d42ab083 JK |
6387 | goto _fail_timer_2; |
6388 | } | |
c5c77ba1 JK |
6389 | |
6390 | #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP | |
6391 | ||
72ed4dc7 | 6392 | g_obtainingIP = false; |
c5c77ba1 JK |
6393 | #endif |
6394 | ||
8a14330f | 6395 | PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", pstrWFIDrv); |
c5c77ba1 JK |
6396 | /* /////////////////////////////////////// */ |
6397 | if (clients_count == 0) { | |
83383ea3 AB |
6398 | sema_init(&hSemHostIFthrdEnd, 0); |
6399 | sema_init(&hSemDeinitDrvHandle, 0); | |
83383ea3 AB |
6400 | sema_init(&hSemHostIntDeinit, 1); |
6401 | } | |
6402 | ||
6403 | sema_init(&(pstrWFIDrv->hSemTestKeyBlock), 0); | |
6404 | sema_init(&(pstrWFIDrv->hSemTestDisconnectBlock), 0); | |
6405 | sema_init(&(pstrWFIDrv->hSemGetRSSI), 0); | |
6406 | sema_init(&(pstrWFIDrv->hSemGetLINKSPEED), 0); | |
6407 | sema_init(&(pstrWFIDrv->hSemGetCHNL), 0); | |
6408 | sema_init(&(pstrWFIDrv->hSemInactiveTime), 0); | |
c5c77ba1 JK |
6409 | |
6410 | /* /////////////////////////////////////// */ | |
6411 | ||
6412 | ||
6413 | ||
6414 | PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count); | |
6415 | ||
6416 | if (clients_count == 0) { | |
cd08fc78 | 6417 | s32Error = wilc_mq_create(&gMsgQHostIF); |
c5c77ba1 JK |
6418 | |
6419 | if (s32Error < 0) { | |
6420 | PRINT_ER("Failed to creat MQ\n"); | |
6421 | goto _fail_; | |
6422 | } | |
1999bd52 AB |
6423 | HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread"); |
6424 | if (IS_ERR(HostIFthreadHandler)) { | |
c5c77ba1 | 6425 | PRINT_ER("Failed to creat Thread\n"); |
e6e12661 | 6426 | s32Error = -EFAULT; |
c5c77ba1 JK |
6427 | goto _fail_mq_; |
6428 | } | |
507d7fc5 GKH |
6429 | setup_timer(&g_hPeriodicRSSI, GetPeriodicRSSI, |
6430 | (unsigned long)pstrWFIDrv); | |
9eb06643 | 6431 | mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000)); |
c5c77ba1 JK |
6432 | } |
6433 | ||
6434 | ||
93dee8ee | 6435 | setup_timer(&pstrWFIDrv->hScanTimer, TimerCB_Scan, 0); |
c5c77ba1 | 6436 | |
93dee8ee | 6437 | setup_timer(&pstrWFIDrv->hConnectTimer, TimerCB_Connect, 0); |
c5c77ba1 | 6438 | |
c5c77ba1 | 6439 | /*Remain on channel timer*/ |
93dee8ee | 6440 | setup_timer(&pstrWFIDrv->hRemainOnChannel, ListenTimerCB, 0); |
c5c77ba1 | 6441 | |
83383ea3 AB |
6442 | sema_init(&(pstrWFIDrv->gtOsCfgValuesSem), 1); |
6443 | down(&(pstrWFIDrv->gtOsCfgValuesSem)); | |
c5c77ba1 | 6444 | |
c5c77ba1 | 6445 | pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE; |
72ed4dc7 | 6446 | /* gWFiDrvHandle->bPendingConnRequest = false; */ |
c5c77ba1 JK |
6447 | |
6448 | /*Initialize CFG WIDS Defualt Values*/ | |
6449 | ||
6450 | pstrWFIDrv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF; | |
6451 | pstrWFIDrv->strCfgValues.scan_source = DEFAULT_SCAN; | |
6452 | pstrWFIDrv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME; | |
6453 | pstrWFIDrv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME; | |
6454 | pstrWFIDrv->strCfgValues.curr_tx_rate = AUTORATE; | |
6455 | ||
c5c77ba1 JK |
6456 | pstrWFIDrv->u64P2p_MgmtTimeout = 0; |
6457 | ||
c5c77ba1 JK |
6458 | PRINT_INFO(HOSTINF_DBG, "Initialization values, Site survey value: %d\n Scan source: %d\n Active scan time: %d\n Passive scan time: %d\nCurrent tx Rate = %d\n", |
6459 | ||
6460 | pstrWFIDrv->strCfgValues.site_survey_enabled, pstrWFIDrv->strCfgValues.scan_source, | |
6461 | pstrWFIDrv->strCfgValues.active_scan_time, pstrWFIDrv->strCfgValues.passive_scan_time, | |
6462 | pstrWFIDrv->strCfgValues.curr_tx_rate); | |
6463 | ||
6464 | ||
83383ea3 | 6465 | up(&(pstrWFIDrv->gtOsCfgValuesSem)); |
c5c77ba1 JK |
6466 | |
6467 | /*TODO Code to setup simulation to be removed later*/ | |
6468 | /*Intialize configurator module*/ | |
6469 | s32Error = CoreConfiguratorInit(); | |
6470 | if (s32Error < 0) { | |
6471 | PRINT_ER("Failed to initialize core configurator\n"); | |
6472 | goto _fail_mem_; | |
6473 | } | |
6474 | ||
c5c77ba1 JK |
6475 | clients_count++; /* increase number of created entities */ |
6476 | ||
6477 | return s32Error; | |
6478 | ||
6479 | ||
6480 | _fail_mem_: | |
b1413b60 | 6481 | if (pstrWFIDrv != NULL) |
49188af2 | 6482 | kfree(pstrWFIDrv); |
4183e979 | 6483 | del_timer_sync(&pstrWFIDrv->hRemainOnChannel); |
c5c77ba1 | 6484 | _fail_timer_2: |
83383ea3 | 6485 | up(&(pstrWFIDrv->gtOsCfgValuesSem)); |
4183e979 | 6486 | del_timer_sync(&pstrWFIDrv->hConnectTimer); |
4183e979 | 6487 | del_timer_sync(&pstrWFIDrv->hScanTimer); |
1999bd52 | 6488 | kthread_stop(HostIFthreadHandler); |
c5c77ba1 | 6489 | _fail_mq_: |
1b128f63 | 6490 | wilc_mq_destroy(&gMsgQHostIF); |
c5c77ba1 JK |
6491 | _fail_: |
6492 | return s32Error; | |
6493 | ||
6494 | ||
6495 | } | |
6496 | /** | |
6497 | * @brief host_int_deinit | |
6498 | * @details host interface initialization function | |
6499 | * @param[in,out] handle to the wifi driver, | |
6500 | * @note | |
6501 | * @author zsalah | |
6502 | * @date 8 March 2012 | |
6503 | * @version 1.0 | |
6504 | */ | |
6505 | ||
218dc407 | 6506 | s32 host_int_deinit(tstrWILC_WFIDrv *hWFIDrv) |
c5c77ba1 | 6507 | { |
e6e12661 | 6508 | s32 s32Error = 0; |
143eb95a | 6509 | struct host_if_msg msg; |
d42ab083 | 6510 | int ret; |
c5c77ba1 JK |
6511 | |
6512 | /*obtain driver handle*/ | |
6513 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; | |
c5c77ba1 JK |
6514 | |
6515 | if (pstrWFIDrv == NULL) { | |
6516 | PRINT_ER("pstrWFIDrv = NULL\n"); | |
6517 | return 0; | |
6518 | } | |
6519 | ||
83383ea3 | 6520 | down(&hSemHostIntDeinit); |
c5c77ba1 JK |
6521 | |
6522 | terminated_handle = pstrWFIDrv; | |
6523 | PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count); | |
6524 | ||
c5c77ba1 JK |
6525 | /*Destroy all timers before acquiring hSemDeinitDrvHandle*/ |
6526 | /*to guarantee handling all messages befor proceeding*/ | |
4183e979 | 6527 | if (del_timer_sync(&pstrWFIDrv->hScanTimer)) { |
03b2d5e7 | 6528 | PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n"); |
c5c77ba1 JK |
6529 | /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */ |
6530 | } | |
6531 | ||
4183e979 | 6532 | if (del_timer_sync(&pstrWFIDrv->hConnectTimer)) { |
03b2d5e7 | 6533 | PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n"); |
c5c77ba1 JK |
6534 | /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */ |
6535 | } | |
6536 | ||
6537 | ||
4183e979 | 6538 | if (del_timer_sync(&g_hPeriodicRSSI)) { |
03b2d5e7 | 6539 | PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n"); |
c5c77ba1 JK |
6540 | /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */ |
6541 | } | |
6542 | ||
c5c77ba1 | 6543 | /*Destroy Remain-onchannel Timer*/ |
4183e979 | 6544 | del_timer_sync(&pstrWFIDrv->hRemainOnChannel); |
c5c77ba1 | 6545 | |
218dc407 | 6546 | host_int_set_wfi_drv_handler(NULL); |
83383ea3 | 6547 | down(&hSemDeinitDrvHandle); |
c5c77ba1 JK |
6548 | |
6549 | ||
6550 | /*Calling the CFG80211 scan done function with the abort flag set to true*/ | |
6551 | if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) { | |
b1413b60 | 6552 | pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL, |
c5c77ba1 JK |
6553 | pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL); |
6554 | ||
b1413b60 | 6555 | pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL; |
c5c77ba1 JK |
6556 | } |
6557 | /*deinit configurator and simulator*/ | |
c5c77ba1 | 6558 | CoreConfiguratorDeInit(); |
c5c77ba1 JK |
6559 | |
6560 | pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE; | |
6561 | ||
72ed4dc7 | 6562 | gbScanWhileConnected = false; |
c5c77ba1 | 6563 | |
143eb95a | 6564 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
6565 | |
6566 | if (clients_count == 1) { | |
4183e979 | 6567 | if (del_timer_sync(&g_hPeriodicRSSI)) { |
03b2d5e7 | 6568 | PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n"); |
c5c77ba1 JK |
6569 | /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */ |
6570 | } | |
a9f812a6 | 6571 | msg.id = HOST_IF_MSG_EXIT; |
143eb95a | 6572 | msg.drvHandler = hWFIDrv; |
c5c77ba1 JK |
6573 | |
6574 | ||
143eb95a | 6575 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
e6e12661 | 6576 | if (s32Error != 0) |
c5c77ba1 | 6577 | PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error); |
c5c77ba1 | 6578 | |
83383ea3 | 6579 | down(&hSemHostIFthrdEnd); |
c5c77ba1 | 6580 | |
1b128f63 | 6581 | wilc_mq_destroy(&gMsgQHostIF); |
c5c77ba1 JK |
6582 | } |
6583 | ||
83383ea3 | 6584 | down(&(pstrWFIDrv->gtOsCfgValuesSem)); |
c5c77ba1 JK |
6585 | |
6586 | /*Setting the gloabl driver handler with NULL*/ | |
c5c77ba1 | 6587 | /* gWFiDrvHandle = NULL; */ |
d42ab083 JK |
6588 | ret = remove_handler_in_list(pstrWFIDrv); |
6589 | if (ret) | |
e6e12661 | 6590 | s32Error = -ENOENT; |
d42ab083 | 6591 | |
b1413b60 | 6592 | if (pstrWFIDrv != NULL) { |
49188af2 | 6593 | kfree(pstrWFIDrv); |
b1413b60 | 6594 | /* pstrWFIDrv=NULL; */ |
c5c77ba1 JK |
6595 | |
6596 | } | |
6597 | ||
6598 | clients_count--; /* Decrease number of created entities */ | |
b1413b60 | 6599 | terminated_handle = NULL; |
83383ea3 | 6600 | up(&hSemHostIntDeinit); |
c5c77ba1 JK |
6601 | return s32Error; |
6602 | } | |
6603 | ||
6604 | ||
6605 | /** | |
6606 | * @brief NetworkInfoReceived | |
6607 | * @details function to to be called when network info packet is received | |
6608 | * @param[in] pu8Buffer the received packet | |
6609 | * @param[in] u32Length length of the received packet | |
6610 | * @return none | |
6611 | * @note | |
6612 | * @author | |
6613 | * @date 1 Mar 2012 | |
6614 | * @version 1.0 | |
6615 | */ | |
4e4467fd | 6616 | void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length) |
c5c77ba1 | 6617 | { |
e6e12661 | 6618 | s32 s32Error = 0; |
143eb95a | 6619 | struct host_if_msg msg; |
d42ab083 | 6620 | int id; |
b1413b60 | 6621 | tstrWILC_WFIDrv *pstrWFIDrv = NULL; |
c5c77ba1 | 6622 | |
d42ab083 JK |
6623 | id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24)); |
6624 | pstrWFIDrv = get_handler_from_id(id); | |
c5c77ba1 JK |
6625 | |
6626 | ||
6627 | ||
6628 | ||
b1413b60 | 6629 | if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) { |
8a14330f | 6630 | PRINT_ER("NetworkInfo received but driver not init[%p]\n", pstrWFIDrv); |
c5c77ba1 JK |
6631 | return; |
6632 | } | |
6633 | ||
6634 | /* prepare the Asynchronous Network Info message */ | |
143eb95a | 6635 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 | 6636 | |
a9f812a6 | 6637 | msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO; |
143eb95a | 6638 | msg.drvHandler = pstrWFIDrv; |
c5c77ba1 | 6639 | |
410c2489 TC |
6640 | msg.body.strRcvdNetworkInfo.u32Length = u32Length; |
6641 | msg.body.strRcvdNetworkInfo.pu8Buffer = kmalloc(u32Length, GFP_KERNEL); /* will be deallocated by the receiving thread */ | |
6642 | memcpy(msg.body.strRcvdNetworkInfo.pu8Buffer, | |
c5c77ba1 JK |
6643 | pu8Buffer, u32Length); |
6644 | ||
6645 | /* send the message */ | |
143eb95a | 6646 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
2b9d5b48 | 6647 | if (s32Error) |
c5c77ba1 | 6648 | PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error); |
c5c77ba1 JK |
6649 | } |
6650 | ||
6651 | /** | |
6652 | * @brief GnrlAsyncInfoReceived | |
6653 | * @details function to be called when general Asynchronous info packet is received | |
6654 | * @param[in] pu8Buffer the received packet | |
6655 | * @param[in] u32Length length of the received packet | |
6656 | * @return none | |
6657 | * @note | |
6658 | * @author | |
6659 | * @date 15 Mar 2012 | |
6660 | * @version 1.0 | |
6661 | */ | |
4e4467fd | 6662 | void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length) |
c5c77ba1 | 6663 | { |
e6e12661 | 6664 | s32 s32Error = 0; |
143eb95a | 6665 | struct host_if_msg msg; |
d42ab083 | 6666 | int id; |
b1413b60 | 6667 | tstrWILC_WFIDrv *pstrWFIDrv = NULL; |
c5c77ba1 | 6668 | |
83383ea3 | 6669 | down(&hSemHostIntDeinit); |
c5c77ba1 | 6670 | |
d42ab083 JK |
6671 | id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24)); |
6672 | pstrWFIDrv = get_handler_from_id(id); | |
03b2d5e7 | 6673 | PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n"); |
c5c77ba1 JK |
6674 | |
6675 | ||
6676 | if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) { | |
6677 | PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n"); | |
83383ea3 | 6678 | up(&hSemHostIntDeinit); |
c5c77ba1 JK |
6679 | return; |
6680 | } | |
6681 | ||
b1413b60 | 6682 | if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL) { |
c5c77ba1 JK |
6683 | /* received mac status is not needed when there is no current Connect Request */ |
6684 | PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n"); | |
83383ea3 | 6685 | up(&hSemHostIntDeinit); |
c5c77ba1 JK |
6686 | return; |
6687 | } | |
6688 | ||
6689 | /* prepare the General Asynchronous Info message */ | |
143eb95a | 6690 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
6691 | |
6692 | ||
a9f812a6 | 6693 | msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO; |
143eb95a | 6694 | msg.drvHandler = pstrWFIDrv; |
c5c77ba1 JK |
6695 | |
6696 | ||
410c2489 TC |
6697 | msg.body.strRcvdGnrlAsyncInfo.u32Length = u32Length; |
6698 | msg.body.strRcvdGnrlAsyncInfo.pu8Buffer = kmalloc(u32Length, GFP_KERNEL); /* will be deallocated by the receiving thread */ | |
6699 | memcpy(msg.body.strRcvdGnrlAsyncInfo.pu8Buffer, | |
c5c77ba1 JK |
6700 | pu8Buffer, u32Length); |
6701 | ||
6702 | /* send the message */ | |
143eb95a | 6703 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
2b9d5b48 | 6704 | if (s32Error) |
c5c77ba1 | 6705 | PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error); |
c5c77ba1 | 6706 | |
83383ea3 | 6707 | up(&hSemHostIntDeinit); |
c5c77ba1 JK |
6708 | } |
6709 | ||
6710 | /** | |
6711 | * @brief host_int_ScanCompleteReceived | |
6712 | * @details Setting scan complete received notifcation in message queue | |
4e4467fd | 6713 | * @param[in] u8* pu8Buffer, u32 u32Length |
c5c77ba1 JK |
6714 | * @return Error code. |
6715 | * @author | |
6716 | * @date | |
6717 | * @version 1.0 | |
6718 | */ | |
4e4467fd | 6719 | void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length) |
c5c77ba1 | 6720 | { |
e6e12661 | 6721 | s32 s32Error = 0; |
143eb95a | 6722 | struct host_if_msg msg; |
d42ab083 | 6723 | int id; |
b1413b60 | 6724 | tstrWILC_WFIDrv *pstrWFIDrv = NULL; |
78c87591 | 6725 | |
d42ab083 JK |
6726 | id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24)); |
6727 | pstrWFIDrv = get_handler_from_id(id); | |
c5c77ba1 JK |
6728 | |
6729 | ||
8a14330f | 6730 | PRINT_D(GENERIC_DBG, "Scan notification received %p\n", pstrWFIDrv); |
c5c77ba1 | 6731 | |
2b9d5b48 | 6732 | if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) |
c5c77ba1 | 6733 | return; |
c5c77ba1 JK |
6734 | |
6735 | /*if there is an ongoing scan request*/ | |
6736 | if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) { | |
6737 | /* prepare theScan Done message */ | |
143eb95a | 6738 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 | 6739 | |
a9f812a6 | 6740 | msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE; |
143eb95a | 6741 | msg.drvHandler = pstrWFIDrv; |
c5c77ba1 JK |
6742 | |
6743 | ||
6744 | /* will be deallocated by the receiving thread */ | |
6745 | /*no need to send message body*/ | |
6746 | ||
410c2489 TC |
6747 | /*msg.body.strScanComplete.u32Length = u32Length; |
6748 | * msg.body.strScanComplete.pu8Buffer = (u8*)WILC_MALLOC(u32Length); | |
6749 | * memcpy(msg.body.strScanComplete.pu8Buffer, | |
c5c77ba1 JK |
6750 | * pu8Buffer, u32Length); */ |
6751 | ||
6752 | /* send the message */ | |
143eb95a | 6753 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
2b9d5b48 | 6754 | if (s32Error) |
c5c77ba1 | 6755 | PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error); |
c5c77ba1 JK |
6756 | } |
6757 | ||
6758 | ||
6759 | return; | |
6760 | ||
6761 | } | |
6762 | ||
c5c77ba1 JK |
6763 | /** |
6764 | * @brief host_int_remain_on_channel | |
6765 | * @details | |
6766 | * @param[in] Handle to wifi driver | |
6767 | * Duration to remain on channel | |
6768 | * Channel to remain on | |
6769 | * Pointer to fn to be called on receive frames in listen state | |
6770 | * Pointer to remain-on-channel expired fn | |
6771 | * Priv | |
6772 | * @return Error code. | |
6773 | * @author | |
6774 | * @date | |
6775 | * @version 1.0 | |
6776 | */ | |
218dc407 | 6777 | s32 host_int_remain_on_channel(tstrWILC_WFIDrv *hWFIDrv, u32 u32SessionID, u32 u32duration, u16 chan, tWILCpfRemainOnChanExpired RemainOnChanExpired, tWILCpfRemainOnChanReady RemainOnChanReady, void *pvUserArg) |
c5c77ba1 | 6778 | { |
e6e12661 | 6779 | s32 s32Error = 0; |
c5c77ba1 | 6780 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 6781 | struct host_if_msg msg; |
c5c77ba1 | 6782 | |
24db713f LK |
6783 | if (pstrWFIDrv == NULL) { |
6784 | PRINT_ER("driver is null\n"); | |
6785 | return -EFAULT; | |
6786 | } | |
c5c77ba1 JK |
6787 | |
6788 | /* prepare the remainonchan Message */ | |
143eb95a | 6789 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
6790 | |
6791 | /* prepare the WiphyParams Message */ | |
a9f812a6 | 6792 | msg.id = HOST_IF_MSG_REMAIN_ON_CHAN; |
410c2489 TC |
6793 | msg.body.strHostIfRemainOnChan.u16Channel = chan; |
6794 | msg.body.strHostIfRemainOnChan.pRemainOnChanExpired = RemainOnChanExpired; | |
6795 | msg.body.strHostIfRemainOnChan.pRemainOnChanReady = RemainOnChanReady; | |
6796 | msg.body.strHostIfRemainOnChan.pVoid = pvUserArg; | |
6797 | msg.body.strHostIfRemainOnChan.u32duration = u32duration; | |
6798 | msg.body.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID; | |
143eb95a TC |
6799 | msg.drvHandler = hWFIDrv; |
6800 | ||
6801 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); | |
2b9d5b48 | 6802 | if (s32Error) |
24db713f | 6803 | PRINT_ER("wilc mq send fail\n"); |
c5c77ba1 JK |
6804 | |
6805 | return s32Error; | |
6806 | } | |
6807 | ||
6808 | /** | |
6809 | * @brief host_int_ListenStateExpired | |
6810 | * @details | |
6811 | * @param[in] Handle to wifi driver | |
6812 | * Duration to remain on channel | |
6813 | * Channel to remain on | |
6814 | * Pointer to fn to be called on receive frames in listen state | |
6815 | * Pointer to remain-on-channel expired fn | |
6816 | * Priv | |
6817 | * @return Error code. | |
6818 | * @author | |
6819 | * @date | |
6820 | * @version 1.0 | |
6821 | */ | |
218dc407 | 6822 | s32 host_int_ListenStateExpired(tstrWILC_WFIDrv *hWFIDrv, u32 u32SessionID) |
c5c77ba1 | 6823 | { |
e6e12661 | 6824 | s32 s32Error = 0; |
c5c77ba1 | 6825 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 6826 | struct host_if_msg msg; |
c5c77ba1 | 6827 | |
24db713f LK |
6828 | if (pstrWFIDrv == NULL) { |
6829 | PRINT_ER("driver is null\n"); | |
6830 | return -EFAULT; | |
6831 | } | |
c5c77ba1 JK |
6832 | |
6833 | /*Stopping remain-on-channel timer*/ | |
8972d0fe | 6834 | del_timer(&pstrWFIDrv->hRemainOnChannel); |
c5c77ba1 JK |
6835 | |
6836 | /* prepare the timer fire Message */ | |
143eb95a | 6837 | memset(&msg, 0, sizeof(struct host_if_msg)); |
a9f812a6 | 6838 | msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED; |
143eb95a | 6839 | msg.drvHandler = hWFIDrv; |
410c2489 | 6840 | msg.body.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID; |
c5c77ba1 | 6841 | |
143eb95a | 6842 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
2b9d5b48 | 6843 | if (s32Error) |
24db713f | 6844 | PRINT_ER("wilc mq send fail\n"); |
c5c77ba1 | 6845 | |
c5c77ba1 JK |
6846 | return s32Error; |
6847 | } | |
6848 | ||
6849 | /** | |
6850 | * @brief host_int_frame_register | |
6851 | * @details | |
6852 | * @param[in] Handle to wifi driver | |
6853 | * @return Error code. | |
6854 | * @author | |
6855 | * @date | |
6856 | * @version 1.0*/ | |
218dc407 | 6857 | s32 host_int_frame_register(tstrWILC_WFIDrv *hWFIDrv, u16 u16FrameType, bool bReg) |
c5c77ba1 | 6858 | { |
e6e12661 | 6859 | s32 s32Error = 0; |
c5c77ba1 | 6860 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 6861 | struct host_if_msg msg; |
c5c77ba1 | 6862 | |
24db713f LK |
6863 | if (pstrWFIDrv == NULL) { |
6864 | PRINT_ER("driver is null\n"); | |
6865 | return -EFAULT; | |
6866 | } | |
c5c77ba1 | 6867 | |
143eb95a | 6868 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
6869 | |
6870 | /* prepare the WiphyParams Message */ | |
a9f812a6 | 6871 | msg.id = HOST_IF_MSG_REGISTER_FRAME; |
c5c77ba1 JK |
6872 | switch (u16FrameType) { |
6873 | case ACTION: | |
6874 | PRINT_D(HOSTINF_DBG, "ACTION\n"); | |
410c2489 | 6875 | msg.body.strHostIfRegisterFrame.u8Regid = ACTION_FRM_IDX; |
c5c77ba1 JK |
6876 | break; |
6877 | ||
6878 | case PROBE_REQ: | |
6879 | PRINT_D(HOSTINF_DBG, "PROBE REQ\n"); | |
410c2489 | 6880 | msg.body.strHostIfRegisterFrame.u8Regid = PROBE_REQ_IDX; |
c5c77ba1 JK |
6881 | break; |
6882 | ||
6883 | default: | |
6884 | PRINT_D(HOSTINF_DBG, "Not valid frame type\n"); | |
6885 | break; | |
6886 | } | |
410c2489 TC |
6887 | msg.body.strHostIfRegisterFrame.u16FrameType = u16FrameType; |
6888 | msg.body.strHostIfRegisterFrame.bReg = bReg; | |
143eb95a | 6889 | msg.drvHandler = hWFIDrv; |
c5c77ba1 | 6890 | |
143eb95a | 6891 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
2b9d5b48 | 6892 | if (s32Error) |
24db713f | 6893 | PRINT_ER("wilc mq send fail\n"); |
c5c77ba1 JK |
6894 | |
6895 | return s32Error; | |
6896 | ||
6897 | ||
6898 | } | |
c5c77ba1 | 6899 | |
c5c77ba1 JK |
6900 | /** |
6901 | * @brief host_int_add_beacon | |
6902 | * @details Setting add beacon params in message queue | |
4e4467fd CL |
6903 | * @param[in] WILC_WFIDrvHandle hWFIDrv, u32 u32Interval, |
6904 | * u32 u32DTIMPeriod,u32 u32HeadLen, u8* pu8Head, | |
6905 | * u32 u32TailLen, u8* pu8Tail | |
c5c77ba1 JK |
6906 | * @return Error code. |
6907 | * @author | |
6908 | * @date | |
6909 | * @version 1.0 | |
6910 | */ | |
218dc407 | 6911 | s32 host_int_add_beacon(tstrWILC_WFIDrv *hWFIDrv, u32 u32Interval, |
4e4467fd CL |
6912 | u32 u32DTIMPeriod, |
6913 | u32 u32HeadLen, u8 *pu8Head, | |
6914 | u32 u32TailLen, u8 *pu8Tail) | |
c5c77ba1 | 6915 | { |
e6e12661 | 6916 | s32 s32Error = 0; |
c5c77ba1 | 6917 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 6918 | struct host_if_msg msg; |
902362b1 | 6919 | struct set_beacon *pstrSetBeaconParam = &msg.body.strHostIFSetBeacon; |
c5c77ba1 | 6920 | |
24db713f LK |
6921 | if (pstrWFIDrv == NULL) { |
6922 | PRINT_ER("driver is null\n"); | |
6923 | return -EFAULT; | |
6924 | } | |
c5c77ba1 | 6925 | |
143eb95a | 6926 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
6927 | |
6928 | PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n"); | |
6929 | ||
6930 | ||
6931 | /* prepare the WiphyParams Message */ | |
a9f812a6 | 6932 | msg.id = HOST_IF_MSG_ADD_BEACON; |
143eb95a | 6933 | msg.drvHandler = hWFIDrv; |
c5c77ba1 JK |
6934 | pstrSetBeaconParam->u32Interval = u32Interval; |
6935 | pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod; | |
6936 | pstrSetBeaconParam->u32HeadLen = u32HeadLen; | |
f3052587 | 6937 | pstrSetBeaconParam->pu8Head = kmalloc(u32HeadLen, GFP_KERNEL); |
24db713f LK |
6938 | if (pstrSetBeaconParam->pu8Head == NULL) { |
6939 | s32Error = -ENOMEM; | |
6940 | goto ERRORHANDLER; | |
6941 | } | |
d00d2ba3 | 6942 | memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen); |
c5c77ba1 JK |
6943 | pstrSetBeaconParam->u32TailLen = u32TailLen; |
6944 | ||
c5c77ba1 | 6945 | if (u32TailLen > 0) { |
f3052587 | 6946 | pstrSetBeaconParam->pu8Tail = kmalloc(u32TailLen, GFP_KERNEL); |
24db713f LK |
6947 | if (pstrSetBeaconParam->pu8Tail == NULL) { |
6948 | s32Error = -ENOMEM; | |
6949 | goto ERRORHANDLER; | |
6950 | } | |
d00d2ba3 | 6951 | memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen); |
c5c77ba1 JK |
6952 | } else { |
6953 | pstrSetBeaconParam->pu8Tail = NULL; | |
6954 | } | |
6955 | ||
143eb95a | 6956 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
2b9d5b48 | 6957 | if (s32Error) |
24db713f | 6958 | PRINT_ER("wilc mq send fail\n"); |
c5c77ba1 | 6959 | |
24db713f LK |
6960 | ERRORHANDLER: |
6961 | if (s32Error) { | |
2b9d5b48 | 6962 | if (pstrSetBeaconParam->pu8Head != NULL) |
49188af2 | 6963 | kfree(pstrSetBeaconParam->pu8Head); |
c5c77ba1 | 6964 | |
2b9d5b48 | 6965 | if (pstrSetBeaconParam->pu8Tail != NULL) |
49188af2 | 6966 | kfree(pstrSetBeaconParam->pu8Tail); |
c5c77ba1 JK |
6967 | } |
6968 | ||
6969 | return s32Error; | |
6970 | ||
6971 | } | |
6972 | ||
6973 | ||
6974 | /** | |
6975 | * @brief host_int_del_beacon | |
6976 | * @details Setting add beacon params in message queue | |
6977 | * @param[in] WILC_WFIDrvHandle hWFIDrv | |
6978 | * @return Error code. | |
6979 | * @author | |
6980 | * @date | |
6981 | * @version 1.0 | |
6982 | */ | |
218dc407 | 6983 | s32 host_int_del_beacon(tstrWILC_WFIDrv *hWFIDrv) |
c5c77ba1 | 6984 | { |
e6e12661 | 6985 | s32 s32Error = 0; |
c5c77ba1 | 6986 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 6987 | struct host_if_msg msg; |
c5c77ba1 | 6988 | |
24db713f LK |
6989 | if (pstrWFIDrv == NULL) { |
6990 | PRINT_ER("driver is null\n"); | |
6991 | return -EFAULT; | |
6992 | } | |
c5c77ba1 JK |
6993 | |
6994 | /* prepare the WiphyParams Message */ | |
a9f812a6 | 6995 | msg.id = HOST_IF_MSG_DEL_BEACON; |
143eb95a | 6996 | msg.drvHandler = hWFIDrv; |
c5c77ba1 JK |
6997 | PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n"); |
6998 | ||
143eb95a | 6999 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
7dc1d0cc LK |
7000 | if (s32Error) |
7001 | PRINT_ER("wilc_mq_send fail\n"); | |
c5c77ba1 | 7002 | |
c5c77ba1 JK |
7003 | return s32Error; |
7004 | } | |
7005 | ||
7006 | ||
7007 | /** | |
7008 | * @brief host_int_add_station | |
7009 | * @details Setting add station params in message queue | |
6a89ba9c | 7010 | * @param[in] WILC_WFIDrvHandle hWFIDrv, struct add_sta_param *pstrStaParams |
c5c77ba1 JK |
7011 | * @return Error code. |
7012 | * @author | |
7013 | * @date | |
7014 | * @version 1.0 | |
7015 | */ | |
6a89ba9c TC |
7016 | s32 host_int_add_station(tstrWILC_WFIDrv *hWFIDrv, |
7017 | struct add_sta_param *pstrStaParams) | |
c5c77ba1 | 7018 | { |
e6e12661 | 7019 | s32 s32Error = 0; |
c5c77ba1 | 7020 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 7021 | struct host_if_msg msg; |
6a89ba9c | 7022 | struct add_sta_param *pstrAddStationMsg = &msg.body.strAddStaParam; |
c5c77ba1 JK |
7023 | |
7024 | ||
24db713f LK |
7025 | if (pstrWFIDrv == NULL) { |
7026 | PRINT_ER("driver is null\n"); | |
7027 | return -EFAULT; | |
7028 | } | |
c5c77ba1 | 7029 | |
143eb95a | 7030 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
7031 | |
7032 | PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n"); | |
7033 | ||
7034 | ||
7035 | /* prepare the WiphyParams Message */ | |
a9f812a6 | 7036 | msg.id = HOST_IF_MSG_ADD_STATION; |
143eb95a | 7037 | msg.drvHandler = hWFIDrv; |
c5c77ba1 | 7038 | |
6a89ba9c | 7039 | memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param)); |
c5c77ba1 | 7040 | if (pstrAddStationMsg->u8NumRates > 0) { |
f3052587 | 7041 | u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL); |
78c87591 | 7042 | |
7ae43363 LK |
7043 | if (!rates) |
7044 | return -ENOMEM; | |
c5c77ba1 | 7045 | |
d00d2ba3 | 7046 | memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates); |
057d1e97 | 7047 | pstrAddStationMsg->pu8Rates = rates; |
c5c77ba1 JK |
7048 | } |
7049 | ||
7050 | ||
143eb95a | 7051 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
2b9d5b48 | 7052 | if (s32Error) |
24db713f | 7053 | PRINT_ER("wilc_mq_send fail\n"); |
c5c77ba1 JK |
7054 | return s32Error; |
7055 | } | |
7056 | ||
7057 | /** | |
7058 | * @brief host_int_del_station | |
7059 | * @details Setting delete station params in message queue | |
63d03e47 | 7060 | * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr |
c5c77ba1 JK |
7061 | * @return Error code. |
7062 | * @author | |
7063 | * @date | |
7064 | * @version 1.0 | |
7065 | */ | |
218dc407 | 7066 | s32 host_int_del_station(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8MacAddr) |
c5c77ba1 | 7067 | { |
e6e12661 | 7068 | s32 s32Error = 0; |
c5c77ba1 | 7069 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 7070 | struct host_if_msg msg; |
fb93a1e1 | 7071 | struct del_sta *pstrDelStationMsg = &msg.body.strDelStaParam; |
c5c77ba1 | 7072 | |
24db713f LK |
7073 | if (pstrWFIDrv == NULL) { |
7074 | PRINT_ER("driver is null\n"); | |
7075 | return -EFAULT; | |
7076 | } | |
c5c77ba1 | 7077 | |
143eb95a | 7078 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
7079 | |
7080 | PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n"); | |
7081 | ||
7082 | ||
7083 | ||
7084 | /* prepare the WiphyParams Message */ | |
a9f812a6 | 7085 | msg.id = HOST_IF_MSG_DEL_STATION; |
143eb95a | 7086 | msg.drvHandler = hWFIDrv; |
c5c77ba1 | 7087 | |
b1413b60 | 7088 | if (pu8MacAddr == NULL) |
2cc46837 | 7089 | memset(pstrDelStationMsg->au8MacAddr, 255, ETH_ALEN); |
c5c77ba1 | 7090 | else |
d00d2ba3 | 7091 | memcpy(pstrDelStationMsg->au8MacAddr, pu8MacAddr, ETH_ALEN); |
c5c77ba1 | 7092 | |
143eb95a | 7093 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
2b9d5b48 | 7094 | if (s32Error) |
24db713f | 7095 | PRINT_ER("wilc_mq_send fail\n"); |
c5c77ba1 JK |
7096 | return s32Error; |
7097 | } | |
7098 | /** | |
7099 | * @brief host_int_del_allstation | |
7100 | * @details Setting del station params in message queue | |
63d03e47 | 7101 | * @param[in] WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]s |
c5c77ba1 JK |
7102 | * @return Error code. |
7103 | * @author | |
7104 | * @date | |
7105 | * @version 1.0 | |
7106 | */ | |
218dc407 | 7107 | s32 host_int_del_allstation(tstrWILC_WFIDrv *hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]) |
c5c77ba1 | 7108 | { |
e6e12661 | 7109 | s32 s32Error = 0; |
c5c77ba1 | 7110 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 7111 | struct host_if_msg msg; |
b4e644e4 | 7112 | struct del_all_sta *pstrDelAllStationMsg = &msg.body.strHostIFDelAllSta; |
63d03e47 | 7113 | u8 au8Zero_Buff[ETH_ALEN] = {0}; |
4e4467fd | 7114 | u32 i; |
63d03e47 | 7115 | u8 u8AssocNumb = 0; |
c5c77ba1 JK |
7116 | |
7117 | ||
24db713f LK |
7118 | if (pstrWFIDrv == NULL) { |
7119 | PRINT_ER("driver is null\n"); | |
7120 | return -EFAULT; | |
7121 | } | |
c5c77ba1 | 7122 | |
143eb95a | 7123 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
7124 | |
7125 | PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n"); | |
7126 | ||
7127 | /* prepare the WiphyParams Message */ | |
a9f812a6 | 7128 | msg.id = HOST_IF_MSG_DEL_ALL_STA; |
143eb95a | 7129 | msg.drvHandler = hWFIDrv; |
c5c77ba1 JK |
7130 | |
7131 | /* Handling situation of deauthenticing all associated stations*/ | |
7132 | for (i = 0; i < MAX_NUM_STA; i++) { | |
7133 | if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) { | |
d00d2ba3 | 7134 | memcpy(pstrDelAllStationMsg->au8Sta_DelAllSta[i], pu8MacAddr[i], ETH_ALEN); |
c5c77ba1 JK |
7135 | PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n", pstrDelAllStationMsg->au8Sta_DelAllSta[i][0], pstrDelAllStationMsg->au8Sta_DelAllSta[i][1], pstrDelAllStationMsg->au8Sta_DelAllSta[i][2], pstrDelAllStationMsg->au8Sta_DelAllSta[i][3], pstrDelAllStationMsg->au8Sta_DelAllSta[i][4], |
7136 | pstrDelAllStationMsg->au8Sta_DelAllSta[i][5]); | |
7137 | u8AssocNumb++; | |
7138 | } | |
7139 | } | |
7140 | if (!u8AssocNumb) { | |
7141 | PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n"); | |
7142 | return s32Error; | |
7143 | } | |
7144 | ||
7145 | pstrDelAllStationMsg->u8Num_AssocSta = u8AssocNumb; | |
143eb95a | 7146 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
7147 | |
7148 | ||
2b9d5b48 | 7149 | if (s32Error) |
24db713f | 7150 | PRINT_ER("wilc_mq_send fail\n"); |
c5c77ba1 | 7151 | |
83383ea3 | 7152 | down(&hWaitResponse); |
c5c77ba1 JK |
7153 | |
7154 | return s32Error; | |
7155 | ||
7156 | } | |
7157 | ||
7158 | /** | |
7159 | * @brief host_int_edit_station | |
7160 | * @details Setting edit station params in message queue | |
6a89ba9c | 7161 | * @param[in] WILC_WFIDrvHandle hWFIDrv, struct add_sta_param *pstrStaParams |
c5c77ba1 JK |
7162 | * @return Error code. |
7163 | * @author | |
7164 | * @date | |
7165 | * @version 1.0 | |
7166 | */ | |
6a89ba9c TC |
7167 | s32 host_int_edit_station(tstrWILC_WFIDrv *hWFIDrv, |
7168 | struct add_sta_param *pstrStaParams) | |
c5c77ba1 | 7169 | { |
e6e12661 | 7170 | s32 s32Error = 0; |
c5c77ba1 | 7171 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 7172 | struct host_if_msg msg; |
6a89ba9c | 7173 | struct add_sta_param *pstrAddStationMsg = &msg.body.strAddStaParam; |
c5c77ba1 | 7174 | |
24db713f LK |
7175 | if (pstrWFIDrv == NULL) { |
7176 | PRINT_ER("driver is null\n"); | |
7177 | return -EFAULT; | |
7178 | } | |
c5c77ba1 JK |
7179 | |
7180 | PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n"); | |
7181 | ||
143eb95a | 7182 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
7183 | |
7184 | ||
7185 | /* prepare the WiphyParams Message */ | |
a9f812a6 | 7186 | msg.id = HOST_IF_MSG_EDIT_STATION; |
143eb95a | 7187 | msg.drvHandler = hWFIDrv; |
c5c77ba1 | 7188 | |
6a89ba9c | 7189 | memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param)); |
c5c77ba1 | 7190 | if (pstrAddStationMsg->u8NumRates > 0) { |
f3052587 | 7191 | u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL); |
78c87591 | 7192 | |
7ae43363 LK |
7193 | if (!rates) |
7194 | return -ENOMEM; | |
7195 | ||
d00d2ba3 | 7196 | memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates); |
057d1e97 | 7197 | pstrAddStationMsg->pu8Rates = rates; |
c5c77ba1 JK |
7198 | } |
7199 | ||
143eb95a | 7200 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
2b9d5b48 | 7201 | if (s32Error) |
24db713f LK |
7202 | PRINT_ER("wilc_mq_send fail\n"); |
7203 | ||
c5c77ba1 JK |
7204 | return s32Error; |
7205 | } | |
108b3439 | 7206 | |
218dc407 | 7207 | s32 host_int_set_power_mgmt(tstrWILC_WFIDrv *hWFIDrv, bool bIsEnabled, u32 u32Timeout) |
c5c77ba1 | 7208 | { |
e6e12661 | 7209 | s32 s32Error = 0; |
c5c77ba1 | 7210 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 7211 | struct host_if_msg msg; |
5a008f1c | 7212 | struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.strPowerMgmtparam; |
c5c77ba1 | 7213 | |
03b2d5e7 | 7214 | PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled); |
c5c77ba1 | 7215 | |
24db713f LK |
7216 | if (pstrWFIDrv == NULL) { |
7217 | PRINT_ER("driver is null\n"); | |
7218 | return -EFAULT; | |
7219 | } | |
c5c77ba1 JK |
7220 | |
7221 | PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n"); | |
7222 | ||
143eb95a | 7223 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
7224 | |
7225 | ||
7226 | /* prepare the WiphyParams Message */ | |
a9f812a6 | 7227 | msg.id = HOST_IF_MSG_POWER_MGMT; |
143eb95a | 7228 | msg.drvHandler = hWFIDrv; |
c5c77ba1 JK |
7229 | |
7230 | pstrPowerMgmtParam->bIsEnabled = bIsEnabled; | |
7231 | pstrPowerMgmtParam->u32Timeout = u32Timeout; | |
7232 | ||
7233 | ||
143eb95a | 7234 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
2b9d5b48 | 7235 | if (s32Error) |
24db713f | 7236 | PRINT_ER("wilc_mq_send fail\n"); |
c5c77ba1 JK |
7237 | return s32Error; |
7238 | } | |
7239 | ||
218dc407 | 7240 | s32 host_int_setup_multicast_filter(tstrWILC_WFIDrv *hWFIDrv, bool bIsEnabled, u32 u32count) |
c5c77ba1 | 7241 | { |
e6e12661 | 7242 | s32 s32Error = 0; |
c5c77ba1 JK |
7243 | |
7244 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; | |
143eb95a | 7245 | struct host_if_msg msg; |
641210ac | 7246 | struct set_multicast *pstrMulticastFilterParam = &msg.body.strHostIfSetMulti; |
c5c77ba1 JK |
7247 | |
7248 | ||
24db713f LK |
7249 | if (pstrWFIDrv == NULL) { |
7250 | PRINT_ER("driver is null\n"); | |
7251 | return -EFAULT; | |
7252 | } | |
c5c77ba1 JK |
7253 | |
7254 | PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n"); | |
7255 | ||
143eb95a | 7256 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
7257 | |
7258 | ||
7259 | /* prepare the WiphyParams Message */ | |
a9f812a6 | 7260 | msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER; |
143eb95a | 7261 | msg.drvHandler = hWFIDrv; |
c5c77ba1 JK |
7262 | |
7263 | pstrMulticastFilterParam->bIsEnabled = bIsEnabled; | |
7264 | pstrMulticastFilterParam->u32count = u32count; | |
7265 | ||
143eb95a | 7266 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
2b9d5b48 | 7267 | if (s32Error) |
24db713f | 7268 | PRINT_ER("wilc_mq_send fail\n"); |
c5c77ba1 JK |
7269 | return s32Error; |
7270 | } | |
7271 | ||
7272 | ||
7273 | ||
c5c77ba1 JK |
7274 | #ifdef WILC_PARSE_SCAN_IN_HOST |
7275 | ||
c5c77ba1 JK |
7276 | /** |
7277 | * @brief host_int_ParseJoinBssParam | |
7278 | * @details Parse Needed Join Parameters and save it in a new JoinBssParam entry | |
7279 | * @param[in] tstrNetworkInfo* ptstrNetworkInfo | |
7280 | * @return | |
7281 | * @author zsalah | |
7282 | * @date | |
7283 | * @version 1.0**/ | |
7284 | static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo) | |
7285 | { | |
7286 | tstrJoinBssParam *pNewJoinBssParam = NULL; | |
63d03e47 | 7287 | u8 *pu8IEs; |
d85f5326 CL |
7288 | u16 u16IEsLen; |
7289 | u16 index = 0; | |
63d03e47 GKH |
7290 | u8 suppRatesNo = 0; |
7291 | u8 extSuppRatesNo; | |
d85f5326 | 7292 | u16 jumpOffset; |
63d03e47 GKH |
7293 | u8 pcipherCount; |
7294 | u8 authCount; | |
7295 | u8 pcipherTotalCount = 0; | |
7296 | u8 authTotalCount = 0; | |
7297 | u8 i, j; | |
c5c77ba1 JK |
7298 | |
7299 | pu8IEs = ptstrNetworkInfo->pu8IEs; | |
7300 | u16IEsLen = ptstrNetworkInfo->u16IEsLen; | |
7301 | ||
f3052587 | 7302 | pNewJoinBssParam = kmalloc(sizeof(tstrJoinBssParam), GFP_KERNEL); |
c5c77ba1 | 7303 | if (pNewJoinBssParam != NULL) { |
2cc46837 | 7304 | memset(pNewJoinBssParam, 0, sizeof(tstrJoinBssParam)); |
c5c77ba1 JK |
7305 | pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod; |
7306 | pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod; | |
7307 | pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo; | |
d00d2ba3 | 7308 | memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6); |
c5c77ba1 JK |
7309 | /*for(i=0; i<6;i++) |
7310 | * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/ | |
d00d2ba3 | 7311 | memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1); |
c5c77ba1 | 7312 | pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen; |
2cc46837 CL |
7313 | memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3); |
7314 | memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3); | |
c5c77ba1 JK |
7315 | /*for(i=0; i<pNewJoinBssParam->ssidLen;i++) |
7316 | * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/ | |
7317 | ||
7318 | /* parse supported rates: */ | |
7319 | while (index < u16IEsLen) { | |
7320 | /* supportedRates IE */ | |
7321 | if (pu8IEs[index] == SUPP_RATES_IE) { | |
7322 | /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */ | |
7323 | suppRatesNo = pu8IEs[index + 1]; | |
7324 | pNewJoinBssParam->supp_rates[0] = suppRatesNo; | |
7325 | index += 2; /* skipping ID and length bytes; */ | |
7326 | ||
7327 | for (i = 0; i < suppRatesNo; i++) { | |
7328 | pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i]; | |
7329 | /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */ | |
7330 | } | |
7331 | index += suppRatesNo; | |
7332 | continue; | |
7333 | } | |
7334 | /* Ext SupportedRates IE */ | |
7335 | else if (pu8IEs[index] == EXT_SUPP_RATES_IE) { | |
7336 | /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */ | |
7337 | /* checking if no of ext. supp and supp rates < max limit */ | |
7338 | extSuppRatesNo = pu8IEs[index + 1]; | |
7339 | if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo)) | |
7340 | pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED; | |
7341 | else | |
7342 | pNewJoinBssParam->supp_rates[0] += extSuppRatesNo; | |
7343 | index += 2; | |
7344 | /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */ | |
7345 | for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) { | |
7346 | pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i]; | |
7347 | /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */ | |
7348 | } | |
7349 | index += extSuppRatesNo; | |
7350 | continue; | |
7351 | } | |
7352 | /* HT Cap. IE */ | |
7353 | else if (pu8IEs[index] == HT_CAPABILITY_IE) { | |
7354 | /* if IE found set the flag */ | |
0be1eb74 | 7355 | pNewJoinBssParam->ht_capable = true; |
c5c77ba1 JK |
7356 | index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */ |
7357 | /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */ | |
7358 | continue; | |
7359 | } else if ((pu8IEs[index] == WMM_IE) && /* WMM Element ID */ | |
7360 | (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) && | |
7361 | (pu8IEs[index + 4] == 0xF2) && /* OUI */ | |
7362 | (pu8IEs[index + 5] == 0x02) && /* OUI Type */ | |
7363 | ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) && /* OUI Sub Type */ | |
7364 | (pu8IEs[index + 7] == 0x01)) { | |
7365 | /* Presence of WMM Info/Param element indicates WMM capability */ | |
0be1eb74 | 7366 | pNewJoinBssParam->wmm_cap = true; |
c5c77ba1 JK |
7367 | |
7368 | /* Check if Bit 7 is set indicating U-APSD capability */ | |
2b9d5b48 | 7369 | if (pu8IEs[index + 8] & (1 << 7)) |
0be1eb74 | 7370 | pNewJoinBssParam->uapsd_cap = true; |
c5c77ba1 JK |
7371 | index += pu8IEs[index + 1] + 2; |
7372 | continue; | |
7373 | } | |
c5c77ba1 JK |
7374 | else if ((pu8IEs[index] == P2P_IE) && /* P2P Element ID */ |
7375 | (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) && | |
7376 | (pu8IEs[index + 4] == 0x9a) && /* OUI */ | |
7377 | (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) { /* OUI Type */ | |
d85f5326 | 7378 | u16 u16P2P_count; |
78c87591 | 7379 | |
c5c77ba1 JK |
7380 | pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf; |
7381 | pNewJoinBssParam->u8NoaEnbaled = 1; | |
7382 | pNewJoinBssParam->u8Index = pu8IEs[index + 9]; | |
7383 | ||
7384 | /* Check if Bit 7 is set indicating Opss capability */ | |
7385 | if (pu8IEs[index + 10] & (1 << 7)) { | |
7386 | pNewJoinBssParam->u8OppEnable = 1; | |
7387 | pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10]; | |
7388 | } else | |
7389 | pNewJoinBssParam->u8OppEnable = 0; | |
7390 | /* HOSTINF_DBG */ | |
03b2d5e7 | 7391 | PRINT_D(GENERIC_DBG, "P2P Dump\n"); |
c5c77ba1 | 7392 | for (i = 0; i < pu8IEs[index + 7]; i++) |
03b2d5e7 | 7393 | PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]); |
c5c77ba1 JK |
7394 | |
7395 | pNewJoinBssParam->u8Count = pu8IEs[index + 11]; | |
7396 | u16P2P_count = index + 12; | |
7397 | ||
d00d2ba3 | 7398 | memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4); |
c5c77ba1 JK |
7399 | u16P2P_count += 4; |
7400 | ||
d00d2ba3 | 7401 | memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4); |
c5c77ba1 JK |
7402 | u16P2P_count += 4; |
7403 | ||
d00d2ba3 | 7404 | memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4); |
c5c77ba1 JK |
7405 | |
7406 | index += pu8IEs[index + 1] + 2; | |
7407 | continue; | |
7408 | ||
7409 | } | |
c5c77ba1 JK |
7410 | else if ((pu8IEs[index] == RSN_IE) || |
7411 | ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) && | |
7412 | (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) && | |
7413 | (pu8IEs[index + 5] == 0x01))) { | |
d85f5326 | 7414 | u16 rsnIndex = index; |
c5c77ba1 JK |
7415 | /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]); |
7416 | * for(i=0; i<pu8IEs[rsnIndex+1]; i++) | |
7417 | * { | |
7418 | * PRINT_D(HOSTINF_DBG,"%0x ",pu8IEs[rsnIndex+2+i]); | |
7419 | * }*/ | |
7420 | if (pu8IEs[rsnIndex] == RSN_IE) { | |
7421 | pNewJoinBssParam->mode_802_11i = 2; | |
7422 | /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */ | |
7423 | } else { /* check if rsn was previously parsed */ | |
7424 | if (pNewJoinBssParam->mode_802_11i == 0) | |
7425 | pNewJoinBssParam->mode_802_11i = 1; | |
7426 | /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */ | |
7427 | rsnIndex += 4; | |
7428 | } | |
7429 | rsnIndex += 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */ | |
7430 | pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex]; | |
7431 | rsnIndex++; | |
03b2d5e7 | 7432 | /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x\n",pNewJoinBssParam->rsn_grp_policy); */ |
c5c77ba1 JK |
7433 | /* initialize policies with invalid values */ |
7434 | ||
7435 | jumpOffset = pu8IEs[rsnIndex] * 4; /* total no.of bytes of pcipher field (count*4) */ | |
7436 | ||
7437 | /*parsing pairwise cipher*/ | |
7438 | ||
7439 | /* saving 3 pcipher max. */ | |
7440 | pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex]; | |
7441 | rsnIndex += 2; /* jump 2 bytes of pcipher count */ | |
7442 | ||
03b2d5e7 | 7443 | /* PRINT_D(HOSTINF_DBG,"\npcipher:%d\n",pcipherCount); */ |
c5c77ba1 JK |
7444 | for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) { |
7445 | /* each count corresponds to 4 bytes, only last byte is saved */ | |
7446 | pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1]; | |
7447 | /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */ | |
7448 | } | |
7449 | pcipherTotalCount += pcipherCount; | |
7450 | rsnIndex += jumpOffset; | |
7451 | ||
7452 | jumpOffset = pu8IEs[rsnIndex] * 4; | |
7453 | ||
7454 | /*parsing AKM suite (auth_policy)*/ | |
7455 | /* saving 3 auth policies max. */ | |
7456 | authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex]; | |
7457 | rsnIndex += 2; /* jump 2 bytes of pcipher count */ | |
7458 | ||
7459 | for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) { | |
7460 | /* each count corresponds to 4 bytes, only last byte is saved */ | |
7461 | pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1]; | |
7462 | } | |
7463 | authTotalCount += authCount; | |
7464 | rsnIndex += jumpOffset; | |
7465 | /*pasring rsn cap. only if rsn IE*/ | |
7466 | if (pu8IEs[index] == RSN_IE) { | |
7467 | pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex]; | |
7468 | pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1]; | |
7469 | rsnIndex += 2; | |
7470 | } | |
f717c0eb | 7471 | pNewJoinBssParam->rsn_found = true; |
c5c77ba1 JK |
7472 | index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */ |
7473 | continue; | |
7474 | } else | |
7475 | index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */ | |
7476 | ||
7477 | } | |
7478 | ||
7479 | ||
7480 | } | |
7481 | ||
7482 | return (void *)pNewJoinBssParam; | |
7483 | ||
7484 | } | |
7485 | ||
7486 | void host_int_freeJoinParams(void *pJoinParams) | |
7487 | { | |
7488 | if ((tstrJoinBssParam *)pJoinParams != NULL) | |
49188af2 | 7489 | kfree((tstrJoinBssParam *)pJoinParams); |
c5c77ba1 JK |
7490 | else |
7491 | PRINT_ER("Unable to FREE null pointer\n"); | |
7492 | } | |
7493 | #endif /*WILC_PARSE_SCAN_IN_HOST*/ | |
7494 | ||
7495 | ||
7496 | /** | |
7497 | * @brief host_int_addBASession | |
7498 | * @details Open a block Ack session with the given parameters | |
7499 | * @param[in] tstrNetworkInfo* ptstrNetworkInfo | |
7500 | * @return | |
7501 | * @author anoureldin | |
7502 | * @date | |
7503 | * @version 1.0**/ | |
7504 | ||
2b05df55 | 7505 | static int host_int_addBASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID, short int BufferSize, |
c5c77ba1 JK |
7506 | short int SessionTimeout, void *drvHandler) |
7507 | { | |
e6e12661 | 7508 | s32 s32Error = 0; |
c5c77ba1 | 7509 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 7510 | struct host_if_msg msg; |
54265472 | 7511 | struct ba_session_info *pBASessionInfo = &msg.body.strHostIfBASessionInfo; |
c5c77ba1 | 7512 | |
24db713f LK |
7513 | if (pstrWFIDrv == NULL) { |
7514 | PRINT_ER("driver is null\n"); | |
7515 | return -EFAULT; | |
7516 | } | |
c5c77ba1 | 7517 | |
143eb95a | 7518 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
7519 | |
7520 | /* prepare the WiphyParams Message */ | |
a9f812a6 | 7521 | msg.id = HOST_IF_MSG_ADD_BA_SESSION; |
c5c77ba1 JK |
7522 | |
7523 | memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN); | |
7524 | pBASessionInfo->u8Ted = TID; | |
7525 | pBASessionInfo->u16BufferSize = BufferSize; | |
7526 | pBASessionInfo->u16SessionTimeout = SessionTimeout; | |
143eb95a | 7527 | msg.drvHandler = hWFIDrv; |
c5c77ba1 | 7528 | |
143eb95a | 7529 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
2b9d5b48 | 7530 | if (s32Error) |
24db713f | 7531 | PRINT_ER("wilc_mq_send fail\n"); |
c5c77ba1 JK |
7532 | |
7533 | return s32Error; | |
7534 | } | |
7535 | ||
7536 | ||
218dc407 | 7537 | s32 host_int_delBASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID) |
c5c77ba1 | 7538 | { |
e6e12661 | 7539 | s32 s32Error = 0; |
c5c77ba1 | 7540 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 7541 | struct host_if_msg msg; |
54265472 | 7542 | struct ba_session_info *pBASessionInfo = &msg.body.strHostIfBASessionInfo; |
c5c77ba1 | 7543 | |
24db713f LK |
7544 | if (pstrWFIDrv == NULL) { |
7545 | PRINT_ER("driver is null\n"); | |
7546 | return -EFAULT; | |
7547 | } | |
c5c77ba1 | 7548 | |
143eb95a | 7549 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
7550 | |
7551 | /* prepare the WiphyParams Message */ | |
a9f812a6 | 7552 | msg.id = HOST_IF_MSG_DEL_BA_SESSION; |
c5c77ba1 JK |
7553 | |
7554 | memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN); | |
7555 | pBASessionInfo->u8Ted = TID; | |
143eb95a | 7556 | msg.drvHandler = hWFIDrv; |
c5c77ba1 | 7557 | |
143eb95a | 7558 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
2b9d5b48 | 7559 | if (s32Error) |
24db713f | 7560 | PRINT_ER("wilc_mq_send fail\n"); |
c5c77ba1 | 7561 | |
83383ea3 | 7562 | down(&hWaitResponse); |
c5c77ba1 JK |
7563 | |
7564 | return s32Error; | |
7565 | } | |
7566 | ||
218dc407 | 7567 | s32 host_int_del_All_Rx_BASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID) |
c5c77ba1 | 7568 | { |
e6e12661 | 7569 | s32 s32Error = 0; |
c5c77ba1 | 7570 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 7571 | struct host_if_msg msg; |
54265472 | 7572 | struct ba_session_info *pBASessionInfo = &msg.body.strHostIfBASessionInfo; |
c5c77ba1 | 7573 | |
24db713f LK |
7574 | if (pstrWFIDrv == NULL) { |
7575 | PRINT_ER("driver is null\n"); | |
7576 | return -EFAULT; | |
7577 | } | |
c5c77ba1 | 7578 | |
143eb95a | 7579 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
7580 | |
7581 | /* prepare the WiphyParams Message */ | |
a9f812a6 | 7582 | msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS; |
c5c77ba1 JK |
7583 | |
7584 | memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN); | |
7585 | pBASessionInfo->u8Ted = TID; | |
143eb95a | 7586 | msg.drvHandler = hWFIDrv; |
c5c77ba1 | 7587 | |
143eb95a | 7588 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
2b9d5b48 | 7589 | if (s32Error) |
24db713f | 7590 | PRINT_ER("wilc_mq_send fail\n"); |
c5c77ba1 | 7591 | |
83383ea3 | 7592 | down(&hWaitResponse); |
c5c77ba1 JK |
7593 | |
7594 | return s32Error; | |
7595 | } | |
7596 | ||
7597 | /** | |
7598 | * @brief host_int_setup_ipaddress | |
7599 | * @details setup IP in firmware | |
7600 | * @param[in] Handle to wifi driver | |
7601 | * @return Error code. | |
7602 | * @author Abdelrahman Sobhy | |
7603 | * @date | |
7604 | * @version 1.0*/ | |
218dc407 | 7605 | s32 host_int_setup_ipaddress(tstrWILC_WFIDrv *hWFIDrv, u8 *u16ipadd, u8 idx) |
c5c77ba1 | 7606 | { |
e6e12661 | 7607 | s32 s32Error = 0; |
c5c77ba1 | 7608 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 7609 | struct host_if_msg msg; |
c5c77ba1 JK |
7610 | |
7611 | /* TODO: Enable This feature on softap firmware */ | |
7612 | return 0; | |
7613 | ||
24db713f LK |
7614 | if (pstrWFIDrv == NULL) { |
7615 | PRINT_ER("driver is null\n"); | |
7616 | return -EFAULT; | |
7617 | } | |
c5c77ba1 | 7618 | |
143eb95a | 7619 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
7620 | |
7621 | /* prepare the WiphyParams Message */ | |
a9f812a6 | 7622 | msg.id = HOST_IF_MSG_SET_IPADDRESS; |
c5c77ba1 | 7623 | |
410c2489 | 7624 | msg.body.strHostIfSetIP.au8IPAddr = u16ipadd; |
143eb95a | 7625 | msg.drvHandler = hWFIDrv; |
410c2489 | 7626 | msg.body.strHostIfSetIP.idx = idx; |
c5c77ba1 | 7627 | |
143eb95a | 7628 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
2b9d5b48 | 7629 | if (s32Error) |
24db713f | 7630 | PRINT_ER("wilc_mq_send fail\n"); |
c5c77ba1 JK |
7631 | |
7632 | return s32Error; | |
7633 | ||
7634 | ||
7635 | } | |
7636 | ||
7637 | /** | |
7638 | * @brief host_int_get_ipaddress | |
7639 | * @details Get IP from firmware | |
7640 | * @param[in] Handle to wifi driver | |
7641 | * @return Error code. | |
7642 | * @author Abdelrahman Sobhy | |
7643 | * @date | |
7644 | * @version 1.0*/ | |
218dc407 | 7645 | s32 host_int_get_ipaddress(tstrWILC_WFIDrv *hWFIDrv, u8 *u16ipadd, u8 idx) |
c5c77ba1 | 7646 | { |
e6e12661 | 7647 | s32 s32Error = 0; |
c5c77ba1 | 7648 | tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; |
143eb95a | 7649 | struct host_if_msg msg; |
c5c77ba1 | 7650 | |
24db713f LK |
7651 | if (pstrWFIDrv == NULL) { |
7652 | PRINT_ER("driver is null\n"); | |
7653 | return -EFAULT; | |
7654 | } | |
c5c77ba1 | 7655 | |
143eb95a | 7656 | memset(&msg, 0, sizeof(struct host_if_msg)); |
c5c77ba1 JK |
7657 | |
7658 | /* prepare the WiphyParams Message */ | |
a9f812a6 | 7659 | msg.id = HOST_IF_MSG_GET_IPADDRESS; |
c5c77ba1 | 7660 | |
410c2489 | 7661 | msg.body.strHostIfSetIP.au8IPAddr = u16ipadd; |
143eb95a | 7662 | msg.drvHandler = hWFIDrv; |
410c2489 | 7663 | msg.body.strHostIfSetIP.idx = idx; |
c5c77ba1 | 7664 | |
143eb95a | 7665 | s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg)); |
2b9d5b48 | 7666 | if (s32Error) |
24db713f | 7667 | PRINT_ER("wilc_mq_send fail\n"); |
c5c77ba1 JK |
7668 | |
7669 | return s32Error; | |
7670 | ||
7671 | ||
7672 | } |