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