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"
8 #include "wilc_wlan_if.h"
9 #include "wilc_msgqueue.h"
10 #include <linux/etherdevice.h>
11 #include "wilc_wfi_netdevice.h"
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
54 #define HOST_IF_SCAN_TIMEOUT 4000
55 #define HOST_IF_CONNECT_TIMEOUT 9500
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
62 #define TCP_ACK_FILTER_LINK_SPEED_THRESH 54
63 #define DEFAULT_LINK_SPEED 72
65 struct cfg_param_attr {
66 struct cfg_param_val cfg_attr_info;
69 struct host_if_wpa_attr {
79 struct host_if_wep_attr {
84 enum AUTHTYPE auth_type;
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;
96 union host_if_key_attr attr;
106 wilc_scan_result result;
108 struct hidden_network hidden_network;
111 struct connect_attr {
118 wilc_connect_result result;
120 enum AUTHTYPE auth_type;
125 struct rcvd_async_info {
130 struct channel_attr {
143 struct set_multicast {
149 u8 del_all_sta[MAX_NUM_STA][ETH_ALEN];
154 u8 mac_addr[ETH_ALEN];
157 struct power_mgmt_param {
167 struct sta_inactive_t {
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;
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;
199 struct del_all_sta del_all_sta_info;
200 struct tx_power tx_power;
205 union message_body body;
206 struct wilc_vif *vif;
209 struct join_bss_param {
215 char ssid[MAX_SSID_LEN];
217 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
224 u8 rsn_pcip_policy[3];
225 u8 rsn_auth_policy[3];
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;
249 u8 wilc_multicast_mac_addr_list[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
251 static u8 rcv_assoc_resp[MAX_ASSOC_RESP_FRAME_SIZE];
253 static bool scan_while_connected;
256 static s8 link_speed;
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;
265 static u8 *info_element;
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
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);
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.
282 int wilc_get_vif_idx(struct wilc_vif *vif)
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
290 * As a result, the index should be between 0 and NUM_CONCURRENT_IFC -1.
292 static struct wilc_vif *wilc_get_vif_from_idx(struct wilc *wilc, int idx)
296 if (index < 0 || index >= NUM_CONCURRENT_IFC)
299 return wilc->vif[index];
302 static void handle_set_channel(struct wilc_vif *vif,
303 struct channel_attr *hif_set_ch)
308 wid.id = (u16)WID_CURRENT_CHANNEL;
310 wid.val = (char *)&hif_set_ch->set_ch;
311 wid.size = sizeof(char);
313 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
314 wilc_get_vif_idx(vif));
317 PRINT_ER("Failed to set channel\n");
320 static s32 handle_set_wfi_drv_handler(struct wilc_vif *vif,
321 struct drv_handler *hif_drv_handler)
326 wid.id = (u16)WID_SET_DRV_HANDLER;
328 wid.val = (s8 *)hif_drv_handler;
329 wid.size = sizeof(*hif_drv_handler);
331 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
332 hif_drv_handler->handler);
334 if (!hif_drv_handler->handler)
335 up(&hif_sema_driver);
338 PRINT_ER("Failed to set driver handler\n");
345 static s32 handle_set_operation_mode(struct wilc_vif *vif,
346 struct op_mode *hif_op_mode)
351 wid.id = (u16)WID_SET_OPERATION_MODE;
353 wid.val = (s8 *)&hif_op_mode->mode;
354 wid.size = sizeof(u32);
356 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
357 wilc_get_vif_idx(vif));
359 if ((hif_op_mode->mode) == IDLE_MODE)
360 up(&hif_sema_driver);
363 PRINT_ER("Failed to set driver handler\n");
370 static s32 handle_set_ip_address(struct wilc_vif *vif, u8 *ip_addr, u8 idx)
374 char firmware_ip_addr[4] = {0};
376 if (ip_addr[0] < 192)
379 memcpy(set_ip[idx], ip_addr, IP_ALEN);
381 wid.id = (u16)WID_IP_ADDRESS;
383 wid.val = (u8 *)ip_addr;
386 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
387 wilc_get_vif_idx(vif));
389 host_int_get_ipaddress(vif, firmware_ip_addr, idx);
392 PRINT_ER("Failed to set IP address\n");
399 static s32 handle_get_ip_address(struct wilc_vif *vif, u8 idx)
404 wid.id = (u16)WID_IP_ADDRESS;
406 wid.val = kmalloc(IP_ALEN, GFP_KERNEL);
409 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
410 wilc_get_vif_idx(vif));
412 memcpy(get_ip[idx], wid.val, IP_ALEN);
416 if (memcmp(get_ip[idx], set_ip[idx], IP_ALEN) != 0)
417 wilc_setup_ipaddress(vif, set_ip[idx], idx);
420 PRINT_ER("Failed to get IP address\n");
427 static s32 handle_set_mac_address(struct wilc_vif *vif,
428 struct set_mac_addr *set_mac_addr)
432 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
435 PRINT_ER("No buffer to send mac address\n");
438 memcpy(mac_buf, set_mac_addr->mac_addr, ETH_ALEN);
440 wid.id = (u16)WID_MAC_ADDR;
445 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
446 wilc_get_vif_idx(vif));
448 PRINT_ER("Failed to set mac address\n");
456 static s32 handle_get_mac_address(struct wilc_vif *vif,
457 struct get_mac_addr *get_mac_addr)
462 wid.id = (u16)WID_MAC_ADDR;
464 wid.val = get_mac_addr->mac_addr;
467 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
468 wilc_get_vif_idx(vif));
471 PRINT_ER("Failed to get mac address\n");
474 up(&hif_sema_wait_response);
479 static s32 handle_cfg_param(struct wilc_vif *vif,
480 struct cfg_param_attr *cfg_param_attr)
483 struct wid wid_list[32];
484 struct host_if_drv *hif_drv = vif->hif_drv;
487 down(&hif_drv->sem_cfg_values);
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;
497 PRINT_ER("check value 6 over\n");
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;
513 PRINT_ER("Impossible value \n");
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;
528 PRINT_ER("Range(1 ~ 65535) over\n");
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;
542 PRINT_ER("Invalid power mode\n");
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;
557 PRINT_ER("Range(1~256) over\n");
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;
572 PRINT_ER("Range(1~256) over\n");
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;
587 PRINT_ER("Threshold Range fail\n");
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;
602 PRINT_ER("Threshold Range fail\n");
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;
616 PRINT_ER("Preamle Range(0~2) over\n");
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;
630 PRINT_ER("Short slot(2) over\n");
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;
644 PRINT_ER("TXOP prot disable\n");
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;
659 PRINT_ER("Beacon interval(1~65535) fail\n");
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;
674 PRINT_ER("DTIM range(1~255) fail\n");
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;
688 PRINT_ER("Site survey disable\n");
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;
703 PRINT_ER("Site survey scan time(1~65535) over\n");
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;
718 PRINT_ER("Active scan time(1~65535) over\n");
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;
733 PRINT_ER("Passive scan time(1~65535) over\n");
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;
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;
754 PRINT_ER("out of TX rate\n");
761 result = wilc_send_config_pkt(vif, SET_CFG, wid_list,
762 wid_cnt, wilc_get_vif_idx(vif));
765 PRINT_ER("Error in setting CFG params\n");
768 up(&hif_drv->sem_cfg_values);
772 static void Handle_wait_msg_q_empty(void)
774 wilc_initialized = 0;
775 up(&hif_sema_wait_response);
778 static s32 Handle_ScanDone(struct wilc_vif *vif,
779 enum scan_event enuEvent);
781 static s32 Handle_Scan(struct wilc_vif *vif,
782 struct scan_attr *pstrHostIFscanAttr)
785 struct wid strWIDList[5];
786 u32 u32WidsCount = 0;
790 u8 *pu8HdnNtwrksWidVal = NULL;
791 struct host_if_drv *hif_drv = vif->hif_drv;
793 hif_drv->usr_scan_req.scan_result = pstrHostIFscanAttr->result;
794 hif_drv->usr_scan_req.arg = pstrHostIFscanAttr->arg;
796 if ((hif_drv->hif_state >= HOST_IF_SCANNING) &&
797 (hif_drv->hif_state < HOST_IF_CONNECTED)) {
798 PRINT_ER("Already scan\n");
803 if (wilc_optaining_ip || wilc_connecting) {
804 PRINT_ER("Don't do obss scan\n");
809 hif_drv->usr_scan_req.rcvd_ch_cnt = 0;
811 strWIDList[u32WidsCount].id = (u16)WID_SSID_PROBE_REQ;
812 strWIDList[u32WidsCount].type = WID_STR;
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;
821 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.n_ssids;
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;
829 strWIDList[u32WidsCount].size = (s32)(valuesize + 1);
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;
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;
847 strWIDList[u32WidsCount].id = WID_SCAN_CHANNEL_LIST;
848 strWIDList[u32WidsCount].type = WID_BIN_DATA;
850 if (pstrHostIFscanAttr->ch_freq_list &&
851 pstrHostIFscanAttr->ch_list_len > 0) {
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;
860 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ch_freq_list;
861 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ch_list_len;
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;
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;
875 result = wilc_send_config_pkt(vif, SET_CFG, strWIDList,
877 wilc_get_vif_idx(vif));
880 PRINT_ER("Failed to send scan parameters config packet\n");
884 del_timer(&hif_drv->scan_timer);
885 Handle_ScanDone(vif, SCAN_EVENT_ABORTED);
888 kfree(pstrHostIFscanAttr->ch_freq_list);
889 pstrHostIFscanAttr->ch_freq_list = NULL;
891 kfree(pstrHostIFscanAttr->ies);
892 pstrHostIFscanAttr->ies = NULL;
893 kfree(pstrHostIFscanAttr->hidden_network.net_info);
894 pstrHostIFscanAttr->hidden_network.net_info = NULL;
896 kfree(pu8HdnNtwrksWidVal);
901 static s32 Handle_ScanDone(struct wilc_vif *vif,
902 enum scan_event enuEvent)
905 u8 u8abort_running_scan;
907 struct host_if_drv *hif_drv = vif->hif_drv;
909 if (enuEvent == SCAN_EVENT_ABORTED) {
910 u8abort_running_scan = 1;
911 wid.id = (u16)WID_ABORT_RUNNING_SCAN;
913 wid.val = (s8 *)&u8abort_running_scan;
914 wid.size = sizeof(char);
916 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
917 wilc_get_vif_idx(vif));
920 PRINT_ER("Failed to set abort running scan\n");
926 PRINT_ER("Driver handler is NULL\n");
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;
939 u8 wilc_connected_ssid[6] = {0};
940 static s32 Handle_Connect(struct wilc_vif *vif,
941 struct connect_attr *pstrHostIFconnectAttr)
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;
950 if (memcmp(pstrHostIFconnectAttr->bssid, wilc_connected_ssid, ETH_ALEN) == 0) {
952 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
956 ptstrJoinBssParam = (struct join_bss_param *)pstrHostIFconnectAttr->params;
957 if (!ptstrJoinBssParam) {
958 PRINT_ER("Required BSSID not found\n");
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);
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';
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);
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;
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));
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));
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));
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;
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,
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;
1028 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
1029 mode_11i = hif_drv->usr_conn_req.security;
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;
1037 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
1038 auth_type = (u8)hif_drv->usr_conn_req.auth_type;
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);
1045 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1046 join_req_size = strWIDList[u32WidsCount].size;
1047 join_req = kmalloc(join_req_size, GFP_KERNEL);
1049 if (!strWIDList[u32WidsCount].val) {
1054 pu8CurrByte = strWIDList[u32WidsCount].val;
1056 if (pstrHostIFconnectAttr->ssid) {
1057 memcpy(pu8CurrByte, pstrHostIFconnectAttr->ssid, pstrHostIFconnectAttr->ssid_len);
1058 pu8CurrByte[pstrHostIFconnectAttr->ssid_len] = '\0';
1060 pu8CurrByte += MAX_SSID_LEN;
1061 *(pu8CurrByte++) = INFRASTRUCTURE;
1063 if ((pstrHostIFconnectAttr->ch >= 1) && (pstrHostIFconnectAttr->ch <= 14)) {
1064 *(pu8CurrByte++) = pstrHostIFconnectAttr->ch;
1066 PRINT_ER("Channel out of range\n");
1067 *(pu8CurrByte++) = 0xFF;
1069 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1070 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1072 if (pstrHostIFconnectAttr->bssid)
1073 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
1076 if (pstrHostIFconnectAttr->bssid)
1077 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
1080 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1081 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1082 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1084 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
1085 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1087 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1088 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1090 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1091 hif_drv->usr_conn_req.ht_capable = ptstrJoinBssParam->ht_capable;
1093 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1094 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1095 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1097 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
1098 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1100 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
1101 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1103 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
1104 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1106 *(pu8CurrByte++) = REAL_JOIN_REQ;
1107 *(pu8CurrByte++) = ptstrJoinBssParam->noa_enabled;
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;
1115 *(pu8CurrByte++) = ptstrJoinBssParam->opp_enabled;
1116 *(pu8CurrByte++) = ptstrJoinBssParam->idx;
1118 if (ptstrJoinBssParam->opp_enabled)
1119 *(pu8CurrByte++) = ptstrJoinBssParam->ct_window;
1121 *(pu8CurrByte++) = ptstrJoinBssParam->cnt;
1123 memcpy(pu8CurrByte, ptstrJoinBssParam->duration, sizeof(ptstrJoinBssParam->duration));
1124 pu8CurrByte += sizeof(ptstrJoinBssParam->duration);
1126 memcpy(pu8CurrByte, ptstrJoinBssParam->interval, sizeof(ptstrJoinBssParam->interval));
1127 pu8CurrByte += sizeof(ptstrJoinBssParam->interval);
1129 memcpy(pu8CurrByte, ptstrJoinBssParam->start_time, sizeof(ptstrJoinBssParam->start_time));
1130 pu8CurrByte += sizeof(ptstrJoinBssParam->start_time);
1133 pu8CurrByte = strWIDList[u32WidsCount].val;
1136 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1137 memcpy(join_req, pu8CurrByte, join_req_size);
1141 if (pstrHostIFconnectAttr->bssid)
1142 memcpy(wilc_connected_ssid,
1143 pstrHostIFconnectAttr->bssid, ETH_ALEN);
1145 result = wilc_send_config_pkt(vif, SET_CFG, strWIDList,
1147 wilc_get_vif_idx(vif));
1149 PRINT_ER("failed to send config packet\n");
1153 hif_drv->hif_state = HOST_IF_WAITING_CONN_RESP;
1158 tstrConnectInfo strConnectInfo;
1160 del_timer(&hif_drv->connect_timer);
1162 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1164 if (pstrHostIFconnectAttr->result) {
1165 if (pstrHostIFconnectAttr->bssid)
1166 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->bssid, 6);
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);
1176 pstrHostIFconnectAttr->result(CONN_DISCONN_EVENT_CONN_RESP,
1180 pstrHostIFconnectAttr->arg);
1181 hif_drv->hif_state = HOST_IF_IDLE;
1182 kfree(strConnectInfo.pu8ReqIEs);
1183 strConnectInfo.pu8ReqIEs = NULL;
1186 PRINT_ER("Connect callback function pointer is NULL\n");
1190 kfree(pstrHostIFconnectAttr->bssid);
1191 pstrHostIFconnectAttr->bssid = NULL;
1193 kfree(pstrHostIFconnectAttr->ssid);
1194 pstrHostIFconnectAttr->ssid = NULL;
1196 kfree(pstrHostIFconnectAttr->ies);
1197 pstrHostIFconnectAttr->ies = NULL;
1203 static s32 Handle_FlushConnect(struct wilc_vif *vif)
1206 struct wid strWIDList[5];
1207 u32 u32WidsCount = 0;
1208 u8 *pu8CurrByte = NULL;
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;
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));
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);
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;
1234 pu8CurrByte += FLUSHED_BYTE_POS;
1235 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1239 result = wilc_send_config_pkt(vif, SET_CFG, strWIDList,
1241 wilc_get_vif_idx(join_req_vif));
1243 PRINT_ER("failed to send config packet\n");
1250 static s32 Handle_ConnectTimeout(struct wilc_vif *vif)
1253 tstrConnectInfo strConnectInfo;
1255 u16 u16DummyReasonCode = 0;
1256 struct host_if_drv *hif_drv = vif->hif_drv;
1259 PRINT_ER("Driver handler is NULL\n");
1263 hif_drv->hif_state = HOST_IF_IDLE;
1265 scan_while_connected = false;
1267 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
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);
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);
1283 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
1287 hif_drv->usr_conn_req.arg);
1289 kfree(strConnectInfo.pu8ReqIEs);
1290 strConnectInfo.pu8ReqIEs = NULL;
1292 PRINT_ER("Connect callback function pointer is NULL\n");
1295 wid.id = (u16)WID_DISCONNECT;
1296 wid.type = WID_CHAR;
1297 wid.val = (s8 *)&u16DummyReasonCode;
1298 wid.size = sizeof(char);
1300 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
1301 wilc_get_vif_idx(vif));
1303 PRINT_ER("Failed to send dissconect config packet\n");
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;
1314 eth_zero_addr(wilc_connected_ssid);
1316 if (join_req && join_req_vif == vif) {
1321 if (info_element && join_req_vif == vif) {
1322 kfree(info_element);
1323 info_element = NULL;
1329 static s32 Handle_RcvdNtwrkInfo(struct wilc_vif *vif,
1330 struct rcvd_net_info *pstrRcvdNetworkInfo)
1333 bool bNewNtwrkFound;
1335 struct network_info *pstrNetworkInfo = NULL;
1336 void *pJoinParams = NULL;
1337 struct host_if_drv *hif_drv = vif->hif_drv;
1339 bNewNtwrkFound = true;
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");
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) {
1358 hif_drv->usr_scan_req.net_info[i].rssi = pstrNetworkInfo->rssi;
1359 bNewNtwrkFound = false;
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;
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);
1375 hif_drv->usr_scan_req.rcvd_ch_cnt++;
1377 pstrNetworkInfo->new_network = true;
1378 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
1380 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1381 hif_drv->usr_scan_req.arg,
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);
1393 kfree(pstrRcvdNetworkInfo->buffer);
1394 pstrRcvdNetworkInfo->buffer = NULL;
1396 if (pstrNetworkInfo) {
1397 kfree(pstrNetworkInfo->ies);
1398 kfree(pstrNetworkInfo);
1404 static s32 host_int_get_assoc_res_info(struct wilc_vif *vif,
1405 u8 *pu8AssocRespInfo,
1406 u32 u32MaxAssocRespInfoLen,
1407 u32 *pu32RcvdAssocRespInfoLen);
1409 static s32 Handle_RcvdGnrlAsyncInfo(struct wilc_vif *vif,
1410 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
1416 u16 u16WidID = (u16)WID_NIL;
1419 u8 u8MacStatusReasonCode;
1420 u8 u8MacStatusAdditionalInfo;
1421 tstrConnectInfo strConnectInfo;
1422 tstrDisconnectNotifInfo strDisconnectNotifInfo;
1424 struct host_if_drv *hif_drv = vif->hif_drv;
1427 PRINT_ER("Driver handler is NULL\n");
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");
1440 u8MsgType = pstrRcvdGnrlAsyncInfo->buffer[0];
1442 if ('I' != u8MsgType) {
1443 PRINT_ER("Received Message format incorrect.\n");
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;
1458 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1460 if (u8MacStatus == MAC_CONNECTED) {
1461 memset(rcv_assoc_resp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
1463 host_int_get_assoc_res_info(vif,
1465 MAX_ASSOC_RESP_FRAME_SIZE,
1466 &u32RcvdAssocRespInfoLen);
1468 if (u32RcvdAssocRespInfoLen != 0) {
1469 s32Err = wilc_parse_assoc_resp_info(rcv_assoc_resp, u32RcvdAssocRespInfoLen,
1470 &pstrConnectRespInfo);
1472 PRINT_ER("wilc_parse_assoc_resp_info() returned error %d\n", s32Err);
1474 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->status;
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);
1485 if (pstrConnectRespInfo) {
1486 kfree(pstrConnectRespInfo->ies);
1487 kfree(pstrConnectRespInfo);
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);
1502 if (hif_drv->usr_conn_req.bssid) {
1503 memcpy(strConnectInfo.au8bssid, hif_drv->usr_conn_req.bssid, 6);
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);
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);
1520 del_timer(&hif_drv->connect_timer);
1521 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
1525 hif_drv->usr_conn_req.arg);
1527 if ((u8MacStatus == MAC_CONNECTED) &&
1528 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
1529 wilc_set_power_mgmt(vif, 0, 0);
1531 hif_drv->hif_state = HOST_IF_CONNECTED;
1533 wilc_optaining_ip = true;
1534 mod_timer(&wilc_during_ip_timer,
1535 jiffies + msecs_to_jiffies(10000));
1537 hif_drv->hif_state = HOST_IF_IDLE;
1538 scan_while_connected = false;
1541 kfree(strConnectInfo.pu8RespIEs);
1542 strConnectInfo.pu8RespIEs = NULL;
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));
1558 if (hif_drv->usr_scan_req.scan_result) {
1559 del_timer(&hif_drv->scan_timer);
1560 Handle_ScanDone(vif, SCAN_EVENT_ABORTED);
1563 strDisconnectNotifInfo.u16reason = 0;
1564 strDisconnectNotifInfo.ie = NULL;
1565 strDisconnectNotifInfo.ie_len = 0;
1567 if (hif_drv->usr_conn_req.conn_result) {
1568 wilc_optaining_ip = false;
1569 wilc_set_power_mgmt(vif, 0, 0);
1571 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1574 &strDisconnectNotifInfo,
1575 hif_drv->usr_conn_req.arg);
1577 PRINT_ER("Connect result callback function is NULL\n");
1580 eth_zero_addr(hif_drv->assoc_bssid);
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;
1591 if (join_req && join_req_vif == vif) {
1596 if (info_element && join_req_vif == vif) {
1597 kfree(info_element);
1598 info_element = NULL;
1601 hif_drv->hif_state = HOST_IF_IDLE;
1602 scan_while_connected = false;
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);
1612 kfree(pstrRcvdGnrlAsyncInfo->buffer);
1613 pstrRcvdGnrlAsyncInfo->buffer = NULL;
1618 static int Handle_Key(struct wilc_vif *vif,
1619 struct key_attr *pstrHostIFkeyAttr)
1623 struct wid strWIDList[5];
1628 struct host_if_drv *hif_drv = vif->hif_drv;
1630 switch (pstrHostIFkeyAttr->type) {
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;
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;
1644 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2,
1647 if (pu8keybuf == NULL) {
1648 PRINT_ER("No buffer to send Key\n");
1652 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1653 pu8keybuf[1] = pstrHostIFkeyAttr->attr.wep.key_len;
1655 memcpy(&pu8keybuf[2], pstrHostIFkeyAttr->attr.wep.key,
1656 pstrHostIFkeyAttr->attr.wep.key_len);
1658 kfree(pstrHostIFkeyAttr->attr.wep.key);
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;
1665 result = wilc_send_config_pkt(vif, SET_CFG,
1667 wilc_get_vif_idx(vif));
1669 } else if (pstrHostIFkeyAttr->action & ADDKEY) {
1670 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2, GFP_KERNEL);
1672 PRINT_ER("No buffer to send Key\n");
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);
1681 wid.id = (u16)WID_ADD_WEP_KEY;
1683 wid.val = (s8 *)pu8keybuf;
1684 wid.size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
1686 result = wilc_send_config_pkt(vif, SET_CFG,
1688 wilc_get_vif_idx(vif));
1690 } else if (pstrHostIFkeyAttr->action & REMOVEKEY) {
1691 wid.id = (u16)WID_REMOVE_WEP_KEY;
1694 s8idxarray[0] = (s8)pstrHostIFkeyAttr->attr.wep.index;
1695 wid.val = s8idxarray;
1698 result = wilc_send_config_pkt(vif, SET_CFG,
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);
1707 result = wilc_send_config_pkt(vif, SET_CFG,
1709 wilc_get_vif_idx(vif));
1711 up(&hif_drv->sem_test_key_block);
1715 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1716 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1718 PRINT_ER("No buffer to send RxGTK Key\n");
1720 goto _WPARxGtk_end_case_;
1723 if (pstrHostIFkeyAttr->attr.wpa.seq)
1724 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
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);
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;
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;
1741 result = wilc_send_config_pkt(vif, SET_CFG,
1743 wilc_get_vif_idx(vif));
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");
1752 goto _WPARxGtk_end_case_;
1755 if (hif_drv->hif_state == HOST_IF_CONNECTED)
1756 memcpy(pu8keybuf, hif_drv->assoc_bssid, ETH_ALEN);
1758 PRINT_ER("Couldn't handle WPARxGtk while state is not HOST_IF_CONNECTED\n");
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);
1766 wid.id = (u16)WID_ADD_RX_GTK;
1768 wid.val = (s8 *)pu8keybuf;
1769 wid.size = RX_MIC_KEY_MSG_LEN;
1771 result = wilc_send_config_pkt(vif, SET_CFG,
1773 wilc_get_vif_idx(vif));
1776 up(&hif_drv->sem_test_key_block);
1778 _WPARxGtk_end_case_:
1779 kfree(pstrHostIFkeyAttr->attr.wpa.key);
1780 kfree(pstrHostIFkeyAttr->attr.wpa.seq);
1787 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1788 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
1790 PRINT_ER("No buffer to send PTK Key\n");
1792 goto _WPAPtk_end_case_;
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);
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;
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;
1811 result = wilc_send_config_pkt(vif, SET_CFG,
1813 wilc_get_vif_idx(vif));
1815 up(&hif_drv->sem_test_key_block);
1816 } else if (pstrHostIFkeyAttr->action & ADDKEY) {
1817 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
1819 PRINT_ER("No buffer to send PTK Key\n");
1821 goto _WPAPtk_end_case_;
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);
1829 wid.id = (u16)WID_ADD_PTK;
1831 wid.val = (s8 *)pu8keybuf;
1832 wid.size = PTK_KEY_MSG_LEN;
1834 result = wilc_send_config_pkt(vif, SET_CFG,
1836 wilc_get_vif_idx(vif));
1838 up(&hif_drv->sem_test_key_block);
1842 kfree(pstrHostIFkeyAttr->attr.wpa.key);
1849 pu8keybuf = kmalloc((pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
1851 PRINT_ER("No buffer to send PMKSA Key\n");
1855 pu8keybuf[0] = pstrHostIFkeyAttr->attr.pmkid.numpmkid;
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);
1862 wid.id = (u16)WID_PMKID_INFO;
1864 wid.val = (s8 *)pu8keybuf;
1865 wid.size = (pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
1867 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
1868 wilc_get_vif_idx(vif));
1875 PRINT_ER("Failed to send key config packet\n");
1880 static void Handle_Disconnect(struct wilc_vif *vif)
1883 struct host_if_drv *hif_drv = vif->hif_drv;
1886 u16 u16DummyReasonCode = 0;
1888 wid.id = (u16)WID_DISCONNECT;
1889 wid.type = WID_CHAR;
1890 wid.val = (s8 *)&u16DummyReasonCode;
1891 wid.size = sizeof(char);
1893 wilc_optaining_ip = false;
1894 wilc_set_power_mgmt(vif, 0, 0);
1896 eth_zero_addr(wilc_connected_ssid);
1898 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
1899 wilc_get_vif_idx(vif));
1902 PRINT_ER("Failed to send dissconect config packet\n");
1904 tstrDisconnectNotifInfo strDisconnectNotifInfo;
1906 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
1908 strDisconnectNotifInfo.u16reason = 0;
1909 strDisconnectNotifInfo.ie = NULL;
1910 strDisconnectNotifInfo.ie_len = 0;
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,
1916 hif_drv->usr_scan_req.arg,
1918 hif_drv->usr_scan_req.scan_result = NULL;
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);
1925 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1928 &strDisconnectNotifInfo,
1929 hif_drv->usr_conn_req.arg);
1931 PRINT_ER("usr_conn_req.conn_result = NULL\n");
1934 scan_while_connected = false;
1936 hif_drv->hif_state = HOST_IF_IDLE;
1938 eth_zero_addr(hif_drv->assoc_bssid);
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;
1949 if (join_req && join_req_vif == vif) {
1954 if (info_element && join_req_vif == vif) {
1955 kfree(info_element);
1956 info_element = NULL;
1960 up(&hif_drv->sem_test_disconn_block);
1963 void wilc_resolve_disconnect_aberration(struct wilc_vif *vif)
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);
1972 static s32 Handle_GetChnl(struct wilc_vif *vif)
1976 struct host_if_drv *hif_drv = vif->hif_drv;
1978 wid.id = (u16)WID_CURRENT_CHANNEL;
1979 wid.type = WID_CHAR;
1980 wid.val = (s8 *)&ch_no;
1981 wid.size = sizeof(char);
1983 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
1984 wilc_get_vif_idx(vif));
1987 PRINT_ER("Failed to get channel number\n");
1991 up(&hif_drv->sem_get_chnl);
1996 static void Handle_GetRssi(struct wilc_vif *vif)
2001 wid.id = (u16)WID_RSSI;
2002 wid.type = WID_CHAR;
2004 wid.size = sizeof(char);
2006 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
2007 wilc_get_vif_idx(vif));
2009 PRINT_ER("Failed to get RSSI value\n");
2013 up(&vif->hif_drv->sem_get_rssi);
2016 static void Handle_GetLinkspeed(struct wilc_vif *vif)
2020 struct host_if_drv *hif_drv = vif->hif_drv;
2024 wid.id = (u16)WID_LINKSPEED;
2025 wid.type = WID_CHAR;
2026 wid.val = &link_speed;
2027 wid.size = sizeof(char);
2029 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
2030 wilc_get_vif_idx(vif));
2032 PRINT_ER("Failed to get LINKSPEED value\n");
2036 up(&hif_drv->sem_get_link_speed);
2039 static s32 Handle_GetStatistics(struct wilc_vif *vif,
2040 struct rf_info *pstrStatistics)
2042 struct wid strWIDList[5];
2043 u32 u32WidsCount = 0, result = 0;
2045 strWIDList[u32WidsCount].id = WID_LINKSPEED;
2046 strWIDList[u32WidsCount].type = WID_CHAR;
2047 strWIDList[u32WidsCount].size = sizeof(char);
2048 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->link_speed;
2051 strWIDList[u32WidsCount].id = WID_RSSI;
2052 strWIDList[u32WidsCount].type = WID_CHAR;
2053 strWIDList[u32WidsCount].size = sizeof(char);
2054 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->rssi;
2057 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
2058 strWIDList[u32WidsCount].type = WID_INT;
2059 strWIDList[u32WidsCount].size = sizeof(u32);
2060 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_cnt;
2063 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
2064 strWIDList[u32WidsCount].type = WID_INT;
2065 strWIDList[u32WidsCount].size = sizeof(u32);
2066 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->rx_cnt;
2069 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
2070 strWIDList[u32WidsCount].type = WID_INT;
2071 strWIDList[u32WidsCount].size = sizeof(u32);
2072 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_fail_cnt;
2075 result = wilc_send_config_pkt(vif, GET_CFG, strWIDList,
2077 wilc_get_vif_idx(vif));
2080 PRINT_ER("Failed to send scan parameters config packet\n");
2082 if (pstrStatistics->link_speed > TCP_ACK_FILTER_LINK_SPEED_THRESH &&
2083 pstrStatistics->link_speed != DEFAULT_LINK_SPEED)
2084 wilc_enable_tcp_ack_filter(true);
2085 else if (pstrStatistics->link_speed != DEFAULT_LINK_SPEED)
2086 wilc_enable_tcp_ack_filter(false);
2088 if (pstrStatistics != &vif->wilc->dummy_statistics)
2089 up(&hif_sema_wait_response);
2093 static s32 Handle_Get_InActiveTime(struct wilc_vif *vif,
2094 struct sta_inactive_t *strHostIfStaInactiveT)
2099 struct host_if_drv *hif_drv = vif->hif_drv;
2101 wid.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
2103 wid.size = ETH_ALEN;
2104 wid.val = kmalloc(wid.size, GFP_KERNEL);
2107 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
2109 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
2111 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2112 wilc_get_vif_idx(vif));
2115 PRINT_ER("Failed to SET incative time\n");
2119 wid.id = (u16)WID_GET_INACTIVE_TIME;
2121 wid.val = (s8 *)&inactive_time;
2122 wid.size = sizeof(u32);
2124 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
2125 wilc_get_vif_idx(vif));
2128 PRINT_ER("Failed to get incative time\n");
2132 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", inactive_time);
2134 up(&hif_drv->sem_inactive_time);
2139 static void Handle_AddBeacon(struct wilc_vif *vif,
2140 struct beacon_attr *pstrSetBeaconParam)
2146 wid.id = (u16)WID_ADD_BEACON;
2148 wid.size = pstrSetBeaconParam->head_len + pstrSetBeaconParam->tail_len + 16;
2149 wid.val = kmalloc(wid.size, GFP_KERNEL);
2153 pu8CurrByte = wid.val;
2154 *pu8CurrByte++ = (pstrSetBeaconParam->interval & 0xFF);
2155 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 8) & 0xFF);
2156 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 16) & 0xFF);
2157 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 24) & 0xFF);
2159 *pu8CurrByte++ = (pstrSetBeaconParam->dtim_period & 0xFF);
2160 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 8) & 0xFF);
2161 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 16) & 0xFF);
2162 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 24) & 0xFF);
2164 *pu8CurrByte++ = (pstrSetBeaconParam->head_len & 0xFF);
2165 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 8) & 0xFF);
2166 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 16) & 0xFF);
2167 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 24) & 0xFF);
2169 memcpy(pu8CurrByte, pstrSetBeaconParam->head, pstrSetBeaconParam->head_len);
2170 pu8CurrByte += pstrSetBeaconParam->head_len;
2172 *pu8CurrByte++ = (pstrSetBeaconParam->tail_len & 0xFF);
2173 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 8) & 0xFF);
2174 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 16) & 0xFF);
2175 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 24) & 0xFF);
2177 if (pstrSetBeaconParam->tail)
2178 memcpy(pu8CurrByte, pstrSetBeaconParam->tail, pstrSetBeaconParam->tail_len);
2179 pu8CurrByte += pstrSetBeaconParam->tail_len;
2181 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2182 wilc_get_vif_idx(vif));
2184 PRINT_ER("Failed to send add beacon config packet\n");
2188 kfree(pstrSetBeaconParam->head);
2189 kfree(pstrSetBeaconParam->tail);
2192 static void Handle_DelBeacon(struct wilc_vif *vif)
2198 wid.id = (u16)WID_DEL_BEACON;
2199 wid.type = WID_CHAR;
2200 wid.size = sizeof(char);
2201 wid.val = &del_beacon;
2206 pu8CurrByte = wid.val;
2208 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2209 wilc_get_vif_idx(vif));
2211 PRINT_ER("Failed to send delete beacon config packet\n");
2214 static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
2215 struct add_sta_param *pstrStationParam)
2219 pu8CurrByte = pu8Buffer;
2221 memcpy(pu8CurrByte, pstrStationParam->bssid, ETH_ALEN);
2222 pu8CurrByte += ETH_ALEN;
2224 *pu8CurrByte++ = pstrStationParam->aid & 0xFF;
2225 *pu8CurrByte++ = (pstrStationParam->aid >> 8) & 0xFF;
2227 *pu8CurrByte++ = pstrStationParam->rates_len;
2228 if (pstrStationParam->rates_len > 0)
2229 memcpy(pu8CurrByte, pstrStationParam->rates,
2230 pstrStationParam->rates_len);
2231 pu8CurrByte += pstrStationParam->rates_len;
2233 *pu8CurrByte++ = pstrStationParam->ht_supported;
2234 *pu8CurrByte++ = pstrStationParam->ht_capa_info & 0xFF;
2235 *pu8CurrByte++ = (pstrStationParam->ht_capa_info >> 8) & 0xFF;
2237 *pu8CurrByte++ = pstrStationParam->ht_ampdu_params;
2238 memcpy(pu8CurrByte, pstrStationParam->ht_supp_mcs_set,
2239 WILC_SUPP_MCS_SET_SIZE);
2240 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
2242 *pu8CurrByte++ = pstrStationParam->ht_ext_params & 0xFF;
2243 *pu8CurrByte++ = (pstrStationParam->ht_ext_params >> 8) & 0xFF;
2245 *pu8CurrByte++ = pstrStationParam->ht_tx_bf_cap & 0xFF;
2246 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 8) & 0xFF;
2247 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 16) & 0xFF;
2248 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 24) & 0xFF;
2250 *pu8CurrByte++ = pstrStationParam->ht_ante_sel;
2252 *pu8CurrByte++ = pstrStationParam->flags_mask & 0xFF;
2253 *pu8CurrByte++ = (pstrStationParam->flags_mask >> 8) & 0xFF;
2255 *pu8CurrByte++ = pstrStationParam->flags_set & 0xFF;
2256 *pu8CurrByte++ = (pstrStationParam->flags_set >> 8) & 0xFF;
2258 return pu8CurrByte - pu8Buffer;
2261 static void Handle_AddStation(struct wilc_vif *vif,
2262 struct add_sta_param *pstrStationParam)
2268 wid.id = (u16)WID_ADD_STA;
2270 wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->rates_len;
2272 wid.val = kmalloc(wid.size, GFP_KERNEL);
2276 pu8CurrByte = wid.val;
2277 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2279 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2280 wilc_get_vif_idx(vif));
2282 PRINT_ER("Failed to send add station config packet\n");
2285 kfree(pstrStationParam->rates);
2289 static void Handle_DelAllSta(struct wilc_vif *vif,
2290 struct del_all_sta *pstrDelAllStaParam)
2296 u8 au8Zero_Buff[6] = {0};
2298 wid.id = (u16)WID_DEL_ALL_STA;
2300 wid.size = (pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1;
2302 wid.val = kmalloc((pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1, GFP_KERNEL);
2306 pu8CurrByte = wid.val;
2308 *(pu8CurrByte++) = pstrDelAllStaParam->assoc_sta;
2310 for (i = 0; i < MAX_NUM_STA; i++) {
2311 if (memcmp(pstrDelAllStaParam->del_all_sta[i], au8Zero_Buff, ETH_ALEN))
2312 memcpy(pu8CurrByte, pstrDelAllStaParam->del_all_sta[i], ETH_ALEN);
2316 pu8CurrByte += ETH_ALEN;
2319 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2320 wilc_get_vif_idx(vif));
2322 PRINT_ER("Failed to send add station config packet\n");
2327 up(&hif_sema_wait_response);
2330 static void Handle_DelStation(struct wilc_vif *vif,
2331 struct del_sta *pstrDelStaParam)
2337 wid.id = (u16)WID_REMOVE_STA;
2339 wid.size = ETH_ALEN;
2341 wid.val = kmalloc(wid.size, GFP_KERNEL);
2345 pu8CurrByte = wid.val;
2347 memcpy(pu8CurrByte, pstrDelStaParam->mac_addr, ETH_ALEN);
2349 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2350 wilc_get_vif_idx(vif));
2352 PRINT_ER("Failed to send add station config packet\n");
2358 static void Handle_EditStation(struct wilc_vif *vif,
2359 struct add_sta_param *pstrStationParam)
2365 wid.id = (u16)WID_EDIT_STA;
2367 wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->rates_len;
2369 wid.val = kmalloc(wid.size, GFP_KERNEL);
2373 pu8CurrByte = wid.val;
2374 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2376 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2377 wilc_get_vif_idx(vif));
2379 PRINT_ER("Failed to send edit station config packet\n");
2382 kfree(pstrStationParam->rates);
2386 static int Handle_RemainOnChan(struct wilc_vif *vif,
2387 struct remain_ch *pstrHostIfRemainOnChan)
2390 u8 u8remain_on_chan_flag;
2392 struct host_if_drv *hif_drv = vif->hif_drv;
2394 if (!hif_drv->remain_on_ch_pending) {
2395 hif_drv->remain_on_ch.arg = pstrHostIfRemainOnChan->arg;
2396 hif_drv->remain_on_ch.expired = pstrHostIfRemainOnChan->expired;
2397 hif_drv->remain_on_ch.ready = pstrHostIfRemainOnChan->ready;
2398 hif_drv->remain_on_ch.ch = pstrHostIfRemainOnChan->ch;
2399 hif_drv->remain_on_ch.id = pstrHostIfRemainOnChan->id;
2401 pstrHostIfRemainOnChan->ch = hif_drv->remain_on_ch.ch;
2404 if (hif_drv->usr_scan_req.scan_result) {
2405 hif_drv->remain_on_ch_pending = 1;
2409 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
2414 if (wilc_optaining_ip || wilc_connecting) {
2419 u8remain_on_chan_flag = true;
2420 wid.id = (u16)WID_REMAIN_ON_CHAN;
2423 wid.val = kmalloc(wid.size, GFP_KERNEL);
2429 wid.val[0] = u8remain_on_chan_flag;
2430 wid.val[1] = (s8)pstrHostIfRemainOnChan->ch;
2432 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2433 wilc_get_vif_idx(vif));
2435 PRINT_ER("Failed to set remain on channel\n");
2439 P2P_LISTEN_STATE = 1;
2440 hif_drv->remain_on_ch_timer.data = (unsigned long)vif;
2441 mod_timer(&hif_drv->remain_on_ch_timer,
2443 msecs_to_jiffies(pstrHostIfRemainOnChan->duration));
2445 if (hif_drv->remain_on_ch.ready)
2446 hif_drv->remain_on_ch.ready(hif_drv->remain_on_ch.arg);
2448 if (hif_drv->remain_on_ch_pending)
2449 hif_drv->remain_on_ch_pending = 0;
2455 static int Handle_RegisterFrame(struct wilc_vif *vif,
2456 struct reg_frame *pstrHostIfRegisterFrame)
2462 wid.id = (u16)WID_REGISTER_FRAME;
2464 wid.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
2468 pu8CurrByte = wid.val;
2470 *pu8CurrByte++ = pstrHostIfRegisterFrame->reg;
2471 *pu8CurrByte++ = pstrHostIfRegisterFrame->reg_id;
2472 memcpy(pu8CurrByte, &pstrHostIfRegisterFrame->frame_type, sizeof(u16));
2474 wid.size = sizeof(u16) + 2;
2476 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2477 wilc_get_vif_idx(vif));
2479 PRINT_ER("Failed to frame register config packet\n");
2486 static u32 Handle_ListenStateExpired(struct wilc_vif *vif,
2487 struct remain_ch *pstrHostIfRemainOnChan)
2489 u8 u8remain_on_chan_flag;
2492 struct host_if_drv *hif_drv = vif->hif_drv;
2494 if (P2P_LISTEN_STATE) {
2495 u8remain_on_chan_flag = false;
2496 wid.id = (u16)WID_REMAIN_ON_CHAN;
2499 wid.val = kmalloc(wid.size, GFP_KERNEL);
2502 PRINT_ER("Failed to allocate memory\n");
2506 wid.val[0] = u8remain_on_chan_flag;
2507 wid.val[1] = FALSE_FRMWR_CHANNEL;
2509 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2510 wilc_get_vif_idx(vif));
2512 PRINT_ER("Failed to set remain on channel\n");
2516 if (hif_drv->remain_on_ch.expired) {
2517 hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.arg,
2518 pstrHostIfRemainOnChan->id);
2520 P2P_LISTEN_STATE = 0;
2522 netdev_dbg(vif->ndev, "Not in listen state\n");
2530 static void ListenTimerCB(unsigned long arg)
2533 struct host_if_msg msg;
2534 struct wilc_vif *vif = (struct wilc_vif *)arg;
2536 del_timer(&vif->hif_drv->remain_on_ch_timer);
2538 memset(&msg, 0, sizeof(struct host_if_msg));
2539 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
2541 msg.body.remain_on_ch.id = vif->hif_drv->remain_on_ch.id;
2543 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2545 PRINT_ER("wilc_mq_send fail\n");
2548 static void Handle_PowerManagement(struct wilc_vif *vif,
2549 struct power_mgmt_param *strPowerMgmtParam)
2555 wid.id = (u16)WID_POWER_MANAGEMENT;
2557 if (strPowerMgmtParam->enabled)
2558 s8PowerMode = MIN_FAST_PS;
2560 s8PowerMode = NO_POWERSAVE;
2562 wid.val = &s8PowerMode;
2563 wid.size = sizeof(char);
2565 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2566 wilc_get_vif_idx(vif));
2568 PRINT_ER("Failed to send power management config packet\n");
2571 static void Handle_SetMulticastFilter(struct wilc_vif *vif,
2572 struct set_multicast *strHostIfSetMulti)
2578 wid.id = (u16)WID_SETUP_MULTICAST_FILTER;
2580 wid.size = sizeof(struct set_multicast) + ((strHostIfSetMulti->cnt) * ETH_ALEN);
2581 wid.val = kmalloc(wid.size, GFP_KERNEL);
2585 pu8CurrByte = wid.val;
2586 *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF);
2591 *pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF);
2592 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF);
2593 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 16) & 0xFF);
2594 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 24) & 0xFF);
2596 if ((strHostIfSetMulti->cnt) > 0)
2597 memcpy(pu8CurrByte, wilc_multicast_mac_addr_list,
2598 ((strHostIfSetMulti->cnt) * ETH_ALEN));
2600 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2601 wilc_get_vif_idx(vif));
2603 PRINT_ER("Failed to send setup multicast config packet\n");
2609 static s32 Handle_DelAllRxBASessions(struct wilc_vif *vif,
2610 struct ba_session_info *strHostIfBASessionInfo)
2616 wid.id = (u16)WID_DEL_ALL_RX_BA;
2618 wid.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2619 wid.size = BLOCK_ACK_REQ_SIZE;
2624 memcpy(ptr, strHostIfBASessionInfo->bssid, ETH_ALEN);
2626 *ptr++ = strHostIfBASessionInfo->tid;
2630 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2631 wilc_get_vif_idx(vif));
2635 up(&hif_sema_wait_response);
2640 static void handle_set_tx_pwr(struct wilc_vif *vif, u8 tx_pwr)
2645 wid.id = (u16)WID_TX_POWER;
2646 wid.type = WID_CHAR;
2648 wid.size = sizeof(char);
2650 ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2651 wilc_get_vif_idx(vif));
2653 netdev_err(vif->ndev, "Failed to set TX PWR\n");
2656 static void handle_get_tx_pwr(struct wilc_vif *vif, u8 *tx_pwr)
2661 wid.id = (u16)WID_TX_POWER;
2662 wid.type = WID_CHAR;
2663 wid.val = (s8 *)tx_pwr;
2664 wid.size = sizeof(char);
2666 ret = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
2667 wilc_get_vif_idx(vif));
2669 netdev_err(vif->ndev, "Failed to get TX PWR\n");
2671 up(&hif_sema_wait_response);
2674 static int hostIFthread(void *pvArg)
2677 struct host_if_msg msg;
2678 struct wilc *wilc = (struct wilc*)pvArg;
2679 struct wilc_vif *vif;
2681 memset(&msg, 0, sizeof(struct host_if_msg));
2684 wilc_mq_recv(&hif_msg_q, &msg, sizeof(struct host_if_msg), &u32Ret);
2686 if (msg.id == HOST_IF_MSG_EXIT)
2689 if ((!wilc_initialized)) {
2690 usleep_range(200 * 1000, 200 * 1000);
2691 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2695 if (msg.id == HOST_IF_MSG_CONNECT &&
2696 vif->hif_drv->usr_scan_req.scan_result) {
2697 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2698 usleep_range(2 * 1000, 2 * 1000);
2703 case HOST_IF_MSG_Q_IDLE:
2704 Handle_wait_msg_q_empty();
2707 case HOST_IF_MSG_SCAN:
2708 Handle_Scan(msg.vif, &msg.body.scan_info);
2711 case HOST_IF_MSG_CONNECT:
2712 Handle_Connect(msg.vif, &msg.body.con_info);
2715 case HOST_IF_MSG_FLUSH_CONNECT:
2716 Handle_FlushConnect(msg.vif);
2719 case HOST_IF_MSG_RCVD_NTWRK_INFO:
2720 Handle_RcvdNtwrkInfo(msg.vif, &msg.body.net_info);
2723 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
2724 Handle_RcvdGnrlAsyncInfo(vif,
2725 &msg.body.async_info);
2728 case HOST_IF_MSG_KEY:
2729 Handle_Key(msg.vif, &msg.body.key_info);
2732 case HOST_IF_MSG_CFG_PARAMS:
2733 handle_cfg_param(msg.vif, &msg.body.cfg_info);
2736 case HOST_IF_MSG_SET_CHANNEL:
2737 handle_set_channel(msg.vif, &msg.body.channel_info);
2740 case HOST_IF_MSG_DISCONNECT:
2741 Handle_Disconnect(msg.vif);
2744 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
2745 del_timer(&vif->hif_drv->scan_timer);
2747 if (!wilc_wlan_get_num_conn_ifcs(wilc))
2748 wilc_chip_sleep_manually(wilc);
2750 Handle_ScanDone(msg.vif, SCAN_EVENT_DONE);
2752 if (vif->hif_drv->remain_on_ch_pending)
2753 Handle_RemainOnChan(msg.vif,
2754 &msg.body.remain_on_ch);
2758 case HOST_IF_MSG_GET_RSSI:
2759 Handle_GetRssi(msg.vif);
2762 case HOST_IF_MSG_GET_LINKSPEED:
2763 Handle_GetLinkspeed(msg.vif);
2766 case HOST_IF_MSG_GET_STATISTICS:
2767 Handle_GetStatistics(msg.vif,
2768 (struct rf_info *)msg.body.data);
2771 case HOST_IF_MSG_GET_CHNL:
2772 Handle_GetChnl(msg.vif);
2775 case HOST_IF_MSG_ADD_BEACON:
2776 Handle_AddBeacon(msg.vif, &msg.body.beacon_info);
2779 case HOST_IF_MSG_DEL_BEACON:
2780 Handle_DelBeacon(msg.vif);
2783 case HOST_IF_MSG_ADD_STATION:
2784 Handle_AddStation(msg.vif, &msg.body.add_sta_info);
2787 case HOST_IF_MSG_DEL_STATION:
2788 Handle_DelStation(msg.vif, &msg.body.del_sta_info);
2791 case HOST_IF_MSG_EDIT_STATION:
2792 Handle_EditStation(msg.vif, &msg.body.edit_sta_info);
2795 case HOST_IF_MSG_GET_INACTIVETIME:
2796 Handle_Get_InActiveTime(msg.vif, &msg.body.mac_info);
2799 case HOST_IF_MSG_SCAN_TIMER_FIRED:
2801 Handle_ScanDone(msg.vif, SCAN_EVENT_ABORTED);
2804 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
2805 Handle_ConnectTimeout(msg.vif);
2808 case HOST_IF_MSG_POWER_MGMT:
2809 Handle_PowerManagement(msg.vif,
2810 &msg.body.pwr_mgmt_info);
2813 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
2814 handle_set_wfi_drv_handler(msg.vif, &msg.body.drv);
2817 case HOST_IF_MSG_SET_OPERATION_MODE:
2818 handle_set_operation_mode(msg.vif, &msg.body.mode);
2821 case HOST_IF_MSG_SET_IPADDRESS:
2822 handle_set_ip_address(vif,
2823 msg.body.ip_info.ip_addr,
2824 msg.body.ip_info.idx);
2827 case HOST_IF_MSG_GET_IPADDRESS:
2828 handle_get_ip_address(vif, msg.body.ip_info.idx);
2831 case HOST_IF_MSG_SET_MAC_ADDRESS:
2832 handle_set_mac_address(msg.vif,
2833 &msg.body.set_mac_info);
2836 case HOST_IF_MSG_GET_MAC_ADDRESS:
2837 handle_get_mac_address(msg.vif,
2838 &msg.body.get_mac_info);
2841 case HOST_IF_MSG_REMAIN_ON_CHAN:
2842 Handle_RemainOnChan(msg.vif, &msg.body.remain_on_ch);
2845 case HOST_IF_MSG_REGISTER_FRAME:
2846 Handle_RegisterFrame(msg.vif, &msg.body.reg_frame);
2849 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
2850 Handle_ListenStateExpired(msg.vif, &msg.body.remain_on_ch);
2853 case HOST_IF_MSG_SET_MULTICAST_FILTER:
2854 Handle_SetMulticastFilter(msg.vif, &msg.body.multicast_info);
2857 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
2858 Handle_DelAllRxBASessions(msg.vif, &msg.body.session_info);
2861 case HOST_IF_MSG_DEL_ALL_STA:
2862 Handle_DelAllSta(msg.vif, &msg.body.del_all_sta_info);
2865 case HOST_IF_MSG_SET_TX_POWER:
2866 handle_set_tx_pwr(msg.vif, msg.body.tx_power.tx_pwr);
2869 case HOST_IF_MSG_GET_TX_POWER:
2870 handle_get_tx_pwr(msg.vif, &msg.body.tx_power.tx_pwr);
2873 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
2878 up(&hif_sema_thread);
2882 static void TimerCB_Scan(unsigned long arg)
2884 struct wilc_vif *vif = (struct wilc_vif *)arg;
2885 struct host_if_msg msg;
2887 memset(&msg, 0, sizeof(struct host_if_msg));
2889 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
2891 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2894 static void TimerCB_Connect(unsigned long arg)
2896 struct wilc_vif *vif = (struct wilc_vif *)arg;
2897 struct host_if_msg msg;
2899 memset(&msg, 0, sizeof(struct host_if_msg));
2901 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
2903 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2906 s32 wilc_remove_key(struct host_if_drv *hif_drv, const u8 *pu8StaAddress)
2910 wid.id = (u16)WID_REMOVE_KEY;
2912 wid.val = (s8 *)pu8StaAddress;
2918 int wilc_remove_wep_key(struct wilc_vif *vif, u8 index)
2921 struct host_if_msg msg;
2922 struct host_if_drv *hif_drv = vif->hif_drv;
2926 PRINT_ER("Failed to send setup multicast config packet\n");
2930 memset(&msg, 0, sizeof(struct host_if_msg));
2932 msg.id = HOST_IF_MSG_KEY;
2933 msg.body.key_info.type = WEP;
2934 msg.body.key_info.action = REMOVEKEY;
2936 msg.body.key_info.attr.wep.index = index;
2938 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2940 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
2941 down(&hif_drv->sem_test_key_block);
2946 int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index)
2949 struct host_if_msg msg;
2950 struct host_if_drv *hif_drv = vif->hif_drv;
2954 PRINT_ER("driver is null\n");
2958 memset(&msg, 0, sizeof(struct host_if_msg));
2960 msg.id = HOST_IF_MSG_KEY;
2961 msg.body.key_info.type = WEP;
2962 msg.body.key_info.action = DEFAULTKEY;
2964 msg.body.key_info.attr.wep.index = index;
2966 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2968 PRINT_ER("Error in sending message queue : Default key index\n");
2969 down(&hif_drv->sem_test_key_block);
2974 int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len,
2978 struct host_if_msg msg;
2979 struct host_if_drv *hif_drv = vif->hif_drv;
2982 PRINT_ER("driver is null\n");
2986 memset(&msg, 0, sizeof(struct host_if_msg));
2988 msg.id = HOST_IF_MSG_KEY;
2989 msg.body.key_info.type = WEP;
2990 msg.body.key_info.action = ADDKEY;
2992 msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
2993 if (!msg.body.key_info.attr.wep.key)
2996 msg.body.key_info.attr.wep.key_len = len;
2997 msg.body.key_info.attr.wep.index = index;
2999 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3001 PRINT_ER("Error in sending message queue :WEP Key\n");
3002 down(&hif_drv->sem_test_key_block);
3007 int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len,
3008 u8 index, u8 mode, enum AUTHTYPE auth_type)
3011 struct host_if_msg msg;
3012 struct host_if_drv *hif_drv = vif->hif_drv;
3016 PRINT_ER("driver is null\n");
3020 memset(&msg, 0, sizeof(struct host_if_msg));
3023 for (i = 0; i < len; i++)
3024 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", key[i]);
3026 msg.id = HOST_IF_MSG_KEY;
3027 msg.body.key_info.type = WEP;
3028 msg.body.key_info.action = ADDKEY_AP;
3030 msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
3031 if (!msg.body.key_info.attr.wep.key)
3034 msg.body.key_info.attr.wep.key_len = len;
3035 msg.body.key_info.attr.wep.index = index;
3036 msg.body.key_info.attr.wep.mode = mode;
3037 msg.body.key_info.attr.wep.auth_type = auth_type;
3039 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3042 PRINT_ER("Error in sending message queue :WEP Key\n");
3043 down(&hif_drv->sem_test_key_block);
3048 int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
3049 const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
3050 u8 mode, u8 cipher_mode, u8 index)
3053 struct host_if_msg msg;
3054 struct host_if_drv *hif_drv = vif->hif_drv;
3055 u8 key_len = ptk_key_len;
3059 PRINT_ER("driver is null\n");
3064 key_len += RX_MIC_KEY_LEN;
3067 key_len += TX_MIC_KEY_LEN;
3069 memset(&msg, 0, sizeof(struct host_if_msg));
3071 msg.id = HOST_IF_MSG_KEY;
3072 msg.body.key_info.type = WPA_PTK;
3073 if (mode == AP_MODE) {
3074 msg.body.key_info.action = ADDKEY_AP;
3075 msg.body.key_info.attr.wpa.index = index;
3077 if (mode == STATION_MODE)
3078 msg.body.key_info.action = ADDKEY;
3080 msg.body.key_info.attr.wpa.key = kmemdup(ptk, ptk_key_len, GFP_KERNEL);
3081 if (!msg.body.key_info.attr.wpa.key)
3085 memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic, RX_MIC_KEY_LEN);
3087 for (i = 0; i < RX_MIC_KEY_LEN; i++)
3088 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, rx_mic[i]);
3092 memcpy(msg.body.key_info.attr.wpa.key + 24, tx_mic, TX_MIC_KEY_LEN);
3094 for (i = 0; i < TX_MIC_KEY_LEN; i++)
3095 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, tx_mic[i]);
3099 msg.body.key_info.attr.wpa.key_len = key_len;
3100 msg.body.key_info.attr.wpa.mac_addr = mac_addr;
3101 msg.body.key_info.attr.wpa.mode = cipher_mode;
3104 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3107 PRINT_ER("Error in sending message queue: PTK Key\n");
3109 down(&hif_drv->sem_test_key_block);
3114 int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
3115 u8 index, u32 key_rsc_len, const u8 *key_rsc,
3116 const u8 *rx_mic, const u8 *tx_mic, u8 mode,
3120 struct host_if_msg msg;
3121 struct host_if_drv *hif_drv = vif->hif_drv;
3122 u8 key_len = gtk_key_len;
3125 PRINT_ER("driver is null\n");
3128 memset(&msg, 0, sizeof(struct host_if_msg));
3131 key_len += RX_MIC_KEY_LEN;
3134 key_len += TX_MIC_KEY_LEN;
3137 msg.body.key_info.attr.wpa.seq = kmemdup(key_rsc,
3140 if (!msg.body.key_info.attr.wpa.seq)
3144 msg.id = HOST_IF_MSG_KEY;
3145 msg.body.key_info.type = WPA_RX_GTK;
3148 if (mode == AP_MODE) {
3149 msg.body.key_info.action = ADDKEY_AP;
3150 msg.body.key_info.attr.wpa.mode = cipher_mode;
3152 if (mode == STATION_MODE)
3153 msg.body.key_info.action = ADDKEY;
3155 msg.body.key_info.attr.wpa.key = kmemdup(rx_gtk,
3158 if (!msg.body.key_info.attr.wpa.key)
3162 memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic,
3166 memcpy(msg.body.key_info.attr.wpa.key + 24, tx_mic,
3169 msg.body.key_info.attr.wpa.index = index;
3170 msg.body.key_info.attr.wpa.key_len = key_len;
3171 msg.body.key_info.attr.wpa.seq_len = key_rsc_len;
3173 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3175 PRINT_ER("Error in sending message queue: RX GTK\n");
3177 down(&hif_drv->sem_test_key_block);
3182 int wilc_set_pmkid_info(struct wilc_vif *vif,
3183 struct host_if_pmkid_attr *pmkid)
3186 struct host_if_msg msg;
3187 struct host_if_drv *hif_drv = vif->hif_drv;
3191 PRINT_ER("driver is null\n");
3195 memset(&msg, 0, sizeof(struct host_if_msg));
3197 msg.id = HOST_IF_MSG_KEY;
3198 msg.body.key_info.type = PMKSA;
3199 msg.body.key_info.action = ADDKEY;
3202 for (i = 0; i < pmkid->numpmkid; i++) {
3203 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].bssid,
3204 &pmkid->pmkidlist[i].bssid, ETH_ALEN);
3205 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].pmkid,
3206 &pmkid->pmkidlist[i].pmkid, PMKID_LEN);
3209 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3211 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
3216 int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr)
3219 struct host_if_msg msg;
3221 memset(&msg, 0, sizeof(struct host_if_msg));
3223 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
3224 msg.body.get_mac_info.mac_addr = mac_addr;
3227 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3229 PRINT_ER("Failed to send get mac address\n");
3233 down(&hif_sema_wait_response);
3237 int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid,
3238 size_t ssid_len, const u8 *ies, size_t ies_len,
3239 wilc_connect_result connect_result, void *user_arg,
3240 u8 security, enum AUTHTYPE auth_type,
3241 u8 channel, void *join_params)
3244 struct host_if_msg msg;
3245 struct host_if_drv *hif_drv = vif->hif_drv;
3247 if (!hif_drv || !connect_result) {
3248 PRINT_ER("Driver is null\n");
3253 PRINT_ER("Unable to Join - JoinParams is NULL\n");
3257 memset(&msg, 0, sizeof(struct host_if_msg));
3259 msg.id = HOST_IF_MSG_CONNECT;
3261 msg.body.con_info.security = security;
3262 msg.body.con_info.auth_type = auth_type;
3263 msg.body.con_info.ch = channel;
3264 msg.body.con_info.result = connect_result;
3265 msg.body.con_info.arg = user_arg;
3266 msg.body.con_info.params = join_params;
3270 msg.body.con_info.bssid = kmemdup(bssid, 6, GFP_KERNEL);
3271 if (!msg.body.con_info.bssid)
3276 msg.body.con_info.ssid_len = ssid_len;
3277 msg.body.con_info.ssid = kmemdup(ssid, ssid_len, GFP_KERNEL);
3278 if (!msg.body.con_info.ssid)
3283 msg.body.con_info.ies_len = ies_len;
3284 msg.body.con_info.ies = kmemdup(ies, ies_len, GFP_KERNEL);
3285 if (!msg.body.con_info.ies)
3288 if (hif_drv->hif_state < HOST_IF_CONNECTING)
3289 hif_drv->hif_state = HOST_IF_CONNECTING;
3291 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3293 PRINT_ER("Failed to send message queue: Set join request\n");
3297 hif_drv->connect_timer.data = (unsigned long)vif;
3298 mod_timer(&hif_drv->connect_timer,
3299 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
3304 int wilc_disconnect(struct wilc_vif *vif, u16 reason_code)
3307 struct host_if_msg msg;
3308 struct host_if_drv *hif_drv = vif->hif_drv;
3311 PRINT_ER("Driver is null\n");
3315 memset(&msg, 0, sizeof(struct host_if_msg));
3317 msg.id = HOST_IF_MSG_DISCONNECT;
3320 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3322 PRINT_ER("Failed to send message queue: disconnect\n");
3324 down(&hif_drv->sem_test_disconn_block);
3329 static s32 host_int_get_assoc_res_info(struct wilc_vif *vif,
3330 u8 *pu8AssocRespInfo,
3331 u32 u32MaxAssocRespInfoLen,
3332 u32 *pu32RcvdAssocRespInfoLen)
3336 struct host_if_drv *hif_drv = vif->hif_drv;
3339 PRINT_ER("Driver is null\n");
3343 wid.id = (u16)WID_ASSOC_RES_INFO;
3345 wid.val = pu8AssocRespInfo;
3346 wid.size = u32MaxAssocRespInfoLen;
3348 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
3349 wilc_get_vif_idx(vif));
3351 *pu32RcvdAssocRespInfoLen = 0;
3352 PRINT_ER("Failed to send association response config packet\n");
3355 *pu32RcvdAssocRespInfoLen = wid.size;
3361 int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel)
3364 struct host_if_msg msg;
3365 struct host_if_drv *hif_drv = vif->hif_drv;
3368 PRINT_ER("driver is null\n");
3372 memset(&msg, 0, sizeof(struct host_if_msg));
3373 msg.id = HOST_IF_MSG_SET_CHANNEL;
3374 msg.body.channel_info.set_ch = channel;
3377 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3379 PRINT_ER("wilc mq send fail\n");
3386 int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mac_idx)
3389 struct host_if_msg msg;
3391 memset(&msg, 0, sizeof(struct host_if_msg));
3392 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
3393 msg.body.drv.handler = index;
3394 msg.body.drv.mac_idx = mac_idx;
3397 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3399 PRINT_ER("wilc mq send fail\n");
3406 int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode)
3409 struct host_if_msg msg;
3411 memset(&msg, 0, sizeof(struct host_if_msg));
3412 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
3413 msg.body.mode.mode = mode;
3416 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3418 PRINT_ER("wilc mq send fail\n");
3425 s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
3426 u32 *pu32InactiveTime)
3429 struct host_if_msg msg;
3430 struct host_if_drv *hif_drv = vif->hif_drv;
3433 PRINT_ER("driver is null\n");
3437 memset(&msg, 0, sizeof(struct host_if_msg));
3438 memcpy(msg.body.mac_info.mac, mac, ETH_ALEN);
3440 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
3443 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3445 PRINT_ER("Failed to send get host channel param's message queue ");
3447 down(&hif_drv->sem_inactive_time);
3449 *pu32InactiveTime = inactive_time;
3454 int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level)
3457 struct host_if_msg msg;
3458 struct host_if_drv *hif_drv = vif->hif_drv;
3460 memset(&msg, 0, sizeof(struct host_if_msg));
3461 msg.id = HOST_IF_MSG_GET_RSSI;
3464 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3466 PRINT_ER("Failed to send get host channel param's message queue ");
3470 down(&hif_drv->sem_get_rssi);
3473 PRINT_ER("RSS pointer value is null");
3482 int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats)
3485 struct host_if_msg msg;
3487 memset(&msg, 0, sizeof(struct host_if_msg));
3488 msg.id = HOST_IF_MSG_GET_STATISTICS;
3489 msg.body.data = (char *)stats;
3492 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3494 PRINT_ER("Failed to send get host channel param's message queue ");
3498 if (stats != &vif->wilc->dummy_statistics)
3499 down(&hif_sema_wait_response);
3503 int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
3504 u8 *ch_freq_list, u8 ch_list_len, const u8 *ies,
3505 size_t ies_len, wilc_scan_result scan_result, void *user_arg,
3506 struct hidden_network *hidden_network)
3509 struct host_if_msg msg;
3510 struct scan_attr *scan_info = &msg.body.scan_info;
3511 struct host_if_drv *hif_drv = vif->hif_drv;
3513 if (!hif_drv || !scan_result) {
3514 PRINT_ER("hif_drv or scan_result = NULL\n");
3518 memset(&msg, 0, sizeof(struct host_if_msg));
3520 msg.id = HOST_IF_MSG_SCAN;
3522 if (hidden_network) {
3523 scan_info->hidden_network.net_info = hidden_network->net_info;
3524 scan_info->hidden_network.n_ssids = hidden_network->n_ssids;
3528 scan_info->src = scan_source;
3529 scan_info->type = scan_type;
3530 scan_info->result = scan_result;
3531 scan_info->arg = user_arg;
3533 scan_info->ch_list_len = ch_list_len;
3534 scan_info->ch_freq_list = kmemdup(ch_freq_list,
3537 if (!scan_info->ch_freq_list)
3540 scan_info->ies_len = ies_len;
3541 scan_info->ies = kmemdup(ies, ies_len, GFP_KERNEL);
3542 if (!scan_info->ies)
3545 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3547 PRINT_ER("Error in sending message queue\n");
3551 hif_drv->scan_timer.data = (unsigned long)vif;
3552 mod_timer(&hif_drv->scan_timer,
3553 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
3558 int wilc_hif_set_cfg(struct wilc_vif *vif,
3559 struct cfg_param_val *cfg_param)
3562 struct host_if_msg msg;
3563 struct host_if_drv *hif_drv = vif->hif_drv;
3566 PRINT_ER("hif_drv NULL\n");
3570 memset(&msg, 0, sizeof(struct host_if_msg));
3571 msg.id = HOST_IF_MSG_CFG_PARAMS;
3572 msg.body.cfg_info.cfg_attr_info = *cfg_param;
3575 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3580 static void GetPeriodicRSSI(unsigned long arg)
3582 struct wilc_vif *vif = (struct wilc_vif *)arg;
3584 if (!vif->hif_drv) {
3585 PRINT_ER("Driver handler is NULL\n");
3589 if (vif->hif_drv->hif_state == HOST_IF_CONNECTED)
3590 wilc_get_statistics(vif, &vif->wilc->dummy_statistics);
3592 periodic_rssi.data = (unsigned long)vif;
3593 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
3596 int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
3599 struct host_if_drv *hif_drv;
3600 struct wilc_vif *vif;
3604 vif = netdev_priv(dev);
3607 scan_while_connected = false;
3609 sema_init(&hif_sema_wait_response, 0);
3611 hif_drv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
3616 *hif_drv_handler = hif_drv;
3617 for (i = 0; i < wilc->vif_num; i++)
3618 if (dev == wilc->vif[i]->ndev) {
3619 wilc->vif[i]->hif_drv = hif_drv;
3623 wilc_optaining_ip = false;
3625 if (clients_count == 0) {
3626 sema_init(&hif_sema_thread, 0);
3627 sema_init(&hif_sema_driver, 0);
3628 sema_init(&hif_sema_deinit, 1);
3631 sema_init(&hif_drv->sem_test_key_block, 0);
3632 sema_init(&hif_drv->sem_test_disconn_block, 0);
3633 sema_init(&hif_drv->sem_get_rssi, 0);
3634 sema_init(&hif_drv->sem_get_link_speed, 0);
3635 sema_init(&hif_drv->sem_get_chnl, 0);
3636 sema_init(&hif_drv->sem_inactive_time, 0);
3638 if (clients_count == 0) {
3639 result = wilc_mq_create(&hif_msg_q);
3642 PRINT_ER("Failed to creat MQ\n");
3646 hif_thread_handler = kthread_run(hostIFthread, wilc,
3649 if (IS_ERR(hif_thread_handler)) {
3650 PRINT_ER("Failed to creat Thread\n");
3654 setup_timer(&periodic_rssi, GetPeriodicRSSI,
3655 (unsigned long)vif);
3656 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
3659 setup_timer(&hif_drv->scan_timer, TimerCB_Scan, 0);
3660 setup_timer(&hif_drv->connect_timer, TimerCB_Connect, 0);
3661 setup_timer(&hif_drv->remain_on_ch_timer, ListenTimerCB, 0);
3663 sema_init(&hif_drv->sem_cfg_values, 1);
3664 down(&hif_drv->sem_cfg_values);
3666 hif_drv->hif_state = HOST_IF_IDLE;
3667 hif_drv->cfg_values.site_survey_enabled = SITE_SURVEY_OFF;
3668 hif_drv->cfg_values.scan_source = DEFAULT_SCAN;
3669 hif_drv->cfg_values.active_scan_time = ACTIVE_SCAN_TIME;
3670 hif_drv->cfg_values.passive_scan_time = PASSIVE_SCAN_TIME;
3671 hif_drv->cfg_values.curr_tx_rate = AUTORATE;
3673 hif_drv->p2p_timeout = 0;
3675 up(&hif_drv->sem_cfg_values);
3682 wilc_mq_destroy(&hif_msg_q);
3687 int wilc_deinit(struct wilc_vif *vif)
3690 struct host_if_msg msg;
3691 struct host_if_drv *hif_drv = vif->hif_drv;
3694 PRINT_ER("hif_drv = NULL\n");
3698 down(&hif_sema_deinit);
3700 terminated_handle = hif_drv;
3702 del_timer_sync(&hif_drv->scan_timer);
3703 del_timer_sync(&hif_drv->connect_timer);
3704 del_timer_sync(&periodic_rssi);
3705 del_timer_sync(&hif_drv->remain_on_ch_timer);
3707 wilc_set_wfi_drv_handler(vif, 0, 0);
3708 down(&hif_sema_driver);
3710 if (hif_drv->usr_scan_req.scan_result) {
3711 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, NULL,
3712 hif_drv->usr_scan_req.arg, NULL);
3713 hif_drv->usr_scan_req.scan_result = NULL;
3716 hif_drv->hif_state = HOST_IF_IDLE;
3718 scan_while_connected = false;
3720 memset(&msg, 0, sizeof(struct host_if_msg));
3722 if (clients_count == 1) {
3723 del_timer_sync(&periodic_rssi);
3724 msg.id = HOST_IF_MSG_EXIT;
3727 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3729 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", result);
3731 down(&hif_sema_thread);
3733 wilc_mq_destroy(&hif_msg_q);
3739 terminated_handle = NULL;
3740 up(&hif_sema_deinit);
3744 void wilc_network_info_received(struct wilc *wilc, u8 *pu8Buffer,
3748 struct host_if_msg msg;
3750 struct host_if_drv *hif_drv = NULL;
3751 struct wilc_vif *vif;
3753 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
3754 vif = wilc_get_vif_from_idx(wilc, id);
3757 hif_drv = vif->hif_drv;
3759 if (!hif_drv || hif_drv == terminated_handle) {
3760 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv);
3764 memset(&msg, 0, sizeof(struct host_if_msg));
3766 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
3769 msg.body.net_info.len = u32Length;
3770 msg.body.net_info.buffer = kmalloc(u32Length, GFP_KERNEL);
3771 memcpy(msg.body.net_info.buffer, pu8Buffer, u32Length);
3773 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3775 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", result);
3778 void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *pu8Buffer,
3782 struct host_if_msg msg;
3784 struct host_if_drv *hif_drv = NULL;
3785 struct wilc_vif *vif;
3787 down(&hif_sema_deinit);
3789 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
3790 vif = wilc_get_vif_from_idx(wilc, id);
3792 up(&hif_sema_deinit);
3796 hif_drv = vif->hif_drv;
3798 if (!hif_drv || hif_drv == terminated_handle) {
3799 up(&hif_sema_deinit);
3803 if (!hif_drv->usr_conn_req.conn_result) {
3804 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
3805 up(&hif_sema_deinit);
3809 memset(&msg, 0, sizeof(struct host_if_msg));
3811 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
3814 msg.body.async_info.len = u32Length;
3815 msg.body.async_info.buffer = kmalloc(u32Length, GFP_KERNEL);
3816 memcpy(msg.body.async_info.buffer, pu8Buffer, u32Length);
3818 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3820 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", result);
3822 up(&hif_sema_deinit);
3825 void wilc_scan_complete_received(struct wilc *wilc, u8 *pu8Buffer,
3829 struct host_if_msg msg;
3831 struct host_if_drv *hif_drv = NULL;
3832 struct wilc_vif *vif;
3834 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
3835 vif = wilc_get_vif_from_idx(wilc, id);
3838 hif_drv = vif->hif_drv;
3840 if (!hif_drv || hif_drv == terminated_handle)
3843 if (hif_drv->usr_scan_req.scan_result) {
3844 memset(&msg, 0, sizeof(struct host_if_msg));
3846 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
3849 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3851 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", result);
3857 int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id,
3858 u32 duration, u16 chan,
3859 wilc_remain_on_chan_expired expired,
3860 wilc_remain_on_chan_ready ready,
3864 struct host_if_msg msg;
3865 struct host_if_drv *hif_drv = vif->hif_drv;
3868 PRINT_ER("driver is null\n");
3872 memset(&msg, 0, sizeof(struct host_if_msg));
3874 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
3875 msg.body.remain_on_ch.ch = chan;
3876 msg.body.remain_on_ch.expired = expired;
3877 msg.body.remain_on_ch.ready = ready;
3878 msg.body.remain_on_ch.arg = user_arg;
3879 msg.body.remain_on_ch.duration = duration;
3880 msg.body.remain_on_ch.id = session_id;
3883 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3885 PRINT_ER("wilc mq send fail\n");
3890 int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id)
3893 struct host_if_msg msg;
3894 struct host_if_drv *hif_drv = vif->hif_drv;
3897 PRINT_ER("driver is null\n");
3901 del_timer(&hif_drv->remain_on_ch_timer);
3903 memset(&msg, 0, sizeof(struct host_if_msg));
3904 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
3906 msg.body.remain_on_ch.id = session_id;
3908 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3910 PRINT_ER("wilc mq send fail\n");
3915 int wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg)
3918 struct host_if_msg msg;
3919 struct host_if_drv *hif_drv = vif->hif_drv;
3922 PRINT_ER("driver is null\n");
3926 memset(&msg, 0, sizeof(struct host_if_msg));
3928 msg.id = HOST_IF_MSG_REGISTER_FRAME;
3929 switch (frame_type) {
3931 msg.body.reg_frame.reg_id = ACTION_FRM_IDX;
3935 msg.body.reg_frame.reg_id = PROBE_REQ_IDX;
3941 msg.body.reg_frame.frame_type = frame_type;
3942 msg.body.reg_frame.reg = reg;
3945 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3947 PRINT_ER("wilc mq send fail\n");
3952 int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period,
3953 u32 head_len, u8 *head, u32 tail_len, u8 *tail)
3956 struct host_if_msg msg;
3957 struct beacon_attr *beacon_info = &msg.body.beacon_info;
3958 struct host_if_drv *hif_drv = vif->hif_drv;
3961 PRINT_ER("driver is null\n");
3965 memset(&msg, 0, sizeof(struct host_if_msg));
3967 msg.id = HOST_IF_MSG_ADD_BEACON;
3969 beacon_info->interval = interval;
3970 beacon_info->dtim_period = dtim_period;
3971 beacon_info->head_len = head_len;
3972 beacon_info->head = kmemdup(head, head_len, GFP_KERNEL);
3973 if (!beacon_info->head) {
3977 beacon_info->tail_len = tail_len;
3980 beacon_info->tail = kmemdup(tail, tail_len, GFP_KERNEL);
3981 if (!beacon_info->tail) {
3986 beacon_info->tail = NULL;
3989 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3991 PRINT_ER("wilc mq send fail\n");
3995 kfree(beacon_info->head);
3997 kfree(beacon_info->tail);
4003 int wilc_del_beacon(struct wilc_vif *vif)
4006 struct host_if_msg msg;
4007 struct host_if_drv *hif_drv = vif->hif_drv;
4010 PRINT_ER("driver is null\n");
4014 msg.id = HOST_IF_MSG_DEL_BEACON;
4017 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4019 PRINT_ER("wilc_mq_send fail\n");
4024 int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param)
4027 struct host_if_msg msg;
4028 struct add_sta_param *add_sta_info = &msg.body.add_sta_info;
4029 struct host_if_drv *hif_drv = vif->hif_drv;
4032 PRINT_ER("driver is null\n");
4036 memset(&msg, 0, sizeof(struct host_if_msg));
4038 msg.id = HOST_IF_MSG_ADD_STATION;
4041 memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param));
4042 if (add_sta_info->rates_len > 0) {
4043 add_sta_info->rates = kmemdup(sta_param->rates,
4044 add_sta_info->rates_len,
4046 if (!add_sta_info->rates)
4050 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4052 PRINT_ER("wilc_mq_send fail\n");
4056 int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr)
4059 struct host_if_msg msg;
4060 struct del_sta *del_sta_info = &msg.body.del_sta_info;
4061 struct host_if_drv *hif_drv = vif->hif_drv;
4064 PRINT_ER("driver is null\n");
4068 memset(&msg, 0, sizeof(struct host_if_msg));
4070 msg.id = HOST_IF_MSG_DEL_STATION;
4074 eth_broadcast_addr(del_sta_info->mac_addr);
4076 memcpy(del_sta_info->mac_addr, mac_addr, ETH_ALEN);
4078 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4080 PRINT_ER("wilc_mq_send fail\n");
4084 int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN])
4087 struct host_if_msg msg;
4088 struct del_all_sta *del_all_sta_info = &msg.body.del_all_sta_info;
4089 struct host_if_drv *hif_drv = vif->hif_drv;
4090 u8 zero_addr[ETH_ALEN] = {0};
4095 PRINT_ER("driver is null\n");
4099 memset(&msg, 0, sizeof(struct host_if_msg));
4101 msg.id = HOST_IF_MSG_DEL_ALL_STA;
4104 for (i = 0; i < MAX_NUM_STA; i++) {
4105 if (memcmp(mac_addr[i], zero_addr, ETH_ALEN)) {
4106 memcpy(del_all_sta_info->del_all_sta[i], mac_addr[i], ETH_ALEN);
4107 PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n",
4108 del_all_sta_info->del_all_sta[i][0],
4109 del_all_sta_info->del_all_sta[i][1],
4110 del_all_sta_info->del_all_sta[i][2],
4111 del_all_sta_info->del_all_sta[i][3],
4112 del_all_sta_info->del_all_sta[i][4],
4113 del_all_sta_info->del_all_sta[i][5]);
4118 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
4122 del_all_sta_info->assoc_sta = assoc_sta;
4123 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4126 PRINT_ER("wilc_mq_send fail\n");
4128 down(&hif_sema_wait_response);
4133 int wilc_edit_station(struct wilc_vif *vif,
4134 struct add_sta_param *sta_param)
4137 struct host_if_msg msg;
4138 struct add_sta_param *add_sta_info = &msg.body.add_sta_info;
4139 struct host_if_drv *hif_drv = vif->hif_drv;
4142 PRINT_ER("driver is null\n");
4146 memset(&msg, 0, sizeof(struct host_if_msg));
4148 msg.id = HOST_IF_MSG_EDIT_STATION;
4151 memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param));
4152 if (add_sta_info->rates_len > 0) {
4153 add_sta_info->rates = kmemdup(sta_param->rates,
4154 add_sta_info->rates_len,
4156 if (!add_sta_info->rates)
4160 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4162 PRINT_ER("wilc_mq_send fail\n");
4167 int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout)
4170 struct host_if_msg msg;
4171 struct power_mgmt_param *pwr_mgmt_info = &msg.body.pwr_mgmt_info;
4172 struct host_if_drv *hif_drv = vif->hif_drv;
4175 PRINT_ER("driver is null\n");
4179 if (wilc_wlan_get_num_conn_ifcs(vif->wilc) == 2 && enabled)
4182 memset(&msg, 0, sizeof(struct host_if_msg));
4184 msg.id = HOST_IF_MSG_POWER_MGMT;
4187 pwr_mgmt_info->enabled = enabled;
4188 pwr_mgmt_info->timeout = timeout;
4190 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4192 PRINT_ER("wilc_mq_send fail\n");
4196 int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled,
4200 struct host_if_msg msg;
4201 struct set_multicast *multicast_filter_param = &msg.body.multicast_info;
4202 struct host_if_drv *hif_drv = vif->hif_drv;
4205 PRINT_ER("driver is null\n");
4209 memset(&msg, 0, sizeof(struct host_if_msg));
4211 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
4214 multicast_filter_param->enabled = enabled;
4215 multicast_filter_param->cnt = count;
4217 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4219 PRINT_ER("wilc_mq_send fail\n");
4223 static void *host_int_ParseJoinBssParam(struct network_info *ptstrNetworkInfo)
4225 struct join_bss_param *pNewJoinBssParam = NULL;
4234 u8 pcipherTotalCount = 0;
4235 u8 authTotalCount = 0;
4238 pu8IEs = ptstrNetworkInfo->ies;
4239 u16IEsLen = ptstrNetworkInfo->ies_len;
4241 pNewJoinBssParam = kzalloc(sizeof(struct join_bss_param), GFP_KERNEL);
4242 if (pNewJoinBssParam) {
4243 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->dtim_period;
4244 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->beacon_period;
4245 pNewJoinBssParam->cap_info = ptstrNetworkInfo->cap_info;
4246 memcpy(pNewJoinBssParam->bssid, ptstrNetworkInfo->bssid, 6);
4247 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->ssid,
4248 ptstrNetworkInfo->ssid_len + 1);
4249 pNewJoinBssParam->ssid_len = ptstrNetworkInfo->ssid_len;
4250 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
4251 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
4253 while (index < u16IEsLen) {
4254 if (pu8IEs[index] == SUPP_RATES_IE) {
4255 suppRatesNo = pu8IEs[index + 1];
4256 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
4259 for (i = 0; i < suppRatesNo; i++)
4260 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
4262 index += suppRatesNo;
4264 } else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
4265 extSuppRatesNo = pu8IEs[index + 1];
4266 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
4267 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
4269 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
4271 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++)
4272 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
4274 index += extSuppRatesNo;
4276 } else if (pu8IEs[index] == HT_CAPABILITY_IE) {
4277 pNewJoinBssParam->ht_capable = true;
4278 index += pu8IEs[index + 1] + 2;
4280 } else if ((pu8IEs[index] == WMM_IE) &&
4281 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
4282 (pu8IEs[index + 4] == 0xF2) &&
4283 (pu8IEs[index + 5] == 0x02) &&
4284 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) &&
4285 (pu8IEs[index + 7] == 0x01)) {
4286 pNewJoinBssParam->wmm_cap = true;
4288 if (pu8IEs[index + 8] & BIT(7))
4289 pNewJoinBssParam->uapsd_cap = true;
4290 index += pu8IEs[index + 1] + 2;
4292 } else if ((pu8IEs[index] == P2P_IE) &&
4293 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
4294 (pu8IEs[index + 4] == 0x9a) &&
4295 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) {
4298 pNewJoinBssParam->tsf = ptstrNetworkInfo->tsf_lo;
4299 pNewJoinBssParam->noa_enabled = 1;
4300 pNewJoinBssParam->idx = pu8IEs[index + 9];
4302 if (pu8IEs[index + 10] & BIT(7)) {
4303 pNewJoinBssParam->opp_enabled = 1;
4304 pNewJoinBssParam->ct_window = pu8IEs[index + 10];
4306 pNewJoinBssParam->opp_enabled = 0;
4309 pNewJoinBssParam->cnt = pu8IEs[index + 11];
4310 u16P2P_count = index + 12;
4312 memcpy(pNewJoinBssParam->duration, pu8IEs + u16P2P_count, 4);
4315 memcpy(pNewJoinBssParam->interval, pu8IEs + u16P2P_count, 4);
4318 memcpy(pNewJoinBssParam->start_time, pu8IEs + u16P2P_count, 4);
4320 index += pu8IEs[index + 1] + 2;
4323 } else if ((pu8IEs[index] == RSN_IE) ||
4324 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
4325 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
4326 (pu8IEs[index + 5] == 0x01))) {
4327 u16 rsnIndex = index;
4329 if (pu8IEs[rsnIndex] == RSN_IE) {
4330 pNewJoinBssParam->mode_802_11i = 2;
4332 if (pNewJoinBssParam->mode_802_11i == 0)
4333 pNewJoinBssParam->mode_802_11i = 1;
4338 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
4340 jumpOffset = pu8IEs[rsnIndex] * 4;
4341 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
4344 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++)
4345 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
4347 pcipherTotalCount += pcipherCount;
4348 rsnIndex += jumpOffset;
4350 jumpOffset = pu8IEs[rsnIndex] * 4;
4352 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
4355 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++)
4356 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
4358 authTotalCount += authCount;
4359 rsnIndex += jumpOffset;
4361 if (pu8IEs[index] == RSN_IE) {
4362 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
4363 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
4366 pNewJoinBssParam->rsn_found = true;
4367 index += pu8IEs[index + 1] + 2;
4370 index += pu8IEs[index + 1] + 2;
4374 return (void *)pNewJoinBssParam;
4377 int wilc_setup_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx)
4380 struct host_if_msg msg;
4381 struct host_if_drv *hif_drv = vif->hif_drv;
4384 PRINT_ER("driver is null\n");
4388 memset(&msg, 0, sizeof(struct host_if_msg));
4390 msg.id = HOST_IF_MSG_SET_IPADDRESS;
4392 msg.body.ip_info.ip_addr = ip_addr;
4394 msg.body.ip_info.idx = idx;
4396 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4398 PRINT_ER("wilc_mq_send fail\n");
4403 static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx)
4406 struct host_if_msg msg;
4407 struct host_if_drv *hif_drv = vif->hif_drv;
4410 PRINT_ER("driver is null\n");
4414 memset(&msg, 0, sizeof(struct host_if_msg));
4416 msg.id = HOST_IF_MSG_GET_IPADDRESS;
4418 msg.body.ip_info.ip_addr = ip_addr;
4420 msg.body.ip_info.idx = idx;
4422 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4424 PRINT_ER("wilc_mq_send fail\n");
4429 int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power)
4432 struct host_if_msg msg;
4434 memset(&msg, 0, sizeof(struct host_if_msg));
4436 msg.id = HOST_IF_MSG_SET_TX_POWER;
4437 msg.body.tx_power.tx_pwr = tx_power;
4440 ret = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4442 netdev_err(vif->ndev, "wilc_mq_send fail\n");
4447 int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power)
4450 struct host_if_msg msg;
4452 memset(&msg, 0, sizeof(struct host_if_msg));
4454 msg.id = HOST_IF_MSG_GET_TX_POWER;
4457 ret = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4459 netdev_err(vif->ndev, "Failed to get TX PWR\n");
4461 down(&hif_sema_wait_response);
4462 *tx_power = msg.body.tx_power.tx_pwr;