staging: wilc1000: periodic_rssi can be static
[deliverable/linux.git] / drivers / staging / wilc1000 / host_interface.c
1 #include <linux/slab.h>
2 #include <linux/time.h>
3 #include <linux/kthread.h>
4 #include <linux/delay.h>
5 #include "host_interface.h"
6 #include "coreconfigurator.h"
7 #include "wilc_wlan_if.h"
8 #include "wilc_msgqueue.h"
9 #include <linux/etherdevice.h>
10
11 extern u8 connecting;
12
13 extern struct timer_list hDuringIpTimer;
14
15 extern u8 g_wilc_initialized;
16
17 #define HOST_IF_MSG_SCAN 0
18 #define HOST_IF_MSG_CONNECT 1
19 #define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
20 #define HOST_IF_MSG_KEY 3
21 #define HOST_IF_MSG_RCVD_NTWRK_INFO 4
22 #define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
23 #define HOST_IF_MSG_CFG_PARAMS 6
24 #define HOST_IF_MSG_SET_CHANNEL 7
25 #define HOST_IF_MSG_DISCONNECT 8
26 #define HOST_IF_MSG_GET_RSSI 9
27 #define HOST_IF_MSG_GET_CHNL 10
28 #define HOST_IF_MSG_ADD_BEACON 11
29 #define HOST_IF_MSG_DEL_BEACON 12
30 #define HOST_IF_MSG_ADD_STATION 13
31 #define HOST_IF_MSG_DEL_STATION 14
32 #define HOST_IF_MSG_EDIT_STATION 15
33 #define HOST_IF_MSG_SCAN_TIMER_FIRED 16
34 #define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
35 #define HOST_IF_MSG_POWER_MGMT 18
36 #define HOST_IF_MSG_GET_INACTIVETIME 19
37 #define HOST_IF_MSG_REMAIN_ON_CHAN 20
38 #define HOST_IF_MSG_REGISTER_FRAME 21
39 #define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
40 #define HOST_IF_MSG_GET_LINKSPEED 23
41 #define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
42 #define HOST_IF_MSG_SET_MAC_ADDRESS 25
43 #define HOST_IF_MSG_GET_MAC_ADDRESS 26
44 #define HOST_IF_MSG_SET_OPERATION_MODE 27
45 #define HOST_IF_MSG_SET_IPADDRESS 28
46 #define HOST_IF_MSG_GET_IPADDRESS 29
47 #define HOST_IF_MSG_FLUSH_CONNECT 30
48 #define HOST_IF_MSG_GET_STATISTICS 31
49 #define HOST_IF_MSG_SET_MULTICAST_FILTER 32
50 #define HOST_IF_MSG_ADD_BA_SESSION 33
51 #define HOST_IF_MSG_DEL_BA_SESSION 34
52 #define HOST_IF_MSG_Q_IDLE 35
53 #define HOST_IF_MSG_DEL_ALL_STA 36
54 #define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
55 #define HOST_IF_MSG_EXIT 100
56
57 #define HOST_IF_SCAN_TIMEOUT 4000
58 #define HOST_IF_CONNECT_TIMEOUT 9500
59
60 #define BA_SESSION_DEFAULT_BUFFER_SIZE 16
61 #define BA_SESSION_DEFAULT_TIMEOUT 1000
62 #define BLOCK_ACK_REQ_SIZE 0x14
63
64 struct cfg_param_attr {
65 struct cfg_param_val cfg_attr_info;
66 };
67
68 struct host_if_wpa_attr {
69 u8 *key;
70 const u8 *mac_addr;
71 u8 *seq;
72 u8 seq_len;
73 u8 index;
74 u8 key_len;
75 u8 mode;
76 };
77
78 struct host_if_wep_attr {
79 u8 *key;
80 u8 key_len;
81 u8 index;
82 u8 mode;
83 enum AUTHTYPE auth_type;
84 };
85
86 union host_if_key_attr {
87 struct host_if_wep_attr wep;
88 struct host_if_wpa_attr wpa;
89 struct host_if_pmkid_attr pmkid;
90 };
91
92 struct key_attr {
93 enum KEY_TYPE type;
94 u8 action;
95 union host_if_key_attr attr;
96 };
97
98 struct scan_attr {
99 u8 src;
100 u8 type;
101 u8 *ch_freq_list;
102 u8 ch_list_len;
103 u8 *ies;
104 size_t ies_len;
105 wilc_scan_result result;
106 void *arg;
107 struct hidden_network hidden_network;
108 };
109
110 struct connect_attr {
111 u8 *bssid;
112 u8 *ssid;
113 size_t ssid_len;
114 u8 *ies;
115 size_t ies_len;
116 u8 security;
117 wilc_connect_result result;
118 void *arg;
119 enum AUTHTYPE auth_type;
120 u8 ch;
121 void *params;
122 };
123
124 struct rcvd_async_info {
125 u8 *buffer;
126 u32 len;
127 };
128
129 struct channel_attr {
130 u8 set_ch;
131 };
132
133 struct beacon_attr {
134 u32 interval;
135 u32 dtim_period;
136 u32 head_len;
137 u8 *head;
138 u32 tail_len;
139 u8 *tail;
140 };
141
142 struct set_multicast {
143 bool enabled;
144 u32 cnt;
145 };
146
147 struct del_all_sta {
148 u8 del_all_sta[MAX_NUM_STA][ETH_ALEN];
149 u8 assoc_sta;
150 };
151
152 struct del_sta {
153 u8 mac_addr[ETH_ALEN];
154 };
155
156 struct power_mgmt_param {
157 bool enabled;
158 u32 timeout;
159 };
160
161 struct set_ip_addr {
162 u8 *ip_addr;
163 u8 idx;
164 };
165
166 struct sta_inactive_t {
167 u8 mac[6];
168 };
169
170 union message_body {
171 struct scan_attr scan_info;
172 struct connect_attr con_info;
173 struct rcvd_net_info net_info;
174 struct rcvd_async_info async_info;
175 struct key_attr key_info;
176 struct cfg_param_attr cfg_info;
177 struct channel_attr channel_info;
178 struct beacon_attr beacon_info;
179 struct add_sta_param add_sta_info;
180 struct del_sta del_sta_info;
181 struct add_sta_param edit_sta_info;
182 struct power_mgmt_param pwr_mgmt_info;
183 struct sta_inactive_t mac_info;
184 struct set_ip_addr ip_info;
185 struct drv_handler drv;
186 struct set_multicast multicast_info;
187 struct op_mode mode;
188 struct set_mac_addr set_mac_info;
189 struct get_mac_addr get_mac_info;
190 struct ba_session_info session_info;
191 struct remain_ch remain_on_ch;
192 struct reg_frame reg_frame;
193 char *data;
194 struct del_all_sta del_all_sta_info;
195 };
196
197 struct host_if_msg {
198 u16 id;
199 union message_body body;
200 struct host_if_drv *drv;
201 };
202
203 struct join_bss_param {
204 BSSTYPE_T bss_type;
205 u8 dtim_period;
206 u16 beacon_period;
207 u16 cap_info;
208 u8 au8bssid[6];
209 char ssid[MAX_SSID_LEN];
210 u8 ssid_len;
211 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
212 u8 ht_capable;
213 u8 wmm_cap;
214 u8 uapsd_cap;
215 bool rsn_found;
216 u8 rsn_grp_policy;
217 u8 mode_802_11i;
218 u8 rsn_pcip_policy[3];
219 u8 rsn_auth_policy[3];
220 u8 rsn_cap[2];
221 u32 tsf;
222 u8 noa_enabled;
223 u8 opp_enabled;
224 u8 ct_window;
225 u8 cnt;
226 u8 idx;
227 u8 duration[4];
228 u8 interval[4];
229 u8 au8StartTime[4];
230 };
231
232 static struct host_if_drv *wfidrv_list[NUM_CONCURRENT_IFC + 1];
233 struct host_if_drv *terminated_handle;
234 bool g_obtainingIP;
235 u8 P2P_LISTEN_STATE;
236 static struct task_struct *hif_thread_handler;
237 static WILC_MsgQueueHandle hif_msg_q;
238 static struct semaphore hif_sema_thread;
239 static struct semaphore hif_sema_driver;
240 static struct semaphore hif_sema_wait_response;
241 static struct semaphore hif_sema_deinit;
242 static struct timer_list periodic_rssi;
243
244 u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
245
246 static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE];
247
248 bool gbScanWhileConnected;
249
250 static s8 gs8Rssi;
251 static s8 gs8lnkspd;
252 static u8 gu8Chnl;
253 static u8 gs8SetIP[2][4];
254 static u8 gs8GetIP[2][4];
255 static u32 gu32InactiveTime;
256 static u8 gu8DelBcn;
257 static u32 gu32WidConnRstHack;
258
259 u8 *gu8FlushedJoinReq;
260 u8 *gu8FlushedInfoElemAsoc;
261 u8 gu8Flushed11iMode;
262 u8 gu8FlushedAuthType;
263 u32 gu32FlushedJoinReqSize;
264 u32 gu32FlushedInfoElemAsocSize;
265 struct host_if_drv *gu8FlushedJoinReqDrvHandler;
266 #define REAL_JOIN_REQ 0
267 #define FLUSHED_JOIN_REQ 1
268 #define FLUSHED_BYTE_POS 79
269
270 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
271
272 extern void chip_sleep_manually(u32 u32SleepTime);
273 extern int linux_wlan_get_num_conn_ifcs(void);
274
275 static int add_handler_in_list(struct host_if_drv *handler)
276 {
277 int i;
278
279 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
280 if (!wfidrv_list[i]) {
281 wfidrv_list[i] = handler;
282 return 0;
283 }
284 }
285
286 return -ENOBUFS;
287 }
288
289 static int remove_handler_in_list(struct host_if_drv *handler)
290 {
291 int i;
292
293 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
294 if (wfidrv_list[i] == handler) {
295 wfidrv_list[i] = NULL;
296 return 0;
297 }
298 }
299
300 return -EINVAL;
301 }
302
303 static int get_id_from_handler(struct host_if_drv *handler)
304 {
305 int i;
306
307 if (!handler)
308 return 0;
309
310 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
311 if (wfidrv_list[i] == handler)
312 return i;
313 }
314
315 return 0;
316 }
317
318 static struct host_if_drv *get_handler_from_id(int id)
319 {
320 if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list))
321 return NULL;
322 return wfidrv_list[id];
323 }
324
325 static s32 Handle_SetChannel(struct host_if_drv *hif_drv,
326 struct channel_attr *pstrHostIFSetChan)
327 {
328
329 s32 s32Error = 0;
330 struct wid strWID;
331
332 strWID.id = (u16)WID_CURRENT_CHANNEL;
333 strWID.type = WID_CHAR;
334 strWID.val = (char *)&(pstrHostIFSetChan->set_ch);
335 strWID.size = sizeof(char);
336
337 PRINT_D(HOSTINF_DBG, "Setting channel\n");
338
339 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
340 get_id_from_handler(hif_drv));
341 if (s32Error) {
342 PRINT_ER("Failed to set channel\n");
343 return -EINVAL;
344 }
345
346 return s32Error;
347 }
348
349 static s32 Handle_SetWfiDrvHandler(struct host_if_drv *hif_drv,
350 struct drv_handler *pstrHostIfSetDrvHandler)
351 {
352
353 s32 s32Error = 0;
354 struct wid strWID;
355
356 strWID.id = (u16)WID_SET_DRV_HANDLER;
357 strWID.type = WID_INT;
358 strWID.val = (s8 *)&(pstrHostIfSetDrvHandler->u32Address);
359 strWID.size = sizeof(u32);
360
361 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
362 pstrHostIfSetDrvHandler->u32Address);
363
364 if (!hif_drv)
365 up(&hif_sema_driver);
366
367 if (s32Error) {
368 PRINT_ER("Failed to set driver handler\n");
369 return -EINVAL;
370 }
371
372 return s32Error;
373 }
374
375 static s32 Handle_SetOperationMode(struct host_if_drv *hif_drv,
376 struct op_mode *pstrHostIfSetOperationMode)
377 {
378
379 s32 s32Error = 0;
380 struct wid strWID;
381
382 strWID.id = (u16)WID_SET_OPERATION_MODE;
383 strWID.type = WID_INT;
384 strWID.val = (s8 *)&(pstrHostIfSetOperationMode->u32Mode);
385 strWID.size = sizeof(u32);
386
387 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
388 get_id_from_handler(hif_drv));
389
390
391 if ((pstrHostIfSetOperationMode->u32Mode) == IDLE_MODE)
392 up(&hif_sema_driver);
393
394 if (s32Error) {
395 PRINT_ER("Failed to set driver handler\n");
396 return -EINVAL;
397 }
398
399 return s32Error;
400 }
401
402 s32 Handle_set_IPAddress(struct host_if_drv *hif_drv, u8 *pu8IPAddr, u8 idx)
403 {
404
405 s32 s32Error = 0;
406 struct wid strWID;
407 char firmwareIPAddress[4] = {0};
408
409 if (pu8IPAddr[0] < 192)
410 pu8IPAddr[0] = 0;
411
412 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n", idx, pu8IPAddr);
413
414 memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN);
415
416 strWID.id = (u16)WID_IP_ADDRESS;
417 strWID.type = WID_STR;
418 strWID.val = (u8 *)pu8IPAddr;
419 strWID.size = IP_ALEN;
420
421 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
422 get_id_from_handler(hif_drv));
423
424
425 host_int_get_ipaddress(hif_drv, firmwareIPAddress, idx);
426
427 if (s32Error) {
428 PRINT_ER("Failed to set IP address\n");
429 return -EINVAL;
430 }
431
432 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
433
434 return s32Error;
435 }
436
437 s32 Handle_get_IPAddress(struct host_if_drv *hif_drv, u8 *pu8IPAddr, u8 idx)
438 {
439
440 s32 s32Error = 0;
441 struct wid strWID;
442
443 strWID.id = (u16)WID_IP_ADDRESS;
444 strWID.type = WID_STR;
445 strWID.val = kmalloc(IP_ALEN, GFP_KERNEL);
446 strWID.size = IP_ALEN;
447
448 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
449 get_id_from_handler(hif_drv));
450
451 PRINT_INFO(HOSTINF_DBG, "%pI4\n", strWID.val);
452
453 memcpy(gs8GetIP[idx], strWID.val, IP_ALEN);
454
455 kfree(strWID.val);
456
457 if (memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0)
458 host_int_setup_ipaddress(hif_drv, gs8SetIP[idx], idx);
459
460 if (s32Error != 0) {
461 PRINT_ER("Failed to get IP address\n");
462 return -EINVAL;
463 }
464
465 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
466 PRINT_INFO(HOSTINF_DBG, "%pI4\n", gs8GetIP[idx]);
467 PRINT_INFO(HOSTINF_DBG, "\n");
468
469 return s32Error;
470 }
471
472 static s32 Handle_SetMacAddress(struct host_if_drv *hif_drv,
473 struct set_mac_addr *pstrHostIfSetMacAddress)
474 {
475
476 s32 s32Error = 0;
477 struct wid strWID;
478 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
479
480 if (mac_buf == NULL) {
481 PRINT_ER("No buffer to send mac address\n");
482 return -EFAULT;
483 }
484 memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
485
486 strWID.id = (u16)WID_MAC_ADDR;
487 strWID.type = WID_STR;
488 strWID.val = mac_buf;
489 strWID.size = ETH_ALEN;
490 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", strWID.val);
491
492 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
493 get_id_from_handler(hif_drv));
494 if (s32Error) {
495 PRINT_ER("Failed to set mac address\n");
496 s32Error = -EFAULT;
497 }
498
499 kfree(mac_buf);
500 return s32Error;
501 }
502
503 static s32 Handle_GetMacAddress(struct host_if_drv *hif_drv,
504 struct get_mac_addr *pstrHostIfGetMacAddress)
505 {
506
507 s32 s32Error = 0;
508 struct wid strWID;
509
510 strWID.id = (u16)WID_MAC_ADDR;
511 strWID.type = WID_STR;
512 strWID.val = pstrHostIfGetMacAddress->u8MacAddress;
513 strWID.size = ETH_ALEN;
514
515 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
516 get_id_from_handler(hif_drv));
517 if (s32Error) {
518 PRINT_ER("Failed to get mac address\n");
519 s32Error = -EFAULT;
520 }
521 up(&hif_sema_wait_response);
522
523 return s32Error;
524 }
525
526 static s32 Handle_CfgParam(struct host_if_drv *hif_drv,
527 struct cfg_param_attr *strHostIFCfgParamAttr)
528 {
529 s32 s32Error = 0;
530 struct wid strWIDList[32];
531 u8 u8WidCnt = 0;
532
533 down(&hif_drv->gtOsCfgValuesSem);
534
535
536 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
537
538 if (strHostIFCfgParamAttr->cfg_attr_info.flag & BSS_TYPE) {
539 if (strHostIFCfgParamAttr->cfg_attr_info.bss_type < 6) {
540 strWIDList[u8WidCnt].id = WID_BSS_TYPE;
541 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.bss_type;
542 strWIDList[u8WidCnt].type = WID_CHAR;
543 strWIDList[u8WidCnt].size = sizeof(char);
544 hif_drv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->cfg_attr_info.bss_type;
545 } else {
546 PRINT_ER("check value 6 over\n");
547 s32Error = -EINVAL;
548 goto ERRORHANDLER;
549 }
550 u8WidCnt++;
551 }
552 if (strHostIFCfgParamAttr->cfg_attr_info.flag & AUTH_TYPE) {
553 if ((strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 1 || (strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 2 || (strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 5) {
554 strWIDList[u8WidCnt].id = WID_AUTH_TYPE;
555 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.auth_type;
556 strWIDList[u8WidCnt].type = WID_CHAR;
557 strWIDList[u8WidCnt].size = sizeof(char);
558 hif_drv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->cfg_attr_info.auth_type;
559 } else {
560 PRINT_ER("Impossible value \n");
561 s32Error = -EINVAL;
562 goto ERRORHANDLER;
563 }
564 u8WidCnt++;
565 }
566 if (strHostIFCfgParamAttr->cfg_attr_info.flag & AUTHEN_TIMEOUT) {
567 if (strHostIFCfgParamAttr->cfg_attr_info.auth_timeout > 0 && strHostIFCfgParamAttr->cfg_attr_info.auth_timeout < 65536) {
568 strWIDList[u8WidCnt].id = WID_AUTH_TIMEOUT;
569 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.auth_timeout;
570 strWIDList[u8WidCnt].type = WID_SHORT;
571 strWIDList[u8WidCnt].size = sizeof(u16);
572 hif_drv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->cfg_attr_info.auth_timeout;
573 } else {
574 PRINT_ER("Range(1 ~ 65535) over\n");
575 s32Error = -EINVAL;
576 goto ERRORHANDLER;
577 }
578 u8WidCnt++;
579 }
580 if (strHostIFCfgParamAttr->cfg_attr_info.flag & POWER_MANAGEMENT) {
581 if (strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode < 5) {
582 strWIDList[u8WidCnt].id = WID_POWER_MANAGEMENT;
583 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode;
584 strWIDList[u8WidCnt].type = WID_CHAR;
585 strWIDList[u8WidCnt].size = sizeof(char);
586 hif_drv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode;
587 } else {
588 PRINT_ER("Invalide power mode\n");
589 s32Error = -EINVAL;
590 goto ERRORHANDLER;
591 }
592 u8WidCnt++;
593 }
594 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RETRY_SHORT) {
595 if ((strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit > 0) && (strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit < 256)) {
596 strWIDList[u8WidCnt].id = WID_SHORT_RETRY_LIMIT;
597 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit;
598 strWIDList[u8WidCnt].type = WID_SHORT;
599 strWIDList[u8WidCnt].size = sizeof(u16);
600 hif_drv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit;
601 } else {
602 PRINT_ER("Range(1~256) over\n");
603 s32Error = -EINVAL;
604 goto ERRORHANDLER;
605 }
606 u8WidCnt++;
607 }
608 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RETRY_LONG) {
609 if ((strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit > 0) && (strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit < 256)) {
610 strWIDList[u8WidCnt].id = WID_LONG_RETRY_LIMIT;
611 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit;
612
613 strWIDList[u8WidCnt].type = WID_SHORT;
614 strWIDList[u8WidCnt].size = sizeof(u16);
615 hif_drv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit;
616 } else {
617 PRINT_ER("Range(1~256) over\n");
618 s32Error = -EINVAL;
619 goto ERRORHANDLER;
620 }
621 u8WidCnt++;
622 }
623 if (strHostIFCfgParamAttr->cfg_attr_info.flag & FRAG_THRESHOLD) {
624
625 if (strHostIFCfgParamAttr->cfg_attr_info.frag_threshold > 255 && strHostIFCfgParamAttr->cfg_attr_info.frag_threshold < 7937) {
626 strWIDList[u8WidCnt].id = WID_FRAG_THRESHOLD;
627 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.frag_threshold;
628 strWIDList[u8WidCnt].type = WID_SHORT;
629 strWIDList[u8WidCnt].size = sizeof(u16);
630 hif_drv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->cfg_attr_info.frag_threshold;
631 } else {
632 PRINT_ER("Threshold Range fail\n");
633 s32Error = -EINVAL;
634 goto ERRORHANDLER;
635 }
636 u8WidCnt++;
637 }
638 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RTS_THRESHOLD) {
639 if (strHostIFCfgParamAttr->cfg_attr_info.rts_threshold > 255 && strHostIFCfgParamAttr->cfg_attr_info.rts_threshold < 65536) {
640 strWIDList[u8WidCnt].id = WID_RTS_THRESHOLD;
641 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.rts_threshold;
642 strWIDList[u8WidCnt].type = WID_SHORT;
643 strWIDList[u8WidCnt].size = sizeof(u16);
644 hif_drv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->cfg_attr_info.rts_threshold;
645 } else {
646 PRINT_ER("Threshold Range fail\n");
647 s32Error = -EINVAL;
648 goto ERRORHANDLER;
649 }
650 u8WidCnt++;
651 }
652 if (strHostIFCfgParamAttr->cfg_attr_info.flag & PREAMBLE) {
653 if (strHostIFCfgParamAttr->cfg_attr_info.preamble_type < 3) {
654 strWIDList[u8WidCnt].id = WID_PREAMBLE;
655 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.preamble_type;
656 strWIDList[u8WidCnt].type = WID_CHAR;
657 strWIDList[u8WidCnt].size = sizeof(char);
658 hif_drv->strCfgValues.preamble_type = strHostIFCfgParamAttr->cfg_attr_info.preamble_type;
659 } else {
660 PRINT_ER("Preamle Range(0~2) over\n");
661 s32Error = -EINVAL;
662 goto ERRORHANDLER;
663 }
664 u8WidCnt++;
665 }
666 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SHORT_SLOT_ALLOWED) {
667 if (strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed < 2) {
668 strWIDList[u8WidCnt].id = WID_SHORT_SLOT_ALLOWED;
669 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed;
670 strWIDList[u8WidCnt].type = WID_CHAR;
671 strWIDList[u8WidCnt].size = sizeof(char);
672 hif_drv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed;
673 } else {
674 PRINT_ER("Short slot(2) over\n");
675 s32Error = -EINVAL;
676 goto ERRORHANDLER;
677 }
678 u8WidCnt++;
679 }
680 if (strHostIFCfgParamAttr->cfg_attr_info.flag & TXOP_PROT_DISABLE) {
681 if (strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled < 2) {
682 strWIDList[u8WidCnt].id = WID_11N_TXOP_PROT_DISABLE;
683 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled;
684 strWIDList[u8WidCnt].type = WID_CHAR;
685 strWIDList[u8WidCnt].size = sizeof(char);
686 hif_drv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled;
687 } else {
688 PRINT_ER("TXOP prot disable\n");
689 s32Error = -EINVAL;
690 goto ERRORHANDLER;
691 }
692 u8WidCnt++;
693 }
694 if (strHostIFCfgParamAttr->cfg_attr_info.flag & BEACON_INTERVAL) {
695 if (strHostIFCfgParamAttr->cfg_attr_info.beacon_interval > 0 && strHostIFCfgParamAttr->cfg_attr_info.beacon_interval < 65536) {
696 strWIDList[u8WidCnt].id = WID_BEACON_INTERVAL;
697 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.beacon_interval;
698 strWIDList[u8WidCnt].type = WID_SHORT;
699 strWIDList[u8WidCnt].size = sizeof(u16);
700 hif_drv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->cfg_attr_info.beacon_interval;
701 } else {
702 PRINT_ER("Beacon interval(1~65535) fail\n");
703 s32Error = -EINVAL;
704 goto ERRORHANDLER;
705 }
706 u8WidCnt++;
707 }
708 if (strHostIFCfgParamAttr->cfg_attr_info.flag & DTIM_PERIOD) {
709 if (strHostIFCfgParamAttr->cfg_attr_info.dtim_period > 0 && strHostIFCfgParamAttr->cfg_attr_info.dtim_period < 256) {
710 strWIDList[u8WidCnt].id = WID_DTIM_PERIOD;
711 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.dtim_period;
712 strWIDList[u8WidCnt].type = WID_CHAR;
713 strWIDList[u8WidCnt].size = sizeof(char);
714 hif_drv->strCfgValues.dtim_period = strHostIFCfgParamAttr->cfg_attr_info.dtim_period;
715 } else {
716 PRINT_ER("DTIM range(1~255) fail\n");
717 s32Error = -EINVAL;
718 goto ERRORHANDLER;
719 }
720 u8WidCnt++;
721 }
722 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SITE_SURVEY) {
723 if (strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled < 3) {
724 strWIDList[u8WidCnt].id = WID_SITE_SURVEY;
725 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled;
726 strWIDList[u8WidCnt].type = WID_CHAR;
727 strWIDList[u8WidCnt].size = sizeof(char);
728 hif_drv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled;
729 } else {
730 PRINT_ER("Site survey disable\n");
731 s32Error = -EINVAL;
732 goto ERRORHANDLER;
733 }
734 u8WidCnt++;
735 }
736 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SITE_SURVEY_SCAN_TIME) {
737 if (strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time < 65536) {
738 strWIDList[u8WidCnt].id = WID_SITE_SURVEY_SCAN_TIME;
739 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time;
740 strWIDList[u8WidCnt].type = WID_SHORT;
741 strWIDList[u8WidCnt].size = sizeof(u16);
742 hif_drv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time;
743 } else {
744 PRINT_ER("Site survey scan time(1~65535) over\n");
745 s32Error = -EINVAL;
746 goto ERRORHANDLER;
747 }
748 u8WidCnt++;
749 }
750 if (strHostIFCfgParamAttr->cfg_attr_info.flag & ACTIVE_SCANTIME) {
751 if (strHostIFCfgParamAttr->cfg_attr_info.active_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.active_scan_time < 65536) {
752 strWIDList[u8WidCnt].id = WID_ACTIVE_SCAN_TIME;
753 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.active_scan_time;
754 strWIDList[u8WidCnt].type = WID_SHORT;
755 strWIDList[u8WidCnt].size = sizeof(u16);
756 hif_drv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->cfg_attr_info.active_scan_time;
757 } else {
758 PRINT_ER("Active scan time(1~65535) over\n");
759 s32Error = -EINVAL;
760 goto ERRORHANDLER;
761 }
762 u8WidCnt++;
763 }
764 if (strHostIFCfgParamAttr->cfg_attr_info.flag & PASSIVE_SCANTIME) {
765 if (strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time < 65536) {
766 strWIDList[u8WidCnt].id = WID_PASSIVE_SCAN_TIME;
767 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time;
768 strWIDList[u8WidCnt].type = WID_SHORT;
769 strWIDList[u8WidCnt].size = sizeof(u16);
770 hif_drv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time;
771 } else {
772 PRINT_ER("Passive scan time(1~65535) over\n");
773 s32Error = -EINVAL;
774 goto ERRORHANDLER;
775 }
776 u8WidCnt++;
777 }
778 if (strHostIFCfgParamAttr->cfg_attr_info.flag & CURRENT_TX_RATE) {
779 enum CURRENT_TXRATE curr_tx_rate = strHostIFCfgParamAttr->cfg_attr_info.curr_tx_rate;
780 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
781 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
782 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
783 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
784 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
785 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
786 strWIDList[u8WidCnt].id = WID_CURRENT_TX_RATE;
787 strWIDList[u8WidCnt].val = (s8 *)&curr_tx_rate;
788 strWIDList[u8WidCnt].type = WID_SHORT;
789 strWIDList[u8WidCnt].size = sizeof(u16);
790 hif_drv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
791 } else {
792 PRINT_ER("out of TX rate\n");
793 s32Error = -EINVAL;
794 goto ERRORHANDLER;
795 }
796 u8WidCnt++;
797 }
798 s32Error = send_config_pkt(SET_CFG, strWIDList, u8WidCnt,
799 get_id_from_handler(hif_drv));
800
801 if (s32Error)
802 PRINT_ER("Error in setting CFG params\n");
803
804 ERRORHANDLER:
805 up(&hif_drv->gtOsCfgValuesSem);
806 return s32Error;
807 }
808
809 static s32 Handle_wait_msg_q_empty(void)
810 {
811 g_wilc_initialized = 0;
812 up(&hif_sema_wait_response);
813 return 0;
814 }
815
816 static s32 Handle_Scan(struct host_if_drv *hif_drv,
817 struct scan_attr *pstrHostIFscanAttr)
818 {
819 s32 s32Error = 0;
820 struct wid strWIDList[5];
821 u32 u32WidsCount = 0;
822 u32 i;
823 u8 *pu8Buffer;
824 u8 valuesize = 0;
825 u8 *pu8HdnNtwrksWidVal = NULL;
826
827 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
828 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", hif_drv->enuHostIFstate);
829
830 hif_drv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->result;
831 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->arg;
832
833 if ((hif_drv->enuHostIFstate >= HOST_IF_SCANNING) && (hif_drv->enuHostIFstate < HOST_IF_CONNECTED)) {
834 PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", hif_drv->enuHostIFstate);
835 PRINT_ER("Already scan\n");
836 s32Error = -EBUSY;
837 goto ERRORHANDLER;
838 }
839
840 if (g_obtainingIP || connecting) {
841 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
842 PRINT_ER("Don't do obss scan\n");
843 s32Error = -EBUSY;
844 goto ERRORHANDLER;
845 }
846
847 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
848
849
850 hif_drv->strWILC_UsrScanReq.u32RcvdChCount = 0;
851
852 strWIDList[u32WidsCount].id = (u16)WID_SSID_PROBE_REQ;
853 strWIDList[u32WidsCount].type = WID_STR;
854
855 for (i = 0; i < pstrHostIFscanAttr->hidden_network.u8ssidnum; i++)
856 valuesize += ((pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
857 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
858 strWIDList[u32WidsCount].val = pu8HdnNtwrksWidVal;
859 if (strWIDList[u32WidsCount].val != NULL) {
860 pu8Buffer = strWIDList[u32WidsCount].val;
861
862 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.u8ssidnum;
863
864 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->hidden_network.u8ssidnum);
865
866 for (i = 0; i < pstrHostIFscanAttr->hidden_network.u8ssidnum; i++) {
867 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen;
868 memcpy(pu8Buffer, pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen);
869 pu8Buffer += pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen;
870 }
871
872
873
874 strWIDList[u32WidsCount].size = (s32)(valuesize + 1);
875 u32WidsCount++;
876 }
877
878 {
879 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_PROBE;
880 strWIDList[u32WidsCount].type = WID_BIN_DATA;
881 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ies;
882 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ies_len;
883 u32WidsCount++;
884 }
885
886 strWIDList[u32WidsCount].id = WID_SCAN_TYPE;
887 strWIDList[u32WidsCount].type = WID_CHAR;
888 strWIDList[u32WidsCount].size = sizeof(char);
889 strWIDList[u32WidsCount].val = (s8 *)(&(pstrHostIFscanAttr->type));
890 u32WidsCount++;
891
892 strWIDList[u32WidsCount].id = WID_SCAN_CHANNEL_LIST;
893 strWIDList[u32WidsCount].type = WID_BIN_DATA;
894
895 if (pstrHostIFscanAttr->ch_freq_list != NULL && pstrHostIFscanAttr->ch_list_len > 0) {
896 int i;
897
898 for (i = 0; i < pstrHostIFscanAttr->ch_list_len; i++) {
899 if (pstrHostIFscanAttr->ch_freq_list[i] > 0)
900 pstrHostIFscanAttr->ch_freq_list[i] = pstrHostIFscanAttr->ch_freq_list[i] - 1;
901 }
902 }
903
904 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ch_freq_list;
905 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ch_list_len;
906 u32WidsCount++;
907
908 strWIDList[u32WidsCount].id = WID_START_SCAN_REQ;
909 strWIDList[u32WidsCount].type = WID_CHAR;
910 strWIDList[u32WidsCount].size = sizeof(char);
911 strWIDList[u32WidsCount].val = (s8 *)(&(pstrHostIFscanAttr->src));
912 u32WidsCount++;
913
914 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)
915 gbScanWhileConnected = true;
916 else if (hif_drv->enuHostIFstate == HOST_IF_IDLE)
917 gbScanWhileConnected = false;
918
919 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
920 get_id_from_handler(hif_drv));
921
922 if (s32Error)
923 PRINT_ER("Failed to send scan paramters config packet\n");
924 else
925 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
926
927 ERRORHANDLER:
928 if (s32Error) {
929 del_timer(&hif_drv->hScanTimer);
930 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
931 }
932
933 kfree(pstrHostIFscanAttr->ch_freq_list);
934 pstrHostIFscanAttr->ch_freq_list = NULL;
935
936 kfree(pstrHostIFscanAttr->ies);
937 pstrHostIFscanAttr->ies = NULL;
938 kfree(pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo);
939 pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo = NULL;
940
941 kfree(pu8HdnNtwrksWidVal);
942
943 return s32Error;
944 }
945
946 static s32 Handle_ScanDone(struct host_if_drv *hif_drv,
947 enum scan_event enuEvent)
948 {
949 s32 s32Error = 0;
950 u8 u8abort_running_scan;
951 struct wid strWID;
952
953
954 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
955
956 if (enuEvent == SCAN_EVENT_ABORTED) {
957 PRINT_D(GENERIC_DBG, "Abort running scan\n");
958 u8abort_running_scan = 1;
959 strWID.id = (u16)WID_ABORT_RUNNING_SCAN;
960 strWID.type = WID_CHAR;
961 strWID.val = (s8 *)&u8abort_running_scan;
962 strWID.size = sizeof(char);
963
964 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
965 get_id_from_handler(hif_drv));
966 if (s32Error) {
967 PRINT_ER("Failed to set abort running scan\n");
968 s32Error = -EFAULT;
969 }
970 }
971
972 if (!hif_drv) {
973 PRINT_ER("Driver handler is NULL\n");
974 return s32Error;
975 }
976
977 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
978 hif_drv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
979 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
980 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
981 }
982
983 return s32Error;
984 }
985
986 u8 u8ConnectedSSID[6] = {0};
987 static s32 Handle_Connect(struct host_if_drv *hif_drv,
988 struct connect_attr *pstrHostIFconnectAttr)
989 {
990 s32 s32Error = 0;
991 struct wid strWIDList[8];
992 u32 u32WidsCount = 0, dummyval = 0;
993 u8 *pu8CurrByte = NULL;
994 struct join_bss_param *ptstrJoinBssParam;
995
996 PRINT_D(GENERIC_DBG, "Handling connect request\n");
997
998 if (memcmp(pstrHostIFconnectAttr->bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
999
1000 s32Error = 0;
1001 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1002 return s32Error;
1003 }
1004
1005 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1006
1007 ptstrJoinBssParam = (struct join_bss_param *)pstrHostIFconnectAttr->params;
1008 if (ptstrJoinBssParam == NULL) {
1009 PRINT_ER("Required BSSID not found\n");
1010 s32Error = -ENOENT;
1011 goto ERRORHANDLER;
1012 }
1013
1014 if (pstrHostIFconnectAttr->bssid != NULL) {
1015 hif_drv->strWILC_UsrConnReq.pu8bssid = kmalloc(6, GFP_KERNEL);
1016 memcpy(hif_drv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->bssid, 6);
1017 }
1018
1019 hif_drv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssid_len;
1020 if (pstrHostIFconnectAttr->ssid != NULL) {
1021 hif_drv->strWILC_UsrConnReq.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssid_len + 1, GFP_KERNEL);
1022 memcpy(hif_drv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->ssid,
1023 pstrHostIFconnectAttr->ssid_len);
1024 hif_drv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssid_len] = '\0';
1025 }
1026
1027 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->ies_len;
1028 if (pstrHostIFconnectAttr->ies != NULL) {
1029 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
1030 memcpy(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->ies,
1031 pstrHostIFconnectAttr->ies_len);
1032 }
1033
1034 hif_drv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->security;
1035 hif_drv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->auth_type;
1036 hif_drv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->result;
1037 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->arg;
1038
1039 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
1040 strWIDList[u32WidsCount].type = WID_INT;
1041 strWIDList[u32WidsCount].size = sizeof(u32);
1042 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1043 u32WidsCount++;
1044
1045 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
1046 strWIDList[u32WidsCount].type = WID_INT;
1047 strWIDList[u32WidsCount].size = sizeof(u32);
1048 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1049 u32WidsCount++;
1050
1051 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
1052 strWIDList[u32WidsCount].type = WID_INT;
1053 strWIDList[u32WidsCount].size = sizeof(u32);
1054 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1055 u32WidsCount++;
1056
1057 {
1058 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
1059 strWIDList[u32WidsCount].type = WID_BIN_DATA;
1060 strWIDList[u32WidsCount].val = hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs;
1061 strWIDList[u32WidsCount].size = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1062 u32WidsCount++;
1063
1064 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1065
1066 gu32FlushedInfoElemAsocSize = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1067 gu8FlushedInfoElemAsoc = kmalloc(gu32FlushedInfoElemAsocSize, GFP_KERNEL);
1068 memcpy(gu8FlushedInfoElemAsoc, hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
1069 gu32FlushedInfoElemAsocSize);
1070 }
1071 }
1072 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
1073 strWIDList[u32WidsCount].type = WID_CHAR;
1074 strWIDList[u32WidsCount].size = sizeof(char);
1075 strWIDList[u32WidsCount].val = (s8 *)(&(hif_drv->strWILC_UsrConnReq.u8security));
1076 u32WidsCount++;
1077
1078 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
1079 gu8Flushed11iMode = hif_drv->strWILC_UsrConnReq.u8security;
1080
1081 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", hif_drv->strWILC_UsrConnReq.u8security);
1082
1083
1084 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
1085 strWIDList[u32WidsCount].type = WID_CHAR;
1086 strWIDList[u32WidsCount].size = sizeof(char);
1087 strWIDList[u32WidsCount].val = (s8 *)(&hif_drv->strWILC_UsrConnReq.tenuAuth_type);
1088 u32WidsCount++;
1089
1090 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
1091 gu8FlushedAuthType = (u8)hif_drv->strWILC_UsrConnReq.tenuAuth_type;
1092
1093 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", hif_drv->strWILC_UsrConnReq.tenuAuth_type);
1094 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
1095 hif_drv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->ch);
1096
1097 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
1098 strWIDList[u32WidsCount].type = WID_STR;
1099 strWIDList[u32WidsCount].size = 112;
1100 strWIDList[u32WidsCount].val = kmalloc(strWIDList[u32WidsCount].size, GFP_KERNEL);
1101
1102 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1103 gu32FlushedJoinReqSize = strWIDList[u32WidsCount].size;
1104 gu8FlushedJoinReq = kmalloc(gu32FlushedJoinReqSize, GFP_KERNEL);
1105 }
1106 if (strWIDList[u32WidsCount].val == NULL) {
1107 s32Error = -EFAULT;
1108 goto ERRORHANDLER;
1109 }
1110
1111 pu8CurrByte = strWIDList[u32WidsCount].val;
1112
1113
1114 if (pstrHostIFconnectAttr->ssid != NULL) {
1115 memcpy(pu8CurrByte, pstrHostIFconnectAttr->ssid, pstrHostIFconnectAttr->ssid_len);
1116 pu8CurrByte[pstrHostIFconnectAttr->ssid_len] = '\0';
1117 }
1118 pu8CurrByte += MAX_SSID_LEN;
1119 *(pu8CurrByte++) = INFRASTRUCTURE;
1120
1121 if ((pstrHostIFconnectAttr->ch >= 1) && (pstrHostIFconnectAttr->ch <= 14)) {
1122 *(pu8CurrByte++) = pstrHostIFconnectAttr->ch;
1123 } else {
1124 PRINT_ER("Channel out of range\n");
1125 *(pu8CurrByte++) = 0xFF;
1126 }
1127 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1128 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1129 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1130
1131 if (pstrHostIFconnectAttr->bssid != NULL)
1132 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
1133 pu8CurrByte += 6;
1134
1135 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1136 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1137 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1138 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1139 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1140
1141 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
1142 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1143
1144 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1145 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1146 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1147
1148 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1149 hif_drv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
1150
1151 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1152 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1153 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1154 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1155 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1156 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1157
1158 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
1159 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1160
1161 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
1162 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1163
1164 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
1165 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1166
1167 *(pu8CurrByte++) = REAL_JOIN_REQ;
1168 *(pu8CurrByte++) = ptstrJoinBssParam->noa_enabled;
1169
1170 if (ptstrJoinBssParam->noa_enabled) {
1171 PRINT_D(HOSTINF_DBG, "NOA present\n");
1172
1173 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1174 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1175 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1176 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1177
1178 *(pu8CurrByte++) = ptstrJoinBssParam->opp_enabled;
1179 *(pu8CurrByte++) = ptstrJoinBssParam->idx;
1180
1181 if (ptstrJoinBssParam->opp_enabled)
1182 *(pu8CurrByte++) = ptstrJoinBssParam->ct_window;
1183
1184 *(pu8CurrByte++) = ptstrJoinBssParam->cnt;
1185
1186 memcpy(pu8CurrByte, ptstrJoinBssParam->duration, sizeof(ptstrJoinBssParam->duration));
1187 pu8CurrByte += sizeof(ptstrJoinBssParam->duration);
1188
1189 memcpy(pu8CurrByte, ptstrJoinBssParam->interval, sizeof(ptstrJoinBssParam->interval));
1190 pu8CurrByte += sizeof(ptstrJoinBssParam->interval);
1191
1192 memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
1193
1194 pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1195
1196 } else
1197 PRINT_D(HOSTINF_DBG, "NOA not present\n");
1198
1199 pu8CurrByte = strWIDList[u32WidsCount].val;
1200 u32WidsCount++;
1201 gu32WidConnRstHack = 0;
1202
1203 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1204 memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
1205 gu8FlushedJoinReqDrvHandler = hif_drv;
1206 }
1207
1208 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1209
1210 if (pstrHostIFconnectAttr->bssid != NULL) {
1211 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->bssid, ETH_ALEN);
1212
1213 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n", pstrHostIFconnectAttr->bssid);
1214 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", u8ConnectedSSID);
1215 }
1216
1217 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
1218 get_id_from_handler(hif_drv));
1219 if (s32Error) {
1220 PRINT_ER("failed to send config packet\n");
1221 s32Error = -EFAULT;
1222 goto ERRORHANDLER;
1223 } else {
1224 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
1225 hif_drv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1226 }
1227
1228 ERRORHANDLER:
1229 if (s32Error) {
1230 tstrConnectInfo strConnectInfo;
1231
1232 del_timer(&hif_drv->hConnectTimer);
1233
1234 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
1235
1236 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1237
1238 if (pstrHostIFconnectAttr->result != NULL) {
1239 if (pstrHostIFconnectAttr->bssid != NULL)
1240 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->bssid, 6);
1241
1242 if (pstrHostIFconnectAttr->ies != NULL) {
1243 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->ies_len;
1244 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
1245 memcpy(strConnectInfo.pu8ReqIEs,
1246 pstrHostIFconnectAttr->ies,
1247 pstrHostIFconnectAttr->ies_len);
1248 }
1249
1250 pstrHostIFconnectAttr->result(CONN_DISCONN_EVENT_CONN_RESP,
1251 &strConnectInfo,
1252 MAC_DISCONNECTED,
1253 NULL,
1254 pstrHostIFconnectAttr->arg);
1255 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1256 kfree(strConnectInfo.pu8ReqIEs);
1257 strConnectInfo.pu8ReqIEs = NULL;
1258
1259 } else {
1260 PRINT_ER("Connect callback function pointer is NULL\n");
1261 }
1262 }
1263
1264 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
1265 kfree(pstrHostIFconnectAttr->bssid);
1266 pstrHostIFconnectAttr->bssid = NULL;
1267
1268 kfree(pstrHostIFconnectAttr->ssid);
1269 pstrHostIFconnectAttr->ssid = NULL;
1270
1271 kfree(pstrHostIFconnectAttr->ies);
1272 pstrHostIFconnectAttr->ies = NULL;
1273
1274 kfree(pu8CurrByte);
1275 return s32Error;
1276 }
1277
1278 static s32 Handle_FlushConnect(struct host_if_drv *hif_drv)
1279 {
1280 s32 s32Error = 0;
1281 struct wid strWIDList[5];
1282 u32 u32WidsCount = 0;
1283 u8 *pu8CurrByte = NULL;
1284
1285 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
1286 strWIDList[u32WidsCount].type = WID_BIN_DATA;
1287 strWIDList[u32WidsCount].val = gu8FlushedInfoElemAsoc;
1288 strWIDList[u32WidsCount].size = gu32FlushedInfoElemAsocSize;
1289 u32WidsCount++;
1290
1291 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
1292 strWIDList[u32WidsCount].type = WID_CHAR;
1293 strWIDList[u32WidsCount].size = sizeof(char);
1294 strWIDList[u32WidsCount].val = (s8 *)(&(gu8Flushed11iMode));
1295 u32WidsCount++;
1296
1297
1298
1299 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
1300 strWIDList[u32WidsCount].type = WID_CHAR;
1301 strWIDList[u32WidsCount].size = sizeof(char);
1302 strWIDList[u32WidsCount].val = (s8 *)(&gu8FlushedAuthType);
1303 u32WidsCount++;
1304
1305 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
1306 strWIDList[u32WidsCount].type = WID_STR;
1307 strWIDList[u32WidsCount].size = gu32FlushedJoinReqSize;
1308 strWIDList[u32WidsCount].val = (s8 *)gu8FlushedJoinReq;
1309 pu8CurrByte = strWIDList[u32WidsCount].val;
1310
1311 pu8CurrByte += FLUSHED_BYTE_POS;
1312 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1313
1314 u32WidsCount++;
1315
1316 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
1317 get_id_from_handler(gu8FlushedJoinReqDrvHandler));
1318 if (s32Error) {
1319 PRINT_ER("failed to send config packet\n");
1320 s32Error = -EINVAL;
1321 }
1322
1323 return s32Error;
1324 }
1325
1326 static s32 Handle_ConnectTimeout(struct host_if_drv *hif_drv)
1327 {
1328 s32 s32Error = 0;
1329 tstrConnectInfo strConnectInfo;
1330 struct wid strWID;
1331 u16 u16DummyReasonCode = 0;
1332
1333 if (!hif_drv) {
1334 PRINT_ER("Driver handler is NULL\n");
1335 return s32Error;
1336 }
1337
1338 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1339
1340 gbScanWhileConnected = false;
1341
1342
1343 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1344
1345 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
1346 if (hif_drv->strWILC_UsrConnReq.pu8bssid != NULL) {
1347 memcpy(strConnectInfo.au8bssid,
1348 hif_drv->strWILC_UsrConnReq.pu8bssid, 6);
1349 }
1350
1351 if (hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1352 strConnectInfo.ReqIEsLen = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1353 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
1354 memcpy(strConnectInfo.pu8ReqIEs,
1355 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
1356 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen);
1357 }
1358
1359 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1360 &strConnectInfo,
1361 MAC_DISCONNECTED,
1362 NULL,
1363 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
1364
1365 kfree(strConnectInfo.pu8ReqIEs);
1366 strConnectInfo.pu8ReqIEs = NULL;
1367 } else {
1368 PRINT_ER("Connect callback function pointer is NULL\n");
1369 }
1370
1371 strWID.id = (u16)WID_DISCONNECT;
1372 strWID.type = WID_CHAR;
1373 strWID.val = (s8 *)&u16DummyReasonCode;
1374 strWID.size = sizeof(char);
1375
1376 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1377
1378 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1379 get_id_from_handler(hif_drv));
1380 if (s32Error)
1381 PRINT_ER("Failed to send dissconect config packet\n");
1382
1383 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
1384 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
1385 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
1386 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1387 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
1388
1389 eth_zero_addr(u8ConnectedSSID);
1390
1391 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
1392 kfree(gu8FlushedJoinReq);
1393 gu8FlushedJoinReq = NULL;
1394 }
1395 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
1396 kfree(gu8FlushedInfoElemAsoc);
1397 gu8FlushedInfoElemAsoc = NULL;
1398 }
1399
1400 return s32Error;
1401 }
1402
1403 static s32 Handle_RcvdNtwrkInfo(struct host_if_drv *hif_drv,
1404 struct rcvd_net_info *pstrRcvdNetworkInfo)
1405 {
1406 u32 i;
1407 bool bNewNtwrkFound;
1408
1409
1410
1411 s32 s32Error = 0;
1412 tstrNetworkInfo *pstrNetworkInfo = NULL;
1413 void *pJoinParams = NULL;
1414
1415 bNewNtwrkFound = true;
1416 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
1417
1418 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
1419 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
1420 parse_network_info(pstrRcvdNetworkInfo->buffer, &pstrNetworkInfo);
1421 if ((pstrNetworkInfo == NULL)
1422 || (hif_drv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
1423 PRINT_ER("driver is null\n");
1424 s32Error = -EINVAL;
1425 goto done;
1426 }
1427
1428 for (i = 0; i < hif_drv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
1429
1430 if ((hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
1431 (pstrNetworkInfo->au8bssid != NULL)) {
1432 if (memcmp(hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
1433 pstrNetworkInfo->au8bssid, 6) == 0) {
1434 if (pstrNetworkInfo->s8rssi <= hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
1435 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
1436 goto done;
1437 } else {
1438 hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
1439 bNewNtwrkFound = false;
1440 break;
1441 }
1442 }
1443 }
1444 }
1445
1446 if (bNewNtwrkFound == true) {
1447 PRINT_D(HOSTINF_DBG, "New network found\n");
1448
1449 if (hif_drv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
1450 hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
1451
1452 if ((hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
1453 && (pstrNetworkInfo->au8bssid != NULL)) {
1454 memcpy(hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
1455 pstrNetworkInfo->au8bssid, 6);
1456
1457 hif_drv->strWILC_UsrScanReq.u32RcvdChCount++;
1458
1459 pstrNetworkInfo->bNewNetwork = true;
1460 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
1461
1462 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1463 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid,
1464 pJoinParams);
1465
1466
1467 }
1468 } else {
1469 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
1470 }
1471 } else {
1472 pstrNetworkInfo->bNewNetwork = false;
1473 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1474 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
1475 }
1476 }
1477
1478 done:
1479 kfree(pstrRcvdNetworkInfo->buffer);
1480 pstrRcvdNetworkInfo->buffer = NULL;
1481
1482 if (pstrNetworkInfo != NULL) {
1483 DeallocateNetworkInfo(pstrNetworkInfo);
1484 pstrNetworkInfo = NULL;
1485 }
1486
1487 return s32Error;
1488 }
1489
1490 static s32 Handle_RcvdGnrlAsyncInfo(struct host_if_drv *hif_drv,
1491 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
1492 {
1493 s32 s32Error = 0;
1494 u8 u8MsgType = 0;
1495 u8 u8MsgID = 0;
1496 u16 u16MsgLen = 0;
1497 u16 u16WidID = (u16)WID_NIL;
1498 u8 u8WidLen = 0;
1499 u8 u8MacStatus;
1500 u8 u8MacStatusReasonCode;
1501 u8 u8MacStatusAdditionalInfo;
1502 tstrConnectInfo strConnectInfo;
1503 tstrDisconnectNotifInfo strDisconnectNotifInfo;
1504 s32 s32Err = 0;
1505
1506 if (!hif_drv) {
1507 PRINT_ER("Driver handler is NULL\n");
1508 return -ENODEV;
1509 }
1510 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", hif_drv->enuHostIFstate,
1511 pstrRcvdGnrlAsyncInfo->buffer[7]);
1512
1513 if ((hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
1514 (hif_drv->enuHostIFstate == HOST_IF_CONNECTED) ||
1515 hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
1516 if ((pstrRcvdGnrlAsyncInfo->buffer == NULL) ||
1517 (hif_drv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
1518 PRINT_ER("driver is null\n");
1519 return -EINVAL;
1520 }
1521
1522 u8MsgType = pstrRcvdGnrlAsyncInfo->buffer[0];
1523
1524 if ('I' != u8MsgType) {
1525 PRINT_ER("Received Message format incorrect.\n");
1526 return -EFAULT;
1527 }
1528
1529 u8MsgID = pstrRcvdGnrlAsyncInfo->buffer[1];
1530 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[2], pstrRcvdGnrlAsyncInfo->buffer[3]);
1531 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[4], pstrRcvdGnrlAsyncInfo->buffer[5]);
1532 u8WidLen = pstrRcvdGnrlAsyncInfo->buffer[6];
1533 u8MacStatus = pstrRcvdGnrlAsyncInfo->buffer[7];
1534 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->buffer[8];
1535 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->buffer[9];
1536 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
1537 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
1538 u32 u32RcvdAssocRespInfoLen;
1539 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
1540
1541 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
1542
1543 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1544
1545 if (u8MacStatus == MAC_CONNECTED) {
1546 memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
1547
1548 host_int_get_assoc_res_info(hif_drv,
1549 gapu8RcvdAssocResp,
1550 MAX_ASSOC_RESP_FRAME_SIZE,
1551 &u32RcvdAssocRespInfoLen);
1552
1553 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
1554
1555 if (u32RcvdAssocRespInfoLen != 0) {
1556
1557 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
1558 s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
1559 &pstrConnectRespInfo);
1560 if (s32Err) {
1561 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
1562 } else {
1563 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
1564
1565 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
1566 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
1567 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
1568 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
1569
1570
1571 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL);
1572 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
1573 pstrConnectRespInfo->u16RespIEsLen);
1574 }
1575 }
1576
1577 if (pstrConnectRespInfo != NULL) {
1578 DeallocateAssocRespInfo(pstrConnectRespInfo);
1579 pstrConnectRespInfo = NULL;
1580 }
1581 }
1582 }
1583 }
1584
1585 if ((u8MacStatus == MAC_CONNECTED) &&
1586 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
1587 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
1588 eth_zero_addr(u8ConnectedSSID);
1589
1590 } else if (u8MacStatus == MAC_DISCONNECTED) {
1591 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
1592 eth_zero_addr(u8ConnectedSSID);
1593 }
1594
1595 if (hif_drv->strWILC_UsrConnReq.pu8bssid != NULL) {
1596 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
1597 memcpy(strConnectInfo.au8bssid, hif_drv->strWILC_UsrConnReq.pu8bssid, 6);
1598
1599 if ((u8MacStatus == MAC_CONNECTED) &&
1600 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
1601 memcpy(hif_drv->au8AssociatedBSSID,
1602 hif_drv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
1603 }
1604 }
1605
1606
1607 if (hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1608 strConnectInfo.ReqIEsLen = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1609 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
1610 memcpy(strConnectInfo.pu8ReqIEs,
1611 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
1612 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen);
1613 }
1614
1615
1616 del_timer(&hif_drv->hConnectTimer);
1617 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1618 &strConnectInfo,
1619 u8MacStatus,
1620 NULL,
1621 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
1622
1623 if ((u8MacStatus == MAC_CONNECTED) &&
1624 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
1625 host_int_set_power_mgmt(hif_drv, 0, 0);
1626
1627 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
1628 hif_drv->enuHostIFstate = HOST_IF_CONNECTED;
1629
1630 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
1631 g_obtainingIP = true;
1632 mod_timer(&hDuringIpTimer,
1633 jiffies + msecs_to_jiffies(10000));
1634 } else {
1635 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
1636 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1637 gbScanWhileConnected = false;
1638 }
1639
1640 kfree(strConnectInfo.pu8RespIEs);
1641 strConnectInfo.pu8RespIEs = NULL;
1642
1643 kfree(strConnectInfo.pu8ReqIEs);
1644 strConnectInfo.pu8ReqIEs = NULL;
1645 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
1646 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
1647 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
1648 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1649 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
1650 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
1651 (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)) {
1652 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
1653
1654 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
1655
1656 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
1657 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
1658 del_timer(&hif_drv->hScanTimer);
1659 Handle_ScanDone((void *)hif_drv, SCAN_EVENT_ABORTED);
1660 }
1661
1662 strDisconnectNotifInfo.u16reason = 0;
1663 strDisconnectNotifInfo.ie = NULL;
1664 strDisconnectNotifInfo.ie_len = 0;
1665
1666 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
1667 g_obtainingIP = false;
1668 host_int_set_power_mgmt(hif_drv, 0, 0);
1669
1670 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1671 NULL,
1672 0,
1673 &strDisconnectNotifInfo,
1674 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
1675
1676 } else {
1677 PRINT_ER("Connect result callback function is NULL\n");
1678 }
1679
1680 eth_zero_addr(hif_drv->au8AssociatedBSSID);
1681
1682 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
1683 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
1684 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
1685 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1686 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
1687
1688 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
1689 kfree(gu8FlushedJoinReq);
1690 gu8FlushedJoinReq = NULL;
1691 }
1692 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
1693 kfree(gu8FlushedInfoElemAsoc);
1694 gu8FlushedInfoElemAsoc = NULL;
1695 }
1696
1697 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1698 gbScanWhileConnected = false;
1699
1700 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
1701 (hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
1702 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
1703 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
1704
1705 del_timer(&hif_drv->hScanTimer);
1706 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult)
1707 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
1708
1709 }
1710
1711 }
1712
1713 kfree(pstrRcvdGnrlAsyncInfo->buffer);
1714 pstrRcvdGnrlAsyncInfo->buffer = NULL;
1715
1716 return s32Error;
1717 }
1718
1719 static int Handle_Key(struct host_if_drv *hif_drv,
1720 struct key_attr *pstrHostIFkeyAttr)
1721 {
1722 s32 s32Error = 0;
1723 struct wid strWID;
1724 struct wid strWIDList[5];
1725 u8 i;
1726 u8 *pu8keybuf;
1727 s8 s8idxarray[1];
1728 s8 ret = 0;
1729
1730 switch (pstrHostIFkeyAttr->type) {
1731
1732
1733 case WEP:
1734
1735 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1736
1737 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
1738 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->attr.wep.index));
1739 strWIDList[0].id = (u16)WID_11I_MODE;
1740 strWIDList[0].type = WID_CHAR;
1741 strWIDList[0].size = sizeof(char);
1742 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.mode));
1743
1744 strWIDList[1].id = WID_AUTH_TYPE;
1745 strWIDList[1].type = WID_CHAR;
1746 strWIDList[1].size = sizeof(char);
1747 strWIDList[1].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.auth_type));
1748
1749 strWIDList[2].id = (u16)WID_KEY_ID;
1750 strWIDList[2].type = WID_CHAR;
1751
1752 strWIDList[2].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.index));
1753 strWIDList[2].size = sizeof(char);
1754
1755 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len, GFP_KERNEL);
1756
1757 if (pu8keybuf == NULL) {
1758 PRINT_ER("No buffer to send Key\n");
1759 return -1;
1760 }
1761
1762 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wep.key,
1763 pstrHostIFkeyAttr->attr.wep.key_len);
1764
1765 kfree(pstrHostIFkeyAttr->attr.wep.key);
1766
1767 strWIDList[3].id = (u16)WID_WEP_KEY_VALUE;
1768 strWIDList[3].type = WID_STR;
1769 strWIDList[3].size = pstrHostIFkeyAttr->attr.wep.key_len;
1770 strWIDList[3].val = (s8 *)pu8keybuf;
1771
1772
1773 s32Error = send_config_pkt(SET_CFG, strWIDList, 4,
1774 get_id_from_handler(hif_drv));
1775 kfree(pu8keybuf);
1776
1777
1778 }
1779
1780 if (pstrHostIFkeyAttr->action & ADDKEY) {
1781 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
1782 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2, GFP_KERNEL);
1783 if (pu8keybuf == NULL) {
1784 PRINT_ER("No buffer to send Key\n");
1785 return -1;
1786 }
1787 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1788 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->attr.wep.key_len, 1);
1789 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->attr.wep.key,
1790 pstrHostIFkeyAttr->attr.wep.key_len);
1791 kfree(pstrHostIFkeyAttr->attr.wep.key);
1792
1793 strWID.id = (u16)WID_ADD_WEP_KEY;
1794 strWID.type = WID_STR;
1795 strWID.val = (s8 *)pu8keybuf;
1796 strWID.size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
1797
1798 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1799 get_id_from_handler(hif_drv));
1800 kfree(pu8keybuf);
1801 } else if (pstrHostIFkeyAttr->action & REMOVEKEY) {
1802
1803 PRINT_D(HOSTINF_DBG, "Removing key\n");
1804 strWID.id = (u16)WID_REMOVE_WEP_KEY;
1805 strWID.type = WID_STR;
1806
1807 s8idxarray[0] = (s8)pstrHostIFkeyAttr->attr.wep.index;
1808 strWID.val = s8idxarray;
1809 strWID.size = 1;
1810
1811 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1812 get_id_from_handler(hif_drv));
1813 } else {
1814 strWID.id = (u16)WID_KEY_ID;
1815 strWID.type = WID_CHAR;
1816 strWID.val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.index));
1817 strWID.size = sizeof(char);
1818
1819 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
1820
1821 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1822 get_id_from_handler(hif_drv));
1823 }
1824 up(&hif_drv->hSemTestKeyBlock);
1825 break;
1826
1827 case WPARxGtk:
1828 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1829 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1830 if (pu8keybuf == NULL) {
1831 PRINT_ER("No buffer to send RxGTK Key\n");
1832 ret = -1;
1833 goto _WPARxGtk_end_case_;
1834 }
1835
1836 if (pstrHostIFkeyAttr->attr.wpa.seq != NULL)
1837 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1838
1839 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1840 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1841 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1842 pstrHostIFkeyAttr->attr.wpa.key_len);
1843
1844 strWIDList[0].id = (u16)WID_11I_MODE;
1845 strWIDList[0].type = WID_CHAR;
1846 strWIDList[0].size = sizeof(char);
1847 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wpa.mode));
1848
1849 strWIDList[1].id = (u16)WID_ADD_RX_GTK;
1850 strWIDList[1].type = WID_STR;
1851 strWIDList[1].val = (s8 *)pu8keybuf;
1852 strWIDList[1].size = RX_MIC_KEY_MSG_LEN;
1853
1854 s32Error = send_config_pkt(SET_CFG, strWIDList, 2,
1855 get_id_from_handler(hif_drv));
1856
1857 kfree(pu8keybuf);
1858 up(&hif_drv->hSemTestKeyBlock);
1859 }
1860
1861 if (pstrHostIFkeyAttr->action & ADDKEY) {
1862 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
1863
1864 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1865 if (pu8keybuf == NULL) {
1866 PRINT_ER("No buffer to send RxGTK Key\n");
1867 ret = -1;
1868 goto _WPARxGtk_end_case_;
1869 }
1870
1871 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)
1872 memcpy(pu8keybuf, hif_drv->au8AssociatedBSSID, ETH_ALEN);
1873 else
1874 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
1875
1876 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1877 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1878 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1879 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1880 pstrHostIFkeyAttr->attr.wpa.key_len);
1881
1882 strWID.id = (u16)WID_ADD_RX_GTK;
1883 strWID.type = WID_STR;
1884 strWID.val = (s8 *)pu8keybuf;
1885 strWID.size = RX_MIC_KEY_MSG_LEN;
1886
1887 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1888 get_id_from_handler(hif_drv));
1889
1890 kfree(pu8keybuf);
1891 up(&hif_drv->hSemTestKeyBlock);
1892 }
1893 _WPARxGtk_end_case_:
1894 kfree(pstrHostIFkeyAttr->attr.wpa.key);
1895 kfree(pstrHostIFkeyAttr->attr.wpa.seq);
1896 if (ret == -1)
1897 return ret;
1898
1899 break;
1900
1901 case WPAPtk:
1902 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1903
1904
1905 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
1906
1907
1908
1909 if (pu8keybuf == NULL) {
1910 PRINT_ER("No buffer to send PTK Key\n");
1911 ret = -1;
1912 goto _WPAPtk_end_case_;
1913
1914 }
1915
1916 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1917 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1918 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1919 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->attr.wpa.key,
1920 pstrHostIFkeyAttr->attr.wpa.key_len);
1921
1922 strWIDList[0].id = (u16)WID_11I_MODE;
1923 strWIDList[0].type = WID_CHAR;
1924 strWIDList[0].size = sizeof(char);
1925 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wpa.mode));
1926
1927 strWIDList[1].id = (u16)WID_ADD_PTK;
1928 strWIDList[1].type = WID_STR;
1929 strWIDList[1].val = (s8 *)pu8keybuf;
1930 strWIDList[1].size = PTK_KEY_MSG_LEN + 1;
1931
1932 s32Error = send_config_pkt(SET_CFG, strWIDList, 2,
1933 get_id_from_handler(hif_drv));
1934 kfree(pu8keybuf);
1935 up(&hif_drv->hSemTestKeyBlock);
1936 }
1937 if (pstrHostIFkeyAttr->action & ADDKEY) {
1938
1939
1940 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
1941
1942
1943
1944 if (pu8keybuf == NULL) {
1945 PRINT_ER("No buffer to send PTK Key\n");
1946 ret = -1;
1947 goto _WPAPtk_end_case_;
1948
1949 }
1950
1951 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1952 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1953 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->attr.wpa.key,
1954 pstrHostIFkeyAttr->attr.wpa.key_len);
1955
1956 strWID.id = (u16)WID_ADD_PTK;
1957 strWID.type = WID_STR;
1958 strWID.val = (s8 *)pu8keybuf;
1959 strWID.size = PTK_KEY_MSG_LEN;
1960
1961 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1962 get_id_from_handler(hif_drv));
1963 kfree(pu8keybuf);
1964 up(&hif_drv->hSemTestKeyBlock);
1965 }
1966
1967 _WPAPtk_end_case_:
1968 kfree(pstrHostIFkeyAttr->attr.wpa.key);
1969 if (ret == -1)
1970 return ret;
1971
1972 break;
1973
1974
1975 case PMKSA:
1976
1977 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
1978
1979 pu8keybuf = kmalloc((pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
1980 if (pu8keybuf == NULL) {
1981 PRINT_ER("No buffer to send PMKSA Key\n");
1982 return -1;
1983 }
1984
1985 pu8keybuf[0] = pstrHostIFkeyAttr->attr.pmkid.numpmkid;
1986
1987 for (i = 0; i < pstrHostIFkeyAttr->attr.pmkid.numpmkid; i++) {
1988 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
1989 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
1990 }
1991
1992 strWID.id = (u16)WID_PMKID_INFO;
1993 strWID.type = WID_STR;
1994 strWID.val = (s8 *)pu8keybuf;
1995 strWID.size = (pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
1996
1997 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1998 get_id_from_handler(hif_drv));
1999
2000 kfree(pu8keybuf);
2001 break;
2002 }
2003
2004 if (s32Error)
2005 PRINT_ER("Failed to send key config packet\n");
2006
2007
2008 return s32Error;
2009 }
2010
2011 static void Handle_Disconnect(struct host_if_drv *hif_drv)
2012 {
2013 struct wid strWID;
2014
2015 s32 s32Error = 0;
2016 u16 u16DummyReasonCode = 0;
2017
2018 strWID.id = (u16)WID_DISCONNECT;
2019 strWID.type = WID_CHAR;
2020 strWID.val = (s8 *)&u16DummyReasonCode;
2021 strWID.size = sizeof(char);
2022
2023
2024
2025 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2026
2027 g_obtainingIP = false;
2028 host_int_set_power_mgmt(hif_drv, 0, 0);
2029
2030 eth_zero_addr(u8ConnectedSSID);
2031
2032 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2033 get_id_from_handler(hif_drv));
2034
2035 if (s32Error) {
2036 PRINT_ER("Failed to send dissconect config packet\n");
2037 } else {
2038 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2039
2040 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
2041
2042 strDisconnectNotifInfo.u16reason = 0;
2043 strDisconnectNotifInfo.ie = NULL;
2044 strDisconnectNotifInfo.ie_len = 0;
2045
2046 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
2047 del_timer(&hif_drv->hScanTimer);
2048 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
2049 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2050
2051 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
2052 }
2053
2054 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2055 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2056 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
2057 del_timer(&hif_drv->hConnectTimer);
2058 }
2059
2060 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
2061 0, &strDisconnectNotifInfo, hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
2062 } else {
2063 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
2064 }
2065
2066 gbScanWhileConnected = false;
2067
2068 hif_drv->enuHostIFstate = HOST_IF_IDLE;
2069
2070 eth_zero_addr(hif_drv->au8AssociatedBSSID);
2071
2072 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
2073 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
2074 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
2075 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2076 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
2077
2078 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
2079 kfree(gu8FlushedJoinReq);
2080 gu8FlushedJoinReq = NULL;
2081 }
2082 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
2083 kfree(gu8FlushedInfoElemAsoc);
2084 gu8FlushedInfoElemAsoc = NULL;
2085 }
2086
2087 }
2088
2089 up(&hif_drv->hSemTestDisconnectBlock);
2090 }
2091
2092
2093 void resolve_disconnect_aberration(struct host_if_drv *hif_drv)
2094 {
2095 if (!hif_drv)
2096 return;
2097 if ((hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (hif_drv->enuHostIFstate == HOST_IF_CONNECTING)) {
2098 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
2099 host_int_disconnect(hif_drv, 1);
2100 }
2101 }
2102
2103 static s32 Handle_GetChnl(struct host_if_drv *hif_drv)
2104 {
2105
2106 s32 s32Error = 0;
2107 struct wid strWID;
2108
2109 strWID.id = (u16)WID_CURRENT_CHANNEL;
2110 strWID.type = WID_CHAR;
2111 strWID.val = (s8 *)&gu8Chnl;
2112 strWID.size = sizeof(char);
2113
2114 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
2115
2116 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2117 get_id_from_handler(hif_drv));
2118
2119 if (s32Error) {
2120 PRINT_ER("Failed to get channel number\n");
2121 s32Error = -EFAULT;
2122 }
2123
2124 up(&hif_drv->hSemGetCHNL);
2125
2126 return s32Error;
2127
2128
2129
2130 }
2131
2132 static void Handle_GetRssi(struct host_if_drv *hif_drv)
2133 {
2134 s32 s32Error = 0;
2135 struct wid strWID;
2136
2137 strWID.id = (u16)WID_RSSI;
2138 strWID.type = WID_CHAR;
2139 strWID.val = &gs8Rssi;
2140 strWID.size = sizeof(char);
2141
2142 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
2143
2144 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2145 get_id_from_handler(hif_drv));
2146 if (s32Error) {
2147 PRINT_ER("Failed to get RSSI value\n");
2148 s32Error = -EFAULT;
2149 }
2150
2151 up(&hif_drv->hSemGetRSSI);
2152
2153
2154 }
2155
2156
2157 static void Handle_GetLinkspeed(struct host_if_drv *hif_drv)
2158 {
2159 s32 s32Error = 0;
2160 struct wid strWID;
2161
2162 gs8lnkspd = 0;
2163
2164 strWID.id = (u16)WID_LINKSPEED;
2165 strWID.type = WID_CHAR;
2166 strWID.val = &gs8lnkspd;
2167 strWID.size = sizeof(char);
2168
2169 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
2170
2171 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2172 get_id_from_handler(hif_drv));
2173 if (s32Error) {
2174 PRINT_ER("Failed to get LINKSPEED value\n");
2175 s32Error = -EFAULT;
2176 }
2177
2178 up(&(hif_drv->hSemGetLINKSPEED));
2179
2180
2181 }
2182
2183 s32 Handle_GetStatistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
2184 {
2185 struct wid strWIDList[5];
2186 u32 u32WidsCount = 0, s32Error = 0;
2187
2188 strWIDList[u32WidsCount].id = WID_LINKSPEED;
2189 strWIDList[u32WidsCount].type = WID_CHAR;
2190 strWIDList[u32WidsCount].size = sizeof(char);
2191 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u8LinkSpeed));
2192 u32WidsCount++;
2193
2194 strWIDList[u32WidsCount].id = WID_RSSI;
2195 strWIDList[u32WidsCount].type = WID_CHAR;
2196 strWIDList[u32WidsCount].size = sizeof(char);
2197 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->s8RSSI));
2198 u32WidsCount++;
2199
2200 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
2201 strWIDList[u32WidsCount].type = WID_INT;
2202 strWIDList[u32WidsCount].size = sizeof(u32);
2203 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32TxCount));
2204 u32WidsCount++;
2205
2206 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
2207 strWIDList[u32WidsCount].type = WID_INT;
2208 strWIDList[u32WidsCount].size = sizeof(u32);
2209 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32RxCount));
2210 u32WidsCount++;
2211
2212 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
2213 strWIDList[u32WidsCount].type = WID_INT;
2214 strWIDList[u32WidsCount].size = sizeof(u32);
2215 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32TxFailureCount));
2216 u32WidsCount++;
2217
2218 s32Error = send_config_pkt(GET_CFG, strWIDList, u32WidsCount,
2219 get_id_from_handler(hif_drv));
2220
2221 if (s32Error)
2222 PRINT_ER("Failed to send scan paramters config packet\n");
2223
2224 up(&hif_sema_wait_response);
2225 return 0;
2226
2227 }
2228
2229 static s32 Handle_Get_InActiveTime(struct host_if_drv *hif_drv,
2230 struct sta_inactive_t *strHostIfStaInactiveT)
2231 {
2232
2233 s32 s32Error = 0;
2234 u8 *stamac;
2235 struct wid strWID;
2236
2237 strWID.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
2238 strWID.type = WID_STR;
2239 strWID.size = ETH_ALEN;
2240 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2241
2242
2243 stamac = strWID.val;
2244 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
2245
2246
2247 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
2248
2249
2250 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2251 get_id_from_handler(hif_drv));
2252
2253 if (s32Error) {
2254 PRINT_ER("Failed to SET incative time\n");
2255 return -EFAULT;
2256 }
2257
2258
2259 strWID.id = (u16)WID_GET_INACTIVE_TIME;
2260 strWID.type = WID_INT;
2261 strWID.val = (s8 *)&gu32InactiveTime;
2262 strWID.size = sizeof(u32);
2263
2264
2265 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2266 get_id_from_handler(hif_drv));
2267
2268 if (s32Error) {
2269 PRINT_ER("Failed to get incative time\n");
2270 return -EFAULT;
2271 }
2272
2273
2274 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
2275
2276 up(&hif_drv->hSemInactiveTime);
2277
2278 return s32Error;
2279
2280
2281
2282 }
2283
2284 static void Handle_AddBeacon(struct host_if_drv *hif_drv,
2285 struct beacon_attr *pstrSetBeaconParam)
2286 {
2287 s32 s32Error = 0;
2288 struct wid strWID;
2289 u8 *pu8CurrByte;
2290
2291 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
2292
2293 strWID.id = (u16)WID_ADD_BEACON;
2294 strWID.type = WID_BIN;
2295 strWID.size = pstrSetBeaconParam->head_len + pstrSetBeaconParam->tail_len + 16;
2296 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2297 if (strWID.val == NULL)
2298 goto ERRORHANDLER;
2299
2300 pu8CurrByte = strWID.val;
2301 *pu8CurrByte++ = (pstrSetBeaconParam->interval & 0xFF);
2302 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 8) & 0xFF);
2303 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 16) & 0xFF);
2304 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 24) & 0xFF);
2305
2306 *pu8CurrByte++ = (pstrSetBeaconParam->dtim_period & 0xFF);
2307 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 8) & 0xFF);
2308 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 16) & 0xFF);
2309 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 24) & 0xFF);
2310
2311 *pu8CurrByte++ = (pstrSetBeaconParam->head_len & 0xFF);
2312 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 8) & 0xFF);
2313 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 16) & 0xFF);
2314 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 24) & 0xFF);
2315
2316 memcpy(pu8CurrByte, pstrSetBeaconParam->head, pstrSetBeaconParam->head_len);
2317 pu8CurrByte += pstrSetBeaconParam->head_len;
2318
2319 *pu8CurrByte++ = (pstrSetBeaconParam->tail_len & 0xFF);
2320 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 8) & 0xFF);
2321 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 16) & 0xFF);
2322 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 24) & 0xFF);
2323
2324 if (pstrSetBeaconParam->tail > 0)
2325 memcpy(pu8CurrByte, pstrSetBeaconParam->tail, pstrSetBeaconParam->tail_len);
2326 pu8CurrByte += pstrSetBeaconParam->tail_len;
2327
2328 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2329 get_id_from_handler(hif_drv));
2330 if (s32Error)
2331 PRINT_ER("Failed to send add beacon config packet\n");
2332
2333 ERRORHANDLER:
2334 kfree(strWID.val);
2335 kfree(pstrSetBeaconParam->head);
2336 kfree(pstrSetBeaconParam->tail);
2337 }
2338
2339 static void Handle_DelBeacon(struct host_if_drv *hif_drv)
2340 {
2341 s32 s32Error = 0;
2342 struct wid strWID;
2343 u8 *pu8CurrByte;
2344
2345 strWID.id = (u16)WID_DEL_BEACON;
2346 strWID.type = WID_CHAR;
2347 strWID.size = sizeof(char);
2348 strWID.val = &gu8DelBcn;
2349
2350 if (strWID.val == NULL)
2351 return;
2352
2353 pu8CurrByte = strWID.val;
2354
2355 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
2356
2357 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2358 get_id_from_handler(hif_drv));
2359 if (s32Error)
2360 PRINT_ER("Failed to send delete beacon config packet\n");
2361 }
2362
2363 static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
2364 struct add_sta_param *pstrStationParam)
2365 {
2366 u8 *pu8CurrByte;
2367
2368 pu8CurrByte = pu8Buffer;
2369
2370 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
2371 memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
2372 pu8CurrByte += ETH_ALEN;
2373
2374 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
2375 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
2376
2377 *pu8CurrByte++ = pstrStationParam->u8NumRates;
2378 if (pstrStationParam->u8NumRates > 0)
2379 memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
2380 pu8CurrByte += pstrStationParam->u8NumRates;
2381
2382 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
2383 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
2384 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
2385
2386 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
2387 memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
2388 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
2389
2390 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
2391 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
2392
2393 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
2394 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
2395 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
2396 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
2397
2398 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
2399
2400 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
2401 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
2402
2403 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
2404 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
2405
2406 return pu8CurrByte - pu8Buffer;
2407 }
2408
2409 static void Handle_AddStation(struct host_if_drv *hif_drv,
2410 struct add_sta_param *pstrStationParam)
2411 {
2412 s32 s32Error = 0;
2413 struct wid strWID;
2414 u8 *pu8CurrByte;
2415
2416 PRINT_D(HOSTINF_DBG, "Handling add station\n");
2417 strWID.id = (u16)WID_ADD_STA;
2418 strWID.type = WID_BIN;
2419 strWID.size = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
2420
2421 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2422 if (strWID.val == NULL)
2423 goto ERRORHANDLER;
2424
2425 pu8CurrByte = strWID.val;
2426 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2427
2428 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2429 get_id_from_handler(hif_drv));
2430 if (s32Error != 0)
2431 PRINT_ER("Failed to send add station config packet\n");
2432
2433 ERRORHANDLER:
2434 kfree(pstrStationParam->pu8Rates);
2435 kfree(strWID.val);
2436 }
2437
2438 static void Handle_DelAllSta(struct host_if_drv *hif_drv,
2439 struct del_all_sta *pstrDelAllStaParam)
2440 {
2441 s32 s32Error = 0;
2442
2443 struct wid strWID;
2444 u8 *pu8CurrByte;
2445 u8 i;
2446 u8 au8Zero_Buff[6] = {0};
2447
2448 strWID.id = (u16)WID_DEL_ALL_STA;
2449 strWID.type = WID_STR;
2450 strWID.size = (pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1;
2451
2452 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
2453
2454 strWID.val = kmalloc((pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1, GFP_KERNEL);
2455 if (strWID.val == NULL)
2456 goto ERRORHANDLER;
2457
2458 pu8CurrByte = strWID.val;
2459
2460 *(pu8CurrByte++) = pstrDelAllStaParam->assoc_sta;
2461
2462 for (i = 0; i < MAX_NUM_STA; i++) {
2463 if (memcmp(pstrDelAllStaParam->del_all_sta[i], au8Zero_Buff, ETH_ALEN))
2464 memcpy(pu8CurrByte, pstrDelAllStaParam->del_all_sta[i], ETH_ALEN);
2465 else
2466 continue;
2467
2468 pu8CurrByte += ETH_ALEN;
2469 }
2470
2471 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2472 get_id_from_handler(hif_drv));
2473 if (s32Error)
2474 PRINT_ER("Failed to send add station config packet\n");
2475
2476 ERRORHANDLER:
2477 kfree(strWID.val);
2478
2479 up(&hif_sema_wait_response);
2480 }
2481
2482 static void Handle_DelStation(struct host_if_drv *hif_drv,
2483 struct del_sta *pstrDelStaParam)
2484 {
2485 s32 s32Error = 0;
2486 struct wid strWID;
2487 u8 *pu8CurrByte;
2488
2489 strWID.id = (u16)WID_REMOVE_STA;
2490 strWID.type = WID_BIN;
2491 strWID.size = ETH_ALEN;
2492
2493 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
2494
2495 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2496 if (strWID.val == NULL)
2497 goto ERRORHANDLER;
2498
2499 pu8CurrByte = strWID.val;
2500
2501 memcpy(pu8CurrByte, pstrDelStaParam->mac_addr, ETH_ALEN);
2502
2503 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2504 get_id_from_handler(hif_drv));
2505 if (s32Error)
2506 PRINT_ER("Failed to send add station config packet\n");
2507
2508 ERRORHANDLER:
2509 kfree(strWID.val);
2510 }
2511
2512 static void Handle_EditStation(struct host_if_drv *hif_drv,
2513 struct add_sta_param *pstrStationParam)
2514 {
2515 s32 s32Error = 0;
2516 struct wid strWID;
2517 u8 *pu8CurrByte;
2518
2519 strWID.id = (u16)WID_EDIT_STA;
2520 strWID.type = WID_BIN;
2521 strWID.size = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
2522
2523 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
2524 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2525 if (strWID.val == NULL)
2526 goto ERRORHANDLER;
2527
2528 pu8CurrByte = strWID.val;
2529 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2530
2531 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2532 get_id_from_handler(hif_drv));
2533 if (s32Error)
2534 PRINT_ER("Failed to send edit station config packet\n");
2535
2536 ERRORHANDLER:
2537 kfree(pstrStationParam->pu8Rates);
2538 kfree(strWID.val);
2539 }
2540
2541 static int Handle_RemainOnChan(struct host_if_drv *hif_drv,
2542 struct remain_ch *pstrHostIfRemainOnChan)
2543 {
2544 s32 s32Error = 0;
2545 u8 u8remain_on_chan_flag;
2546 struct wid strWID;
2547
2548 if (!hif_drv->u8RemainOnChan_pendingreq) {
2549 hif_drv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
2550 hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
2551 hif_drv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
2552 hif_drv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
2553 hif_drv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
2554 } else {
2555 pstrHostIfRemainOnChan->u16Channel = hif_drv->strHostIfRemainOnChan.u16Channel;
2556 }
2557
2558 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
2559 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
2560 hif_drv->u8RemainOnChan_pendingreq = 1;
2561 s32Error = -EBUSY;
2562 goto ERRORHANDLER;
2563 }
2564 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2565 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
2566 s32Error = -EBUSY;
2567 goto ERRORHANDLER;
2568 }
2569
2570 if (g_obtainingIP || connecting) {
2571 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
2572 s32Error = -EBUSY;
2573 goto ERRORHANDLER;
2574 }
2575
2576 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
2577
2578 u8remain_on_chan_flag = true;
2579 strWID.id = (u16)WID_REMAIN_ON_CHAN;
2580 strWID.type = WID_STR;
2581 strWID.size = 2;
2582 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2583
2584 if (strWID.val == NULL) {
2585 s32Error = -ENOMEM;
2586 goto ERRORHANDLER;
2587 }
2588
2589 strWID.val[0] = u8remain_on_chan_flag;
2590 strWID.val[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
2591
2592 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2593 get_id_from_handler(hif_drv));
2594 if (s32Error != 0)
2595 PRINT_ER("Failed to set remain on channel\n");
2596
2597 ERRORHANDLER:
2598 {
2599 P2P_LISTEN_STATE = 1;
2600 hif_drv->hRemainOnChannel.data = (unsigned long)hif_drv;
2601 mod_timer(&hif_drv->hRemainOnChannel,
2602 jiffies +
2603 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
2604
2605 if (hif_drv->strHostIfRemainOnChan.pRemainOnChanReady)
2606 hif_drv->strHostIfRemainOnChan.pRemainOnChanReady(hif_drv->strHostIfRemainOnChan.pVoid);
2607
2608 if (hif_drv->u8RemainOnChan_pendingreq)
2609 hif_drv->u8RemainOnChan_pendingreq = 0;
2610 }
2611 return s32Error;
2612 }
2613
2614 static int Handle_RegisterFrame(struct host_if_drv *hif_drv,
2615 struct reg_frame *pstrHostIfRegisterFrame)
2616 {
2617 s32 s32Error = 0;
2618 struct wid strWID;
2619 u8 *pu8CurrByte;
2620
2621 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
2622
2623 strWID.id = (u16)WID_REGISTER_FRAME;
2624 strWID.type = WID_STR;
2625 strWID.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
2626 if (strWID.val == NULL)
2627 return -ENOMEM;
2628
2629 pu8CurrByte = strWID.val;
2630
2631 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
2632 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
2633 memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
2634
2635
2636 strWID.size = sizeof(u16) + 2;
2637
2638 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2639 get_id_from_handler(hif_drv));
2640 if (s32Error) {
2641 PRINT_ER("Failed to frame register config packet\n");
2642 s32Error = -EINVAL;
2643 }
2644
2645 return s32Error;
2646
2647 }
2648
2649 #define FALSE_FRMWR_CHANNEL 100
2650 static u32 Handle_ListenStateExpired(struct host_if_drv *hif_drv,
2651 struct remain_ch *pstrHostIfRemainOnChan)
2652 {
2653 u8 u8remain_on_chan_flag;
2654 struct wid strWID;
2655 s32 s32Error = 0;
2656
2657 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
2658
2659 if (P2P_LISTEN_STATE) {
2660 u8remain_on_chan_flag = false;
2661 strWID.id = (u16)WID_REMAIN_ON_CHAN;
2662 strWID.type = WID_STR;
2663 strWID.size = 2;
2664 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2665
2666 if (strWID.val == NULL)
2667 PRINT_ER("Failed to allocate memory\n");
2668
2669 strWID.val[0] = u8remain_on_chan_flag;
2670 strWID.val[1] = FALSE_FRMWR_CHANNEL;
2671
2672 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2673 get_id_from_handler(hif_drv));
2674 if (s32Error != 0) {
2675 PRINT_ER("Failed to set remain on channel\n");
2676 goto _done_;
2677 }
2678
2679 if (hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired) {
2680 hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired(hif_drv->strHostIfRemainOnChan.pVoid
2681 , pstrHostIfRemainOnChan->u32ListenSessionID);
2682 }
2683 P2P_LISTEN_STATE = 0;
2684 } else {
2685 PRINT_D(GENERIC_DBG, "Not in listen state\n");
2686 s32Error = -EFAULT;
2687 }
2688
2689 _done_:
2690 return s32Error;
2691 }
2692
2693 static void ListenTimerCB(unsigned long arg)
2694 {
2695 s32 s32Error = 0;
2696 struct host_if_msg msg;
2697 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
2698
2699 del_timer(&hif_drv->hRemainOnChannel);
2700
2701 memset(&msg, 0, sizeof(struct host_if_msg));
2702 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
2703 msg.drv = hif_drv;
2704 msg.body.remain_on_ch.u32ListenSessionID = hif_drv->strHostIfRemainOnChan.u32ListenSessionID;
2705
2706 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2707 if (s32Error)
2708 PRINT_ER("wilc_mq_send fail\n");
2709 }
2710
2711 static void Handle_PowerManagement(struct host_if_drv *hif_drv,
2712 struct power_mgmt_param *strPowerMgmtParam)
2713 {
2714 s32 s32Error = 0;
2715 struct wid strWID;
2716 s8 s8PowerMode;
2717
2718 strWID.id = (u16)WID_POWER_MANAGEMENT;
2719
2720 if (strPowerMgmtParam->enabled == true)
2721 s8PowerMode = MIN_FAST_PS;
2722 else
2723 s8PowerMode = NO_POWERSAVE;
2724 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
2725 strWID.val = &s8PowerMode;
2726 strWID.size = sizeof(char);
2727
2728 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
2729
2730 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2731 get_id_from_handler(hif_drv));
2732 if (s32Error)
2733 PRINT_ER("Failed to send power management config packet\n");
2734 }
2735
2736 static void Handle_SetMulticastFilter(struct host_if_drv *hif_drv,
2737 struct set_multicast *strHostIfSetMulti)
2738 {
2739 s32 s32Error = 0;
2740 struct wid strWID;
2741 u8 *pu8CurrByte;
2742
2743 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
2744
2745 strWID.id = (u16)WID_SETUP_MULTICAST_FILTER;
2746 strWID.type = WID_BIN;
2747 strWID.size = sizeof(struct set_multicast) + ((strHostIfSetMulti->cnt) * ETH_ALEN);
2748 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2749 if (strWID.val == NULL)
2750 goto ERRORHANDLER;
2751
2752 pu8CurrByte = strWID.val;
2753 *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF);
2754 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 8) & 0xFF);
2755 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 16) & 0xFF);
2756 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 24) & 0xFF);
2757
2758 *pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF);
2759 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF);
2760 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 16) & 0xFF);
2761 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 24) & 0xFF);
2762
2763 if ((strHostIfSetMulti->cnt) > 0)
2764 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->cnt) * ETH_ALEN));
2765
2766 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2767 get_id_from_handler(hif_drv));
2768 if (s32Error)
2769 PRINT_ER("Failed to send setup multicast config packet\n");
2770
2771 ERRORHANDLER:
2772 kfree(strWID.val);
2773
2774 }
2775
2776 static s32 Handle_AddBASession(struct host_if_drv *hif_drv,
2777 struct ba_session_info *strHostIfBASessionInfo)
2778 {
2779 s32 s32Error = 0;
2780 struct wid strWID;
2781 int AddbaTimeout = 100;
2782 char *ptr = NULL;
2783
2784 PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\nBufferSize == %d\nSessionTimeOut = %d\n",
2785 strHostIfBASessionInfo->au8Bssid[0],
2786 strHostIfBASessionInfo->au8Bssid[1],
2787 strHostIfBASessionInfo->au8Bssid[2],
2788 strHostIfBASessionInfo->u16BufferSize,
2789 strHostIfBASessionInfo->u16SessionTimeout,
2790 strHostIfBASessionInfo->u8Ted);
2791
2792 strWID.id = (u16)WID_11E_P_ACTION_REQ;
2793 strWID.type = WID_STR;
2794 strWID.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2795 strWID.size = BLOCK_ACK_REQ_SIZE;
2796 ptr = strWID.val;
2797 *ptr++ = 0x14;
2798 *ptr++ = 0x3;
2799 *ptr++ = 0x0;
2800 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2801 ptr += ETH_ALEN;
2802 *ptr++ = strHostIfBASessionInfo->u8Ted;
2803 *ptr++ = 1;
2804 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
2805 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
2806 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
2807 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
2808 *ptr++ = (AddbaTimeout & 0xFF);
2809 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
2810 *ptr++ = 8;
2811 *ptr++ = 0;
2812
2813 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2814 get_id_from_handler(hif_drv));
2815 if (s32Error)
2816 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
2817
2818
2819 strWID.id = (u16)WID_11E_P_ACTION_REQ;
2820 strWID.type = WID_STR;
2821 strWID.size = 15;
2822 ptr = strWID.val;
2823 *ptr++ = 15;
2824 *ptr++ = 7;
2825 *ptr++ = 0x2;
2826 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2827 ptr += ETH_ALEN;
2828 *ptr++ = strHostIfBASessionInfo->u8Ted;
2829 *ptr++ = 8;
2830 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
2831 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
2832 *ptr++ = 3;
2833 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2834 get_id_from_handler(hif_drv));
2835
2836 kfree(strWID.val);
2837
2838 return s32Error;
2839
2840 }
2841
2842 static s32 Handle_DelAllRxBASessions(struct host_if_drv *hif_drv,
2843 struct ba_session_info *strHostIfBASessionInfo)
2844 {
2845 s32 s32Error = 0;
2846 struct wid strWID;
2847 char *ptr = NULL;
2848
2849 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
2850 strHostIfBASessionInfo->au8Bssid[0],
2851 strHostIfBASessionInfo->au8Bssid[1],
2852 strHostIfBASessionInfo->au8Bssid[2],
2853 strHostIfBASessionInfo->u8Ted);
2854
2855 strWID.id = (u16)WID_DEL_ALL_RX_BA;
2856 strWID.type = WID_STR;
2857 strWID.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2858 strWID.size = BLOCK_ACK_REQ_SIZE;
2859 ptr = strWID.val;
2860 *ptr++ = 0x14;
2861 *ptr++ = 0x3;
2862 *ptr++ = 0x2;
2863 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2864 ptr += ETH_ALEN;
2865 *ptr++ = strHostIfBASessionInfo->u8Ted;
2866 *ptr++ = 0;
2867 *ptr++ = 32;
2868
2869 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2870 get_id_from_handler(hif_drv));
2871 if (s32Error)
2872 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
2873
2874
2875 kfree(strWID.val);
2876
2877 up(&hif_sema_wait_response);
2878
2879 return s32Error;
2880
2881 }
2882
2883 static int hostIFthread(void *pvArg)
2884 {
2885 u32 u32Ret;
2886 struct host_if_msg msg;
2887 struct host_if_drv *hif_drv;
2888
2889 memset(&msg, 0, sizeof(struct host_if_msg));
2890
2891 while (1) {
2892 wilc_mq_recv(&hif_msg_q, &msg, sizeof(struct host_if_msg), &u32Ret);
2893 hif_drv = (struct host_if_drv *)msg.drv;
2894 if (msg.id == HOST_IF_MSG_EXIT) {
2895 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
2896 break;
2897 }
2898
2899 if ((!g_wilc_initialized)) {
2900 PRINT_D(GENERIC_DBG, "--WAIT--");
2901 usleep_range(200 * 1000, 200 * 1000);
2902 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2903 continue;
2904 }
2905
2906 if (msg.id == HOST_IF_MSG_CONNECT && hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
2907 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
2908 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2909 usleep_range(2 * 1000, 2 * 1000);
2910 continue;
2911 }
2912
2913 switch (msg.id) {
2914 case HOST_IF_MSG_Q_IDLE:
2915 Handle_wait_msg_q_empty();
2916 break;
2917
2918 case HOST_IF_MSG_SCAN:
2919 Handle_Scan(msg.drv, &msg.body.scan_info);
2920 break;
2921
2922 case HOST_IF_MSG_CONNECT:
2923 Handle_Connect(msg.drv, &msg.body.con_info);
2924 break;
2925
2926 case HOST_IF_MSG_FLUSH_CONNECT:
2927 Handle_FlushConnect(msg.drv);
2928 break;
2929
2930 case HOST_IF_MSG_RCVD_NTWRK_INFO:
2931 Handle_RcvdNtwrkInfo(msg.drv, &msg.body.net_info);
2932 break;
2933
2934 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
2935 Handle_RcvdGnrlAsyncInfo(msg.drv, &msg.body.async_info);
2936 break;
2937
2938 case HOST_IF_MSG_KEY:
2939 Handle_Key(msg.drv, &msg.body.key_info);
2940 break;
2941
2942 case HOST_IF_MSG_CFG_PARAMS:
2943
2944 Handle_CfgParam(msg.drv, &msg.body.cfg_info);
2945 break;
2946
2947 case HOST_IF_MSG_SET_CHANNEL:
2948 Handle_SetChannel(msg.drv, &msg.body.channel_info);
2949 break;
2950
2951 case HOST_IF_MSG_DISCONNECT:
2952 Handle_Disconnect(msg.drv);
2953 break;
2954
2955 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
2956 del_timer(&hif_drv->hScanTimer);
2957 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
2958
2959 if (!linux_wlan_get_num_conn_ifcs())
2960 chip_sleep_manually(INFINITE_SLEEP_TIME);
2961
2962 Handle_ScanDone(msg.drv, SCAN_EVENT_DONE);
2963
2964 if (hif_drv->u8RemainOnChan_pendingreq)
2965 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
2966
2967 break;
2968
2969 case HOST_IF_MSG_GET_RSSI:
2970 Handle_GetRssi(msg.drv);
2971 break;
2972
2973 case HOST_IF_MSG_GET_LINKSPEED:
2974 Handle_GetLinkspeed(msg.drv);
2975 break;
2976
2977 case HOST_IF_MSG_GET_STATISTICS:
2978 Handle_GetStatistics(msg.drv, (struct rf_info *)msg.body.data);
2979 break;
2980
2981 case HOST_IF_MSG_GET_CHNL:
2982 Handle_GetChnl(msg.drv);
2983 break;
2984
2985 case HOST_IF_MSG_ADD_BEACON:
2986 Handle_AddBeacon(msg.drv, &msg.body.beacon_info);
2987 break;
2988
2989 case HOST_IF_MSG_DEL_BEACON:
2990 Handle_DelBeacon(msg.drv);
2991 break;
2992
2993 case HOST_IF_MSG_ADD_STATION:
2994 Handle_AddStation(msg.drv, &msg.body.add_sta_info);
2995 break;
2996
2997 case HOST_IF_MSG_DEL_STATION:
2998 Handle_DelStation(msg.drv, &msg.body.del_sta_info);
2999 break;
3000
3001 case HOST_IF_MSG_EDIT_STATION:
3002 Handle_EditStation(msg.drv, &msg.body.edit_sta_info);
3003 break;
3004
3005 case HOST_IF_MSG_GET_INACTIVETIME:
3006 Handle_Get_InActiveTime(msg.drv, &msg.body.mac_info);
3007 break;
3008
3009 case HOST_IF_MSG_SCAN_TIMER_FIRED:
3010 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
3011
3012 Handle_ScanDone(msg.drv, SCAN_EVENT_ABORTED);
3013 break;
3014
3015 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
3016 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
3017 Handle_ConnectTimeout(msg.drv);
3018 break;
3019
3020 case HOST_IF_MSG_POWER_MGMT:
3021 Handle_PowerManagement(msg.drv, &msg.body.pwr_mgmt_info);
3022 break;
3023
3024 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
3025 Handle_SetWfiDrvHandler(msg.drv,
3026 &msg.body.drv);
3027 break;
3028
3029 case HOST_IF_MSG_SET_OPERATION_MODE:
3030 Handle_SetOperationMode(msg.drv, &msg.body.mode);
3031 break;
3032
3033 case HOST_IF_MSG_SET_IPADDRESS:
3034 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
3035 Handle_set_IPAddress(msg.drv, msg.body.ip_info.ip_addr, msg.body.ip_info.idx);
3036 break;
3037
3038 case HOST_IF_MSG_GET_IPADDRESS:
3039 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
3040 Handle_get_IPAddress(msg.drv, msg.body.ip_info.ip_addr, msg.body.ip_info.idx);
3041 break;
3042
3043 case HOST_IF_MSG_SET_MAC_ADDRESS:
3044 Handle_SetMacAddress(msg.drv, &msg.body.set_mac_info);
3045 break;
3046
3047 case HOST_IF_MSG_GET_MAC_ADDRESS:
3048 Handle_GetMacAddress(msg.drv, &msg.body.get_mac_info);
3049 break;
3050
3051 case HOST_IF_MSG_REMAIN_ON_CHAN:
3052 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
3053 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
3054 break;
3055
3056 case HOST_IF_MSG_REGISTER_FRAME:
3057 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
3058 Handle_RegisterFrame(msg.drv, &msg.body.reg_frame);
3059 break;
3060
3061 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
3062 Handle_ListenStateExpired(msg.drv, &msg.body.remain_on_ch);
3063 break;
3064
3065 case HOST_IF_MSG_SET_MULTICAST_FILTER:
3066 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
3067 Handle_SetMulticastFilter(msg.drv, &msg.body.multicast_info);
3068 break;
3069
3070 case HOST_IF_MSG_ADD_BA_SESSION:
3071 Handle_AddBASession(msg.drv, &msg.body.session_info);
3072 break;
3073
3074 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
3075 Handle_DelAllRxBASessions(msg.drv, &msg.body.session_info);
3076 break;
3077
3078 case HOST_IF_MSG_DEL_ALL_STA:
3079 Handle_DelAllSta(msg.drv, &msg.body.del_all_sta_info);
3080 break;
3081
3082 default:
3083 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
3084 break;
3085 }
3086 }
3087
3088 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
3089 up(&hif_sema_thread);
3090 return 0;
3091 }
3092
3093 static void TimerCB_Scan(unsigned long arg)
3094 {
3095 void *pvArg = (void *)arg;
3096 struct host_if_msg msg;
3097
3098 memset(&msg, 0, sizeof(struct host_if_msg));
3099 msg.drv = pvArg;
3100 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
3101
3102 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3103 }
3104
3105 static void TimerCB_Connect(unsigned long arg)
3106 {
3107 void *pvArg = (void *)arg;
3108 struct host_if_msg msg;
3109
3110 memset(&msg, 0, sizeof(struct host_if_msg));
3111 msg.drv = pvArg;
3112 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
3113
3114 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3115 }
3116
3117 s32 host_int_remove_key(struct host_if_drv *hif_drv, const u8 *pu8StaAddress)
3118 {
3119 struct wid strWID;
3120
3121 strWID.id = (u16)WID_REMOVE_KEY;
3122 strWID.type = WID_STR;
3123 strWID.val = (s8 *)pu8StaAddress;
3124 strWID.size = 6;
3125
3126 return 0;
3127 }
3128
3129 int host_int_remove_wep_key(struct host_if_drv *hif_drv, u8 index)
3130 {
3131 int result = 0;
3132 struct host_if_msg msg;
3133
3134 if (!hif_drv) {
3135 result = -EFAULT;
3136 PRINT_ER("Failed to send setup multicast config packet\n");
3137 return result;
3138 }
3139
3140 memset(&msg, 0, sizeof(struct host_if_msg));
3141
3142 msg.id = HOST_IF_MSG_KEY;
3143 msg.body.key_info.type = WEP;
3144 msg.body.key_info.action = REMOVEKEY;
3145 msg.drv = hif_drv;
3146 msg.body.key_info.attr.wep.index = index;
3147
3148 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3149 if (result)
3150 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
3151 down(&hif_drv->hSemTestKeyBlock);
3152
3153 return result;
3154 }
3155
3156 s32 host_int_set_WEPDefaultKeyID(struct host_if_drv *hif_drv, u8 u8Index)
3157 {
3158 s32 s32Error = 0;
3159 struct host_if_msg msg;
3160
3161
3162 if (!hif_drv) {
3163 s32Error = -EFAULT;
3164 PRINT_ER("driver is null\n");
3165 return s32Error;
3166 }
3167
3168 memset(&msg, 0, sizeof(struct host_if_msg));
3169
3170
3171 msg.id = HOST_IF_MSG_KEY;
3172 msg.body.key_info.type = WEP;
3173 msg.body.key_info.action = DEFAULTKEY;
3174 msg.drv = hif_drv;
3175 msg.body.key_info.attr.wep.index = u8Index;
3176
3177 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3178 if (s32Error)
3179 PRINT_ER("Error in sending message queue : Default key index\n");
3180 down(&hif_drv->hSemTestKeyBlock);
3181
3182 return s32Error;
3183 }
3184
3185 s32 host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv,
3186 const u8 *pu8WepKey,
3187 u8 u8WepKeylen,
3188 u8 u8Keyidx)
3189 {
3190
3191 s32 s32Error = 0;
3192 struct host_if_msg msg;
3193
3194 if (!hif_drv) {
3195 s32Error = -EFAULT;
3196 PRINT_ER("driver is null\n");
3197 return s32Error;
3198 }
3199
3200 memset(&msg, 0, sizeof(struct host_if_msg));
3201
3202
3203 msg.id = HOST_IF_MSG_KEY;
3204 msg.body.key_info.type = WEP;
3205 msg.body.key_info.action = ADDKEY;
3206 msg.drv = hif_drv;
3207 msg.body.key_info.attr.wep.key = kmalloc(u8WepKeylen, GFP_KERNEL);
3208 memcpy(msg.body.key_info.attr.wep.key, pu8WepKey, u8WepKeylen);
3209 msg.body.key_info.attr.wep.key_len = (u8WepKeylen);
3210 msg.body.key_info.attr.wep.index = u8Keyidx;
3211
3212 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3213 if (s32Error)
3214 PRINT_ER("Error in sending message queue :WEP Key\n");
3215 down(&hif_drv->hSemTestKeyBlock);
3216
3217 return s32Error;
3218
3219 }
3220
3221 s32 host_int_add_wep_key_bss_ap(struct host_if_drv *hif_drv,
3222 const u8 *pu8WepKey,
3223 u8 u8WepKeylen,
3224 u8 u8Keyidx,
3225 u8 u8mode,
3226 enum AUTHTYPE tenuAuth_type)
3227 {
3228
3229 s32 s32Error = 0;
3230 struct host_if_msg msg;
3231 u8 i;
3232
3233 if (!hif_drv) {
3234 s32Error = -EFAULT;
3235 PRINT_ER("driver is null\n");
3236 return s32Error;
3237 }
3238
3239 memset(&msg, 0, sizeof(struct host_if_msg));
3240
3241 if (INFO) {
3242 for (i = 0; i < u8WepKeylen; i++)
3243 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
3244 }
3245 msg.id = HOST_IF_MSG_KEY;
3246 msg.body.key_info.type = WEP;
3247 msg.body.key_info.action = ADDKEY_AP;
3248 msg.drv = hif_drv;
3249 msg.body.key_info.attr.wep.key = kmalloc(u8WepKeylen, GFP_KERNEL);
3250 memcpy(msg.body.key_info.attr.wep.key, pu8WepKey, (u8WepKeylen));
3251 msg.body.key_info.attr.wep.key_len = (u8WepKeylen);
3252 msg.body.key_info.attr.wep.index = u8Keyidx;
3253 msg.body.key_info.attr.wep.mode = u8mode;
3254 msg.body.key_info.attr.wep.auth_type = tenuAuth_type;
3255
3256 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3257
3258 if (s32Error)
3259 PRINT_ER("Error in sending message queue :WEP Key\n");
3260 down(&hif_drv->hSemTestKeyBlock);
3261
3262 return s32Error;
3263
3264 }
3265
3266 s32 host_int_add_ptk(struct host_if_drv *hif_drv, const u8 *pu8Ptk,
3267 u8 u8PtkKeylen, const u8 *mac_addr,
3268 const u8 *pu8RxMic, const u8 *pu8TxMic,
3269 u8 mode, u8 u8Ciphermode, u8 u8Idx)
3270 {
3271 s32 s32Error = 0;
3272 struct host_if_msg msg;
3273 u8 u8KeyLen = u8PtkKeylen;
3274 u32 i;
3275
3276 if (!hif_drv) {
3277 s32Error = -EFAULT;
3278 PRINT_ER("driver is null\n");
3279 return s32Error;
3280 }
3281 if (pu8RxMic != NULL)
3282 u8KeyLen += RX_MIC_KEY_LEN;
3283 if (pu8TxMic != NULL)
3284 u8KeyLen += TX_MIC_KEY_LEN;
3285
3286 memset(&msg, 0, sizeof(struct host_if_msg));
3287
3288
3289 msg.id = HOST_IF_MSG_KEY;
3290 msg.body.key_info.type = WPAPtk;
3291 if (mode == AP_MODE) {
3292 msg.body.key_info.action = ADDKEY_AP;
3293 msg.body.key_info.attr.wpa.index = u8Idx;
3294 }
3295 if (mode == STATION_MODE)
3296 msg.body.key_info.action = ADDKEY;
3297
3298 msg.body.key_info.attr.wpa.key = kmalloc(u8PtkKeylen, GFP_KERNEL);
3299 memcpy(msg.body.key_info.attr.wpa.key, pu8Ptk, u8PtkKeylen);
3300
3301 if (pu8RxMic != NULL) {
3302 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic, RX_MIC_KEY_LEN);
3303 if (INFO) {
3304 for (i = 0; i < RX_MIC_KEY_LEN; i++)
3305 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
3306 }
3307 }
3308 if (pu8TxMic != NULL) {
3309 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic, TX_MIC_KEY_LEN);
3310 if (INFO) {
3311 for (i = 0; i < TX_MIC_KEY_LEN; i++)
3312 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
3313 }
3314 }
3315
3316 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
3317 msg.body.key_info.attr.wpa.mac_addr = mac_addr;
3318 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
3319 msg.drv = hif_drv;
3320
3321 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3322
3323 if (s32Error)
3324 PRINT_ER("Error in sending message queue: PTK Key\n");
3325
3326 down(&hif_drv->hSemTestKeyBlock);
3327
3328 return s32Error;
3329 }
3330
3331 s32 host_int_add_rx_gtk(struct host_if_drv *hif_drv, const u8 *pu8RxGtk,
3332 u8 u8GtkKeylen, u8 u8KeyIdx,
3333 u32 u32KeyRSClen, const u8 *KeyRSC,
3334 const u8 *pu8RxMic, const u8 *pu8TxMic,
3335 u8 mode, u8 u8Ciphermode)
3336 {
3337 s32 s32Error = 0;
3338 struct host_if_msg msg;
3339 u8 u8KeyLen = u8GtkKeylen;
3340
3341 if (!hif_drv) {
3342 s32Error = -EFAULT;
3343 PRINT_ER("driver is null\n");
3344 return s32Error;
3345 }
3346 memset(&msg, 0, sizeof(struct host_if_msg));
3347
3348
3349 if (pu8RxMic != NULL)
3350 u8KeyLen += RX_MIC_KEY_LEN;
3351 if (pu8TxMic != NULL)
3352 u8KeyLen += TX_MIC_KEY_LEN;
3353 if (KeyRSC != NULL) {
3354 msg.body.key_info.attr.wpa.seq = kmalloc(u32KeyRSClen, GFP_KERNEL);
3355 memcpy(msg.body.key_info.attr.wpa.seq, KeyRSC, u32KeyRSClen);
3356 }
3357
3358
3359 msg.id = HOST_IF_MSG_KEY;
3360 msg.body.key_info.type = WPARxGtk;
3361 msg.drv = hif_drv;
3362
3363 if (mode == AP_MODE) {
3364 msg.body.key_info.action = ADDKEY_AP;
3365 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
3366 }
3367 if (mode == STATION_MODE)
3368 msg.body.key_info.action = ADDKEY;
3369
3370 msg.body.key_info.attr.wpa.key = kmalloc(u8KeyLen, GFP_KERNEL);
3371 memcpy(msg.body.key_info.attr.wpa.key, pu8RxGtk, u8GtkKeylen);
3372
3373 if (pu8RxMic != NULL) {
3374 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic, RX_MIC_KEY_LEN);
3375 }
3376 if (pu8TxMic != NULL) {
3377 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic, TX_MIC_KEY_LEN);
3378 }
3379
3380 msg.body.key_info.attr.wpa.index = u8KeyIdx;
3381 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
3382 msg.body.key_info.attr.wpa.seq_len = u32KeyRSClen;
3383
3384 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3385 if (s32Error)
3386 PRINT_ER("Error in sending message queue: RX GTK\n");
3387
3388 down(&hif_drv->hSemTestKeyBlock);
3389
3390 return s32Error;
3391 }
3392
3393 s32 host_int_set_pmkid_info(struct host_if_drv *hif_drv, struct host_if_pmkid_attr *pu8PmkidInfoArray)
3394 {
3395 s32 s32Error = 0;
3396 struct host_if_msg msg;
3397 u32 i;
3398
3399
3400 if (!hif_drv) {
3401 s32Error = -EFAULT;
3402 PRINT_ER("driver is null\n");
3403 return s32Error;
3404 }
3405
3406 memset(&msg, 0, sizeof(struct host_if_msg));
3407
3408 msg.id = HOST_IF_MSG_KEY;
3409 msg.body.key_info.type = PMKSA;
3410 msg.body.key_info.action = ADDKEY;
3411 msg.drv = hif_drv;
3412
3413 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
3414 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
3415 ETH_ALEN);
3416 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
3417 PMKID_LEN);
3418 }
3419
3420 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3421 if (s32Error)
3422 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
3423
3424 return s32Error;
3425 }
3426
3427 s32 host_int_get_pmkid_info(struct host_if_drv *hif_drv,
3428 u8 *pu8PmkidInfoArray,
3429 u32 u32PmkidInfoLen)
3430 {
3431 struct wid strWID;
3432
3433 strWID.id = (u16)WID_PMKID_INFO;
3434 strWID.type = WID_STR;
3435 strWID.size = u32PmkidInfoLen;
3436 strWID.val = pu8PmkidInfoArray;
3437
3438 return 0;
3439 }
3440
3441 s32 host_int_set_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3442 u8 *pu8PassPhrase,
3443 u8 u8Psklength)
3444 {
3445 struct wid strWID;
3446
3447 if ((u8Psklength > 7) && (u8Psklength < 65)) {
3448 strWID.id = (u16)WID_11I_PSK;
3449 strWID.type = WID_STR;
3450 strWID.val = pu8PassPhrase;
3451 strWID.size = u8Psklength;
3452 }
3453
3454 return 0;
3455 }
3456
3457 s32 host_int_get_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
3458 {
3459 s32 s32Error = 0;
3460 struct host_if_msg msg;
3461
3462 memset(&msg, 0, sizeof(struct host_if_msg));
3463
3464 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
3465 msg.body.get_mac_info.u8MacAddress = pu8MacAddress;
3466 msg.drv = hif_drv;
3467
3468 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3469 if (s32Error) {
3470 PRINT_ER("Failed to send get mac address\n");
3471 return -EFAULT;
3472 }
3473
3474 down(&hif_sema_wait_response);
3475 return s32Error;
3476 }
3477
3478 s32 host_int_set_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
3479 {
3480 s32 s32Error = 0;
3481 struct host_if_msg msg;
3482
3483 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
3484
3485 memset(&msg, 0, sizeof(struct host_if_msg));
3486 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
3487 memcpy(msg.body.set_mac_info.u8MacAddress, pu8MacAddress, ETH_ALEN);
3488 msg.drv = hif_drv;
3489
3490 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3491 if (s32Error)
3492 PRINT_ER("Failed to send message queue: Set mac address\n");
3493
3494 return s32Error;
3495
3496 }
3497
3498 s32 host_int_get_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3499 u8 *pu8PassPhrase, u8 u8Psklength)
3500 {
3501 struct wid strWID;
3502
3503 strWID.id = (u16)WID_11I_PSK;
3504 strWID.type = WID_STR;
3505 strWID.size = u8Psklength;
3506 strWID.val = pu8PassPhrase;
3507
3508 return 0;
3509 }
3510
3511 s32 host_int_set_start_scan_req(struct host_if_drv *hif_drv, u8 scanSource)
3512 {
3513 struct wid strWID;
3514
3515 strWID.id = (u16)WID_START_SCAN_REQ;
3516 strWID.type = WID_CHAR;
3517 strWID.val = (s8 *)&scanSource;
3518 strWID.size = sizeof(char);
3519
3520 return 0;
3521 }
3522
3523 s32 host_int_get_start_scan_req(struct host_if_drv *hif_drv, u8 *pu8ScanSource)
3524 {
3525 struct wid strWID;
3526
3527 strWID.id = (u16)WID_START_SCAN_REQ;
3528 strWID.type = WID_CHAR;
3529 strWID.val = (s8 *)pu8ScanSource;
3530 strWID.size = sizeof(char);
3531
3532 return 0;
3533 }
3534
3535 s32 host_int_set_join_req(struct host_if_drv *hif_drv, u8 *pu8bssid,
3536 const u8 *pu8ssid, size_t ssidLen,
3537 const u8 *pu8IEs, size_t IEsLen,
3538 wilc_connect_result pfConnectResult, void *pvUserArg,
3539 u8 u8security, enum AUTHTYPE tenuAuth_type,
3540 u8 u8channel, void *pJoinParams)
3541 {
3542 s32 s32Error = 0;
3543 struct host_if_msg msg;
3544
3545 if (!hif_drv || pfConnectResult == NULL) {
3546 s32Error = -EFAULT;
3547 PRINT_ER("Driver is null\n");
3548 return s32Error;
3549 }
3550
3551 if (pJoinParams == NULL) {
3552 PRINT_ER("Unable to Join - JoinParams is NULL\n");
3553 return -EFAULT;
3554 }
3555
3556 memset(&msg, 0, sizeof(struct host_if_msg));
3557
3558 msg.id = HOST_IF_MSG_CONNECT;
3559
3560 msg.body.con_info.security = u8security;
3561 msg.body.con_info.auth_type = tenuAuth_type;
3562 msg.body.con_info.ch = u8channel;
3563 msg.body.con_info.result = pfConnectResult;
3564 msg.body.con_info.arg = pvUserArg;
3565 msg.body.con_info.params = pJoinParams;
3566 msg.drv = hif_drv ;
3567
3568 if (pu8bssid != NULL) {
3569 msg.body.con_info.bssid = kmalloc(6, GFP_KERNEL);
3570 memcpy(msg.body.con_info.bssid, pu8bssid, 6);
3571 }
3572
3573 if (pu8ssid != NULL) {
3574 msg.body.con_info.ssid_len = ssidLen;
3575 msg.body.con_info.ssid = kmalloc(ssidLen, GFP_KERNEL);
3576 memcpy(msg.body.con_info.ssid, pu8ssid, ssidLen);
3577 }
3578
3579 if (pu8IEs != NULL) {
3580 msg.body.con_info.ies_len = IEsLen;
3581 msg.body.con_info.ies = kmalloc(IEsLen, GFP_KERNEL);
3582 memcpy(msg.body.con_info.ies, pu8IEs, IEsLen);
3583 }
3584 if (hif_drv->enuHostIFstate < HOST_IF_CONNECTING)
3585 hif_drv->enuHostIFstate = HOST_IF_CONNECTING;
3586 else
3587 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", hif_drv->enuHostIFstate);
3588
3589 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3590 if (s32Error) {
3591 PRINT_ER("Failed to send message queue: Set join request\n");
3592 return -EFAULT;
3593 }
3594
3595 hif_drv->hConnectTimer.data = (unsigned long)hif_drv;
3596 mod_timer(&hif_drv->hConnectTimer,
3597 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
3598
3599 return s32Error;
3600 }
3601
3602 s32 host_int_flush_join_req(struct host_if_drv *hif_drv)
3603 {
3604 s32 s32Error = 0;
3605 struct host_if_msg msg;
3606
3607 if (!gu8FlushedJoinReq) {
3608 s32Error = -EFAULT;
3609 return s32Error;
3610 }
3611
3612
3613 if (!hif_drv) {
3614 s32Error = -EFAULT;
3615 PRINT_ER("Driver is null\n");
3616 return s32Error;
3617 }
3618
3619 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
3620 msg.drv = hif_drv;
3621
3622 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3623 if (s32Error) {
3624 PRINT_ER("Failed to send message queue: Flush join request\n");
3625 return -EFAULT;
3626 }
3627
3628 return s32Error;
3629 }
3630
3631 s32 host_int_disconnect(struct host_if_drv *hif_drv, u16 u16ReasonCode)
3632 {
3633 s32 s32Error = 0;
3634 struct host_if_msg msg;
3635
3636 if (!hif_drv) {
3637 PRINT_ER("Driver is null\n");
3638 return -EFAULT;
3639 }
3640
3641 memset(&msg, 0, sizeof(struct host_if_msg));
3642
3643 msg.id = HOST_IF_MSG_DISCONNECT;
3644 msg.drv = hif_drv;
3645
3646 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3647 if (s32Error)
3648 PRINT_ER("Failed to send message queue: disconnect\n");
3649
3650 down(&hif_drv->hSemTestDisconnectBlock);
3651
3652 return s32Error;
3653 }
3654
3655 s32 host_int_disconnect_station(struct host_if_drv *hif_drv, u8 assoc_id)
3656 {
3657 struct wid strWID;
3658
3659 strWID.id = (u16)WID_DISCONNECT;
3660 strWID.type = WID_CHAR;
3661 strWID.val = (s8 *)&assoc_id;
3662 strWID.size = sizeof(char);
3663
3664 return 0;
3665 }
3666
3667 s32 host_int_get_assoc_req_info(struct host_if_drv *hif_drv, u8 *pu8AssocReqInfo,
3668 u32 u32AssocReqInfoLen)
3669 {
3670 struct wid strWID;
3671
3672 strWID.id = (u16)WID_ASSOC_REQ_INFO;
3673 strWID.type = WID_STR;
3674 strWID.val = pu8AssocReqInfo;
3675 strWID.size = u32AssocReqInfoLen;
3676
3677 return 0;
3678 }
3679
3680 s32 host_int_get_assoc_res_info(struct host_if_drv *hif_drv, u8 *pu8AssocRespInfo,
3681 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
3682 {
3683 s32 s32Error = 0;
3684 struct wid strWID;
3685
3686 if (!hif_drv) {
3687 PRINT_ER("Driver is null\n");
3688 return -EFAULT;
3689 }
3690
3691 strWID.id = (u16)WID_ASSOC_RES_INFO;
3692 strWID.type = WID_STR;
3693 strWID.val = pu8AssocRespInfo;
3694 strWID.size = u32MaxAssocRespInfoLen;
3695
3696 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
3697 get_id_from_handler(hif_drv));
3698 if (s32Error) {
3699 *pu32RcvdAssocRespInfoLen = 0;
3700 PRINT_ER("Failed to send association response config packet\n");
3701 return -EINVAL;
3702 } else {
3703 *pu32RcvdAssocRespInfoLen = strWID.size;
3704 }
3705
3706 return s32Error;
3707 }
3708
3709 s32 host_int_get_rx_power_level(struct host_if_drv *hif_drv, u8 *pu8RxPowerLevel,
3710 u32 u32RxPowerLevelLen)
3711 {
3712 struct wid strWID;
3713
3714 strWID.id = (u16)WID_RX_POWER_LEVEL;
3715 strWID.type = WID_STR;
3716 strWID.val = pu8RxPowerLevel;
3717 strWID.size = u32RxPowerLevelLen;
3718
3719 return 0;
3720 }
3721
3722 int host_int_set_mac_chnl_num(struct host_if_drv *hif_drv, u8 channel)
3723 {
3724 int result;
3725 struct host_if_msg msg;
3726
3727 if (!hif_drv) {
3728 PRINT_ER("driver is null\n");
3729 return -EFAULT;
3730 }
3731
3732 memset(&msg, 0, sizeof(struct host_if_msg));
3733 msg.id = HOST_IF_MSG_SET_CHANNEL;
3734 msg.body.channel_info.set_ch = channel;
3735 msg.drv = hif_drv;
3736
3737 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3738 if (result) {
3739 PRINT_ER("wilc mq send fail\n");
3740 return -EINVAL;
3741 }
3742
3743 return 0;
3744 }
3745
3746 int host_int_wait_msg_queue_idle(void)
3747 {
3748 int result = 0;
3749
3750 struct host_if_msg msg;
3751 memset(&msg, 0, sizeof(struct host_if_msg));
3752 msg.id = HOST_IF_MSG_Q_IDLE;
3753 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3754 if (result) {
3755 PRINT_ER("wilc mq send fail\n");
3756 result = -EINVAL;
3757 }
3758
3759 down(&hif_sema_wait_response);
3760
3761 return result;
3762 }
3763
3764 int host_int_set_wfi_drv_handler(struct host_if_drv *hif_drv)
3765 {
3766 int result = 0;
3767
3768 struct host_if_msg msg;
3769 memset(&msg, 0, sizeof(struct host_if_msg));
3770 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
3771 msg.body.drv.u32Address = get_id_from_handler(hif_drv);
3772 msg.drv = hif_drv;
3773
3774 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3775 if (result) {
3776 PRINT_ER("wilc mq send fail\n");
3777 result = -EINVAL;
3778 }
3779
3780 return result;
3781 }
3782
3783 int host_int_set_operation_mode(struct host_if_drv *hif_drv, u32 mode)
3784 {
3785 int result = 0;
3786
3787 struct host_if_msg msg;
3788 memset(&msg, 0, sizeof(struct host_if_msg));
3789 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
3790 msg.body.mode.u32Mode = mode;
3791 msg.drv = hif_drv;
3792
3793 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3794 if (result) {
3795 PRINT_ER("wilc mq send fail\n");
3796 result = -EINVAL;
3797 }
3798
3799 return result;
3800 }
3801
3802 s32 host_int_get_host_chnl_num(struct host_if_drv *hif_drv, u8 *pu8ChNo)
3803 {
3804 s32 s32Error = 0;
3805 struct host_if_msg msg;
3806
3807 if (!hif_drv) {
3808 PRINT_ER("driver is null\n");
3809 return -EFAULT;
3810 }
3811
3812 memset(&msg, 0, sizeof(struct host_if_msg));
3813
3814 msg.id = HOST_IF_MSG_GET_CHNL;
3815 msg.drv = hif_drv;
3816
3817 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3818 if (s32Error)
3819 PRINT_ER("wilc mq send fail\n");
3820 down(&hif_drv->hSemGetCHNL);
3821
3822 *pu8ChNo = gu8Chnl;
3823
3824 return s32Error;
3825
3826
3827 }
3828
3829 s32 host_int_get_inactive_time(struct host_if_drv *hif_drv,
3830 const u8 *mac, u32 *pu32InactiveTime)
3831 {
3832 s32 s32Error = 0;
3833 struct host_if_msg msg;
3834
3835 if (!hif_drv) {
3836 PRINT_ER("driver is null\n");
3837 return -EFAULT;
3838 }
3839
3840 memset(&msg, 0, sizeof(struct host_if_msg));
3841
3842
3843 memcpy(msg.body.mac_info.mac,
3844 mac, ETH_ALEN);
3845
3846 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
3847 msg.drv = hif_drv;
3848
3849 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3850 if (s32Error)
3851 PRINT_ER("Failed to send get host channel param's message queue ");
3852
3853 down(&hif_drv->hSemInactiveTime);
3854
3855 *pu32InactiveTime = gu32InactiveTime;
3856
3857 return s32Error;
3858 }
3859
3860 s32 host_int_test_get_int_wid(struct host_if_drv *hif_drv, u32 *pu32TestMemAddr)
3861 {
3862
3863 s32 s32Error = 0;
3864 struct wid strWID;
3865
3866 if (!hif_drv) {
3867 PRINT_ER("driver is null\n");
3868 return -EFAULT;
3869 }
3870
3871 strWID.id = (u16)WID_MEMORY_ADDRESS;
3872 strWID.type = WID_INT;
3873 strWID.val = (s8 *)pu32TestMemAddr;
3874 strWID.size = sizeof(u32);
3875
3876 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
3877 get_id_from_handler(hif_drv));
3878
3879 if (s32Error) {
3880 PRINT_ER("Failed to get wid value\n");
3881 return -EINVAL;
3882 } else {
3883 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
3884
3885 }
3886
3887 return s32Error;
3888 }
3889
3890 s32 host_int_get_rssi(struct host_if_drv *hif_drv, s8 *ps8Rssi)
3891 {
3892 s32 s32Error = 0;
3893 struct host_if_msg msg;
3894 memset(&msg, 0, sizeof(struct host_if_msg));
3895
3896 msg.id = HOST_IF_MSG_GET_RSSI;
3897 msg.drv = hif_drv;
3898
3899 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3900 if (s32Error) {
3901 PRINT_ER("Failed to send get host channel param's message queue ");
3902 return -EFAULT;
3903 }
3904
3905 down(&hif_drv->hSemGetRSSI);
3906
3907
3908 if (ps8Rssi == NULL) {
3909 PRINT_ER("RSS pointer value is null");
3910 return -EFAULT;
3911 }
3912
3913
3914 *ps8Rssi = gs8Rssi;
3915
3916
3917 return s32Error;
3918 }
3919
3920 s32 host_int_get_link_speed(struct host_if_drv *hif_drv, s8 *ps8lnkspd)
3921 {
3922 struct host_if_msg msg;
3923 s32 s32Error = 0;
3924 memset(&msg, 0, sizeof(struct host_if_msg));
3925
3926 msg.id = HOST_IF_MSG_GET_LINKSPEED;
3927 msg.drv = hif_drv;
3928
3929 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3930 if (s32Error) {
3931 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
3932 return -EFAULT;
3933 }
3934
3935 down(&hif_drv->hSemGetLINKSPEED);
3936
3937
3938 if (ps8lnkspd == NULL) {
3939 PRINT_ER("LINKSPEED pointer value is null");
3940 return -EFAULT;
3941 }
3942
3943
3944 *ps8lnkspd = gs8lnkspd;
3945
3946
3947 return s32Error;
3948 }
3949
3950 s32 host_int_get_statistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
3951 {
3952 s32 s32Error = 0;
3953 struct host_if_msg msg;
3954 memset(&msg, 0, sizeof(struct host_if_msg));
3955
3956 msg.id = HOST_IF_MSG_GET_STATISTICS;
3957 msg.body.data = (char *)pstrStatistics;
3958 msg.drv = hif_drv;
3959
3960 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3961 if (s32Error) {
3962 PRINT_ER("Failed to send get host channel param's message queue ");
3963 return -EFAULT;
3964 }
3965
3966 down(&hif_sema_wait_response);
3967 return s32Error;
3968 }
3969
3970 s32 host_int_scan(struct host_if_drv *hif_drv, u8 u8ScanSource,
3971 u8 u8ScanType, u8 *pu8ChnlFreqList,
3972 u8 u8ChnlListLen, const u8 *pu8IEs,
3973 size_t IEsLen, wilc_scan_result ScanResult,
3974 void *pvUserArg, struct hidden_network *pstrHiddenNetwork)
3975 {
3976 s32 s32Error = 0;
3977 struct host_if_msg msg;
3978
3979 if (!hif_drv || ScanResult == NULL) {
3980 PRINT_ER("hif_drv or ScanResult = NULL\n");
3981 return -EFAULT;
3982 }
3983
3984 memset(&msg, 0, sizeof(struct host_if_msg));
3985
3986 msg.id = HOST_IF_MSG_SCAN;
3987
3988 if (pstrHiddenNetwork != NULL) {
3989 msg.body.scan_info.hidden_network.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
3990 msg.body.scan_info.hidden_network.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
3991
3992 } else
3993 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
3994
3995 msg.drv = hif_drv;
3996 msg.body.scan_info.src = u8ScanSource;
3997 msg.body.scan_info.type = u8ScanType;
3998 msg.body.scan_info.result = ScanResult;
3999 msg.body.scan_info.arg = pvUserArg;
4000
4001 msg.body.scan_info.ch_list_len = u8ChnlListLen;
4002 msg.body.scan_info.ch_freq_list = kmalloc(u8ChnlListLen, GFP_KERNEL);
4003 memcpy(msg.body.scan_info.ch_freq_list, pu8ChnlFreqList, u8ChnlListLen);
4004
4005 msg.body.scan_info.ies_len = IEsLen;
4006 msg.body.scan_info.ies = kmalloc(IEsLen, GFP_KERNEL);
4007 memcpy(msg.body.scan_info.ies, pu8IEs, IEsLen);
4008
4009 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4010 if (s32Error) {
4011 PRINT_ER("Error in sending message queue\n");
4012 return -EINVAL;
4013 }
4014
4015 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
4016 hif_drv->hScanTimer.data = (unsigned long)hif_drv;
4017 mod_timer(&hif_drv->hScanTimer,
4018 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
4019
4020 return s32Error;
4021
4022 }
4023
4024 s32 hif_set_cfg(struct host_if_drv *hif_drv,
4025 struct cfg_param_val *pstrCfgParamVal)
4026 {
4027
4028 s32 s32Error = 0;
4029 struct host_if_msg msg;
4030
4031
4032 if (!hif_drv) {
4033 PRINT_ER("hif_drv NULL\n");
4034 return -EFAULT;
4035 }
4036
4037 memset(&msg, 0, sizeof(struct host_if_msg));
4038 msg.id = HOST_IF_MSG_CFG_PARAMS;
4039 msg.body.cfg_info.cfg_attr_info = *pstrCfgParamVal;
4040 msg.drv = hif_drv;
4041
4042 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4043
4044 return s32Error;
4045
4046 }
4047
4048 s32 hif_get_cfg(struct host_if_drv *hif_drv, u16 u16WID, u16 *pu16WID_Value)
4049 {
4050 s32 s32Error = 0;
4051
4052 down(&hif_drv->gtOsCfgValuesSem);
4053
4054 if (!hif_drv) {
4055 PRINT_ER("hif_drv NULL\n");
4056 return -EFAULT;
4057 }
4058 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
4059 switch (u16WID) {
4060
4061 case WID_BSS_TYPE:
4062 *pu16WID_Value = (u16)hif_drv->strCfgValues.bss_type;
4063 break;
4064
4065 case WID_AUTH_TYPE:
4066 *pu16WID_Value = (u16)hif_drv->strCfgValues.auth_type;
4067 break;
4068
4069 case WID_AUTH_TIMEOUT:
4070 *pu16WID_Value = hif_drv->strCfgValues.auth_timeout;
4071 break;
4072
4073 case WID_POWER_MANAGEMENT:
4074 *pu16WID_Value = (u16)hif_drv->strCfgValues.power_mgmt_mode;
4075 break;
4076
4077 case WID_SHORT_RETRY_LIMIT:
4078 *pu16WID_Value = hif_drv->strCfgValues.short_retry_limit;
4079 break;
4080
4081 case WID_LONG_RETRY_LIMIT:
4082 *pu16WID_Value = hif_drv->strCfgValues.long_retry_limit;
4083 break;
4084
4085 case WID_FRAG_THRESHOLD:
4086 *pu16WID_Value = hif_drv->strCfgValues.frag_threshold;
4087 break;
4088
4089 case WID_RTS_THRESHOLD:
4090 *pu16WID_Value = hif_drv->strCfgValues.rts_threshold;
4091 break;
4092
4093 case WID_PREAMBLE:
4094 *pu16WID_Value = (u16)hif_drv->strCfgValues.preamble_type;
4095 break;
4096
4097 case WID_SHORT_SLOT_ALLOWED:
4098 *pu16WID_Value = (u16) hif_drv->strCfgValues.short_slot_allowed;
4099 break;
4100
4101 case WID_11N_TXOP_PROT_DISABLE:
4102 *pu16WID_Value = (u16)hif_drv->strCfgValues.txop_prot_disabled;
4103 break;
4104
4105 case WID_BEACON_INTERVAL:
4106 *pu16WID_Value = hif_drv->strCfgValues.beacon_interval;
4107 break;
4108
4109 case WID_DTIM_PERIOD:
4110 *pu16WID_Value = (u16)hif_drv->strCfgValues.dtim_period;
4111 break;
4112
4113 case WID_SITE_SURVEY:
4114 *pu16WID_Value = (u16)hif_drv->strCfgValues.site_survey_enabled;
4115 break;
4116
4117 case WID_SITE_SURVEY_SCAN_TIME:
4118 *pu16WID_Value = hif_drv->strCfgValues.site_survey_scan_time;
4119 break;
4120
4121 case WID_ACTIVE_SCAN_TIME:
4122 *pu16WID_Value = hif_drv->strCfgValues.active_scan_time;
4123 break;
4124
4125 case WID_PASSIVE_SCAN_TIME:
4126 *pu16WID_Value = hif_drv->strCfgValues.passive_scan_time;
4127 break;
4128
4129 case WID_CURRENT_TX_RATE:
4130 *pu16WID_Value = hif_drv->strCfgValues.curr_tx_rate;
4131 break;
4132
4133 default:
4134 break;
4135 }
4136
4137 up(&hif_drv->gtOsCfgValuesSem);
4138
4139 return s32Error;
4140
4141 }
4142
4143 void host_int_send_join_leave_info_to_host
4144 (u16 assocId, u8 *stationAddr, bool joining)
4145 {
4146 }
4147
4148 static void GetPeriodicRSSI(unsigned long arg)
4149 {
4150 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
4151
4152 if (!hif_drv) {
4153 PRINT_ER("Driver handler is NULL\n");
4154 return;
4155 }
4156
4157 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED) {
4158 s32 s32Error = 0;
4159 struct host_if_msg msg;
4160
4161 memset(&msg, 0, sizeof(struct host_if_msg));
4162
4163 msg.id = HOST_IF_MSG_GET_RSSI;
4164 msg.drv = hif_drv;
4165
4166 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4167 if (s32Error) {
4168 PRINT_ER("Failed to send get host channel param's message queue ");
4169 return;
4170 }
4171 }
4172 periodic_rssi.data = (unsigned long)hif_drv;
4173 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
4174 }
4175
4176
4177 void host_int_send_network_info_to_host
4178 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
4179 {
4180 }
4181
4182 static u32 clients_count;
4183
4184 s32 host_int_init(struct host_if_drv **hif_drv_handler)
4185 {
4186 s32 result = 0;
4187 struct host_if_drv *hif_drv;
4188 int err;
4189
4190 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
4191
4192 gbScanWhileConnected = false;
4193
4194 sema_init(&hif_sema_wait_response, 0);
4195
4196 hif_drv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
4197 if (!hif_drv) {
4198 result = -ENOMEM;
4199 goto _fail_;
4200 }
4201 *hif_drv_handler = hif_drv;
4202 err = add_handler_in_list(hif_drv);
4203 if (err) {
4204 result = -EFAULT;
4205 goto _fail_timer_2;
4206 }
4207
4208 g_obtainingIP = false;
4209
4210 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", hif_drv);
4211 if (clients_count == 0) {
4212 sema_init(&hif_sema_thread, 0);
4213 sema_init(&hif_sema_driver, 0);
4214 sema_init(&hif_sema_deinit, 1);
4215 }
4216
4217 sema_init(&hif_drv->hSemTestKeyBlock, 0);
4218 sema_init(&hif_drv->hSemTestDisconnectBlock, 0);
4219 sema_init(&hif_drv->hSemGetRSSI, 0);
4220 sema_init(&hif_drv->hSemGetLINKSPEED, 0);
4221 sema_init(&hif_drv->hSemGetCHNL, 0);
4222 sema_init(&hif_drv->hSemInactiveTime, 0);
4223
4224 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
4225
4226 if (clients_count == 0) {
4227 result = wilc_mq_create(&hif_msg_q);
4228
4229 if (result < 0) {
4230 PRINT_ER("Failed to creat MQ\n");
4231 goto _fail_;
4232 }
4233
4234 hif_thread_handler = kthread_run(hostIFthread, NULL, "WILC_kthread");
4235
4236 if (IS_ERR(hif_thread_handler)) {
4237 PRINT_ER("Failed to creat Thread\n");
4238 result = -EFAULT;
4239 goto _fail_mq_;
4240 }
4241 setup_timer(&periodic_rssi, GetPeriodicRSSI,
4242 (unsigned long)hif_drv);
4243 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
4244 }
4245
4246 setup_timer(&hif_drv->hScanTimer, TimerCB_Scan, 0);
4247
4248 setup_timer(&hif_drv->hConnectTimer, TimerCB_Connect, 0);
4249
4250 setup_timer(&hif_drv->hRemainOnChannel, ListenTimerCB, 0);
4251
4252 sema_init(&(hif_drv->gtOsCfgValuesSem), 1);
4253 down(&hif_drv->gtOsCfgValuesSem);
4254
4255 hif_drv->enuHostIFstate = HOST_IF_IDLE;
4256 hif_drv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
4257 hif_drv->strCfgValues.scan_source = DEFAULT_SCAN;
4258 hif_drv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
4259 hif_drv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
4260 hif_drv->strCfgValues.curr_tx_rate = AUTORATE;
4261
4262 hif_drv->u64P2p_MgmtTimeout = 0;
4263
4264 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",
4265
4266 hif_drv->strCfgValues.site_survey_enabled, hif_drv->strCfgValues.scan_source,
4267 hif_drv->strCfgValues.active_scan_time, hif_drv->strCfgValues.passive_scan_time,
4268 hif_drv->strCfgValues.curr_tx_rate);
4269
4270 up(&hif_drv->gtOsCfgValuesSem);
4271
4272 clients_count++;
4273
4274 return result;
4275
4276 _fail_timer_2:
4277 up(&hif_drv->gtOsCfgValuesSem);
4278 del_timer_sync(&hif_drv->hConnectTimer);
4279 del_timer_sync(&hif_drv->hScanTimer);
4280 kthread_stop(hif_thread_handler);
4281 _fail_mq_:
4282 wilc_mq_destroy(&hif_msg_q);
4283 _fail_:
4284 return result;
4285 }
4286
4287 s32 host_int_deinit(struct host_if_drv *hif_drv)
4288 {
4289 s32 s32Error = 0;
4290 struct host_if_msg msg;
4291 int ret;
4292
4293 if (!hif_drv) {
4294 PRINT_ER("hif_drv = NULL\n");
4295 return 0;
4296 }
4297
4298 down(&hif_sema_deinit);
4299
4300 terminated_handle = hif_drv;
4301 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
4302
4303 if (del_timer_sync(&hif_drv->hScanTimer)) {
4304 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
4305 }
4306
4307 if (del_timer_sync(&hif_drv->hConnectTimer)) {
4308 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4309 }
4310
4311 if (del_timer_sync(&periodic_rssi))
4312 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4313
4314 del_timer_sync(&hif_drv->hRemainOnChannel);
4315
4316 host_int_set_wfi_drv_handler(NULL);
4317 down(&hif_sema_driver);
4318
4319 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
4320 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
4321 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
4322
4323 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
4324 }
4325
4326 hif_drv->enuHostIFstate = HOST_IF_IDLE;
4327
4328 gbScanWhileConnected = false;
4329
4330 memset(&msg, 0, sizeof(struct host_if_msg));
4331
4332 if (clients_count == 1) {
4333 if (del_timer_sync(&periodic_rssi))
4334 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4335
4336 msg.id = HOST_IF_MSG_EXIT;
4337 msg.drv = hif_drv;
4338
4339 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4340 if (s32Error != 0)
4341 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
4342
4343 down(&hif_sema_thread);
4344
4345 wilc_mq_destroy(&hif_msg_q);
4346 }
4347
4348 down(&(hif_drv->gtOsCfgValuesSem));
4349
4350 ret = remove_handler_in_list(hif_drv);
4351 if (ret)
4352 s32Error = -ENOENT;
4353
4354 kfree(hif_drv);
4355
4356 clients_count--;
4357 terminated_handle = NULL;
4358 up(&hif_sema_deinit);
4359 return s32Error;
4360 }
4361
4362 void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
4363 {
4364 s32 s32Error = 0;
4365 struct host_if_msg msg;
4366 int id;
4367 struct host_if_drv *hif_drv = NULL;
4368
4369 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4370 hif_drv = get_handler_from_id(id);
4371
4372
4373
4374
4375 if (!hif_drv || hif_drv == terminated_handle) {
4376 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv);
4377 return;
4378 }
4379
4380 memset(&msg, 0, sizeof(struct host_if_msg));
4381
4382 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
4383 msg.drv = hif_drv;
4384
4385 msg.body.net_info.len = u32Length;
4386 msg.body.net_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4387 memcpy(msg.body.net_info.buffer, pu8Buffer, u32Length);
4388
4389 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4390 if (s32Error)
4391 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
4392 }
4393
4394 void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
4395 {
4396 s32 s32Error = 0;
4397 struct host_if_msg msg;
4398 int id;
4399 struct host_if_drv *hif_drv = NULL;
4400
4401 down(&hif_sema_deinit);
4402
4403 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4404 hif_drv = get_handler_from_id(id);
4405 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
4406
4407
4408 if (!hif_drv || hif_drv == terminated_handle) {
4409 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
4410 up(&hif_sema_deinit);
4411 return;
4412 }
4413
4414 if (!hif_drv->strWILC_UsrConnReq.pfUserConnectResult) {
4415 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
4416 up(&hif_sema_deinit);
4417 return;
4418 }
4419
4420 memset(&msg, 0, sizeof(struct host_if_msg));
4421
4422
4423 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
4424 msg.drv = hif_drv;
4425
4426 msg.body.async_info.len = u32Length;
4427 msg.body.async_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4428 memcpy(msg.body.async_info.buffer, pu8Buffer, u32Length);
4429
4430 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4431 if (s32Error)
4432 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
4433
4434 up(&hif_sema_deinit);
4435 }
4436
4437 void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
4438 {
4439 s32 s32Error = 0;
4440 struct host_if_msg msg;
4441 int id;
4442 struct host_if_drv *hif_drv = NULL;
4443
4444 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4445 hif_drv = get_handler_from_id(id);
4446
4447
4448 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", hif_drv);
4449
4450 if (!hif_drv || hif_drv == terminated_handle)
4451 return;
4452
4453 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
4454 memset(&msg, 0, sizeof(struct host_if_msg));
4455
4456 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
4457 msg.drv = hif_drv;
4458
4459 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4460 if (s32Error)
4461 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
4462 }
4463
4464
4465 return;
4466
4467 }
4468
4469 s32 host_int_remain_on_channel(struct host_if_drv *hif_drv, u32 u32SessionID,
4470 u32 u32duration, u16 chan,
4471 wilc_remain_on_chan_expired RemainOnChanExpired,
4472 wilc_remain_on_chan_ready RemainOnChanReady,
4473 void *pvUserArg)
4474 {
4475 s32 s32Error = 0;
4476 struct host_if_msg msg;
4477
4478 if (!hif_drv) {
4479 PRINT_ER("driver is null\n");
4480 return -EFAULT;
4481 }
4482
4483 memset(&msg, 0, sizeof(struct host_if_msg));
4484
4485 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
4486 msg.body.remain_on_ch.u16Channel = chan;
4487 msg.body.remain_on_ch.pRemainOnChanExpired = RemainOnChanExpired;
4488 msg.body.remain_on_ch.pRemainOnChanReady = RemainOnChanReady;
4489 msg.body.remain_on_ch.pVoid = pvUserArg;
4490 msg.body.remain_on_ch.u32duration = u32duration;
4491 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
4492 msg.drv = hif_drv;
4493
4494 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4495 if (s32Error)
4496 PRINT_ER("wilc mq send fail\n");
4497
4498 return s32Error;
4499 }
4500
4501 s32 host_int_ListenStateExpired(struct host_if_drv *hif_drv, u32 u32SessionID)
4502 {
4503 s32 s32Error = 0;
4504 struct host_if_msg msg;
4505
4506 if (!hif_drv) {
4507 PRINT_ER("driver is null\n");
4508 return -EFAULT;
4509 }
4510
4511 del_timer(&hif_drv->hRemainOnChannel);
4512
4513 memset(&msg, 0, sizeof(struct host_if_msg));
4514 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
4515 msg.drv = hif_drv;
4516 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
4517
4518 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4519 if (s32Error)
4520 PRINT_ER("wilc mq send fail\n");
4521
4522 return s32Error;
4523 }
4524
4525 s32 host_int_frame_register(struct host_if_drv *hif_drv, u16 u16FrameType, bool bReg)
4526 {
4527 s32 s32Error = 0;
4528 struct host_if_msg msg;
4529
4530 if (!hif_drv) {
4531 PRINT_ER("driver is null\n");
4532 return -EFAULT;
4533 }
4534
4535 memset(&msg, 0, sizeof(struct host_if_msg));
4536
4537 msg.id = HOST_IF_MSG_REGISTER_FRAME;
4538 switch (u16FrameType) {
4539 case ACTION:
4540 PRINT_D(HOSTINF_DBG, "ACTION\n");
4541 msg.body.reg_frame.u8Regid = ACTION_FRM_IDX;
4542 break;
4543
4544 case PROBE_REQ:
4545 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
4546 msg.body.reg_frame.u8Regid = PROBE_REQ_IDX;
4547 break;
4548
4549 default:
4550 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
4551 break;
4552 }
4553 msg.body.reg_frame.u16FrameType = u16FrameType;
4554 msg.body.reg_frame.bReg = bReg;
4555 msg.drv = hif_drv;
4556
4557 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4558 if (s32Error)
4559 PRINT_ER("wilc mq send fail\n");
4560
4561 return s32Error;
4562
4563
4564 }
4565
4566 s32 host_int_add_beacon(struct host_if_drv *hif_drv, u32 u32Interval,
4567 u32 u32DTIMPeriod, u32 u32HeadLen, u8 *pu8Head,
4568 u32 u32TailLen, u8 *pu8Tail)
4569 {
4570 s32 s32Error = 0;
4571 struct host_if_msg msg;
4572 struct beacon_attr *pstrSetBeaconParam = &msg.body.beacon_info;
4573
4574 if (!hif_drv) {
4575 PRINT_ER("driver is null\n");
4576 return -EFAULT;
4577 }
4578
4579 memset(&msg, 0, sizeof(struct host_if_msg));
4580
4581 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
4582
4583 msg.id = HOST_IF_MSG_ADD_BEACON;
4584 msg.drv = hif_drv;
4585 pstrSetBeaconParam->interval = u32Interval;
4586 pstrSetBeaconParam->dtim_period = u32DTIMPeriod;
4587 pstrSetBeaconParam->head_len = u32HeadLen;
4588 pstrSetBeaconParam->head = kmalloc(u32HeadLen, GFP_KERNEL);
4589 if (pstrSetBeaconParam->head == NULL) {
4590 s32Error = -ENOMEM;
4591 goto ERRORHANDLER;
4592 }
4593 memcpy(pstrSetBeaconParam->head, pu8Head, u32HeadLen);
4594 pstrSetBeaconParam->tail_len = u32TailLen;
4595
4596 if (u32TailLen > 0) {
4597 pstrSetBeaconParam->tail = kmalloc(u32TailLen, GFP_KERNEL);
4598 if (pstrSetBeaconParam->tail == NULL) {
4599 s32Error = -ENOMEM;
4600 goto ERRORHANDLER;
4601 }
4602 memcpy(pstrSetBeaconParam->tail, pu8Tail, u32TailLen);
4603 } else {
4604 pstrSetBeaconParam->tail = NULL;
4605 }
4606
4607 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4608 if (s32Error)
4609 PRINT_ER("wilc mq send fail\n");
4610
4611 ERRORHANDLER:
4612 if (s32Error) {
4613 kfree(pstrSetBeaconParam->head);
4614
4615 kfree(pstrSetBeaconParam->tail);
4616 }
4617
4618 return s32Error;
4619
4620 }
4621
4622 s32 host_int_del_beacon(struct host_if_drv *hif_drv)
4623 {
4624 s32 s32Error = 0;
4625 struct host_if_msg msg;
4626
4627 if (!hif_drv) {
4628 PRINT_ER("driver is null\n");
4629 return -EFAULT;
4630 }
4631
4632 msg.id = HOST_IF_MSG_DEL_BEACON;
4633 msg.drv = hif_drv;
4634 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
4635
4636 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4637 if (s32Error)
4638 PRINT_ER("wilc_mq_send fail\n");
4639
4640 return s32Error;
4641 }
4642
4643 s32 host_int_add_station(struct host_if_drv *hif_drv,
4644 struct add_sta_param *pstrStaParams)
4645 {
4646 s32 s32Error = 0;
4647 struct host_if_msg msg;
4648 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
4649
4650
4651 if (!hif_drv) {
4652 PRINT_ER("driver is null\n");
4653 return -EFAULT;
4654 }
4655
4656 memset(&msg, 0, sizeof(struct host_if_msg));
4657
4658 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
4659
4660 msg.id = HOST_IF_MSG_ADD_STATION;
4661 msg.drv = hif_drv;
4662
4663 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
4664 if (pstrAddStationMsg->u8NumRates > 0) {
4665 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
4666
4667 if (!rates)
4668 return -ENOMEM;
4669
4670 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
4671 pstrAddStationMsg->pu8Rates = rates;
4672 }
4673
4674 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4675 if (s32Error)
4676 PRINT_ER("wilc_mq_send fail\n");
4677 return s32Error;
4678 }
4679
4680 s32 host_int_del_station(struct host_if_drv *hif_drv, const u8 *pu8MacAddr)
4681 {
4682 s32 s32Error = 0;
4683 struct host_if_msg msg;
4684 struct del_sta *pstrDelStationMsg = &msg.body.del_sta_info;
4685
4686 if (!hif_drv) {
4687 PRINT_ER("driver is null\n");
4688 return -EFAULT;
4689 }
4690
4691 memset(&msg, 0, sizeof(struct host_if_msg));
4692
4693 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
4694
4695 msg.id = HOST_IF_MSG_DEL_STATION;
4696 msg.drv = hif_drv;
4697
4698 if (pu8MacAddr == NULL)
4699 memset(pstrDelStationMsg->mac_addr, 255, ETH_ALEN);
4700 else
4701 memcpy(pstrDelStationMsg->mac_addr, pu8MacAddr, ETH_ALEN);
4702
4703 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4704 if (s32Error)
4705 PRINT_ER("wilc_mq_send fail\n");
4706 return s32Error;
4707 }
4708
4709 s32 host_int_del_allstation(struct host_if_drv *hif_drv,
4710 u8 pu8MacAddr[][ETH_ALEN])
4711 {
4712 s32 s32Error = 0;
4713 struct host_if_msg msg;
4714 struct del_all_sta *pstrDelAllStationMsg = &msg.body.del_all_sta_info;
4715 u8 au8Zero_Buff[ETH_ALEN] = {0};
4716 u32 i;
4717 u8 u8AssocNumb = 0;
4718
4719
4720 if (!hif_drv) {
4721 PRINT_ER("driver is null\n");
4722 return -EFAULT;
4723 }
4724
4725 memset(&msg, 0, sizeof(struct host_if_msg));
4726
4727 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
4728
4729 msg.id = HOST_IF_MSG_DEL_ALL_STA;
4730 msg.drv = hif_drv;
4731
4732 for (i = 0; i < MAX_NUM_STA; i++) {
4733 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
4734 memcpy(pstrDelAllStationMsg->del_all_sta[i], pu8MacAddr[i], ETH_ALEN);
4735 PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n",
4736 pstrDelAllStationMsg->del_all_sta[i][0],
4737 pstrDelAllStationMsg->del_all_sta[i][1],
4738 pstrDelAllStationMsg->del_all_sta[i][2],
4739 pstrDelAllStationMsg->del_all_sta[i][3],
4740 pstrDelAllStationMsg->del_all_sta[i][4],
4741 pstrDelAllStationMsg->del_all_sta[i][5]);
4742 u8AssocNumb++;
4743 }
4744 }
4745 if (!u8AssocNumb) {
4746 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
4747 return s32Error;
4748 }
4749
4750 pstrDelAllStationMsg->assoc_sta = u8AssocNumb;
4751 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4752
4753 if (s32Error)
4754 PRINT_ER("wilc_mq_send fail\n");
4755
4756 down(&hif_sema_wait_response);
4757
4758 return s32Error;
4759
4760 }
4761
4762 s32 host_int_edit_station(struct host_if_drv *hif_drv,
4763 struct add_sta_param *pstrStaParams)
4764 {
4765 s32 s32Error = 0;
4766 struct host_if_msg msg;
4767 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
4768
4769 if (!hif_drv) {
4770 PRINT_ER("driver is null\n");
4771 return -EFAULT;
4772 }
4773
4774 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
4775
4776 memset(&msg, 0, sizeof(struct host_if_msg));
4777
4778 msg.id = HOST_IF_MSG_EDIT_STATION;
4779 msg.drv = hif_drv;
4780
4781 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
4782 if (pstrAddStationMsg->u8NumRates > 0) {
4783 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
4784
4785 if (!rates)
4786 return -ENOMEM;
4787
4788 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
4789 pstrAddStationMsg->pu8Rates = rates;
4790 }
4791
4792 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4793 if (s32Error)
4794 PRINT_ER("wilc_mq_send fail\n");
4795
4796 return s32Error;
4797 }
4798
4799 s32 host_int_set_power_mgmt(struct host_if_drv *hif_drv,
4800 bool bIsEnabled,
4801 u32 u32Timeout)
4802 {
4803 s32 s32Error = 0;
4804 struct host_if_msg msg;
4805 struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.pwr_mgmt_info;
4806
4807 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
4808
4809 if (!hif_drv) {
4810 PRINT_ER("driver is null\n");
4811 return -EFAULT;
4812 }
4813
4814 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
4815
4816 memset(&msg, 0, sizeof(struct host_if_msg));
4817
4818 msg.id = HOST_IF_MSG_POWER_MGMT;
4819 msg.drv = hif_drv;
4820
4821 pstrPowerMgmtParam->enabled = bIsEnabled;
4822 pstrPowerMgmtParam->timeout = u32Timeout;
4823
4824 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4825 if (s32Error)
4826 PRINT_ER("wilc_mq_send fail\n");
4827 return s32Error;
4828 }
4829
4830 s32 host_int_setup_multicast_filter(struct host_if_drv *hif_drv,
4831 bool bIsEnabled,
4832 u32 u32count)
4833 {
4834 s32 s32Error = 0;
4835 struct host_if_msg msg;
4836 struct set_multicast *pstrMulticastFilterParam = &msg.body.multicast_info;
4837
4838
4839 if (!hif_drv) {
4840 PRINT_ER("driver is null\n");
4841 return -EFAULT;
4842 }
4843
4844 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
4845
4846 memset(&msg, 0, sizeof(struct host_if_msg));
4847
4848 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
4849 msg.drv = hif_drv;
4850
4851 pstrMulticastFilterParam->enabled = bIsEnabled;
4852 pstrMulticastFilterParam->cnt = u32count;
4853
4854 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4855 if (s32Error)
4856 PRINT_ER("wilc_mq_send fail\n");
4857 return s32Error;
4858 }
4859
4860 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
4861 {
4862 struct join_bss_param *pNewJoinBssParam = NULL;
4863 u8 *pu8IEs;
4864 u16 u16IEsLen;
4865 u16 index = 0;
4866 u8 suppRatesNo = 0;
4867 u8 extSuppRatesNo;
4868 u16 jumpOffset;
4869 u8 pcipherCount;
4870 u8 authCount;
4871 u8 pcipherTotalCount = 0;
4872 u8 authTotalCount = 0;
4873 u8 i, j;
4874
4875 pu8IEs = ptstrNetworkInfo->pu8IEs;
4876 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
4877
4878 pNewJoinBssParam = kzalloc(sizeof(struct join_bss_param), GFP_KERNEL);
4879 if (pNewJoinBssParam != NULL) {
4880 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
4881 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
4882 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
4883 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
4884 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
4885 pNewJoinBssParam->ssid_len = ptstrNetworkInfo->u8SsidLen;
4886 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
4887 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
4888
4889 while (index < u16IEsLen) {
4890 if (pu8IEs[index] == SUPP_RATES_IE) {
4891 suppRatesNo = pu8IEs[index + 1];
4892 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
4893 index += 2;
4894
4895 for (i = 0; i < suppRatesNo; i++) {
4896 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
4897 }
4898 index += suppRatesNo;
4899 continue;
4900 } else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
4901 extSuppRatesNo = pu8IEs[index + 1];
4902 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
4903 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
4904 else
4905 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
4906 index += 2;
4907 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
4908 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
4909 }
4910 index += extSuppRatesNo;
4911 continue;
4912 } else if (pu8IEs[index] == HT_CAPABILITY_IE) {
4913 pNewJoinBssParam->ht_capable = true;
4914 index += pu8IEs[index + 1] + 2;
4915 continue;
4916 } else if ((pu8IEs[index] == WMM_IE) &&
4917 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
4918 (pu8IEs[index + 4] == 0xF2) &&
4919 (pu8IEs[index + 5] == 0x02) &&
4920 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) &&
4921 (pu8IEs[index + 7] == 0x01)) {
4922 pNewJoinBssParam->wmm_cap = true;
4923
4924 if (pu8IEs[index + 8] & BIT(7))
4925 pNewJoinBssParam->uapsd_cap = true;
4926 index += pu8IEs[index + 1] + 2;
4927 continue;
4928 } else if ((pu8IEs[index] == P2P_IE) &&
4929 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
4930 (pu8IEs[index + 4] == 0x9a) &&
4931 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) {
4932 u16 u16P2P_count;
4933
4934 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
4935 pNewJoinBssParam->noa_enabled = 1;
4936 pNewJoinBssParam->idx = pu8IEs[index + 9];
4937
4938 if (pu8IEs[index + 10] & BIT(7)) {
4939 pNewJoinBssParam->opp_enabled = 1;
4940 pNewJoinBssParam->ct_window = pu8IEs[index + 10];
4941 } else {
4942 pNewJoinBssParam->opp_enabled = 0;
4943 }
4944
4945 PRINT_D(GENERIC_DBG, "P2P Dump\n");
4946 for (i = 0; i < pu8IEs[index + 7]; i++)
4947 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
4948
4949 pNewJoinBssParam->cnt = pu8IEs[index + 11];
4950 u16P2P_count = index + 12;
4951
4952 memcpy(pNewJoinBssParam->duration, pu8IEs + u16P2P_count, 4);
4953 u16P2P_count += 4;
4954
4955 memcpy(pNewJoinBssParam->interval, pu8IEs + u16P2P_count, 4);
4956 u16P2P_count += 4;
4957
4958 memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
4959
4960 index += pu8IEs[index + 1] + 2;
4961 continue;
4962
4963 } else if ((pu8IEs[index] == RSN_IE) ||
4964 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
4965 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
4966 (pu8IEs[index + 5] == 0x01))) {
4967 u16 rsnIndex = index;
4968
4969 if (pu8IEs[rsnIndex] == RSN_IE) {
4970 pNewJoinBssParam->mode_802_11i = 2;
4971 } else {
4972 if (pNewJoinBssParam->mode_802_11i == 0)
4973 pNewJoinBssParam->mode_802_11i = 1;
4974 rsnIndex += 4;
4975 }
4976
4977 rsnIndex += 7;
4978 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
4979 rsnIndex++;
4980 jumpOffset = pu8IEs[rsnIndex] * 4;
4981 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
4982 rsnIndex += 2;
4983
4984 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
4985 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
4986 }
4987 pcipherTotalCount += pcipherCount;
4988 rsnIndex += jumpOffset;
4989
4990 jumpOffset = pu8IEs[rsnIndex] * 4;
4991
4992 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
4993 rsnIndex += 2;
4994
4995 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
4996 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
4997 }
4998 authTotalCount += authCount;
4999 rsnIndex += jumpOffset;
5000
5001 if (pu8IEs[index] == RSN_IE) {
5002 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
5003 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
5004 rsnIndex += 2;
5005 }
5006 pNewJoinBssParam->rsn_found = true;
5007 index += pu8IEs[index + 1] + 2;
5008 continue;
5009 } else
5010 index += pu8IEs[index + 1] + 2;
5011
5012 }
5013
5014
5015 }
5016
5017 return (void *)pNewJoinBssParam;
5018
5019 }
5020
5021 void host_int_freeJoinParams(void *pJoinParams)
5022 {
5023 if ((struct bss_param *)pJoinParams != NULL)
5024 kfree((struct bss_param *)pJoinParams);
5025 else
5026 PRINT_ER("Unable to FREE null pointer\n");
5027 }
5028
5029 s32 host_int_delBASession(struct host_if_drv *hif_drv, char *pBSSID, char TID)
5030 {
5031 s32 s32Error = 0;
5032 struct host_if_msg msg;
5033 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
5034
5035 if (!hif_drv) {
5036 PRINT_ER("driver is null\n");
5037 return -EFAULT;
5038 }
5039
5040 memset(&msg, 0, sizeof(struct host_if_msg));
5041
5042 msg.id = HOST_IF_MSG_DEL_BA_SESSION;
5043
5044 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
5045 pBASessionInfo->u8Ted = TID;
5046 msg.drv = hif_drv;
5047
5048 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
5049 if (s32Error)
5050 PRINT_ER("wilc_mq_send fail\n");
5051
5052 down(&hif_sema_wait_response);
5053
5054 return s32Error;
5055 }
5056
5057 s32 host_int_del_All_Rx_BASession(struct host_if_drv *hif_drv,
5058 char *pBSSID,
5059 char TID)
5060 {
5061 s32 s32Error = 0;
5062 struct host_if_msg msg;
5063 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
5064
5065 if (!hif_drv) {
5066 PRINT_ER("driver is null\n");
5067 return -EFAULT;
5068 }
5069
5070 memset(&msg, 0, sizeof(struct host_if_msg));
5071
5072 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
5073
5074 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
5075 pBASessionInfo->u8Ted = TID;
5076 msg.drv = hif_drv;
5077
5078 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
5079 if (s32Error)
5080 PRINT_ER("wilc_mq_send fail\n");
5081
5082 down(&hif_sema_wait_response);
5083
5084 return s32Error;
5085 }
5086
5087 s32 host_int_setup_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
5088 {
5089 s32 s32Error = 0;
5090 struct host_if_msg msg;
5091
5092 return 0;
5093
5094 if (!hif_drv) {
5095 PRINT_ER("driver is null\n");
5096 return -EFAULT;
5097 }
5098
5099 memset(&msg, 0, sizeof(struct host_if_msg));
5100
5101 msg.id = HOST_IF_MSG_SET_IPADDRESS;
5102
5103 msg.body.ip_info.ip_addr = u16ipadd;
5104 msg.drv = hif_drv;
5105 msg.body.ip_info.idx = idx;
5106
5107 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
5108 if (s32Error)
5109 PRINT_ER("wilc_mq_send fail\n");
5110
5111 return s32Error;
5112
5113
5114 }
5115
5116 s32 host_int_get_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
5117 {
5118 s32 s32Error = 0;
5119 struct host_if_msg msg;
5120
5121 if (!hif_drv) {
5122 PRINT_ER("driver is null\n");
5123 return -EFAULT;
5124 }
5125
5126 memset(&msg, 0, sizeof(struct host_if_msg));
5127
5128 msg.id = HOST_IF_MSG_GET_IPADDRESS;
5129
5130 msg.body.ip_info.ip_addr = u16ipadd;
5131 msg.drv = hif_drv;
5132 msg.body.ip_info.idx = idx;
5133
5134 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
5135 if (s32Error)
5136 PRINT_ER("wilc_mq_send fail\n");
5137
5138 return s32Error;
5139
5140
5141 }
This page took 0.241372 seconds and 5 git commands to generate.