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