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