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_ADD_BEACON 11
24 #define HOST_IF_MSG_DEL_BEACON 12
25 #define HOST_IF_MSG_ADD_STATION 13
26 #define HOST_IF_MSG_DEL_STATION 14
27 #define HOST_IF_MSG_EDIT_STATION 15
28 #define HOST_IF_MSG_SCAN_TIMER_FIRED 16
29 #define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
30 #define HOST_IF_MSG_POWER_MGMT 18
31 #define HOST_IF_MSG_GET_INACTIVETIME 19
32 #define HOST_IF_MSG_REMAIN_ON_CHAN 20
33 #define HOST_IF_MSG_REGISTER_FRAME 21
34 #define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
35 #define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
36 #define HOST_IF_MSG_GET_MAC_ADDRESS 26
37 #define HOST_IF_MSG_SET_OPERATION_MODE 27
38 #define HOST_IF_MSG_SET_IPADDRESS 28
39 #define HOST_IF_MSG_GET_IPADDRESS 29
40 #define HOST_IF_MSG_GET_STATISTICS 31
41 #define HOST_IF_MSG_SET_MULTICAST_FILTER 32
42 #define HOST_IF_MSG_DEL_BA_SESSION 34
43 #define HOST_IF_MSG_DEL_ALL_STA 36
44 #define HOST_IF_MSG_SET_TX_POWER 38
45 #define HOST_IF_MSG_GET_TX_POWER 39
46 #define HOST_IF_MSG_EXIT 100
48 #define HOST_IF_SCAN_TIMEOUT 4000
49 #define HOST_IF_CONNECT_TIMEOUT 9500
51 #define BA_SESSION_DEFAULT_BUFFER_SIZE 16
52 #define BA_SESSION_DEFAULT_TIMEOUT 1000
53 #define BLOCK_ACK_REQ_SIZE 0x14
54 #define FALSE_FRMWR_CHANNEL 100
56 #define TCP_ACK_FILTER_LINK_SPEED_THRESH 54
57 #define DEFAULT_LINK_SPEED 72
59 struct host_if_wpa_attr {
69 struct host_if_wep_attr {
74 enum AUTHTYPE auth_type;
77 union host_if_key_attr {
78 struct host_if_wep_attr wep;
79 struct host_if_wpa_attr wpa;
80 struct host_if_pmkid_attr pmkid;
86 union host_if_key_attr attr;
96 wilc_scan_result result;
98 struct hidden_network hidden_network;
101 struct connect_attr {
108 wilc_connect_result result;
110 enum AUTHTYPE auth_type;
115 struct rcvd_async_info {
120 struct channel_attr {
133 struct set_multicast {
139 u8 del_all_sta[MAX_NUM_STA][ETH_ALEN];
144 u8 mac_addr[ETH_ALEN];
147 struct power_mgmt_param {
157 struct sta_inactive_t {
166 struct scan_attr scan_info;
167 struct connect_attr con_info;
168 struct rcvd_net_info net_info;
169 struct rcvd_async_info async_info;
170 struct key_attr key_info;
171 struct cfg_param_attr cfg_info;
172 struct channel_attr channel_info;
173 struct beacon_attr beacon_info;
174 struct add_sta_param add_sta_info;
175 struct del_sta del_sta_info;
176 struct add_sta_param edit_sta_info;
177 struct power_mgmt_param pwr_mgmt_info;
178 struct sta_inactive_t mac_info;
179 struct set_ip_addr ip_info;
180 struct drv_handler drv;
181 struct set_multicast multicast_info;
183 struct set_mac_addr set_mac_info;
184 struct get_mac_addr get_mac_info;
185 struct ba_session_info session_info;
186 struct remain_ch remain_on_ch;
187 struct reg_frame reg_frame;
189 struct del_all_sta del_all_sta_info;
190 struct tx_power tx_power;
195 union message_body body;
196 struct wilc_vif *vif;
199 struct join_bss_param {
205 char ssid[MAX_SSID_LEN];
207 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
214 u8 rsn_pcip_policy[3];
215 u8 rsn_auth_policy[3];
228 static struct host_if_drv *terminated_handle;
229 bool wilc_optaining_ip;
230 static u8 P2P_LISTEN_STATE;
231 static struct task_struct *hif_thread_handler;
232 static struct message_queue hif_msg_q;
233 static struct semaphore hif_sema_thread;
234 static struct semaphore hif_sema_driver;
235 static struct semaphore hif_sema_wait_response;
236 static struct semaphore hif_sema_deinit;
237 static struct timer_list periodic_rssi;
239 u8 wilc_multicast_mac_addr_list[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
241 static u8 rcv_assoc_resp[MAX_ASSOC_RESP_FRAME_SIZE];
243 static bool scan_while_connected;
246 static u8 set_ip[2][4];
247 static u8 get_ip[2][4];
248 static u32 inactive_time;
249 static u8 del_beacon;
250 static u32 clients_count;
253 static u8 *info_element;
256 static u32 join_req_size;
257 static u32 info_element_size;
258 static struct wilc_vif *join_req_vif;
259 #define REAL_JOIN_REQ 0
260 #define FLUSHED_JOIN_REQ 1
261 #define FLUSHED_BYTE_POS 79
263 static void *host_int_ParseJoinBssParam(struct network_info *ptstrNetworkInfo);
264 static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx);
266 /* The u8IfIdx starts from 0 to NUM_CONCURRENT_IFC -1, but 0 index used as
267 * special purpose in wilc device, so we add 1 to the index to starts from 1.
268 * As a result, the returned index will be 1 to NUM_CONCURRENT_IFC.
270 int wilc_get_vif_idx(struct wilc_vif *vif)
275 /* We need to minus 1 from idx which is from wilc device to get real index
276 * of wilc->vif[], because we add 1 when pass to wilc device in the function
278 * As a result, the index should be between 0 and NUM_CONCURRENT_IFC -1.
280 static struct wilc_vif *wilc_get_vif_from_idx(struct wilc *wilc, int idx)
284 if (index < 0 || index >= NUM_CONCURRENT_IFC)
287 return wilc->vif[index];
290 static void handle_set_channel(struct wilc_vif *vif,
291 struct channel_attr *hif_set_ch)
296 wid.id = (u16)WID_CURRENT_CHANNEL;
298 wid.val = (char *)&hif_set_ch->set_ch;
299 wid.size = sizeof(char);
301 ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
302 wilc_get_vif_idx(vif));
305 netdev_err(vif->ndev, "Failed to set channel\n");
308 static s32 handle_set_wfi_drv_handler(struct wilc_vif *vif,
309 struct drv_handler *hif_drv_handler)
314 wid.id = (u16)WID_SET_DRV_HANDLER;
316 wid.val = (s8 *)hif_drv_handler;
317 wid.size = sizeof(*hif_drv_handler);
319 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
320 hif_drv_handler->handler);
322 if (!hif_drv_handler->handler)
323 up(&hif_sema_driver);
326 netdev_err(vif->ndev, "Failed to set driver handler\n");
333 static s32 handle_set_operation_mode(struct wilc_vif *vif,
334 struct op_mode *hif_op_mode)
339 wid.id = (u16)WID_SET_OPERATION_MODE;
341 wid.val = (s8 *)&hif_op_mode->mode;
342 wid.size = sizeof(u32);
344 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
345 wilc_get_vif_idx(vif));
347 if ((hif_op_mode->mode) == IDLE_MODE)
348 up(&hif_sema_driver);
351 netdev_err(vif->ndev, "Failed to set driver handler\n");
358 static s32 handle_set_ip_address(struct wilc_vif *vif, u8 *ip_addr, u8 idx)
362 char firmware_ip_addr[4] = {0};
364 if (ip_addr[0] < 192)
367 memcpy(set_ip[idx], ip_addr, IP_ALEN);
369 wid.id = (u16)WID_IP_ADDRESS;
371 wid.val = (u8 *)ip_addr;
374 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
375 wilc_get_vif_idx(vif));
377 host_int_get_ipaddress(vif, firmware_ip_addr, idx);
380 netdev_err(vif->ndev, "Failed to set IP address\n");
387 static s32 handle_get_ip_address(struct wilc_vif *vif, u8 idx)
392 wid.id = (u16)WID_IP_ADDRESS;
394 wid.val = kmalloc(IP_ALEN, GFP_KERNEL);
397 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
398 wilc_get_vif_idx(vif));
400 memcpy(get_ip[idx], wid.val, IP_ALEN);
404 if (memcmp(get_ip[idx], set_ip[idx], IP_ALEN) != 0)
405 wilc_setup_ipaddress(vif, set_ip[idx], idx);
408 netdev_err(vif->ndev, "Failed to get IP address\n");
415 static s32 handle_get_mac_address(struct wilc_vif *vif,
416 struct get_mac_addr *get_mac_addr)
421 wid.id = (u16)WID_MAC_ADDR;
423 wid.val = get_mac_addr->mac_addr;
426 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
427 wilc_get_vif_idx(vif));
430 netdev_err(vif->ndev, "Failed to get mac address\n");
433 up(&hif_sema_wait_response);
438 static s32 handle_cfg_param(struct wilc_vif *vif,
439 struct cfg_param_attr *cfg_param_attr)
442 struct wid wid_list[32];
443 struct host_if_drv *hif_drv = vif->hif_drv;
446 mutex_lock(&hif_drv->cfg_values_lock);
448 if (cfg_param_attr->flag & BSS_TYPE) {
449 if (cfg_param_attr->bss_type < 6) {
450 wid_list[i].id = WID_BSS_TYPE;
451 wid_list[i].val = (s8 *)&cfg_param_attr->bss_type;
452 wid_list[i].type = WID_CHAR;
453 wid_list[i].size = sizeof(char);
454 hif_drv->cfg_values.bss_type = (u8)cfg_param_attr->bss_type;
456 netdev_err(vif->ndev, "check value 6 over\n");
462 if (cfg_param_attr->flag & AUTH_TYPE) {
463 if (cfg_param_attr->auth_type == 1 ||
464 cfg_param_attr->auth_type == 2 ||
465 cfg_param_attr->auth_type == 5) {
466 wid_list[i].id = WID_AUTH_TYPE;
467 wid_list[i].val = (s8 *)&cfg_param_attr->auth_type;
468 wid_list[i].type = WID_CHAR;
469 wid_list[i].size = sizeof(char);
470 hif_drv->cfg_values.auth_type = (u8)cfg_param_attr->auth_type;
472 netdev_err(vif->ndev, "Impossible value\n");
478 if (cfg_param_attr->flag & AUTHEN_TIMEOUT) {
479 if (cfg_param_attr->auth_timeout > 0 &&
480 cfg_param_attr->auth_timeout < 65536) {
481 wid_list[i].id = WID_AUTH_TIMEOUT;
482 wid_list[i].val = (s8 *)&cfg_param_attr->auth_timeout;
483 wid_list[i].type = WID_SHORT;
484 wid_list[i].size = sizeof(u16);
485 hif_drv->cfg_values.auth_timeout = cfg_param_attr->auth_timeout;
487 netdev_err(vif->ndev, "Range(1 ~ 65535) over\n");
493 if (cfg_param_attr->flag & POWER_MANAGEMENT) {
494 if (cfg_param_attr->power_mgmt_mode < 5) {
495 wid_list[i].id = WID_POWER_MANAGEMENT;
496 wid_list[i].val = (s8 *)&cfg_param_attr->power_mgmt_mode;
497 wid_list[i].type = WID_CHAR;
498 wid_list[i].size = sizeof(char);
499 hif_drv->cfg_values.power_mgmt_mode = (u8)cfg_param_attr->power_mgmt_mode;
501 netdev_err(vif->ndev, "Invalid power mode\n");
507 if (cfg_param_attr->flag & RETRY_SHORT) {
508 if (cfg_param_attr->short_retry_limit > 0 &&
509 cfg_param_attr->short_retry_limit < 256) {
510 wid_list[i].id = WID_SHORT_RETRY_LIMIT;
511 wid_list[i].val = (s8 *)&cfg_param_attr->short_retry_limit;
512 wid_list[i].type = WID_SHORT;
513 wid_list[i].size = sizeof(u16);
514 hif_drv->cfg_values.short_retry_limit = cfg_param_attr->short_retry_limit;
516 netdev_err(vif->ndev, "Range(1~256) over\n");
522 if (cfg_param_attr->flag & RETRY_LONG) {
523 if (cfg_param_attr->long_retry_limit > 0 &&
524 cfg_param_attr->long_retry_limit < 256) {
525 wid_list[i].id = WID_LONG_RETRY_LIMIT;
526 wid_list[i].val = (s8 *)&cfg_param_attr->long_retry_limit;
527 wid_list[i].type = WID_SHORT;
528 wid_list[i].size = sizeof(u16);
529 hif_drv->cfg_values.long_retry_limit = cfg_param_attr->long_retry_limit;
531 netdev_err(vif->ndev, "Range(1~256) over\n");
537 if (cfg_param_attr->flag & FRAG_THRESHOLD) {
538 if (cfg_param_attr->frag_threshold > 255 &&
539 cfg_param_attr->frag_threshold < 7937) {
540 wid_list[i].id = WID_FRAG_THRESHOLD;
541 wid_list[i].val = (s8 *)&cfg_param_attr->frag_threshold;
542 wid_list[i].type = WID_SHORT;
543 wid_list[i].size = sizeof(u16);
544 hif_drv->cfg_values.frag_threshold = cfg_param_attr->frag_threshold;
546 netdev_err(vif->ndev, "Threshold Range fail\n");
552 if (cfg_param_attr->flag & RTS_THRESHOLD) {
553 if (cfg_param_attr->rts_threshold > 255 &&
554 cfg_param_attr->rts_threshold < 65536) {
555 wid_list[i].id = WID_RTS_THRESHOLD;
556 wid_list[i].val = (s8 *)&cfg_param_attr->rts_threshold;
557 wid_list[i].type = WID_SHORT;
558 wid_list[i].size = sizeof(u16);
559 hif_drv->cfg_values.rts_threshold = cfg_param_attr->rts_threshold;
561 netdev_err(vif->ndev, "Threshold Range fail\n");
567 if (cfg_param_attr->flag & PREAMBLE) {
568 if (cfg_param_attr->preamble_type < 3) {
569 wid_list[i].id = WID_PREAMBLE;
570 wid_list[i].val = (s8 *)&cfg_param_attr->preamble_type;
571 wid_list[i].type = WID_CHAR;
572 wid_list[i].size = sizeof(char);
573 hif_drv->cfg_values.preamble_type = cfg_param_attr->preamble_type;
575 netdev_err(vif->ndev, "Preamle Range(0~2) over\n");
581 if (cfg_param_attr->flag & SHORT_SLOT_ALLOWED) {
582 if (cfg_param_attr->short_slot_allowed < 2) {
583 wid_list[i].id = WID_SHORT_SLOT_ALLOWED;
584 wid_list[i].val = (s8 *)&cfg_param_attr->short_slot_allowed;
585 wid_list[i].type = WID_CHAR;
586 wid_list[i].size = sizeof(char);
587 hif_drv->cfg_values.short_slot_allowed = (u8)cfg_param_attr->short_slot_allowed;
589 netdev_err(vif->ndev, "Short slot(2) over\n");
595 if (cfg_param_attr->flag & TXOP_PROT_DISABLE) {
596 if (cfg_param_attr->txop_prot_disabled < 2) {
597 wid_list[i].id = WID_11N_TXOP_PROT_DISABLE;
598 wid_list[i].val = (s8 *)&cfg_param_attr->txop_prot_disabled;
599 wid_list[i].type = WID_CHAR;
600 wid_list[i].size = sizeof(char);
601 hif_drv->cfg_values.txop_prot_disabled = (u8)cfg_param_attr->txop_prot_disabled;
603 netdev_err(vif->ndev, "TXOP prot disable\n");
609 if (cfg_param_attr->flag & BEACON_INTERVAL) {
610 if (cfg_param_attr->beacon_interval > 0 &&
611 cfg_param_attr->beacon_interval < 65536) {
612 wid_list[i].id = WID_BEACON_INTERVAL;
613 wid_list[i].val = (s8 *)&cfg_param_attr->beacon_interval;
614 wid_list[i].type = WID_SHORT;
615 wid_list[i].size = sizeof(u16);
616 hif_drv->cfg_values.beacon_interval = cfg_param_attr->beacon_interval;
618 netdev_err(vif->ndev, "Beacon interval(1~65535)fail\n");
624 if (cfg_param_attr->flag & DTIM_PERIOD) {
625 if (cfg_param_attr->dtim_period > 0 &&
626 cfg_param_attr->dtim_period < 256) {
627 wid_list[i].id = WID_DTIM_PERIOD;
628 wid_list[i].val = (s8 *)&cfg_param_attr->dtim_period;
629 wid_list[i].type = WID_CHAR;
630 wid_list[i].size = sizeof(char);
631 hif_drv->cfg_values.dtim_period = cfg_param_attr->dtim_period;
633 netdev_err(vif->ndev, "DTIM range(1~255) fail\n");
639 if (cfg_param_attr->flag & SITE_SURVEY) {
640 if (cfg_param_attr->site_survey_enabled < 3) {
641 wid_list[i].id = WID_SITE_SURVEY;
642 wid_list[i].val = (s8 *)&cfg_param_attr->site_survey_enabled;
643 wid_list[i].type = WID_CHAR;
644 wid_list[i].size = sizeof(char);
645 hif_drv->cfg_values.site_survey_enabled = (u8)cfg_param_attr->site_survey_enabled;
647 netdev_err(vif->ndev, "Site survey disable\n");
653 if (cfg_param_attr->flag & SITE_SURVEY_SCAN_TIME) {
654 if (cfg_param_attr->site_survey_scan_time > 0 &&
655 cfg_param_attr->site_survey_scan_time < 65536) {
656 wid_list[i].id = WID_SITE_SURVEY_SCAN_TIME;
657 wid_list[i].val = (s8 *)&cfg_param_attr->site_survey_scan_time;
658 wid_list[i].type = WID_SHORT;
659 wid_list[i].size = sizeof(u16);
660 hif_drv->cfg_values.site_survey_scan_time = cfg_param_attr->site_survey_scan_time;
662 netdev_err(vif->ndev, "Site scan time(1~65535) over\n");
668 if (cfg_param_attr->flag & ACTIVE_SCANTIME) {
669 if (cfg_param_attr->active_scan_time > 0 &&
670 cfg_param_attr->active_scan_time < 65536) {
671 wid_list[i].id = WID_ACTIVE_SCAN_TIME;
672 wid_list[i].val = (s8 *)&cfg_param_attr->active_scan_time;
673 wid_list[i].type = WID_SHORT;
674 wid_list[i].size = sizeof(u16);
675 hif_drv->cfg_values.active_scan_time = cfg_param_attr->active_scan_time;
677 netdev_err(vif->ndev, "Active time(1~65535) over\n");
683 if (cfg_param_attr->flag & PASSIVE_SCANTIME) {
684 if (cfg_param_attr->passive_scan_time > 0 &&
685 cfg_param_attr->passive_scan_time < 65536) {
686 wid_list[i].id = WID_PASSIVE_SCAN_TIME;
687 wid_list[i].val = (s8 *)&cfg_param_attr->passive_scan_time;
688 wid_list[i].type = WID_SHORT;
689 wid_list[i].size = sizeof(u16);
690 hif_drv->cfg_values.passive_scan_time = cfg_param_attr->passive_scan_time;
692 netdev_err(vif->ndev, "Passive time(1~65535) over\n");
698 if (cfg_param_attr->flag & CURRENT_TX_RATE) {
699 enum CURRENT_TXRATE curr_tx_rate = cfg_param_attr->curr_tx_rate;
701 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1 ||
702 curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5 ||
703 curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6 ||
704 curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12 ||
705 curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24 ||
706 curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 ||
707 curr_tx_rate == MBPS_54) {
708 wid_list[i].id = WID_CURRENT_TX_RATE;
709 wid_list[i].val = (s8 *)&curr_tx_rate;
710 wid_list[i].type = WID_SHORT;
711 wid_list[i].size = sizeof(u16);
712 hif_drv->cfg_values.curr_tx_rate = (u8)curr_tx_rate;
714 netdev_err(vif->ndev, "out of TX rate\n");
721 result = wilc_send_config_pkt(vif, SET_CFG, wid_list,
722 i, wilc_get_vif_idx(vif));
725 netdev_err(vif->ndev, "Error in setting CFG params\n");
728 mutex_unlock(&hif_drv->cfg_values_lock);
732 static s32 Handle_ScanDone(struct wilc_vif *vif,
733 enum scan_event enuEvent);
735 static s32 Handle_Scan(struct wilc_vif *vif,
736 struct scan_attr *pstrHostIFscanAttr)
739 struct wid strWIDList[5];
740 u32 u32WidsCount = 0;
744 u8 *pu8HdnNtwrksWidVal = NULL;
745 struct host_if_drv *hif_drv = vif->hif_drv;
747 hif_drv->usr_scan_req.scan_result = pstrHostIFscanAttr->result;
748 hif_drv->usr_scan_req.arg = pstrHostIFscanAttr->arg;
750 if ((hif_drv->hif_state >= HOST_IF_SCANNING) &&
751 (hif_drv->hif_state < HOST_IF_CONNECTED)) {
752 netdev_err(vif->ndev, "Already scan\n");
757 if (wilc_optaining_ip || wilc_connecting) {
758 netdev_err(vif->ndev, "Don't do obss scan\n");
763 hif_drv->usr_scan_req.rcvd_ch_cnt = 0;
765 strWIDList[u32WidsCount].id = (u16)WID_SSID_PROBE_REQ;
766 strWIDList[u32WidsCount].type = WID_STR;
768 for (i = 0; i < pstrHostIFscanAttr->hidden_network.n_ssids; i++)
769 valuesize += ((pstrHostIFscanAttr->hidden_network.net_info[i].ssid_len) + 1);
770 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
771 strWIDList[u32WidsCount].val = pu8HdnNtwrksWidVal;
772 if (strWIDList[u32WidsCount].val) {
773 pu8Buffer = strWIDList[u32WidsCount].val;
775 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.n_ssids;
777 for (i = 0; i < pstrHostIFscanAttr->hidden_network.n_ssids; i++) {
778 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.net_info[i].ssid_len;
779 memcpy(pu8Buffer, pstrHostIFscanAttr->hidden_network.net_info[i].ssid, pstrHostIFscanAttr->hidden_network.net_info[i].ssid_len);
780 pu8Buffer += pstrHostIFscanAttr->hidden_network.net_info[i].ssid_len;
783 strWIDList[u32WidsCount].size = (s32)(valuesize + 1);
788 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_PROBE;
789 strWIDList[u32WidsCount].type = WID_BIN_DATA;
790 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ies;
791 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ies_len;
795 strWIDList[u32WidsCount].id = WID_SCAN_TYPE;
796 strWIDList[u32WidsCount].type = WID_CHAR;
797 strWIDList[u32WidsCount].size = sizeof(char);
798 strWIDList[u32WidsCount].val = (s8 *)&pstrHostIFscanAttr->type;
801 strWIDList[u32WidsCount].id = WID_SCAN_CHANNEL_LIST;
802 strWIDList[u32WidsCount].type = WID_BIN_DATA;
804 if (pstrHostIFscanAttr->ch_freq_list &&
805 pstrHostIFscanAttr->ch_list_len > 0) {
808 for (i = 0; i < pstrHostIFscanAttr->ch_list_len; i++) {
809 if (pstrHostIFscanAttr->ch_freq_list[i] > 0)
810 pstrHostIFscanAttr->ch_freq_list[i] = pstrHostIFscanAttr->ch_freq_list[i] - 1;
814 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ch_freq_list;
815 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ch_list_len;
818 strWIDList[u32WidsCount].id = WID_START_SCAN_REQ;
819 strWIDList[u32WidsCount].type = WID_CHAR;
820 strWIDList[u32WidsCount].size = sizeof(char);
821 strWIDList[u32WidsCount].val = (s8 *)&pstrHostIFscanAttr->src;
824 if (hif_drv->hif_state == HOST_IF_CONNECTED)
825 scan_while_connected = true;
826 else if (hif_drv->hif_state == HOST_IF_IDLE)
827 scan_while_connected = false;
829 result = wilc_send_config_pkt(vif, SET_CFG, strWIDList,
831 wilc_get_vif_idx(vif));
834 netdev_err(vif->ndev, "Failed to send scan parameters\n");
838 del_timer(&hif_drv->scan_timer);
839 Handle_ScanDone(vif, SCAN_EVENT_ABORTED);
842 kfree(pstrHostIFscanAttr->ch_freq_list);
843 pstrHostIFscanAttr->ch_freq_list = NULL;
845 kfree(pstrHostIFscanAttr->ies);
846 pstrHostIFscanAttr->ies = NULL;
847 kfree(pstrHostIFscanAttr->hidden_network.net_info);
848 pstrHostIFscanAttr->hidden_network.net_info = NULL;
850 kfree(pu8HdnNtwrksWidVal);
855 static s32 Handle_ScanDone(struct wilc_vif *vif,
856 enum scan_event enuEvent)
859 u8 u8abort_running_scan;
861 struct host_if_drv *hif_drv = vif->hif_drv;
863 if (enuEvent == SCAN_EVENT_ABORTED) {
864 u8abort_running_scan = 1;
865 wid.id = (u16)WID_ABORT_RUNNING_SCAN;
867 wid.val = (s8 *)&u8abort_running_scan;
868 wid.size = sizeof(char);
870 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
871 wilc_get_vif_idx(vif));
874 netdev_err(vif->ndev, "Failed to set abort running\n");
880 netdev_err(vif->ndev, "Driver handler is NULL\n");
884 if (hif_drv->usr_scan_req.scan_result) {
885 hif_drv->usr_scan_req.scan_result(enuEvent, NULL,
886 hif_drv->usr_scan_req.arg, NULL);
887 hif_drv->usr_scan_req.scan_result = NULL;
893 u8 wilc_connected_ssid[6] = {0};
894 static s32 Handle_Connect(struct wilc_vif *vif,
895 struct connect_attr *pstrHostIFconnectAttr)
898 struct wid strWIDList[8];
899 u32 u32WidsCount = 0, dummyval = 0;
900 u8 *pu8CurrByte = NULL;
901 struct join_bss_param *ptstrJoinBssParam;
902 struct host_if_drv *hif_drv = vif->hif_drv;
904 if (memcmp(pstrHostIFconnectAttr->bssid, wilc_connected_ssid, ETH_ALEN) == 0) {
906 netdev_err(vif->ndev, "Discard connect request\n");
910 ptstrJoinBssParam = pstrHostIFconnectAttr->params;
911 if (!ptstrJoinBssParam) {
912 netdev_err(vif->ndev, "Required BSSID not found\n");
917 if (pstrHostIFconnectAttr->bssid) {
918 hif_drv->usr_conn_req.bssid = kmalloc(6, GFP_KERNEL);
919 memcpy(hif_drv->usr_conn_req.bssid, pstrHostIFconnectAttr->bssid, 6);
922 hif_drv->usr_conn_req.ssid_len = pstrHostIFconnectAttr->ssid_len;
923 if (pstrHostIFconnectAttr->ssid) {
924 hif_drv->usr_conn_req.ssid = kmalloc(pstrHostIFconnectAttr->ssid_len + 1, GFP_KERNEL);
925 memcpy(hif_drv->usr_conn_req.ssid,
926 pstrHostIFconnectAttr->ssid,
927 pstrHostIFconnectAttr->ssid_len);
928 hif_drv->usr_conn_req.ssid[pstrHostIFconnectAttr->ssid_len] = '\0';
931 hif_drv->usr_conn_req.ies_len = pstrHostIFconnectAttr->ies_len;
932 if (pstrHostIFconnectAttr->ies) {
933 hif_drv->usr_conn_req.ies = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
934 memcpy(hif_drv->usr_conn_req.ies,
935 pstrHostIFconnectAttr->ies,
936 pstrHostIFconnectAttr->ies_len);
939 hif_drv->usr_conn_req.security = pstrHostIFconnectAttr->security;
940 hif_drv->usr_conn_req.auth_type = pstrHostIFconnectAttr->auth_type;
941 hif_drv->usr_conn_req.conn_result = pstrHostIFconnectAttr->result;
942 hif_drv->usr_conn_req.arg = pstrHostIFconnectAttr->arg;
944 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
945 strWIDList[u32WidsCount].type = WID_INT;
946 strWIDList[u32WidsCount].size = sizeof(u32);
947 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
950 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
951 strWIDList[u32WidsCount].type = WID_INT;
952 strWIDList[u32WidsCount].size = sizeof(u32);
953 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
956 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
957 strWIDList[u32WidsCount].type = WID_INT;
958 strWIDList[u32WidsCount].size = sizeof(u32);
959 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
963 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
964 strWIDList[u32WidsCount].type = WID_BIN_DATA;
965 strWIDList[u32WidsCount].val = hif_drv->usr_conn_req.ies;
966 strWIDList[u32WidsCount].size = hif_drv->usr_conn_req.ies_len;
969 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
970 info_element_size = hif_drv->usr_conn_req.ies_len;
971 info_element = kmalloc(info_element_size, GFP_KERNEL);
972 memcpy(info_element, hif_drv->usr_conn_req.ies,
976 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
977 strWIDList[u32WidsCount].type = WID_CHAR;
978 strWIDList[u32WidsCount].size = sizeof(char);
979 strWIDList[u32WidsCount].val = (s8 *)&hif_drv->usr_conn_req.security;
982 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
983 mode_11i = hif_drv->usr_conn_req.security;
985 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
986 strWIDList[u32WidsCount].type = WID_CHAR;
987 strWIDList[u32WidsCount].size = sizeof(char);
988 strWIDList[u32WidsCount].val = (s8 *)&hif_drv->usr_conn_req.auth_type;
991 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
992 auth_type = (u8)hif_drv->usr_conn_req.auth_type;
994 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
995 strWIDList[u32WidsCount].type = WID_STR;
996 strWIDList[u32WidsCount].size = 112;
997 strWIDList[u32WidsCount].val = kmalloc(strWIDList[u32WidsCount].size, GFP_KERNEL);
999 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1000 join_req_size = strWIDList[u32WidsCount].size;
1001 join_req = kmalloc(join_req_size, GFP_KERNEL);
1003 if (!strWIDList[u32WidsCount].val) {
1008 pu8CurrByte = strWIDList[u32WidsCount].val;
1010 if (pstrHostIFconnectAttr->ssid) {
1011 memcpy(pu8CurrByte, pstrHostIFconnectAttr->ssid, pstrHostIFconnectAttr->ssid_len);
1012 pu8CurrByte[pstrHostIFconnectAttr->ssid_len] = '\0';
1014 pu8CurrByte += MAX_SSID_LEN;
1015 *(pu8CurrByte++) = INFRASTRUCTURE;
1017 if ((pstrHostIFconnectAttr->ch >= 1) && (pstrHostIFconnectAttr->ch <= 14)) {
1018 *(pu8CurrByte++) = pstrHostIFconnectAttr->ch;
1020 netdev_err(vif->ndev, "Channel out of range\n");
1021 *(pu8CurrByte++) = 0xFF;
1023 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1024 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1026 if (pstrHostIFconnectAttr->bssid)
1027 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
1030 if (pstrHostIFconnectAttr->bssid)
1031 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
1034 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1035 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1036 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1038 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
1039 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1041 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1042 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1044 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1045 hif_drv->usr_conn_req.ht_capable = ptstrJoinBssParam->ht_capable;
1047 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1048 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1049 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1051 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
1052 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1054 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
1055 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1057 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
1058 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1060 *(pu8CurrByte++) = REAL_JOIN_REQ;
1061 *(pu8CurrByte++) = ptstrJoinBssParam->noa_enabled;
1063 if (ptstrJoinBssParam->noa_enabled) {
1064 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1065 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1066 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1067 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1069 *(pu8CurrByte++) = ptstrJoinBssParam->opp_enabled;
1070 *(pu8CurrByte++) = ptstrJoinBssParam->idx;
1072 if (ptstrJoinBssParam->opp_enabled)
1073 *(pu8CurrByte++) = ptstrJoinBssParam->ct_window;
1075 *(pu8CurrByte++) = ptstrJoinBssParam->cnt;
1077 memcpy(pu8CurrByte, ptstrJoinBssParam->duration, sizeof(ptstrJoinBssParam->duration));
1078 pu8CurrByte += sizeof(ptstrJoinBssParam->duration);
1080 memcpy(pu8CurrByte, ptstrJoinBssParam->interval, sizeof(ptstrJoinBssParam->interval));
1081 pu8CurrByte += sizeof(ptstrJoinBssParam->interval);
1083 memcpy(pu8CurrByte, ptstrJoinBssParam->start_time, sizeof(ptstrJoinBssParam->start_time));
1084 pu8CurrByte += sizeof(ptstrJoinBssParam->start_time);
1087 pu8CurrByte = strWIDList[u32WidsCount].val;
1090 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1091 memcpy(join_req, pu8CurrByte, join_req_size);
1095 if (pstrHostIFconnectAttr->bssid)
1096 memcpy(wilc_connected_ssid,
1097 pstrHostIFconnectAttr->bssid, ETH_ALEN);
1099 result = wilc_send_config_pkt(vif, SET_CFG, strWIDList,
1101 wilc_get_vif_idx(vif));
1103 netdev_err(vif->ndev, "failed to send config packet\n");
1107 hif_drv->hif_state = HOST_IF_WAITING_CONN_RESP;
1112 struct connect_info strConnectInfo;
1114 del_timer(&hif_drv->connect_timer);
1116 memset(&strConnectInfo, 0, sizeof(struct connect_info));
1118 if (pstrHostIFconnectAttr->result) {
1119 if (pstrHostIFconnectAttr->bssid)
1120 memcpy(strConnectInfo.bssid, pstrHostIFconnectAttr->bssid, 6);
1122 if (pstrHostIFconnectAttr->ies) {
1123 strConnectInfo.req_ies_len = pstrHostIFconnectAttr->ies_len;
1124 strConnectInfo.req_ies = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
1125 memcpy(strConnectInfo.req_ies,
1126 pstrHostIFconnectAttr->ies,
1127 pstrHostIFconnectAttr->ies_len);
1130 pstrHostIFconnectAttr->result(CONN_DISCONN_EVENT_CONN_RESP,
1134 pstrHostIFconnectAttr->arg);
1135 hif_drv->hif_state = HOST_IF_IDLE;
1136 kfree(strConnectInfo.req_ies);
1137 strConnectInfo.req_ies = NULL;
1140 netdev_err(vif->ndev, "Connect callback is NULL\n");
1144 kfree(pstrHostIFconnectAttr->bssid);
1145 pstrHostIFconnectAttr->bssid = NULL;
1147 kfree(pstrHostIFconnectAttr->ssid);
1148 pstrHostIFconnectAttr->ssid = NULL;
1150 kfree(pstrHostIFconnectAttr->ies);
1151 pstrHostIFconnectAttr->ies = NULL;
1157 static s32 Handle_ConnectTimeout(struct wilc_vif *vif)
1160 struct connect_info strConnectInfo;
1162 u16 u16DummyReasonCode = 0;
1163 struct host_if_drv *hif_drv = vif->hif_drv;
1166 netdev_err(vif->ndev, "Driver handler is NULL\n");
1170 hif_drv->hif_state = HOST_IF_IDLE;
1172 scan_while_connected = false;
1174 memset(&strConnectInfo, 0, sizeof(struct connect_info));
1176 if (hif_drv->usr_conn_req.conn_result) {
1177 if (hif_drv->usr_conn_req.bssid) {
1178 memcpy(strConnectInfo.bssid,
1179 hif_drv->usr_conn_req.bssid, 6);
1182 if (hif_drv->usr_conn_req.ies) {
1183 strConnectInfo.req_ies_len = hif_drv->usr_conn_req.ies_len;
1184 strConnectInfo.req_ies = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL);
1185 memcpy(strConnectInfo.req_ies,
1186 hif_drv->usr_conn_req.ies,
1187 hif_drv->usr_conn_req.ies_len);
1190 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
1194 hif_drv->usr_conn_req.arg);
1196 kfree(strConnectInfo.req_ies);
1197 strConnectInfo.req_ies = NULL;
1199 netdev_err(vif->ndev, "Connect callback is NULL\n");
1202 wid.id = (u16)WID_DISCONNECT;
1203 wid.type = WID_CHAR;
1204 wid.val = (s8 *)&u16DummyReasonCode;
1205 wid.size = sizeof(char);
1207 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
1208 wilc_get_vif_idx(vif));
1210 netdev_err(vif->ndev, "Failed to send dissconect\n");
1212 hif_drv->usr_conn_req.ssid_len = 0;
1213 kfree(hif_drv->usr_conn_req.ssid);
1214 hif_drv->usr_conn_req.ssid = NULL;
1215 kfree(hif_drv->usr_conn_req.bssid);
1216 hif_drv->usr_conn_req.bssid = NULL;
1217 hif_drv->usr_conn_req.ies_len = 0;
1218 kfree(hif_drv->usr_conn_req.ies);
1219 hif_drv->usr_conn_req.ies = NULL;
1221 eth_zero_addr(wilc_connected_ssid);
1223 if (join_req && join_req_vif == vif) {
1228 if (info_element && join_req_vif == vif) {
1229 kfree(info_element);
1230 info_element = NULL;
1236 static s32 Handle_RcvdNtwrkInfo(struct wilc_vif *vif,
1237 struct rcvd_net_info *pstrRcvdNetworkInfo)
1240 bool bNewNtwrkFound;
1242 struct network_info *pstrNetworkInfo = NULL;
1243 void *pJoinParams = NULL;
1244 struct host_if_drv *hif_drv = vif->hif_drv;
1246 bNewNtwrkFound = true;
1248 if (hif_drv->usr_scan_req.scan_result) {
1249 wilc_parse_network_info(pstrRcvdNetworkInfo->buffer, &pstrNetworkInfo);
1250 if ((!pstrNetworkInfo) ||
1251 (!hif_drv->usr_scan_req.scan_result)) {
1252 netdev_err(vif->ndev, "driver is null\n");
1257 for (i = 0; i < hif_drv->usr_scan_req.rcvd_ch_cnt; i++) {
1258 if ((hif_drv->usr_scan_req.net_info[i].bssid) &&
1259 (pstrNetworkInfo->bssid)) {
1260 if (memcmp(hif_drv->usr_scan_req.net_info[i].bssid,
1261 pstrNetworkInfo->bssid, 6) == 0) {
1262 if (pstrNetworkInfo->rssi <= hif_drv->usr_scan_req.net_info[i].rssi) {
1265 hif_drv->usr_scan_req.net_info[i].rssi = pstrNetworkInfo->rssi;
1266 bNewNtwrkFound = false;
1273 if (bNewNtwrkFound) {
1274 if (hif_drv->usr_scan_req.rcvd_ch_cnt < MAX_NUM_SCANNED_NETWORKS) {
1275 hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].rssi = pstrNetworkInfo->rssi;
1277 if (hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].bssid &&
1278 pstrNetworkInfo->bssid) {
1279 memcpy(hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].bssid,
1280 pstrNetworkInfo->bssid, 6);
1282 hif_drv->usr_scan_req.rcvd_ch_cnt++;
1284 pstrNetworkInfo->new_network = true;
1285 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
1287 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1288 hif_drv->usr_scan_req.arg,
1293 pstrNetworkInfo->new_network = false;
1294 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1295 hif_drv->usr_scan_req.arg, NULL);
1300 kfree(pstrRcvdNetworkInfo->buffer);
1301 pstrRcvdNetworkInfo->buffer = NULL;
1303 if (pstrNetworkInfo) {
1304 kfree(pstrNetworkInfo->ies);
1305 kfree(pstrNetworkInfo);
1311 static s32 host_int_get_assoc_res_info(struct wilc_vif *vif,
1312 u8 *pu8AssocRespInfo,
1313 u32 u32MaxAssocRespInfoLen,
1314 u32 *pu32RcvdAssocRespInfoLen);
1316 static s32 Handle_RcvdGnrlAsyncInfo(struct wilc_vif *vif,
1317 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
1323 u16 u16WidID = (u16)WID_NIL;
1326 u8 u8MacStatusReasonCode;
1327 u8 u8MacStatusAdditionalInfo;
1328 struct connect_info strConnectInfo;
1329 struct disconnect_info strDisconnectNotifInfo;
1331 struct host_if_drv *hif_drv = vif->hif_drv;
1334 netdev_err(vif->ndev, "Driver handler is NULL\n");
1338 if ((hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) ||
1339 (hif_drv->hif_state == HOST_IF_CONNECTED) ||
1340 hif_drv->usr_scan_req.scan_result) {
1341 if (!pstrRcvdGnrlAsyncInfo->buffer ||
1342 !hif_drv->usr_conn_req.conn_result) {
1343 netdev_err(vif->ndev, "driver is null\n");
1347 u8MsgType = pstrRcvdGnrlAsyncInfo->buffer[0];
1349 if ('I' != u8MsgType) {
1350 netdev_err(vif->ndev, "Received Message incorrect.\n");
1354 u8MsgID = pstrRcvdGnrlAsyncInfo->buffer[1];
1355 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[2], pstrRcvdGnrlAsyncInfo->buffer[3]);
1356 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[4], pstrRcvdGnrlAsyncInfo->buffer[5]);
1357 u8WidLen = pstrRcvdGnrlAsyncInfo->buffer[6];
1358 u8MacStatus = pstrRcvdGnrlAsyncInfo->buffer[7];
1359 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->buffer[8];
1360 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->buffer[9];
1361 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
1362 u32 u32RcvdAssocRespInfoLen = 0;
1363 struct connect_resp_info *pstrConnectRespInfo = NULL;
1365 memset(&strConnectInfo, 0, sizeof(struct connect_info));
1367 if (u8MacStatus == MAC_CONNECTED) {
1368 memset(rcv_assoc_resp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
1370 host_int_get_assoc_res_info(vif,
1372 MAX_ASSOC_RESP_FRAME_SIZE,
1373 &u32RcvdAssocRespInfoLen);
1375 if (u32RcvdAssocRespInfoLen != 0) {
1376 s32Err = wilc_parse_assoc_resp_info(rcv_assoc_resp, u32RcvdAssocRespInfoLen,
1377 &pstrConnectRespInfo);
1379 netdev_err(vif->ndev, "wilc_parse_assoc_resp_info() returned error %d\n", s32Err);
1381 strConnectInfo.status = pstrConnectRespInfo->status;
1383 if (strConnectInfo.status == SUCCESSFUL_STATUSCODE) {
1384 if (pstrConnectRespInfo->ies) {
1385 strConnectInfo.resp_ies_len = pstrConnectRespInfo->ies_len;
1386 strConnectInfo.resp_ies = kmalloc(pstrConnectRespInfo->ies_len, GFP_KERNEL);
1387 memcpy(strConnectInfo.resp_ies, pstrConnectRespInfo->ies,
1388 pstrConnectRespInfo->ies_len);
1392 if (pstrConnectRespInfo) {
1393 kfree(pstrConnectRespInfo->ies);
1394 kfree(pstrConnectRespInfo);
1400 if ((u8MacStatus == MAC_CONNECTED) &&
1401 (strConnectInfo.status != SUCCESSFUL_STATUSCODE)) {
1402 netdev_err(vif->ndev, "Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
1403 eth_zero_addr(wilc_connected_ssid);
1404 } else if (u8MacStatus == MAC_DISCONNECTED) {
1405 netdev_err(vif->ndev, "Received MAC status is MAC_DISCONNECTED\n");
1406 eth_zero_addr(wilc_connected_ssid);
1409 if (hif_drv->usr_conn_req.bssid) {
1410 memcpy(strConnectInfo.bssid, hif_drv->usr_conn_req.bssid, 6);
1412 if ((u8MacStatus == MAC_CONNECTED) &&
1413 (strConnectInfo.status == SUCCESSFUL_STATUSCODE)) {
1414 memcpy(hif_drv->assoc_bssid,
1415 hif_drv->usr_conn_req.bssid, ETH_ALEN);
1419 if (hif_drv->usr_conn_req.ies) {
1420 strConnectInfo.req_ies_len = hif_drv->usr_conn_req.ies_len;
1421 strConnectInfo.req_ies = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL);
1422 memcpy(strConnectInfo.req_ies,
1423 hif_drv->usr_conn_req.ies,
1424 hif_drv->usr_conn_req.ies_len);
1427 del_timer(&hif_drv->connect_timer);
1428 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
1432 hif_drv->usr_conn_req.arg);
1434 if ((u8MacStatus == MAC_CONNECTED) &&
1435 (strConnectInfo.status == SUCCESSFUL_STATUSCODE)) {
1436 wilc_set_power_mgmt(vif, 0, 0);
1438 hif_drv->hif_state = HOST_IF_CONNECTED;
1440 wilc_optaining_ip = true;
1441 mod_timer(&wilc_during_ip_timer,
1442 jiffies + msecs_to_jiffies(10000));
1444 hif_drv->hif_state = HOST_IF_IDLE;
1445 scan_while_connected = false;
1448 kfree(strConnectInfo.resp_ies);
1449 strConnectInfo.resp_ies = NULL;
1451 kfree(strConnectInfo.req_ies);
1452 strConnectInfo.req_ies = NULL;
1453 hif_drv->usr_conn_req.ssid_len = 0;
1454 kfree(hif_drv->usr_conn_req.ssid);
1455 hif_drv->usr_conn_req.ssid = NULL;
1456 kfree(hif_drv->usr_conn_req.bssid);
1457 hif_drv->usr_conn_req.bssid = NULL;
1458 hif_drv->usr_conn_req.ies_len = 0;
1459 kfree(hif_drv->usr_conn_req.ies);
1460 hif_drv->usr_conn_req.ies = NULL;
1461 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
1462 (hif_drv->hif_state == HOST_IF_CONNECTED)) {
1463 memset(&strDisconnectNotifInfo, 0, sizeof(struct disconnect_info));
1465 if (hif_drv->usr_scan_req.scan_result) {
1466 del_timer(&hif_drv->scan_timer);
1467 Handle_ScanDone(vif, SCAN_EVENT_ABORTED);
1470 strDisconnectNotifInfo.reason = 0;
1471 strDisconnectNotifInfo.ie = NULL;
1472 strDisconnectNotifInfo.ie_len = 0;
1474 if (hif_drv->usr_conn_req.conn_result) {
1475 wilc_optaining_ip = false;
1476 wilc_set_power_mgmt(vif, 0, 0);
1478 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1481 &strDisconnectNotifInfo,
1482 hif_drv->usr_conn_req.arg);
1484 netdev_err(vif->ndev, "Connect result NULL\n");
1487 eth_zero_addr(hif_drv->assoc_bssid);
1489 hif_drv->usr_conn_req.ssid_len = 0;
1490 kfree(hif_drv->usr_conn_req.ssid);
1491 hif_drv->usr_conn_req.ssid = NULL;
1492 kfree(hif_drv->usr_conn_req.bssid);
1493 hif_drv->usr_conn_req.bssid = NULL;
1494 hif_drv->usr_conn_req.ies_len = 0;
1495 kfree(hif_drv->usr_conn_req.ies);
1496 hif_drv->usr_conn_req.ies = NULL;
1498 if (join_req && join_req_vif == vif) {
1503 if (info_element && join_req_vif == vif) {
1504 kfree(info_element);
1505 info_element = NULL;
1508 hif_drv->hif_state = HOST_IF_IDLE;
1509 scan_while_connected = false;
1511 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
1512 (hif_drv->usr_scan_req.scan_result)) {
1513 del_timer(&hif_drv->scan_timer);
1514 if (hif_drv->usr_scan_req.scan_result)
1515 Handle_ScanDone(vif, SCAN_EVENT_ABORTED);
1519 kfree(pstrRcvdGnrlAsyncInfo->buffer);
1520 pstrRcvdGnrlAsyncInfo->buffer = NULL;
1525 static int Handle_Key(struct wilc_vif *vif,
1526 struct key_attr *pstrHostIFkeyAttr)
1530 struct wid strWIDList[5];
1535 struct host_if_drv *hif_drv = vif->hif_drv;
1537 switch (pstrHostIFkeyAttr->type) {
1540 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1541 strWIDList[0].id = (u16)WID_11I_MODE;
1542 strWIDList[0].type = WID_CHAR;
1543 strWIDList[0].size = sizeof(char);
1544 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.mode;
1546 strWIDList[1].id = WID_AUTH_TYPE;
1547 strWIDList[1].type = WID_CHAR;
1548 strWIDList[1].size = sizeof(char);
1549 strWIDList[1].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.auth_type;
1551 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2,
1556 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1557 pu8keybuf[1] = pstrHostIFkeyAttr->attr.wep.key_len;
1559 memcpy(&pu8keybuf[2], pstrHostIFkeyAttr->attr.wep.key,
1560 pstrHostIFkeyAttr->attr.wep.key_len);
1562 kfree(pstrHostIFkeyAttr->attr.wep.key);
1564 strWIDList[2].id = (u16)WID_WEP_KEY_VALUE;
1565 strWIDList[2].type = WID_STR;
1566 strWIDList[2].size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
1567 strWIDList[2].val = (s8 *)pu8keybuf;
1569 result = wilc_send_config_pkt(vif, SET_CFG,
1571 wilc_get_vif_idx(vif));
1573 } else if (pstrHostIFkeyAttr->action & ADDKEY) {
1574 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2, GFP_KERNEL);
1577 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1578 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->attr.wep.key_len, 1);
1579 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->attr.wep.key,
1580 pstrHostIFkeyAttr->attr.wep.key_len);
1581 kfree(pstrHostIFkeyAttr->attr.wep.key);
1583 wid.id = (u16)WID_ADD_WEP_KEY;
1585 wid.val = (s8 *)pu8keybuf;
1586 wid.size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
1588 result = wilc_send_config_pkt(vif, SET_CFG,
1590 wilc_get_vif_idx(vif));
1592 } else if (pstrHostIFkeyAttr->action & REMOVEKEY) {
1593 wid.id = (u16)WID_REMOVE_WEP_KEY;
1596 s8idxarray[0] = (s8)pstrHostIFkeyAttr->attr.wep.index;
1597 wid.val = s8idxarray;
1600 result = wilc_send_config_pkt(vif, SET_CFG,
1602 wilc_get_vif_idx(vif));
1603 } else if (pstrHostIFkeyAttr->action & DEFAULTKEY) {
1604 wid.id = (u16)WID_KEY_ID;
1605 wid.type = WID_CHAR;
1606 wid.val = (s8 *)&pstrHostIFkeyAttr->attr.wep.index;
1607 wid.size = sizeof(char);
1609 result = wilc_send_config_pkt(vif, SET_CFG,
1611 wilc_get_vif_idx(vif));
1613 up(&hif_drv->sem_test_key_block);
1617 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1618 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1621 goto _WPARxGtk_end_case_;
1624 if (pstrHostIFkeyAttr->attr.wpa.seq)
1625 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1627 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1628 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1629 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1630 pstrHostIFkeyAttr->attr.wpa.key_len);
1632 strWIDList[0].id = (u16)WID_11I_MODE;
1633 strWIDList[0].type = WID_CHAR;
1634 strWIDList[0].size = sizeof(char);
1635 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode;
1637 strWIDList[1].id = (u16)WID_ADD_RX_GTK;
1638 strWIDList[1].type = WID_STR;
1639 strWIDList[1].val = (s8 *)pu8keybuf;
1640 strWIDList[1].size = RX_MIC_KEY_MSG_LEN;
1642 result = wilc_send_config_pkt(vif, SET_CFG,
1644 wilc_get_vif_idx(vif));
1647 up(&hif_drv->sem_test_key_block);
1648 } else if (pstrHostIFkeyAttr->action & ADDKEY) {
1649 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1650 if (pu8keybuf == NULL) {
1652 goto _WPARxGtk_end_case_;
1655 if (hif_drv->hif_state == HOST_IF_CONNECTED)
1656 memcpy(pu8keybuf, hif_drv->assoc_bssid, ETH_ALEN);
1658 netdev_err(vif->ndev, "Couldn't handle\n");
1660 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1661 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1662 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1663 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1664 pstrHostIFkeyAttr->attr.wpa.key_len);
1666 wid.id = (u16)WID_ADD_RX_GTK;
1668 wid.val = (s8 *)pu8keybuf;
1669 wid.size = RX_MIC_KEY_MSG_LEN;
1671 result = wilc_send_config_pkt(vif, SET_CFG,
1673 wilc_get_vif_idx(vif));
1676 up(&hif_drv->sem_test_key_block);
1678 _WPARxGtk_end_case_:
1679 kfree(pstrHostIFkeyAttr->attr.wpa.key);
1680 kfree(pstrHostIFkeyAttr->attr.wpa.seq);
1687 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1688 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
1691 goto _WPAPtk_end_case_;
1694 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1695 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1696 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1697 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->attr.wpa.key,
1698 pstrHostIFkeyAttr->attr.wpa.key_len);
1700 strWIDList[0].id = (u16)WID_11I_MODE;
1701 strWIDList[0].type = WID_CHAR;
1702 strWIDList[0].size = sizeof(char);
1703 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode;
1705 strWIDList[1].id = (u16)WID_ADD_PTK;
1706 strWIDList[1].type = WID_STR;
1707 strWIDList[1].val = (s8 *)pu8keybuf;
1708 strWIDList[1].size = PTK_KEY_MSG_LEN + 1;
1710 result = wilc_send_config_pkt(vif, SET_CFG,
1712 wilc_get_vif_idx(vif));
1714 up(&hif_drv->sem_test_key_block);
1715 } else if (pstrHostIFkeyAttr->action & ADDKEY) {
1716 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
1718 netdev_err(vif->ndev, "No buffer send PTK\n");
1720 goto _WPAPtk_end_case_;
1723 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1724 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1725 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->attr.wpa.key,
1726 pstrHostIFkeyAttr->attr.wpa.key_len);
1728 wid.id = (u16)WID_ADD_PTK;
1730 wid.val = (s8 *)pu8keybuf;
1731 wid.size = PTK_KEY_MSG_LEN;
1733 result = wilc_send_config_pkt(vif, SET_CFG,
1735 wilc_get_vif_idx(vif));
1737 up(&hif_drv->sem_test_key_block);
1741 kfree(pstrHostIFkeyAttr->attr.wpa.key);
1748 pu8keybuf = kmalloc((pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
1750 netdev_err(vif->ndev, "No buffer to send PMKSA Key\n");
1754 pu8keybuf[0] = pstrHostIFkeyAttr->attr.pmkid.numpmkid;
1756 for (i = 0; i < pstrHostIFkeyAttr->attr.pmkid.numpmkid; i++) {
1757 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
1758 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
1761 wid.id = (u16)WID_PMKID_INFO;
1763 wid.val = (s8 *)pu8keybuf;
1764 wid.size = (pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
1766 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
1767 wilc_get_vif_idx(vif));
1774 netdev_err(vif->ndev, "Failed to send key config packet\n");
1779 static void Handle_Disconnect(struct wilc_vif *vif)
1782 struct host_if_drv *hif_drv = vif->hif_drv;
1785 u16 u16DummyReasonCode = 0;
1787 wid.id = (u16)WID_DISCONNECT;
1788 wid.type = WID_CHAR;
1789 wid.val = (s8 *)&u16DummyReasonCode;
1790 wid.size = sizeof(char);
1792 wilc_optaining_ip = false;
1793 wilc_set_power_mgmt(vif, 0, 0);
1795 eth_zero_addr(wilc_connected_ssid);
1797 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
1798 wilc_get_vif_idx(vif));
1801 netdev_err(vif->ndev, "Failed to send dissconect\n");
1803 struct disconnect_info strDisconnectNotifInfo;
1805 memset(&strDisconnectNotifInfo, 0, sizeof(struct disconnect_info));
1807 strDisconnectNotifInfo.reason = 0;
1808 strDisconnectNotifInfo.ie = NULL;
1809 strDisconnectNotifInfo.ie_len = 0;
1811 if (hif_drv->usr_scan_req.scan_result) {
1812 del_timer(&hif_drv->scan_timer);
1813 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED,
1815 hif_drv->usr_scan_req.arg,
1817 hif_drv->usr_scan_req.scan_result = NULL;
1820 if (hif_drv->usr_conn_req.conn_result) {
1821 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP)
1822 del_timer(&hif_drv->connect_timer);
1824 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1827 &strDisconnectNotifInfo,
1828 hif_drv->usr_conn_req.arg);
1830 netdev_err(vif->ndev, "conn_result = NULL\n");
1833 scan_while_connected = false;
1835 hif_drv->hif_state = HOST_IF_IDLE;
1837 eth_zero_addr(hif_drv->assoc_bssid);
1839 hif_drv->usr_conn_req.ssid_len = 0;
1840 kfree(hif_drv->usr_conn_req.ssid);
1841 hif_drv->usr_conn_req.ssid = NULL;
1842 kfree(hif_drv->usr_conn_req.bssid);
1843 hif_drv->usr_conn_req.bssid = NULL;
1844 hif_drv->usr_conn_req.ies_len = 0;
1845 kfree(hif_drv->usr_conn_req.ies);
1846 hif_drv->usr_conn_req.ies = NULL;
1848 if (join_req && join_req_vif == vif) {
1853 if (info_element && join_req_vif == vif) {
1854 kfree(info_element);
1855 info_element = NULL;
1859 up(&hif_drv->sem_test_disconn_block);
1862 void wilc_resolve_disconnect_aberration(struct wilc_vif *vif)
1866 if ((vif->hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) ||
1867 (vif->hif_drv->hif_state == HOST_IF_CONNECTING))
1868 wilc_disconnect(vif, 1);
1871 static void Handle_GetRssi(struct wilc_vif *vif)
1876 wid.id = (u16)WID_RSSI;
1877 wid.type = WID_CHAR;
1879 wid.size = sizeof(char);
1881 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
1882 wilc_get_vif_idx(vif));
1884 netdev_err(vif->ndev, "Failed to get RSSI value\n");
1888 up(&vif->hif_drv->sem_get_rssi);
1891 static s32 Handle_GetStatistics(struct wilc_vif *vif,
1892 struct rf_info *pstrStatistics)
1894 struct wid strWIDList[5];
1895 u32 u32WidsCount = 0, result = 0;
1897 strWIDList[u32WidsCount].id = WID_LINKSPEED;
1898 strWIDList[u32WidsCount].type = WID_CHAR;
1899 strWIDList[u32WidsCount].size = sizeof(char);
1900 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->link_speed;
1903 strWIDList[u32WidsCount].id = WID_RSSI;
1904 strWIDList[u32WidsCount].type = WID_CHAR;
1905 strWIDList[u32WidsCount].size = sizeof(char);
1906 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->rssi;
1909 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
1910 strWIDList[u32WidsCount].type = WID_INT;
1911 strWIDList[u32WidsCount].size = sizeof(u32);
1912 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_cnt;
1915 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
1916 strWIDList[u32WidsCount].type = WID_INT;
1917 strWIDList[u32WidsCount].size = sizeof(u32);
1918 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->rx_cnt;
1921 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
1922 strWIDList[u32WidsCount].type = WID_INT;
1923 strWIDList[u32WidsCount].size = sizeof(u32);
1924 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_fail_cnt;
1927 result = wilc_send_config_pkt(vif, GET_CFG, strWIDList,
1929 wilc_get_vif_idx(vif));
1932 netdev_err(vif->ndev, "Failed to send scan parameters\n");
1934 if (pstrStatistics->link_speed > TCP_ACK_FILTER_LINK_SPEED_THRESH &&
1935 pstrStatistics->link_speed != DEFAULT_LINK_SPEED)
1936 wilc_enable_tcp_ack_filter(true);
1937 else if (pstrStatistics->link_speed != DEFAULT_LINK_SPEED)
1938 wilc_enable_tcp_ack_filter(false);
1940 if (pstrStatistics != &vif->wilc->dummy_statistics)
1941 up(&hif_sema_wait_response);
1945 static s32 Handle_Get_InActiveTime(struct wilc_vif *vif,
1946 struct sta_inactive_t *strHostIfStaInactiveT)
1951 struct host_if_drv *hif_drv = vif->hif_drv;
1953 wid.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
1955 wid.size = ETH_ALEN;
1956 wid.val = kmalloc(wid.size, GFP_KERNEL);
1959 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
1961 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
1962 wilc_get_vif_idx(vif));
1965 netdev_err(vif->ndev, "Failed to SET incative time\n");
1969 wid.id = (u16)WID_GET_INACTIVE_TIME;
1971 wid.val = (s8 *)&inactive_time;
1972 wid.size = sizeof(u32);
1974 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
1975 wilc_get_vif_idx(vif));
1978 netdev_err(vif->ndev, "Failed to get incative time\n");
1982 up(&hif_drv->sem_inactive_time);
1987 static void Handle_AddBeacon(struct wilc_vif *vif,
1988 struct beacon_attr *pstrSetBeaconParam)
1994 wid.id = (u16)WID_ADD_BEACON;
1996 wid.size = pstrSetBeaconParam->head_len + pstrSetBeaconParam->tail_len + 16;
1997 wid.val = kmalloc(wid.size, GFP_KERNEL);
2001 pu8CurrByte = wid.val;
2002 *pu8CurrByte++ = (pstrSetBeaconParam->interval & 0xFF);
2003 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 8) & 0xFF);
2004 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 16) & 0xFF);
2005 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 24) & 0xFF);
2007 *pu8CurrByte++ = (pstrSetBeaconParam->dtim_period & 0xFF);
2008 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 8) & 0xFF);
2009 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 16) & 0xFF);
2010 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 24) & 0xFF);
2012 *pu8CurrByte++ = (pstrSetBeaconParam->head_len & 0xFF);
2013 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 8) & 0xFF);
2014 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 16) & 0xFF);
2015 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 24) & 0xFF);
2017 memcpy(pu8CurrByte, pstrSetBeaconParam->head, pstrSetBeaconParam->head_len);
2018 pu8CurrByte += pstrSetBeaconParam->head_len;
2020 *pu8CurrByte++ = (pstrSetBeaconParam->tail_len & 0xFF);
2021 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 8) & 0xFF);
2022 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 16) & 0xFF);
2023 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 24) & 0xFF);
2025 if (pstrSetBeaconParam->tail)
2026 memcpy(pu8CurrByte, pstrSetBeaconParam->tail, pstrSetBeaconParam->tail_len);
2027 pu8CurrByte += pstrSetBeaconParam->tail_len;
2029 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2030 wilc_get_vif_idx(vif));
2032 netdev_err(vif->ndev, "Failed to send add beacon\n");
2036 kfree(pstrSetBeaconParam->head);
2037 kfree(pstrSetBeaconParam->tail);
2040 static void Handle_DelBeacon(struct wilc_vif *vif)
2046 wid.id = (u16)WID_DEL_BEACON;
2047 wid.type = WID_CHAR;
2048 wid.size = sizeof(char);
2049 wid.val = &del_beacon;
2054 pu8CurrByte = wid.val;
2056 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2057 wilc_get_vif_idx(vif));
2059 netdev_err(vif->ndev, "Failed to send delete beacon\n");
2062 static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
2063 struct add_sta_param *pstrStationParam)
2067 pu8CurrByte = pu8Buffer;
2069 memcpy(pu8CurrByte, pstrStationParam->bssid, ETH_ALEN);
2070 pu8CurrByte += ETH_ALEN;
2072 *pu8CurrByte++ = pstrStationParam->aid & 0xFF;
2073 *pu8CurrByte++ = (pstrStationParam->aid >> 8) & 0xFF;
2075 *pu8CurrByte++ = pstrStationParam->rates_len;
2076 if (pstrStationParam->rates_len > 0)
2077 memcpy(pu8CurrByte, pstrStationParam->rates,
2078 pstrStationParam->rates_len);
2079 pu8CurrByte += pstrStationParam->rates_len;
2081 *pu8CurrByte++ = pstrStationParam->ht_supported;
2082 *pu8CurrByte++ = pstrStationParam->ht_capa_info & 0xFF;
2083 *pu8CurrByte++ = (pstrStationParam->ht_capa_info >> 8) & 0xFF;
2085 *pu8CurrByte++ = pstrStationParam->ht_ampdu_params;
2086 memcpy(pu8CurrByte, pstrStationParam->ht_supp_mcs_set,
2087 WILC_SUPP_MCS_SET_SIZE);
2088 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
2090 *pu8CurrByte++ = pstrStationParam->ht_ext_params & 0xFF;
2091 *pu8CurrByte++ = (pstrStationParam->ht_ext_params >> 8) & 0xFF;
2093 *pu8CurrByte++ = pstrStationParam->ht_tx_bf_cap & 0xFF;
2094 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 8) & 0xFF;
2095 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 16) & 0xFF;
2096 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 24) & 0xFF;
2098 *pu8CurrByte++ = pstrStationParam->ht_ante_sel;
2100 *pu8CurrByte++ = pstrStationParam->flags_mask & 0xFF;
2101 *pu8CurrByte++ = (pstrStationParam->flags_mask >> 8) & 0xFF;
2103 *pu8CurrByte++ = pstrStationParam->flags_set & 0xFF;
2104 *pu8CurrByte++ = (pstrStationParam->flags_set >> 8) & 0xFF;
2106 return pu8CurrByte - pu8Buffer;
2109 static void Handle_AddStation(struct wilc_vif *vif,
2110 struct add_sta_param *pstrStationParam)
2116 wid.id = (u16)WID_ADD_STA;
2118 wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->rates_len;
2120 wid.val = kmalloc(wid.size, GFP_KERNEL);
2124 pu8CurrByte = wid.val;
2125 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2127 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2128 wilc_get_vif_idx(vif));
2130 netdev_err(vif->ndev, "Failed to send add station\n");
2133 kfree(pstrStationParam->rates);
2137 static void Handle_DelAllSta(struct wilc_vif *vif,
2138 struct del_all_sta *pstrDelAllStaParam)
2144 u8 au8Zero_Buff[6] = {0};
2146 wid.id = (u16)WID_DEL_ALL_STA;
2148 wid.size = (pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1;
2150 wid.val = kmalloc((pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1, GFP_KERNEL);
2154 pu8CurrByte = wid.val;
2156 *(pu8CurrByte++) = pstrDelAllStaParam->assoc_sta;
2158 for (i = 0; i < MAX_NUM_STA; i++) {
2159 if (memcmp(pstrDelAllStaParam->del_all_sta[i], au8Zero_Buff, ETH_ALEN))
2160 memcpy(pu8CurrByte, pstrDelAllStaParam->del_all_sta[i], ETH_ALEN);
2164 pu8CurrByte += ETH_ALEN;
2167 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2168 wilc_get_vif_idx(vif));
2170 netdev_err(vif->ndev, "Failed to send add station\n");
2175 up(&hif_sema_wait_response);
2178 static void Handle_DelStation(struct wilc_vif *vif,
2179 struct del_sta *pstrDelStaParam)
2185 wid.id = (u16)WID_REMOVE_STA;
2187 wid.size = ETH_ALEN;
2189 wid.val = kmalloc(wid.size, GFP_KERNEL);
2193 pu8CurrByte = wid.val;
2195 memcpy(pu8CurrByte, pstrDelStaParam->mac_addr, ETH_ALEN);
2197 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2198 wilc_get_vif_idx(vif));
2200 netdev_err(vif->ndev, "Failed to send add station\n");
2206 static void Handle_EditStation(struct wilc_vif *vif,
2207 struct add_sta_param *pstrStationParam)
2213 wid.id = (u16)WID_EDIT_STA;
2215 wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->rates_len;
2217 wid.val = kmalloc(wid.size, GFP_KERNEL);
2221 pu8CurrByte = wid.val;
2222 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2224 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2225 wilc_get_vif_idx(vif));
2227 netdev_err(vif->ndev, "Failed to send edit station\n");
2230 kfree(pstrStationParam->rates);
2234 static int Handle_RemainOnChan(struct wilc_vif *vif,
2235 struct remain_ch *pstrHostIfRemainOnChan)
2238 u8 u8remain_on_chan_flag;
2240 struct host_if_drv *hif_drv = vif->hif_drv;
2242 if (!hif_drv->remain_on_ch_pending) {
2243 hif_drv->remain_on_ch.arg = pstrHostIfRemainOnChan->arg;
2244 hif_drv->remain_on_ch.expired = pstrHostIfRemainOnChan->expired;
2245 hif_drv->remain_on_ch.ready = pstrHostIfRemainOnChan->ready;
2246 hif_drv->remain_on_ch.ch = pstrHostIfRemainOnChan->ch;
2247 hif_drv->remain_on_ch.id = pstrHostIfRemainOnChan->id;
2249 pstrHostIfRemainOnChan->ch = hif_drv->remain_on_ch.ch;
2252 if (hif_drv->usr_scan_req.scan_result) {
2253 hif_drv->remain_on_ch_pending = 1;
2257 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
2262 if (wilc_optaining_ip || wilc_connecting) {
2267 u8remain_on_chan_flag = true;
2268 wid.id = (u16)WID_REMAIN_ON_CHAN;
2271 wid.val = kmalloc(wid.size, GFP_KERNEL);
2277 wid.val[0] = u8remain_on_chan_flag;
2278 wid.val[1] = (s8)pstrHostIfRemainOnChan->ch;
2280 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2281 wilc_get_vif_idx(vif));
2283 netdev_err(vif->ndev, "Failed to set remain on channel\n");
2287 P2P_LISTEN_STATE = 1;
2288 hif_drv->remain_on_ch_timer.data = (unsigned long)vif;
2289 mod_timer(&hif_drv->remain_on_ch_timer,
2291 msecs_to_jiffies(pstrHostIfRemainOnChan->duration));
2293 if (hif_drv->remain_on_ch.ready)
2294 hif_drv->remain_on_ch.ready(hif_drv->remain_on_ch.arg);
2296 if (hif_drv->remain_on_ch_pending)
2297 hif_drv->remain_on_ch_pending = 0;
2303 static int Handle_RegisterFrame(struct wilc_vif *vif,
2304 struct reg_frame *pstrHostIfRegisterFrame)
2310 wid.id = (u16)WID_REGISTER_FRAME;
2312 wid.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
2316 pu8CurrByte = wid.val;
2318 *pu8CurrByte++ = pstrHostIfRegisterFrame->reg;
2319 *pu8CurrByte++ = pstrHostIfRegisterFrame->reg_id;
2320 memcpy(pu8CurrByte, &pstrHostIfRegisterFrame->frame_type, sizeof(u16));
2322 wid.size = sizeof(u16) + 2;
2324 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2325 wilc_get_vif_idx(vif));
2327 netdev_err(vif->ndev, "Failed to frame register\n");
2334 static u32 Handle_ListenStateExpired(struct wilc_vif *vif,
2335 struct remain_ch *pstrHostIfRemainOnChan)
2337 u8 u8remain_on_chan_flag;
2340 struct host_if_drv *hif_drv = vif->hif_drv;
2342 if (P2P_LISTEN_STATE) {
2343 u8remain_on_chan_flag = false;
2344 wid.id = (u16)WID_REMAIN_ON_CHAN;
2347 wid.val = kmalloc(wid.size, GFP_KERNEL);
2350 netdev_err(vif->ndev, "Failed to allocate memory\n");
2354 wid.val[0] = u8remain_on_chan_flag;
2355 wid.val[1] = FALSE_FRMWR_CHANNEL;
2357 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2358 wilc_get_vif_idx(vif));
2360 netdev_err(vif->ndev, "Failed to set remain channel\n");
2364 if (hif_drv->remain_on_ch.expired) {
2365 hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.arg,
2366 pstrHostIfRemainOnChan->id);
2368 P2P_LISTEN_STATE = 0;
2370 netdev_dbg(vif->ndev, "Not in listen state\n");
2378 static void ListenTimerCB(unsigned long arg)
2381 struct host_if_msg msg;
2382 struct wilc_vif *vif = (struct wilc_vif *)arg;
2384 del_timer(&vif->hif_drv->remain_on_ch_timer);
2386 memset(&msg, 0, sizeof(struct host_if_msg));
2387 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
2389 msg.body.remain_on_ch.id = vif->hif_drv->remain_on_ch.id;
2391 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2393 netdev_err(vif->ndev, "wilc_mq_send fail\n");
2396 static void Handle_PowerManagement(struct wilc_vif *vif,
2397 struct power_mgmt_param *strPowerMgmtParam)
2403 wid.id = (u16)WID_POWER_MANAGEMENT;
2405 if (strPowerMgmtParam->enabled)
2406 s8PowerMode = MIN_FAST_PS;
2408 s8PowerMode = NO_POWERSAVE;
2410 wid.val = &s8PowerMode;
2411 wid.size = sizeof(char);
2413 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2414 wilc_get_vif_idx(vif));
2416 netdev_err(vif->ndev, "Failed to send power management\n");
2419 static void Handle_SetMulticastFilter(struct wilc_vif *vif,
2420 struct set_multicast *strHostIfSetMulti)
2426 wid.id = (u16)WID_SETUP_MULTICAST_FILTER;
2428 wid.size = sizeof(struct set_multicast) + ((strHostIfSetMulti->cnt) * ETH_ALEN);
2429 wid.val = kmalloc(wid.size, GFP_KERNEL);
2433 pu8CurrByte = wid.val;
2434 *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF);
2439 *pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF);
2440 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF);
2441 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 16) & 0xFF);
2442 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 24) & 0xFF);
2444 if ((strHostIfSetMulti->cnt) > 0)
2445 memcpy(pu8CurrByte, wilc_multicast_mac_addr_list,
2446 ((strHostIfSetMulti->cnt) * ETH_ALEN));
2448 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2449 wilc_get_vif_idx(vif));
2451 netdev_err(vif->ndev, "Failed to send setup multicast\n");
2457 static void handle_set_tx_pwr(struct wilc_vif *vif, u8 tx_pwr)
2462 wid.id = (u16)WID_TX_POWER;
2463 wid.type = WID_CHAR;
2465 wid.size = sizeof(char);
2467 ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2468 wilc_get_vif_idx(vif));
2470 netdev_err(vif->ndev, "Failed to set TX PWR\n");
2473 static void handle_get_tx_pwr(struct wilc_vif *vif, u8 *tx_pwr)
2478 wid.id = (u16)WID_TX_POWER;
2479 wid.type = WID_CHAR;
2480 wid.val = (s8 *)tx_pwr;
2481 wid.size = sizeof(char);
2483 ret = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
2484 wilc_get_vif_idx(vif));
2486 netdev_err(vif->ndev, "Failed to get TX PWR\n");
2488 up(&hif_sema_wait_response);
2491 static int hostIFthread(void *pvArg)
2494 struct host_if_msg msg;
2495 struct wilc *wilc = pvArg;
2496 struct wilc_vif *vif;
2498 memset(&msg, 0, sizeof(struct host_if_msg));
2501 wilc_mq_recv(&hif_msg_q, &msg, sizeof(struct host_if_msg), &u32Ret);
2503 if (msg.id == HOST_IF_MSG_EXIT)
2506 if ((!wilc_initialized)) {
2507 usleep_range(200 * 1000, 200 * 1000);
2508 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2512 if (msg.id == HOST_IF_MSG_CONNECT &&
2513 vif->hif_drv->usr_scan_req.scan_result) {
2514 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2515 usleep_range(2 * 1000, 2 * 1000);
2520 case HOST_IF_MSG_SCAN:
2521 Handle_Scan(msg.vif, &msg.body.scan_info);
2524 case HOST_IF_MSG_CONNECT:
2525 Handle_Connect(msg.vif, &msg.body.con_info);
2528 case HOST_IF_MSG_RCVD_NTWRK_INFO:
2529 Handle_RcvdNtwrkInfo(msg.vif, &msg.body.net_info);
2532 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
2533 Handle_RcvdGnrlAsyncInfo(vif,
2534 &msg.body.async_info);
2537 case HOST_IF_MSG_KEY:
2538 Handle_Key(msg.vif, &msg.body.key_info);
2541 case HOST_IF_MSG_CFG_PARAMS:
2542 handle_cfg_param(msg.vif, &msg.body.cfg_info);
2545 case HOST_IF_MSG_SET_CHANNEL:
2546 handle_set_channel(msg.vif, &msg.body.channel_info);
2549 case HOST_IF_MSG_DISCONNECT:
2550 Handle_Disconnect(msg.vif);
2553 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
2554 del_timer(&vif->hif_drv->scan_timer);
2556 if (!wilc_wlan_get_num_conn_ifcs(wilc))
2557 wilc_chip_sleep_manually(wilc);
2559 Handle_ScanDone(msg.vif, SCAN_EVENT_DONE);
2561 if (vif->hif_drv->remain_on_ch_pending)
2562 Handle_RemainOnChan(msg.vif,
2563 &msg.body.remain_on_ch);
2567 case HOST_IF_MSG_GET_RSSI:
2568 Handle_GetRssi(msg.vif);
2571 case HOST_IF_MSG_GET_STATISTICS:
2572 Handle_GetStatistics(msg.vif,
2573 (struct rf_info *)msg.body.data);
2576 case HOST_IF_MSG_ADD_BEACON:
2577 Handle_AddBeacon(msg.vif, &msg.body.beacon_info);
2580 case HOST_IF_MSG_DEL_BEACON:
2581 Handle_DelBeacon(msg.vif);
2584 case HOST_IF_MSG_ADD_STATION:
2585 Handle_AddStation(msg.vif, &msg.body.add_sta_info);
2588 case HOST_IF_MSG_DEL_STATION:
2589 Handle_DelStation(msg.vif, &msg.body.del_sta_info);
2592 case HOST_IF_MSG_EDIT_STATION:
2593 Handle_EditStation(msg.vif, &msg.body.edit_sta_info);
2596 case HOST_IF_MSG_GET_INACTIVETIME:
2597 Handle_Get_InActiveTime(msg.vif, &msg.body.mac_info);
2600 case HOST_IF_MSG_SCAN_TIMER_FIRED:
2602 Handle_ScanDone(msg.vif, SCAN_EVENT_ABORTED);
2605 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
2606 Handle_ConnectTimeout(msg.vif);
2609 case HOST_IF_MSG_POWER_MGMT:
2610 Handle_PowerManagement(msg.vif,
2611 &msg.body.pwr_mgmt_info);
2614 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
2615 handle_set_wfi_drv_handler(msg.vif, &msg.body.drv);
2618 case HOST_IF_MSG_SET_OPERATION_MODE:
2619 handle_set_operation_mode(msg.vif, &msg.body.mode);
2622 case HOST_IF_MSG_SET_IPADDRESS:
2623 handle_set_ip_address(vif,
2624 msg.body.ip_info.ip_addr,
2625 msg.body.ip_info.idx);
2628 case HOST_IF_MSG_GET_IPADDRESS:
2629 handle_get_ip_address(vif, msg.body.ip_info.idx);
2632 case HOST_IF_MSG_GET_MAC_ADDRESS:
2633 handle_get_mac_address(msg.vif,
2634 &msg.body.get_mac_info);
2637 case HOST_IF_MSG_REMAIN_ON_CHAN:
2638 Handle_RemainOnChan(msg.vif, &msg.body.remain_on_ch);
2641 case HOST_IF_MSG_REGISTER_FRAME:
2642 Handle_RegisterFrame(msg.vif, &msg.body.reg_frame);
2645 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
2646 Handle_ListenStateExpired(msg.vif, &msg.body.remain_on_ch);
2649 case HOST_IF_MSG_SET_MULTICAST_FILTER:
2650 Handle_SetMulticastFilter(msg.vif, &msg.body.multicast_info);
2653 case HOST_IF_MSG_DEL_ALL_STA:
2654 Handle_DelAllSta(msg.vif, &msg.body.del_all_sta_info);
2657 case HOST_IF_MSG_SET_TX_POWER:
2658 handle_set_tx_pwr(msg.vif, msg.body.tx_power.tx_pwr);
2661 case HOST_IF_MSG_GET_TX_POWER:
2662 handle_get_tx_pwr(msg.vif, &msg.body.tx_power.tx_pwr);
2665 netdev_err(vif->ndev, "[Host Interface] undefined\n");
2670 up(&hif_sema_thread);
2674 static void TimerCB_Scan(unsigned long arg)
2676 struct wilc_vif *vif = (struct wilc_vif *)arg;
2677 struct host_if_msg msg;
2679 memset(&msg, 0, sizeof(struct host_if_msg));
2681 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
2683 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2686 static void TimerCB_Connect(unsigned long arg)
2688 struct wilc_vif *vif = (struct wilc_vif *)arg;
2689 struct host_if_msg msg;
2691 memset(&msg, 0, sizeof(struct host_if_msg));
2693 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
2695 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2698 s32 wilc_remove_key(struct host_if_drv *hif_drv, const u8 *pu8StaAddress)
2702 wid.id = (u16)WID_REMOVE_KEY;
2704 wid.val = (s8 *)pu8StaAddress;
2710 int wilc_remove_wep_key(struct wilc_vif *vif, u8 index)
2713 struct host_if_msg msg;
2714 struct host_if_drv *hif_drv = vif->hif_drv;
2718 netdev_err(vif->ndev, "Failed to send setup multicast\n");
2722 memset(&msg, 0, sizeof(struct host_if_msg));
2724 msg.id = HOST_IF_MSG_KEY;
2725 msg.body.key_info.type = WEP;
2726 msg.body.key_info.action = REMOVEKEY;
2728 msg.body.key_info.attr.wep.index = index;
2730 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2732 netdev_err(vif->ndev, "Request to remove WEP key\n");
2733 down(&hif_drv->sem_test_key_block);
2738 int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index)
2741 struct host_if_msg msg;
2742 struct host_if_drv *hif_drv = vif->hif_drv;
2746 netdev_err(vif->ndev, "driver is null\n");
2750 memset(&msg, 0, sizeof(struct host_if_msg));
2752 msg.id = HOST_IF_MSG_KEY;
2753 msg.body.key_info.type = WEP;
2754 msg.body.key_info.action = DEFAULTKEY;
2756 msg.body.key_info.attr.wep.index = index;
2758 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2760 netdev_err(vif->ndev, "Default key index\n");
2761 down(&hif_drv->sem_test_key_block);
2766 int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len,
2770 struct host_if_msg msg;
2771 struct host_if_drv *hif_drv = vif->hif_drv;
2774 netdev_err(vif->ndev, "driver is null\n");
2778 memset(&msg, 0, sizeof(struct host_if_msg));
2780 msg.id = HOST_IF_MSG_KEY;
2781 msg.body.key_info.type = WEP;
2782 msg.body.key_info.action = ADDKEY;
2784 msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
2785 if (!msg.body.key_info.attr.wep.key)
2788 msg.body.key_info.attr.wep.key_len = len;
2789 msg.body.key_info.attr.wep.index = index;
2791 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2793 netdev_err(vif->ndev, "STA - WEP Key\n");
2794 down(&hif_drv->sem_test_key_block);
2799 int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len,
2800 u8 index, u8 mode, enum AUTHTYPE auth_type)
2803 struct host_if_msg msg;
2804 struct host_if_drv *hif_drv = vif->hif_drv;
2807 netdev_err(vif->ndev, "driver is null\n");
2811 memset(&msg, 0, sizeof(struct host_if_msg));
2813 msg.id = HOST_IF_MSG_KEY;
2814 msg.body.key_info.type = WEP;
2815 msg.body.key_info.action = ADDKEY_AP;
2817 msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
2818 if (!msg.body.key_info.attr.wep.key)
2821 msg.body.key_info.attr.wep.key_len = len;
2822 msg.body.key_info.attr.wep.index = index;
2823 msg.body.key_info.attr.wep.mode = mode;
2824 msg.body.key_info.attr.wep.auth_type = auth_type;
2826 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2829 netdev_err(vif->ndev, "AP - WEP Key\n");
2830 down(&hif_drv->sem_test_key_block);
2835 int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
2836 const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
2837 u8 mode, u8 cipher_mode, u8 index)
2840 struct host_if_msg msg;
2841 struct host_if_drv *hif_drv = vif->hif_drv;
2842 u8 key_len = ptk_key_len;
2845 netdev_err(vif->ndev, "driver is null\n");
2850 key_len += RX_MIC_KEY_LEN;
2853 key_len += TX_MIC_KEY_LEN;
2855 memset(&msg, 0, sizeof(struct host_if_msg));
2857 msg.id = HOST_IF_MSG_KEY;
2858 msg.body.key_info.type = WPA_PTK;
2859 if (mode == AP_MODE) {
2860 msg.body.key_info.action = ADDKEY_AP;
2861 msg.body.key_info.attr.wpa.index = index;
2863 if (mode == STATION_MODE)
2864 msg.body.key_info.action = ADDKEY;
2866 msg.body.key_info.attr.wpa.key = kmemdup(ptk, ptk_key_len, GFP_KERNEL);
2867 if (!msg.body.key_info.attr.wpa.key)
2871 memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic, RX_MIC_KEY_LEN);
2874 memcpy(msg.body.key_info.attr.wpa.key + 24, tx_mic, TX_MIC_KEY_LEN);
2876 msg.body.key_info.attr.wpa.key_len = key_len;
2877 msg.body.key_info.attr.wpa.mac_addr = mac_addr;
2878 msg.body.key_info.attr.wpa.mode = cipher_mode;
2881 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2884 netdev_err(vif->ndev, "PTK Key\n");
2886 down(&hif_drv->sem_test_key_block);
2891 int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
2892 u8 index, u32 key_rsc_len, const u8 *key_rsc,
2893 const u8 *rx_mic, const u8 *tx_mic, u8 mode,
2897 struct host_if_msg msg;
2898 struct host_if_drv *hif_drv = vif->hif_drv;
2899 u8 key_len = gtk_key_len;
2902 netdev_err(vif->ndev, "driver is null\n");
2905 memset(&msg, 0, sizeof(struct host_if_msg));
2908 key_len += RX_MIC_KEY_LEN;
2911 key_len += TX_MIC_KEY_LEN;
2914 msg.body.key_info.attr.wpa.seq = kmemdup(key_rsc,
2917 if (!msg.body.key_info.attr.wpa.seq)
2921 msg.id = HOST_IF_MSG_KEY;
2922 msg.body.key_info.type = WPA_RX_GTK;
2925 if (mode == AP_MODE) {
2926 msg.body.key_info.action = ADDKEY_AP;
2927 msg.body.key_info.attr.wpa.mode = cipher_mode;
2929 if (mode == STATION_MODE)
2930 msg.body.key_info.action = ADDKEY;
2932 msg.body.key_info.attr.wpa.key = kmemdup(rx_gtk,
2935 if (!msg.body.key_info.attr.wpa.key)
2939 memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic,
2943 memcpy(msg.body.key_info.attr.wpa.key + 24, tx_mic,
2946 msg.body.key_info.attr.wpa.index = index;
2947 msg.body.key_info.attr.wpa.key_len = key_len;
2948 msg.body.key_info.attr.wpa.seq_len = key_rsc_len;
2950 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2952 netdev_err(vif->ndev, "RX GTK\n");
2954 down(&hif_drv->sem_test_key_block);
2959 int wilc_set_pmkid_info(struct wilc_vif *vif,
2960 struct host_if_pmkid_attr *pmkid)
2963 struct host_if_msg msg;
2964 struct host_if_drv *hif_drv = vif->hif_drv;
2968 netdev_err(vif->ndev, "driver is null\n");
2972 memset(&msg, 0, sizeof(struct host_if_msg));
2974 msg.id = HOST_IF_MSG_KEY;
2975 msg.body.key_info.type = PMKSA;
2976 msg.body.key_info.action = ADDKEY;
2979 for (i = 0; i < pmkid->numpmkid; i++) {
2980 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].bssid,
2981 &pmkid->pmkidlist[i].bssid, ETH_ALEN);
2982 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].pmkid,
2983 &pmkid->pmkidlist[i].pmkid, PMKID_LEN);
2986 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2988 netdev_err(vif->ndev, "PMKID Info\n");
2993 int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr)
2996 struct host_if_msg msg;
2998 memset(&msg, 0, sizeof(struct host_if_msg));
3000 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
3001 msg.body.get_mac_info.mac_addr = mac_addr;
3004 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3006 netdev_err(vif->ndev, "Failed to send get mac address\n");
3010 down(&hif_sema_wait_response);
3014 int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid,
3015 size_t ssid_len, const u8 *ies, size_t ies_len,
3016 wilc_connect_result connect_result, void *user_arg,
3017 u8 security, enum AUTHTYPE auth_type,
3018 u8 channel, void *join_params)
3021 struct host_if_msg msg;
3022 struct host_if_drv *hif_drv = vif->hif_drv;
3024 if (!hif_drv || !connect_result) {
3025 netdev_err(vif->ndev, "Driver is null\n");
3030 netdev_err(vif->ndev, "Unable to Join - JoinParams is NULL\n");
3034 memset(&msg, 0, sizeof(struct host_if_msg));
3036 msg.id = HOST_IF_MSG_CONNECT;
3038 msg.body.con_info.security = security;
3039 msg.body.con_info.auth_type = auth_type;
3040 msg.body.con_info.ch = channel;
3041 msg.body.con_info.result = connect_result;
3042 msg.body.con_info.arg = user_arg;
3043 msg.body.con_info.params = join_params;
3047 msg.body.con_info.bssid = kmemdup(bssid, 6, GFP_KERNEL);
3048 if (!msg.body.con_info.bssid)
3053 msg.body.con_info.ssid_len = ssid_len;
3054 msg.body.con_info.ssid = kmemdup(ssid, ssid_len, GFP_KERNEL);
3055 if (!msg.body.con_info.ssid)
3060 msg.body.con_info.ies_len = ies_len;
3061 msg.body.con_info.ies = kmemdup(ies, ies_len, GFP_KERNEL);
3062 if (!msg.body.con_info.ies)
3065 if (hif_drv->hif_state < HOST_IF_CONNECTING)
3066 hif_drv->hif_state = HOST_IF_CONNECTING;
3068 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3070 netdev_err(vif->ndev, "send message: Set join request\n");
3074 hif_drv->connect_timer.data = (unsigned long)vif;
3075 mod_timer(&hif_drv->connect_timer,
3076 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
3081 int wilc_disconnect(struct wilc_vif *vif, u16 reason_code)
3084 struct host_if_msg msg;
3085 struct host_if_drv *hif_drv = vif->hif_drv;
3088 netdev_err(vif->ndev, "Driver is null\n");
3092 memset(&msg, 0, sizeof(struct host_if_msg));
3094 msg.id = HOST_IF_MSG_DISCONNECT;
3097 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3099 netdev_err(vif->ndev, "Failed to send message: disconnect\n");
3101 down(&hif_drv->sem_test_disconn_block);
3106 static s32 host_int_get_assoc_res_info(struct wilc_vif *vif,
3107 u8 *pu8AssocRespInfo,
3108 u32 u32MaxAssocRespInfoLen,
3109 u32 *pu32RcvdAssocRespInfoLen)
3113 struct host_if_drv *hif_drv = vif->hif_drv;
3116 netdev_err(vif->ndev, "Driver is null\n");
3120 wid.id = (u16)WID_ASSOC_RES_INFO;
3122 wid.val = pu8AssocRespInfo;
3123 wid.size = u32MaxAssocRespInfoLen;
3125 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
3126 wilc_get_vif_idx(vif));
3128 *pu32RcvdAssocRespInfoLen = 0;
3129 netdev_err(vif->ndev, "Failed to send association response\n");
3133 *pu32RcvdAssocRespInfoLen = wid.size;
3137 int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel)
3140 struct host_if_msg msg;
3141 struct host_if_drv *hif_drv = vif->hif_drv;
3144 netdev_err(vif->ndev, "driver is null\n");
3148 memset(&msg, 0, sizeof(struct host_if_msg));
3149 msg.id = HOST_IF_MSG_SET_CHANNEL;
3150 msg.body.channel_info.set_ch = channel;
3153 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3155 netdev_err(vif->ndev, "wilc mq send fail\n");
3162 int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mac_idx)
3165 struct host_if_msg msg;
3167 memset(&msg, 0, sizeof(struct host_if_msg));
3168 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
3169 msg.body.drv.handler = index;
3170 msg.body.drv.mac_idx = mac_idx;
3173 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3175 netdev_err(vif->ndev, "wilc mq send fail\n");
3182 int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode)
3185 struct host_if_msg msg;
3187 memset(&msg, 0, sizeof(struct host_if_msg));
3188 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
3189 msg.body.mode.mode = mode;
3192 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3194 netdev_err(vif->ndev, "wilc mq send fail\n");
3201 s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
3202 u32 *pu32InactiveTime)
3205 struct host_if_msg msg;
3206 struct host_if_drv *hif_drv = vif->hif_drv;
3209 netdev_err(vif->ndev, "driver is null\n");
3213 memset(&msg, 0, sizeof(struct host_if_msg));
3214 memcpy(msg.body.mac_info.mac, mac, ETH_ALEN);
3216 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
3219 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3221 netdev_err(vif->ndev, "Failed to send get host ch param\n");
3223 down(&hif_drv->sem_inactive_time);
3225 *pu32InactiveTime = inactive_time;
3230 int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level)
3233 struct host_if_msg msg;
3234 struct host_if_drv *hif_drv = vif->hif_drv;
3236 memset(&msg, 0, sizeof(struct host_if_msg));
3237 msg.id = HOST_IF_MSG_GET_RSSI;
3240 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3242 netdev_err(vif->ndev, "Failed to send get host ch param\n");
3246 down(&hif_drv->sem_get_rssi);
3249 netdev_err(vif->ndev, "RSS pointer value is null\n");
3258 int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats)
3261 struct host_if_msg msg;
3263 memset(&msg, 0, sizeof(struct host_if_msg));
3264 msg.id = HOST_IF_MSG_GET_STATISTICS;
3265 msg.body.data = (char *)stats;
3268 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3270 netdev_err(vif->ndev, "Failed to send get host channel\n");
3274 if (stats != &vif->wilc->dummy_statistics)
3275 down(&hif_sema_wait_response);
3279 int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
3280 u8 *ch_freq_list, u8 ch_list_len, const u8 *ies,
3281 size_t ies_len, wilc_scan_result scan_result, void *user_arg,
3282 struct hidden_network *hidden_network)
3285 struct host_if_msg msg;
3286 struct scan_attr *scan_info = &msg.body.scan_info;
3287 struct host_if_drv *hif_drv = vif->hif_drv;
3289 if (!hif_drv || !scan_result) {
3290 netdev_err(vif->ndev, "hif_drv or scan_result = NULL\n");
3294 memset(&msg, 0, sizeof(struct host_if_msg));
3296 msg.id = HOST_IF_MSG_SCAN;
3298 if (hidden_network) {
3299 scan_info->hidden_network.net_info = hidden_network->net_info;
3300 scan_info->hidden_network.n_ssids = hidden_network->n_ssids;
3304 scan_info->src = scan_source;
3305 scan_info->type = scan_type;
3306 scan_info->result = scan_result;
3307 scan_info->arg = user_arg;
3309 scan_info->ch_list_len = ch_list_len;
3310 scan_info->ch_freq_list = kmemdup(ch_freq_list,
3313 if (!scan_info->ch_freq_list)
3316 scan_info->ies_len = ies_len;
3317 scan_info->ies = kmemdup(ies, ies_len, GFP_KERNEL);
3318 if (!scan_info->ies)
3321 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3323 netdev_err(vif->ndev, "Error in sending message queue\n");
3327 hif_drv->scan_timer.data = (unsigned long)vif;
3328 mod_timer(&hif_drv->scan_timer,
3329 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
3334 int wilc_hif_set_cfg(struct wilc_vif *vif,
3335 struct cfg_param_attr *cfg_param)
3338 struct host_if_msg msg;
3339 struct host_if_drv *hif_drv = vif->hif_drv;
3342 netdev_err(vif->ndev, "hif_drv NULL\n");
3346 memset(&msg, 0, sizeof(struct host_if_msg));
3347 msg.id = HOST_IF_MSG_CFG_PARAMS;
3348 msg.body.cfg_info = *cfg_param;
3351 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3356 static void GetPeriodicRSSI(unsigned long arg)
3358 struct wilc_vif *vif = (struct wilc_vif *)arg;
3360 if (!vif->hif_drv) {
3361 netdev_err(vif->ndev, "Driver handler is NULL\n");
3365 if (vif->hif_drv->hif_state == HOST_IF_CONNECTED)
3366 wilc_get_statistics(vif, &vif->wilc->dummy_statistics);
3368 periodic_rssi.data = (unsigned long)vif;
3369 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
3372 int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
3375 struct host_if_drv *hif_drv;
3376 struct wilc_vif *vif;
3380 vif = netdev_priv(dev);
3383 scan_while_connected = false;
3385 sema_init(&hif_sema_wait_response, 0);
3387 hif_drv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
3392 *hif_drv_handler = hif_drv;
3393 for (i = 0; i < wilc->vif_num; i++)
3394 if (dev == wilc->vif[i]->ndev) {
3395 wilc->vif[i]->hif_drv = hif_drv;
3399 wilc_optaining_ip = false;
3401 if (clients_count == 0) {
3402 sema_init(&hif_sema_thread, 0);
3403 sema_init(&hif_sema_driver, 0);
3404 sema_init(&hif_sema_deinit, 1);
3407 sema_init(&hif_drv->sem_test_key_block, 0);
3408 sema_init(&hif_drv->sem_test_disconn_block, 0);
3409 sema_init(&hif_drv->sem_get_rssi, 0);
3410 sema_init(&hif_drv->sem_inactive_time, 0);
3412 if (clients_count == 0) {
3413 result = wilc_mq_create(&hif_msg_q);
3416 netdev_err(vif->ndev, "Failed to creat MQ\n");
3420 hif_thread_handler = kthread_run(hostIFthread, wilc,
3423 if (IS_ERR(hif_thread_handler)) {
3424 netdev_err(vif->ndev, "Failed to creat Thread\n");
3428 setup_timer(&periodic_rssi, GetPeriodicRSSI,
3429 (unsigned long)vif);
3430 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
3433 setup_timer(&hif_drv->scan_timer, TimerCB_Scan, 0);
3434 setup_timer(&hif_drv->connect_timer, TimerCB_Connect, 0);
3435 setup_timer(&hif_drv->remain_on_ch_timer, ListenTimerCB, 0);
3437 mutex_init(&hif_drv->cfg_values_lock);
3438 mutex_lock(&hif_drv->cfg_values_lock);
3440 hif_drv->hif_state = HOST_IF_IDLE;
3441 hif_drv->cfg_values.site_survey_enabled = SITE_SURVEY_OFF;
3442 hif_drv->cfg_values.scan_source = DEFAULT_SCAN;
3443 hif_drv->cfg_values.active_scan_time = ACTIVE_SCAN_TIME;
3444 hif_drv->cfg_values.passive_scan_time = PASSIVE_SCAN_TIME;
3445 hif_drv->cfg_values.curr_tx_rate = AUTORATE;
3447 hif_drv->p2p_timeout = 0;
3449 mutex_unlock(&hif_drv->cfg_values_lock);
3456 wilc_mq_destroy(&hif_msg_q);
3461 int wilc_deinit(struct wilc_vif *vif)
3464 struct host_if_msg msg;
3465 struct host_if_drv *hif_drv = vif->hif_drv;
3468 netdev_err(vif->ndev, "hif_drv = NULL\n");
3472 down(&hif_sema_deinit);
3474 terminated_handle = hif_drv;
3476 del_timer_sync(&hif_drv->scan_timer);
3477 del_timer_sync(&hif_drv->connect_timer);
3478 del_timer_sync(&periodic_rssi);
3479 del_timer_sync(&hif_drv->remain_on_ch_timer);
3481 wilc_set_wfi_drv_handler(vif, 0, 0);
3482 down(&hif_sema_driver);
3484 if (hif_drv->usr_scan_req.scan_result) {
3485 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, NULL,
3486 hif_drv->usr_scan_req.arg, NULL);
3487 hif_drv->usr_scan_req.scan_result = NULL;
3490 hif_drv->hif_state = HOST_IF_IDLE;
3492 scan_while_connected = false;
3494 memset(&msg, 0, sizeof(struct host_if_msg));
3496 if (clients_count == 1) {
3497 del_timer_sync(&periodic_rssi);
3498 msg.id = HOST_IF_MSG_EXIT;
3501 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3503 netdev_err(vif->ndev, "deinit : Error(%d)\n", result);
3505 down(&hif_sema_thread);
3507 wilc_mq_destroy(&hif_msg_q);
3513 terminated_handle = NULL;
3514 up(&hif_sema_deinit);
3518 void wilc_network_info_received(struct wilc *wilc, u8 *pu8Buffer,
3522 struct host_if_msg msg;
3524 struct host_if_drv *hif_drv = NULL;
3525 struct wilc_vif *vif;
3527 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
3528 vif = wilc_get_vif_from_idx(wilc, id);
3531 hif_drv = vif->hif_drv;
3533 if (!hif_drv || hif_drv == terminated_handle) {
3534 netdev_err(vif->ndev, "driver not init[%p]\n", hif_drv);
3538 memset(&msg, 0, sizeof(struct host_if_msg));
3540 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
3543 msg.body.net_info.len = u32Length;
3544 msg.body.net_info.buffer = kmalloc(u32Length, GFP_KERNEL);
3545 memcpy(msg.body.net_info.buffer, pu8Buffer, u32Length);
3547 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3549 netdev_err(vif->ndev, "message parameters (%d)\n", result);
3552 void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *pu8Buffer,
3556 struct host_if_msg msg;
3558 struct host_if_drv *hif_drv = NULL;
3559 struct wilc_vif *vif;
3561 down(&hif_sema_deinit);
3563 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
3564 vif = wilc_get_vif_from_idx(wilc, id);
3566 up(&hif_sema_deinit);
3570 hif_drv = vif->hif_drv;
3572 if (!hif_drv || hif_drv == terminated_handle) {
3573 up(&hif_sema_deinit);
3577 if (!hif_drv->usr_conn_req.conn_result) {
3578 netdev_err(vif->ndev, "there is no current Connect Request\n");
3579 up(&hif_sema_deinit);
3583 memset(&msg, 0, sizeof(struct host_if_msg));
3585 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
3588 msg.body.async_info.len = u32Length;
3589 msg.body.async_info.buffer = kmalloc(u32Length, GFP_KERNEL);
3590 memcpy(msg.body.async_info.buffer, pu8Buffer, u32Length);
3592 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3594 netdev_err(vif->ndev, "synchronous info (%d)\n", result);
3596 up(&hif_sema_deinit);
3599 void wilc_scan_complete_received(struct wilc *wilc, u8 *pu8Buffer,
3603 struct host_if_msg msg;
3605 struct host_if_drv *hif_drv = NULL;
3606 struct wilc_vif *vif;
3608 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
3609 vif = wilc_get_vif_from_idx(wilc, id);
3612 hif_drv = vif->hif_drv;
3614 if (!hif_drv || hif_drv == terminated_handle)
3617 if (hif_drv->usr_scan_req.scan_result) {
3618 memset(&msg, 0, sizeof(struct host_if_msg));
3620 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
3623 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3625 netdev_err(vif->ndev, "complete param (%d)\n", result);
3629 int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id,
3630 u32 duration, u16 chan,
3631 wilc_remain_on_chan_expired expired,
3632 wilc_remain_on_chan_ready ready,
3636 struct host_if_msg msg;
3637 struct host_if_drv *hif_drv = vif->hif_drv;
3640 netdev_err(vif->ndev, "driver is null\n");
3644 memset(&msg, 0, sizeof(struct host_if_msg));
3646 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
3647 msg.body.remain_on_ch.ch = chan;
3648 msg.body.remain_on_ch.expired = expired;
3649 msg.body.remain_on_ch.ready = ready;
3650 msg.body.remain_on_ch.arg = user_arg;
3651 msg.body.remain_on_ch.duration = duration;
3652 msg.body.remain_on_ch.id = session_id;
3655 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3657 netdev_err(vif->ndev, "wilc mq send fail\n");
3662 int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id)
3665 struct host_if_msg msg;
3666 struct host_if_drv *hif_drv = vif->hif_drv;
3669 netdev_err(vif->ndev, "driver is null\n");
3673 del_timer(&hif_drv->remain_on_ch_timer);
3675 memset(&msg, 0, sizeof(struct host_if_msg));
3676 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
3678 msg.body.remain_on_ch.id = session_id;
3680 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3682 netdev_err(vif->ndev, "wilc mq send fail\n");
3687 int wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg)
3690 struct host_if_msg msg;
3691 struct host_if_drv *hif_drv = vif->hif_drv;
3694 netdev_err(vif->ndev, "driver is null\n");
3698 memset(&msg, 0, sizeof(struct host_if_msg));
3700 msg.id = HOST_IF_MSG_REGISTER_FRAME;
3701 switch (frame_type) {
3703 msg.body.reg_frame.reg_id = ACTION_FRM_IDX;
3707 msg.body.reg_frame.reg_id = PROBE_REQ_IDX;
3713 msg.body.reg_frame.frame_type = frame_type;
3714 msg.body.reg_frame.reg = reg;
3717 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3719 netdev_err(vif->ndev, "wilc mq send fail\n");
3724 int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period,
3725 u32 head_len, u8 *head, u32 tail_len, u8 *tail)
3728 struct host_if_msg msg;
3729 struct beacon_attr *beacon_info = &msg.body.beacon_info;
3730 struct host_if_drv *hif_drv = vif->hif_drv;
3733 netdev_err(vif->ndev, "driver is null\n");
3737 memset(&msg, 0, sizeof(struct host_if_msg));
3739 msg.id = HOST_IF_MSG_ADD_BEACON;
3741 beacon_info->interval = interval;
3742 beacon_info->dtim_period = dtim_period;
3743 beacon_info->head_len = head_len;
3744 beacon_info->head = kmemdup(head, head_len, GFP_KERNEL);
3745 if (!beacon_info->head) {
3749 beacon_info->tail_len = tail_len;
3752 beacon_info->tail = kmemdup(tail, tail_len, GFP_KERNEL);
3753 if (!beacon_info->tail) {
3758 beacon_info->tail = NULL;
3761 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3763 netdev_err(vif->ndev, "wilc mq send fail\n");
3767 kfree(beacon_info->head);
3769 kfree(beacon_info->tail);
3775 int wilc_del_beacon(struct wilc_vif *vif)
3778 struct host_if_msg msg;
3779 struct host_if_drv *hif_drv = vif->hif_drv;
3782 netdev_err(vif->ndev, "driver is null\n");
3786 msg.id = HOST_IF_MSG_DEL_BEACON;
3789 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3791 netdev_err(vif->ndev, "wilc_mq_send fail\n");
3796 int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param)
3799 struct host_if_msg msg;
3800 struct add_sta_param *add_sta_info = &msg.body.add_sta_info;
3801 struct host_if_drv *hif_drv = vif->hif_drv;
3804 netdev_err(vif->ndev, "driver is null\n");
3808 memset(&msg, 0, sizeof(struct host_if_msg));
3810 msg.id = HOST_IF_MSG_ADD_STATION;
3813 memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param));
3814 if (add_sta_info->rates_len > 0) {
3815 add_sta_info->rates = kmemdup(sta_param->rates,
3816 add_sta_info->rates_len,
3818 if (!add_sta_info->rates)
3822 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3824 netdev_err(vif->ndev, "wilc_mq_send fail\n");
3828 int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr)
3831 struct host_if_msg msg;
3832 struct del_sta *del_sta_info = &msg.body.del_sta_info;
3833 struct host_if_drv *hif_drv = vif->hif_drv;
3836 netdev_err(vif->ndev, "driver is null\n");
3840 memset(&msg, 0, sizeof(struct host_if_msg));
3842 msg.id = HOST_IF_MSG_DEL_STATION;
3846 eth_broadcast_addr(del_sta_info->mac_addr);
3848 memcpy(del_sta_info->mac_addr, mac_addr, ETH_ALEN);
3850 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3852 netdev_err(vif->ndev, "wilc_mq_send fail\n");
3856 int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN])
3859 struct host_if_msg msg;
3860 struct del_all_sta *del_all_sta_info = &msg.body.del_all_sta_info;
3861 struct host_if_drv *hif_drv = vif->hif_drv;
3862 u8 zero_addr[ETH_ALEN] = {0};
3867 netdev_err(vif->ndev, "driver is null\n");
3871 memset(&msg, 0, sizeof(struct host_if_msg));
3873 msg.id = HOST_IF_MSG_DEL_ALL_STA;
3876 for (i = 0; i < MAX_NUM_STA; i++) {
3877 if (memcmp(mac_addr[i], zero_addr, ETH_ALEN)) {
3878 memcpy(del_all_sta_info->del_all_sta[i], mac_addr[i], ETH_ALEN);
3885 del_all_sta_info->assoc_sta = assoc_sta;
3886 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3889 netdev_err(vif->ndev, "wilc_mq_send fail\n");
3891 down(&hif_sema_wait_response);
3896 int wilc_edit_station(struct wilc_vif *vif,
3897 struct add_sta_param *sta_param)
3900 struct host_if_msg msg;
3901 struct add_sta_param *add_sta_info = &msg.body.add_sta_info;
3902 struct host_if_drv *hif_drv = vif->hif_drv;
3905 netdev_err(vif->ndev, "driver is null\n");
3909 memset(&msg, 0, sizeof(struct host_if_msg));
3911 msg.id = HOST_IF_MSG_EDIT_STATION;
3914 memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param));
3915 if (add_sta_info->rates_len > 0) {
3916 add_sta_info->rates = kmemdup(sta_param->rates,
3917 add_sta_info->rates_len,
3919 if (!add_sta_info->rates)
3923 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3925 netdev_err(vif->ndev, "wilc_mq_send fail\n");
3930 int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout)
3933 struct host_if_msg msg;
3934 struct power_mgmt_param *pwr_mgmt_info = &msg.body.pwr_mgmt_info;
3935 struct host_if_drv *hif_drv = vif->hif_drv;
3938 netdev_err(vif->ndev, "driver is null\n");
3942 if (wilc_wlan_get_num_conn_ifcs(vif->wilc) == 2 && enabled)
3945 memset(&msg, 0, sizeof(struct host_if_msg));
3947 msg.id = HOST_IF_MSG_POWER_MGMT;
3950 pwr_mgmt_info->enabled = enabled;
3951 pwr_mgmt_info->timeout = timeout;
3953 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3955 netdev_err(vif->ndev, "wilc_mq_send fail\n");
3959 int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled,
3963 struct host_if_msg msg;
3964 struct set_multicast *multicast_filter_param = &msg.body.multicast_info;
3965 struct host_if_drv *hif_drv = vif->hif_drv;
3968 netdev_err(vif->ndev, "driver is null\n");
3972 memset(&msg, 0, sizeof(struct host_if_msg));
3974 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
3977 multicast_filter_param->enabled = enabled;
3978 multicast_filter_param->cnt = count;
3980 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3982 netdev_err(vif->ndev, "wilc_mq_send fail\n");
3986 static void *host_int_ParseJoinBssParam(struct network_info *ptstrNetworkInfo)
3988 struct join_bss_param *pNewJoinBssParam = NULL;
3997 u8 pcipherTotalCount = 0;
3998 u8 authTotalCount = 0;
4001 pu8IEs = ptstrNetworkInfo->ies;
4002 u16IEsLen = ptstrNetworkInfo->ies_len;
4004 pNewJoinBssParam = kzalloc(sizeof(struct join_bss_param), GFP_KERNEL);
4005 if (pNewJoinBssParam) {
4006 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->dtim_period;
4007 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->beacon_period;
4008 pNewJoinBssParam->cap_info = ptstrNetworkInfo->cap_info;
4009 memcpy(pNewJoinBssParam->bssid, ptstrNetworkInfo->bssid, 6);
4010 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->ssid,
4011 ptstrNetworkInfo->ssid_len + 1);
4012 pNewJoinBssParam->ssid_len = ptstrNetworkInfo->ssid_len;
4013 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
4014 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
4016 while (index < u16IEsLen) {
4017 if (pu8IEs[index] == SUPP_RATES_IE) {
4018 suppRatesNo = pu8IEs[index + 1];
4019 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
4022 for (i = 0; i < suppRatesNo; i++)
4023 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
4025 index += suppRatesNo;
4027 } else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
4028 extSuppRatesNo = pu8IEs[index + 1];
4029 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
4030 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
4032 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
4034 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++)
4035 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
4037 index += extSuppRatesNo;
4039 } else if (pu8IEs[index] == HT_CAPABILITY_IE) {
4040 pNewJoinBssParam->ht_capable = true;
4041 index += pu8IEs[index + 1] + 2;
4043 } else if ((pu8IEs[index] == WMM_IE) &&
4044 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
4045 (pu8IEs[index + 4] == 0xF2) &&
4046 (pu8IEs[index + 5] == 0x02) &&
4047 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) &&
4048 (pu8IEs[index + 7] == 0x01)) {
4049 pNewJoinBssParam->wmm_cap = true;
4051 if (pu8IEs[index + 8] & BIT(7))
4052 pNewJoinBssParam->uapsd_cap = true;
4053 index += pu8IEs[index + 1] + 2;
4055 } else if ((pu8IEs[index] == P2P_IE) &&
4056 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
4057 (pu8IEs[index + 4] == 0x9a) &&
4058 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) {
4061 pNewJoinBssParam->tsf = ptstrNetworkInfo->tsf_lo;
4062 pNewJoinBssParam->noa_enabled = 1;
4063 pNewJoinBssParam->idx = pu8IEs[index + 9];
4065 if (pu8IEs[index + 10] & BIT(7)) {
4066 pNewJoinBssParam->opp_enabled = 1;
4067 pNewJoinBssParam->ct_window = pu8IEs[index + 10];
4069 pNewJoinBssParam->opp_enabled = 0;
4072 pNewJoinBssParam->cnt = pu8IEs[index + 11];
4073 u16P2P_count = index + 12;
4075 memcpy(pNewJoinBssParam->duration, pu8IEs + u16P2P_count, 4);
4078 memcpy(pNewJoinBssParam->interval, pu8IEs + u16P2P_count, 4);
4081 memcpy(pNewJoinBssParam->start_time, pu8IEs + u16P2P_count, 4);
4083 index += pu8IEs[index + 1] + 2;
4086 } else if ((pu8IEs[index] == RSN_IE) ||
4087 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
4088 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
4089 (pu8IEs[index + 5] == 0x01))) {
4090 u16 rsnIndex = index;
4092 if (pu8IEs[rsnIndex] == RSN_IE) {
4093 pNewJoinBssParam->mode_802_11i = 2;
4095 if (pNewJoinBssParam->mode_802_11i == 0)
4096 pNewJoinBssParam->mode_802_11i = 1;
4101 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
4103 jumpOffset = pu8IEs[rsnIndex] * 4;
4104 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
4107 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++)
4108 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
4110 pcipherTotalCount += pcipherCount;
4111 rsnIndex += jumpOffset;
4113 jumpOffset = pu8IEs[rsnIndex] * 4;
4115 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
4118 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++)
4119 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
4121 authTotalCount += authCount;
4122 rsnIndex += jumpOffset;
4124 if (pu8IEs[index] == RSN_IE) {
4125 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
4126 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
4129 pNewJoinBssParam->rsn_found = true;
4130 index += pu8IEs[index + 1] + 2;
4133 index += pu8IEs[index + 1] + 2;
4137 return (void *)pNewJoinBssParam;
4140 int wilc_setup_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx)
4143 struct host_if_msg msg;
4144 struct host_if_drv *hif_drv = vif->hif_drv;
4147 netdev_err(vif->ndev, "driver is null\n");
4151 memset(&msg, 0, sizeof(struct host_if_msg));
4153 msg.id = HOST_IF_MSG_SET_IPADDRESS;
4155 msg.body.ip_info.ip_addr = ip_addr;
4157 msg.body.ip_info.idx = idx;
4159 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4161 netdev_err(vif->ndev, "wilc_mq_send fail\n");
4166 static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx)
4169 struct host_if_msg msg;
4170 struct host_if_drv *hif_drv = vif->hif_drv;
4173 netdev_err(vif->ndev, "driver is null\n");
4177 memset(&msg, 0, sizeof(struct host_if_msg));
4179 msg.id = HOST_IF_MSG_GET_IPADDRESS;
4181 msg.body.ip_info.ip_addr = ip_addr;
4183 msg.body.ip_info.idx = idx;
4185 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4187 netdev_err(vif->ndev, "wilc_mq_send fail\n");
4192 int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power)
4195 struct host_if_msg msg;
4197 memset(&msg, 0, sizeof(struct host_if_msg));
4199 msg.id = HOST_IF_MSG_SET_TX_POWER;
4200 msg.body.tx_power.tx_pwr = tx_power;
4203 ret = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4205 netdev_err(vif->ndev, "wilc_mq_send fail\n");
4210 int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power)
4213 struct host_if_msg msg;
4215 memset(&msg, 0, sizeof(struct host_if_msg));
4217 msg.id = HOST_IF_MSG_GET_TX_POWER;
4220 ret = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4222 netdev_err(vif->ndev, "Failed to get TX PWR\n");
4224 down(&hif_sema_wait_response);
4225 *tx_power = msg.body.tx_power.tx_pwr;