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