staging: wilc1000: renames u16CapInfo of connect_resp_info structure
[deliverable/linux.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"
491880eb 7#include "wilc_wlan.h"
5366012d 8#include "wilc_wlan_if.h"
f23eb98b 9#include "wilc_msgqueue.h"
281dd5ac 10#include <linux/etherdevice.h>
d5382219 11#include "wilc_wfi_netdevice.h"
c5c77ba1 12
9eac3a15
CL
13#define HOST_IF_MSG_SCAN 0
14#define HOST_IF_MSG_CONNECT 1
15#define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
16#define HOST_IF_MSG_KEY 3
17#define HOST_IF_MSG_RCVD_NTWRK_INFO 4
18#define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
19#define HOST_IF_MSG_CFG_PARAMS 6
20#define HOST_IF_MSG_SET_CHANNEL 7
21#define HOST_IF_MSG_DISCONNECT 8
22#define HOST_IF_MSG_GET_RSSI 9
23#define HOST_IF_MSG_GET_CHNL 10
24#define HOST_IF_MSG_ADD_BEACON 11
25#define HOST_IF_MSG_DEL_BEACON 12
26#define HOST_IF_MSG_ADD_STATION 13
27#define HOST_IF_MSG_DEL_STATION 14
28#define HOST_IF_MSG_EDIT_STATION 15
29#define HOST_IF_MSG_SCAN_TIMER_FIRED 16
30#define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
31#define HOST_IF_MSG_POWER_MGMT 18
32#define HOST_IF_MSG_GET_INACTIVETIME 19
33#define HOST_IF_MSG_REMAIN_ON_CHAN 20
34#define HOST_IF_MSG_REGISTER_FRAME 21
35#define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
36#define HOST_IF_MSG_GET_LINKSPEED 23
37#define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
38#define HOST_IF_MSG_SET_MAC_ADDRESS 25
39#define HOST_IF_MSG_GET_MAC_ADDRESS 26
40#define HOST_IF_MSG_SET_OPERATION_MODE 27
41#define HOST_IF_MSG_SET_IPADDRESS 28
42#define HOST_IF_MSG_GET_IPADDRESS 29
43#define HOST_IF_MSG_FLUSH_CONNECT 30
44#define HOST_IF_MSG_GET_STATISTICS 31
45#define HOST_IF_MSG_SET_MULTICAST_FILTER 32
9eac3a15
CL
46#define HOST_IF_MSG_DEL_BA_SESSION 34
47#define HOST_IF_MSG_Q_IDLE 35
48#define HOST_IF_MSG_DEL_ALL_STA 36
70418790
GL
49#define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 37
50#define HOST_IF_MSG_SET_TX_POWER 38
51#define HOST_IF_MSG_GET_TX_POWER 39
9eac3a15 52#define HOST_IF_MSG_EXIT 100
d85f5326 53
e54d5b75
CL
54#define HOST_IF_SCAN_TIMEOUT 4000
55#define HOST_IF_CONNECT_TIMEOUT 9500
c5c77ba1 56
e54d5b75
CL
57#define BA_SESSION_DEFAULT_BUFFER_SIZE 16
58#define BA_SESSION_DEFAULT_TIMEOUT 1000
59#define BLOCK_ACK_REQ_SIZE 0x14
9f3295a2 60#define FALSE_FRMWR_CHANNEL 100
c5c77ba1 61
4fd62291
GL
62#define TCP_ACK_FILTER_LINK_SPEED_THRESH 54
63#define DEFAULT_LINK_SPEED 72
64
361ff841 65struct cfg_param_attr {
221371e5 66 struct cfg_param_val cfg_attr_info;
361ff841 67};
c5c77ba1 68
4372d3d3 69struct host_if_wpa_attr {
124968fc 70 u8 *key;
248080aa 71 const u8 *mac_addr;
0e74c009 72 u8 *seq;
dacc594d 73 u8 seq_len;
e2dfbac5 74 u8 index;
6acf2919 75 u8 key_len;
7b2ebb28 76 u8 mode;
4372d3d3 77};
c5c77ba1 78
c276c44a 79struct host_if_wep_attr {
e5538d34 80 u8 *key;
d520e355 81 u8 key_len;
259b3aa6 82 u8 index;
b5eaff12 83 u8 mode;
7fa252e7 84 enum AUTHTYPE auth_type;
c276c44a 85};
c5c77ba1 86
40cc2c90 87union host_if_key_attr {
2ed7a2fb 88 struct host_if_wep_attr wep;
e3501a4d 89 struct host_if_wpa_attr wpa;
610e3868 90 struct host_if_pmkid_attr pmkid;
40cc2c90 91};
c5c77ba1 92
c98387a5 93struct key_attr {
8e9f427a 94 enum KEY_TYPE type;
0d17e382 95 u8 action;
73b2e381 96 union host_if_key_attr attr;
c98387a5 97};
c5c77ba1 98
c476feb8 99struct scan_attr {
42568898 100 u8 src;
1e276c88 101 u8 type;
82eeb0ad 102 u8 *ch_freq_list;
f97bd9ca 103 u8 ch_list_len;
d6f19aa5 104 u8 *ies;
7b1f76cd 105 size_t ies_len;
c17c6da6 106 wilc_scan_result result;
5f2b50c8 107 void *arg;
629b9ca0 108 struct hidden_network hidden_network;
c476feb8 109};
c5c77ba1 110
120ae593 111struct connect_attr {
9254db07 112 u8 *bssid;
f7bbd9cf 113 u8 *ssid;
8b3c9fa6 114 size_t ssid_len;
2ea158c4 115 u8 *ies;
b59d5c5b 116 size_t ies_len;
a64fd677 117 u8 security;
6abcc11d 118 wilc_connect_result result;
8f38db89 119 void *arg;
61b4fd02 120 enum AUTHTYPE auth_type;
0d1527e6 121 u8 ch;
f2bed2ca 122 void *params;
120ae593 123};
c5c77ba1 124
f23a9eab 125struct rcvd_async_info {
33722ac7 126 u8 *buffer;
f94f4889 127 u32 len;
f23a9eab 128};
c5c77ba1 129
94bdfe42 130struct channel_attr {
730ee059 131 u8 set_ch;
326b323d 132};
c5c77ba1 133
7f33fecd 134struct beacon_attr {
12262dda 135 u32 interval;
e76ab770 136 u32 dtim_period;
51c66185 137 u32 head_len;
8ce528b9 138 u8 *head;
030c57e2 139 u32 tail_len;
7dbcb6d3 140 u8 *tail;
902362b1 141};
c5c77ba1 142
641210ac 143struct set_multicast {
bae636eb 144 bool enabled;
adab2f71 145 u32 cnt;
641210ac 146};
c5c77ba1 147
b4e644e4 148struct del_all_sta {
e51b9216 149 u8 del_all_sta[MAX_NUM_STA][ETH_ALEN];
8ba1803f 150 u8 assoc_sta;
b4e644e4 151};
c5c77ba1 152
fb93a1e1 153struct del_sta {
e4839d39 154 u8 mac_addr[ETH_ALEN];
fb93a1e1 155};
c5c77ba1 156
5a008f1c 157struct power_mgmt_param {
33c70c1b 158 bool enabled;
937918ff 159 u32 timeout;
5a008f1c 160};
c5c77ba1 161
15191eaf 162struct set_ip_addr {
78675be5 163 u8 *ip_addr;
63d03e47 164 u8 idx;
15191eaf 165};
c5c77ba1 166
3d1eac04 167struct sta_inactive_t {
63d03e47 168 u8 mac[6];
3d1eac04 169};
ae4dfa57 170
70418790
GL
171struct tx_power {
172 u8 tx_pwr;
173};
174
dfc7663b 175union message_body {
4528bdb5 176 struct scan_attr scan_info;
3f501971 177 struct connect_attr con_info;
02d19460 178 struct rcvd_net_info net_info;
66add622 179 struct rcvd_async_info async_info;
18990bfe 180 struct key_attr key_info;
a2340c36 181 struct cfg_param_attr cfg_info;
ffd6dbc8 182 struct channel_attr channel_info;
a98491e5 183 struct beacon_attr beacon_info;
ca8f47f8 184 struct add_sta_param add_sta_info;
889c25be 185 struct del_sta del_sta_info;
4a930962 186 struct add_sta_param edit_sta_info;
49e1f81b 187 struct power_mgmt_param pwr_mgmt_info;
66bac7f2 188 struct sta_inactive_t mac_info;
fb2d65ed 189 struct set_ip_addr ip_info;
5e4377e6 190 struct drv_handler drv;
a079cf4d 191 struct set_multicast multicast_info;
00c4630e 192 struct op_mode mode;
15326e28 193 struct set_mac_addr set_mac_info;
a5848695 194 struct get_mac_addr get_mac_info;
c833b474 195 struct ba_session_info session_info;
070d365c 196 struct remain_ch remain_on_ch;
5c4008db 197 struct reg_frame reg_frame;
e60831e9 198 char *data;
b0c1e80e 199 struct del_all_sta del_all_sta_info;
70418790 200 struct tx_power tx_power;
dfc7663b 201};
c5c77ba1 202
3a8c41b5 203struct host_if_msg {
ae4dfa57
LK
204 u16 id;
205 union message_body body;
cf60106b 206 struct wilc_vif *vif;
3a8c41b5 207};
c5c77ba1 208
e0a12217 209struct join_bss_param {
c5c77ba1 210 BSSTYPE_T bss_type;
63d03e47 211 u8 dtim_period;
d85f5326
CL
212 u16 beacon_period;
213 u16 cap_info;
63d03e47 214 u8 au8bssid[6];
576917ad 215 char ssid[MAX_SSID_LEN];
619d27b8 216 u8 ssid_len;
63d03e47
GKH
217 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
218 u8 ht_capable;
219 u8 wmm_cap;
220 u8 uapsd_cap;
72ed4dc7 221 bool rsn_found;
63d03e47
GKH
222 u8 rsn_grp_policy;
223 u8 mode_802_11i;
224 u8 rsn_pcip_policy[3];
225 u8 rsn_auth_policy[3];
226 u8 rsn_cap[2];
4e4467fd 227 u32 tsf;
7a8d51d7 228 u8 noa_enabled;
d72b33ca 229 u8 opp_enabled;
99b66945 230 u8 ct_window;
c21047ed 231 u8 cnt;
cc179008 232 u8 idx;
109e6cab 233 u8 duration[4];
1d8b76b3 234 u8 interval[4];
4be55e22 235 u8 start_time[4];
e0a12217 236};
c5c77ba1 237
d27afda3 238static struct host_if_drv *terminated_handle;
0e1af73d 239bool wilc_optaining_ip;
1608c403 240static u8 P2P_LISTEN_STATE;
c2115d8e 241static struct task_struct *hif_thread_handler;
5ba89554 242static struct message_queue hif_msg_q;
834e0cb0 243static struct semaphore hif_sema_thread;
413f930e 244static struct semaphore hif_sema_driver;
2d25af87 245static struct semaphore hif_sema_wait_response;
17225002 246static struct semaphore hif_sema_deinit;
24aadb8b 247static struct timer_list periodic_rssi;
c5c77ba1 248
0e1af73d 249u8 wilc_multicast_mac_addr_list[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
c5c77ba1 250
a633c0b5 251static u8 rcv_assoc_resp[MAX_ASSOC_RESP_FRAME_SIZE];
c5c77ba1 252
f64321c6 253static bool scan_while_connected;
c5c77ba1 254
144b7b23 255static s8 rssi;
75327a02 256static s8 link_speed;
95ebb0ff 257static u8 ch_no;
078b1e98 258static u8 set_ip[2][4];
1e75d01c 259static u8 get_ip[2][4];
ad26906f 260static u32 inactive_time;
a74c7bf8 261static u8 del_beacon;
7178aed8 262static u32 clients_count;
c5c77ba1 263
ef599194 264static u8 *join_req;
1608c403 265static u8 *info_element;
23047d5b 266static u8 mode_11i;
1608c403
AB
267static u8 auth_type;
268static u32 join_req_size;
5e0e7c2e 269static u32 info_element_size;
7036c624 270static struct wilc_vif *join_req_vif;
c5c77ba1
JK
271#define REAL_JOIN_REQ 0
272#define FLUSHED_JOIN_REQ 1
ae4dfa57 273#define FLUSHED_BYTE_POS 79
c5c77ba1 274
6b5180a0 275static void *host_int_ParseJoinBssParam(struct network_info *ptstrNetworkInfo);
4ad878be 276static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx);
c5c77ba1 277
eb9939b7
GL
278/* The u8IfIdx starts from 0 to NUM_CONCURRENT_IFC -1, but 0 index used as
279 * special purpose in wilc device, so we add 1 to the index to starts from 1.
280 * As a result, the returned index will be 1 to NUM_CONCURRENT_IFC.
281 */
31f0f697 282int wilc_get_vif_idx(struct wilc_vif *vif)
d42ab083 283{
6750140d 284 return vif->idx + 1;
eb9939b7
GL
285}
286
287/* We need to minus 1 from idx which is from wilc device to get real index
288 * of wilc->vif[], because we add 1 when pass to wilc device in the function
289 * wilc_get_vif_idx.
290 * As a result, the index should be between 0 and NUM_CONCURRENT_IFC -1.
291 */
292static struct wilc_vif *wilc_get_vif_from_idx(struct wilc *wilc, int idx)
293{
294 int index = idx - 1;
295
296 if (index < 0 || index >= NUM_CONCURRENT_IFC)
d42ab083 297 return NULL;
eb9939b7
GL
298
299 return wilc->vif[index];
d42ab083
JK
300}
301
71130e81 302static s32 handle_set_channel(struct wilc_vif *vif,
9cf7878c 303 struct channel_attr *hif_set_ch)
c5c77ba1 304{
31390eec 305 s32 result = 0;
45102f83 306 struct wid wid;
c5c77ba1 307
45102f83
LK
308 wid.id = (u16)WID_CURRENT_CHANNEL;
309 wid.type = WID_CHAR;
9cf7878c 310 wid.val = (char *)&hif_set_ch->set_ch;
45102f83 311 wid.size = sizeof(char);
c5c77ba1 312
79df6a49 313 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
4cf93d70 314 wilc_get_vif_idx(vif));
31390eec
LK
315
316 if (result) {
c5c77ba1 317 PRINT_ER("Failed to set channel\n");
24db713f 318 return -EINVAL;
c5c77ba1
JK
319 }
320
31390eec 321 return result;
c5c77ba1 322}
ae4dfa57 323
71130e81 324static s32 handle_set_wfi_drv_handler(struct wilc_vif *vif,
23f2badd 325 struct drv_handler *hif_drv_handler)
c5c77ba1 326{
31390eec 327 s32 result = 0;
45102f83 328 struct wid wid;
c5c77ba1 329
45102f83 330 wid.id = (u16)WID_SET_DRV_HANDLER;
b3306865
GL
331 wid.type = WID_STR;
332 wid.val = (s8 *)hif_drv_handler;
333 wid.size = sizeof(*hif_drv_handler);
c5c77ba1 334
79df6a49 335 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
ec62e6d1 336 hif_drv_handler->handler);
c5c77ba1 337
31f0f697 338 if (!hif_drv_handler->handler)
27ff2168 339 up(&hif_sema_driver);
c5c77ba1 340
31390eec 341 if (result) {
c5c77ba1 342 PRINT_ER("Failed to set driver handler\n");
24db713f 343 return -EINVAL;
c5c77ba1
JK
344 }
345
31390eec 346 return result;
c5c77ba1
JK
347}
348
71130e81 349static s32 handle_set_operation_mode(struct wilc_vif *vif,
97b5c591 350 struct op_mode *hif_op_mode)
c5c77ba1 351{
31390eec 352 s32 result = 0;
45102f83 353 struct wid wid;
c5c77ba1 354
45102f83
LK
355 wid.id = (u16)WID_SET_OPERATION_MODE;
356 wid.type = WID_INT;
acff1d71 357 wid.val = (s8 *)&hif_op_mode->mode;
45102f83 358 wid.size = sizeof(u32);
c5c77ba1 359
79df6a49 360 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
4cf93d70 361 wilc_get_vif_idx(vif));
c5c77ba1 362
acff1d71 363 if ((hif_op_mode->mode) == IDLE_MODE)
27ff2168 364 up(&hif_sema_driver);
c5c77ba1 365
31390eec 366 if (result) {
c5c77ba1 367 PRINT_ER("Failed to set driver handler\n");
24db713f 368 return -EINVAL;
c5c77ba1
JK
369 }
370
31390eec 371 return result;
c5c77ba1
JK
372}
373
71130e81 374static s32 handle_set_ip_address(struct wilc_vif *vif, u8 *ip_addr, u8 idx)
c5c77ba1 375{
31390eec 376 s32 result = 0;
45102f83 377 struct wid wid;
ebc57d19 378 char firmware_ip_addr[4] = {0};
c5c77ba1 379
a6527c3b
LK
380 if (ip_addr[0] < 192)
381 ip_addr[0] = 0;
c5c77ba1 382
a6527c3b 383 memcpy(set_ip[idx], ip_addr, IP_ALEN);
c5c77ba1 384
45102f83
LK
385 wid.id = (u16)WID_IP_ADDRESS;
386 wid.type = WID_STR;
a6527c3b 387 wid.val = (u8 *)ip_addr;
45102f83 388 wid.size = IP_ALEN;
c5c77ba1 389
79df6a49 390 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
4cf93d70 391 wilc_get_vif_idx(vif));
c5c77ba1 392
f8813d3a 393 host_int_get_ipaddress(vif, firmware_ip_addr, idx);
c5c77ba1 394
31390eec 395 if (result) {
24db713f
LK
396 PRINT_ER("Failed to set IP address\n");
397 return -EINVAL;
c5c77ba1
JK
398 }
399
31390eec 400 return result;
c5c77ba1
JK
401}
402
71130e81 403static s32 handle_get_ip_address(struct wilc_vif *vif, u8 idx)
c5c77ba1 404{
31390eec 405 s32 result = 0;
45102f83 406 struct wid wid;
c5c77ba1 407
45102f83
LK
408 wid.id = (u16)WID_IP_ADDRESS;
409 wid.type = WID_STR;
410 wid.val = kmalloc(IP_ALEN, GFP_KERNEL);
411 wid.size = IP_ALEN;
c5c77ba1 412
79df6a49 413 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
4cf93d70 414 wilc_get_vif_idx(vif));
c5c77ba1 415
45102f83 416 memcpy(get_ip[idx], wid.val, IP_ALEN);
c5c77ba1 417
45102f83 418 kfree(wid.val);
c5c77ba1 419
1e75d01c 420 if (memcmp(get_ip[idx], set_ip[idx], IP_ALEN) != 0)
fbf5379b 421 wilc_setup_ipaddress(vif, set_ip[idx], idx);
c5c77ba1 422
31390eec 423 if (result != 0) {
c5c77ba1 424 PRINT_ER("Failed to get IP address\n");
24db713f 425 return -EINVAL;
c5c77ba1
JK
426 }
427
31390eec 428 return result;
c5c77ba1
JK
429}
430
71130e81 431static s32 handle_set_mac_address(struct wilc_vif *vif,
a8267421 432 struct set_mac_addr *set_mac_addr)
c5c77ba1 433{
31390eec 434 s32 result = 0;
45102f83 435 struct wid wid;
f3052587 436 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
c09389ac 437
91109e11 438 if (!mac_buf) {
c5c77ba1 439 PRINT_ER("No buffer to send mac address\n");
e6e12661 440 return -EFAULT;
c5c77ba1 441 }
090dbb10 442 memcpy(mac_buf, set_mac_addr->mac_addr, ETH_ALEN);
c5c77ba1 443
45102f83
LK
444 wid.id = (u16)WID_MAC_ADDR;
445 wid.type = WID_STR;
446 wid.val = mac_buf;
447 wid.size = ETH_ALEN;
448 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", wid.val);
ae4dfa57 449
79df6a49 450 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
4cf93d70 451 wilc_get_vif_idx(vif));
31390eec 452 if (result) {
c5c77ba1 453 PRINT_ER("Failed to set mac address\n");
31390eec 454 result = -EFAULT;
c5c77ba1
JK
455 }
456
49188af2 457 kfree(mac_buf);
31390eec 458 return result;
c5c77ba1
JK
459}
460
71130e81 461static s32 handle_get_mac_address(struct wilc_vif *vif,
b3bf8fd9 462 struct get_mac_addr *get_mac_addr)
c5c77ba1 463{
31390eec 464 s32 result = 0;
45102f83 465 struct wid wid;
c5c77ba1 466
45102f83
LK
467 wid.id = (u16)WID_MAC_ADDR;
468 wid.type = WID_STR;
7f0ee9a6 469 wid.val = get_mac_addr->mac_addr;
45102f83 470 wid.size = ETH_ALEN;
c5c77ba1 471
79df6a49 472 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
4cf93d70 473 wilc_get_vif_idx(vif));
31390eec
LK
474
475 if (result) {
c5c77ba1 476 PRINT_ER("Failed to get mac address\n");
31390eec 477 result = -EFAULT;
c5c77ba1 478 }
2d25af87 479 up(&hif_sema_wait_response);
c5c77ba1 480
31390eec 481 return result;
c5c77ba1
JK
482}
483
71130e81 484static s32 handle_cfg_param(struct wilc_vif *vif,
dc276664 485 struct cfg_param_attr *cfg_param_attr)
c5c77ba1 486{
31390eec 487 s32 result = 0;
13ca52ad 488 struct wid wid_list[32];
71130e81 489 struct host_if_drv *hif_drv = vif->hif_drv;
540c3e88 490 u8 wid_cnt = 0;
c5c77ba1 491
33110ad7 492 down(&hif_drv->sem_cfg_values);
c5c77ba1 493
02ae2bdf
LK
494 if (cfg_param_attr->cfg_attr_info.flag & BSS_TYPE) {
495 if (cfg_param_attr->cfg_attr_info.bss_type < 6) {
540c3e88
LK
496 wid_list[wid_cnt].id = WID_BSS_TYPE;
497 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.bss_type;
498 wid_list[wid_cnt].type = WID_CHAR;
499 wid_list[wid_cnt].size = sizeof(char);
02ae2bdf 500 hif_drv->cfg_values.bss_type = (u8)cfg_param_attr->cfg_attr_info.bss_type;
c5c77ba1 501 } else {
24db713f 502 PRINT_ER("check value 6 over\n");
31390eec 503 result = -EINVAL;
24db713f 504 goto ERRORHANDLER;
c5c77ba1 505 }
540c3e88 506 wid_cnt++;
c5c77ba1 507 }
02ae2bdf
LK
508 if (cfg_param_attr->cfg_attr_info.flag & AUTH_TYPE) {
509 if (cfg_param_attr->cfg_attr_info.auth_type == 1 ||
510 cfg_param_attr->cfg_attr_info.auth_type == 2 ||
511 cfg_param_attr->cfg_attr_info.auth_type == 5) {
540c3e88
LK
512 wid_list[wid_cnt].id = WID_AUTH_TYPE;
513 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.auth_type;
514 wid_list[wid_cnt].type = WID_CHAR;
515 wid_list[wid_cnt].size = sizeof(char);
02ae2bdf 516 hif_drv->cfg_values.auth_type = (u8)cfg_param_attr->cfg_attr_info.auth_type;
c5c77ba1 517 } else {
24db713f 518 PRINT_ER("Impossible value \n");
31390eec 519 result = -EINVAL;
24db713f 520 goto ERRORHANDLER;
c5c77ba1 521 }
540c3e88 522 wid_cnt++;
c5c77ba1 523 }
02ae2bdf
LK
524 if (cfg_param_attr->cfg_attr_info.flag & AUTHEN_TIMEOUT) {
525 if (cfg_param_attr->cfg_attr_info.auth_timeout > 0 &&
526 cfg_param_attr->cfg_attr_info.auth_timeout < 65536) {
540c3e88
LK
527 wid_list[wid_cnt].id = WID_AUTH_TIMEOUT;
528 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.auth_timeout;
529 wid_list[wid_cnt].type = WID_SHORT;
530 wid_list[wid_cnt].size = sizeof(u16);
02ae2bdf 531 hif_drv->cfg_values.auth_timeout = cfg_param_attr->cfg_attr_info.auth_timeout;
c5c77ba1 532 } else {
24db713f 533 PRINT_ER("Range(1 ~ 65535) over\n");
31390eec 534 result = -EINVAL;
24db713f 535 goto ERRORHANDLER;
c5c77ba1 536 }
540c3e88 537 wid_cnt++;
c5c77ba1 538 }
02ae2bdf
LK
539 if (cfg_param_attr->cfg_attr_info.flag & POWER_MANAGEMENT) {
540 if (cfg_param_attr->cfg_attr_info.power_mgmt_mode < 5) {
540c3e88
LK
541 wid_list[wid_cnt].id = WID_POWER_MANAGEMENT;
542 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.power_mgmt_mode;
543 wid_list[wid_cnt].type = WID_CHAR;
544 wid_list[wid_cnt].size = sizeof(char);
02ae2bdf 545 hif_drv->cfg_values.power_mgmt_mode = (u8)cfg_param_attr->cfg_attr_info.power_mgmt_mode;
c5c77ba1 546 } else {
24db713f 547 PRINT_ER("Invalide power mode\n");
31390eec 548 result = -EINVAL;
24db713f 549 goto ERRORHANDLER;
c5c77ba1 550 }
540c3e88 551 wid_cnt++;
c5c77ba1 552 }
02ae2bdf
LK
553 if (cfg_param_attr->cfg_attr_info.flag & RETRY_SHORT) {
554 if (cfg_param_attr->cfg_attr_info.short_retry_limit > 0 &&
555 cfg_param_attr->cfg_attr_info.short_retry_limit < 256) {
540c3e88
LK
556 wid_list[wid_cnt].id = WID_SHORT_RETRY_LIMIT;
557 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.short_retry_limit;
558 wid_list[wid_cnt].type = WID_SHORT;
559 wid_list[wid_cnt].size = sizeof(u16);
02ae2bdf 560 hif_drv->cfg_values.short_retry_limit = cfg_param_attr->cfg_attr_info.short_retry_limit;
c5c77ba1 561 } else {
24db713f 562 PRINT_ER("Range(1~256) over\n");
31390eec 563 result = -EINVAL;
24db713f 564 goto ERRORHANDLER;
c5c77ba1 565 }
540c3e88 566 wid_cnt++;
c5c77ba1 567 }
02ae2bdf
LK
568 if (cfg_param_attr->cfg_attr_info.flag & RETRY_LONG) {
569 if (cfg_param_attr->cfg_attr_info.long_retry_limit > 0 &&
570 cfg_param_attr->cfg_attr_info.long_retry_limit < 256) {
540c3e88
LK
571 wid_list[wid_cnt].id = WID_LONG_RETRY_LIMIT;
572 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.long_retry_limit;
573 wid_list[wid_cnt].type = WID_SHORT;
574 wid_list[wid_cnt].size = sizeof(u16);
02ae2bdf 575 hif_drv->cfg_values.long_retry_limit = cfg_param_attr->cfg_attr_info.long_retry_limit;
c5c77ba1 576 } else {
24db713f 577 PRINT_ER("Range(1~256) over\n");
31390eec 578 result = -EINVAL;
24db713f 579 goto ERRORHANDLER;
c5c77ba1 580 }
540c3e88 581 wid_cnt++;
c5c77ba1 582 }
02ae2bdf
LK
583 if (cfg_param_attr->cfg_attr_info.flag & FRAG_THRESHOLD) {
584 if (cfg_param_attr->cfg_attr_info.frag_threshold > 255 &&
585 cfg_param_attr->cfg_attr_info.frag_threshold < 7937) {
540c3e88
LK
586 wid_list[wid_cnt].id = WID_FRAG_THRESHOLD;
587 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.frag_threshold;
588 wid_list[wid_cnt].type = WID_SHORT;
589 wid_list[wid_cnt].size = sizeof(u16);
02ae2bdf 590 hif_drv->cfg_values.frag_threshold = cfg_param_attr->cfg_attr_info.frag_threshold;
c5c77ba1 591 } else {
24db713f 592 PRINT_ER("Threshold Range fail\n");
31390eec 593 result = -EINVAL;
24db713f 594 goto ERRORHANDLER;
c5c77ba1 595 }
540c3e88 596 wid_cnt++;
c5c77ba1 597 }
02ae2bdf
LK
598 if (cfg_param_attr->cfg_attr_info.flag & RTS_THRESHOLD) {
599 if (cfg_param_attr->cfg_attr_info.rts_threshold > 255 &&
600 cfg_param_attr->cfg_attr_info.rts_threshold < 65536) {
540c3e88
LK
601 wid_list[wid_cnt].id = WID_RTS_THRESHOLD;
602 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.rts_threshold;
603 wid_list[wid_cnt].type = WID_SHORT;
604 wid_list[wid_cnt].size = sizeof(u16);
02ae2bdf 605 hif_drv->cfg_values.rts_threshold = cfg_param_attr->cfg_attr_info.rts_threshold;
c5c77ba1 606 } else {
24db713f 607 PRINT_ER("Threshold Range fail\n");
31390eec 608 result = -EINVAL;
24db713f 609 goto ERRORHANDLER;
c5c77ba1 610 }
540c3e88 611 wid_cnt++;
c5c77ba1 612 }
02ae2bdf
LK
613 if (cfg_param_attr->cfg_attr_info.flag & PREAMBLE) {
614 if (cfg_param_attr->cfg_attr_info.preamble_type < 3) {
540c3e88
LK
615 wid_list[wid_cnt].id = WID_PREAMBLE;
616 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.preamble_type;
617 wid_list[wid_cnt].type = WID_CHAR;
618 wid_list[wid_cnt].size = sizeof(char);
02ae2bdf 619 hif_drv->cfg_values.preamble_type = cfg_param_attr->cfg_attr_info.preamble_type;
c5c77ba1 620 } else {
24db713f 621 PRINT_ER("Preamle Range(0~2) over\n");
31390eec 622 result = -EINVAL;
24db713f 623 goto ERRORHANDLER;
c5c77ba1 624 }
540c3e88 625 wid_cnt++;
c5c77ba1 626 }
02ae2bdf
LK
627 if (cfg_param_attr->cfg_attr_info.flag & SHORT_SLOT_ALLOWED) {
628 if (cfg_param_attr->cfg_attr_info.short_slot_allowed < 2) {
540c3e88
LK
629 wid_list[wid_cnt].id = WID_SHORT_SLOT_ALLOWED;
630 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.short_slot_allowed;
631 wid_list[wid_cnt].type = WID_CHAR;
632 wid_list[wid_cnt].size = sizeof(char);
02ae2bdf 633 hif_drv->cfg_values.short_slot_allowed = (u8)cfg_param_attr->cfg_attr_info.short_slot_allowed;
c5c77ba1 634 } else {
24db713f 635 PRINT_ER("Short slot(2) over\n");
31390eec 636 result = -EINVAL;
24db713f 637 goto ERRORHANDLER;
c5c77ba1 638 }
540c3e88 639 wid_cnt++;
c5c77ba1 640 }
02ae2bdf
LK
641 if (cfg_param_attr->cfg_attr_info.flag & TXOP_PROT_DISABLE) {
642 if (cfg_param_attr->cfg_attr_info.txop_prot_disabled < 2) {
540c3e88
LK
643 wid_list[wid_cnt].id = WID_11N_TXOP_PROT_DISABLE;
644 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.txop_prot_disabled;
645 wid_list[wid_cnt].type = WID_CHAR;
646 wid_list[wid_cnt].size = sizeof(char);
02ae2bdf 647 hif_drv->cfg_values.txop_prot_disabled = (u8)cfg_param_attr->cfg_attr_info.txop_prot_disabled;
c5c77ba1 648 } else {
24db713f 649 PRINT_ER("TXOP prot disable\n");
31390eec 650 result = -EINVAL;
24db713f 651 goto ERRORHANDLER;
c5c77ba1 652 }
540c3e88 653 wid_cnt++;
c5c77ba1 654 }
02ae2bdf
LK
655 if (cfg_param_attr->cfg_attr_info.flag & BEACON_INTERVAL) {
656 if (cfg_param_attr->cfg_attr_info.beacon_interval > 0 &&
657 cfg_param_attr->cfg_attr_info.beacon_interval < 65536) {
540c3e88
LK
658 wid_list[wid_cnt].id = WID_BEACON_INTERVAL;
659 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.beacon_interval;
660 wid_list[wid_cnt].type = WID_SHORT;
661 wid_list[wid_cnt].size = sizeof(u16);
02ae2bdf 662 hif_drv->cfg_values.beacon_interval = cfg_param_attr->cfg_attr_info.beacon_interval;
c5c77ba1 663 } else {
24db713f 664 PRINT_ER("Beacon interval(1~65535) fail\n");
31390eec 665 result = -EINVAL;
24db713f 666 goto ERRORHANDLER;
c5c77ba1 667 }
540c3e88 668 wid_cnt++;
c5c77ba1 669 }
02ae2bdf
LK
670 if (cfg_param_attr->cfg_attr_info.flag & DTIM_PERIOD) {
671 if (cfg_param_attr->cfg_attr_info.dtim_period > 0 &&
672 cfg_param_attr->cfg_attr_info.dtim_period < 256) {
540c3e88
LK
673 wid_list[wid_cnt].id = WID_DTIM_PERIOD;
674 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.dtim_period;
675 wid_list[wid_cnt].type = WID_CHAR;
676 wid_list[wid_cnt].size = sizeof(char);
02ae2bdf 677 hif_drv->cfg_values.dtim_period = cfg_param_attr->cfg_attr_info.dtim_period;
c5c77ba1 678 } else {
24db713f 679 PRINT_ER("DTIM range(1~255) fail\n");
31390eec 680 result = -EINVAL;
24db713f 681 goto ERRORHANDLER;
c5c77ba1 682 }
540c3e88 683 wid_cnt++;
c5c77ba1 684 }
02ae2bdf
LK
685 if (cfg_param_attr->cfg_attr_info.flag & SITE_SURVEY) {
686 if (cfg_param_attr->cfg_attr_info.site_survey_enabled < 3) {
540c3e88
LK
687 wid_list[wid_cnt].id = WID_SITE_SURVEY;
688 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.site_survey_enabled;
689 wid_list[wid_cnt].type = WID_CHAR;
690 wid_list[wid_cnt].size = sizeof(char);
02ae2bdf 691 hif_drv->cfg_values.site_survey_enabled = (u8)cfg_param_attr->cfg_attr_info.site_survey_enabled;
c5c77ba1 692 } else {
24db713f 693 PRINT_ER("Site survey disable\n");
31390eec 694 result = -EINVAL;
24db713f 695 goto ERRORHANDLER;
c5c77ba1 696 }
540c3e88 697 wid_cnt++;
c5c77ba1 698 }
02ae2bdf
LK
699 if (cfg_param_attr->cfg_attr_info.flag & SITE_SURVEY_SCAN_TIME) {
700 if (cfg_param_attr->cfg_attr_info.site_survey_scan_time > 0 &&
701 cfg_param_attr->cfg_attr_info.site_survey_scan_time < 65536) {
540c3e88
LK
702 wid_list[wid_cnt].id = WID_SITE_SURVEY_SCAN_TIME;
703 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.site_survey_scan_time;
704 wid_list[wid_cnt].type = WID_SHORT;
705 wid_list[wid_cnt].size = sizeof(u16);
02ae2bdf 706 hif_drv->cfg_values.site_survey_scan_time = cfg_param_attr->cfg_attr_info.site_survey_scan_time;
c5c77ba1 707 } else {
24db713f 708 PRINT_ER("Site survey scan time(1~65535) over\n");
31390eec 709 result = -EINVAL;
24db713f 710 goto ERRORHANDLER;
c5c77ba1 711 }
540c3e88 712 wid_cnt++;
c5c77ba1 713 }
02ae2bdf
LK
714 if (cfg_param_attr->cfg_attr_info.flag & ACTIVE_SCANTIME) {
715 if (cfg_param_attr->cfg_attr_info.active_scan_time > 0 &&
716 cfg_param_attr->cfg_attr_info.active_scan_time < 65536) {
540c3e88
LK
717 wid_list[wid_cnt].id = WID_ACTIVE_SCAN_TIME;
718 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.active_scan_time;
719 wid_list[wid_cnt].type = WID_SHORT;
720 wid_list[wid_cnt].size = sizeof(u16);
02ae2bdf 721 hif_drv->cfg_values.active_scan_time = cfg_param_attr->cfg_attr_info.active_scan_time;
c5c77ba1 722 } else {
24db713f 723 PRINT_ER("Active scan time(1~65535) over\n");
31390eec 724 result = -EINVAL;
24db713f 725 goto ERRORHANDLER;
c5c77ba1 726 }
540c3e88 727 wid_cnt++;
c5c77ba1 728 }
02ae2bdf
LK
729 if (cfg_param_attr->cfg_attr_info.flag & PASSIVE_SCANTIME) {
730 if (cfg_param_attr->cfg_attr_info.passive_scan_time > 0 &&
731 cfg_param_attr->cfg_attr_info.passive_scan_time < 65536) {
540c3e88
LK
732 wid_list[wid_cnt].id = WID_PASSIVE_SCAN_TIME;
733 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.passive_scan_time;
734 wid_list[wid_cnt].type = WID_SHORT;
735 wid_list[wid_cnt].size = sizeof(u16);
02ae2bdf 736 hif_drv->cfg_values.passive_scan_time = cfg_param_attr->cfg_attr_info.passive_scan_time;
c5c77ba1 737 } else {
24db713f 738 PRINT_ER("Passive scan time(1~65535) over\n");
31390eec 739 result = -EINVAL;
24db713f 740 goto ERRORHANDLER;
c5c77ba1 741 }
540c3e88 742 wid_cnt++;
c5c77ba1 743 }
02ae2bdf
LK
744 if (cfg_param_attr->cfg_attr_info.flag & CURRENT_TX_RATE) {
745 enum CURRENT_TXRATE curr_tx_rate = cfg_param_attr->cfg_attr_info.curr_tx_rate;
c09389ac 746
c5c77ba1
JK
747 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
748 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
749 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
750 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
751 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
752 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
540c3e88
LK
753 wid_list[wid_cnt].id = WID_CURRENT_TX_RATE;
754 wid_list[wid_cnt].val = (s8 *)&curr_tx_rate;
755 wid_list[wid_cnt].type = WID_SHORT;
756 wid_list[wid_cnt].size = sizeof(u16);
ace303f0 757 hif_drv->cfg_values.curr_tx_rate = (u8)curr_tx_rate;
c5c77ba1 758 } else {
24db713f 759 PRINT_ER("out of TX rate\n");
31390eec 760 result = -EINVAL;
24db713f 761 goto ERRORHANDLER;
c5c77ba1 762 }
540c3e88 763 wid_cnt++;
c5c77ba1 764 }
31390eec 765
79df6a49 766 result = wilc_send_config_pkt(vif, SET_CFG, wid_list,
eb9939b7 767 wid_cnt, wilc_get_vif_idx(vif));
c5c77ba1 768
31390eec 769 if (result)
c5c77ba1
JK
770 PRINT_ER("Error in setting CFG params\n");
771
24db713f 772ERRORHANDLER:
33110ad7 773 up(&hif_drv->sem_cfg_values);
31390eec 774 return result;
c5c77ba1
JK
775}
776
3b840e49 777static void Handle_wait_msg_q_empty(void)
c5c77ba1 778{
0e1af73d 779 wilc_initialized = 0;
2d25af87 780 up(&hif_sema_wait_response);
c5c77ba1
JK
781}
782
71130e81 783static s32 Handle_ScanDone(struct wilc_vif *vif,
1608c403
AB
784 enum scan_event enuEvent);
785
71130e81 786static s32 Handle_Scan(struct wilc_vif *vif,
c476feb8 787 struct scan_attr *pstrHostIFscanAttr)
c5c77ba1 788{
31390eec 789 s32 result = 0;
e9e0c260 790 struct wid strWIDList[5];
4e4467fd
CL
791 u32 u32WidsCount = 0;
792 u32 i;
63d03e47
GKH
793 u8 *pu8Buffer;
794 u8 valuesize = 0;
795 u8 *pu8HdnNtwrksWidVal = NULL;
71130e81 796 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 797
bc801855 798 hif_drv->usr_scan_req.scan_result = pstrHostIFscanAttr->result;
66eaea30 799 hif_drv->usr_scan_req.arg = pstrHostIFscanAttr->arg;
c5c77ba1 800
b60005a8
LK
801 if ((hif_drv->hif_state >= HOST_IF_SCANNING) &&
802 (hif_drv->hif_state < HOST_IF_CONNECTED)) {
803 PRINT_D(GENERIC_DBG, "Don't scan already in [%d] state\n",
804 hif_drv->hif_state);
24db713f 805 PRINT_ER("Already scan\n");
31390eec 806 result = -EBUSY;
24db713f 807 goto ERRORHANDLER;
c5c77ba1
JK
808 }
809
0e1af73d 810 if (wilc_optaining_ip || wilc_connecting) {
c5c77ba1 811 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
24db713f 812 PRINT_ER("Don't do obss scan\n");
31390eec 813 result = -EBUSY;
24db713f 814 goto ERRORHANDLER;
c5c77ba1 815 }
c5c77ba1 816
f79756ee 817 hif_drv->usr_scan_req.rcvd_ch_cnt = 0;
c5c77ba1 818
daaf16ba 819 strWIDList[u32WidsCount].id = (u16)WID_SSID_PROBE_REQ;
416d8321 820 strWIDList[u32WidsCount].type = WID_STR;
c5c77ba1 821
40e05e86 822 for (i = 0; i < pstrHostIFscanAttr->hidden_network.n_ssids; i++)
245a1865 823 valuesize += ((pstrHostIFscanAttr->hidden_network.net_info[i].ssid_len) + 1);
f3052587 824 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
900bb4a6 825 strWIDList[u32WidsCount].val = pu8HdnNtwrksWidVal;
91109e11 826 if (strWIDList[u32WidsCount].val) {
900bb4a6 827 pu8Buffer = strWIDList[u32WidsCount].val;
c5c77ba1 828
40e05e86 829 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.n_ssids;
c5c77ba1 830
40e05e86 831 for (i = 0; i < pstrHostIFscanAttr->hidden_network.n_ssids; i++) {
245a1865
CL
832 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.net_info[i].ssid_len;
833 memcpy(pu8Buffer, pstrHostIFscanAttr->hidden_network.net_info[i].ssid, pstrHostIFscanAttr->hidden_network.net_info[i].ssid_len);
834 pu8Buffer += pstrHostIFscanAttr->hidden_network.net_info[i].ssid_len;
c5c77ba1
JK
835 }
836
2fd3e443 837 strWIDList[u32WidsCount].size = (s32)(valuesize + 1);
c5c77ba1
JK
838 u32WidsCount++;
839 }
840
c5c77ba1 841 {
daaf16ba 842 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_PROBE;
416d8321 843 strWIDList[u32WidsCount].type = WID_BIN_DATA;
d6f19aa5 844 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ies;
7b1f76cd 845 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ies_len;
c5c77ba1
JK
846 u32WidsCount++;
847 }
848
daaf16ba 849 strWIDList[u32WidsCount].id = WID_SCAN_TYPE;
416d8321 850 strWIDList[u32WidsCount].type = WID_CHAR;
2fd3e443 851 strWIDList[u32WidsCount].size = sizeof(char);
bafaa696 852 strWIDList[u32WidsCount].val = (s8 *)&pstrHostIFscanAttr->type;
c5c77ba1
JK
853 u32WidsCount++;
854
daaf16ba 855 strWIDList[u32WidsCount].id = WID_SCAN_CHANNEL_LIST;
416d8321 856 strWIDList[u32WidsCount].type = WID_BIN_DATA;
c5c77ba1 857
91109e11
LK
858 if (pstrHostIFscanAttr->ch_freq_list &&
859 pstrHostIFscanAttr->ch_list_len > 0) {
c5c77ba1
JK
860 int i;
861
f97bd9ca 862 for (i = 0; i < pstrHostIFscanAttr->ch_list_len; i++) {
82eeb0ad
LK
863 if (pstrHostIFscanAttr->ch_freq_list[i] > 0)
864 pstrHostIFscanAttr->ch_freq_list[i] = pstrHostIFscanAttr->ch_freq_list[i] - 1;
c5c77ba1
JK
865 }
866 }
867
82eeb0ad 868 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ch_freq_list;
f97bd9ca 869 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ch_list_len;
c5c77ba1
JK
870 u32WidsCount++;
871
daaf16ba 872 strWIDList[u32WidsCount].id = WID_START_SCAN_REQ;
416d8321 873 strWIDList[u32WidsCount].type = WID_CHAR;
2fd3e443 874 strWIDList[u32WidsCount].size = sizeof(char);
bafaa696 875 strWIDList[u32WidsCount].val = (s8 *)&pstrHostIFscanAttr->src;
c5c77ba1
JK
876 u32WidsCount++;
877
b60005a8 878 if (hif_drv->hif_state == HOST_IF_CONNECTED)
ca8540e4 879 scan_while_connected = true;
b60005a8 880 else if (hif_drv->hif_state == HOST_IF_IDLE)
ca8540e4 881 scan_while_connected = false;
c5c77ba1 882
79df6a49 883 result = wilc_send_config_pkt(vif, SET_CFG, strWIDList,
ec62e6d1 884 u32WidsCount,
eb9939b7 885 wilc_get_vif_idx(vif));
c5c77ba1 886
31390eec 887 if (result)
c5c77ba1 888 PRINT_ER("Failed to send scan paramters config packet\n");
c5c77ba1 889
24db713f 890ERRORHANDLER:
31390eec 891 if (result) {
13b313e4 892 del_timer(&hif_drv->scan_timer);
71130e81 893 Handle_ScanDone(vif, SCAN_EVENT_ABORTED);
c5c77ba1
JK
894 }
895
95f840fb
SB
896 kfree(pstrHostIFscanAttr->ch_freq_list);
897 pstrHostIFscanAttr->ch_freq_list = NULL;
c5c77ba1 898
95f840fb
SB
899 kfree(pstrHostIFscanAttr->ies);
900 pstrHostIFscanAttr->ies = NULL;
245a1865
CL
901 kfree(pstrHostIFscanAttr->hidden_network.net_info);
902 pstrHostIFscanAttr->hidden_network.net_info = NULL;
c5c77ba1 903
95f840fb 904 kfree(pu8HdnNtwrksWidVal);
c5c77ba1 905
31390eec 906 return result;
c5c77ba1
JK
907}
908
71130e81 909static s32 Handle_ScanDone(struct wilc_vif *vif,
a4ab1ade 910 enum scan_event enuEvent)
c5c77ba1 911{
31390eec 912 s32 result = 0;
63d03e47 913 u8 u8abort_running_scan;
45102f83 914 struct wid wid;
71130e81 915 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 916
c5c77ba1
JK
917 if (enuEvent == SCAN_EVENT_ABORTED) {
918 PRINT_D(GENERIC_DBG, "Abort running scan\n");
919 u8abort_running_scan = 1;
45102f83
LK
920 wid.id = (u16)WID_ABORT_RUNNING_SCAN;
921 wid.type = WID_CHAR;
922 wid.val = (s8 *)&u8abort_running_scan;
923 wid.size = sizeof(char);
c5c77ba1 924
79df6a49 925 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
4cf93d70 926 wilc_get_vif_idx(vif));
31390eec
LK
927
928 if (result) {
c5c77ba1 929 PRINT_ER("Failed to set abort running scan\n");
31390eec 930 result = -EFAULT;
c5c77ba1
JK
931 }
932 }
933
a4ab1ade 934 if (!hif_drv) {
c5c77ba1 935 PRINT_ER("Driver handler is NULL\n");
31390eec 936 return result;
c5c77ba1
JK
937 }
938
bc801855
LK
939 if (hif_drv->usr_scan_req.scan_result) {
940 hif_drv->usr_scan_req.scan_result(enuEvent, NULL,
66eaea30 941 hif_drv->usr_scan_req.arg, NULL);
bc801855 942 hif_drv->usr_scan_req.scan_result = NULL;
c5c77ba1
JK
943 }
944
31390eec 945 return result;
c5c77ba1
JK
946}
947
e554a305 948u8 wilc_connected_ssid[6] = {0};
71130e81 949static s32 Handle_Connect(struct wilc_vif *vif,
120ae593 950 struct connect_attr *pstrHostIFconnectAttr)
c5c77ba1 951{
31390eec 952 s32 result = 0;
e9e0c260 953 struct wid strWIDList[8];
4e4467fd 954 u32 u32WidsCount = 0, dummyval = 0;
63d03e47 955 u8 *pu8CurrByte = NULL;
e0a12217 956 struct join_bss_param *ptstrJoinBssParam;
71130e81 957 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1
JK
958
959 PRINT_D(GENERIC_DBG, "Handling connect request\n");
960
e554a305 961 if (memcmp(pstrHostIFconnectAttr->bssid, wilc_connected_ssid, ETH_ALEN) == 0) {
31390eec 962 result = 0;
c5c77ba1 963 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
31390eec 964 return result;
c5c77ba1
JK
965 }
966
f2bed2ca 967 ptstrJoinBssParam = (struct join_bss_param *)pstrHostIFconnectAttr->params;
91109e11 968 if (!ptstrJoinBssParam) {
c5c77ba1 969 PRINT_ER("Required BSSID not found\n");
31390eec 970 result = -ENOENT;
24db713f 971 goto ERRORHANDLER;
c5c77ba1 972 }
c5c77ba1 973
91109e11 974 if (pstrHostIFconnectAttr->bssid) {
f8b17132
LK
975 hif_drv->usr_conn_req.pu8bssid = kmalloc(6, GFP_KERNEL);
976 memcpy(hif_drv->usr_conn_req.pu8bssid, pstrHostIFconnectAttr->bssid, 6);
c5c77ba1
JK
977 }
978
74ab5e45 979 hif_drv->usr_conn_req.ssid_len = pstrHostIFconnectAttr->ssid_len;
91109e11 980 if (pstrHostIFconnectAttr->ssid) {
f8b17132
LK
981 hif_drv->usr_conn_req.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssid_len + 1, GFP_KERNEL);
982 memcpy(hif_drv->usr_conn_req.pu8ssid,
8c8360b3
LK
983 pstrHostIFconnectAttr->ssid,
984 pstrHostIFconnectAttr->ssid_len);
f8b17132 985 hif_drv->usr_conn_req.pu8ssid[pstrHostIFconnectAttr->ssid_len] = '\0';
c5c77ba1
JK
986 }
987
331ed080 988 hif_drv->usr_conn_req.ies_len = pstrHostIFconnectAttr->ies_len;
91109e11 989 if (pstrHostIFconnectAttr->ies) {
a3b2f4b9
LK
990 hif_drv->usr_conn_req.ies = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
991 memcpy(hif_drv->usr_conn_req.ies,
8c8360b3
LK
992 pstrHostIFconnectAttr->ies,
993 pstrHostIFconnectAttr->ies_len);
c5c77ba1
JK
994 }
995
f8b17132 996 hif_drv->usr_conn_req.u8security = pstrHostIFconnectAttr->security;
7d069728 997 hif_drv->usr_conn_req.auth_type = pstrHostIFconnectAttr->auth_type;
33bfb198 998 hif_drv->usr_conn_req.conn_result = pstrHostIFconnectAttr->result;
73abaa49 999 hif_drv->usr_conn_req.arg = pstrHostIFconnectAttr->arg;
c5c77ba1 1000
daaf16ba 1001 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
416d8321 1002 strWIDList[u32WidsCount].type = WID_INT;
2fd3e443 1003 strWIDList[u32WidsCount].size = sizeof(u32);
900bb4a6 1004 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
c5c77ba1
JK
1005 u32WidsCount++;
1006
daaf16ba 1007 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
416d8321 1008 strWIDList[u32WidsCount].type = WID_INT;
2fd3e443 1009 strWIDList[u32WidsCount].size = sizeof(u32);
900bb4a6 1010 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
c5c77ba1
JK
1011 u32WidsCount++;
1012
daaf16ba 1013 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
416d8321 1014 strWIDList[u32WidsCount].type = WID_INT;
2fd3e443 1015 strWIDList[u32WidsCount].size = sizeof(u32);
900bb4a6 1016 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
c5c77ba1
JK
1017 u32WidsCount++;
1018
c5c77ba1 1019 {
daaf16ba 1020 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
416d8321 1021 strWIDList[u32WidsCount].type = WID_BIN_DATA;
a3b2f4b9 1022 strWIDList[u32WidsCount].val = hif_drv->usr_conn_req.ies;
331ed080 1023 strWIDList[u32WidsCount].size = hif_drv->usr_conn_req.ies_len;
c5c77ba1
JK
1024 u32WidsCount++;
1025
f7bbd9cf 1026 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
331ed080 1027 info_element_size = hif_drv->usr_conn_req.ies_len;
dfef7b84 1028 info_element = kmalloc(info_element_size, GFP_KERNEL);
a3b2f4b9 1029 memcpy(info_element, hif_drv->usr_conn_req.ies,
dfef7b84 1030 info_element_size);
c5c77ba1
JK
1031 }
1032 }
daaf16ba 1033 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
416d8321 1034 strWIDList[u32WidsCount].type = WID_CHAR;
2fd3e443 1035 strWIDList[u32WidsCount].size = sizeof(char);
f8b17132 1036 strWIDList[u32WidsCount].val = (s8 *)&hif_drv->usr_conn_req.u8security;
c5c77ba1
JK
1037 u32WidsCount++;
1038
f7bbd9cf 1039 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
f8b17132 1040 mode_11i = hif_drv->usr_conn_req.u8security;
c5c77ba1 1041
daaf16ba 1042 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
416d8321 1043 strWIDList[u32WidsCount].type = WID_CHAR;
2fd3e443 1044 strWIDList[u32WidsCount].size = sizeof(char);
7d069728 1045 strWIDList[u32WidsCount].val = (s8 *)&hif_drv->usr_conn_req.auth_type;
c5c77ba1
JK
1046 u32WidsCount++;
1047
f7bbd9cf 1048 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
7d069728 1049 auth_type = (u8)hif_drv->usr_conn_req.auth_type;
c5c77ba1 1050
daaf16ba 1051 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
416d8321 1052 strWIDList[u32WidsCount].type = WID_STR;
ae4dfa57 1053 strWIDList[u32WidsCount].size = 112;
900bb4a6 1054 strWIDList[u32WidsCount].val = kmalloc(strWIDList[u32WidsCount].size, GFP_KERNEL);
c5c77ba1 1055
f7bbd9cf 1056 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
0626baaa
LK
1057 join_req_size = strWIDList[u32WidsCount].size;
1058 join_req = kmalloc(join_req_size, GFP_KERNEL);
c5c77ba1 1059 }
91109e11 1060 if (!strWIDList[u32WidsCount].val) {
31390eec 1061 result = -EFAULT;
24db713f
LK
1062 goto ERRORHANDLER;
1063 }
c5c77ba1 1064
900bb4a6 1065 pu8CurrByte = strWIDList[u32WidsCount].val;
c5c77ba1 1066
91109e11 1067 if (pstrHostIFconnectAttr->ssid) {
8b3c9fa6
LK
1068 memcpy(pu8CurrByte, pstrHostIFconnectAttr->ssid, pstrHostIFconnectAttr->ssid_len);
1069 pu8CurrByte[pstrHostIFconnectAttr->ssid_len] = '\0';
c5c77ba1
JK
1070 }
1071 pu8CurrByte += MAX_SSID_LEN;
c5c77ba1 1072 *(pu8CurrByte++) = INFRASTRUCTURE;
ae4dfa57 1073
0d1527e6
LK
1074 if ((pstrHostIFconnectAttr->ch >= 1) && (pstrHostIFconnectAttr->ch <= 14)) {
1075 *(pu8CurrByte++) = pstrHostIFconnectAttr->ch;
c5c77ba1
JK
1076 } else {
1077 PRINT_ER("Channel out of range\n");
1078 *(pu8CurrByte++) = 0xFF;
1079 }
c5c77ba1
JK
1080 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1081 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
c5c77ba1 1082
91109e11 1083 if (pstrHostIFconnectAttr->bssid)
9254db07 1084 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
c5c77ba1
JK
1085 pu8CurrByte += 6;
1086
c0f52fba
TC
1087 if (pstrHostIFconnectAttr->bssid)
1088 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
1089 pu8CurrByte += 6;
1090
c5c77ba1
JK
1091 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1092 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
c5c77ba1 1093 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
ae4dfa57 1094
d00d2ba3 1095 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
c5c77ba1
JK
1096 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1097
c5c77ba1 1098 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
c5c77ba1
JK
1099 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1100
c5c77ba1 1101 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
ff06982c 1102 hif_drv->usr_conn_req.ht_capable = ptstrJoinBssParam->ht_capable;
c5c77ba1 1103
c5c77ba1 1104 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
c5c77ba1 1105 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
c5c77ba1 1106 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
ae4dfa57 1107
d00d2ba3 1108 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
c5c77ba1
JK
1109 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1110
d00d2ba3 1111 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
c5c77ba1
JK
1112 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1113
d00d2ba3 1114 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
c5c77ba1
JK
1115 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1116
c5c77ba1 1117 *(pu8CurrByte++) = REAL_JOIN_REQ;
7a8d51d7 1118 *(pu8CurrByte++) = ptstrJoinBssParam->noa_enabled;
c5c77ba1 1119
7a8d51d7 1120 if (ptstrJoinBssParam->noa_enabled) {
c5c77ba1
JK
1121 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1122 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1123 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1124 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1125
d72b33ca 1126 *(pu8CurrByte++) = ptstrJoinBssParam->opp_enabled;
cc179008 1127 *(pu8CurrByte++) = ptstrJoinBssParam->idx;
c5c77ba1 1128
d72b33ca 1129 if (ptstrJoinBssParam->opp_enabled)
99b66945 1130 *(pu8CurrByte++) = ptstrJoinBssParam->ct_window;
c5c77ba1 1131
c21047ed 1132 *(pu8CurrByte++) = ptstrJoinBssParam->cnt;
c5c77ba1 1133
109e6cab
LK
1134 memcpy(pu8CurrByte, ptstrJoinBssParam->duration, sizeof(ptstrJoinBssParam->duration));
1135 pu8CurrByte += sizeof(ptstrJoinBssParam->duration);
c5c77ba1 1136
1d8b76b3
LK
1137 memcpy(pu8CurrByte, ptstrJoinBssParam->interval, sizeof(ptstrJoinBssParam->interval));
1138 pu8CurrByte += sizeof(ptstrJoinBssParam->interval);
c5c77ba1 1139
4be55e22
LK
1140 memcpy(pu8CurrByte, ptstrJoinBssParam->start_time, sizeof(ptstrJoinBssParam->start_time));
1141 pu8CurrByte += sizeof(ptstrJoinBssParam->start_time);
c4f97526 1142 }
c5c77ba1 1143
900bb4a6 1144 pu8CurrByte = strWIDList[u32WidsCount].val;
c5c77ba1 1145 u32WidsCount++;
c5c77ba1 1146
f7bbd9cf 1147 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
0626baaa 1148 memcpy(join_req, pu8CurrByte, join_req_size);
7036c624 1149 join_req_vif = vif;
c5c77ba1
JK
1150 }
1151
91109e11 1152 if (pstrHostIFconnectAttr->bssid) {
e554a305
LK
1153 memcpy(wilc_connected_ssid,
1154 pstrHostIFconnectAttr->bssid, ETH_ALEN);
1155 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n",
1156 pstrHostIFconnectAttr->bssid);
1157 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", wilc_connected_ssid);
c5c77ba1
JK
1158 }
1159
79df6a49 1160 result = wilc_send_config_pkt(vif, SET_CFG, strWIDList,
ec62e6d1 1161 u32WidsCount,
eb9939b7 1162 wilc_get_vif_idx(vif));
31390eec 1163 if (result) {
24db713f 1164 PRINT_ER("failed to send config packet\n");
31390eec 1165 result = -EFAULT;
24db713f 1166 goto ERRORHANDLER;
c5c77ba1
JK
1167 } else {
1168 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
b60005a8 1169 hif_drv->hif_state = HOST_IF_WAITING_CONN_RESP;
c5c77ba1 1170 }
c5c77ba1 1171
24db713f 1172ERRORHANDLER:
31390eec 1173 if (result) {
c5c77ba1
JK
1174 tstrConnectInfo strConnectInfo;
1175
81a59506 1176 del_timer(&hif_drv->connect_timer);
c5c77ba1 1177
2cc46837 1178 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
c5c77ba1 1179
91109e11
LK
1180 if (pstrHostIFconnectAttr->result) {
1181 if (pstrHostIFconnectAttr->bssid)
9254db07 1182 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->bssid, 6);
c5c77ba1 1183
91109e11 1184 if (pstrHostIFconnectAttr->ies) {
b59d5c5b
LK
1185 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->ies_len;
1186 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
d00d2ba3 1187 memcpy(strConnectInfo.pu8ReqIEs,
8c8360b3
LK
1188 pstrHostIFconnectAttr->ies,
1189 pstrHostIFconnectAttr->ies_len);
c5c77ba1
JK
1190 }
1191
6abcc11d 1192 pstrHostIFconnectAttr->result(CONN_DISCONN_EVENT_CONN_RESP,
c5c77ba1
JK
1193 &strConnectInfo,
1194 MAC_DISCONNECTED,
1195 NULL,
8f38db89 1196 pstrHostIFconnectAttr->arg);
b60005a8 1197 hif_drv->hif_state = HOST_IF_IDLE;
95f840fb
SB
1198 kfree(strConnectInfo.pu8ReqIEs);
1199 strConnectInfo.pu8ReqIEs = NULL;
c5c77ba1
JK
1200
1201 } else {
03b2d5e7 1202 PRINT_ER("Connect callback function pointer is NULL\n");
c5c77ba1
JK
1203 }
1204 }
1205
95f840fb
SB
1206 kfree(pstrHostIFconnectAttr->bssid);
1207 pstrHostIFconnectAttr->bssid = NULL;
c5c77ba1 1208
95f840fb
SB
1209 kfree(pstrHostIFconnectAttr->ssid);
1210 pstrHostIFconnectAttr->ssid = NULL;
c5c77ba1 1211
95f840fb
SB
1212 kfree(pstrHostIFconnectAttr->ies);
1213 pstrHostIFconnectAttr->ies = NULL;
c5c77ba1 1214
95f840fb 1215 kfree(pu8CurrByte);
31390eec 1216 return result;
c5c77ba1
JK
1217}
1218
71130e81 1219static s32 Handle_FlushConnect(struct wilc_vif *vif)
c5c77ba1 1220{
31390eec 1221 s32 result = 0;
e9e0c260 1222 struct wid strWIDList[5];
4e4467fd 1223 u32 u32WidsCount = 0;
63d03e47 1224 u8 *pu8CurrByte = NULL;
c5c77ba1 1225
daaf16ba 1226 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
416d8321 1227 strWIDList[u32WidsCount].type = WID_BIN_DATA;
48ce2465 1228 strWIDList[u32WidsCount].val = info_element;
dfef7b84 1229 strWIDList[u32WidsCount].size = info_element_size;
c5c77ba1
JK
1230 u32WidsCount++;
1231
daaf16ba 1232 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
416d8321 1233 strWIDList[u32WidsCount].type = WID_CHAR;
2fd3e443 1234 strWIDList[u32WidsCount].size = sizeof(char);
1bd9d44c 1235 strWIDList[u32WidsCount].val = (s8 *)(&(mode_11i));
c5c77ba1
JK
1236 u32WidsCount++;
1237
daaf16ba 1238 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
416d8321 1239 strWIDList[u32WidsCount].type = WID_CHAR;
2fd3e443 1240 strWIDList[u32WidsCount].size = sizeof(char);
fba4989e 1241 strWIDList[u32WidsCount].val = (s8 *)(&auth_type);
c5c77ba1
JK
1242 u32WidsCount++;
1243
daaf16ba 1244 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
416d8321 1245 strWIDList[u32WidsCount].type = WID_STR;
0626baaa 1246 strWIDList[u32WidsCount].size = join_req_size;
044a6410 1247 strWIDList[u32WidsCount].val = (s8 *)join_req;
900bb4a6 1248 pu8CurrByte = strWIDList[u32WidsCount].val;
c5c77ba1
JK
1249
1250 pu8CurrByte += FLUSHED_BYTE_POS;
1251 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1252
1253 u32WidsCount++;
1254
79df6a49 1255 result = wilc_send_config_pkt(vif, SET_CFG, strWIDList,
ec62e6d1 1256 u32WidsCount,
7036c624 1257 wilc_get_vif_idx(join_req_vif));
31390eec 1258 if (result) {
24db713f 1259 PRINT_ER("failed to send config packet\n");
31390eec 1260 result = -EINVAL;
c5c77ba1
JK
1261 }
1262
31390eec 1263 return result;
c5c77ba1
JK
1264}
1265
71130e81 1266static s32 Handle_ConnectTimeout(struct wilc_vif *vif)
c5c77ba1 1267{
31390eec 1268 s32 result = 0;
c5c77ba1 1269 tstrConnectInfo strConnectInfo;
45102f83 1270 struct wid wid;
d85f5326 1271 u16 u16DummyReasonCode = 0;
71130e81 1272 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 1273
a4ab1ade 1274 if (!hif_drv) {
c5c77ba1 1275 PRINT_ER("Driver handler is NULL\n");
31390eec 1276 return result;
c5c77ba1
JK
1277 }
1278
b60005a8 1279 hif_drv->hif_state = HOST_IF_IDLE;
c5c77ba1 1280
ca8540e4 1281 scan_while_connected = false;
c5c77ba1 1282
2cc46837 1283 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
c5c77ba1 1284
33bfb198 1285 if (hif_drv->usr_conn_req.conn_result) {
f8b17132 1286 if (hif_drv->usr_conn_req.pu8bssid) {
d00d2ba3 1287 memcpy(strConnectInfo.au8bssid,
f8b17132 1288 hif_drv->usr_conn_req.pu8bssid, 6);
c5c77ba1
JK
1289 }
1290
a3b2f4b9 1291 if (hif_drv->usr_conn_req.ies) {
331ed080
LK
1292 strConnectInfo.ReqIEsLen = hif_drv->usr_conn_req.ies_len;
1293 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL);
d00d2ba3 1294 memcpy(strConnectInfo.pu8ReqIEs,
a3b2f4b9 1295 hif_drv->usr_conn_req.ies,
331ed080 1296 hif_drv->usr_conn_req.ies_len);
c5c77ba1
JK
1297 }
1298
33bfb198
LK
1299 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
1300 &strConnectInfo,
1301 MAC_DISCONNECTED,
1302 NULL,
73abaa49 1303 hif_drv->usr_conn_req.arg);
c5c77ba1 1304
95f840fb
SB
1305 kfree(strConnectInfo.pu8ReqIEs);
1306 strConnectInfo.pu8ReqIEs = NULL;
c5c77ba1 1307 } else {
03b2d5e7 1308 PRINT_ER("Connect callback function pointer is NULL\n");
c5c77ba1
JK
1309 }
1310
45102f83
LK
1311 wid.id = (u16)WID_DISCONNECT;
1312 wid.type = WID_CHAR;
1313 wid.val = (s8 *)&u16DummyReasonCode;
1314 wid.size = sizeof(char);
c5c77ba1 1315
79df6a49 1316 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
4cf93d70 1317 wilc_get_vif_idx(vif));
31390eec 1318 if (result)
c5c77ba1 1319 PRINT_ER("Failed to send dissconect config packet\n");
c5c77ba1 1320
74ab5e45 1321 hif_drv->usr_conn_req.ssid_len = 0;
f8b17132 1322 kfree(hif_drv->usr_conn_req.pu8ssid);
cc28e4bf 1323 hif_drv->usr_conn_req.pu8ssid = NULL;
f8b17132 1324 kfree(hif_drv->usr_conn_req.pu8bssid);
cc28e4bf 1325 hif_drv->usr_conn_req.pu8bssid = NULL;
331ed080 1326 hif_drv->usr_conn_req.ies_len = 0;
a3b2f4b9 1327 kfree(hif_drv->usr_conn_req.ies);
cc28e4bf 1328 hif_drv->usr_conn_req.ies = NULL;
c5c77ba1 1329
e554a305 1330 eth_zero_addr(wilc_connected_ssid);
ae4dfa57 1331
7036c624 1332 if (join_req && join_req_vif == vif) {
044a6410
LK
1333 kfree(join_req);
1334 join_req = NULL;
c5c77ba1 1335 }
48ce2465 1336
7036c624 1337 if (info_element && join_req_vif == vif) {
48ce2465
LK
1338 kfree(info_element);
1339 info_element = NULL;
c5c77ba1
JK
1340 }
1341
31390eec 1342 return result;
c5c77ba1
JK
1343}
1344
71130e81 1345static s32 Handle_RcvdNtwrkInfo(struct wilc_vif *vif,
3bbd59f5 1346 struct rcvd_net_info *pstrRcvdNetworkInfo)
c5c77ba1 1347{
4e4467fd 1348 u32 i;
72ed4dc7 1349 bool bNewNtwrkFound;
31390eec 1350 s32 result = 0;
6b5180a0 1351 struct network_info *pstrNetworkInfo = NULL;
c5c77ba1 1352 void *pJoinParams = NULL;
71130e81 1353 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 1354
72ed4dc7 1355 bNewNtwrkFound = true;
c5c77ba1 1356
bc801855 1357 if (hif_drv->usr_scan_req.scan_result) {
0e1af73d 1358 wilc_parse_network_info(pstrRcvdNetworkInfo->buffer, &pstrNetworkInfo);
91109e11 1359 if ((!pstrNetworkInfo) ||
bc801855 1360 (!hif_drv->usr_scan_req.scan_result)) {
24db713f 1361 PRINT_ER("driver is null\n");
31390eec 1362 result = -EINVAL;
24db713f 1363 goto done;
c5c77ba1
JK
1364 }
1365
f79756ee 1366 for (i = 0; i < hif_drv->usr_scan_req.rcvd_ch_cnt; i++) {
af973f30 1367 if ((hif_drv->usr_scan_req.net_info[i].au8bssid) &&
91109e11 1368 (pstrNetworkInfo->au8bssid)) {
af973f30 1369 if (memcmp(hif_drv->usr_scan_req.net_info[i].au8bssid,
8c8360b3 1370 pstrNetworkInfo->au8bssid, 6) == 0) {
5c23a291 1371 if (pstrNetworkInfo->rssi <= hif_drv->usr_scan_req.net_info[i].s8rssi) {
c5c77ba1
JK
1372 goto done;
1373 } else {
5c23a291 1374 hif_drv->usr_scan_req.net_info[i].s8rssi = pstrNetworkInfo->rssi;
72ed4dc7 1375 bNewNtwrkFound = false;
c5c77ba1
JK
1376 break;
1377 }
1378 }
1379 }
1380 }
1381
047e6646 1382 if (bNewNtwrkFound) {
f79756ee 1383 if (hif_drv->usr_scan_req.rcvd_ch_cnt < MAX_NUM_SCANNED_NETWORKS) {
5c23a291 1384 hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].s8rssi = pstrNetworkInfo->rssi;
c5c77ba1 1385
f79756ee 1386 if (hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].au8bssid &&
91109e11 1387 pstrNetworkInfo->au8bssid) {
f79756ee 1388 memcpy(hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].au8bssid,
8c8360b3 1389 pstrNetworkInfo->au8bssid, 6);
c5c77ba1 1390
f79756ee 1391 hif_drv->usr_scan_req.rcvd_ch_cnt++;
c5c77ba1 1392
72ed4dc7 1393 pstrNetworkInfo->bNewNetwork = true;
c5c77ba1 1394 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
c5c77ba1 1395
bc801855 1396 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
66eaea30 1397 hif_drv->usr_scan_req.arg,
bc801855 1398 pJoinParams);
c5c77ba1 1399 }
c5c77ba1
JK
1400 }
1401 } else {
72ed4dc7 1402 pstrNetworkInfo->bNewNetwork = false;
bc801855 1403 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
66eaea30 1404 hif_drv->usr_scan_req.arg, NULL);
c5c77ba1
JK
1405 }
1406 }
1407
c5c77ba1 1408done:
95f840fb
SB
1409 kfree(pstrRcvdNetworkInfo->buffer);
1410 pstrRcvdNetworkInfo->buffer = NULL;
c5c77ba1 1411
91109e11 1412 if (pstrNetworkInfo) {
d9fb23d7
LK
1413 kfree(pstrNetworkInfo->pu8IEs);
1414 kfree(pstrNetworkInfo);
c5c77ba1
JK
1415 }
1416
31390eec 1417 return result;
c5c77ba1
JK
1418}
1419
71130e81 1420static s32 host_int_get_assoc_res_info(struct wilc_vif *vif,
1608c403
AB
1421 u8 *pu8AssocRespInfo,
1422 u32 u32MaxAssocRespInfoLen,
1423 u32 *pu32RcvdAssocRespInfoLen);
1424
cf60106b 1425static s32 Handle_RcvdGnrlAsyncInfo(struct wilc_vif *vif,
f23a9eab 1426 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
c5c77ba1 1427{
31390eec 1428 s32 result = 0;
63d03e47
GKH
1429 u8 u8MsgType = 0;
1430 u8 u8MsgID = 0;
d85f5326
CL
1431 u16 u16MsgLen = 0;
1432 u16 u16WidID = (u16)WID_NIL;
63d03e47
GKH
1433 u8 u8WidLen = 0;
1434 u8 u8MacStatus;
1435 u8 u8MacStatusReasonCode;
1436 u8 u8MacStatusAdditionalInfo;
c5c77ba1
JK
1437 tstrConnectInfo strConnectInfo;
1438 tstrDisconnectNotifInfo strDisconnectNotifInfo;
e6e12661 1439 s32 s32Err = 0;
71130e81 1440 struct host_if_drv *hif_drv = vif->hif_drv;
78c87591 1441
a4ab1ade 1442 if (!hif_drv) {
c5c77ba1 1443 PRINT_ER("Driver handler is NULL\n");
234837de
LK
1444 return -ENODEV;
1445 }
b60005a8
LK
1446 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n",
1447 hif_drv->hif_state, pstrRcvdGnrlAsyncInfo->buffer[7]);
c5c77ba1 1448
b60005a8
LK
1449 if ((hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) ||
1450 (hif_drv->hif_state == HOST_IF_CONNECTED) ||
bc801855 1451 hif_drv->usr_scan_req.scan_result) {
91109e11 1452 if (!pstrRcvdGnrlAsyncInfo->buffer ||
33bfb198 1453 !hif_drv->usr_conn_req.conn_result) {
24db713f
LK
1454 PRINT_ER("driver is null\n");
1455 return -EINVAL;
c5c77ba1
JK
1456 }
1457
33722ac7 1458 u8MsgType = pstrRcvdGnrlAsyncInfo->buffer[0];
c5c77ba1 1459
c5c77ba1
JK
1460 if ('I' != u8MsgType) {
1461 PRINT_ER("Received Message format incorrect.\n");
24db713f 1462 return -EFAULT;
c5c77ba1
JK
1463 }
1464
33722ac7
LK
1465 u8MsgID = pstrRcvdGnrlAsyncInfo->buffer[1];
1466 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[2], pstrRcvdGnrlAsyncInfo->buffer[3]);
1467 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[4], pstrRcvdGnrlAsyncInfo->buffer[5]);
1468 u8WidLen = pstrRcvdGnrlAsyncInfo->buffer[6];
1469 u8MacStatus = pstrRcvdGnrlAsyncInfo->buffer[7];
1470 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->buffer[8];
1471 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->buffer[9];
b60005a8 1472 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
71130e81 1473 u32 u32RcvdAssocRespInfoLen = 0;
40d96e1d 1474 struct connect_resp_info *pstrConnectRespInfo = NULL;
c5c77ba1 1475
2cc46837 1476 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
c5c77ba1
JK
1477
1478 if (u8MacStatus == MAC_CONNECTED) {
a633c0b5 1479 memset(rcv_assoc_resp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
c5c77ba1 1480
71130e81 1481 host_int_get_assoc_res_info(vif,
a633c0b5 1482 rcv_assoc_resp,
c5c77ba1
JK
1483 MAX_ASSOC_RESP_FRAME_SIZE,
1484 &u32RcvdAssocRespInfoLen);
1485
c5c77ba1 1486 if (u32RcvdAssocRespInfoLen != 0) {
0e1af73d 1487 s32Err = wilc_parse_assoc_resp_info(rcv_assoc_resp, u32RcvdAssocRespInfoLen,
c5c77ba1
JK
1488 &pstrConnectRespInfo);
1489 if (s32Err) {
0e1af73d 1490 PRINT_ER("wilc_parse_assoc_resp_info() returned error %d\n", s32Err);
c5c77ba1 1491 } else {
ba7b6ff5 1492 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->status;
c5c77ba1
JK
1493
1494 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
ba7b6ff5
LK
1495 if (pstrConnectRespInfo->ies) {
1496 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->ies_len;
1497 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->ies_len, GFP_KERNEL);
1498 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->ies,
1499 pstrConnectRespInfo->ies_len);
c5c77ba1
JK
1500 }
1501 }
1502
91109e11 1503 if (pstrConnectRespInfo) {
ba7b6ff5 1504 kfree(pstrConnectRespInfo->ies);
5f79c2ae 1505 kfree(pstrConnectRespInfo);
c5c77ba1
JK
1506 }
1507 }
1508 }
1509 }
1510
c5c77ba1
JK
1511 if ((u8MacStatus == MAC_CONNECTED) &&
1512 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
03b2d5e7 1513 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
e554a305 1514 eth_zero_addr(wilc_connected_ssid);
c5c77ba1
JK
1515 } else if (u8MacStatus == MAC_DISCONNECTED) {
1516 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
e554a305 1517 eth_zero_addr(wilc_connected_ssid);
c5c77ba1
JK
1518 }
1519
f8b17132 1520 if (hif_drv->usr_conn_req.pu8bssid) {
f8b17132 1521 memcpy(strConnectInfo.au8bssid, hif_drv->usr_conn_req.pu8bssid, 6);
c5c77ba1
JK
1522
1523 if ((u8MacStatus == MAC_CONNECTED) &&
1524 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
2a4eded9 1525 memcpy(hif_drv->assoc_bssid,
f8b17132 1526 hif_drv->usr_conn_req.pu8bssid, ETH_ALEN);
c5c77ba1
JK
1527 }
1528 }
1529
a3b2f4b9 1530 if (hif_drv->usr_conn_req.ies) {
331ed080
LK
1531 strConnectInfo.ReqIEsLen = hif_drv->usr_conn_req.ies_len;
1532 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL);
d00d2ba3 1533 memcpy(strConnectInfo.pu8ReqIEs,
a3b2f4b9 1534 hif_drv->usr_conn_req.ies,
331ed080 1535 hif_drv->usr_conn_req.ies_len);
c5c77ba1
JK
1536 }
1537
81a59506 1538 del_timer(&hif_drv->connect_timer);
33bfb198
LK
1539 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
1540 &strConnectInfo,
1541 u8MacStatus,
1542 NULL,
73abaa49 1543 hif_drv->usr_conn_req.arg);
c5c77ba1 1544
c5c77ba1
JK
1545 if ((u8MacStatus == MAC_CONNECTED) &&
1546 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
fbf5379b 1547 wilc_set_power_mgmt(vif, 0, 0);
c5c77ba1 1548
b60005a8 1549 hif_drv->hif_state = HOST_IF_CONNECTED;
c5c77ba1 1550
c5c77ba1 1551 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
0e1af73d
AB
1552 wilc_optaining_ip = true;
1553 mod_timer(&wilc_during_ip_timer,
9eb06643 1554 jiffies + msecs_to_jiffies(10000));
c5c77ba1 1555 } else {
b60005a8 1556 hif_drv->hif_state = HOST_IF_IDLE;
ca8540e4 1557 scan_while_connected = false;
c5c77ba1
JK
1558 }
1559
95f840fb
SB
1560 kfree(strConnectInfo.pu8RespIEs);
1561 strConnectInfo.pu8RespIEs = NULL;
c5c77ba1 1562
95f840fb
SB
1563 kfree(strConnectInfo.pu8ReqIEs);
1564 strConnectInfo.pu8ReqIEs = NULL;
74ab5e45 1565 hif_drv->usr_conn_req.ssid_len = 0;
f8b17132 1566 kfree(hif_drv->usr_conn_req.pu8ssid);
cc28e4bf 1567 hif_drv->usr_conn_req.pu8ssid = NULL;
f8b17132 1568 kfree(hif_drv->usr_conn_req.pu8bssid);
cc28e4bf 1569 hif_drv->usr_conn_req.pu8bssid = NULL;
331ed080 1570 hif_drv->usr_conn_req.ies_len = 0;
a3b2f4b9 1571 kfree(hif_drv->usr_conn_req.ies);
cc28e4bf 1572 hif_drv->usr_conn_req.ies = NULL;
c5c77ba1 1573 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
b60005a8 1574 (hif_drv->hif_state == HOST_IF_CONNECTED)) {
2cc46837 1575 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
c5c77ba1 1576
bc801855 1577 if (hif_drv->usr_scan_req.scan_result) {
13b313e4 1578 del_timer(&hif_drv->scan_timer);
71130e81 1579 Handle_ScanDone(vif, SCAN_EVENT_ABORTED);
c5c77ba1
JK
1580 }
1581
1582 strDisconnectNotifInfo.u16reason = 0;
1583 strDisconnectNotifInfo.ie = NULL;
1584 strDisconnectNotifInfo.ie_len = 0;
1585
33bfb198 1586 if (hif_drv->usr_conn_req.conn_result) {
0e1af73d 1587 wilc_optaining_ip = false;
fbf5379b 1588 wilc_set_power_mgmt(vif, 0, 0);
c5c77ba1 1589
33bfb198
LK
1590 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1591 NULL,
1592 0,
1593 &strDisconnectNotifInfo,
73abaa49 1594 hif_drv->usr_conn_req.arg);
c5c77ba1 1595 } else {
03b2d5e7 1596 PRINT_ER("Connect result callback function is NULL\n");
c5c77ba1
JK
1597 }
1598
2a4eded9 1599 eth_zero_addr(hif_drv->assoc_bssid);
c5c77ba1 1600
74ab5e45 1601 hif_drv->usr_conn_req.ssid_len = 0;
f8b17132 1602 kfree(hif_drv->usr_conn_req.pu8ssid);
cc28e4bf 1603 hif_drv->usr_conn_req.pu8ssid = NULL;
f8b17132 1604 kfree(hif_drv->usr_conn_req.pu8bssid);
cc28e4bf 1605 hif_drv->usr_conn_req.pu8bssid = NULL;
331ed080 1606 hif_drv->usr_conn_req.ies_len = 0;
a3b2f4b9 1607 kfree(hif_drv->usr_conn_req.ies);
cc28e4bf 1608 hif_drv->usr_conn_req.ies = NULL;
c5c77ba1 1609
7036c624 1610 if (join_req && join_req_vif == vif) {
044a6410
LK
1611 kfree(join_req);
1612 join_req = NULL;
c5c77ba1 1613 }
48ce2465 1614
7036c624 1615 if (info_element && join_req_vif == vif) {
48ce2465
LK
1616 kfree(info_element);
1617 info_element = NULL;
c5c77ba1
JK
1618 }
1619
b60005a8 1620 hif_drv->hif_state = HOST_IF_IDLE;
ca8540e4 1621 scan_while_connected = false;
c5c77ba1
JK
1622
1623 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
bc801855 1624 (hif_drv->usr_scan_req.scan_result)) {
13b313e4 1625 del_timer(&hif_drv->scan_timer);
bc801855 1626 if (hif_drv->usr_scan_req.scan_result)
71130e81 1627 Handle_ScanDone(vif, SCAN_EVENT_ABORTED);
c5c77ba1 1628 }
c5c77ba1
JK
1629 }
1630
95f840fb
SB
1631 kfree(pstrRcvdGnrlAsyncInfo->buffer);
1632 pstrRcvdGnrlAsyncInfo->buffer = NULL;
c5c77ba1 1633
31390eec 1634 return result;
c5c77ba1
JK
1635}
1636
71130e81 1637static int Handle_Key(struct wilc_vif *vif,
c98387a5 1638 struct key_attr *pstrHostIFkeyAttr)
c5c77ba1 1639{
31390eec 1640 s32 result = 0;
45102f83 1641 struct wid wid;
e9e0c260 1642 struct wid strWIDList[5];
63d03e47
GKH
1643 u8 i;
1644 u8 *pu8keybuf;
ca356ada
CL
1645 s8 s8idxarray[1];
1646 s8 ret = 0;
71130e81 1647 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 1648
8e9f427a 1649 switch (pstrHostIFkeyAttr->type) {
c5c77ba1
JK
1650 case WEP:
1651
0d17e382 1652 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
daaf16ba 1653 strWIDList[0].id = (u16)WID_11I_MODE;
416d8321 1654 strWIDList[0].type = WID_CHAR;
2fd3e443 1655 strWIDList[0].size = sizeof(char);
bafaa696 1656 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.mode;
c5c77ba1 1657
daaf16ba 1658 strWIDList[1].id = WID_AUTH_TYPE;
416d8321 1659 strWIDList[1].type = WID_CHAR;
2fd3e443 1660 strWIDList[1].size = sizeof(char);
bafaa696 1661 strWIDList[1].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.auth_type;
c5c77ba1 1662
ec450483 1663 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2,
543f5b13 1664 GFP_KERNEL);
c5c77ba1
JK
1665
1666 if (pu8keybuf == NULL) {
1667 PRINT_ER("No buffer to send Key\n");
9081987d 1668 return -ENOMEM;
c5c77ba1
JK
1669 }
1670
ec450483
GL
1671 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1672 pu8keybuf[1] = pstrHostIFkeyAttr->attr.wep.key_len;
1673
1674 memcpy(&pu8keybuf[2], pstrHostIFkeyAttr->attr.wep.key,
1675 pstrHostIFkeyAttr->attr.wep.key_len);
1676
73b2e381 1677 kfree(pstrHostIFkeyAttr->attr.wep.key);
c5c77ba1 1678
ec450483
GL
1679 strWIDList[2].id = (u16)WID_WEP_KEY_VALUE;
1680 strWIDList[2].type = WID_STR;
1681 strWIDList[2].size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
1682 strWIDList[2].val = (s8 *)pu8keybuf;
c5c77ba1 1683
79df6a49 1684 result = wilc_send_config_pkt(vif, SET_CFG,
ec450483 1685 strWIDList, 3,
4cf93d70 1686 wilc_get_vif_idx(vif));
49188af2 1687 kfree(pu8keybuf);
9edaa5f3 1688 } else if (pstrHostIFkeyAttr->action & ADDKEY) {
73b2e381 1689 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2, GFP_KERNEL);
91109e11 1690 if (!pu8keybuf) {
c5c77ba1 1691 PRINT_ER("No buffer to send Key\n");
9081987d 1692 return -ENOMEM;
c5c77ba1 1693 }
73b2e381
LK
1694 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1695 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->attr.wep.key_len, 1);
1696 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->attr.wep.key,
8c8360b3 1697 pstrHostIFkeyAttr->attr.wep.key_len);
73b2e381 1698 kfree(pstrHostIFkeyAttr->attr.wep.key);
c5c77ba1 1699
45102f83
LK
1700 wid.id = (u16)WID_ADD_WEP_KEY;
1701 wid.type = WID_STR;
1702 wid.val = (s8 *)pu8keybuf;
1703 wid.size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
c5c77ba1 1704
79df6a49 1705 result = wilc_send_config_pkt(vif, SET_CFG,
4cf93d70
CL
1706 &wid, 1,
1707 wilc_get_vif_idx(vif));
49188af2 1708 kfree(pu8keybuf);
0d17e382 1709 } else if (pstrHostIFkeyAttr->action & REMOVEKEY) {
45102f83
LK
1710 wid.id = (u16)WID_REMOVE_WEP_KEY;
1711 wid.type = WID_STR;
c5c77ba1 1712
73b2e381 1713 s8idxarray[0] = (s8)pstrHostIFkeyAttr->attr.wep.index;
45102f83
LK
1714 wid.val = s8idxarray;
1715 wid.size = 1;
c5c77ba1 1716
79df6a49 1717 result = wilc_send_config_pkt(vif, SET_CFG,
4cf93d70
CL
1718 &wid, 1,
1719 wilc_get_vif_idx(vif));
ec450483 1720 } else if (pstrHostIFkeyAttr->action & DEFAULTKEY) {
45102f83
LK
1721 wid.id = (u16)WID_KEY_ID;
1722 wid.type = WID_CHAR;
1723 wid.val = (s8 *)&pstrHostIFkeyAttr->attr.wep.index;
1724 wid.size = sizeof(char);
c5c77ba1 1725
79df6a49 1726 result = wilc_send_config_pkt(vif, SET_CFG,
4cf93d70
CL
1727 &wid, 1,
1728 wilc_get_vif_idx(vif));
c5c77ba1 1729 }
9ea47133 1730 up(&hif_drv->sem_test_key_block);
c5c77ba1
JK
1731 break;
1732
5cd8f7ae 1733 case WPA_RX_GTK:
0d17e382 1734 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
b156f1ed 1735 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
91109e11 1736 if (!pu8keybuf) {
c5c77ba1 1737 PRINT_ER("No buffer to send RxGTK Key\n");
9081987d 1738 ret = -ENOMEM;
c5c77ba1
JK
1739 goto _WPARxGtk_end_case_;
1740 }
1741
91109e11 1742 if (pstrHostIFkeyAttr->attr.wpa.seq)
0e74c009 1743 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
c5c77ba1 1744
e2dfbac5 1745 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
6acf2919 1746 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
124968fc 1747 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
8c8360b3 1748 pstrHostIFkeyAttr->attr.wpa.key_len);
c5c77ba1 1749
daaf16ba 1750 strWIDList[0].id = (u16)WID_11I_MODE;
416d8321 1751 strWIDList[0].type = WID_CHAR;
2fd3e443 1752 strWIDList[0].size = sizeof(char);
bafaa696 1753 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode;
c5c77ba1 1754
daaf16ba 1755 strWIDList[1].id = (u16)WID_ADD_RX_GTK;
416d8321 1756 strWIDList[1].type = WID_STR;
900bb4a6 1757 strWIDList[1].val = (s8 *)pu8keybuf;
2fd3e443 1758 strWIDList[1].size = RX_MIC_KEY_MSG_LEN;
c5c77ba1 1759
79df6a49 1760 result = wilc_send_config_pkt(vif, SET_CFG,
4cf93d70
CL
1761 strWIDList, 2,
1762 wilc_get_vif_idx(vif));
c5c77ba1 1763
49188af2 1764 kfree(pu8keybuf);
9ea47133 1765 up(&hif_drv->sem_test_key_block);
9edaa5f3 1766 } else if (pstrHostIFkeyAttr->action & ADDKEY) {
b156f1ed 1767 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
c5c77ba1
JK
1768 if (pu8keybuf == NULL) {
1769 PRINT_ER("No buffer to send RxGTK Key\n");
9081987d 1770 ret = -ENOMEM;
c5c77ba1
JK
1771 goto _WPARxGtk_end_case_;
1772 }
1773
b60005a8 1774 if (hif_drv->hif_state == HOST_IF_CONNECTED)
2a4eded9 1775 memcpy(pu8keybuf, hif_drv->assoc_bssid, ETH_ALEN);
78174ada 1776 else
b60005a8 1777 PRINT_ER("Couldn't handle WPARxGtk while state is not HOST_IF_CONNECTED\n");
c5c77ba1 1778
0e74c009 1779 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
e2dfbac5 1780 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
6acf2919 1781 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
124968fc 1782 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
8c8360b3 1783 pstrHostIFkeyAttr->attr.wpa.key_len);
c5c77ba1 1784
45102f83
LK
1785 wid.id = (u16)WID_ADD_RX_GTK;
1786 wid.type = WID_STR;
1787 wid.val = (s8 *)pu8keybuf;
1788 wid.size = RX_MIC_KEY_MSG_LEN;
c5c77ba1 1789
79df6a49 1790 result = wilc_send_config_pkt(vif, SET_CFG,
4cf93d70
CL
1791 &wid, 1,
1792 wilc_get_vif_idx(vif));
c5c77ba1 1793
49188af2 1794 kfree(pu8keybuf);
9ea47133 1795 up(&hif_drv->sem_test_key_block);
c5c77ba1
JK
1796 }
1797_WPARxGtk_end_case_:
124968fc 1798 kfree(pstrHostIFkeyAttr->attr.wpa.key);
0e74c009 1799 kfree(pstrHostIFkeyAttr->attr.wpa.seq);
9081987d 1800 if (ret)
c5c77ba1
JK
1801 return ret;
1802
1803 break;
1804
2141fe39 1805 case WPA_PTK:
0d17e382 1806 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
f3052587 1807 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
91109e11 1808 if (!pu8keybuf) {
c5c77ba1 1809 PRINT_ER("No buffer to send PTK Key\n");
9081987d 1810 ret = -ENOMEM;
c5c77ba1 1811 goto _WPAPtk_end_case_;
c5c77ba1
JK
1812 }
1813
248080aa 1814 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
e2dfbac5 1815 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.index, 1);
6acf2919 1816 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
124968fc 1817 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->attr.wpa.key,
8c8360b3 1818 pstrHostIFkeyAttr->attr.wpa.key_len);
c5c77ba1 1819
daaf16ba 1820 strWIDList[0].id = (u16)WID_11I_MODE;
416d8321 1821 strWIDList[0].type = WID_CHAR;
2fd3e443 1822 strWIDList[0].size = sizeof(char);
bafaa696 1823 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode;
c5c77ba1 1824
daaf16ba 1825 strWIDList[1].id = (u16)WID_ADD_PTK;
416d8321 1826 strWIDList[1].type = WID_STR;
900bb4a6 1827 strWIDList[1].val = (s8 *)pu8keybuf;
2fd3e443 1828 strWIDList[1].size = PTK_KEY_MSG_LEN + 1;
c5c77ba1 1829
79df6a49 1830 result = wilc_send_config_pkt(vif, SET_CFG,
4cf93d70
CL
1831 strWIDList, 2,
1832 wilc_get_vif_idx(vif));
49188af2 1833 kfree(pu8keybuf);
9ea47133 1834 up(&hif_drv->sem_test_key_block);
9edaa5f3 1835 } else if (pstrHostIFkeyAttr->action & ADDKEY) {
f3052587 1836 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
91109e11 1837 if (!pu8keybuf) {
c5c77ba1 1838 PRINT_ER("No buffer to send PTK Key\n");
9081987d 1839 ret = -ENOMEM;
c5c77ba1 1840 goto _WPAPtk_end_case_;
c5c77ba1
JK
1841 }
1842
248080aa 1843 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
6acf2919 1844 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
124968fc 1845 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->attr.wpa.key,
8c8360b3 1846 pstrHostIFkeyAttr->attr.wpa.key_len);
c5c77ba1 1847
45102f83
LK
1848 wid.id = (u16)WID_ADD_PTK;
1849 wid.type = WID_STR;
1850 wid.val = (s8 *)pu8keybuf;
1851 wid.size = PTK_KEY_MSG_LEN;
c5c77ba1 1852
79df6a49 1853 result = wilc_send_config_pkt(vif, SET_CFG,
4cf93d70
CL
1854 &wid, 1,
1855 wilc_get_vif_idx(vif));
49188af2 1856 kfree(pu8keybuf);
9ea47133 1857 up(&hif_drv->sem_test_key_block);
c5c77ba1
JK
1858 }
1859
1860_WPAPtk_end_case_:
124968fc 1861 kfree(pstrHostIFkeyAttr->attr.wpa.key);
9081987d 1862 if (ret)
c5c77ba1
JK
1863 return ret;
1864
1865 break;
1866
c5c77ba1 1867 case PMKSA:
73b2e381 1868 pu8keybuf = kmalloc((pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
91109e11 1869 if (!pu8keybuf) {
c5c77ba1 1870 PRINT_ER("No buffer to send PMKSA Key\n");
9081987d 1871 return -ENOMEM;
c5c77ba1
JK
1872 }
1873
73b2e381 1874 pu8keybuf[0] = pstrHostIFkeyAttr->attr.pmkid.numpmkid;
c5c77ba1 1875
73b2e381
LK
1876 for (i = 0; i < pstrHostIFkeyAttr->attr.pmkid.numpmkid; i++) {
1877 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
1878 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
c5c77ba1
JK
1879 }
1880
45102f83
LK
1881 wid.id = (u16)WID_PMKID_INFO;
1882 wid.type = WID_STR;
1883 wid.val = (s8 *)pu8keybuf;
1884 wid.size = (pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
c5c77ba1 1885
79df6a49 1886 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
4cf93d70 1887 wilc_get_vif_idx(vif));
c5c77ba1 1888
49188af2 1889 kfree(pu8keybuf);
c5c77ba1
JK
1890 break;
1891 }
1892
31390eec 1893 if (result)
c5c77ba1
JK
1894 PRINT_ER("Failed to send key config packet\n");
1895
31390eec 1896 return result;
c5c77ba1
JK
1897}
1898
71130e81 1899static void Handle_Disconnect(struct wilc_vif *vif)
c5c77ba1 1900{
45102f83 1901 struct wid wid;
71130e81 1902 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 1903
31390eec 1904 s32 result = 0;
d85f5326 1905 u16 u16DummyReasonCode = 0;
c5c77ba1 1906
45102f83
LK
1907 wid.id = (u16)WID_DISCONNECT;
1908 wid.type = WID_CHAR;
1909 wid.val = (s8 *)&u16DummyReasonCode;
1910 wid.size = sizeof(char);
c5c77ba1 1911
0e1af73d 1912 wilc_optaining_ip = false;
fbf5379b 1913 wilc_set_power_mgmt(vif, 0, 0);
c5c77ba1 1914
e554a305 1915 eth_zero_addr(wilc_connected_ssid);
c5c77ba1 1916
79df6a49 1917 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
4cf93d70 1918 wilc_get_vif_idx(vif));
c5c77ba1 1919
31390eec 1920 if (result) {
c5c77ba1 1921 PRINT_ER("Failed to send dissconect config packet\n");
c5c77ba1
JK
1922 } else {
1923 tstrDisconnectNotifInfo strDisconnectNotifInfo;
1924
2cc46837 1925 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
c5c77ba1
JK
1926
1927 strDisconnectNotifInfo.u16reason = 0;
1928 strDisconnectNotifInfo.ie = NULL;
1929 strDisconnectNotifInfo.ie_len = 0;
1930
bc801855 1931 if (hif_drv->usr_scan_req.scan_result) {
13b313e4 1932 del_timer(&hif_drv->scan_timer);
33bfb198
LK
1933 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED,
1934 NULL,
1935 hif_drv->usr_scan_req.arg,
1936 NULL);
bc801855 1937 hif_drv->usr_scan_req.scan_result = NULL;
c5c77ba1
JK
1938 }
1939
33bfb198 1940 if (hif_drv->usr_conn_req.conn_result) {
c4f97526 1941 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP)
81a59506 1942 del_timer(&hif_drv->connect_timer);
c5c77ba1 1943
33bfb198
LK
1944 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1945 NULL,
1946 0,
1947 &strDisconnectNotifInfo,
73abaa49 1948 hif_drv->usr_conn_req.arg);
c5c77ba1 1949 } else {
33bfb198 1950 PRINT_ER("usr_conn_req.conn_result = NULL\n");
c5c77ba1
JK
1951 }
1952
ca8540e4 1953 scan_while_connected = false;
c5c77ba1 1954
b60005a8 1955 hif_drv->hif_state = HOST_IF_IDLE;
c5c77ba1 1956
2a4eded9 1957 eth_zero_addr(hif_drv->assoc_bssid);
c5c77ba1 1958
74ab5e45 1959 hif_drv->usr_conn_req.ssid_len = 0;
f8b17132 1960 kfree(hif_drv->usr_conn_req.pu8ssid);
cc28e4bf 1961 hif_drv->usr_conn_req.pu8ssid = NULL;
f8b17132 1962 kfree(hif_drv->usr_conn_req.pu8bssid);
cc28e4bf 1963 hif_drv->usr_conn_req.pu8bssid = NULL;
331ed080 1964 hif_drv->usr_conn_req.ies_len = 0;
a3b2f4b9 1965 kfree(hif_drv->usr_conn_req.ies);
cc28e4bf 1966 hif_drv->usr_conn_req.ies = NULL;
c5c77ba1 1967
7036c624 1968 if (join_req && join_req_vif == vif) {
044a6410
LK
1969 kfree(join_req);
1970 join_req = NULL;
c5c77ba1 1971 }
48ce2465 1972
7036c624 1973 if (info_element && join_req_vif == vif) {
48ce2465
LK
1974 kfree(info_element);
1975 info_element = NULL;
c5c77ba1 1976 }
c5c77ba1
JK
1977 }
1978
e55e4967 1979 up(&hif_drv->sem_test_disconn_block);
c5c77ba1
JK
1980}
1981
fbf5379b 1982void wilc_resolve_disconnect_aberration(struct wilc_vif *vif)
c5c77ba1 1983{
fbf5379b 1984 if (!vif->hif_drv)
c5c77ba1 1985 return;
fbf5379b 1986 if ((vif->hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) ||
c4f97526 1987 (vif->hif_drv->hif_state == HOST_IF_CONNECTING))
fbf5379b 1988 wilc_disconnect(vif, 1);
c5c77ba1 1989}
c5c77ba1 1990
71130e81 1991static s32 Handle_GetChnl(struct wilc_vif *vif)
c5c77ba1 1992{
31390eec 1993 s32 result = 0;
45102f83 1994 struct wid wid;
71130e81 1995 struct host_if_drv *hif_drv = vif->hif_drv;
78c87591 1996
45102f83
LK
1997 wid.id = (u16)WID_CURRENT_CHANNEL;
1998 wid.type = WID_CHAR;
1999 wid.val = (s8 *)&ch_no;
2000 wid.size = sizeof(char);
c5c77ba1 2001
79df6a49 2002 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
4cf93d70 2003 wilc_get_vif_idx(vif));
ae4dfa57 2004
31390eec 2005 if (result) {
c5c77ba1 2006 PRINT_ER("Failed to get channel number\n");
31390eec 2007 result = -EFAULT;
c5c77ba1
JK
2008 }
2009
4ea90008 2010 up(&hif_drv->sem_get_chnl);
c5c77ba1 2011
31390eec 2012 return result;
c5c77ba1
JK
2013}
2014
71130e81 2015static void Handle_GetRssi(struct wilc_vif *vif)
c5c77ba1 2016{
31390eec 2017 s32 result = 0;
45102f83 2018 struct wid wid;
c5c77ba1 2019
45102f83
LK
2020 wid.id = (u16)WID_RSSI;
2021 wid.type = WID_CHAR;
2022 wid.val = &rssi;
2023 wid.size = sizeof(char);
c5c77ba1 2024
79df6a49 2025 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
4cf93d70 2026 wilc_get_vif_idx(vif));
31390eec 2027 if (result) {
c5c77ba1 2028 PRINT_ER("Failed to get RSSI value\n");
31390eec 2029 result = -EFAULT;
c5c77ba1
JK
2030 }
2031
71130e81 2032 up(&vif->hif_drv->sem_get_rssi);
c5c77ba1
JK
2033}
2034
71130e81 2035static void Handle_GetLinkspeed(struct wilc_vif *vif)
c5c77ba1 2036{
31390eec 2037 s32 result = 0;
45102f83 2038 struct wid wid;
71130e81 2039 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 2040
75327a02 2041 link_speed = 0;
c5c77ba1 2042
45102f83
LK
2043 wid.id = (u16)WID_LINKSPEED;
2044 wid.type = WID_CHAR;
2045 wid.val = &link_speed;
2046 wid.size = sizeof(char);
ae4dfa57 2047
79df6a49 2048 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
4cf93d70 2049 wilc_get_vif_idx(vif));
31390eec 2050 if (result) {
c5c77ba1 2051 PRINT_ER("Failed to get LINKSPEED value\n");
31390eec 2052 result = -EFAULT;
c5c77ba1
JK
2053 }
2054
bc34da66 2055 up(&hif_drv->sem_get_link_speed);
c5c77ba1
JK
2056}
2057
71130e81
GL
2058static s32 Handle_GetStatistics(struct wilc_vif *vif,
2059 struct rf_info *pstrStatistics)
c5c77ba1 2060{
e9e0c260 2061 struct wid strWIDList[5];
31390eec 2062 u32 u32WidsCount = 0, result = 0;
c5c77ba1 2063
daaf16ba 2064 strWIDList[u32WidsCount].id = WID_LINKSPEED;
416d8321 2065 strWIDList[u32WidsCount].type = WID_CHAR;
2fd3e443 2066 strWIDList[u32WidsCount].size = sizeof(char);
5babeecb 2067 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->link_speed;
c5c77ba1
JK
2068 u32WidsCount++;
2069
daaf16ba 2070 strWIDList[u32WidsCount].id = WID_RSSI;
416d8321 2071 strWIDList[u32WidsCount].type = WID_CHAR;
2fd3e443 2072 strWIDList[u32WidsCount].size = sizeof(char);
00c8dfcf 2073 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->rssi;
c5c77ba1
JK
2074 u32WidsCount++;
2075
daaf16ba 2076 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
416d8321 2077 strWIDList[u32WidsCount].type = WID_INT;
2fd3e443 2078 strWIDList[u32WidsCount].size = sizeof(u32);
7e84ff4e 2079 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_cnt;
c5c77ba1
JK
2080 u32WidsCount++;
2081
daaf16ba 2082 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
416d8321 2083 strWIDList[u32WidsCount].type = WID_INT;
2fd3e443 2084 strWIDList[u32WidsCount].size = sizeof(u32);
9b99274a 2085 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->rx_cnt;
c5c77ba1
JK
2086 u32WidsCount++;
2087
daaf16ba 2088 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
416d8321 2089 strWIDList[u32WidsCount].type = WID_INT;
2fd3e443 2090 strWIDList[u32WidsCount].size = sizeof(u32);
54160376 2091 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_fail_cnt;
c5c77ba1
JK
2092 u32WidsCount++;
2093
79df6a49 2094 result = wilc_send_config_pkt(vif, GET_CFG, strWIDList,
4cf93d70
CL
2095 u32WidsCount,
2096 wilc_get_vif_idx(vif));
c5c77ba1 2097
31390eec 2098 if (result)
c5c77ba1 2099 PRINT_ER("Failed to send scan paramters config packet\n");
24db713f 2100
4fd62291
GL
2101 if (pstrStatistics->link_speed > TCP_ACK_FILTER_LINK_SPEED_THRESH &&
2102 pstrStatistics->link_speed != DEFAULT_LINK_SPEED)
2103 wilc_enable_tcp_ack_filter(true);
2104 else if (pstrStatistics->link_speed != DEFAULT_LINK_SPEED)
2105 wilc_enable_tcp_ack_filter(false);
2106
2107 if (pstrStatistics != &vif->wilc->dummy_statistics)
2108 up(&hif_sema_wait_response);
c5c77ba1 2109 return 0;
c5c77ba1
JK
2110}
2111
71130e81 2112static s32 Handle_Get_InActiveTime(struct wilc_vif *vif,
3d1eac04 2113 struct sta_inactive_t *strHostIfStaInactiveT)
c5c77ba1 2114{
31390eec 2115 s32 result = 0;
63d03e47 2116 u8 *stamac;
45102f83 2117 struct wid wid;
71130e81 2118 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 2119
45102f83
LK
2120 wid.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
2121 wid.type = WID_STR;
2122 wid.size = ETH_ALEN;
2123 wid.val = kmalloc(wid.size, GFP_KERNEL);
c5c77ba1 2124
45102f83 2125 stamac = wid.val;
d00d2ba3 2126 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
c5c77ba1 2127
c5c77ba1
JK
2128 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
2129
79df6a49 2130 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
4cf93d70 2131 wilc_get_vif_idx(vif));
ae4dfa57 2132
31390eec 2133 if (result) {
c5c77ba1 2134 PRINT_ER("Failed to SET incative time\n");
24db713f 2135 return -EFAULT;
c5c77ba1
JK
2136 }
2137
45102f83
LK
2138 wid.id = (u16)WID_GET_INACTIVE_TIME;
2139 wid.type = WID_INT;
2140 wid.val = (s8 *)&inactive_time;
2141 wid.size = sizeof(u32);
c5c77ba1 2142
79df6a49 2143 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
4cf93d70 2144 wilc_get_vif_idx(vif));
ae4dfa57 2145
31390eec 2146 if (result) {
c5c77ba1 2147 PRINT_ER("Failed to get incative time\n");
24db713f 2148 return -EFAULT;
c5c77ba1
JK
2149 }
2150
ad26906f 2151 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", inactive_time);
c5c77ba1 2152
569a3c67 2153 up(&hif_drv->sem_inactive_time);
c5c77ba1 2154
31390eec 2155 return result;
c5c77ba1
JK
2156}
2157
71130e81 2158static void Handle_AddBeacon(struct wilc_vif *vif,
7f33fecd 2159 struct beacon_attr *pstrSetBeaconParam)
c5c77ba1 2160{
31390eec 2161 s32 result = 0;
45102f83 2162 struct wid wid;
63d03e47 2163 u8 *pu8CurrByte;
78c87591 2164
45102f83
LK
2165 wid.id = (u16)WID_ADD_BEACON;
2166 wid.type = WID_BIN;
2167 wid.size = pstrSetBeaconParam->head_len + pstrSetBeaconParam->tail_len + 16;
2168 wid.val = kmalloc(wid.size, GFP_KERNEL);
2169 if (!wid.val)
24db713f 2170 goto ERRORHANDLER;
c5c77ba1 2171
45102f83 2172 pu8CurrByte = wid.val;
12262dda
LK
2173 *pu8CurrByte++ = (pstrSetBeaconParam->interval & 0xFF);
2174 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 8) & 0xFF);
2175 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 16) & 0xFF);
2176 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 24) & 0xFF);
c5c77ba1 2177
e76ab770
LK
2178 *pu8CurrByte++ = (pstrSetBeaconParam->dtim_period & 0xFF);
2179 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 8) & 0xFF);
2180 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 16) & 0xFF);
2181 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 24) & 0xFF);
c5c77ba1 2182
51c66185
LK
2183 *pu8CurrByte++ = (pstrSetBeaconParam->head_len & 0xFF);
2184 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 8) & 0xFF);
2185 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 16) & 0xFF);
2186 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 24) & 0xFF);
c5c77ba1 2187
8ce528b9 2188 memcpy(pu8CurrByte, pstrSetBeaconParam->head, pstrSetBeaconParam->head_len);
51c66185 2189 pu8CurrByte += pstrSetBeaconParam->head_len;
c5c77ba1 2190
030c57e2
LK
2191 *pu8CurrByte++ = (pstrSetBeaconParam->tail_len & 0xFF);
2192 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 8) & 0xFF);
2193 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 16) & 0xFF);
2194 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 24) & 0xFF);
c5c77ba1 2195
7cf8e59e 2196 if (pstrSetBeaconParam->tail)
7dbcb6d3 2197 memcpy(pu8CurrByte, pstrSetBeaconParam->tail, pstrSetBeaconParam->tail_len);
030c57e2 2198 pu8CurrByte += pstrSetBeaconParam->tail_len;
c5c77ba1 2199
79df6a49
GL
2200 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2201 wilc_get_vif_idx(vif));
31390eec 2202 if (result)
c5c77ba1 2203 PRINT_ER("Failed to send add beacon config packet\n");
c5c77ba1 2204
24db713f 2205ERRORHANDLER:
45102f83 2206 kfree(wid.val);
8ce528b9 2207 kfree(pstrSetBeaconParam->head);
7dbcb6d3 2208 kfree(pstrSetBeaconParam->tail);
c5c77ba1
JK
2209}
2210
71130e81 2211static void Handle_DelBeacon(struct wilc_vif *vif)
c5c77ba1 2212{
31390eec 2213 s32 result = 0;
45102f83 2214 struct wid wid;
63d03e47 2215 u8 *pu8CurrByte;
78c87591 2216
45102f83
LK
2217 wid.id = (u16)WID_DEL_BEACON;
2218 wid.type = WID_CHAR;
2219 wid.size = sizeof(char);
2220 wid.val = &del_beacon;
c5c77ba1 2221
45102f83 2222 if (!wid.val)
24db713f 2223 return;
c5c77ba1 2224
45102f83 2225 pu8CurrByte = wid.val;
c5c77ba1 2226
79df6a49 2227 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
4cf93d70 2228 wilc_get_vif_idx(vif));
31390eec 2229 if (result)
c5c77ba1 2230 PRINT_ER("Failed to send delete beacon config packet\n");
c5c77ba1
JK
2231}
2232
6a89ba9c
TC
2233static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
2234 struct add_sta_param *pstrStationParam)
c5c77ba1 2235{
63d03e47 2236 u8 *pu8CurrByte;
c5c77ba1
JK
2237
2238 pu8CurrByte = pu8Buffer;
2239
2353c388 2240 memcpy(pu8CurrByte, pstrStationParam->bssid, ETH_ALEN);
c5c77ba1
JK
2241 pu8CurrByte += ETH_ALEN;
2242
4101eb8a
LK
2243 *pu8CurrByte++ = pstrStationParam->aid & 0xFF;
2244 *pu8CurrByte++ = (pstrStationParam->aid >> 8) & 0xFF;
c5c77ba1 2245
e734223c
LK
2246 *pu8CurrByte++ = pstrStationParam->rates_len;
2247 if (pstrStationParam->rates_len > 0)
a622e016 2248 memcpy(pu8CurrByte, pstrStationParam->rates,
e734223c
LK
2249 pstrStationParam->rates_len);
2250 pu8CurrByte += pstrStationParam->rates_len;
c5c77ba1 2251
22520120 2252 *pu8CurrByte++ = pstrStationParam->ht_supported;
0d073f69
LK
2253 *pu8CurrByte++ = pstrStationParam->ht_capa_info & 0xFF;
2254 *pu8CurrByte++ = (pstrStationParam->ht_capa_info >> 8) & 0xFF;
c5c77ba1 2255
fba1f2d2 2256 *pu8CurrByte++ = pstrStationParam->ht_ampdu_params;
5ebbf4f7
LK
2257 memcpy(pu8CurrByte, pstrStationParam->ht_supp_mcs_set,
2258 WILC_SUPP_MCS_SET_SIZE);
c5c77ba1
JK
2259 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
2260
223741d7
LK
2261 *pu8CurrByte++ = pstrStationParam->ht_ext_params & 0xFF;
2262 *pu8CurrByte++ = (pstrStationParam->ht_ext_params >> 8) & 0xFF;
c5c77ba1 2263
74fe73cf
LK
2264 *pu8CurrByte++ = pstrStationParam->ht_tx_bf_cap & 0xFF;
2265 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 8) & 0xFF;
2266 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 16) & 0xFF;
2267 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 24) & 0xFF;
c5c77ba1 2268
a486baff 2269 *pu8CurrByte++ = pstrStationParam->ht_ante_sel;
c5c77ba1 2270
f676e17a
LK
2271 *pu8CurrByte++ = pstrStationParam->flags_mask & 0xFF;
2272 *pu8CurrByte++ = (pstrStationParam->flags_mask >> 8) & 0xFF;
c5c77ba1 2273
67ab64e4
LK
2274 *pu8CurrByte++ = pstrStationParam->flags_set & 0xFF;
2275 *pu8CurrByte++ = (pstrStationParam->flags_set >> 8) & 0xFF;
c5c77ba1
JK
2276
2277 return pu8CurrByte - pu8Buffer;
2278}
2279
71130e81 2280static void Handle_AddStation(struct wilc_vif *vif,
6a89ba9c 2281 struct add_sta_param *pstrStationParam)
c5c77ba1 2282{
31390eec 2283 s32 result = 0;
45102f83 2284 struct wid wid;
63d03e47 2285 u8 *pu8CurrByte;
78c87591 2286
45102f83
LK
2287 wid.id = (u16)WID_ADD_STA;
2288 wid.type = WID_BIN;
e734223c 2289 wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->rates_len;
c5c77ba1 2290
45102f83
LK
2291 wid.val = kmalloc(wid.size, GFP_KERNEL);
2292 if (!wid.val)
24db713f 2293 goto ERRORHANDLER;
c5c77ba1 2294
45102f83 2295 pu8CurrByte = wid.val;
c5c77ba1
JK
2296 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2297
79df6a49 2298 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
4cf93d70 2299 wilc_get_vif_idx(vif));
31390eec 2300 if (result != 0)
c5c77ba1 2301 PRINT_ER("Failed to send add station config packet\n");
c5c77ba1 2302
24db713f 2303ERRORHANDLER:
a622e016 2304 kfree(pstrStationParam->rates);
45102f83 2305 kfree(wid.val);
c5c77ba1
JK
2306}
2307
71130e81 2308static void Handle_DelAllSta(struct wilc_vif *vif,
b4e644e4 2309 struct del_all_sta *pstrDelAllStaParam)
c5c77ba1 2310{
31390eec 2311 s32 result = 0;
45102f83 2312 struct wid wid;
63d03e47 2313 u8 *pu8CurrByte;
63d03e47 2314 u8 i;
3703480b 2315 u8 au8Zero_Buff[6] = {0};
78c87591 2316
45102f83
LK
2317 wid.id = (u16)WID_DEL_ALL_STA;
2318 wid.type = WID_STR;
2319 wid.size = (pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1;
c5c77ba1 2320
45102f83
LK
2321 wid.val = kmalloc((pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1, GFP_KERNEL);
2322 if (!wid.val)
24db713f 2323 goto ERRORHANDLER;
c5c77ba1 2324
45102f83 2325 pu8CurrByte = wid.val;
c5c77ba1 2326
8ba1803f 2327 *(pu8CurrByte++) = pstrDelAllStaParam->assoc_sta;
c5c77ba1
JK
2328
2329 for (i = 0; i < MAX_NUM_STA; i++) {
e51b9216
LK
2330 if (memcmp(pstrDelAllStaParam->del_all_sta[i], au8Zero_Buff, ETH_ALEN))
2331 memcpy(pu8CurrByte, pstrDelAllStaParam->del_all_sta[i], ETH_ALEN);
c5c77ba1
JK
2332 else
2333 continue;
2334
2335 pu8CurrByte += ETH_ALEN;
2336 }
2337
79df6a49 2338 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
4cf93d70 2339 wilc_get_vif_idx(vif));
31390eec 2340 if (result)
83cc9be5 2341 PRINT_ER("Failed to send add station config packet\n");
c5c77ba1 2342
24db713f 2343ERRORHANDLER:
45102f83 2344 kfree(wid.val);
c5c77ba1 2345
2d25af87 2346 up(&hif_sema_wait_response);
c5c77ba1
JK
2347}
2348
71130e81 2349static void Handle_DelStation(struct wilc_vif *vif,
fb93a1e1 2350 struct del_sta *pstrDelStaParam)
c5c77ba1 2351{
31390eec 2352 s32 result = 0;
45102f83 2353 struct wid wid;
63d03e47 2354 u8 *pu8CurrByte;
c5c77ba1 2355
45102f83
LK
2356 wid.id = (u16)WID_REMOVE_STA;
2357 wid.type = WID_BIN;
2358 wid.size = ETH_ALEN;
c5c77ba1 2359
45102f83
LK
2360 wid.val = kmalloc(wid.size, GFP_KERNEL);
2361 if (!wid.val)
24db713f 2362 goto ERRORHANDLER;
c5c77ba1 2363
45102f83 2364 pu8CurrByte = wid.val;
c5c77ba1 2365
e4839d39 2366 memcpy(pu8CurrByte, pstrDelStaParam->mac_addr, ETH_ALEN);
c5c77ba1 2367
79df6a49 2368 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
4cf93d70 2369 wilc_get_vif_idx(vif));
31390eec 2370 if (result)
83cc9be5 2371 PRINT_ER("Failed to send add station config packet\n");
c5c77ba1 2372
24db713f 2373ERRORHANDLER:
45102f83 2374 kfree(wid.val);
c5c77ba1
JK
2375}
2376
71130e81 2377static void Handle_EditStation(struct wilc_vif *vif,
6a89ba9c 2378 struct add_sta_param *pstrStationParam)
c5c77ba1 2379{
31390eec 2380 s32 result = 0;
45102f83 2381 struct wid wid;
63d03e47 2382 u8 *pu8CurrByte;
c5c77ba1 2383
45102f83
LK
2384 wid.id = (u16)WID_EDIT_STA;
2385 wid.type = WID_BIN;
e734223c 2386 wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->rates_len;
c5c77ba1 2387
45102f83
LK
2388 wid.val = kmalloc(wid.size, GFP_KERNEL);
2389 if (!wid.val)
24db713f 2390 goto ERRORHANDLER;
c5c77ba1 2391
45102f83 2392 pu8CurrByte = wid.val;
c5c77ba1
JK
2393 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2394
79df6a49 2395 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
4cf93d70 2396 wilc_get_vif_idx(vif));
31390eec 2397 if (result)
c5c77ba1 2398 PRINT_ER("Failed to send edit station config packet\n");
c5c77ba1 2399
24db713f 2400ERRORHANDLER:
a622e016 2401 kfree(pstrStationParam->rates);
45102f83 2402 kfree(wid.val);
c5c77ba1 2403}
c5c77ba1 2404
71130e81 2405static int Handle_RemainOnChan(struct wilc_vif *vif,
2f9c03f5 2406 struct remain_ch *pstrHostIfRemainOnChan)
c5c77ba1 2407{
31390eec 2408 s32 result = 0;
63d03e47 2409 u8 u8remain_on_chan_flag;
45102f83 2410 struct wid wid;
71130e81 2411 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 2412
5beef2ca 2413 if (!hif_drv->remain_on_ch_pending) {
c5cc4b12 2414 hif_drv->remain_on_ch.arg = pstrHostIfRemainOnChan->arg;
bfb62abc 2415 hif_drv->remain_on_ch.expired = pstrHostIfRemainOnChan->expired;
5e5f7916 2416 hif_drv->remain_on_ch.ready = pstrHostIfRemainOnChan->ready;
839ab709 2417 hif_drv->remain_on_ch.ch = pstrHostIfRemainOnChan->ch;
9d764e38 2418 hif_drv->remain_on_ch.id = pstrHostIfRemainOnChan->id;
c5c77ba1 2419 } else {
839ab709 2420 pstrHostIfRemainOnChan->ch = hif_drv->remain_on_ch.ch;
c5c77ba1
JK
2421 }
2422
bc801855 2423 if (hif_drv->usr_scan_req.scan_result) {
c5c77ba1 2424 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
5beef2ca 2425 hif_drv->remain_on_ch_pending = 1;
31390eec 2426 result = -EBUSY;
24db713f 2427 goto ERRORHANDLER;
c5c77ba1 2428 }
b60005a8 2429 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
c5c77ba1 2430 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
31390eec 2431 result = -EBUSY;
24db713f 2432 goto ERRORHANDLER;
c5c77ba1
JK
2433 }
2434
0e1af73d 2435 if (wilc_optaining_ip || wilc_connecting) {
c5c77ba1 2436 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
31390eec 2437 result = -EBUSY;
24db713f 2438 goto ERRORHANDLER;
c5c77ba1 2439 }
c5c77ba1 2440
72ed4dc7 2441 u8remain_on_chan_flag = true;
45102f83
LK
2442 wid.id = (u16)WID_REMAIN_ON_CHAN;
2443 wid.type = WID_STR;
2444 wid.size = 2;
2445 wid.val = kmalloc(wid.size, GFP_KERNEL);
2446 if (!wid.val) {
31390eec 2447 result = -ENOMEM;
24db713f
LK
2448 goto ERRORHANDLER;
2449 }
c5c77ba1 2450
45102f83 2451 wid.val[0] = u8remain_on_chan_flag;
839ab709 2452 wid.val[1] = (s8)pstrHostIfRemainOnChan->ch;
c5c77ba1 2453
79df6a49 2454 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
4cf93d70 2455 wilc_get_vif_idx(vif));
31390eec 2456 if (result != 0)
c5c77ba1 2457 PRINT_ER("Failed to set remain on channel\n");
c5c77ba1 2458
24db713f 2459ERRORHANDLER:
c5c77ba1
JK
2460 {
2461 P2P_LISTEN_STATE = 1;
71130e81 2462 hif_drv->remain_on_ch_timer.data = (unsigned long)vif;
cc2d7e9e 2463 mod_timer(&hif_drv->remain_on_ch_timer,
9eb06643 2464 jiffies +
fb6e0680 2465 msecs_to_jiffies(pstrHostIfRemainOnChan->duration));
c5c77ba1 2466
5e5f7916 2467 if (hif_drv->remain_on_ch.ready)
c5cc4b12 2468 hif_drv->remain_on_ch.ready(hif_drv->remain_on_ch.arg);
c5c77ba1 2469
5beef2ca
LK
2470 if (hif_drv->remain_on_ch_pending)
2471 hif_drv->remain_on_ch_pending = 0;
c5c77ba1 2472 }
31390eec
LK
2473
2474 return result;
c5c77ba1
JK
2475}
2476
71130e81 2477static int Handle_RegisterFrame(struct wilc_vif *vif,
bc37c5df 2478 struct reg_frame *pstrHostIfRegisterFrame)
c5c77ba1 2479{
31390eec 2480 s32 result = 0;
45102f83 2481 struct wid wid;
63d03e47 2482 u8 *pu8CurrByte;
c5c77ba1 2483
45102f83
LK
2484 wid.id = (u16)WID_REGISTER_FRAME;
2485 wid.type = WID_STR;
2486 wid.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
2487 if (!wid.val)
24db713f 2488 return -ENOMEM;
c5c77ba1 2489
45102f83 2490 pu8CurrByte = wid.val;
c5c77ba1 2491
6abf8681 2492 *pu8CurrByte++ = pstrHostIfRegisterFrame->reg;
bcb410bb 2493 *pu8CurrByte++ = pstrHostIfRegisterFrame->reg_id;
d5f654ca 2494 memcpy(pu8CurrByte, &pstrHostIfRegisterFrame->frame_type, sizeof(u16));
c5c77ba1 2495
45102f83 2496 wid.size = sizeof(u16) + 2;
c5c77ba1 2497
79df6a49 2498 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
4cf93d70 2499 wilc_get_vif_idx(vif));
31390eec 2500 if (result) {
c5c77ba1 2501 PRINT_ER("Failed to frame register config packet\n");
31390eec 2502 result = -EINVAL;
c5c77ba1
JK
2503 }
2504
31390eec 2505 return result;
c5c77ba1
JK
2506}
2507
71130e81 2508static u32 Handle_ListenStateExpired(struct wilc_vif *vif,
2f9c03f5 2509 struct remain_ch *pstrHostIfRemainOnChan)
c5c77ba1 2510{
63d03e47 2511 u8 u8remain_on_chan_flag;
45102f83 2512 struct wid wid;
31390eec 2513 s32 result = 0;
71130e81 2514 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 2515
c5c77ba1 2516 if (P2P_LISTEN_STATE) {
72ed4dc7 2517 u8remain_on_chan_flag = false;
45102f83
LK
2518 wid.id = (u16)WID_REMAIN_ON_CHAN;
2519 wid.type = WID_STR;
2520 wid.size = 2;
2521 wid.val = kmalloc(wid.size, GFP_KERNEL);
c5c77ba1 2522
653bb463 2523 if (!wid.val) {
c5c77ba1 2524 PRINT_ER("Failed to allocate memory\n");
653bb463
LK
2525 return -ENOMEM;
2526 }
c5c77ba1 2527
45102f83
LK
2528 wid.val[0] = u8remain_on_chan_flag;
2529 wid.val[1] = FALSE_FRMWR_CHANNEL;
c5c77ba1 2530
79df6a49 2531 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
4cf93d70 2532 wilc_get_vif_idx(vif));
31390eec 2533 if (result != 0) {
c5c77ba1
JK
2534 PRINT_ER("Failed to set remain on channel\n");
2535 goto _done_;
2536 }
2537
bfb62abc 2538 if (hif_drv->remain_on_ch.expired) {
c5cc4b12 2539 hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.arg,
9d764e38 2540 pstrHostIfRemainOnChan->id);
c5c77ba1
JK
2541 }
2542 P2P_LISTEN_STATE = 0;
2543 } else {
2544 PRINT_D(GENERIC_DBG, "Not in listen state\n");
31390eec 2545 result = -EFAULT;
c5c77ba1
JK
2546 }
2547
2548_done_:
31390eec 2549 return result;
c5c77ba1
JK
2550}
2551
93dee8ee 2552static void ListenTimerCB(unsigned long arg)
c5c77ba1 2553{
31390eec 2554 s32 result = 0;
143eb95a 2555 struct host_if_msg msg;
71130e81 2556 struct wilc_vif *vif = (struct wilc_vif *)arg;
ae4dfa57 2557
71130e81 2558 del_timer(&vif->hif_drv->remain_on_ch_timer);
c5c77ba1 2559
143eb95a 2560 memset(&msg, 0, sizeof(struct host_if_msg));
a9f812a6 2561 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
71130e81
GL
2562 msg.vif = vif;
2563 msg.body.remain_on_ch.id = vif->hif_drv->remain_on_ch.id;
c5c77ba1 2564
31390eec
LK
2565 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2566 if (result)
24db713f 2567 PRINT_ER("wilc_mq_send fail\n");
c5c77ba1 2568}
c5c77ba1 2569
71130e81 2570static void Handle_PowerManagement(struct wilc_vif *vif,
5a008f1c 2571 struct power_mgmt_param *strPowerMgmtParam)
c5c77ba1 2572{
31390eec 2573 s32 result = 0;
45102f83 2574 struct wid wid;
ca356ada 2575 s8 s8PowerMode;
78c87591 2576
45102f83 2577 wid.id = (u16)WID_POWER_MANAGEMENT;
c5c77ba1 2578
047e6646 2579 if (strPowerMgmtParam->enabled)
c5c77ba1 2580 s8PowerMode = MIN_FAST_PS;
78174ada 2581 else
c5c77ba1 2582 s8PowerMode = NO_POWERSAVE;
c4f97526 2583
45102f83
LK
2584 wid.val = &s8PowerMode;
2585 wid.size = sizeof(char);
c5c77ba1 2586
79df6a49 2587 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
4cf93d70 2588 wilc_get_vif_idx(vif));
31390eec 2589 if (result)
c5c77ba1 2590 PRINT_ER("Failed to send power management config packet\n");
c5c77ba1
JK
2591}
2592
71130e81 2593static void Handle_SetMulticastFilter(struct wilc_vif *vif,
641210ac 2594 struct set_multicast *strHostIfSetMulti)
c5c77ba1 2595{
31390eec 2596 s32 result = 0;
45102f83 2597 struct wid wid;
63d03e47 2598 u8 *pu8CurrByte;
c5c77ba1 2599
45102f83
LK
2600 wid.id = (u16)WID_SETUP_MULTICAST_FILTER;
2601 wid.type = WID_BIN;
2602 wid.size = sizeof(struct set_multicast) + ((strHostIfSetMulti->cnt) * ETH_ALEN);
2603 wid.val = kmalloc(wid.size, GFP_KERNEL);
2604 if (!wid.val)
24db713f 2605 goto ERRORHANDLER;
c5c77ba1 2606
45102f83 2607 pu8CurrByte = wid.val;
bae636eb 2608 *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF);
c8751ad7
LK
2609 *pu8CurrByte++ = 0;
2610 *pu8CurrByte++ = 0;
2611 *pu8CurrByte++ = 0;
c5c77ba1 2612
adab2f71
LK
2613 *pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF);
2614 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF);
2615 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 16) & 0xFF);
2616 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 24) & 0xFF);
c5c77ba1 2617
adab2f71 2618 if ((strHostIfSetMulti->cnt) > 0)
0e1af73d 2619 memcpy(pu8CurrByte, wilc_multicast_mac_addr_list,
fb70e9f5 2620 ((strHostIfSetMulti->cnt) * ETH_ALEN));
c5c77ba1 2621
79df6a49 2622 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
4cf93d70 2623 wilc_get_vif_idx(vif));
31390eec 2624 if (result)
c5c77ba1 2625 PRINT_ER("Failed to send setup multicast config packet\n");
c5c77ba1 2626
24db713f 2627ERRORHANDLER:
45102f83 2628 kfree(wid.val);
c5c77ba1
JK
2629}
2630
71130e81 2631static s32 Handle_DelAllRxBASessions(struct wilc_vif *vif,
54265472 2632 struct ba_session_info *strHostIfBASessionInfo)
c5c77ba1 2633{
31390eec 2634 s32 result = 0;
45102f83 2635 struct wid wid;
c5c77ba1 2636 char *ptr = NULL;
c5c77ba1 2637
03b2d5e7 2638 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
3fc4999e
LK
2639 strHostIfBASessionInfo->bssid[0],
2640 strHostIfBASessionInfo->bssid[1],
2641 strHostIfBASessionInfo->bssid[2],
16c9b391 2642 strHostIfBASessionInfo->tid);
c5c77ba1 2643
45102f83
LK
2644 wid.id = (u16)WID_DEL_ALL_RX_BA;
2645 wid.type = WID_STR;
2646 wid.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2647 wid.size = BLOCK_ACK_REQ_SIZE;
2648 ptr = wid.val;
c5c77ba1
JK
2649 *ptr++ = 0x14;
2650 *ptr++ = 0x3;
2651 *ptr++ = 0x2;
3fc4999e 2652 memcpy(ptr, strHostIfBASessionInfo->bssid, ETH_ALEN);
c5c77ba1 2653 ptr += ETH_ALEN;
16c9b391 2654 *ptr++ = strHostIfBASessionInfo->tid;
c5c77ba1 2655 *ptr++ = 0;
ae4dfa57 2656 *ptr++ = 32;
c5c77ba1 2657
79df6a49 2658 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
4cf93d70 2659 wilc_get_vif_idx(vif));
c5c77ba1 2660
45102f83 2661 kfree(wid.val);
c5c77ba1 2662
2d25af87 2663 up(&hif_sema_wait_response);
c5c77ba1 2664
31390eec 2665 return result;
c5c77ba1
JK
2666}
2667
70418790
GL
2668static void handle_set_tx_pwr(struct wilc_vif *vif, u8 tx_pwr)
2669{
2670 int ret;
2671 struct wid wid;
2672
2673 wid.id = (u16)WID_TX_POWER;
2674 wid.type = WID_CHAR;
2675 wid.val = &tx_pwr;
2676 wid.size = sizeof(char);
2677
79df6a49
GL
2678 ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2679 wilc_get_vif_idx(vif));
70418790
GL
2680 if (ret)
2681 netdev_err(vif->ndev, "Failed to set TX PWR\n");
2682}
2683
2684static void handle_get_tx_pwr(struct wilc_vif *vif, u8 *tx_pwr)
2685{
2686 s32 ret = 0;
2687 struct wid wid;
2688
2689 wid.id = (u16)WID_TX_POWER;
2690 wid.type = WID_CHAR;
2691 wid.val = (s8 *)tx_pwr;
2692 wid.size = sizeof(char);
2693
79df6a49
GL
2694 ret = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
2695 wilc_get_vif_idx(vif));
70418790
GL
2696 if (ret)
2697 netdev_err(vif->ndev, "Failed to get TX PWR\n");
2698
2699 up(&hif_sema_wait_response);
2700}
2701
1999bd52 2702static int hostIFthread(void *pvArg)
c5c77ba1 2703{
4e4467fd 2704 u32 u32Ret;
143eb95a 2705 struct host_if_msg msg;
00215dde 2706 struct wilc *wilc = (struct wilc*)pvArg;
cf60106b 2707 struct wilc_vif *vif;
c5c77ba1 2708
143eb95a 2709 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1
JK
2710
2711 while (1) {
cb067dcf 2712 wilc_mq_recv(&hif_msg_q, &msg, sizeof(struct host_if_msg), &u32Ret);
cf60106b 2713 vif = msg.vif;
a9f812a6 2714 if (msg.id == HOST_IF_MSG_EXIT) {
c5c77ba1
JK
2715 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
2716 break;
2717 }
2718
0e1af73d 2719 if ((!wilc_initialized)) {
c5c77ba1 2720 PRINT_D(GENERIC_DBG, "--WAIT--");
80e29c7a 2721 usleep_range(200 * 1000, 200 * 1000);
cb067dcf 2722 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
c5c77ba1
JK
2723 continue;
2724 }
2725
91109e11 2726 if (msg.id == HOST_IF_MSG_CONNECT &&
b13584a8 2727 vif->hif_drv->usr_scan_req.scan_result) {
cb067dcf 2728 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
80e29c7a 2729 usleep_range(2 * 1000, 2 * 1000);
c5c77ba1
JK
2730 continue;
2731 }
2732
a9f812a6 2733 switch (msg.id) {
c5c77ba1
JK
2734 case HOST_IF_MSG_Q_IDLE:
2735 Handle_wait_msg_q_empty();
2736 break;
2737
2738 case HOST_IF_MSG_SCAN:
71130e81 2739 Handle_Scan(msg.vif, &msg.body.scan_info);
c5c77ba1
JK
2740 break;
2741
2742 case HOST_IF_MSG_CONNECT:
71130e81 2743 Handle_Connect(msg.vif, &msg.body.con_info);
c5c77ba1
JK
2744 break;
2745
c5c77ba1 2746 case HOST_IF_MSG_FLUSH_CONNECT:
71130e81 2747 Handle_FlushConnect(msg.vif);
c5c77ba1
JK
2748 break;
2749
2750 case HOST_IF_MSG_RCVD_NTWRK_INFO:
71130e81 2751 Handle_RcvdNtwrkInfo(msg.vif, &msg.body.net_info);
c5c77ba1
JK
2752 break;
2753
2754 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
71130e81 2755 Handle_RcvdGnrlAsyncInfo(vif,
cf60106b 2756 &msg.body.async_info);
c5c77ba1
JK
2757 break;
2758
2759 case HOST_IF_MSG_KEY:
71130e81 2760 Handle_Key(msg.vif, &msg.body.key_info);
c5c77ba1
JK
2761 break;
2762
2763 case HOST_IF_MSG_CFG_PARAMS:
71130e81 2764 handle_cfg_param(msg.vif, &msg.body.cfg_info);
c5c77ba1
JK
2765 break;
2766
2767 case HOST_IF_MSG_SET_CHANNEL:
71130e81 2768 handle_set_channel(msg.vif, &msg.body.channel_info);
c5c77ba1
JK
2769 break;
2770
2771 case HOST_IF_MSG_DISCONNECT:
71130e81 2772 Handle_Disconnect(msg.vif);
c5c77ba1
JK
2773 break;
2774
2775 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
b13584a8 2776 del_timer(&vif->hif_drv->scan_timer);
c5c77ba1 2777
825b966f 2778 if (!wilc_wlan_get_num_conn_ifcs(wilc))
00215dde 2779 wilc_chip_sleep_manually(wilc);
c5c77ba1 2780
71130e81 2781 Handle_ScanDone(msg.vif, SCAN_EVENT_DONE);
c5c77ba1 2782
b13584a8 2783 if (vif->hif_drv->remain_on_ch_pending)
71130e81
GL
2784 Handle_RemainOnChan(msg.vif,
2785 &msg.body.remain_on_ch);
c5c77ba1
JK
2786
2787 break;
2788
2789 case HOST_IF_MSG_GET_RSSI:
71130e81 2790 Handle_GetRssi(msg.vif);
c5c77ba1
JK
2791 break;
2792
2793 case HOST_IF_MSG_GET_LINKSPEED:
71130e81 2794 Handle_GetLinkspeed(msg.vif);
c5c77ba1
JK
2795 break;
2796
2797 case HOST_IF_MSG_GET_STATISTICS:
71130e81
GL
2798 Handle_GetStatistics(msg.vif,
2799 (struct rf_info *)msg.body.data);
c5c77ba1
JK
2800 break;
2801
2802 case HOST_IF_MSG_GET_CHNL:
71130e81 2803 Handle_GetChnl(msg.vif);
c5c77ba1
JK
2804 break;
2805
c5c77ba1 2806 case HOST_IF_MSG_ADD_BEACON:
71130e81 2807 Handle_AddBeacon(msg.vif, &msg.body.beacon_info);
c5c77ba1
JK
2808 break;
2809
2810 case HOST_IF_MSG_DEL_BEACON:
71130e81 2811 Handle_DelBeacon(msg.vif);
c5c77ba1
JK
2812 break;
2813
2814 case HOST_IF_MSG_ADD_STATION:
71130e81 2815 Handle_AddStation(msg.vif, &msg.body.add_sta_info);
c5c77ba1
JK
2816 break;
2817
2818 case HOST_IF_MSG_DEL_STATION:
71130e81 2819 Handle_DelStation(msg.vif, &msg.body.del_sta_info);
c5c77ba1
JK
2820 break;
2821
2822 case HOST_IF_MSG_EDIT_STATION:
71130e81 2823 Handle_EditStation(msg.vif, &msg.body.edit_sta_info);
c5c77ba1
JK
2824 break;
2825
2826 case HOST_IF_MSG_GET_INACTIVETIME:
71130e81 2827 Handle_Get_InActiveTime(msg.vif, &msg.body.mac_info);
c5c77ba1
JK
2828 break;
2829
c5c77ba1 2830 case HOST_IF_MSG_SCAN_TIMER_FIRED:
c5c77ba1 2831
71130e81 2832 Handle_ScanDone(msg.vif, SCAN_EVENT_ABORTED);
c5c77ba1
JK
2833 break;
2834
2835 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
71130e81 2836 Handle_ConnectTimeout(msg.vif);
c5c77ba1
JK
2837 break;
2838
2839 case HOST_IF_MSG_POWER_MGMT:
71130e81
GL
2840 Handle_PowerManagement(msg.vif,
2841 &msg.body.pwr_mgmt_info);
c5c77ba1
JK
2842 break;
2843
2844 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
71130e81 2845 handle_set_wfi_drv_handler(msg.vif, &msg.body.drv);
c5c77ba1
JK
2846 break;
2847
2848 case HOST_IF_MSG_SET_OPERATION_MODE:
71130e81 2849 handle_set_operation_mode(msg.vif, &msg.body.mode);
c5c77ba1
JK
2850 break;
2851
2852 case HOST_IF_MSG_SET_IPADDRESS:
71130e81 2853 handle_set_ip_address(vif,
a6e6d48b
LK
2854 msg.body.ip_info.ip_addr,
2855 msg.body.ip_info.idx);
c5c77ba1
JK
2856 break;
2857
2858 case HOST_IF_MSG_GET_IPADDRESS:
71130e81 2859 handle_get_ip_address(vif, msg.body.ip_info.idx);
c5c77ba1
JK
2860 break;
2861
c5c77ba1 2862 case HOST_IF_MSG_SET_MAC_ADDRESS:
71130e81 2863 handle_set_mac_address(msg.vif,
a8267421 2864 &msg.body.set_mac_info);
c5c77ba1
JK
2865 break;
2866
c5c77ba1 2867 case HOST_IF_MSG_GET_MAC_ADDRESS:
71130e81 2868 handle_get_mac_address(msg.vif,
b3bf8fd9 2869 &msg.body.get_mac_info);
c5c77ba1
JK
2870 break;
2871
c5c77ba1 2872 case HOST_IF_MSG_REMAIN_ON_CHAN:
71130e81 2873 Handle_RemainOnChan(msg.vif, &msg.body.remain_on_ch);
c5c77ba1
JK
2874 break;
2875
2876 case HOST_IF_MSG_REGISTER_FRAME:
71130e81 2877 Handle_RegisterFrame(msg.vif, &msg.body.reg_frame);
c5c77ba1
JK
2878 break;
2879
2880 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
71130e81 2881 Handle_ListenStateExpired(msg.vif, &msg.body.remain_on_ch);
c5c77ba1
JK
2882 break;
2883
c5c77ba1 2884 case HOST_IF_MSG_SET_MULTICAST_FILTER:
71130e81 2885 Handle_SetMulticastFilter(msg.vif, &msg.body.multicast_info);
c5c77ba1
JK
2886 break;
2887
c5c77ba1 2888 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
71130e81 2889 Handle_DelAllRxBASessions(msg.vif, &msg.body.session_info);
c5c77ba1
JK
2890 break;
2891
2892 case HOST_IF_MSG_DEL_ALL_STA:
71130e81 2893 Handle_DelAllSta(msg.vif, &msg.body.del_all_sta_info);
c5c77ba1
JK
2894 break;
2895
70418790
GL
2896 case HOST_IF_MSG_SET_TX_POWER:
2897 handle_set_tx_pwr(msg.vif, msg.body.tx_power.tx_pwr);
2898 break;
2899
2900 case HOST_IF_MSG_GET_TX_POWER:
2901 handle_get_tx_pwr(msg.vif, &msg.body.tx_power.tx_pwr);
2902 break;
c5c77ba1 2903 default:
03b2d5e7 2904 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
c5c77ba1
JK
2905 break;
2906 }
2907 }
2908
834e0cb0 2909 up(&hif_sema_thread);
1999bd52 2910 return 0;
c5c77ba1
JK
2911}
2912
93dee8ee 2913static void TimerCB_Scan(unsigned long arg)
c5c77ba1 2914{
71130e81 2915 struct wilc_vif *vif = (struct wilc_vif *)arg;
143eb95a 2916 struct host_if_msg msg;
c5c77ba1 2917
143eb95a 2918 memset(&msg, 0, sizeof(struct host_if_msg));
71130e81 2919 msg.vif = vif;
a9f812a6 2920 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
c5c77ba1 2921
cb067dcf 2922 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
c5c77ba1
JK
2923}
2924
93dee8ee 2925static void TimerCB_Connect(unsigned long arg)
c5c77ba1 2926{
71130e81 2927 struct wilc_vif *vif = (struct wilc_vif *)arg;
143eb95a 2928 struct host_if_msg msg;
c5c77ba1 2929
143eb95a 2930 memset(&msg, 0, sizeof(struct host_if_msg));
71130e81 2931 msg.vif = vif;
a9f812a6 2932 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
c5c77ba1 2933
cb067dcf 2934 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
c5c77ba1
JK
2935}
2936
0e1af73d 2937s32 wilc_remove_key(struct host_if_drv *hif_drv, const u8 *pu8StaAddress)
c5c77ba1 2938{
45102f83 2939 struct wid wid;
c5c77ba1 2940
45102f83
LK
2941 wid.id = (u16)WID_REMOVE_KEY;
2942 wid.type = WID_STR;
2943 wid.val = (s8 *)pu8StaAddress;
2944 wid.size = 6;
c5c77ba1 2945
b68d820b 2946 return 0;
c5c77ba1
JK
2947}
2948
fbf5379b 2949int wilc_remove_wep_key(struct wilc_vif *vif, u8 index)
c5c77ba1 2950{
9e5e8b44 2951 int result = 0;
143eb95a 2952 struct host_if_msg msg;
fbf5379b 2953 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 2954
a4ab1ade 2955 if (!hif_drv) {
9e5e8b44 2956 result = -EFAULT;
24db713f 2957 PRINT_ER("Failed to send setup multicast config packet\n");
9e5e8b44 2958 return result;
24db713f 2959 }
c5c77ba1 2960
143eb95a 2961 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1 2962
a9f812a6 2963 msg.id = HOST_IF_MSG_KEY;
8e9f427a 2964 msg.body.key_info.type = WEP;
0d17e382 2965 msg.body.key_info.action = REMOVEKEY;
cf60106b 2966 msg.vif = vif;
73b2e381 2967 msg.body.key_info.attr.wep.index = index;
c5c77ba1 2968
cb067dcf 2969 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
9e5e8b44 2970 if (result)
03b2d5e7 2971 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
9ea47133 2972 down(&hif_drv->sem_test_key_block);
c5c77ba1 2973
9e5e8b44 2974 return result;
c5c77ba1
JK
2975}
2976
fbf5379b 2977int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index)
c5c77ba1 2978{
5b41c7c9 2979 int result = 0;
143eb95a 2980 struct host_if_msg msg;
fbf5379b 2981 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 2982
a4ab1ade 2983 if (!hif_drv) {
31390eec 2984 result = -EFAULT;
24db713f 2985 PRINT_ER("driver is null\n");
31390eec 2986 return result;
24db713f 2987 }
c5c77ba1 2988
143eb95a 2989 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1 2990
a9f812a6 2991 msg.id = HOST_IF_MSG_KEY;
8e9f427a 2992 msg.body.key_info.type = WEP;
0d17e382 2993 msg.body.key_info.action = DEFAULTKEY;
cf60106b 2994 msg.vif = vif;
e91d0349 2995 msg.body.key_info.attr.wep.index = index;
c5c77ba1 2996
31390eec
LK
2997 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2998 if (result)
c5c77ba1 2999 PRINT_ER("Error in sending message queue : Default key index\n");
9ea47133 3000 down(&hif_drv->sem_test_key_block);
c5c77ba1 3001
31390eec 3002 return result;
c5c77ba1
JK
3003}
3004
fbf5379b
GL
3005int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len,
3006 u8 index)
c5c77ba1 3007{
66b8cb89 3008 int result = 0;
143eb95a 3009 struct host_if_msg msg;
fbf5379b 3010 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 3011
a4ab1ade 3012 if (!hif_drv) {
24db713f 3013 PRINT_ER("driver is null\n");
77178807 3014 return -EFAULT;
24db713f 3015 }
c5c77ba1 3016
143eb95a 3017 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1 3018
a9f812a6 3019 msg.id = HOST_IF_MSG_KEY;
8e9f427a 3020 msg.body.key_info.type = WEP;
0d17e382 3021 msg.body.key_info.action = ADDKEY;
cf60106b 3022 msg.vif = vif;
1cc0c328
CL
3023 msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
3024 if (!msg.body.key_info.attr.wep.key)
3025 return -ENOMEM;
3026
dbc53194 3027 msg.body.key_info.attr.wep.key_len = len;
0b2cc3e5 3028 msg.body.key_info.attr.wep.index = index;
c5c77ba1 3029
31390eec
LK
3030 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3031 if (result)
c5c77ba1 3032 PRINT_ER("Error in sending message queue :WEP Key\n");
9ea47133 3033 down(&hif_drv->sem_test_key_block);
c5c77ba1 3034
31390eec 3035 return result;
c5c77ba1
JK
3036}
3037
fbf5379b
GL
3038int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len,
3039 u8 index, u8 mode, enum AUTHTYPE auth_type)
c5c77ba1 3040{
641c20a6 3041 int result = 0;
143eb95a 3042 struct host_if_msg msg;
fbf5379b 3043 struct host_if_drv *hif_drv = vif->hif_drv;
fd741461 3044 int i;
c5c77ba1 3045
a4ab1ade 3046 if (!hif_drv) {
24db713f 3047 PRINT_ER("driver is null\n");
77178807 3048 return -EFAULT;
24db713f 3049 }
c5c77ba1 3050
143eb95a 3051 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1
JK
3052
3053 if (INFO) {
a5389b07 3054 for (i = 0; i < len; i++)
8111725a 3055 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", key[i]);
c5c77ba1 3056 }
a9f812a6 3057 msg.id = HOST_IF_MSG_KEY;
8e9f427a 3058 msg.body.key_info.type = WEP;
0d17e382 3059 msg.body.key_info.action = ADDKEY_AP;
cf60106b 3060 msg.vif = vif;
58eabd68
CL
3061 msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
3062 if (!msg.body.key_info.attr.wep.key)
3063 return -ENOMEM;
3064
a5389b07 3065 msg.body.key_info.attr.wep.key_len = len;
a76dc953 3066 msg.body.key_info.attr.wep.index = index;
730a28da 3067 msg.body.key_info.attr.wep.mode = mode;
ff3bce2f 3068 msg.body.key_info.attr.wep.auth_type = auth_type;
ae4dfa57 3069
31390eec 3070 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
c5c77ba1 3071
31390eec 3072 if (result)
c5c77ba1 3073 PRINT_ER("Error in sending message queue :WEP Key\n");
9ea47133 3074 down(&hif_drv->sem_test_key_block);
c5c77ba1 3075
31390eec 3076 return result;
c5c77ba1 3077}
108b3439 3078
fbf5379b
GL
3079int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
3080 const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
3081 u8 mode, u8 cipher_mode, u8 index)
c5c77ba1 3082{
706ab42e 3083 int result = 0;
143eb95a 3084 struct host_if_msg msg;
fbf5379b 3085 struct host_if_drv *hif_drv = vif->hif_drv;
53bbbb57 3086 u8 key_len = ptk_key_len;
fa269074 3087 int i;
78c87591 3088
a4ab1ade 3089 if (!hif_drv) {
24db713f 3090 PRINT_ER("driver is null\n");
77178807 3091 return -EFAULT;
24db713f 3092 }
91109e11 3093
38f66290 3094 if (rx_mic)
53bbbb57 3095 key_len += RX_MIC_KEY_LEN;
91109e11 3096
d7c0242b 3097 if (tx_mic)
53bbbb57 3098 key_len += TX_MIC_KEY_LEN;
c5c77ba1 3099
143eb95a 3100 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1 3101
a9f812a6 3102 msg.id = HOST_IF_MSG_KEY;
2141fe39 3103 msg.body.key_info.type = WPA_PTK;
c5c77ba1 3104 if (mode == AP_MODE) {
0d17e382 3105 msg.body.key_info.action = ADDKEY_AP;
3e5c4ab6 3106 msg.body.key_info.attr.wpa.index = index;
c5c77ba1 3107 }
c5c77ba1 3108 if (mode == STATION_MODE)
0d17e382 3109 msg.body.key_info.action = ADDKEY;
c5c77ba1 3110
8ab8c592
CL
3111 msg.body.key_info.attr.wpa.key = kmemdup(ptk, ptk_key_len, GFP_KERNEL);
3112 if (!msg.body.key_info.attr.wpa.key)
3113 return -ENOMEM;
c5c77ba1 3114
38f66290
CL
3115 if (rx_mic) {
3116 memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic, RX_MIC_KEY_LEN);
c5c77ba1
JK
3117 if (INFO) {
3118 for (i = 0; i < RX_MIC_KEY_LEN; i++)
38f66290 3119 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, rx_mic[i]);
c5c77ba1
JK
3120 }
3121 }
d7c0242b
CL
3122 if (tx_mic) {
3123 memcpy(msg.body.key_info.attr.wpa.key + 24, tx_mic, TX_MIC_KEY_LEN);
c5c77ba1
JK
3124 if (INFO) {
3125 for (i = 0; i < TX_MIC_KEY_LEN; i++)
d7c0242b 3126 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, tx_mic[i]);
c5c77ba1
JK
3127 }
3128 }
3129
53bbbb57 3130 msg.body.key_info.attr.wpa.key_len = key_len;
248080aa 3131 msg.body.key_info.attr.wpa.mac_addr = mac_addr;
f0c82579 3132 msg.body.key_info.attr.wpa.mode = cipher_mode;
cf60106b 3133 msg.vif = vif;
c5c77ba1 3134
31390eec 3135 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
c5c77ba1 3136
31390eec 3137 if (result)
c5c77ba1
JK
3138 PRINT_ER("Error in sending message queue: PTK Key\n");
3139
9ea47133 3140 down(&hif_drv->sem_test_key_block);
c5c77ba1 3141
31390eec 3142 return result;
c5c77ba1
JK
3143}
3144
fbf5379b
GL
3145int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
3146 u8 index, u32 key_rsc_len, const u8 *key_rsc,
3147 const u8 *rx_mic, const u8 *tx_mic, u8 mode,
3148 u8 cipher_mode)
c5c77ba1 3149{
1503457f 3150 int result = 0;
143eb95a 3151 struct host_if_msg msg;
fbf5379b 3152 struct host_if_drv *hif_drv = vif->hif_drv;
d002fcc0 3153 u8 key_len = gtk_key_len;
c5c77ba1 3154
a4ab1ade 3155 if (!hif_drv) {
24db713f 3156 PRINT_ER("driver is null\n");
77178807 3157 return -EFAULT;
24db713f 3158 }
143eb95a 3159 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1 3160
6d36c273 3161 if (rx_mic)
d002fcc0 3162 key_len += RX_MIC_KEY_LEN;
91109e11 3163
2f79758d 3164 if (tx_mic)
d002fcc0 3165 key_len += TX_MIC_KEY_LEN;
91109e11 3166
982859cc 3167 if (key_rsc) {
9bfda382
CL
3168 msg.body.key_info.attr.wpa.seq = kmemdup(key_rsc,
3169 key_rsc_len,
3170 GFP_KERNEL);
3171 if (!msg.body.key_info.attr.wpa.seq)
3172 return -ENOMEM;
c5c77ba1
JK
3173 }
3174
a9f812a6 3175 msg.id = HOST_IF_MSG_KEY;
5cd8f7ae 3176 msg.body.key_info.type = WPA_RX_GTK;
cf60106b 3177 msg.vif = vif;
c5c77ba1 3178
c5c77ba1 3179 if (mode == AP_MODE) {
0d17e382 3180 msg.body.key_info.action = ADDKEY_AP;
57bfcbc4 3181 msg.body.key_info.attr.wpa.mode = cipher_mode;
c5c77ba1 3182 }
c5c77ba1 3183 if (mode == STATION_MODE)
0d17e382 3184 msg.body.key_info.action = ADDKEY;
c5c77ba1 3185
9bfda382
CL
3186 msg.body.key_info.attr.wpa.key = kmemdup(rx_gtk,
3187 key_len,
3188 GFP_KERNEL);
3189 if (!msg.body.key_info.attr.wpa.key)
3190 return -ENOMEM;
c5c77ba1 3191
6d36c273
CL
3192 if (rx_mic)
3193 memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic,
d1666e2a 3194 RX_MIC_KEY_LEN);
91109e11 3195
2f79758d
CL
3196 if (tx_mic)
3197 memcpy(msg.body.key_info.attr.wpa.key + 24, tx_mic,
d1666e2a 3198 TX_MIC_KEY_LEN);
c5c77ba1 3199
9a5e5736 3200 msg.body.key_info.attr.wpa.index = index;
d002fcc0 3201 msg.body.key_info.attr.wpa.key_len = key_len;
18bef999 3202 msg.body.key_info.attr.wpa.seq_len = key_rsc_len;
c5c77ba1 3203
31390eec
LK
3204 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3205 if (result)
c5c77ba1 3206 PRINT_ER("Error in sending message queue: RX GTK\n");
ae4dfa57 3207
9ea47133 3208 down(&hif_drv->sem_test_key_block);
c5c77ba1 3209
31390eec 3210 return result;
c5c77ba1 3211}
c5c77ba1 3212
1ab58705 3213int wilc_set_pmkid_info(struct wilc_vif *vif,
16c0cba7 3214 struct host_if_pmkid_attr *pmkid)
c5c77ba1 3215{
1ab58705 3216 int result = 0;
143eb95a 3217 struct host_if_msg msg;
fbf5379b 3218 struct host_if_drv *hif_drv = vif->hif_drv;
89dec139 3219 int i;
c5c77ba1 3220
a4ab1ade 3221 if (!hif_drv) {
24db713f 3222 PRINT_ER("driver is null\n");
77178807 3223 return -EFAULT;
24db713f 3224 }
c5c77ba1 3225
143eb95a 3226 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1 3227
a9f812a6 3228 msg.id = HOST_IF_MSG_KEY;
8e9f427a 3229 msg.body.key_info.type = PMKSA;
0d17e382 3230 msg.body.key_info.action = ADDKEY;
cf60106b 3231 msg.vif = vif;
c5c77ba1 3232
16c0cba7 3233 for (i = 0; i < pmkid->numpmkid; i++) {
8c8360b3 3234 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].bssid,
16c0cba7 3235 &pmkid->pmkidlist[i].bssid, ETH_ALEN);
8c8360b3 3236 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].pmkid,
16c0cba7 3237 &pmkid->pmkidlist[i].pmkid, PMKID_LEN);
c5c77ba1
JK
3238 }
3239
31390eec
LK
3240 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3241 if (result)
c5c77ba1
JK
3242 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
3243
31390eec 3244 return result;
c5c77ba1
JK
3245}
3246
1eabfe3f 3247int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr)
c5c77ba1 3248{
dcb15a08 3249 int result = 0;
143eb95a 3250 struct host_if_msg msg;
c5c77ba1 3251
143eb95a 3252 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1 3253
a9f812a6 3254 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
1eabfe3f 3255 msg.body.get_mac_info.mac_addr = mac_addr;
cf60106b 3256 msg.vif = vif;
ae4dfa57 3257
31390eec
LK
3258 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3259 if (result) {
c5c77ba1 3260 PRINT_ER("Failed to send get mac address\n");
e6e12661 3261 return -EFAULT;
c5c77ba1
JK
3262 }
3263
2d25af87 3264 down(&hif_sema_wait_response);
31390eec 3265 return result;
c5c77ba1
JK
3266}
3267
f2cb5f3f 3268int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid,
8c38d960 3269 size_t ssid_len, const u8 *ies, size_t ies_len,
2ef29833 3270 wilc_connect_result connect_result, void *user_arg,
12a3b8bc 3271 u8 security, enum AUTHTYPE auth_type,
f382b376 3272 u8 channel, void *join_params)
c5c77ba1 3273{
0a285b27 3274 int result = 0;
143eb95a 3275 struct host_if_msg msg;
fbf5379b 3276 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 3277
81c23a7e 3278 if (!hif_drv || !connect_result) {
24db713f 3279 PRINT_ER("Driver is null\n");
77178807 3280 return -EFAULT;
24db713f 3281 }
c5c77ba1 3282
f382b376 3283 if (!join_params) {
c5c77ba1 3284 PRINT_ER("Unable to Join - JoinParams is NULL\n");
24db713f 3285 return -EFAULT;
c5c77ba1 3286 }
24db713f 3287
143eb95a 3288 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1 3289
a9f812a6 3290 msg.id = HOST_IF_MSG_CONNECT;
c5c77ba1 3291
e0c54a88 3292 msg.body.con_info.security = security;
12a3b8bc 3293 msg.body.con_info.auth_type = auth_type;
0ea1ece0 3294 msg.body.con_info.ch = channel;
81c23a7e 3295 msg.body.con_info.result = connect_result;
2ef29833 3296 msg.body.con_info.arg = user_arg;
f382b376 3297 msg.body.con_info.params = join_params;
cf60106b 3298 msg.vif = vif;
c5c77ba1 3299
16a537ca 3300 if (bssid) {
11623136
CL
3301 msg.body.con_info.bssid = kmemdup(bssid, 6, GFP_KERNEL);
3302 if (!msg.body.con_info.bssid)
3303 return -ENOMEM;
c5c77ba1
JK
3304 }
3305
f2cb5f3f 3306 if (ssid) {
dee39b1b 3307 msg.body.con_info.ssid_len = ssid_len;
11623136
CL
3308 msg.body.con_info.ssid = kmemdup(ssid, ssid_len, GFP_KERNEL);
3309 if (!msg.body.con_info.ssid)
3310 return -ENOMEM;
c5c77ba1
JK
3311 }
3312
88c9421a 3313 if (ies) {
8c38d960 3314 msg.body.con_info.ies_len = ies_len;
11623136
CL
3315 msg.body.con_info.ies = kmemdup(ies, ies_len, GFP_KERNEL);
3316 if (!msg.body.con_info.ies)
3317 return -ENOMEM;
c5c77ba1 3318 }
b60005a8
LK
3319 if (hif_drv->hif_state < HOST_IF_CONNECTING)
3320 hif_drv->hif_state = HOST_IF_CONNECTING;
78174ada 3321 else
b60005a8
LK
3322 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' : %d\n",
3323 hif_drv->hif_state);
c5c77ba1 3324
31390eec
LK
3325 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3326 if (result) {
c5c77ba1 3327 PRINT_ER("Failed to send message queue: Set join request\n");
24db713f 3328 return -EFAULT;
c5c77ba1
JK
3329 }
3330
71130e81 3331 hif_drv->connect_timer.data = (unsigned long)vif;
81a59506 3332 mod_timer(&hif_drv->connect_timer,
9eb06643 3333 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
c5c77ba1 3334
31390eec 3335 return result;
c5c77ba1
JK
3336}
3337
9f723fde 3338int wilc_disconnect(struct wilc_vif *vif, u16 reason_code)
c5c77ba1 3339{
5350251a 3340 int result = 0;
143eb95a 3341 struct host_if_msg msg;
fbf5379b 3342 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 3343
a4ab1ade 3344 if (!hif_drv) {
24db713f
LK
3345 PRINT_ER("Driver is null\n");
3346 return -EFAULT;
c5c77ba1
JK
3347 }
3348
143eb95a 3349 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1 3350
a9f812a6 3351 msg.id = HOST_IF_MSG_DISCONNECT;
cf60106b 3352 msg.vif = vif;
c5c77ba1 3353
31390eec
LK
3354 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3355 if (result)
c5c77ba1 3356 PRINT_ER("Failed to send message queue: disconnect\n");
ae4dfa57 3357
e55e4967 3358 down(&hif_drv->sem_test_disconn_block);
c5c77ba1 3359
31390eec 3360 return result;
c5c77ba1
JK
3361}
3362
71130e81 3363static s32 host_int_get_assoc_res_info(struct wilc_vif *vif,
1608c403
AB
3364 u8 *pu8AssocRespInfo,
3365 u32 u32MaxAssocRespInfoLen,
3366 u32 *pu32RcvdAssocRespInfoLen)
c5c77ba1 3367{
31390eec 3368 s32 result = 0;
45102f83 3369 struct wid wid;
71130e81 3370 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 3371
a4ab1ade 3372 if (!hif_drv) {
24db713f
LK
3373 PRINT_ER("Driver is null\n");
3374 return -EFAULT;
c5c77ba1
JK
3375 }
3376
45102f83
LK
3377 wid.id = (u16)WID_ASSOC_RES_INFO;
3378 wid.type = WID_STR;
3379 wid.val = pu8AssocRespInfo;
3380 wid.size = u32MaxAssocRespInfoLen;
c5c77ba1 3381
79df6a49 3382 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
4cf93d70 3383 wilc_get_vif_idx(vif));
31390eec 3384 if (result) {
c5c77ba1 3385 *pu32RcvdAssocRespInfoLen = 0;
24db713f
LK
3386 PRINT_ER("Failed to send association response config packet\n");
3387 return -EINVAL;
c5c77ba1 3388 } else {
45102f83 3389 *pu32RcvdAssocRespInfoLen = wid.size;
c5c77ba1
JK
3390 }
3391
31390eec 3392 return result;
c5c77ba1
JK
3393}
3394
fbf5379b 3395int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel)
c5c77ba1 3396{
792fb25b 3397 int result;
143eb95a 3398 struct host_if_msg msg;
fbf5379b 3399 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 3400
a4ab1ade 3401 if (!hif_drv) {
24db713f
LK
3402 PRINT_ER("driver is null\n");
3403 return -EFAULT;
3404 }
c5c77ba1 3405
143eb95a 3406 memset(&msg, 0, sizeof(struct host_if_msg));
a9f812a6 3407 msg.id = HOST_IF_MSG_SET_CHANNEL;
730ee059 3408 msg.body.channel_info.set_ch = channel;
cf60106b 3409 msg.vif = vif;
c5c77ba1 3410
cb067dcf 3411 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
1ef58e42 3412 if (result) {
24db713f 3413 PRINT_ER("wilc mq send fail\n");
792fb25b 3414 return -EINVAL;
c5c77ba1
JK
3415 }
3416
792fb25b 3417 return 0;
c5c77ba1
JK
3418}
3419
b3306865 3420int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mac_idx)
c5c77ba1 3421{
a094101c 3422 int result = 0;
143eb95a 3423 struct host_if_msg msg;
c09389ac 3424
143eb95a 3425 memset(&msg, 0, sizeof(struct host_if_msg));
a9f812a6 3426 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
31f0f697 3427 msg.body.drv.handler = index;
b3306865 3428 msg.body.drv.mac_idx = mac_idx;
cf60106b 3429 msg.vif = vif;
c5c77ba1 3430
cb067dcf 3431 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
a094101c 3432 if (result) {
24db713f 3433 PRINT_ER("wilc mq send fail\n");
a094101c 3434 result = -EINVAL;
c5c77ba1
JK
3435 }
3436
a094101c 3437 return result;
c5c77ba1
JK
3438}
3439
fbf5379b 3440int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode)
c5c77ba1 3441{
a0c1ee0c 3442 int result = 0;
143eb95a 3443 struct host_if_msg msg;
c09389ac 3444
143eb95a 3445 memset(&msg, 0, sizeof(struct host_if_msg));
a9f812a6 3446 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
c96debf1 3447 msg.body.mode.mode = mode;
cf60106b 3448 msg.vif = vif;
c5c77ba1 3449
cb067dcf 3450 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
a0c1ee0c 3451 if (result) {
24db713f 3452 PRINT_ER("wilc mq send fail\n");
a0c1ee0c 3453 result = -EINVAL;
c5c77ba1
JK
3454 }
3455
a0c1ee0c 3456 return result;
c5c77ba1
JK
3457}
3458
fbf5379b
GL
3459s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
3460 u32 *pu32InactiveTime)
c5c77ba1 3461{
31390eec 3462 s32 result = 0;
143eb95a 3463 struct host_if_msg msg;
fbf5379b 3464 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 3465
a4ab1ade 3466 if (!hif_drv) {
24db713f
LK
3467 PRINT_ER("driver is null\n");
3468 return -EFAULT;
c5c77ba1
JK
3469 }
3470
143eb95a 3471 memset(&msg, 0, sizeof(struct host_if_msg));
8c8360b3 3472 memcpy(msg.body.mac_info.mac, mac, ETH_ALEN);
c5c77ba1 3473
a9f812a6 3474 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
cf60106b 3475 msg.vif = vif;
c5c77ba1 3476
31390eec
LK
3477 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3478 if (result)
c5c77ba1
JK
3479 PRINT_ER("Failed to send get host channel param's message queue ");
3480
569a3c67 3481 down(&hif_drv->sem_inactive_time);
c5c77ba1 3482
ad26906f 3483 *pu32InactiveTime = inactive_time;
c5c77ba1 3484
31390eec 3485 return result;
c5c77ba1 3486}
108b3439 3487
652bb5e8 3488int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level)
c5c77ba1 3489{
e16aed64 3490 int result = 0;
143eb95a 3491 struct host_if_msg msg;
fbf5379b 3492 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 3493
c09389ac 3494 memset(&msg, 0, sizeof(struct host_if_msg));
a9f812a6 3495 msg.id = HOST_IF_MSG_GET_RSSI;
cf60106b 3496 msg.vif = vif;
c5c77ba1 3497
31390eec
LK
3498 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3499 if (result) {
c5c77ba1 3500 PRINT_ER("Failed to send get host channel param's message queue ");
e6e12661 3501 return -EFAULT;
c5c77ba1
JK
3502 }
3503
7e111f9e 3504 down(&hif_drv->sem_get_rssi);
c5c77ba1 3505
652bb5e8 3506 if (!rssi_level) {
c5c77ba1 3507 PRINT_ER("RSS pointer value is null");
e6e12661 3508 return -EFAULT;
c5c77ba1
JK
3509 }
3510
652bb5e8 3511 *rssi_level = rssi;
c5c77ba1 3512
31390eec 3513 return result;
c5c77ba1
JK
3514}
3515
f70b25ff 3516int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats)
c5c77ba1 3517{
cd163d32 3518 int result = 0;
143eb95a 3519 struct host_if_msg msg;
c5c77ba1 3520
c09389ac 3521 memset(&msg, 0, sizeof(struct host_if_msg));
a9f812a6 3522 msg.id = HOST_IF_MSG_GET_STATISTICS;
f70b25ff 3523 msg.body.data = (char *)stats;
cf60106b 3524 msg.vif = vif;
ae4dfa57 3525
31390eec
LK
3526 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3527 if (result) {
c5c77ba1 3528 PRINT_ER("Failed to send get host channel param's message queue ");
e6e12661 3529 return -EFAULT;
c5c77ba1
JK
3530 }
3531
4fd62291
GL
3532 if (stats != &vif->wilc->dummy_statistics)
3533 down(&hif_sema_wait_response);
31390eec 3534 return result;
c5c77ba1
JK
3535}
3536
c0734df9 3537int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
ce2d023f 3538 u8 *ch_freq_list, u8 ch_list_len, const u8 *ies,
2c97f2d4 3539 size_t ies_len, wilc_scan_result scan_result, void *user_arg,
d317818b 3540 struct hidden_network *hidden_network)
c5c77ba1 3541{
03a5d8c0 3542 int result = 0;
143eb95a 3543 struct host_if_msg msg;
fbf5379b 3544 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 3545
c8fb0bf9
CL
3546 if (!hif_drv || !scan_result) {
3547 PRINT_ER("hif_drv or scan_result = NULL\n");
24db713f
LK
3548 return -EFAULT;
3549 }
c5c77ba1 3550
143eb95a 3551 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1 3552
a9f812a6 3553 msg.id = HOST_IF_MSG_SCAN;
c5c77ba1 3554
d317818b
CL
3555 if (hidden_network) {
3556 msg.body.scan_info.hidden_network.net_info = hidden_network->net_info;
3557 msg.body.scan_info.hidden_network.n_ssids = hidden_network->n_ssids;
c4f97526 3558 }
c5c77ba1 3559
cf60106b 3560 msg.vif = vif;
3c2be65f 3561 msg.body.scan_info.src = scan_source;
c0734df9 3562 msg.body.scan_info.type = scan_type;
c8fb0bf9 3563 msg.body.scan_info.result = scan_result;
2c97f2d4 3564 msg.body.scan_info.arg = user_arg;
4528bdb5 3565
86163ec9 3566 msg.body.scan_info.ch_list_len = ch_list_len;
1a271d99
CL
3567 msg.body.scan_info.ch_freq_list = kmemdup(ch_freq_list,
3568 ch_list_len,
3569 GFP_KERNEL);
3570 if (!msg.body.scan_info.ch_freq_list)
3571 return -ENOMEM;
c5c77ba1 3572
6ca31901 3573 msg.body.scan_info.ies_len = ies_len;
1a271d99
CL
3574 msg.body.scan_info.ies = kmemdup(ies, ies_len, GFP_KERNEL);
3575 if (!msg.body.scan_info.ies)
3576 return -ENOMEM;
c5c77ba1 3577
31390eec
LK
3578 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3579 if (result) {
24db713f
LK
3580 PRINT_ER("Error in sending message queue\n");
3581 return -EINVAL;
c5c77ba1
JK
3582 }
3583
71130e81 3584 hif_drv->scan_timer.data = (unsigned long)vif;
13b313e4 3585 mod_timer(&hif_drv->scan_timer,
9eb06643 3586 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
c5c77ba1 3587
31390eec 3588 return result;
c5c77ba1 3589}
ae4dfa57 3590
fbf5379b
GL
3591s32 wilc_hif_set_cfg(struct wilc_vif *vif,
3592 struct cfg_param_val *pstrCfgParamVal)
c5c77ba1 3593{
31390eec 3594 s32 result = 0;
143eb95a 3595 struct host_if_msg msg;
fbf5379b 3596 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 3597
a4ab1ade
TC
3598 if (!hif_drv) {
3599 PRINT_ER("hif_drv NULL\n");
24db713f
LK
3600 return -EFAULT;
3601 }
ae4dfa57 3602
143eb95a 3603 memset(&msg, 0, sizeof(struct host_if_msg));
a9f812a6 3604 msg.id = HOST_IF_MSG_CFG_PARAMS;
221371e5 3605 msg.body.cfg_info.cfg_attr_info = *pstrCfgParamVal;
cf60106b 3606 msg.vif = vif;
c5c77ba1 3607
31390eec 3608 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
c5c77ba1 3609
31390eec 3610 return result;
c5c77ba1
JK
3611}
3612
93dee8ee 3613static void GetPeriodicRSSI(unsigned long arg)
c5c77ba1 3614{
71130e81 3615 struct wilc_vif *vif = (struct wilc_vif *)arg;
78c87591 3616
71130e81 3617 if (!vif->hif_drv) {
c5c77ba1
JK
3618 PRINT_ER("Driver handler is NULL\n");
3619 return;
3620 }
3621
4fd62291
GL
3622 if (vif->hif_drv->hif_state == HOST_IF_CONNECTED)
3623 wilc_get_statistics(vif, &vif->wilc->dummy_statistics);
c5c77ba1 3624
71130e81 3625 periodic_rssi.data = (unsigned long)vif;
262f55e1 3626 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
c5c77ba1
JK
3627}
3628
1e995c10 3629int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
c5c77ba1 3630{
1e995c10 3631 int result = 0;
a4ab1ade 3632 struct host_if_drv *hif_drv;
a4cac481 3633 struct wilc_vif *vif;
d5382219 3634 struct wilc *wilc;
03efae32 3635 int i;
d5382219 3636
a4cac481
GL
3637 vif = netdev_priv(dev);
3638 wilc = vif->wilc;
c5c77ba1 3639
ca8540e4 3640 scan_while_connected = false;
c5c77ba1 3641
2d25af87 3642 sema_init(&hif_sema_wait_response, 0);
c5c77ba1 3643
a4ab1ade
TC
3644 hif_drv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
3645 if (!hif_drv) {
5b09bd32 3646 result = -ENOMEM;
17db84eb 3647 goto _fail_;
c5c77ba1 3648 }
a4ab1ade 3649 *hif_drv_handler = hif_drv;
03efae32
GL
3650 for (i = 0; i < wilc->vif_num; i++)
3651 if (dev == wilc->vif[i]->ndev) {
3652 wilc->vif[i]->hif_drv = hif_drv;
3653 break;
3654 }
c5c77ba1 3655
0e1af73d 3656 wilc_optaining_ip = false;
c5c77ba1 3657
c5c77ba1 3658 if (clients_count == 0) {
834e0cb0 3659 sema_init(&hif_sema_thread, 0);
27ff2168 3660 sema_init(&hif_sema_driver, 0);
440e8993 3661 sema_init(&hif_sema_deinit, 1);
83383ea3
AB
3662 }
3663
9ea47133 3664 sema_init(&hif_drv->sem_test_key_block, 0);
e55e4967 3665 sema_init(&hif_drv->sem_test_disconn_block, 0);
7e111f9e 3666 sema_init(&hif_drv->sem_get_rssi, 0);
bc34da66 3667 sema_init(&hif_drv->sem_get_link_speed, 0);
4ea90008 3668 sema_init(&hif_drv->sem_get_chnl, 0);
569a3c67 3669 sema_init(&hif_drv->sem_inactive_time, 0);
c5c77ba1 3670
c5c77ba1 3671 if (clients_count == 0) {
cb067dcf 3672 result = wilc_mq_create(&hif_msg_q);
c5c77ba1 3673
5b09bd32 3674 if (result < 0) {
c5c77ba1
JK
3675 PRINT_ER("Failed to creat MQ\n");
3676 goto _fail_;
3677 }
c2115d8e 3678
d5382219
GL
3679 hif_thread_handler = kthread_run(hostIFthread, wilc,
3680 "WILC_kthread");
c2115d8e
LK
3681
3682 if (IS_ERR(hif_thread_handler)) {
c5c77ba1 3683 PRINT_ER("Failed to creat Thread\n");
5b09bd32 3684 result = -EFAULT;
c5c77ba1
JK
3685 goto _fail_mq_;
3686 }
262f55e1 3687 setup_timer(&periodic_rssi, GetPeriodicRSSI,
71130e81 3688 (unsigned long)vif);
262f55e1 3689 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
c5c77ba1
JK
3690 }
3691
13b313e4 3692 setup_timer(&hif_drv->scan_timer, TimerCB_Scan, 0);
81a59506 3693 setup_timer(&hif_drv->connect_timer, TimerCB_Connect, 0);
cc2d7e9e 3694 setup_timer(&hif_drv->remain_on_ch_timer, ListenTimerCB, 0);
c5c77ba1 3695
33110ad7
LK
3696 sema_init(&hif_drv->sem_cfg_values, 1);
3697 down(&hif_drv->sem_cfg_values);
c5c77ba1 3698
b60005a8 3699 hif_drv->hif_state = HOST_IF_IDLE;
ace303f0
LK
3700 hif_drv->cfg_values.site_survey_enabled = SITE_SURVEY_OFF;
3701 hif_drv->cfg_values.scan_source = DEFAULT_SCAN;
3702 hif_drv->cfg_values.active_scan_time = ACTIVE_SCAN_TIME;
3703 hif_drv->cfg_values.passive_scan_time = PASSIVE_SCAN_TIME;
3704 hif_drv->cfg_values.curr_tx_rate = AUTORATE;
c5c77ba1 3705
1229b1ab 3706 hif_drv->p2p_timeout = 0;
c5c77ba1 3707
33110ad7 3708 up(&hif_drv->sem_cfg_values);
c5c77ba1 3709
ae4dfa57 3710 clients_count++;
c5c77ba1 3711
5b09bd32 3712 return result;
c5c77ba1 3713
c5c77ba1 3714_fail_mq_:
cb067dcf 3715 wilc_mq_destroy(&hif_msg_q);
c5c77ba1 3716_fail_:
5b09bd32 3717 return result;
c5c77ba1 3718}
c5c77ba1 3719
fbf5379b 3720s32 wilc_deinit(struct wilc_vif *vif)
c5c77ba1 3721{
31390eec 3722 s32 result = 0;
143eb95a 3723 struct host_if_msg msg;
fbf5379b 3724 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 3725
a4ab1ade
TC
3726 if (!hif_drv) {
3727 PRINT_ER("hif_drv = NULL\n");
c5c77ba1
JK
3728 return 0;
3729 }
3730
440e8993 3731 down(&hif_sema_deinit);
c5c77ba1 3732
a4ab1ade 3733 terminated_handle = hif_drv;
c5c77ba1 3734
c4f97526
CP
3735 del_timer_sync(&hif_drv->scan_timer);
3736 del_timer_sync(&hif_drv->connect_timer);
3737 del_timer_sync(&periodic_rssi);
cc2d7e9e 3738 del_timer_sync(&hif_drv->remain_on_ch_timer);
c5c77ba1 3739
b3306865 3740 wilc_set_wfi_drv_handler(vif, 0, 0);
27ff2168 3741 down(&hif_sema_driver);
c5c77ba1 3742
bc801855
LK
3743 if (hif_drv->usr_scan_req.scan_result) {
3744 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, NULL,
66eaea30 3745 hif_drv->usr_scan_req.arg, NULL);
bc801855 3746 hif_drv->usr_scan_req.scan_result = NULL;
c5c77ba1 3747 }
c5c77ba1 3748
b60005a8 3749 hif_drv->hif_state = HOST_IF_IDLE;
c5c77ba1 3750
ca8540e4 3751 scan_while_connected = false;
c5c77ba1 3752
143eb95a 3753 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1
JK
3754
3755 if (clients_count == 1) {
c4f97526 3756 del_timer_sync(&periodic_rssi);
a9f812a6 3757 msg.id = HOST_IF_MSG_EXIT;
cf60106b 3758 msg.vif = vif;
c5c77ba1 3759
31390eec
LK
3760 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3761 if (result != 0)
3762 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", result);
c5c77ba1 3763
834e0cb0 3764 down(&hif_sema_thread);
c5c77ba1 3765
cb067dcf 3766 wilc_mq_destroy(&hif_msg_q);
c5c77ba1
JK
3767 }
3768
a4ab1ade 3769 kfree(hif_drv);
c5c77ba1 3770
ae4dfa57 3771 clients_count--;
b1413b60 3772 terminated_handle = NULL;
440e8993 3773 up(&hif_sema_deinit);
31390eec 3774 return result;
c5c77ba1
JK
3775}
3776
cd04d221
GL
3777void wilc_network_info_received(struct wilc *wilc, u8 *pu8Buffer,
3778 u32 u32Length)
c5c77ba1 3779{
31390eec 3780 s32 result = 0;
143eb95a 3781 struct host_if_msg msg;
d42ab083 3782 int id;
a4ab1ade 3783 struct host_if_drv *hif_drv = NULL;
eb9939b7 3784 struct wilc_vif *vif;
c5c77ba1 3785
d42ab083 3786 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
eb9939b7
GL
3787 vif = wilc_get_vif_from_idx(wilc, id);
3788 if (!vif)
3789 return;
3790 hif_drv = vif->hif_drv;
c5c77ba1 3791
a4ab1ade
TC
3792 if (!hif_drv || hif_drv == terminated_handle) {
3793 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv);
c5c77ba1
JK
3794 return;
3795 }
3796
143eb95a 3797 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1 3798
a9f812a6 3799 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
eb9939b7 3800 msg.vif = vif;
c5c77ba1 3801
3bffac68 3802 msg.body.net_info.len = u32Length;
b021b80b
LK
3803 msg.body.net_info.buffer = kmalloc(u32Length, GFP_KERNEL);
3804 memcpy(msg.body.net_info.buffer, pu8Buffer, u32Length);
c5c77ba1 3805
31390eec
LK
3806 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3807 if (result)
3808 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", result);
c5c77ba1
JK
3809}
3810
cd04d221
GL
3811void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *pu8Buffer,
3812 u32 u32Length)
c5c77ba1 3813{
31390eec 3814 s32 result = 0;
143eb95a 3815 struct host_if_msg msg;
d42ab083 3816 int id;
a4ab1ade 3817 struct host_if_drv *hif_drv = NULL;
eb9939b7 3818 struct wilc_vif *vif;
c5c77ba1 3819
440e8993 3820 down(&hif_sema_deinit);
c5c77ba1 3821
d42ab083 3822 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
eb9939b7
GL
3823 vif = wilc_get_vif_from_idx(wilc, id);
3824 if (!vif) {
3825 up(&hif_sema_deinit);
3826 return;
3827 }
3828
3829 hif_drv = vif->hif_drv;
c5c77ba1 3830
a4ab1ade 3831 if (!hif_drv || hif_drv == terminated_handle) {
440e8993 3832 up(&hif_sema_deinit);
c5c77ba1
JK
3833 return;
3834 }
3835
33bfb198 3836 if (!hif_drv->usr_conn_req.conn_result) {
c5c77ba1 3837 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
440e8993 3838 up(&hif_sema_deinit);
c5c77ba1
JK
3839 return;
3840 }
3841
143eb95a 3842 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1 3843
a9f812a6 3844 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
eb9939b7 3845 msg.vif = vif;
c5c77ba1 3846
f94f4889 3847 msg.body.async_info.len = u32Length;
33722ac7
LK
3848 msg.body.async_info.buffer = kmalloc(u32Length, GFP_KERNEL);
3849 memcpy(msg.body.async_info.buffer, pu8Buffer, u32Length);
c5c77ba1 3850
31390eec
LK
3851 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3852 if (result)
3853 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", result);
c5c77ba1 3854
440e8993 3855 up(&hif_sema_deinit);
c5c77ba1
JK
3856}
3857
cd04d221
GL
3858void wilc_scan_complete_received(struct wilc *wilc, u8 *pu8Buffer,
3859 u32 u32Length)
c5c77ba1 3860{
31390eec 3861 s32 result = 0;
143eb95a 3862 struct host_if_msg msg;
d42ab083 3863 int id;
a4ab1ade 3864 struct host_if_drv *hif_drv = NULL;
eb9939b7 3865 struct wilc_vif *vif;
78c87591 3866
d42ab083 3867 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
eb9939b7
GL
3868 vif = wilc_get_vif_from_idx(wilc, id);
3869 if (!vif)
3870 return;
3871 hif_drv = vif->hif_drv;
c5c77ba1 3872
a4ab1ade 3873 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", hif_drv);
c5c77ba1 3874
a4ab1ade 3875 if (!hif_drv || hif_drv == terminated_handle)
c5c77ba1 3876 return;
c5c77ba1 3877
bc801855 3878 if (hif_drv->usr_scan_req.scan_result) {
143eb95a 3879 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1 3880
a9f812a6 3881 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
eb9939b7 3882 msg.vif = vif;
c5c77ba1 3883
31390eec
LK
3884 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3885 if (result)
3886 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", result);
c5c77ba1
JK
3887 }
3888
c5c77ba1 3889 return;
c5c77ba1
JK
3890}
3891
6f7584be 3892int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id,
d44cd45e 3893 u32 duration, u16 chan,
95bfdd58 3894 wilc_remain_on_chan_expired expired,
1aae9398 3895 wilc_remain_on_chan_ready ready,
482c4330 3896 void *user_arg)
c5c77ba1 3897{
6d6bc400 3898 int result = 0;
143eb95a 3899 struct host_if_msg msg;
fbf5379b 3900 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 3901
a4ab1ade 3902 if (!hif_drv) {
24db713f
LK
3903 PRINT_ER("driver is null\n");
3904 return -EFAULT;
3905 }
c5c77ba1 3906
143eb95a 3907 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1 3908
a9f812a6 3909 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
839ab709 3910 msg.body.remain_on_ch.ch = chan;
95bfdd58 3911 msg.body.remain_on_ch.expired = expired;
1aae9398 3912 msg.body.remain_on_ch.ready = ready;
482c4330 3913 msg.body.remain_on_ch.arg = user_arg;
d44cd45e 3914 msg.body.remain_on_ch.duration = duration;
6f7584be 3915 msg.body.remain_on_ch.id = session_id;
cf60106b 3916 msg.vif = vif;
143eb95a 3917
31390eec
LK
3918 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3919 if (result)
24db713f 3920 PRINT_ER("wilc mq send fail\n");
c5c77ba1 3921
31390eec 3922 return result;
c5c77ba1
JK
3923}
3924
6b0f7cdd 3925int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id)
c5c77ba1 3926{
5ca581ef 3927 int result = 0;
143eb95a 3928 struct host_if_msg msg;
fbf5379b 3929 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 3930
a4ab1ade 3931 if (!hif_drv) {
24db713f
LK
3932 PRINT_ER("driver is null\n");
3933 return -EFAULT;
3934 }
c5c77ba1 3935
cc2d7e9e 3936 del_timer(&hif_drv->remain_on_ch_timer);
c5c77ba1 3937
143eb95a 3938 memset(&msg, 0, sizeof(struct host_if_msg));
a9f812a6 3939 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
cf60106b 3940 msg.vif = vif;
6b0f7cdd 3941 msg.body.remain_on_ch.id = session_id;
c5c77ba1 3942
31390eec
LK
3943 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3944 if (result)
24db713f 3945 PRINT_ER("wilc mq send fail\n");
c5c77ba1 3946
31390eec 3947 return result;
c5c77ba1
JK
3948}
3949
8859fc28 3950int wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg)
c5c77ba1 3951{
de61db9e 3952 int result = 0;
143eb95a 3953 struct host_if_msg msg;
fbf5379b 3954 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 3955
a4ab1ade 3956 if (!hif_drv) {
24db713f
LK
3957 PRINT_ER("driver is null\n");
3958 return -EFAULT;
3959 }
c5c77ba1 3960
143eb95a 3961 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1 3962
a9f812a6 3963 msg.id = HOST_IF_MSG_REGISTER_FRAME;
2a8432ff 3964 switch (frame_type) {
c5c77ba1 3965 case ACTION:
bcb410bb 3966 msg.body.reg_frame.reg_id = ACTION_FRM_IDX;
c5c77ba1
JK
3967 break;
3968
3969 case PROBE_REQ:
bcb410bb 3970 msg.body.reg_frame.reg_id = PROBE_REQ_IDX;
c5c77ba1
JK
3971 break;
3972
3973 default:
c5c77ba1
JK
3974 break;
3975 }
2a8432ff 3976 msg.body.reg_frame.frame_type = frame_type;
8859fc28 3977 msg.body.reg_frame.reg = reg;
cf60106b 3978 msg.vif = vif;
c5c77ba1 3979
31390eec
LK
3980 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3981 if (result)
24db713f 3982 PRINT_ER("wilc mq send fail\n");
c5c77ba1 3983
31390eec 3984 return result;
c5c77ba1 3985}
c5c77ba1 3986
916935f5 3987int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period,
733d1031 3988 u32 head_len, u8 *head, u32 tail_len, u8 *tail)
c5c77ba1 3989{
4d84dbed 3990 int result = 0;
143eb95a 3991 struct host_if_msg msg;
75bf22c1 3992 struct beacon_attr *beacon_info = &msg.body.beacon_info;
fbf5379b 3993 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 3994
a4ab1ade 3995 if (!hif_drv) {
24db713f
LK
3996 PRINT_ER("driver is null\n");
3997 return -EFAULT;
3998 }
c5c77ba1 3999
143eb95a 4000 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1 4001
a9f812a6 4002 msg.id = HOST_IF_MSG_ADD_BEACON;
cf60106b 4003 msg.vif = vif;
75bf22c1
CL
4004 beacon_info->interval = interval;
4005 beacon_info->dtim_period = dtim_period;
4006 beacon_info->head_len = head_len;
4007 beacon_info->head = kmemdup(head, head_len, GFP_KERNEL);
4008 if (!beacon_info->head) {
31390eec 4009 result = -ENOMEM;
24db713f
LK
4010 goto ERRORHANDLER;
4011 }
75bf22c1 4012 beacon_info->tail_len = tail_len;
c5c77ba1 4013
2df3585b 4014 if (tail_len > 0) {
75bf22c1
CL
4015 beacon_info->tail = kmemdup(tail, tail_len, GFP_KERNEL);
4016 if (!beacon_info->tail) {
31390eec 4017 result = -ENOMEM;
24db713f
LK
4018 goto ERRORHANDLER;
4019 }
c5c77ba1 4020 } else {
75bf22c1 4021 beacon_info->tail = NULL;
c5c77ba1
JK
4022 }
4023
31390eec
LK
4024 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4025 if (result)
24db713f 4026 PRINT_ER("wilc mq send fail\n");
c5c77ba1 4027
24db713f 4028ERRORHANDLER:
31390eec 4029 if (result) {
75bf22c1 4030 kfree(beacon_info->head);
c5c77ba1 4031
75bf22c1 4032 kfree(beacon_info->tail);
c5c77ba1
JK
4033 }
4034
31390eec 4035 return result;
c5c77ba1
JK
4036}
4037
fbf5379b 4038int wilc_del_beacon(struct wilc_vif *vif)
c5c77ba1 4039{
0a5298cb 4040 int result = 0;
143eb95a 4041 struct host_if_msg msg;
fbf5379b 4042 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 4043
a4ab1ade 4044 if (!hif_drv) {
24db713f
LK
4045 PRINT_ER("driver is null\n");
4046 return -EFAULT;
4047 }
c5c77ba1 4048
a9f812a6 4049 msg.id = HOST_IF_MSG_DEL_BEACON;
cf60106b 4050 msg.vif = vif;
c5c77ba1 4051
31390eec
LK
4052 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4053 if (result)
7dc1d0cc 4054 PRINT_ER("wilc_mq_send fail\n");
c5c77ba1 4055
31390eec 4056 return result;
c5c77ba1
JK
4057}
4058
fbf5379b 4059int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param)
c5c77ba1 4060{
18cfbd33 4061 int result = 0;
143eb95a 4062 struct host_if_msg msg;
773e02e6 4063 struct add_sta_param *add_sta_info = &msg.body.add_sta_info;
fbf5379b 4064 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 4065
a4ab1ade 4066 if (!hif_drv) {
24db713f
LK
4067 PRINT_ER("driver is null\n");
4068 return -EFAULT;
4069 }
c5c77ba1 4070
143eb95a 4071 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1 4072
a9f812a6 4073 msg.id = HOST_IF_MSG_ADD_STATION;
cf60106b 4074 msg.vif = vif;
c5c77ba1 4075
773e02e6
CL
4076 memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param));
4077 if (add_sta_info->rates_len > 0) {
9062305b
CL
4078 add_sta_info->rates = kmemdup(sta_param->rates,
4079 add_sta_info->rates_len,
4080 GFP_KERNEL);
4081 if (!add_sta_info->rates)
7ae43363 4082 return -ENOMEM;
c5c77ba1
JK
4083 }
4084
31390eec
LK
4085 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4086 if (result)
24db713f 4087 PRINT_ER("wilc_mq_send fail\n");
31390eec 4088 return result;
c5c77ba1
JK
4089}
4090
fbf5379b 4091int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr)
c5c77ba1 4092{
79a0c0a8 4093 int result = 0;
143eb95a 4094 struct host_if_msg msg;
c87fbede 4095 struct del_sta *del_sta_info = &msg.body.del_sta_info;
fbf5379b 4096 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 4097
a4ab1ade 4098 if (!hif_drv) {
24db713f
LK
4099 PRINT_ER("driver is null\n");
4100 return -EFAULT;
4101 }
c5c77ba1 4102
143eb95a 4103 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1 4104
a9f812a6 4105 msg.id = HOST_IF_MSG_DEL_STATION;
cf60106b 4106 msg.vif = vif;
c5c77ba1 4107
c9c4eb41 4108 if (!mac_addr)
c87fbede 4109 eth_broadcast_addr(del_sta_info->mac_addr);
c5c77ba1 4110 else
c87fbede 4111 memcpy(del_sta_info->mac_addr, mac_addr, ETH_ALEN);
c5c77ba1 4112
31390eec
LK
4113 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4114 if (result)
24db713f 4115 PRINT_ER("wilc_mq_send fail\n");
31390eec 4116 return result;
c5c77ba1 4117}
ae4dfa57 4118
2092374d 4119int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN])
c5c77ba1 4120{
253eb92e 4121 int result = 0;
143eb95a 4122 struct host_if_msg msg;
55d44a62 4123 struct del_all_sta *del_all_sta_info = &msg.body.del_all_sta_info;
fbf5379b 4124 struct host_if_drv *hif_drv = vif->hif_drv;
06e682b0 4125 u8 zero_addr[ETH_ALEN] = {0};
cc971eec 4126 int i;
9d6cec9f 4127 u8 assoc_sta = 0;
c5c77ba1 4128
a4ab1ade 4129 if (!hif_drv) {
24db713f
LK
4130 PRINT_ER("driver is null\n");
4131 return -EFAULT;
4132 }
c5c77ba1 4133
143eb95a 4134 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1 4135
a9f812a6 4136 msg.id = HOST_IF_MSG_DEL_ALL_STA;
cf60106b 4137 msg.vif = vif;
c5c77ba1 4138
c5c77ba1 4139 for (i = 0; i < MAX_NUM_STA; i++) {
06e682b0 4140 if (memcmp(mac_addr[i], zero_addr, ETH_ALEN)) {
55d44a62 4141 memcpy(del_all_sta_info->del_all_sta[i], mac_addr[i], ETH_ALEN);
e51b9216 4142 PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n",
55d44a62
CL
4143 del_all_sta_info->del_all_sta[i][0],
4144 del_all_sta_info->del_all_sta[i][1],
4145 del_all_sta_info->del_all_sta[i][2],
4146 del_all_sta_info->del_all_sta[i][3],
4147 del_all_sta_info->del_all_sta[i][4],
4148 del_all_sta_info->del_all_sta[i][5]);
9d6cec9f 4149 assoc_sta++;
c5c77ba1
JK
4150 }
4151 }
9d6cec9f 4152 if (!assoc_sta) {
c5c77ba1 4153 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
31390eec 4154 return result;
c5c77ba1
JK
4155 }
4156
9d6cec9f 4157 del_all_sta_info->assoc_sta = assoc_sta;
31390eec 4158 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
c5c77ba1 4159
31390eec 4160 if (result)
24db713f 4161 PRINT_ER("wilc_mq_send fail\n");
c5c77ba1 4162
2d25af87 4163 down(&hif_sema_wait_response);
c5c77ba1 4164
31390eec 4165 return result;
c5c77ba1
JK
4166}
4167
4208e663 4168int wilc_edit_station(struct wilc_vif *vif,
4c7abe19 4169 struct add_sta_param *sta_param)
c5c77ba1 4170{
4208e663 4171 int result = 0;
143eb95a 4172 struct host_if_msg msg;
785c0712 4173 struct add_sta_param *add_sta_info = &msg.body.add_sta_info;
fbf5379b 4174 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 4175
a4ab1ade 4176 if (!hif_drv) {
24db713f
LK
4177 PRINT_ER("driver is null\n");
4178 return -EFAULT;
4179 }
c5c77ba1 4180
143eb95a 4181 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1 4182
a9f812a6 4183 msg.id = HOST_IF_MSG_EDIT_STATION;
cf60106b 4184 msg.vif = vif;
c5c77ba1 4185
785c0712
CL
4186 memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param));
4187 if (add_sta_info->rates_len > 0) {
e38d850f
CL
4188 add_sta_info->rates = kmemdup(sta_param->rates,
4189 add_sta_info->rates_len,
4190 GFP_KERNEL);
4191 if (!add_sta_info->rates)
7ae43363 4192 return -ENOMEM;
c5c77ba1
JK
4193 }
4194
31390eec
LK
4195 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4196 if (result)
24db713f
LK
4197 PRINT_ER("wilc_mq_send fail\n");
4198
31390eec 4199 return result;
c5c77ba1 4200}
108b3439 4201
ecd27500 4202int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout)
c5c77ba1 4203{
5d48f12c 4204 int result = 0;
143eb95a 4205 struct host_if_msg msg;
568640e4 4206 struct power_mgmt_param *pwr_mgmt_info = &msg.body.pwr_mgmt_info;
fbf5379b 4207 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 4208
a4ab1ade 4209 if (!hif_drv) {
24db713f
LK
4210 PRINT_ER("driver is null\n");
4211 return -EFAULT;
4212 }
c5c77ba1 4213
ff9d65ab
GL
4214 if (wilc_wlan_get_num_conn_ifcs(vif->wilc) == 2 && enabled)
4215 return 0;
4216
143eb95a 4217 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1 4218
a9f812a6 4219 msg.id = HOST_IF_MSG_POWER_MGMT;
cf60106b 4220 msg.vif = vif;
c5c77ba1 4221
568640e4
CL
4222 pwr_mgmt_info->enabled = enabled;
4223 pwr_mgmt_info->timeout = timeout;
c5c77ba1 4224
31390eec
LK
4225 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4226 if (result)
24db713f 4227 PRINT_ER("wilc_mq_send fail\n");
31390eec 4228 return result;
c5c77ba1
JK
4229}
4230
b80c0943 4231int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled,
2dff2d42 4232 u32 count)
c5c77ba1 4233{
14d9526f 4234 int result = 0;
143eb95a 4235 struct host_if_msg msg;
40ecd38a 4236 struct set_multicast *multicast_filter_param = &msg.body.multicast_info;
fbf5379b 4237 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 4238
a4ab1ade 4239 if (!hif_drv) {
24db713f
LK
4240 PRINT_ER("driver is null\n");
4241 return -EFAULT;
4242 }
c5c77ba1 4243
143eb95a 4244 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1 4245
a9f812a6 4246 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
cf60106b 4247 msg.vif = vif;
c5c77ba1 4248
40ecd38a
CL
4249 multicast_filter_param->enabled = enabled;
4250 multicast_filter_param->cnt = count;
c5c77ba1 4251
31390eec
LK
4252 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4253 if (result)
24db713f 4254 PRINT_ER("wilc_mq_send fail\n");
31390eec 4255 return result;
c5c77ba1
JK
4256}
4257
6b5180a0 4258static void *host_int_ParseJoinBssParam(struct network_info *ptstrNetworkInfo)
c5c77ba1 4259{
e0a12217 4260 struct join_bss_param *pNewJoinBssParam = NULL;
63d03e47 4261 u8 *pu8IEs;
d85f5326
CL
4262 u16 u16IEsLen;
4263 u16 index = 0;
63d03e47
GKH
4264 u8 suppRatesNo = 0;
4265 u8 extSuppRatesNo;
d85f5326 4266 u16 jumpOffset;
63d03e47
GKH
4267 u8 pcipherCount;
4268 u8 authCount;
4269 u8 pcipherTotalCount = 0;
4270 u8 authTotalCount = 0;
4271 u8 i, j;
c5c77ba1
JK
4272
4273 pu8IEs = ptstrNetworkInfo->pu8IEs;
4274 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
4275
b156f1ed 4276 pNewJoinBssParam = kzalloc(sizeof(struct join_bss_param), GFP_KERNEL);
91109e11 4277 if (pNewJoinBssParam) {
c5c77ba1
JK
4278 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
4279 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
fa5e2d15 4280 pNewJoinBssParam->cap_info = ptstrNetworkInfo->cap_info;
d00d2ba3 4281 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
d00d2ba3 4282 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
619d27b8 4283 pNewJoinBssParam->ssid_len = ptstrNetworkInfo->u8SsidLen;
2cc46837
CL
4284 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
4285 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
c5c77ba1 4286
c5c77ba1 4287 while (index < u16IEsLen) {
c5c77ba1 4288 if (pu8IEs[index] == SUPP_RATES_IE) {
c5c77ba1
JK
4289 suppRatesNo = pu8IEs[index + 1];
4290 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
ae4dfa57 4291 index += 2;
c5c77ba1 4292
d1666e2a 4293 for (i = 0; i < suppRatesNo; i++)
c5c77ba1 4294 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
d1666e2a 4295
c5c77ba1
JK
4296 index += suppRatesNo;
4297 continue;
ae4dfa57 4298 } else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
c5c77ba1
JK
4299 extSuppRatesNo = pu8IEs[index + 1];
4300 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
4301 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
4302 else
4303 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
4304 index += 2;
d1666e2a 4305 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++)
c5c77ba1 4306 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
d1666e2a 4307
c5c77ba1
JK
4308 index += extSuppRatesNo;
4309 continue;
ae4dfa57 4310 } else if (pu8IEs[index] == HT_CAPABILITY_IE) {
0be1eb74 4311 pNewJoinBssParam->ht_capable = true;
ae4dfa57 4312 index += pu8IEs[index + 1] + 2;
c5c77ba1 4313 continue;
ae4dfa57 4314 } else if ((pu8IEs[index] == WMM_IE) &&
c5c77ba1 4315 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
ae4dfa57
LK
4316 (pu8IEs[index + 4] == 0xF2) &&
4317 (pu8IEs[index + 5] == 0x02) &&
4318 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) &&
c5c77ba1 4319 (pu8IEs[index + 7] == 0x01)) {
0be1eb74 4320 pNewJoinBssParam->wmm_cap = true;
c5c77ba1 4321
ffda203c 4322 if (pu8IEs[index + 8] & BIT(7))
0be1eb74 4323 pNewJoinBssParam->uapsd_cap = true;
c5c77ba1
JK
4324 index += pu8IEs[index + 1] + 2;
4325 continue;
ae4dfa57 4326 } else if ((pu8IEs[index] == P2P_IE) &&
c5c77ba1 4327 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
ae4dfa57
LK
4328 (pu8IEs[index + 4] == 0x9a) &&
4329 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) {
d85f5326 4330 u16 u16P2P_count;
78c87591 4331
c5c77ba1 4332 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
7a8d51d7 4333 pNewJoinBssParam->noa_enabled = 1;
cc179008 4334 pNewJoinBssParam->idx = pu8IEs[index + 9];
c5c77ba1 4335
ffda203c 4336 if (pu8IEs[index + 10] & BIT(7)) {
d72b33ca 4337 pNewJoinBssParam->opp_enabled = 1;
99b66945 4338 pNewJoinBssParam->ct_window = pu8IEs[index + 10];
d72b33ca
LK
4339 } else {
4340 pNewJoinBssParam->opp_enabled = 0;
4341 }
ae4dfa57 4342
03b2d5e7 4343 PRINT_D(GENERIC_DBG, "P2P Dump\n");
c5c77ba1 4344 for (i = 0; i < pu8IEs[index + 7]; i++)
03b2d5e7 4345 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
c5c77ba1 4346
c21047ed 4347 pNewJoinBssParam->cnt = pu8IEs[index + 11];
c5c77ba1
JK
4348 u16P2P_count = index + 12;
4349
109e6cab 4350 memcpy(pNewJoinBssParam->duration, pu8IEs + u16P2P_count, 4);
c5c77ba1
JK
4351 u16P2P_count += 4;
4352
1d8b76b3 4353 memcpy(pNewJoinBssParam->interval, pu8IEs + u16P2P_count, 4);
c5c77ba1
JK
4354 u16P2P_count += 4;
4355
4be55e22 4356 memcpy(pNewJoinBssParam->start_time, pu8IEs + u16P2P_count, 4);
c5c77ba1
JK
4357
4358 index += pu8IEs[index + 1] + 2;
4359 continue;
4360
ae4dfa57 4361 } else if ((pu8IEs[index] == RSN_IE) ||
c5c77ba1
JK
4362 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
4363 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
4364 (pu8IEs[index + 5] == 0x01))) {
d85f5326 4365 u16 rsnIndex = index;
ae4dfa57 4366
c5c77ba1
JK
4367 if (pu8IEs[rsnIndex] == RSN_IE) {
4368 pNewJoinBssParam->mode_802_11i = 2;
ae4dfa57 4369 } else {
c5c77ba1
JK
4370 if (pNewJoinBssParam->mode_802_11i == 0)
4371 pNewJoinBssParam->mode_802_11i = 1;
c5c77ba1
JK
4372 rsnIndex += 4;
4373 }
ae4dfa57
LK
4374
4375 rsnIndex += 7;
c5c77ba1
JK
4376 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
4377 rsnIndex++;
ae4dfa57 4378 jumpOffset = pu8IEs[rsnIndex] * 4;
c5c77ba1 4379 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
ae4dfa57 4380 rsnIndex += 2;
c5c77ba1 4381
d1666e2a 4382 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++)
c5c77ba1 4383 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
d1666e2a 4384
c5c77ba1
JK
4385 pcipherTotalCount += pcipherCount;
4386 rsnIndex += jumpOffset;
4387
4388 jumpOffset = pu8IEs[rsnIndex] * 4;
4389
c5c77ba1 4390 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
ae4dfa57 4391 rsnIndex += 2;
c5c77ba1 4392
d1666e2a 4393 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++)
c5c77ba1 4394 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
d1666e2a 4395
c5c77ba1
JK
4396 authTotalCount += authCount;
4397 rsnIndex += jumpOffset;
ae4dfa57 4398
c5c77ba1
JK
4399 if (pu8IEs[index] == RSN_IE) {
4400 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
4401 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
4402 rsnIndex += 2;
4403 }
f717c0eb 4404 pNewJoinBssParam->rsn_found = true;
ae4dfa57 4405 index += pu8IEs[index + 1] + 2;
c5c77ba1
JK
4406 continue;
4407 } else
ae4dfa57 4408 index += pu8IEs[index + 1] + 2;
c5c77ba1 4409 }
c5c77ba1
JK
4410 }
4411
4412 return (void *)pNewJoinBssParam;
c5c77ba1
JK
4413}
4414
6964f086 4415int wilc_setup_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx)
c5c77ba1 4416{
3d2a0bf7 4417 int result = 0;
143eb95a 4418 struct host_if_msg msg;
fbf5379b 4419 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 4420
a4ab1ade 4421 if (!hif_drv) {
24db713f
LK
4422 PRINT_ER("driver is null\n");
4423 return -EFAULT;
4424 }
c5c77ba1 4425
143eb95a 4426 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1 4427
a9f812a6 4428 msg.id = HOST_IF_MSG_SET_IPADDRESS;
c5c77ba1 4429
6964f086 4430 msg.body.ip_info.ip_addr = ip_addr;
cf60106b 4431 msg.vif = vif;
fb2d65ed 4432 msg.body.ip_info.idx = idx;
c5c77ba1 4433
31390eec
LK
4434 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4435 if (result)
24db713f 4436 PRINT_ER("wilc_mq_send fail\n");
c5c77ba1 4437
31390eec 4438 return result;
c5c77ba1
JK
4439}
4440
3b4276d9 4441static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx)
c5c77ba1 4442{
cb8f4e0e 4443 int result = 0;
143eb95a 4444 struct host_if_msg msg;
f8813d3a 4445 struct host_if_drv *hif_drv = vif->hif_drv;
c5c77ba1 4446
a4ab1ade 4447 if (!hif_drv) {
24db713f
LK
4448 PRINT_ER("driver is null\n");
4449 return -EFAULT;
4450 }
c5c77ba1 4451
143eb95a 4452 memset(&msg, 0, sizeof(struct host_if_msg));
c5c77ba1 4453
a9f812a6 4454 msg.id = HOST_IF_MSG_GET_IPADDRESS;
c5c77ba1 4455
3b4276d9 4456 msg.body.ip_info.ip_addr = ip_addr;
cf60106b 4457 msg.vif = vif;
fb2d65ed 4458 msg.body.ip_info.idx = idx;
c5c77ba1 4459
31390eec
LK
4460 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4461 if (result)
24db713f 4462 PRINT_ER("wilc_mq_send fail\n");
c5c77ba1 4463
31390eec 4464 return result;
c5c77ba1 4465}
70418790
GL
4466
4467int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power)
4468{
4469 int ret = 0;
4470 struct host_if_msg msg;
4471
4472 memset(&msg, 0, sizeof(struct host_if_msg));
4473
4474 msg.id = HOST_IF_MSG_SET_TX_POWER;
4475 msg.body.tx_power.tx_pwr = tx_power;
4476 msg.vif = vif;
4477
4478 ret = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4479 if (ret)
4480 netdev_err(vif->ndev, "wilc_mq_send fail\n");
4481
4482 return ret;
4483}
4484
4485int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power)
4486{
4487 int ret = 0;
4488 struct host_if_msg msg;
4489
4490 memset(&msg, 0, sizeof(struct host_if_msg));
4491
4492 msg.id = HOST_IF_MSG_GET_TX_POWER;
4493 msg.vif = vif;
4494
4495 ret = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4496 if (ret)
4497 netdev_err(vif->ndev, "Failed to get TX PWR\n");
4498
4499 down(&hif_sema_wait_response);
4500 *tx_power = msg.body.tx_power.tx_pwr;
4501
4502 return ret;
4503}
This page took 1.02256 seconds and 5 git commands to generate.