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