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 ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
314 wilc_get_vif_idx(vif));
317 netdev_err(vif->ndev, "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 void handle_set_mac_address(struct wilc_vif *vif,
428 struct set_mac_addr *set_mac_addr)
433 u8 *mac_buf = kmemdup(set_mac_addr->mac_addr, ETH_ALEN, GFP_KERNEL);
437 wid.id = (u16)WID_MAC_ADDR;
442 ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
443 wilc_get_vif_idx(vif));
445 PRINT_ER("Failed to set mac address\n");
450 static s32 handle_get_mac_address(struct wilc_vif *vif,
451 struct get_mac_addr *get_mac_addr)
456 wid.id = (u16)WID_MAC_ADDR;
458 wid.val = get_mac_addr->mac_addr;
461 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
462 wilc_get_vif_idx(vif));
465 PRINT_ER("Failed to get mac address\n");
468 up(&hif_sema_wait_response);
473 static s32 handle_cfg_param(struct wilc_vif *vif,
474 struct cfg_param_attr *cfg_param_attr)
477 struct wid wid_list[32];
478 struct host_if_drv *hif_drv = vif->hif_drv;
481 down(&hif_drv->sem_cfg_values);
483 if (cfg_param_attr->cfg_attr_info.flag & BSS_TYPE) {
484 if (cfg_param_attr->cfg_attr_info.bss_type < 6) {
485 wid_list[wid_cnt].id = WID_BSS_TYPE;
486 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.bss_type;
487 wid_list[wid_cnt].type = WID_CHAR;
488 wid_list[wid_cnt].size = sizeof(char);
489 hif_drv->cfg_values.bss_type = (u8)cfg_param_attr->cfg_attr_info.bss_type;
491 PRINT_ER("check value 6 over\n");
497 if (cfg_param_attr->cfg_attr_info.flag & AUTH_TYPE) {
498 if (cfg_param_attr->cfg_attr_info.auth_type == 1 ||
499 cfg_param_attr->cfg_attr_info.auth_type == 2 ||
500 cfg_param_attr->cfg_attr_info.auth_type == 5) {
501 wid_list[wid_cnt].id = WID_AUTH_TYPE;
502 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.auth_type;
503 wid_list[wid_cnt].type = WID_CHAR;
504 wid_list[wid_cnt].size = sizeof(char);
505 hif_drv->cfg_values.auth_type = (u8)cfg_param_attr->cfg_attr_info.auth_type;
507 PRINT_ER("Impossible value \n");
513 if (cfg_param_attr->cfg_attr_info.flag & AUTHEN_TIMEOUT) {
514 if (cfg_param_attr->cfg_attr_info.auth_timeout > 0 &&
515 cfg_param_attr->cfg_attr_info.auth_timeout < 65536) {
516 wid_list[wid_cnt].id = WID_AUTH_TIMEOUT;
517 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.auth_timeout;
518 wid_list[wid_cnt].type = WID_SHORT;
519 wid_list[wid_cnt].size = sizeof(u16);
520 hif_drv->cfg_values.auth_timeout = cfg_param_attr->cfg_attr_info.auth_timeout;
522 PRINT_ER("Range(1 ~ 65535) over\n");
528 if (cfg_param_attr->cfg_attr_info.flag & POWER_MANAGEMENT) {
529 if (cfg_param_attr->cfg_attr_info.power_mgmt_mode < 5) {
530 wid_list[wid_cnt].id = WID_POWER_MANAGEMENT;
531 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.power_mgmt_mode;
532 wid_list[wid_cnt].type = WID_CHAR;
533 wid_list[wid_cnt].size = sizeof(char);
534 hif_drv->cfg_values.power_mgmt_mode = (u8)cfg_param_attr->cfg_attr_info.power_mgmt_mode;
536 PRINT_ER("Invalid power mode\n");
542 if (cfg_param_attr->cfg_attr_info.flag & RETRY_SHORT) {
543 if (cfg_param_attr->cfg_attr_info.short_retry_limit > 0 &&
544 cfg_param_attr->cfg_attr_info.short_retry_limit < 256) {
545 wid_list[wid_cnt].id = WID_SHORT_RETRY_LIMIT;
546 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.short_retry_limit;
547 wid_list[wid_cnt].type = WID_SHORT;
548 wid_list[wid_cnt].size = sizeof(u16);
549 hif_drv->cfg_values.short_retry_limit = cfg_param_attr->cfg_attr_info.short_retry_limit;
551 PRINT_ER("Range(1~256) over\n");
557 if (cfg_param_attr->cfg_attr_info.flag & RETRY_LONG) {
558 if (cfg_param_attr->cfg_attr_info.long_retry_limit > 0 &&
559 cfg_param_attr->cfg_attr_info.long_retry_limit < 256) {
560 wid_list[wid_cnt].id = WID_LONG_RETRY_LIMIT;
561 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.long_retry_limit;
562 wid_list[wid_cnt].type = WID_SHORT;
563 wid_list[wid_cnt].size = sizeof(u16);
564 hif_drv->cfg_values.long_retry_limit = cfg_param_attr->cfg_attr_info.long_retry_limit;
566 PRINT_ER("Range(1~256) over\n");
572 if (cfg_param_attr->cfg_attr_info.flag & FRAG_THRESHOLD) {
573 if (cfg_param_attr->cfg_attr_info.frag_threshold > 255 &&
574 cfg_param_attr->cfg_attr_info.frag_threshold < 7937) {
575 wid_list[wid_cnt].id = WID_FRAG_THRESHOLD;
576 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.frag_threshold;
577 wid_list[wid_cnt].type = WID_SHORT;
578 wid_list[wid_cnt].size = sizeof(u16);
579 hif_drv->cfg_values.frag_threshold = cfg_param_attr->cfg_attr_info.frag_threshold;
581 PRINT_ER("Threshold Range fail\n");
587 if (cfg_param_attr->cfg_attr_info.flag & RTS_THRESHOLD) {
588 if (cfg_param_attr->cfg_attr_info.rts_threshold > 255 &&
589 cfg_param_attr->cfg_attr_info.rts_threshold < 65536) {
590 wid_list[wid_cnt].id = WID_RTS_THRESHOLD;
591 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.rts_threshold;
592 wid_list[wid_cnt].type = WID_SHORT;
593 wid_list[wid_cnt].size = sizeof(u16);
594 hif_drv->cfg_values.rts_threshold = cfg_param_attr->cfg_attr_info.rts_threshold;
596 PRINT_ER("Threshold Range fail\n");
602 if (cfg_param_attr->cfg_attr_info.flag & PREAMBLE) {
603 if (cfg_param_attr->cfg_attr_info.preamble_type < 3) {
604 wid_list[wid_cnt].id = WID_PREAMBLE;
605 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.preamble_type;
606 wid_list[wid_cnt].type = WID_CHAR;
607 wid_list[wid_cnt].size = sizeof(char);
608 hif_drv->cfg_values.preamble_type = cfg_param_attr->cfg_attr_info.preamble_type;
610 PRINT_ER("Preamle Range(0~2) over\n");
616 if (cfg_param_attr->cfg_attr_info.flag & SHORT_SLOT_ALLOWED) {
617 if (cfg_param_attr->cfg_attr_info.short_slot_allowed < 2) {
618 wid_list[wid_cnt].id = WID_SHORT_SLOT_ALLOWED;
619 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.short_slot_allowed;
620 wid_list[wid_cnt].type = WID_CHAR;
621 wid_list[wid_cnt].size = sizeof(char);
622 hif_drv->cfg_values.short_slot_allowed = (u8)cfg_param_attr->cfg_attr_info.short_slot_allowed;
624 PRINT_ER("Short slot(2) over\n");
630 if (cfg_param_attr->cfg_attr_info.flag & TXOP_PROT_DISABLE) {
631 if (cfg_param_attr->cfg_attr_info.txop_prot_disabled < 2) {
632 wid_list[wid_cnt].id = WID_11N_TXOP_PROT_DISABLE;
633 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.txop_prot_disabled;
634 wid_list[wid_cnt].type = WID_CHAR;
635 wid_list[wid_cnt].size = sizeof(char);
636 hif_drv->cfg_values.txop_prot_disabled = (u8)cfg_param_attr->cfg_attr_info.txop_prot_disabled;
638 PRINT_ER("TXOP prot disable\n");
644 if (cfg_param_attr->cfg_attr_info.flag & BEACON_INTERVAL) {
645 if (cfg_param_attr->cfg_attr_info.beacon_interval > 0 &&
646 cfg_param_attr->cfg_attr_info.beacon_interval < 65536) {
647 wid_list[wid_cnt].id = WID_BEACON_INTERVAL;
648 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.beacon_interval;
649 wid_list[wid_cnt].type = WID_SHORT;
650 wid_list[wid_cnt].size = sizeof(u16);
651 hif_drv->cfg_values.beacon_interval = cfg_param_attr->cfg_attr_info.beacon_interval;
653 PRINT_ER("Beacon interval(1~65535) fail\n");
659 if (cfg_param_attr->cfg_attr_info.flag & DTIM_PERIOD) {
660 if (cfg_param_attr->cfg_attr_info.dtim_period > 0 &&
661 cfg_param_attr->cfg_attr_info.dtim_period < 256) {
662 wid_list[wid_cnt].id = WID_DTIM_PERIOD;
663 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.dtim_period;
664 wid_list[wid_cnt].type = WID_CHAR;
665 wid_list[wid_cnt].size = sizeof(char);
666 hif_drv->cfg_values.dtim_period = cfg_param_attr->cfg_attr_info.dtim_period;
668 PRINT_ER("DTIM range(1~255) fail\n");
674 if (cfg_param_attr->cfg_attr_info.flag & SITE_SURVEY) {
675 if (cfg_param_attr->cfg_attr_info.site_survey_enabled < 3) {
676 wid_list[wid_cnt].id = WID_SITE_SURVEY;
677 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.site_survey_enabled;
678 wid_list[wid_cnt].type = WID_CHAR;
679 wid_list[wid_cnt].size = sizeof(char);
680 hif_drv->cfg_values.site_survey_enabled = (u8)cfg_param_attr->cfg_attr_info.site_survey_enabled;
682 PRINT_ER("Site survey disable\n");
688 if (cfg_param_attr->cfg_attr_info.flag & SITE_SURVEY_SCAN_TIME) {
689 if (cfg_param_attr->cfg_attr_info.site_survey_scan_time > 0 &&
690 cfg_param_attr->cfg_attr_info.site_survey_scan_time < 65536) {
691 wid_list[wid_cnt].id = WID_SITE_SURVEY_SCAN_TIME;
692 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.site_survey_scan_time;
693 wid_list[wid_cnt].type = WID_SHORT;
694 wid_list[wid_cnt].size = sizeof(u16);
695 hif_drv->cfg_values.site_survey_scan_time = cfg_param_attr->cfg_attr_info.site_survey_scan_time;
697 PRINT_ER("Site survey scan time(1~65535) over\n");
703 if (cfg_param_attr->cfg_attr_info.flag & ACTIVE_SCANTIME) {
704 if (cfg_param_attr->cfg_attr_info.active_scan_time > 0 &&
705 cfg_param_attr->cfg_attr_info.active_scan_time < 65536) {
706 wid_list[wid_cnt].id = WID_ACTIVE_SCAN_TIME;
707 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.active_scan_time;
708 wid_list[wid_cnt].type = WID_SHORT;
709 wid_list[wid_cnt].size = sizeof(u16);
710 hif_drv->cfg_values.active_scan_time = cfg_param_attr->cfg_attr_info.active_scan_time;
712 PRINT_ER("Active scan time(1~65535) over\n");
718 if (cfg_param_attr->cfg_attr_info.flag & PASSIVE_SCANTIME) {
719 if (cfg_param_attr->cfg_attr_info.passive_scan_time > 0 &&
720 cfg_param_attr->cfg_attr_info.passive_scan_time < 65536) {
721 wid_list[wid_cnt].id = WID_PASSIVE_SCAN_TIME;
722 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.passive_scan_time;
723 wid_list[wid_cnt].type = WID_SHORT;
724 wid_list[wid_cnt].size = sizeof(u16);
725 hif_drv->cfg_values.passive_scan_time = cfg_param_attr->cfg_attr_info.passive_scan_time;
727 PRINT_ER("Passive scan time(1~65535) over\n");
733 if (cfg_param_attr->cfg_attr_info.flag & CURRENT_TX_RATE) {
734 enum CURRENT_TXRATE curr_tx_rate = cfg_param_attr->cfg_attr_info.curr_tx_rate;
736 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
737 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
738 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
739 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
740 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
741 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
742 wid_list[wid_cnt].id = WID_CURRENT_TX_RATE;
743 wid_list[wid_cnt].val = (s8 *)&curr_tx_rate;
744 wid_list[wid_cnt].type = WID_SHORT;
745 wid_list[wid_cnt].size = sizeof(u16);
746 hif_drv->cfg_values.curr_tx_rate = (u8)curr_tx_rate;
748 PRINT_ER("out of TX rate\n");
755 result = wilc_send_config_pkt(vif, SET_CFG, wid_list,
756 wid_cnt, wilc_get_vif_idx(vif));
759 PRINT_ER("Error in setting CFG params\n");
762 up(&hif_drv->sem_cfg_values);
766 static void Handle_wait_msg_q_empty(void)
768 wilc_initialized = 0;
769 up(&hif_sema_wait_response);
772 static s32 Handle_ScanDone(struct wilc_vif *vif,
773 enum scan_event enuEvent);
775 static s32 Handle_Scan(struct wilc_vif *vif,
776 struct scan_attr *pstrHostIFscanAttr)
779 struct wid strWIDList[5];
780 u32 u32WidsCount = 0;
784 u8 *pu8HdnNtwrksWidVal = NULL;
785 struct host_if_drv *hif_drv = vif->hif_drv;
787 hif_drv->usr_scan_req.scan_result = pstrHostIFscanAttr->result;
788 hif_drv->usr_scan_req.arg = pstrHostIFscanAttr->arg;
790 if ((hif_drv->hif_state >= HOST_IF_SCANNING) &&
791 (hif_drv->hif_state < HOST_IF_CONNECTED)) {
792 PRINT_ER("Already scan\n");
797 if (wilc_optaining_ip || wilc_connecting) {
798 PRINT_ER("Don't do obss scan\n");
803 hif_drv->usr_scan_req.rcvd_ch_cnt = 0;
805 strWIDList[u32WidsCount].id = (u16)WID_SSID_PROBE_REQ;
806 strWIDList[u32WidsCount].type = WID_STR;
808 for (i = 0; i < pstrHostIFscanAttr->hidden_network.n_ssids; i++)
809 valuesize += ((pstrHostIFscanAttr->hidden_network.net_info[i].ssid_len) + 1);
810 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
811 strWIDList[u32WidsCount].val = pu8HdnNtwrksWidVal;
812 if (strWIDList[u32WidsCount].val) {
813 pu8Buffer = strWIDList[u32WidsCount].val;
815 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.n_ssids;
817 for (i = 0; i < pstrHostIFscanAttr->hidden_network.n_ssids; i++) {
818 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.net_info[i].ssid_len;
819 memcpy(pu8Buffer, pstrHostIFscanAttr->hidden_network.net_info[i].ssid, pstrHostIFscanAttr->hidden_network.net_info[i].ssid_len);
820 pu8Buffer += pstrHostIFscanAttr->hidden_network.net_info[i].ssid_len;
823 strWIDList[u32WidsCount].size = (s32)(valuesize + 1);
828 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_PROBE;
829 strWIDList[u32WidsCount].type = WID_BIN_DATA;
830 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ies;
831 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ies_len;
835 strWIDList[u32WidsCount].id = WID_SCAN_TYPE;
836 strWIDList[u32WidsCount].type = WID_CHAR;
837 strWIDList[u32WidsCount].size = sizeof(char);
838 strWIDList[u32WidsCount].val = (s8 *)&pstrHostIFscanAttr->type;
841 strWIDList[u32WidsCount].id = WID_SCAN_CHANNEL_LIST;
842 strWIDList[u32WidsCount].type = WID_BIN_DATA;
844 if (pstrHostIFscanAttr->ch_freq_list &&
845 pstrHostIFscanAttr->ch_list_len > 0) {
848 for (i = 0; i < pstrHostIFscanAttr->ch_list_len; i++) {
849 if (pstrHostIFscanAttr->ch_freq_list[i] > 0)
850 pstrHostIFscanAttr->ch_freq_list[i] = pstrHostIFscanAttr->ch_freq_list[i] - 1;
854 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ch_freq_list;
855 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ch_list_len;
858 strWIDList[u32WidsCount].id = WID_START_SCAN_REQ;
859 strWIDList[u32WidsCount].type = WID_CHAR;
860 strWIDList[u32WidsCount].size = sizeof(char);
861 strWIDList[u32WidsCount].val = (s8 *)&pstrHostIFscanAttr->src;
864 if (hif_drv->hif_state == HOST_IF_CONNECTED)
865 scan_while_connected = true;
866 else if (hif_drv->hif_state == HOST_IF_IDLE)
867 scan_while_connected = false;
869 result = wilc_send_config_pkt(vif, SET_CFG, strWIDList,
871 wilc_get_vif_idx(vif));
874 PRINT_ER("Failed to send scan parameters config packet\n");
878 del_timer(&hif_drv->scan_timer);
879 Handle_ScanDone(vif, SCAN_EVENT_ABORTED);
882 kfree(pstrHostIFscanAttr->ch_freq_list);
883 pstrHostIFscanAttr->ch_freq_list = NULL;
885 kfree(pstrHostIFscanAttr->ies);
886 pstrHostIFscanAttr->ies = NULL;
887 kfree(pstrHostIFscanAttr->hidden_network.net_info);
888 pstrHostIFscanAttr->hidden_network.net_info = NULL;
890 kfree(pu8HdnNtwrksWidVal);
895 static s32 Handle_ScanDone(struct wilc_vif *vif,
896 enum scan_event enuEvent)
899 u8 u8abort_running_scan;
901 struct host_if_drv *hif_drv = vif->hif_drv;
903 if (enuEvent == SCAN_EVENT_ABORTED) {
904 u8abort_running_scan = 1;
905 wid.id = (u16)WID_ABORT_RUNNING_SCAN;
907 wid.val = (s8 *)&u8abort_running_scan;
908 wid.size = sizeof(char);
910 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
911 wilc_get_vif_idx(vif));
914 PRINT_ER("Failed to set abort running scan\n");
920 PRINT_ER("Driver handler is NULL\n");
924 if (hif_drv->usr_scan_req.scan_result) {
925 hif_drv->usr_scan_req.scan_result(enuEvent, NULL,
926 hif_drv->usr_scan_req.arg, NULL);
927 hif_drv->usr_scan_req.scan_result = NULL;
933 u8 wilc_connected_ssid[6] = {0};
934 static s32 Handle_Connect(struct wilc_vif *vif,
935 struct connect_attr *pstrHostIFconnectAttr)
938 struct wid strWIDList[8];
939 u32 u32WidsCount = 0, dummyval = 0;
940 u8 *pu8CurrByte = NULL;
941 struct join_bss_param *ptstrJoinBssParam;
942 struct host_if_drv *hif_drv = vif->hif_drv;
944 if (memcmp(pstrHostIFconnectAttr->bssid, wilc_connected_ssid, ETH_ALEN) == 0) {
946 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
950 ptstrJoinBssParam = pstrHostIFconnectAttr->params;
951 if (!ptstrJoinBssParam) {
952 PRINT_ER("Required BSSID not found\n");
957 if (pstrHostIFconnectAttr->bssid) {
958 hif_drv->usr_conn_req.bssid = kmalloc(6, GFP_KERNEL);
959 memcpy(hif_drv->usr_conn_req.bssid, pstrHostIFconnectAttr->bssid, 6);
962 hif_drv->usr_conn_req.ssid_len = pstrHostIFconnectAttr->ssid_len;
963 if (pstrHostIFconnectAttr->ssid) {
964 hif_drv->usr_conn_req.ssid = kmalloc(pstrHostIFconnectAttr->ssid_len + 1, GFP_KERNEL);
965 memcpy(hif_drv->usr_conn_req.ssid,
966 pstrHostIFconnectAttr->ssid,
967 pstrHostIFconnectAttr->ssid_len);
968 hif_drv->usr_conn_req.ssid[pstrHostIFconnectAttr->ssid_len] = '\0';
971 hif_drv->usr_conn_req.ies_len = pstrHostIFconnectAttr->ies_len;
972 if (pstrHostIFconnectAttr->ies) {
973 hif_drv->usr_conn_req.ies = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
974 memcpy(hif_drv->usr_conn_req.ies,
975 pstrHostIFconnectAttr->ies,
976 pstrHostIFconnectAttr->ies_len);
979 hif_drv->usr_conn_req.security = pstrHostIFconnectAttr->security;
980 hif_drv->usr_conn_req.auth_type = pstrHostIFconnectAttr->auth_type;
981 hif_drv->usr_conn_req.conn_result = pstrHostIFconnectAttr->result;
982 hif_drv->usr_conn_req.arg = pstrHostIFconnectAttr->arg;
984 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
985 strWIDList[u32WidsCount].type = WID_INT;
986 strWIDList[u32WidsCount].size = sizeof(u32);
987 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
990 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
991 strWIDList[u32WidsCount].type = WID_INT;
992 strWIDList[u32WidsCount].size = sizeof(u32);
993 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
996 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
997 strWIDList[u32WidsCount].type = WID_INT;
998 strWIDList[u32WidsCount].size = sizeof(u32);
999 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1003 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
1004 strWIDList[u32WidsCount].type = WID_BIN_DATA;
1005 strWIDList[u32WidsCount].val = hif_drv->usr_conn_req.ies;
1006 strWIDList[u32WidsCount].size = hif_drv->usr_conn_req.ies_len;
1009 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1010 info_element_size = hif_drv->usr_conn_req.ies_len;
1011 info_element = kmalloc(info_element_size, GFP_KERNEL);
1012 memcpy(info_element, hif_drv->usr_conn_req.ies,
1016 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
1017 strWIDList[u32WidsCount].type = WID_CHAR;
1018 strWIDList[u32WidsCount].size = sizeof(char);
1019 strWIDList[u32WidsCount].val = (s8 *)&hif_drv->usr_conn_req.security;
1022 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
1023 mode_11i = hif_drv->usr_conn_req.security;
1025 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
1026 strWIDList[u32WidsCount].type = WID_CHAR;
1027 strWIDList[u32WidsCount].size = sizeof(char);
1028 strWIDList[u32WidsCount].val = (s8 *)&hif_drv->usr_conn_req.auth_type;
1031 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
1032 auth_type = (u8)hif_drv->usr_conn_req.auth_type;
1034 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
1035 strWIDList[u32WidsCount].type = WID_STR;
1036 strWIDList[u32WidsCount].size = 112;
1037 strWIDList[u32WidsCount].val = kmalloc(strWIDList[u32WidsCount].size, GFP_KERNEL);
1039 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1040 join_req_size = strWIDList[u32WidsCount].size;
1041 join_req = kmalloc(join_req_size, GFP_KERNEL);
1043 if (!strWIDList[u32WidsCount].val) {
1048 pu8CurrByte = strWIDList[u32WidsCount].val;
1050 if (pstrHostIFconnectAttr->ssid) {
1051 memcpy(pu8CurrByte, pstrHostIFconnectAttr->ssid, pstrHostIFconnectAttr->ssid_len);
1052 pu8CurrByte[pstrHostIFconnectAttr->ssid_len] = '\0';
1054 pu8CurrByte += MAX_SSID_LEN;
1055 *(pu8CurrByte++) = INFRASTRUCTURE;
1057 if ((pstrHostIFconnectAttr->ch >= 1) && (pstrHostIFconnectAttr->ch <= 14)) {
1058 *(pu8CurrByte++) = pstrHostIFconnectAttr->ch;
1060 PRINT_ER("Channel out of range\n");
1061 *(pu8CurrByte++) = 0xFF;
1063 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1064 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1066 if (pstrHostIFconnectAttr->bssid)
1067 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
1070 if (pstrHostIFconnectAttr->bssid)
1071 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
1074 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1075 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1076 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1078 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
1079 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1081 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1082 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1084 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1085 hif_drv->usr_conn_req.ht_capable = ptstrJoinBssParam->ht_capable;
1087 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1088 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1089 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1091 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
1092 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1094 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
1095 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1097 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
1098 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1100 *(pu8CurrByte++) = REAL_JOIN_REQ;
1101 *(pu8CurrByte++) = ptstrJoinBssParam->noa_enabled;
1103 if (ptstrJoinBssParam->noa_enabled) {
1104 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1105 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1106 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1107 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1109 *(pu8CurrByte++) = ptstrJoinBssParam->opp_enabled;
1110 *(pu8CurrByte++) = ptstrJoinBssParam->idx;
1112 if (ptstrJoinBssParam->opp_enabled)
1113 *(pu8CurrByte++) = ptstrJoinBssParam->ct_window;
1115 *(pu8CurrByte++) = ptstrJoinBssParam->cnt;
1117 memcpy(pu8CurrByte, ptstrJoinBssParam->duration, sizeof(ptstrJoinBssParam->duration));
1118 pu8CurrByte += sizeof(ptstrJoinBssParam->duration);
1120 memcpy(pu8CurrByte, ptstrJoinBssParam->interval, sizeof(ptstrJoinBssParam->interval));
1121 pu8CurrByte += sizeof(ptstrJoinBssParam->interval);
1123 memcpy(pu8CurrByte, ptstrJoinBssParam->start_time, sizeof(ptstrJoinBssParam->start_time));
1124 pu8CurrByte += sizeof(ptstrJoinBssParam->start_time);
1127 pu8CurrByte = strWIDList[u32WidsCount].val;
1130 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1131 memcpy(join_req, pu8CurrByte, join_req_size);
1135 if (pstrHostIFconnectAttr->bssid)
1136 memcpy(wilc_connected_ssid,
1137 pstrHostIFconnectAttr->bssid, ETH_ALEN);
1139 result = wilc_send_config_pkt(vif, SET_CFG, strWIDList,
1141 wilc_get_vif_idx(vif));
1143 PRINT_ER("failed to send config packet\n");
1147 hif_drv->hif_state = HOST_IF_WAITING_CONN_RESP;
1152 tstrConnectInfo strConnectInfo;
1154 del_timer(&hif_drv->connect_timer);
1156 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1158 if (pstrHostIFconnectAttr->result) {
1159 if (pstrHostIFconnectAttr->bssid)
1160 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->bssid, 6);
1162 if (pstrHostIFconnectAttr->ies) {
1163 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->ies_len;
1164 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
1165 memcpy(strConnectInfo.pu8ReqIEs,
1166 pstrHostIFconnectAttr->ies,
1167 pstrHostIFconnectAttr->ies_len);
1170 pstrHostIFconnectAttr->result(CONN_DISCONN_EVENT_CONN_RESP,
1174 pstrHostIFconnectAttr->arg);
1175 hif_drv->hif_state = HOST_IF_IDLE;
1176 kfree(strConnectInfo.pu8ReqIEs);
1177 strConnectInfo.pu8ReqIEs = NULL;
1180 PRINT_ER("Connect callback function pointer is NULL\n");
1184 kfree(pstrHostIFconnectAttr->bssid);
1185 pstrHostIFconnectAttr->bssid = NULL;
1187 kfree(pstrHostIFconnectAttr->ssid);
1188 pstrHostIFconnectAttr->ssid = NULL;
1190 kfree(pstrHostIFconnectAttr->ies);
1191 pstrHostIFconnectAttr->ies = NULL;
1197 static s32 Handle_FlushConnect(struct wilc_vif *vif)
1200 struct wid strWIDList[5];
1201 u32 u32WidsCount = 0;
1202 u8 *pu8CurrByte = NULL;
1204 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
1205 strWIDList[u32WidsCount].type = WID_BIN_DATA;
1206 strWIDList[u32WidsCount].val = info_element;
1207 strWIDList[u32WidsCount].size = info_element_size;
1210 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
1211 strWIDList[u32WidsCount].type = WID_CHAR;
1212 strWIDList[u32WidsCount].size = sizeof(char);
1213 strWIDList[u32WidsCount].val = (s8 *)(&(mode_11i));
1216 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
1217 strWIDList[u32WidsCount].type = WID_CHAR;
1218 strWIDList[u32WidsCount].size = sizeof(char);
1219 strWIDList[u32WidsCount].val = (s8 *)(&auth_type);
1222 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
1223 strWIDList[u32WidsCount].type = WID_STR;
1224 strWIDList[u32WidsCount].size = join_req_size;
1225 strWIDList[u32WidsCount].val = (s8 *)join_req;
1226 pu8CurrByte = strWIDList[u32WidsCount].val;
1228 pu8CurrByte += FLUSHED_BYTE_POS;
1229 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1233 result = wilc_send_config_pkt(vif, SET_CFG, strWIDList,
1235 wilc_get_vif_idx(join_req_vif));
1237 PRINT_ER("failed to send config packet\n");
1244 static s32 Handle_ConnectTimeout(struct wilc_vif *vif)
1247 tstrConnectInfo strConnectInfo;
1249 u16 u16DummyReasonCode = 0;
1250 struct host_if_drv *hif_drv = vif->hif_drv;
1253 PRINT_ER("Driver handler is NULL\n");
1257 hif_drv->hif_state = HOST_IF_IDLE;
1259 scan_while_connected = false;
1261 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1263 if (hif_drv->usr_conn_req.conn_result) {
1264 if (hif_drv->usr_conn_req.bssid) {
1265 memcpy(strConnectInfo.au8bssid,
1266 hif_drv->usr_conn_req.bssid, 6);
1269 if (hif_drv->usr_conn_req.ies) {
1270 strConnectInfo.ReqIEsLen = hif_drv->usr_conn_req.ies_len;
1271 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL);
1272 memcpy(strConnectInfo.pu8ReqIEs,
1273 hif_drv->usr_conn_req.ies,
1274 hif_drv->usr_conn_req.ies_len);
1277 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
1281 hif_drv->usr_conn_req.arg);
1283 kfree(strConnectInfo.pu8ReqIEs);
1284 strConnectInfo.pu8ReqIEs = NULL;
1286 PRINT_ER("Connect callback function pointer is NULL\n");
1289 wid.id = (u16)WID_DISCONNECT;
1290 wid.type = WID_CHAR;
1291 wid.val = (s8 *)&u16DummyReasonCode;
1292 wid.size = sizeof(char);
1294 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
1295 wilc_get_vif_idx(vif));
1297 PRINT_ER("Failed to send dissconect config packet\n");
1299 hif_drv->usr_conn_req.ssid_len = 0;
1300 kfree(hif_drv->usr_conn_req.ssid);
1301 hif_drv->usr_conn_req.ssid = NULL;
1302 kfree(hif_drv->usr_conn_req.bssid);
1303 hif_drv->usr_conn_req.bssid = NULL;
1304 hif_drv->usr_conn_req.ies_len = 0;
1305 kfree(hif_drv->usr_conn_req.ies);
1306 hif_drv->usr_conn_req.ies = NULL;
1308 eth_zero_addr(wilc_connected_ssid);
1310 if (join_req && join_req_vif == vif) {
1315 if (info_element && join_req_vif == vif) {
1316 kfree(info_element);
1317 info_element = NULL;
1323 static s32 Handle_RcvdNtwrkInfo(struct wilc_vif *vif,
1324 struct rcvd_net_info *pstrRcvdNetworkInfo)
1327 bool bNewNtwrkFound;
1329 struct network_info *pstrNetworkInfo = NULL;
1330 void *pJoinParams = NULL;
1331 struct host_if_drv *hif_drv = vif->hif_drv;
1333 bNewNtwrkFound = true;
1335 if (hif_drv->usr_scan_req.scan_result) {
1336 wilc_parse_network_info(pstrRcvdNetworkInfo->buffer, &pstrNetworkInfo);
1337 if ((!pstrNetworkInfo) ||
1338 (!hif_drv->usr_scan_req.scan_result)) {
1339 PRINT_ER("driver is null\n");
1344 for (i = 0; i < hif_drv->usr_scan_req.rcvd_ch_cnt; i++) {
1345 if ((hif_drv->usr_scan_req.net_info[i].bssid) &&
1346 (pstrNetworkInfo->bssid)) {
1347 if (memcmp(hif_drv->usr_scan_req.net_info[i].bssid,
1348 pstrNetworkInfo->bssid, 6) == 0) {
1349 if (pstrNetworkInfo->rssi <= hif_drv->usr_scan_req.net_info[i].rssi) {
1352 hif_drv->usr_scan_req.net_info[i].rssi = pstrNetworkInfo->rssi;
1353 bNewNtwrkFound = false;
1360 if (bNewNtwrkFound) {
1361 if (hif_drv->usr_scan_req.rcvd_ch_cnt < MAX_NUM_SCANNED_NETWORKS) {
1362 hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].rssi = pstrNetworkInfo->rssi;
1364 if (hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].bssid &&
1365 pstrNetworkInfo->bssid) {
1366 memcpy(hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].bssid,
1367 pstrNetworkInfo->bssid, 6);
1369 hif_drv->usr_scan_req.rcvd_ch_cnt++;
1371 pstrNetworkInfo->new_network = true;
1372 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
1374 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1375 hif_drv->usr_scan_req.arg,
1380 pstrNetworkInfo->new_network = false;
1381 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1382 hif_drv->usr_scan_req.arg, NULL);
1387 kfree(pstrRcvdNetworkInfo->buffer);
1388 pstrRcvdNetworkInfo->buffer = NULL;
1390 if (pstrNetworkInfo) {
1391 kfree(pstrNetworkInfo->ies);
1392 kfree(pstrNetworkInfo);
1398 static s32 host_int_get_assoc_res_info(struct wilc_vif *vif,
1399 u8 *pu8AssocRespInfo,
1400 u32 u32MaxAssocRespInfoLen,
1401 u32 *pu32RcvdAssocRespInfoLen);
1403 static s32 Handle_RcvdGnrlAsyncInfo(struct wilc_vif *vif,
1404 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
1410 u16 u16WidID = (u16)WID_NIL;
1413 u8 u8MacStatusReasonCode;
1414 u8 u8MacStatusAdditionalInfo;
1415 tstrConnectInfo strConnectInfo;
1416 tstrDisconnectNotifInfo strDisconnectNotifInfo;
1418 struct host_if_drv *hif_drv = vif->hif_drv;
1421 PRINT_ER("Driver handler is NULL\n");
1425 if ((hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) ||
1426 (hif_drv->hif_state == HOST_IF_CONNECTED) ||
1427 hif_drv->usr_scan_req.scan_result) {
1428 if (!pstrRcvdGnrlAsyncInfo->buffer ||
1429 !hif_drv->usr_conn_req.conn_result) {
1430 PRINT_ER("driver is null\n");
1434 u8MsgType = pstrRcvdGnrlAsyncInfo->buffer[0];
1436 if ('I' != u8MsgType) {
1437 PRINT_ER("Received Message format incorrect.\n");
1441 u8MsgID = pstrRcvdGnrlAsyncInfo->buffer[1];
1442 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[2], pstrRcvdGnrlAsyncInfo->buffer[3]);
1443 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[4], pstrRcvdGnrlAsyncInfo->buffer[5]);
1444 u8WidLen = pstrRcvdGnrlAsyncInfo->buffer[6];
1445 u8MacStatus = pstrRcvdGnrlAsyncInfo->buffer[7];
1446 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->buffer[8];
1447 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->buffer[9];
1448 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
1449 u32 u32RcvdAssocRespInfoLen = 0;
1450 struct connect_resp_info *pstrConnectRespInfo = NULL;
1452 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1454 if (u8MacStatus == MAC_CONNECTED) {
1455 memset(rcv_assoc_resp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
1457 host_int_get_assoc_res_info(vif,
1459 MAX_ASSOC_RESP_FRAME_SIZE,
1460 &u32RcvdAssocRespInfoLen);
1462 if (u32RcvdAssocRespInfoLen != 0) {
1463 s32Err = wilc_parse_assoc_resp_info(rcv_assoc_resp, u32RcvdAssocRespInfoLen,
1464 &pstrConnectRespInfo);
1466 PRINT_ER("wilc_parse_assoc_resp_info() returned error %d\n", s32Err);
1468 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->status;
1470 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
1471 if (pstrConnectRespInfo->ies) {
1472 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->ies_len;
1473 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->ies_len, GFP_KERNEL);
1474 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->ies,
1475 pstrConnectRespInfo->ies_len);
1479 if (pstrConnectRespInfo) {
1480 kfree(pstrConnectRespInfo->ies);
1481 kfree(pstrConnectRespInfo);
1487 if ((u8MacStatus == MAC_CONNECTED) &&
1488 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
1489 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
1490 eth_zero_addr(wilc_connected_ssid);
1491 } else if (u8MacStatus == MAC_DISCONNECTED) {
1492 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
1493 eth_zero_addr(wilc_connected_ssid);
1496 if (hif_drv->usr_conn_req.bssid) {
1497 memcpy(strConnectInfo.au8bssid, hif_drv->usr_conn_req.bssid, 6);
1499 if ((u8MacStatus == MAC_CONNECTED) &&
1500 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
1501 memcpy(hif_drv->assoc_bssid,
1502 hif_drv->usr_conn_req.bssid, ETH_ALEN);
1506 if (hif_drv->usr_conn_req.ies) {
1507 strConnectInfo.ReqIEsLen = hif_drv->usr_conn_req.ies_len;
1508 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL);
1509 memcpy(strConnectInfo.pu8ReqIEs,
1510 hif_drv->usr_conn_req.ies,
1511 hif_drv->usr_conn_req.ies_len);
1514 del_timer(&hif_drv->connect_timer);
1515 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
1519 hif_drv->usr_conn_req.arg);
1521 if ((u8MacStatus == MAC_CONNECTED) &&
1522 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
1523 wilc_set_power_mgmt(vif, 0, 0);
1525 hif_drv->hif_state = HOST_IF_CONNECTED;
1527 wilc_optaining_ip = true;
1528 mod_timer(&wilc_during_ip_timer,
1529 jiffies + msecs_to_jiffies(10000));
1531 hif_drv->hif_state = HOST_IF_IDLE;
1532 scan_while_connected = false;
1535 kfree(strConnectInfo.pu8RespIEs);
1536 strConnectInfo.pu8RespIEs = NULL;
1538 kfree(strConnectInfo.pu8ReqIEs);
1539 strConnectInfo.pu8ReqIEs = NULL;
1540 hif_drv->usr_conn_req.ssid_len = 0;
1541 kfree(hif_drv->usr_conn_req.ssid);
1542 hif_drv->usr_conn_req.ssid = NULL;
1543 kfree(hif_drv->usr_conn_req.bssid);
1544 hif_drv->usr_conn_req.bssid = NULL;
1545 hif_drv->usr_conn_req.ies_len = 0;
1546 kfree(hif_drv->usr_conn_req.ies);
1547 hif_drv->usr_conn_req.ies = NULL;
1548 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
1549 (hif_drv->hif_state == HOST_IF_CONNECTED)) {
1550 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
1552 if (hif_drv->usr_scan_req.scan_result) {
1553 del_timer(&hif_drv->scan_timer);
1554 Handle_ScanDone(vif, SCAN_EVENT_ABORTED);
1557 strDisconnectNotifInfo.u16reason = 0;
1558 strDisconnectNotifInfo.ie = NULL;
1559 strDisconnectNotifInfo.ie_len = 0;
1561 if (hif_drv->usr_conn_req.conn_result) {
1562 wilc_optaining_ip = false;
1563 wilc_set_power_mgmt(vif, 0, 0);
1565 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1568 &strDisconnectNotifInfo,
1569 hif_drv->usr_conn_req.arg);
1571 PRINT_ER("Connect result callback function is NULL\n");
1574 eth_zero_addr(hif_drv->assoc_bssid);
1576 hif_drv->usr_conn_req.ssid_len = 0;
1577 kfree(hif_drv->usr_conn_req.ssid);
1578 hif_drv->usr_conn_req.ssid = NULL;
1579 kfree(hif_drv->usr_conn_req.bssid);
1580 hif_drv->usr_conn_req.bssid = NULL;
1581 hif_drv->usr_conn_req.ies_len = 0;
1582 kfree(hif_drv->usr_conn_req.ies);
1583 hif_drv->usr_conn_req.ies = NULL;
1585 if (join_req && join_req_vif == vif) {
1590 if (info_element && join_req_vif == vif) {
1591 kfree(info_element);
1592 info_element = NULL;
1595 hif_drv->hif_state = HOST_IF_IDLE;
1596 scan_while_connected = false;
1598 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
1599 (hif_drv->usr_scan_req.scan_result)) {
1600 del_timer(&hif_drv->scan_timer);
1601 if (hif_drv->usr_scan_req.scan_result)
1602 Handle_ScanDone(vif, SCAN_EVENT_ABORTED);
1606 kfree(pstrRcvdGnrlAsyncInfo->buffer);
1607 pstrRcvdGnrlAsyncInfo->buffer = NULL;
1612 static int Handle_Key(struct wilc_vif *vif,
1613 struct key_attr *pstrHostIFkeyAttr)
1617 struct wid strWIDList[5];
1622 struct host_if_drv *hif_drv = vif->hif_drv;
1624 switch (pstrHostIFkeyAttr->type) {
1627 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1628 strWIDList[0].id = (u16)WID_11I_MODE;
1629 strWIDList[0].type = WID_CHAR;
1630 strWIDList[0].size = sizeof(char);
1631 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.mode;
1633 strWIDList[1].id = WID_AUTH_TYPE;
1634 strWIDList[1].type = WID_CHAR;
1635 strWIDList[1].size = sizeof(char);
1636 strWIDList[1].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.auth_type;
1638 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2,
1641 if (pu8keybuf == NULL) {
1642 PRINT_ER("No buffer to send Key\n");
1646 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1647 pu8keybuf[1] = pstrHostIFkeyAttr->attr.wep.key_len;
1649 memcpy(&pu8keybuf[2], pstrHostIFkeyAttr->attr.wep.key,
1650 pstrHostIFkeyAttr->attr.wep.key_len);
1652 kfree(pstrHostIFkeyAttr->attr.wep.key);
1654 strWIDList[2].id = (u16)WID_WEP_KEY_VALUE;
1655 strWIDList[2].type = WID_STR;
1656 strWIDList[2].size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
1657 strWIDList[2].val = (s8 *)pu8keybuf;
1659 result = wilc_send_config_pkt(vif, SET_CFG,
1661 wilc_get_vif_idx(vif));
1663 } else if (pstrHostIFkeyAttr->action & ADDKEY) {
1664 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2, GFP_KERNEL);
1666 PRINT_ER("No buffer to send Key\n");
1669 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1670 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->attr.wep.key_len, 1);
1671 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->attr.wep.key,
1672 pstrHostIFkeyAttr->attr.wep.key_len);
1673 kfree(pstrHostIFkeyAttr->attr.wep.key);
1675 wid.id = (u16)WID_ADD_WEP_KEY;
1677 wid.val = (s8 *)pu8keybuf;
1678 wid.size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
1680 result = wilc_send_config_pkt(vif, SET_CFG,
1682 wilc_get_vif_idx(vif));
1684 } else if (pstrHostIFkeyAttr->action & REMOVEKEY) {
1685 wid.id = (u16)WID_REMOVE_WEP_KEY;
1688 s8idxarray[0] = (s8)pstrHostIFkeyAttr->attr.wep.index;
1689 wid.val = s8idxarray;
1692 result = wilc_send_config_pkt(vif, SET_CFG,
1694 wilc_get_vif_idx(vif));
1695 } else if (pstrHostIFkeyAttr->action & DEFAULTKEY) {
1696 wid.id = (u16)WID_KEY_ID;
1697 wid.type = WID_CHAR;
1698 wid.val = (s8 *)&pstrHostIFkeyAttr->attr.wep.index;
1699 wid.size = sizeof(char);
1701 result = wilc_send_config_pkt(vif, SET_CFG,
1703 wilc_get_vif_idx(vif));
1705 up(&hif_drv->sem_test_key_block);
1709 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1710 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1712 PRINT_ER("No buffer to send RxGTK Key\n");
1714 goto _WPARxGtk_end_case_;
1717 if (pstrHostIFkeyAttr->attr.wpa.seq)
1718 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1720 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1721 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1722 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1723 pstrHostIFkeyAttr->attr.wpa.key_len);
1725 strWIDList[0].id = (u16)WID_11I_MODE;
1726 strWIDList[0].type = WID_CHAR;
1727 strWIDList[0].size = sizeof(char);
1728 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode;
1730 strWIDList[1].id = (u16)WID_ADD_RX_GTK;
1731 strWIDList[1].type = WID_STR;
1732 strWIDList[1].val = (s8 *)pu8keybuf;
1733 strWIDList[1].size = RX_MIC_KEY_MSG_LEN;
1735 result = wilc_send_config_pkt(vif, SET_CFG,
1737 wilc_get_vif_idx(vif));
1740 up(&hif_drv->sem_test_key_block);
1741 } else if (pstrHostIFkeyAttr->action & ADDKEY) {
1742 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1743 if (pu8keybuf == NULL) {
1744 PRINT_ER("No buffer to send RxGTK Key\n");
1746 goto _WPARxGtk_end_case_;
1749 if (hif_drv->hif_state == HOST_IF_CONNECTED)
1750 memcpy(pu8keybuf, hif_drv->assoc_bssid, ETH_ALEN);
1752 PRINT_ER("Couldn't handle WPARxGtk while state is not HOST_IF_CONNECTED\n");
1754 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1755 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1756 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1757 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1758 pstrHostIFkeyAttr->attr.wpa.key_len);
1760 wid.id = (u16)WID_ADD_RX_GTK;
1762 wid.val = (s8 *)pu8keybuf;
1763 wid.size = RX_MIC_KEY_MSG_LEN;
1765 result = wilc_send_config_pkt(vif, SET_CFG,
1767 wilc_get_vif_idx(vif));
1770 up(&hif_drv->sem_test_key_block);
1772 _WPARxGtk_end_case_:
1773 kfree(pstrHostIFkeyAttr->attr.wpa.key);
1774 kfree(pstrHostIFkeyAttr->attr.wpa.seq);
1781 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1782 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
1784 PRINT_ER("No buffer to send PTK Key\n");
1786 goto _WPAPtk_end_case_;
1789 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1790 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1791 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1792 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->attr.wpa.key,
1793 pstrHostIFkeyAttr->attr.wpa.key_len);
1795 strWIDList[0].id = (u16)WID_11I_MODE;
1796 strWIDList[0].type = WID_CHAR;
1797 strWIDList[0].size = sizeof(char);
1798 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode;
1800 strWIDList[1].id = (u16)WID_ADD_PTK;
1801 strWIDList[1].type = WID_STR;
1802 strWIDList[1].val = (s8 *)pu8keybuf;
1803 strWIDList[1].size = PTK_KEY_MSG_LEN + 1;
1805 result = wilc_send_config_pkt(vif, SET_CFG,
1807 wilc_get_vif_idx(vif));
1809 up(&hif_drv->sem_test_key_block);
1810 } else if (pstrHostIFkeyAttr->action & ADDKEY) {
1811 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
1813 PRINT_ER("No buffer to send PTK Key\n");
1815 goto _WPAPtk_end_case_;
1818 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1819 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1820 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->attr.wpa.key,
1821 pstrHostIFkeyAttr->attr.wpa.key_len);
1823 wid.id = (u16)WID_ADD_PTK;
1825 wid.val = (s8 *)pu8keybuf;
1826 wid.size = PTK_KEY_MSG_LEN;
1828 result = wilc_send_config_pkt(vif, SET_CFG,
1830 wilc_get_vif_idx(vif));
1832 up(&hif_drv->sem_test_key_block);
1836 kfree(pstrHostIFkeyAttr->attr.wpa.key);
1843 pu8keybuf = kmalloc((pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
1845 PRINT_ER("No buffer to send PMKSA Key\n");
1849 pu8keybuf[0] = pstrHostIFkeyAttr->attr.pmkid.numpmkid;
1851 for (i = 0; i < pstrHostIFkeyAttr->attr.pmkid.numpmkid; i++) {
1852 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
1853 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
1856 wid.id = (u16)WID_PMKID_INFO;
1858 wid.val = (s8 *)pu8keybuf;
1859 wid.size = (pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
1861 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
1862 wilc_get_vif_idx(vif));
1869 PRINT_ER("Failed to send key config packet\n");
1874 static void Handle_Disconnect(struct wilc_vif *vif)
1877 struct host_if_drv *hif_drv = vif->hif_drv;
1880 u16 u16DummyReasonCode = 0;
1882 wid.id = (u16)WID_DISCONNECT;
1883 wid.type = WID_CHAR;
1884 wid.val = (s8 *)&u16DummyReasonCode;
1885 wid.size = sizeof(char);
1887 wilc_optaining_ip = false;
1888 wilc_set_power_mgmt(vif, 0, 0);
1890 eth_zero_addr(wilc_connected_ssid);
1892 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
1893 wilc_get_vif_idx(vif));
1896 PRINT_ER("Failed to send dissconect config packet\n");
1898 tstrDisconnectNotifInfo strDisconnectNotifInfo;
1900 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
1902 strDisconnectNotifInfo.u16reason = 0;
1903 strDisconnectNotifInfo.ie = NULL;
1904 strDisconnectNotifInfo.ie_len = 0;
1906 if (hif_drv->usr_scan_req.scan_result) {
1907 del_timer(&hif_drv->scan_timer);
1908 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED,
1910 hif_drv->usr_scan_req.arg,
1912 hif_drv->usr_scan_req.scan_result = NULL;
1915 if (hif_drv->usr_conn_req.conn_result) {
1916 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP)
1917 del_timer(&hif_drv->connect_timer);
1919 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1922 &strDisconnectNotifInfo,
1923 hif_drv->usr_conn_req.arg);
1925 PRINT_ER("usr_conn_req.conn_result = NULL\n");
1928 scan_while_connected = false;
1930 hif_drv->hif_state = HOST_IF_IDLE;
1932 eth_zero_addr(hif_drv->assoc_bssid);
1934 hif_drv->usr_conn_req.ssid_len = 0;
1935 kfree(hif_drv->usr_conn_req.ssid);
1936 hif_drv->usr_conn_req.ssid = NULL;
1937 kfree(hif_drv->usr_conn_req.bssid);
1938 hif_drv->usr_conn_req.bssid = NULL;
1939 hif_drv->usr_conn_req.ies_len = 0;
1940 kfree(hif_drv->usr_conn_req.ies);
1941 hif_drv->usr_conn_req.ies = NULL;
1943 if (join_req && join_req_vif == vif) {
1948 if (info_element && join_req_vif == vif) {
1949 kfree(info_element);
1950 info_element = NULL;
1954 up(&hif_drv->sem_test_disconn_block);
1957 void wilc_resolve_disconnect_aberration(struct wilc_vif *vif)
1961 if ((vif->hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) ||
1962 (vif->hif_drv->hif_state == HOST_IF_CONNECTING))
1963 wilc_disconnect(vif, 1);
1966 static s32 Handle_GetChnl(struct wilc_vif *vif)
1971 wid.id = (u16)WID_CURRENT_CHANNEL;
1972 wid.type = WID_CHAR;
1973 wid.val = (s8 *)&ch_no;
1974 wid.size = sizeof(char);
1976 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
1977 wilc_get_vif_idx(vif));
1980 PRINT_ER("Failed to get channel number\n");
1987 static void Handle_GetRssi(struct wilc_vif *vif)
1992 wid.id = (u16)WID_RSSI;
1993 wid.type = WID_CHAR;
1995 wid.size = sizeof(char);
1997 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
1998 wilc_get_vif_idx(vif));
2000 PRINT_ER("Failed to get RSSI value\n");
2004 up(&vif->hif_drv->sem_get_rssi);
2007 static void Handle_GetLinkspeed(struct wilc_vif *vif)
2014 wid.id = (u16)WID_LINKSPEED;
2015 wid.type = WID_CHAR;
2016 wid.val = &link_speed;
2017 wid.size = sizeof(char);
2019 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
2020 wilc_get_vif_idx(vif));
2022 PRINT_ER("Failed to get LINKSPEED value\n");
2028 static s32 Handle_GetStatistics(struct wilc_vif *vif,
2029 struct rf_info *pstrStatistics)
2031 struct wid strWIDList[5];
2032 u32 u32WidsCount = 0, result = 0;
2034 strWIDList[u32WidsCount].id = WID_LINKSPEED;
2035 strWIDList[u32WidsCount].type = WID_CHAR;
2036 strWIDList[u32WidsCount].size = sizeof(char);
2037 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->link_speed;
2040 strWIDList[u32WidsCount].id = WID_RSSI;
2041 strWIDList[u32WidsCount].type = WID_CHAR;
2042 strWIDList[u32WidsCount].size = sizeof(char);
2043 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->rssi;
2046 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
2047 strWIDList[u32WidsCount].type = WID_INT;
2048 strWIDList[u32WidsCount].size = sizeof(u32);
2049 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_cnt;
2052 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
2053 strWIDList[u32WidsCount].type = WID_INT;
2054 strWIDList[u32WidsCount].size = sizeof(u32);
2055 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->rx_cnt;
2058 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
2059 strWIDList[u32WidsCount].type = WID_INT;
2060 strWIDList[u32WidsCount].size = sizeof(u32);
2061 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_fail_cnt;
2064 result = wilc_send_config_pkt(vif, GET_CFG, strWIDList,
2066 wilc_get_vif_idx(vif));
2069 PRINT_ER("Failed to send scan parameters config packet\n");
2071 if (pstrStatistics->link_speed > TCP_ACK_FILTER_LINK_SPEED_THRESH &&
2072 pstrStatistics->link_speed != DEFAULT_LINK_SPEED)
2073 wilc_enable_tcp_ack_filter(true);
2074 else if (pstrStatistics->link_speed != DEFAULT_LINK_SPEED)
2075 wilc_enable_tcp_ack_filter(false);
2077 if (pstrStatistics != &vif->wilc->dummy_statistics)
2078 up(&hif_sema_wait_response);
2082 static s32 Handle_Get_InActiveTime(struct wilc_vif *vif,
2083 struct sta_inactive_t *strHostIfStaInactiveT)
2088 struct host_if_drv *hif_drv = vif->hif_drv;
2090 wid.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
2092 wid.size = ETH_ALEN;
2093 wid.val = kmalloc(wid.size, GFP_KERNEL);
2096 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
2098 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
2100 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2101 wilc_get_vif_idx(vif));
2104 PRINT_ER("Failed to SET incative time\n");
2108 wid.id = (u16)WID_GET_INACTIVE_TIME;
2110 wid.val = (s8 *)&inactive_time;
2111 wid.size = sizeof(u32);
2113 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
2114 wilc_get_vif_idx(vif));
2117 PRINT_ER("Failed to get incative time\n");
2121 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", inactive_time);
2123 up(&hif_drv->sem_inactive_time);
2128 static void Handle_AddBeacon(struct wilc_vif *vif,
2129 struct beacon_attr *pstrSetBeaconParam)
2135 wid.id = (u16)WID_ADD_BEACON;
2137 wid.size = pstrSetBeaconParam->head_len + pstrSetBeaconParam->tail_len + 16;
2138 wid.val = kmalloc(wid.size, GFP_KERNEL);
2142 pu8CurrByte = wid.val;
2143 *pu8CurrByte++ = (pstrSetBeaconParam->interval & 0xFF);
2144 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 8) & 0xFF);
2145 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 16) & 0xFF);
2146 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 24) & 0xFF);
2148 *pu8CurrByte++ = (pstrSetBeaconParam->dtim_period & 0xFF);
2149 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 8) & 0xFF);
2150 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 16) & 0xFF);
2151 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 24) & 0xFF);
2153 *pu8CurrByte++ = (pstrSetBeaconParam->head_len & 0xFF);
2154 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 8) & 0xFF);
2155 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 16) & 0xFF);
2156 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 24) & 0xFF);
2158 memcpy(pu8CurrByte, pstrSetBeaconParam->head, pstrSetBeaconParam->head_len);
2159 pu8CurrByte += pstrSetBeaconParam->head_len;
2161 *pu8CurrByte++ = (pstrSetBeaconParam->tail_len & 0xFF);
2162 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 8) & 0xFF);
2163 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 16) & 0xFF);
2164 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 24) & 0xFF);
2166 if (pstrSetBeaconParam->tail)
2167 memcpy(pu8CurrByte, pstrSetBeaconParam->tail, pstrSetBeaconParam->tail_len);
2168 pu8CurrByte += pstrSetBeaconParam->tail_len;
2170 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2171 wilc_get_vif_idx(vif));
2173 PRINT_ER("Failed to send add beacon config packet\n");
2177 kfree(pstrSetBeaconParam->head);
2178 kfree(pstrSetBeaconParam->tail);
2181 static void Handle_DelBeacon(struct wilc_vif *vif)
2187 wid.id = (u16)WID_DEL_BEACON;
2188 wid.type = WID_CHAR;
2189 wid.size = sizeof(char);
2190 wid.val = &del_beacon;
2195 pu8CurrByte = wid.val;
2197 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2198 wilc_get_vif_idx(vif));
2200 PRINT_ER("Failed to send delete beacon config packet\n");
2203 static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
2204 struct add_sta_param *pstrStationParam)
2208 pu8CurrByte = pu8Buffer;
2210 memcpy(pu8CurrByte, pstrStationParam->bssid, ETH_ALEN);
2211 pu8CurrByte += ETH_ALEN;
2213 *pu8CurrByte++ = pstrStationParam->aid & 0xFF;
2214 *pu8CurrByte++ = (pstrStationParam->aid >> 8) & 0xFF;
2216 *pu8CurrByte++ = pstrStationParam->rates_len;
2217 if (pstrStationParam->rates_len > 0)
2218 memcpy(pu8CurrByte, pstrStationParam->rates,
2219 pstrStationParam->rates_len);
2220 pu8CurrByte += pstrStationParam->rates_len;
2222 *pu8CurrByte++ = pstrStationParam->ht_supported;
2223 *pu8CurrByte++ = pstrStationParam->ht_capa_info & 0xFF;
2224 *pu8CurrByte++ = (pstrStationParam->ht_capa_info >> 8) & 0xFF;
2226 *pu8CurrByte++ = pstrStationParam->ht_ampdu_params;
2227 memcpy(pu8CurrByte, pstrStationParam->ht_supp_mcs_set,
2228 WILC_SUPP_MCS_SET_SIZE);
2229 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
2231 *pu8CurrByte++ = pstrStationParam->ht_ext_params & 0xFF;
2232 *pu8CurrByte++ = (pstrStationParam->ht_ext_params >> 8) & 0xFF;
2234 *pu8CurrByte++ = pstrStationParam->ht_tx_bf_cap & 0xFF;
2235 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 8) & 0xFF;
2236 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 16) & 0xFF;
2237 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 24) & 0xFF;
2239 *pu8CurrByte++ = pstrStationParam->ht_ante_sel;
2241 *pu8CurrByte++ = pstrStationParam->flags_mask & 0xFF;
2242 *pu8CurrByte++ = (pstrStationParam->flags_mask >> 8) & 0xFF;
2244 *pu8CurrByte++ = pstrStationParam->flags_set & 0xFF;
2245 *pu8CurrByte++ = (pstrStationParam->flags_set >> 8) & 0xFF;
2247 return pu8CurrByte - pu8Buffer;
2250 static void Handle_AddStation(struct wilc_vif *vif,
2251 struct add_sta_param *pstrStationParam)
2257 wid.id = (u16)WID_ADD_STA;
2259 wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->rates_len;
2261 wid.val = kmalloc(wid.size, GFP_KERNEL);
2265 pu8CurrByte = wid.val;
2266 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2268 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2269 wilc_get_vif_idx(vif));
2271 PRINT_ER("Failed to send add station config packet\n");
2274 kfree(pstrStationParam->rates);
2278 static void Handle_DelAllSta(struct wilc_vif *vif,
2279 struct del_all_sta *pstrDelAllStaParam)
2285 u8 au8Zero_Buff[6] = {0};
2287 wid.id = (u16)WID_DEL_ALL_STA;
2289 wid.size = (pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1;
2291 wid.val = kmalloc((pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1, GFP_KERNEL);
2295 pu8CurrByte = wid.val;
2297 *(pu8CurrByte++) = pstrDelAllStaParam->assoc_sta;
2299 for (i = 0; i < MAX_NUM_STA; i++) {
2300 if (memcmp(pstrDelAllStaParam->del_all_sta[i], au8Zero_Buff, ETH_ALEN))
2301 memcpy(pu8CurrByte, pstrDelAllStaParam->del_all_sta[i], ETH_ALEN);
2305 pu8CurrByte += ETH_ALEN;
2308 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2309 wilc_get_vif_idx(vif));
2311 PRINT_ER("Failed to send add station config packet\n");
2316 up(&hif_sema_wait_response);
2319 static void Handle_DelStation(struct wilc_vif *vif,
2320 struct del_sta *pstrDelStaParam)
2326 wid.id = (u16)WID_REMOVE_STA;
2328 wid.size = ETH_ALEN;
2330 wid.val = kmalloc(wid.size, GFP_KERNEL);
2334 pu8CurrByte = wid.val;
2336 memcpy(pu8CurrByte, pstrDelStaParam->mac_addr, ETH_ALEN);
2338 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2339 wilc_get_vif_idx(vif));
2341 PRINT_ER("Failed to send add station config packet\n");
2347 static void Handle_EditStation(struct wilc_vif *vif,
2348 struct add_sta_param *pstrStationParam)
2354 wid.id = (u16)WID_EDIT_STA;
2356 wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->rates_len;
2358 wid.val = kmalloc(wid.size, GFP_KERNEL);
2362 pu8CurrByte = wid.val;
2363 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2365 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2366 wilc_get_vif_idx(vif));
2368 PRINT_ER("Failed to send edit station config packet\n");
2371 kfree(pstrStationParam->rates);
2375 static int Handle_RemainOnChan(struct wilc_vif *vif,
2376 struct remain_ch *pstrHostIfRemainOnChan)
2379 u8 u8remain_on_chan_flag;
2381 struct host_if_drv *hif_drv = vif->hif_drv;
2383 if (!hif_drv->remain_on_ch_pending) {
2384 hif_drv->remain_on_ch.arg = pstrHostIfRemainOnChan->arg;
2385 hif_drv->remain_on_ch.expired = pstrHostIfRemainOnChan->expired;
2386 hif_drv->remain_on_ch.ready = pstrHostIfRemainOnChan->ready;
2387 hif_drv->remain_on_ch.ch = pstrHostIfRemainOnChan->ch;
2388 hif_drv->remain_on_ch.id = pstrHostIfRemainOnChan->id;
2390 pstrHostIfRemainOnChan->ch = hif_drv->remain_on_ch.ch;
2393 if (hif_drv->usr_scan_req.scan_result) {
2394 hif_drv->remain_on_ch_pending = 1;
2398 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
2403 if (wilc_optaining_ip || wilc_connecting) {
2408 u8remain_on_chan_flag = true;
2409 wid.id = (u16)WID_REMAIN_ON_CHAN;
2412 wid.val = kmalloc(wid.size, GFP_KERNEL);
2418 wid.val[0] = u8remain_on_chan_flag;
2419 wid.val[1] = (s8)pstrHostIfRemainOnChan->ch;
2421 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2422 wilc_get_vif_idx(vif));
2424 PRINT_ER("Failed to set remain on channel\n");
2428 P2P_LISTEN_STATE = 1;
2429 hif_drv->remain_on_ch_timer.data = (unsigned long)vif;
2430 mod_timer(&hif_drv->remain_on_ch_timer,
2432 msecs_to_jiffies(pstrHostIfRemainOnChan->duration));
2434 if (hif_drv->remain_on_ch.ready)
2435 hif_drv->remain_on_ch.ready(hif_drv->remain_on_ch.arg);
2437 if (hif_drv->remain_on_ch_pending)
2438 hif_drv->remain_on_ch_pending = 0;
2444 static int Handle_RegisterFrame(struct wilc_vif *vif,
2445 struct reg_frame *pstrHostIfRegisterFrame)
2451 wid.id = (u16)WID_REGISTER_FRAME;
2453 wid.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
2457 pu8CurrByte = wid.val;
2459 *pu8CurrByte++ = pstrHostIfRegisterFrame->reg;
2460 *pu8CurrByte++ = pstrHostIfRegisterFrame->reg_id;
2461 memcpy(pu8CurrByte, &pstrHostIfRegisterFrame->frame_type, sizeof(u16));
2463 wid.size = sizeof(u16) + 2;
2465 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2466 wilc_get_vif_idx(vif));
2468 PRINT_ER("Failed to frame register config packet\n");
2475 static u32 Handle_ListenStateExpired(struct wilc_vif *vif,
2476 struct remain_ch *pstrHostIfRemainOnChan)
2478 u8 u8remain_on_chan_flag;
2481 struct host_if_drv *hif_drv = vif->hif_drv;
2483 if (P2P_LISTEN_STATE) {
2484 u8remain_on_chan_flag = false;
2485 wid.id = (u16)WID_REMAIN_ON_CHAN;
2488 wid.val = kmalloc(wid.size, GFP_KERNEL);
2491 PRINT_ER("Failed to allocate memory\n");
2495 wid.val[0] = u8remain_on_chan_flag;
2496 wid.val[1] = FALSE_FRMWR_CHANNEL;
2498 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2499 wilc_get_vif_idx(vif));
2501 PRINT_ER("Failed to set remain on channel\n");
2505 if (hif_drv->remain_on_ch.expired) {
2506 hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.arg,
2507 pstrHostIfRemainOnChan->id);
2509 P2P_LISTEN_STATE = 0;
2511 netdev_dbg(vif->ndev, "Not in listen state\n");
2519 static void ListenTimerCB(unsigned long arg)
2522 struct host_if_msg msg;
2523 struct wilc_vif *vif = (struct wilc_vif *)arg;
2525 del_timer(&vif->hif_drv->remain_on_ch_timer);
2527 memset(&msg, 0, sizeof(struct host_if_msg));
2528 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
2530 msg.body.remain_on_ch.id = vif->hif_drv->remain_on_ch.id;
2532 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2534 PRINT_ER("wilc_mq_send fail\n");
2537 static void Handle_PowerManagement(struct wilc_vif *vif,
2538 struct power_mgmt_param *strPowerMgmtParam)
2544 wid.id = (u16)WID_POWER_MANAGEMENT;
2546 if (strPowerMgmtParam->enabled)
2547 s8PowerMode = MIN_FAST_PS;
2549 s8PowerMode = NO_POWERSAVE;
2551 wid.val = &s8PowerMode;
2552 wid.size = sizeof(char);
2554 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2555 wilc_get_vif_idx(vif));
2557 PRINT_ER("Failed to send power management config packet\n");
2560 static void Handle_SetMulticastFilter(struct wilc_vif *vif,
2561 struct set_multicast *strHostIfSetMulti)
2567 wid.id = (u16)WID_SETUP_MULTICAST_FILTER;
2569 wid.size = sizeof(struct set_multicast) + ((strHostIfSetMulti->cnt) * ETH_ALEN);
2570 wid.val = kmalloc(wid.size, GFP_KERNEL);
2574 pu8CurrByte = wid.val;
2575 *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF);
2580 *pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF);
2581 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF);
2582 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 16) & 0xFF);
2583 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 24) & 0xFF);
2585 if ((strHostIfSetMulti->cnt) > 0)
2586 memcpy(pu8CurrByte, wilc_multicast_mac_addr_list,
2587 ((strHostIfSetMulti->cnt) * ETH_ALEN));
2589 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2590 wilc_get_vif_idx(vif));
2592 PRINT_ER("Failed to send setup multicast config packet\n");
2598 static s32 Handle_DelAllRxBASessions(struct wilc_vif *vif,
2599 struct ba_session_info *strHostIfBASessionInfo)
2605 wid.id = (u16)WID_DEL_ALL_RX_BA;
2607 wid.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2608 wid.size = BLOCK_ACK_REQ_SIZE;
2613 memcpy(ptr, strHostIfBASessionInfo->bssid, ETH_ALEN);
2615 *ptr++ = strHostIfBASessionInfo->tid;
2619 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2620 wilc_get_vif_idx(vif));
2624 up(&hif_sema_wait_response);
2629 static void handle_set_tx_pwr(struct wilc_vif *vif, u8 tx_pwr)
2634 wid.id = (u16)WID_TX_POWER;
2635 wid.type = WID_CHAR;
2637 wid.size = sizeof(char);
2639 ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2640 wilc_get_vif_idx(vif));
2642 netdev_err(vif->ndev, "Failed to set TX PWR\n");
2645 static void handle_get_tx_pwr(struct wilc_vif *vif, u8 *tx_pwr)
2650 wid.id = (u16)WID_TX_POWER;
2651 wid.type = WID_CHAR;
2652 wid.val = (s8 *)tx_pwr;
2653 wid.size = sizeof(char);
2655 ret = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
2656 wilc_get_vif_idx(vif));
2658 netdev_err(vif->ndev, "Failed to get TX PWR\n");
2660 up(&hif_sema_wait_response);
2663 static int hostIFthread(void *pvArg)
2666 struct host_if_msg msg;
2667 struct wilc *wilc = pvArg;
2668 struct wilc_vif *vif;
2670 memset(&msg, 0, sizeof(struct host_if_msg));
2673 wilc_mq_recv(&hif_msg_q, &msg, sizeof(struct host_if_msg), &u32Ret);
2675 if (msg.id == HOST_IF_MSG_EXIT)
2678 if ((!wilc_initialized)) {
2679 usleep_range(200 * 1000, 200 * 1000);
2680 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2684 if (msg.id == HOST_IF_MSG_CONNECT &&
2685 vif->hif_drv->usr_scan_req.scan_result) {
2686 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2687 usleep_range(2 * 1000, 2 * 1000);
2692 case HOST_IF_MSG_Q_IDLE:
2693 Handle_wait_msg_q_empty();
2696 case HOST_IF_MSG_SCAN:
2697 Handle_Scan(msg.vif, &msg.body.scan_info);
2700 case HOST_IF_MSG_CONNECT:
2701 Handle_Connect(msg.vif, &msg.body.con_info);
2704 case HOST_IF_MSG_FLUSH_CONNECT:
2705 Handle_FlushConnect(msg.vif);
2708 case HOST_IF_MSG_RCVD_NTWRK_INFO:
2709 Handle_RcvdNtwrkInfo(msg.vif, &msg.body.net_info);
2712 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
2713 Handle_RcvdGnrlAsyncInfo(vif,
2714 &msg.body.async_info);
2717 case HOST_IF_MSG_KEY:
2718 Handle_Key(msg.vif, &msg.body.key_info);
2721 case HOST_IF_MSG_CFG_PARAMS:
2722 handle_cfg_param(msg.vif, &msg.body.cfg_info);
2725 case HOST_IF_MSG_SET_CHANNEL:
2726 handle_set_channel(msg.vif, &msg.body.channel_info);
2729 case HOST_IF_MSG_DISCONNECT:
2730 Handle_Disconnect(msg.vif);
2733 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
2734 del_timer(&vif->hif_drv->scan_timer);
2736 if (!wilc_wlan_get_num_conn_ifcs(wilc))
2737 wilc_chip_sleep_manually(wilc);
2739 Handle_ScanDone(msg.vif, SCAN_EVENT_DONE);
2741 if (vif->hif_drv->remain_on_ch_pending)
2742 Handle_RemainOnChan(msg.vif,
2743 &msg.body.remain_on_ch);
2747 case HOST_IF_MSG_GET_RSSI:
2748 Handle_GetRssi(msg.vif);
2751 case HOST_IF_MSG_GET_LINKSPEED:
2752 Handle_GetLinkspeed(msg.vif);
2755 case HOST_IF_MSG_GET_STATISTICS:
2756 Handle_GetStatistics(msg.vif,
2757 (struct rf_info *)msg.body.data);
2760 case HOST_IF_MSG_GET_CHNL:
2761 Handle_GetChnl(msg.vif);
2764 case HOST_IF_MSG_ADD_BEACON:
2765 Handle_AddBeacon(msg.vif, &msg.body.beacon_info);
2768 case HOST_IF_MSG_DEL_BEACON:
2769 Handle_DelBeacon(msg.vif);
2772 case HOST_IF_MSG_ADD_STATION:
2773 Handle_AddStation(msg.vif, &msg.body.add_sta_info);
2776 case HOST_IF_MSG_DEL_STATION:
2777 Handle_DelStation(msg.vif, &msg.body.del_sta_info);
2780 case HOST_IF_MSG_EDIT_STATION:
2781 Handle_EditStation(msg.vif, &msg.body.edit_sta_info);
2784 case HOST_IF_MSG_GET_INACTIVETIME:
2785 Handle_Get_InActiveTime(msg.vif, &msg.body.mac_info);
2788 case HOST_IF_MSG_SCAN_TIMER_FIRED:
2790 Handle_ScanDone(msg.vif, SCAN_EVENT_ABORTED);
2793 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
2794 Handle_ConnectTimeout(msg.vif);
2797 case HOST_IF_MSG_POWER_MGMT:
2798 Handle_PowerManagement(msg.vif,
2799 &msg.body.pwr_mgmt_info);
2802 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
2803 handle_set_wfi_drv_handler(msg.vif, &msg.body.drv);
2806 case HOST_IF_MSG_SET_OPERATION_MODE:
2807 handle_set_operation_mode(msg.vif, &msg.body.mode);
2810 case HOST_IF_MSG_SET_IPADDRESS:
2811 handle_set_ip_address(vif,
2812 msg.body.ip_info.ip_addr,
2813 msg.body.ip_info.idx);
2816 case HOST_IF_MSG_GET_IPADDRESS:
2817 handle_get_ip_address(vif, msg.body.ip_info.idx);
2820 case HOST_IF_MSG_SET_MAC_ADDRESS:
2821 handle_set_mac_address(msg.vif,
2822 &msg.body.set_mac_info);
2825 case HOST_IF_MSG_GET_MAC_ADDRESS:
2826 handle_get_mac_address(msg.vif,
2827 &msg.body.get_mac_info);
2830 case HOST_IF_MSG_REMAIN_ON_CHAN:
2831 Handle_RemainOnChan(msg.vif, &msg.body.remain_on_ch);
2834 case HOST_IF_MSG_REGISTER_FRAME:
2835 Handle_RegisterFrame(msg.vif, &msg.body.reg_frame);
2838 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
2839 Handle_ListenStateExpired(msg.vif, &msg.body.remain_on_ch);
2842 case HOST_IF_MSG_SET_MULTICAST_FILTER:
2843 Handle_SetMulticastFilter(msg.vif, &msg.body.multicast_info);
2846 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
2847 Handle_DelAllRxBASessions(msg.vif, &msg.body.session_info);
2850 case HOST_IF_MSG_DEL_ALL_STA:
2851 Handle_DelAllSta(msg.vif, &msg.body.del_all_sta_info);
2854 case HOST_IF_MSG_SET_TX_POWER:
2855 handle_set_tx_pwr(msg.vif, msg.body.tx_power.tx_pwr);
2858 case HOST_IF_MSG_GET_TX_POWER:
2859 handle_get_tx_pwr(msg.vif, &msg.body.tx_power.tx_pwr);
2862 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
2867 up(&hif_sema_thread);
2871 static void TimerCB_Scan(unsigned long arg)
2873 struct wilc_vif *vif = (struct wilc_vif *)arg;
2874 struct host_if_msg msg;
2876 memset(&msg, 0, sizeof(struct host_if_msg));
2878 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
2880 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2883 static void TimerCB_Connect(unsigned long arg)
2885 struct wilc_vif *vif = (struct wilc_vif *)arg;
2886 struct host_if_msg msg;
2888 memset(&msg, 0, sizeof(struct host_if_msg));
2890 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
2892 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2895 s32 wilc_remove_key(struct host_if_drv *hif_drv, const u8 *pu8StaAddress)
2899 wid.id = (u16)WID_REMOVE_KEY;
2901 wid.val = (s8 *)pu8StaAddress;
2907 int wilc_remove_wep_key(struct wilc_vif *vif, u8 index)
2910 struct host_if_msg msg;
2911 struct host_if_drv *hif_drv = vif->hif_drv;
2915 PRINT_ER("Failed to send setup multicast config packet\n");
2919 memset(&msg, 0, sizeof(struct host_if_msg));
2921 msg.id = HOST_IF_MSG_KEY;
2922 msg.body.key_info.type = WEP;
2923 msg.body.key_info.action = REMOVEKEY;
2925 msg.body.key_info.attr.wep.index = index;
2927 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2929 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
2930 down(&hif_drv->sem_test_key_block);
2935 int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index)
2938 struct host_if_msg msg;
2939 struct host_if_drv *hif_drv = vif->hif_drv;
2943 PRINT_ER("driver is null\n");
2947 memset(&msg, 0, sizeof(struct host_if_msg));
2949 msg.id = HOST_IF_MSG_KEY;
2950 msg.body.key_info.type = WEP;
2951 msg.body.key_info.action = DEFAULTKEY;
2953 msg.body.key_info.attr.wep.index = index;
2955 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2957 PRINT_ER("Error in sending message queue : Default key index\n");
2958 down(&hif_drv->sem_test_key_block);
2963 int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len,
2967 struct host_if_msg msg;
2968 struct host_if_drv *hif_drv = vif->hif_drv;
2971 PRINT_ER("driver is null\n");
2975 memset(&msg, 0, sizeof(struct host_if_msg));
2977 msg.id = HOST_IF_MSG_KEY;
2978 msg.body.key_info.type = WEP;
2979 msg.body.key_info.action = ADDKEY;
2981 msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
2982 if (!msg.body.key_info.attr.wep.key)
2985 msg.body.key_info.attr.wep.key_len = len;
2986 msg.body.key_info.attr.wep.index = index;
2988 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2990 PRINT_ER("Error in sending message queue :WEP Key\n");
2991 down(&hif_drv->sem_test_key_block);
2996 int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len,
2997 u8 index, u8 mode, enum AUTHTYPE auth_type)
3000 struct host_if_msg msg;
3001 struct host_if_drv *hif_drv = vif->hif_drv;
3005 PRINT_ER("driver is null\n");
3009 memset(&msg, 0, sizeof(struct host_if_msg));
3012 for (i = 0; i < len; i++)
3013 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", key[i]);
3015 msg.id = HOST_IF_MSG_KEY;
3016 msg.body.key_info.type = WEP;
3017 msg.body.key_info.action = ADDKEY_AP;
3019 msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
3020 if (!msg.body.key_info.attr.wep.key)
3023 msg.body.key_info.attr.wep.key_len = len;
3024 msg.body.key_info.attr.wep.index = index;
3025 msg.body.key_info.attr.wep.mode = mode;
3026 msg.body.key_info.attr.wep.auth_type = auth_type;
3028 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3031 PRINT_ER("Error in sending message queue :WEP Key\n");
3032 down(&hif_drv->sem_test_key_block);
3037 int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
3038 const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
3039 u8 mode, u8 cipher_mode, u8 index)
3042 struct host_if_msg msg;
3043 struct host_if_drv *hif_drv = vif->hif_drv;
3044 u8 key_len = ptk_key_len;
3048 PRINT_ER("driver is null\n");
3053 key_len += RX_MIC_KEY_LEN;
3056 key_len += TX_MIC_KEY_LEN;
3058 memset(&msg, 0, sizeof(struct host_if_msg));
3060 msg.id = HOST_IF_MSG_KEY;
3061 msg.body.key_info.type = WPA_PTK;
3062 if (mode == AP_MODE) {
3063 msg.body.key_info.action = ADDKEY_AP;
3064 msg.body.key_info.attr.wpa.index = index;
3066 if (mode == STATION_MODE)
3067 msg.body.key_info.action = ADDKEY;
3069 msg.body.key_info.attr.wpa.key = kmemdup(ptk, ptk_key_len, GFP_KERNEL);
3070 if (!msg.body.key_info.attr.wpa.key)
3074 memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic, RX_MIC_KEY_LEN);
3076 for (i = 0; i < RX_MIC_KEY_LEN; i++)
3077 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, rx_mic[i]);
3081 memcpy(msg.body.key_info.attr.wpa.key + 24, tx_mic, TX_MIC_KEY_LEN);
3083 for (i = 0; i < TX_MIC_KEY_LEN; i++)
3084 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, tx_mic[i]);
3088 msg.body.key_info.attr.wpa.key_len = key_len;
3089 msg.body.key_info.attr.wpa.mac_addr = mac_addr;
3090 msg.body.key_info.attr.wpa.mode = cipher_mode;
3093 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3096 PRINT_ER("Error in sending message queue: PTK Key\n");
3098 down(&hif_drv->sem_test_key_block);
3103 int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
3104 u8 index, u32 key_rsc_len, const u8 *key_rsc,
3105 const u8 *rx_mic, const u8 *tx_mic, u8 mode,
3109 struct host_if_msg msg;
3110 struct host_if_drv *hif_drv = vif->hif_drv;
3111 u8 key_len = gtk_key_len;
3114 PRINT_ER("driver is null\n");
3117 memset(&msg, 0, sizeof(struct host_if_msg));
3120 key_len += RX_MIC_KEY_LEN;
3123 key_len += TX_MIC_KEY_LEN;
3126 msg.body.key_info.attr.wpa.seq = kmemdup(key_rsc,
3129 if (!msg.body.key_info.attr.wpa.seq)
3133 msg.id = HOST_IF_MSG_KEY;
3134 msg.body.key_info.type = WPA_RX_GTK;
3137 if (mode == AP_MODE) {
3138 msg.body.key_info.action = ADDKEY_AP;
3139 msg.body.key_info.attr.wpa.mode = cipher_mode;
3141 if (mode == STATION_MODE)
3142 msg.body.key_info.action = ADDKEY;
3144 msg.body.key_info.attr.wpa.key = kmemdup(rx_gtk,
3147 if (!msg.body.key_info.attr.wpa.key)
3151 memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic,
3155 memcpy(msg.body.key_info.attr.wpa.key + 24, tx_mic,
3158 msg.body.key_info.attr.wpa.index = index;
3159 msg.body.key_info.attr.wpa.key_len = key_len;
3160 msg.body.key_info.attr.wpa.seq_len = key_rsc_len;
3162 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3164 PRINT_ER("Error in sending message queue: RX GTK\n");
3166 down(&hif_drv->sem_test_key_block);
3171 int wilc_set_pmkid_info(struct wilc_vif *vif,
3172 struct host_if_pmkid_attr *pmkid)
3175 struct host_if_msg msg;
3176 struct host_if_drv *hif_drv = vif->hif_drv;
3180 PRINT_ER("driver is null\n");
3184 memset(&msg, 0, sizeof(struct host_if_msg));
3186 msg.id = HOST_IF_MSG_KEY;
3187 msg.body.key_info.type = PMKSA;
3188 msg.body.key_info.action = ADDKEY;
3191 for (i = 0; i < pmkid->numpmkid; i++) {
3192 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].bssid,
3193 &pmkid->pmkidlist[i].bssid, ETH_ALEN);
3194 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].pmkid,
3195 &pmkid->pmkidlist[i].pmkid, PMKID_LEN);
3198 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3200 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
3205 int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr)
3208 struct host_if_msg msg;
3210 memset(&msg, 0, sizeof(struct host_if_msg));
3212 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
3213 msg.body.get_mac_info.mac_addr = mac_addr;
3216 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3218 PRINT_ER("Failed to send get mac address\n");
3222 down(&hif_sema_wait_response);
3226 int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid,
3227 size_t ssid_len, const u8 *ies, size_t ies_len,
3228 wilc_connect_result connect_result, void *user_arg,
3229 u8 security, enum AUTHTYPE auth_type,
3230 u8 channel, void *join_params)
3233 struct host_if_msg msg;
3234 struct host_if_drv *hif_drv = vif->hif_drv;
3236 if (!hif_drv || !connect_result) {
3237 PRINT_ER("Driver is null\n");
3242 PRINT_ER("Unable to Join - JoinParams is NULL\n");
3246 memset(&msg, 0, sizeof(struct host_if_msg));
3248 msg.id = HOST_IF_MSG_CONNECT;
3250 msg.body.con_info.security = security;
3251 msg.body.con_info.auth_type = auth_type;
3252 msg.body.con_info.ch = channel;
3253 msg.body.con_info.result = connect_result;
3254 msg.body.con_info.arg = user_arg;
3255 msg.body.con_info.params = join_params;
3259 msg.body.con_info.bssid = kmemdup(bssid, 6, GFP_KERNEL);
3260 if (!msg.body.con_info.bssid)
3265 msg.body.con_info.ssid_len = ssid_len;
3266 msg.body.con_info.ssid = kmemdup(ssid, ssid_len, GFP_KERNEL);
3267 if (!msg.body.con_info.ssid)
3272 msg.body.con_info.ies_len = ies_len;
3273 msg.body.con_info.ies = kmemdup(ies, ies_len, GFP_KERNEL);
3274 if (!msg.body.con_info.ies)
3277 if (hif_drv->hif_state < HOST_IF_CONNECTING)
3278 hif_drv->hif_state = HOST_IF_CONNECTING;
3280 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3282 PRINT_ER("Failed to send message queue: Set join request\n");
3286 hif_drv->connect_timer.data = (unsigned long)vif;
3287 mod_timer(&hif_drv->connect_timer,
3288 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
3293 int wilc_disconnect(struct wilc_vif *vif, u16 reason_code)
3296 struct host_if_msg msg;
3297 struct host_if_drv *hif_drv = vif->hif_drv;
3300 PRINT_ER("Driver is null\n");
3304 memset(&msg, 0, sizeof(struct host_if_msg));
3306 msg.id = HOST_IF_MSG_DISCONNECT;
3309 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3311 PRINT_ER("Failed to send message queue: disconnect\n");
3313 down(&hif_drv->sem_test_disconn_block);
3318 static s32 host_int_get_assoc_res_info(struct wilc_vif *vif,
3319 u8 *pu8AssocRespInfo,
3320 u32 u32MaxAssocRespInfoLen,
3321 u32 *pu32RcvdAssocRespInfoLen)
3325 struct host_if_drv *hif_drv = vif->hif_drv;
3328 PRINT_ER("Driver is null\n");
3332 wid.id = (u16)WID_ASSOC_RES_INFO;
3334 wid.val = pu8AssocRespInfo;
3335 wid.size = u32MaxAssocRespInfoLen;
3337 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
3338 wilc_get_vif_idx(vif));
3340 *pu32RcvdAssocRespInfoLen = 0;
3341 PRINT_ER("Failed to send association response config packet\n");
3345 *pu32RcvdAssocRespInfoLen = wid.size;
3349 int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel)
3352 struct host_if_msg msg;
3353 struct host_if_drv *hif_drv = vif->hif_drv;
3356 PRINT_ER("driver is null\n");
3360 memset(&msg, 0, sizeof(struct host_if_msg));
3361 msg.id = HOST_IF_MSG_SET_CHANNEL;
3362 msg.body.channel_info.set_ch = channel;
3365 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3367 PRINT_ER("wilc mq send fail\n");
3374 int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mac_idx)
3377 struct host_if_msg msg;
3379 memset(&msg, 0, sizeof(struct host_if_msg));
3380 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
3381 msg.body.drv.handler = index;
3382 msg.body.drv.mac_idx = mac_idx;
3385 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3387 PRINT_ER("wilc mq send fail\n");
3394 int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode)
3397 struct host_if_msg msg;
3399 memset(&msg, 0, sizeof(struct host_if_msg));
3400 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
3401 msg.body.mode.mode = mode;
3404 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3406 PRINT_ER("wilc mq send fail\n");
3413 s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
3414 u32 *pu32InactiveTime)
3417 struct host_if_msg msg;
3418 struct host_if_drv *hif_drv = vif->hif_drv;
3421 PRINT_ER("driver is null\n");
3425 memset(&msg, 0, sizeof(struct host_if_msg));
3426 memcpy(msg.body.mac_info.mac, mac, ETH_ALEN);
3428 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
3431 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3433 PRINT_ER("Failed to send get host channel param's message queue ");
3435 down(&hif_drv->sem_inactive_time);
3437 *pu32InactiveTime = inactive_time;
3442 int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level)
3445 struct host_if_msg msg;
3446 struct host_if_drv *hif_drv = vif->hif_drv;
3448 memset(&msg, 0, sizeof(struct host_if_msg));
3449 msg.id = HOST_IF_MSG_GET_RSSI;
3452 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3454 PRINT_ER("Failed to send get host channel param's message queue ");
3458 down(&hif_drv->sem_get_rssi);
3461 PRINT_ER("RSS pointer value is null");
3470 int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats)
3473 struct host_if_msg msg;
3475 memset(&msg, 0, sizeof(struct host_if_msg));
3476 msg.id = HOST_IF_MSG_GET_STATISTICS;
3477 msg.body.data = (char *)stats;
3480 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3482 PRINT_ER("Failed to send get host channel param's message queue ");
3486 if (stats != &vif->wilc->dummy_statistics)
3487 down(&hif_sema_wait_response);
3491 int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
3492 u8 *ch_freq_list, u8 ch_list_len, const u8 *ies,
3493 size_t ies_len, wilc_scan_result scan_result, void *user_arg,
3494 struct hidden_network *hidden_network)
3497 struct host_if_msg msg;
3498 struct scan_attr *scan_info = &msg.body.scan_info;
3499 struct host_if_drv *hif_drv = vif->hif_drv;
3501 if (!hif_drv || !scan_result) {
3502 PRINT_ER("hif_drv or scan_result = NULL\n");
3506 memset(&msg, 0, sizeof(struct host_if_msg));
3508 msg.id = HOST_IF_MSG_SCAN;
3510 if (hidden_network) {
3511 scan_info->hidden_network.net_info = hidden_network->net_info;
3512 scan_info->hidden_network.n_ssids = hidden_network->n_ssids;
3516 scan_info->src = scan_source;
3517 scan_info->type = scan_type;
3518 scan_info->result = scan_result;
3519 scan_info->arg = user_arg;
3521 scan_info->ch_list_len = ch_list_len;
3522 scan_info->ch_freq_list = kmemdup(ch_freq_list,
3525 if (!scan_info->ch_freq_list)
3528 scan_info->ies_len = ies_len;
3529 scan_info->ies = kmemdup(ies, ies_len, GFP_KERNEL);
3530 if (!scan_info->ies)
3533 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3535 PRINT_ER("Error in sending message queue\n");
3539 hif_drv->scan_timer.data = (unsigned long)vif;
3540 mod_timer(&hif_drv->scan_timer,
3541 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
3546 int wilc_hif_set_cfg(struct wilc_vif *vif,
3547 struct cfg_param_val *cfg_param)
3550 struct host_if_msg msg;
3551 struct host_if_drv *hif_drv = vif->hif_drv;
3554 PRINT_ER("hif_drv NULL\n");
3558 memset(&msg, 0, sizeof(struct host_if_msg));
3559 msg.id = HOST_IF_MSG_CFG_PARAMS;
3560 msg.body.cfg_info.cfg_attr_info = *cfg_param;
3563 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3568 static void GetPeriodicRSSI(unsigned long arg)
3570 struct wilc_vif *vif = (struct wilc_vif *)arg;
3572 if (!vif->hif_drv) {
3573 PRINT_ER("Driver handler is NULL\n");
3577 if (vif->hif_drv->hif_state == HOST_IF_CONNECTED)
3578 wilc_get_statistics(vif, &vif->wilc->dummy_statistics);
3580 periodic_rssi.data = (unsigned long)vif;
3581 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
3584 int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
3587 struct host_if_drv *hif_drv;
3588 struct wilc_vif *vif;
3592 vif = netdev_priv(dev);
3595 scan_while_connected = false;
3597 sema_init(&hif_sema_wait_response, 0);
3599 hif_drv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
3604 *hif_drv_handler = hif_drv;
3605 for (i = 0; i < wilc->vif_num; i++)
3606 if (dev == wilc->vif[i]->ndev) {
3607 wilc->vif[i]->hif_drv = hif_drv;
3611 wilc_optaining_ip = false;
3613 if (clients_count == 0) {
3614 sema_init(&hif_sema_thread, 0);
3615 sema_init(&hif_sema_driver, 0);
3616 sema_init(&hif_sema_deinit, 1);
3619 sema_init(&hif_drv->sem_test_key_block, 0);
3620 sema_init(&hif_drv->sem_test_disconn_block, 0);
3621 sema_init(&hif_drv->sem_get_rssi, 0);
3622 sema_init(&hif_drv->sem_inactive_time, 0);
3624 if (clients_count == 0) {
3625 result = wilc_mq_create(&hif_msg_q);
3628 PRINT_ER("Failed to creat MQ\n");
3632 hif_thread_handler = kthread_run(hostIFthread, wilc,
3635 if (IS_ERR(hif_thread_handler)) {
3636 PRINT_ER("Failed to creat Thread\n");
3640 setup_timer(&periodic_rssi, GetPeriodicRSSI,
3641 (unsigned long)vif);
3642 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
3645 setup_timer(&hif_drv->scan_timer, TimerCB_Scan, 0);
3646 setup_timer(&hif_drv->connect_timer, TimerCB_Connect, 0);
3647 setup_timer(&hif_drv->remain_on_ch_timer, ListenTimerCB, 0);
3649 sema_init(&hif_drv->sem_cfg_values, 1);
3650 down(&hif_drv->sem_cfg_values);
3652 hif_drv->hif_state = HOST_IF_IDLE;
3653 hif_drv->cfg_values.site_survey_enabled = SITE_SURVEY_OFF;
3654 hif_drv->cfg_values.scan_source = DEFAULT_SCAN;
3655 hif_drv->cfg_values.active_scan_time = ACTIVE_SCAN_TIME;
3656 hif_drv->cfg_values.passive_scan_time = PASSIVE_SCAN_TIME;
3657 hif_drv->cfg_values.curr_tx_rate = AUTORATE;
3659 hif_drv->p2p_timeout = 0;
3661 up(&hif_drv->sem_cfg_values);
3668 wilc_mq_destroy(&hif_msg_q);
3673 int wilc_deinit(struct wilc_vif *vif)
3676 struct host_if_msg msg;
3677 struct host_if_drv *hif_drv = vif->hif_drv;
3680 PRINT_ER("hif_drv = NULL\n");
3684 down(&hif_sema_deinit);
3686 terminated_handle = hif_drv;
3688 del_timer_sync(&hif_drv->scan_timer);
3689 del_timer_sync(&hif_drv->connect_timer);
3690 del_timer_sync(&periodic_rssi);
3691 del_timer_sync(&hif_drv->remain_on_ch_timer);
3693 wilc_set_wfi_drv_handler(vif, 0, 0);
3694 down(&hif_sema_driver);
3696 if (hif_drv->usr_scan_req.scan_result) {
3697 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, NULL,
3698 hif_drv->usr_scan_req.arg, NULL);
3699 hif_drv->usr_scan_req.scan_result = NULL;
3702 hif_drv->hif_state = HOST_IF_IDLE;
3704 scan_while_connected = false;
3706 memset(&msg, 0, sizeof(struct host_if_msg));
3708 if (clients_count == 1) {
3709 del_timer_sync(&periodic_rssi);
3710 msg.id = HOST_IF_MSG_EXIT;
3713 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3715 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", result);
3717 down(&hif_sema_thread);
3719 wilc_mq_destroy(&hif_msg_q);
3725 terminated_handle = NULL;
3726 up(&hif_sema_deinit);
3730 void wilc_network_info_received(struct wilc *wilc, u8 *pu8Buffer,
3734 struct host_if_msg msg;
3736 struct host_if_drv *hif_drv = NULL;
3737 struct wilc_vif *vif;
3739 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
3740 vif = wilc_get_vif_from_idx(wilc, id);
3743 hif_drv = vif->hif_drv;
3745 if (!hif_drv || hif_drv == terminated_handle) {
3746 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv);
3750 memset(&msg, 0, sizeof(struct host_if_msg));
3752 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
3755 msg.body.net_info.len = u32Length;
3756 msg.body.net_info.buffer = kmalloc(u32Length, GFP_KERNEL);
3757 memcpy(msg.body.net_info.buffer, pu8Buffer, u32Length);
3759 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3761 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", result);
3764 void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *pu8Buffer,
3768 struct host_if_msg msg;
3770 struct host_if_drv *hif_drv = NULL;
3771 struct wilc_vif *vif;
3773 down(&hif_sema_deinit);
3775 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
3776 vif = wilc_get_vif_from_idx(wilc, id);
3778 up(&hif_sema_deinit);
3782 hif_drv = vif->hif_drv;
3784 if (!hif_drv || hif_drv == terminated_handle) {
3785 up(&hif_sema_deinit);
3789 if (!hif_drv->usr_conn_req.conn_result) {
3790 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
3791 up(&hif_sema_deinit);
3795 memset(&msg, 0, sizeof(struct host_if_msg));
3797 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
3800 msg.body.async_info.len = u32Length;
3801 msg.body.async_info.buffer = kmalloc(u32Length, GFP_KERNEL);
3802 memcpy(msg.body.async_info.buffer, pu8Buffer, u32Length);
3804 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3806 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", result);
3808 up(&hif_sema_deinit);
3811 void wilc_scan_complete_received(struct wilc *wilc, u8 *pu8Buffer,
3815 struct host_if_msg msg;
3817 struct host_if_drv *hif_drv = NULL;
3818 struct wilc_vif *vif;
3820 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
3821 vif = wilc_get_vif_from_idx(wilc, id);
3824 hif_drv = vif->hif_drv;
3826 if (!hif_drv || hif_drv == terminated_handle)
3829 if (hif_drv->usr_scan_req.scan_result) {
3830 memset(&msg, 0, sizeof(struct host_if_msg));
3832 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
3835 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3837 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", result);
3841 int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id,
3842 u32 duration, u16 chan,
3843 wilc_remain_on_chan_expired expired,
3844 wilc_remain_on_chan_ready ready,
3848 struct host_if_msg msg;
3849 struct host_if_drv *hif_drv = vif->hif_drv;
3852 PRINT_ER("driver is null\n");
3856 memset(&msg, 0, sizeof(struct host_if_msg));
3858 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
3859 msg.body.remain_on_ch.ch = chan;
3860 msg.body.remain_on_ch.expired = expired;
3861 msg.body.remain_on_ch.ready = ready;
3862 msg.body.remain_on_ch.arg = user_arg;
3863 msg.body.remain_on_ch.duration = duration;
3864 msg.body.remain_on_ch.id = session_id;
3867 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3869 PRINT_ER("wilc mq send fail\n");
3874 int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id)
3877 struct host_if_msg msg;
3878 struct host_if_drv *hif_drv = vif->hif_drv;
3881 PRINT_ER("driver is null\n");
3885 del_timer(&hif_drv->remain_on_ch_timer);
3887 memset(&msg, 0, sizeof(struct host_if_msg));
3888 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
3890 msg.body.remain_on_ch.id = session_id;
3892 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3894 PRINT_ER("wilc mq send fail\n");
3899 int wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg)
3902 struct host_if_msg msg;
3903 struct host_if_drv *hif_drv = vif->hif_drv;
3906 PRINT_ER("driver is null\n");
3910 memset(&msg, 0, sizeof(struct host_if_msg));
3912 msg.id = HOST_IF_MSG_REGISTER_FRAME;
3913 switch (frame_type) {
3915 msg.body.reg_frame.reg_id = ACTION_FRM_IDX;
3919 msg.body.reg_frame.reg_id = PROBE_REQ_IDX;
3925 msg.body.reg_frame.frame_type = frame_type;
3926 msg.body.reg_frame.reg = reg;
3929 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3931 PRINT_ER("wilc mq send fail\n");
3936 int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period,
3937 u32 head_len, u8 *head, u32 tail_len, u8 *tail)
3940 struct host_if_msg msg;
3941 struct beacon_attr *beacon_info = &msg.body.beacon_info;
3942 struct host_if_drv *hif_drv = vif->hif_drv;
3945 PRINT_ER("driver is null\n");
3949 memset(&msg, 0, sizeof(struct host_if_msg));
3951 msg.id = HOST_IF_MSG_ADD_BEACON;
3953 beacon_info->interval = interval;
3954 beacon_info->dtim_period = dtim_period;
3955 beacon_info->head_len = head_len;
3956 beacon_info->head = kmemdup(head, head_len, GFP_KERNEL);
3957 if (!beacon_info->head) {
3961 beacon_info->tail_len = tail_len;
3964 beacon_info->tail = kmemdup(tail, tail_len, GFP_KERNEL);
3965 if (!beacon_info->tail) {
3970 beacon_info->tail = NULL;
3973 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3975 PRINT_ER("wilc mq send fail\n");
3979 kfree(beacon_info->head);
3981 kfree(beacon_info->tail);
3987 int wilc_del_beacon(struct wilc_vif *vif)
3990 struct host_if_msg msg;
3991 struct host_if_drv *hif_drv = vif->hif_drv;
3994 PRINT_ER("driver is null\n");
3998 msg.id = HOST_IF_MSG_DEL_BEACON;
4001 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4003 PRINT_ER("wilc_mq_send fail\n");
4008 int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param)
4011 struct host_if_msg msg;
4012 struct add_sta_param *add_sta_info = &msg.body.add_sta_info;
4013 struct host_if_drv *hif_drv = vif->hif_drv;
4016 PRINT_ER("driver is null\n");
4020 memset(&msg, 0, sizeof(struct host_if_msg));
4022 msg.id = HOST_IF_MSG_ADD_STATION;
4025 memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param));
4026 if (add_sta_info->rates_len > 0) {
4027 add_sta_info->rates = kmemdup(sta_param->rates,
4028 add_sta_info->rates_len,
4030 if (!add_sta_info->rates)
4034 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4036 PRINT_ER("wilc_mq_send fail\n");
4040 int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr)
4043 struct host_if_msg msg;
4044 struct del_sta *del_sta_info = &msg.body.del_sta_info;
4045 struct host_if_drv *hif_drv = vif->hif_drv;
4048 PRINT_ER("driver is null\n");
4052 memset(&msg, 0, sizeof(struct host_if_msg));
4054 msg.id = HOST_IF_MSG_DEL_STATION;
4058 eth_broadcast_addr(del_sta_info->mac_addr);
4060 memcpy(del_sta_info->mac_addr, mac_addr, ETH_ALEN);
4062 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4064 PRINT_ER("wilc_mq_send fail\n");
4068 int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN])
4071 struct host_if_msg msg;
4072 struct del_all_sta *del_all_sta_info = &msg.body.del_all_sta_info;
4073 struct host_if_drv *hif_drv = vif->hif_drv;
4074 u8 zero_addr[ETH_ALEN] = {0};
4079 PRINT_ER("driver is null\n");
4083 memset(&msg, 0, sizeof(struct host_if_msg));
4085 msg.id = HOST_IF_MSG_DEL_ALL_STA;
4088 for (i = 0; i < MAX_NUM_STA; i++) {
4089 if (memcmp(mac_addr[i], zero_addr, ETH_ALEN)) {
4090 memcpy(del_all_sta_info->del_all_sta[i], mac_addr[i], ETH_ALEN);
4091 PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n",
4092 del_all_sta_info->del_all_sta[i][0],
4093 del_all_sta_info->del_all_sta[i][1],
4094 del_all_sta_info->del_all_sta[i][2],
4095 del_all_sta_info->del_all_sta[i][3],
4096 del_all_sta_info->del_all_sta[i][4],
4097 del_all_sta_info->del_all_sta[i][5]);
4102 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
4106 del_all_sta_info->assoc_sta = assoc_sta;
4107 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4110 PRINT_ER("wilc_mq_send fail\n");
4112 down(&hif_sema_wait_response);
4117 int wilc_edit_station(struct wilc_vif *vif,
4118 struct add_sta_param *sta_param)
4121 struct host_if_msg msg;
4122 struct add_sta_param *add_sta_info = &msg.body.add_sta_info;
4123 struct host_if_drv *hif_drv = vif->hif_drv;
4126 PRINT_ER("driver is null\n");
4130 memset(&msg, 0, sizeof(struct host_if_msg));
4132 msg.id = HOST_IF_MSG_EDIT_STATION;
4135 memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param));
4136 if (add_sta_info->rates_len > 0) {
4137 add_sta_info->rates = kmemdup(sta_param->rates,
4138 add_sta_info->rates_len,
4140 if (!add_sta_info->rates)
4144 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4146 PRINT_ER("wilc_mq_send fail\n");
4151 int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout)
4154 struct host_if_msg msg;
4155 struct power_mgmt_param *pwr_mgmt_info = &msg.body.pwr_mgmt_info;
4156 struct host_if_drv *hif_drv = vif->hif_drv;
4159 PRINT_ER("driver is null\n");
4163 if (wilc_wlan_get_num_conn_ifcs(vif->wilc) == 2 && enabled)
4166 memset(&msg, 0, sizeof(struct host_if_msg));
4168 msg.id = HOST_IF_MSG_POWER_MGMT;
4171 pwr_mgmt_info->enabled = enabled;
4172 pwr_mgmt_info->timeout = timeout;
4174 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4176 PRINT_ER("wilc_mq_send fail\n");
4180 int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled,
4184 struct host_if_msg msg;
4185 struct set_multicast *multicast_filter_param = &msg.body.multicast_info;
4186 struct host_if_drv *hif_drv = vif->hif_drv;
4189 PRINT_ER("driver is null\n");
4193 memset(&msg, 0, sizeof(struct host_if_msg));
4195 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
4198 multicast_filter_param->enabled = enabled;
4199 multicast_filter_param->cnt = count;
4201 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4203 PRINT_ER("wilc_mq_send fail\n");
4207 static void *host_int_ParseJoinBssParam(struct network_info *ptstrNetworkInfo)
4209 struct join_bss_param *pNewJoinBssParam = NULL;
4218 u8 pcipherTotalCount = 0;
4219 u8 authTotalCount = 0;
4222 pu8IEs = ptstrNetworkInfo->ies;
4223 u16IEsLen = ptstrNetworkInfo->ies_len;
4225 pNewJoinBssParam = kzalloc(sizeof(struct join_bss_param), GFP_KERNEL);
4226 if (pNewJoinBssParam) {
4227 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->dtim_period;
4228 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->beacon_period;
4229 pNewJoinBssParam->cap_info = ptstrNetworkInfo->cap_info;
4230 memcpy(pNewJoinBssParam->bssid, ptstrNetworkInfo->bssid, 6);
4231 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->ssid,
4232 ptstrNetworkInfo->ssid_len + 1);
4233 pNewJoinBssParam->ssid_len = ptstrNetworkInfo->ssid_len;
4234 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
4235 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
4237 while (index < u16IEsLen) {
4238 if (pu8IEs[index] == SUPP_RATES_IE) {
4239 suppRatesNo = pu8IEs[index + 1];
4240 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
4243 for (i = 0; i < suppRatesNo; i++)
4244 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
4246 index += suppRatesNo;
4248 } else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
4249 extSuppRatesNo = pu8IEs[index + 1];
4250 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
4251 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
4253 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
4255 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++)
4256 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
4258 index += extSuppRatesNo;
4260 } else if (pu8IEs[index] == HT_CAPABILITY_IE) {
4261 pNewJoinBssParam->ht_capable = true;
4262 index += pu8IEs[index + 1] + 2;
4264 } else if ((pu8IEs[index] == WMM_IE) &&
4265 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
4266 (pu8IEs[index + 4] == 0xF2) &&
4267 (pu8IEs[index + 5] == 0x02) &&
4268 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) &&
4269 (pu8IEs[index + 7] == 0x01)) {
4270 pNewJoinBssParam->wmm_cap = true;
4272 if (pu8IEs[index + 8] & BIT(7))
4273 pNewJoinBssParam->uapsd_cap = true;
4274 index += pu8IEs[index + 1] + 2;
4276 } else if ((pu8IEs[index] == P2P_IE) &&
4277 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
4278 (pu8IEs[index + 4] == 0x9a) &&
4279 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) {
4282 pNewJoinBssParam->tsf = ptstrNetworkInfo->tsf_lo;
4283 pNewJoinBssParam->noa_enabled = 1;
4284 pNewJoinBssParam->idx = pu8IEs[index + 9];
4286 if (pu8IEs[index + 10] & BIT(7)) {
4287 pNewJoinBssParam->opp_enabled = 1;
4288 pNewJoinBssParam->ct_window = pu8IEs[index + 10];
4290 pNewJoinBssParam->opp_enabled = 0;
4293 pNewJoinBssParam->cnt = pu8IEs[index + 11];
4294 u16P2P_count = index + 12;
4296 memcpy(pNewJoinBssParam->duration, pu8IEs + u16P2P_count, 4);
4299 memcpy(pNewJoinBssParam->interval, pu8IEs + u16P2P_count, 4);
4302 memcpy(pNewJoinBssParam->start_time, pu8IEs + u16P2P_count, 4);
4304 index += pu8IEs[index + 1] + 2;
4307 } else if ((pu8IEs[index] == RSN_IE) ||
4308 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
4309 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
4310 (pu8IEs[index + 5] == 0x01))) {
4311 u16 rsnIndex = index;
4313 if (pu8IEs[rsnIndex] == RSN_IE) {
4314 pNewJoinBssParam->mode_802_11i = 2;
4316 if (pNewJoinBssParam->mode_802_11i == 0)
4317 pNewJoinBssParam->mode_802_11i = 1;
4322 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
4324 jumpOffset = pu8IEs[rsnIndex] * 4;
4325 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
4328 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++)
4329 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
4331 pcipherTotalCount += pcipherCount;
4332 rsnIndex += jumpOffset;
4334 jumpOffset = pu8IEs[rsnIndex] * 4;
4336 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
4339 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++)
4340 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
4342 authTotalCount += authCount;
4343 rsnIndex += jumpOffset;
4345 if (pu8IEs[index] == RSN_IE) {
4346 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
4347 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
4350 pNewJoinBssParam->rsn_found = true;
4351 index += pu8IEs[index + 1] + 2;
4354 index += pu8IEs[index + 1] + 2;
4358 return (void *)pNewJoinBssParam;
4361 int wilc_setup_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx)
4364 struct host_if_msg msg;
4365 struct host_if_drv *hif_drv = vif->hif_drv;
4368 PRINT_ER("driver is null\n");
4372 memset(&msg, 0, sizeof(struct host_if_msg));
4374 msg.id = HOST_IF_MSG_SET_IPADDRESS;
4376 msg.body.ip_info.ip_addr = ip_addr;
4378 msg.body.ip_info.idx = idx;
4380 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4382 PRINT_ER("wilc_mq_send fail\n");
4387 static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx)
4390 struct host_if_msg msg;
4391 struct host_if_drv *hif_drv = vif->hif_drv;
4394 PRINT_ER("driver is null\n");
4398 memset(&msg, 0, sizeof(struct host_if_msg));
4400 msg.id = HOST_IF_MSG_GET_IPADDRESS;
4402 msg.body.ip_info.ip_addr = ip_addr;
4404 msg.body.ip_info.idx = idx;
4406 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4408 PRINT_ER("wilc_mq_send fail\n");
4413 int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power)
4416 struct host_if_msg msg;
4418 memset(&msg, 0, sizeof(struct host_if_msg));
4420 msg.id = HOST_IF_MSG_SET_TX_POWER;
4421 msg.body.tx_power.tx_pwr = tx_power;
4424 ret = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4426 netdev_err(vif->ndev, "wilc_mq_send fail\n");
4431 int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power)
4434 struct host_if_msg msg;
4436 memset(&msg, 0, sizeof(struct host_if_msg));
4438 msg.id = HOST_IF_MSG_GET_TX_POWER;
4441 ret = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4443 netdev_err(vif->ndev, "Failed to get TX PWR\n");
4445 down(&hif_sema_wait_response);
4446 *tx_power = msg.body.tx_power.tx_pwr;