1 #include <linux/slab.h>
2 #include <linux/time.h>
3 #include <linux/kthread.h>
4 #include <linux/delay.h>
5 #include <linux/completion.h>
6 #include <linux/list.h>
7 #include <linux/workqueue.h>
8 #include "host_interface.h"
9 #include <linux/spinlock.h>
10 #include <linux/errno.h>
11 #include "coreconfigurator.h"
12 #include "wilc_wlan.h"
13 #include "wilc_wlan_if.h"
14 #include <linux/etherdevice.h>
15 #include "wilc_wfi_netdevice.h"
17 #define HOST_IF_MSG_SCAN 0
18 #define HOST_IF_MSG_CONNECT 1
19 #define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
20 #define HOST_IF_MSG_KEY 3
21 #define HOST_IF_MSG_RCVD_NTWRK_INFO 4
22 #define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
23 #define HOST_IF_MSG_CFG_PARAMS 6
24 #define HOST_IF_MSG_SET_CHANNEL 7
25 #define HOST_IF_MSG_DISCONNECT 8
26 #define HOST_IF_MSG_GET_RSSI 9
27 #define HOST_IF_MSG_ADD_BEACON 11
28 #define HOST_IF_MSG_DEL_BEACON 12
29 #define HOST_IF_MSG_ADD_STATION 13
30 #define HOST_IF_MSG_DEL_STATION 14
31 #define HOST_IF_MSG_EDIT_STATION 15
32 #define HOST_IF_MSG_SCAN_TIMER_FIRED 16
33 #define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
34 #define HOST_IF_MSG_POWER_MGMT 18
35 #define HOST_IF_MSG_GET_INACTIVETIME 19
36 #define HOST_IF_MSG_REMAIN_ON_CHAN 20
37 #define HOST_IF_MSG_REGISTER_FRAME 21
38 #define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
39 #define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
40 #define HOST_IF_MSG_GET_MAC_ADDRESS 26
41 #define HOST_IF_MSG_SET_OPERATION_MODE 27
42 #define HOST_IF_MSG_SET_IPADDRESS 28
43 #define HOST_IF_MSG_GET_IPADDRESS 29
44 #define HOST_IF_MSG_GET_STATISTICS 31
45 #define HOST_IF_MSG_SET_MULTICAST_FILTER 32
46 #define HOST_IF_MSG_DEL_BA_SESSION 34
47 #define HOST_IF_MSG_DEL_ALL_STA 36
48 #define HOST_IF_MSG_SET_TX_POWER 38
49 #define HOST_IF_MSG_GET_TX_POWER 39
50 #define HOST_IF_MSG_EXIT 100
52 #define HOST_IF_SCAN_TIMEOUT 4000
53 #define HOST_IF_CONNECT_TIMEOUT 9500
55 #define BA_SESSION_DEFAULT_BUFFER_SIZE 16
56 #define BA_SESSION_DEFAULT_TIMEOUT 1000
57 #define BLOCK_ACK_REQ_SIZE 0x14
58 #define FALSE_FRMWR_CHANNEL 100
60 #define TCP_ACK_FILTER_LINK_SPEED_THRESH 54
61 #define DEFAULT_LINK_SPEED 72
63 struct host_if_wpa_attr {
73 struct host_if_wep_attr {
78 enum AUTHTYPE auth_type;
81 union host_if_key_attr {
82 struct host_if_wep_attr wep;
83 struct host_if_wpa_attr wpa;
84 struct host_if_pmkid_attr pmkid;
90 union host_if_key_attr attr;
100 wilc_scan_result result;
102 struct hidden_network hidden_network;
105 struct connect_attr {
112 wilc_connect_result result;
114 enum AUTHTYPE auth_type;
119 struct rcvd_async_info {
124 struct channel_attr {
137 struct set_multicast {
143 u8 del_all_sta[MAX_NUM_STA][ETH_ALEN];
148 u8 mac_addr[ETH_ALEN];
151 struct power_mgmt_param {
161 struct sta_inactive_t {
170 struct scan_attr scan_info;
171 struct connect_attr con_info;
172 struct rcvd_net_info net_info;
173 struct rcvd_async_info async_info;
174 struct key_attr key_info;
175 struct cfg_param_attr cfg_info;
176 struct channel_attr channel_info;
177 struct beacon_attr beacon_info;
178 struct add_sta_param add_sta_info;
179 struct del_sta del_sta_info;
180 struct add_sta_param edit_sta_info;
181 struct power_mgmt_param pwr_mgmt_info;
182 struct sta_inactive_t mac_info;
183 struct set_ip_addr ip_info;
184 struct drv_handler drv;
185 struct set_multicast multicast_info;
187 struct get_mac_addr get_mac_info;
188 struct ba_session_info session_info;
189 struct remain_ch remain_on_ch;
190 struct reg_frame reg_frame;
192 struct del_all_sta del_all_sta_info;
193 struct tx_power tx_power;
198 union message_body body;
199 struct wilc_vif *vif;
200 struct work_struct work;
203 struct join_bss_param {
209 char ssid[MAX_SSID_LEN];
211 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
218 u8 rsn_pcip_policy[3];
219 u8 rsn_auth_policy[3];
232 static struct host_if_drv *terminated_handle;
233 bool wilc_optaining_ip;
234 static u8 P2P_LISTEN_STATE;
235 static struct workqueue_struct *hif_workqueue;
236 static struct completion hif_thread_comp;
237 static struct completion hif_driver_comp;
238 static struct completion hif_wait_response;
239 static struct mutex hif_deinit_lock;
240 static struct timer_list periodic_rssi;
242 u8 wilc_multicast_mac_addr_list[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
244 static u8 rcv_assoc_resp[MAX_ASSOC_RESP_FRAME_SIZE];
246 static bool scan_while_connected;
249 static u8 set_ip[2][4];
250 static u8 get_ip[2][4];
251 static u32 inactive_time;
252 static u8 del_beacon;
253 static u32 clients_count;
256 static u8 *info_element;
259 static u32 join_req_size;
260 static u32 info_element_size;
261 static struct wilc_vif *join_req_vif;
262 #define REAL_JOIN_REQ 0
263 #define FLUSHED_JOIN_REQ 1
264 #define FLUSHED_BYTE_POS 79
266 static void *host_int_ParseJoinBssParam(struct network_info *ptstrNetworkInfo);
267 static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx);
268 static s32 Handle_ScanDone(struct wilc_vif *vif, enum scan_event enuEvent);
269 static void host_if_work(struct work_struct *work);
274 * @note copied from FLO glue implementatuion
277 static int wilc_enqueue_cmd(struct host_if_msg *msg)
279 struct host_if_msg *new_msg;
281 new_msg = kmemdup(msg, sizeof(*new_msg), GFP_ATOMIC);
285 INIT_WORK(&new_msg->work, host_if_work);
286 queue_work(hif_workqueue, &new_msg->work);
291 /* The u8IfIdx starts from 0 to NUM_CONCURRENT_IFC -1, but 0 index used as
292 * special purpose in wilc device, so we add 1 to the index to starts from 1.
293 * As a result, the returned index will be 1 to NUM_CONCURRENT_IFC.
295 int wilc_get_vif_idx(struct wilc_vif *vif)
300 /* We need to minus 1 from idx which is from wilc device to get real index
301 * of wilc->vif[], because we add 1 when pass to wilc device in the function
303 * As a result, the index should be between 0 and NUM_CONCURRENT_IFC -1.
305 static struct wilc_vif *wilc_get_vif_from_idx(struct wilc *wilc, int idx)
309 if (index < 0 || index >= NUM_CONCURRENT_IFC)
312 return wilc->vif[index];
315 static void handle_set_channel(struct wilc_vif *vif,
316 struct channel_attr *hif_set_ch)
321 wid.id = (u16)WID_CURRENT_CHANNEL;
323 wid.val = (char *)&hif_set_ch->set_ch;
324 wid.size = sizeof(char);
326 ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
327 wilc_get_vif_idx(vif));
330 netdev_err(vif->ndev, "Failed to set channel\n");
333 static void handle_set_wfi_drv_handler(struct wilc_vif *vif,
334 struct drv_handler *hif_drv_handler)
339 wid.id = (u16)WID_SET_DRV_HANDLER;
341 wid.val = (s8 *)hif_drv_handler;
342 wid.size = sizeof(*hif_drv_handler);
344 ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
345 hif_drv_handler->handler);
347 if (!hif_drv_handler->handler)
348 complete(&hif_driver_comp);
351 netdev_err(vif->ndev, "Failed to set driver handler\n");
354 static void handle_set_operation_mode(struct wilc_vif *vif,
355 struct op_mode *hif_op_mode)
360 wid.id = (u16)WID_SET_OPERATION_MODE;
362 wid.val = (s8 *)&hif_op_mode->mode;
363 wid.size = sizeof(u32);
365 ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
366 wilc_get_vif_idx(vif));
368 if ((hif_op_mode->mode) == IDLE_MODE)
369 complete(&hif_driver_comp);
372 netdev_err(vif->ndev, "Failed to set driver handler\n");
375 static void handle_set_ip_address(struct wilc_vif *vif, u8 *ip_addr, u8 idx)
379 char firmware_ip_addr[4] = {0};
381 if (ip_addr[0] < 192)
384 memcpy(set_ip[idx], ip_addr, IP_ALEN);
386 wid.id = (u16)WID_IP_ADDRESS;
388 wid.val = (u8 *)ip_addr;
391 ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
392 wilc_get_vif_idx(vif));
394 host_int_get_ipaddress(vif, firmware_ip_addr, idx);
397 netdev_err(vif->ndev, "Failed to set IP address\n");
400 static void handle_get_ip_address(struct wilc_vif *vif, u8 idx)
405 wid.id = (u16)WID_IP_ADDRESS;
407 wid.val = kmalloc(IP_ALEN, GFP_KERNEL);
410 ret = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
411 wilc_get_vif_idx(vif));
413 memcpy(get_ip[idx], wid.val, IP_ALEN);
417 if (memcmp(get_ip[idx], set_ip[idx], IP_ALEN) != 0)
418 wilc_setup_ipaddress(vif, set_ip[idx], idx);
421 netdev_err(vif->ndev, "Failed to get IP address\n");
424 static void handle_get_mac_address(struct wilc_vif *vif,
425 struct get_mac_addr *get_mac_addr)
430 wid.id = (u16)WID_MAC_ADDR;
432 wid.val = get_mac_addr->mac_addr;
435 ret = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
436 wilc_get_vif_idx(vif));
439 netdev_err(vif->ndev, "Failed to get mac address\n");
440 complete(&hif_wait_response);
443 static void handle_cfg_param(struct wilc_vif *vif,
444 struct cfg_param_attr *cfg_param_attr)
447 struct wid wid_list[32];
448 struct host_if_drv *hif_drv = vif->hif_drv;
451 mutex_lock(&hif_drv->cfg_values_lock);
453 if (cfg_param_attr->flag & BSS_TYPE) {
454 u8 bss_type = cfg_param_attr->bss_type;
457 wid_list[i].id = WID_BSS_TYPE;
458 wid_list[i].val = (s8 *)&bss_type;
459 wid_list[i].type = WID_CHAR;
460 wid_list[i].size = sizeof(char);
461 hif_drv->cfg_values.bss_type = bss_type;
463 netdev_err(vif->ndev, "check value 6 over\n");
468 if (cfg_param_attr->flag & AUTH_TYPE) {
469 if (cfg_param_attr->auth_type == 1 ||
470 cfg_param_attr->auth_type == 2 ||
471 cfg_param_attr->auth_type == 5) {
472 wid_list[i].id = WID_AUTH_TYPE;
473 wid_list[i].val = (s8 *)&cfg_param_attr->auth_type;
474 wid_list[i].type = WID_CHAR;
475 wid_list[i].size = sizeof(char);
476 hif_drv->cfg_values.auth_type = (u8)cfg_param_attr->auth_type;
478 netdev_err(vif->ndev, "Impossible value\n");
483 if (cfg_param_attr->flag & AUTHEN_TIMEOUT) {
484 if (cfg_param_attr->auth_timeout > 0 &&
485 cfg_param_attr->auth_timeout < 65536) {
486 wid_list[i].id = WID_AUTH_TIMEOUT;
487 wid_list[i].val = (s8 *)&cfg_param_attr->auth_timeout;
488 wid_list[i].type = WID_SHORT;
489 wid_list[i].size = sizeof(u16);
490 hif_drv->cfg_values.auth_timeout = cfg_param_attr->auth_timeout;
492 netdev_err(vif->ndev, "Range(1 ~ 65535) over\n");
497 if (cfg_param_attr->flag & POWER_MANAGEMENT) {
498 if (cfg_param_attr->power_mgmt_mode < 5) {
499 wid_list[i].id = WID_POWER_MANAGEMENT;
500 wid_list[i].val = (s8 *)&cfg_param_attr->power_mgmt_mode;
501 wid_list[i].type = WID_CHAR;
502 wid_list[i].size = sizeof(char);
503 hif_drv->cfg_values.power_mgmt_mode = (u8)cfg_param_attr->power_mgmt_mode;
505 netdev_err(vif->ndev, "Invalid power mode\n");
510 if (cfg_param_attr->flag & RETRY_SHORT) {
511 if (cfg_param_attr->short_retry_limit > 0 &&
512 cfg_param_attr->short_retry_limit < 256) {
513 wid_list[i].id = WID_SHORT_RETRY_LIMIT;
514 wid_list[i].val = (s8 *)&cfg_param_attr->short_retry_limit;
515 wid_list[i].type = WID_SHORT;
516 wid_list[i].size = sizeof(u16);
517 hif_drv->cfg_values.short_retry_limit = cfg_param_attr->short_retry_limit;
519 netdev_err(vif->ndev, "Range(1~256) over\n");
524 if (cfg_param_attr->flag & RETRY_LONG) {
525 if (cfg_param_attr->long_retry_limit > 0 &&
526 cfg_param_attr->long_retry_limit < 256) {
527 wid_list[i].id = WID_LONG_RETRY_LIMIT;
528 wid_list[i].val = (s8 *)&cfg_param_attr->long_retry_limit;
529 wid_list[i].type = WID_SHORT;
530 wid_list[i].size = sizeof(u16);
531 hif_drv->cfg_values.long_retry_limit = cfg_param_attr->long_retry_limit;
533 netdev_err(vif->ndev, "Range(1~256) over\n");
538 if (cfg_param_attr->flag & FRAG_THRESHOLD) {
539 if (cfg_param_attr->frag_threshold > 255 &&
540 cfg_param_attr->frag_threshold < 7937) {
541 wid_list[i].id = WID_FRAG_THRESHOLD;
542 wid_list[i].val = (s8 *)&cfg_param_attr->frag_threshold;
543 wid_list[i].type = WID_SHORT;
544 wid_list[i].size = sizeof(u16);
545 hif_drv->cfg_values.frag_threshold = cfg_param_attr->frag_threshold;
547 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");
566 if (cfg_param_attr->flag & PREAMBLE) {
567 if (cfg_param_attr->preamble_type < 3) {
568 wid_list[i].id = WID_PREAMBLE;
569 wid_list[i].val = (s8 *)&cfg_param_attr->preamble_type;
570 wid_list[i].type = WID_CHAR;
571 wid_list[i].size = sizeof(char);
572 hif_drv->cfg_values.preamble_type = cfg_param_attr->preamble_type;
574 netdev_err(vif->ndev, "Preamle Range(0~2) over\n");
579 if (cfg_param_attr->flag & SHORT_SLOT_ALLOWED) {
580 if (cfg_param_attr->short_slot_allowed < 2) {
581 wid_list[i].id = WID_SHORT_SLOT_ALLOWED;
582 wid_list[i].val = (s8 *)&cfg_param_attr->short_slot_allowed;
583 wid_list[i].type = WID_CHAR;
584 wid_list[i].size = sizeof(char);
585 hif_drv->cfg_values.short_slot_allowed = (u8)cfg_param_attr->short_slot_allowed;
587 netdev_err(vif->ndev, "Short slot(2) over\n");
592 if (cfg_param_attr->flag & TXOP_PROT_DISABLE) {
593 if (cfg_param_attr->txop_prot_disabled < 2) {
594 wid_list[i].id = WID_11N_TXOP_PROT_DISABLE;
595 wid_list[i].val = (s8 *)&cfg_param_attr->txop_prot_disabled;
596 wid_list[i].type = WID_CHAR;
597 wid_list[i].size = sizeof(char);
598 hif_drv->cfg_values.txop_prot_disabled = (u8)cfg_param_attr->txop_prot_disabled;
600 netdev_err(vif->ndev, "TXOP prot disable\n");
605 if (cfg_param_attr->flag & BEACON_INTERVAL) {
606 if (cfg_param_attr->beacon_interval > 0 &&
607 cfg_param_attr->beacon_interval < 65536) {
608 wid_list[i].id = WID_BEACON_INTERVAL;
609 wid_list[i].val = (s8 *)&cfg_param_attr->beacon_interval;
610 wid_list[i].type = WID_SHORT;
611 wid_list[i].size = sizeof(u16);
612 hif_drv->cfg_values.beacon_interval = cfg_param_attr->beacon_interval;
614 netdev_err(vif->ndev, "Beacon interval(1~65535)fail\n");
619 if (cfg_param_attr->flag & DTIM_PERIOD) {
620 if (cfg_param_attr->dtim_period > 0 &&
621 cfg_param_attr->dtim_period < 256) {
622 wid_list[i].id = WID_DTIM_PERIOD;
623 wid_list[i].val = (s8 *)&cfg_param_attr->dtim_period;
624 wid_list[i].type = WID_CHAR;
625 wid_list[i].size = sizeof(char);
626 hif_drv->cfg_values.dtim_period = cfg_param_attr->dtim_period;
628 netdev_err(vif->ndev, "DTIM range(1~255) fail\n");
633 if (cfg_param_attr->flag & SITE_SURVEY) {
634 if (cfg_param_attr->site_survey_enabled < 3) {
635 wid_list[i].id = WID_SITE_SURVEY;
636 wid_list[i].val = (s8 *)&cfg_param_attr->site_survey_enabled;
637 wid_list[i].type = WID_CHAR;
638 wid_list[i].size = sizeof(char);
639 hif_drv->cfg_values.site_survey_enabled = (u8)cfg_param_attr->site_survey_enabled;
641 netdev_err(vif->ndev, "Site survey disable\n");
646 if (cfg_param_attr->flag & SITE_SURVEY_SCAN_TIME) {
647 if (cfg_param_attr->site_survey_scan_time > 0 &&
648 cfg_param_attr->site_survey_scan_time < 65536) {
649 wid_list[i].id = WID_SITE_SURVEY_SCAN_TIME;
650 wid_list[i].val = (s8 *)&cfg_param_attr->site_survey_scan_time;
651 wid_list[i].type = WID_SHORT;
652 wid_list[i].size = sizeof(u16);
653 hif_drv->cfg_values.site_survey_scan_time = cfg_param_attr->site_survey_scan_time;
655 netdev_err(vif->ndev, "Site scan time(1~65535) over\n");
660 if (cfg_param_attr->flag & ACTIVE_SCANTIME) {
661 if (cfg_param_attr->active_scan_time > 0 &&
662 cfg_param_attr->active_scan_time < 65536) {
663 wid_list[i].id = WID_ACTIVE_SCAN_TIME;
664 wid_list[i].val = (s8 *)&cfg_param_attr->active_scan_time;
665 wid_list[i].type = WID_SHORT;
666 wid_list[i].size = sizeof(u16);
667 hif_drv->cfg_values.active_scan_time = cfg_param_attr->active_scan_time;
669 netdev_err(vif->ndev, "Active time(1~65535) over\n");
674 if (cfg_param_attr->flag & PASSIVE_SCANTIME) {
675 if (cfg_param_attr->passive_scan_time > 0 &&
676 cfg_param_attr->passive_scan_time < 65536) {
677 wid_list[i].id = WID_PASSIVE_SCAN_TIME;
678 wid_list[i].val = (s8 *)&cfg_param_attr->passive_scan_time;
679 wid_list[i].type = WID_SHORT;
680 wid_list[i].size = sizeof(u16);
681 hif_drv->cfg_values.passive_scan_time = cfg_param_attr->passive_scan_time;
683 netdev_err(vif->ndev, "Passive time(1~65535) over\n");
688 if (cfg_param_attr->flag & CURRENT_TX_RATE) {
689 enum CURRENT_TXRATE curr_tx_rate = cfg_param_attr->curr_tx_rate;
691 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1 ||
692 curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5 ||
693 curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6 ||
694 curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12 ||
695 curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24 ||
696 curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 ||
697 curr_tx_rate == MBPS_54) {
698 wid_list[i].id = WID_CURRENT_TX_RATE;
699 wid_list[i].val = (s8 *)&curr_tx_rate;
700 wid_list[i].type = WID_SHORT;
701 wid_list[i].size = sizeof(u16);
702 hif_drv->cfg_values.curr_tx_rate = (u8)curr_tx_rate;
704 netdev_err(vif->ndev, "out of TX rate\n");
710 ret = wilc_send_config_pkt(vif, SET_CFG, wid_list,
711 i, wilc_get_vif_idx(vif));
714 netdev_err(vif->ndev, "Error in setting CFG params\n");
717 mutex_unlock(&hif_drv->cfg_values_lock);
720 static s32 handle_scan(struct wilc_vif *vif, struct scan_attr *scan_info)
723 struct wid wid_list[5];
728 u8 *pu8HdnNtwrksWidVal = NULL;
729 struct host_if_drv *hif_drv = vif->hif_drv;
731 hif_drv->usr_scan_req.scan_result = scan_info->result;
732 hif_drv->usr_scan_req.arg = scan_info->arg;
734 if ((hif_drv->hif_state >= HOST_IF_SCANNING) &&
735 (hif_drv->hif_state < HOST_IF_CONNECTED)) {
736 netdev_err(vif->ndev, "Already scan\n");
741 if (wilc_optaining_ip || wilc_connecting) {
742 netdev_err(vif->ndev, "Don't do obss scan\n");
747 hif_drv->usr_scan_req.rcvd_ch_cnt = 0;
749 wid_list[index].id = (u16)WID_SSID_PROBE_REQ;
750 wid_list[index].type = WID_STR;
752 for (i = 0; i < scan_info->hidden_network.n_ssids; i++)
753 valuesize += ((scan_info->hidden_network.net_info[i].ssid_len) + 1);
754 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
755 wid_list[index].val = pu8HdnNtwrksWidVal;
756 if (wid_list[index].val) {
757 buffer = wid_list[index].val;
759 *buffer++ = scan_info->hidden_network.n_ssids;
761 for (i = 0; i < scan_info->hidden_network.n_ssids; i++) {
762 *buffer++ = scan_info->hidden_network.net_info[i].ssid_len;
763 memcpy(buffer, scan_info->hidden_network.net_info[i].ssid, scan_info->hidden_network.net_info[i].ssid_len);
764 buffer += scan_info->hidden_network.net_info[i].ssid_len;
767 wid_list[index].size = (s32)(valuesize + 1);
771 wid_list[index].id = WID_INFO_ELEMENT_PROBE;
772 wid_list[index].type = WID_BIN_DATA;
773 wid_list[index].val = scan_info->ies;
774 wid_list[index].size = scan_info->ies_len;
777 wid_list[index].id = WID_SCAN_TYPE;
778 wid_list[index].type = WID_CHAR;
779 wid_list[index].size = sizeof(char);
780 wid_list[index].val = (s8 *)&scan_info->type;
783 wid_list[index].id = WID_SCAN_CHANNEL_LIST;
784 wid_list[index].type = WID_BIN_DATA;
786 if (scan_info->ch_freq_list &&
787 scan_info->ch_list_len > 0) {
790 for (i = 0; i < scan_info->ch_list_len; i++) {
791 if (scan_info->ch_freq_list[i] > 0)
792 scan_info->ch_freq_list[i] = scan_info->ch_freq_list[i] - 1;
796 wid_list[index].val = scan_info->ch_freq_list;
797 wid_list[index].size = scan_info->ch_list_len;
800 wid_list[index].id = WID_START_SCAN_REQ;
801 wid_list[index].type = WID_CHAR;
802 wid_list[index].size = sizeof(char);
803 wid_list[index].val = (s8 *)&scan_info->src;
806 if (hif_drv->hif_state == HOST_IF_CONNECTED)
807 scan_while_connected = true;
808 else if (hif_drv->hif_state == HOST_IF_IDLE)
809 scan_while_connected = false;
811 result = wilc_send_config_pkt(vif, SET_CFG, wid_list,
813 wilc_get_vif_idx(vif));
816 netdev_err(vif->ndev, "Failed to send scan parameters\n");
820 del_timer(&hif_drv->scan_timer);
821 Handle_ScanDone(vif, SCAN_EVENT_ABORTED);
824 kfree(scan_info->ch_freq_list);
825 scan_info->ch_freq_list = NULL;
827 kfree(scan_info->ies);
828 scan_info->ies = NULL;
829 kfree(scan_info->hidden_network.net_info);
830 scan_info->hidden_network.net_info = NULL;
832 kfree(pu8HdnNtwrksWidVal);
837 static s32 Handle_ScanDone(struct wilc_vif *vif,
838 enum scan_event enuEvent)
841 u8 u8abort_running_scan;
843 struct host_if_drv *hif_drv = vif->hif_drv;
845 if (enuEvent == SCAN_EVENT_ABORTED) {
846 u8abort_running_scan = 1;
847 wid.id = (u16)WID_ABORT_RUNNING_SCAN;
849 wid.val = (s8 *)&u8abort_running_scan;
850 wid.size = sizeof(char);
852 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
853 wilc_get_vif_idx(vif));
856 netdev_err(vif->ndev, "Failed to set abort running\n");
862 netdev_err(vif->ndev, "Driver handler is NULL\n");
866 if (hif_drv->usr_scan_req.scan_result) {
867 hif_drv->usr_scan_req.scan_result(enuEvent, NULL,
868 hif_drv->usr_scan_req.arg, NULL);
869 hif_drv->usr_scan_req.scan_result = NULL;
875 u8 wilc_connected_ssid[6] = {0};
876 static s32 Handle_Connect(struct wilc_vif *vif,
877 struct connect_attr *pstrHostIFconnectAttr)
880 struct wid strWIDList[8];
881 u32 u32WidsCount = 0, dummyval = 0;
882 u8 *pu8CurrByte = NULL;
883 struct join_bss_param *ptstrJoinBssParam;
884 struct host_if_drv *hif_drv = vif->hif_drv;
886 if (memcmp(pstrHostIFconnectAttr->bssid, wilc_connected_ssid, ETH_ALEN) == 0) {
888 netdev_err(vif->ndev, "Discard connect request\n");
892 ptstrJoinBssParam = pstrHostIFconnectAttr->params;
893 if (!ptstrJoinBssParam) {
894 netdev_err(vif->ndev, "Required BSSID not found\n");
899 if (pstrHostIFconnectAttr->bssid) {
900 hif_drv->usr_conn_req.bssid = kmalloc(6, GFP_KERNEL);
901 memcpy(hif_drv->usr_conn_req.bssid, pstrHostIFconnectAttr->bssid, 6);
904 hif_drv->usr_conn_req.ssid_len = pstrHostIFconnectAttr->ssid_len;
905 if (pstrHostIFconnectAttr->ssid) {
906 hif_drv->usr_conn_req.ssid = kmalloc(pstrHostIFconnectAttr->ssid_len + 1, GFP_KERNEL);
907 memcpy(hif_drv->usr_conn_req.ssid,
908 pstrHostIFconnectAttr->ssid,
909 pstrHostIFconnectAttr->ssid_len);
910 hif_drv->usr_conn_req.ssid[pstrHostIFconnectAttr->ssid_len] = '\0';
913 hif_drv->usr_conn_req.ies_len = pstrHostIFconnectAttr->ies_len;
914 if (pstrHostIFconnectAttr->ies) {
915 hif_drv->usr_conn_req.ies = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
916 memcpy(hif_drv->usr_conn_req.ies,
917 pstrHostIFconnectAttr->ies,
918 pstrHostIFconnectAttr->ies_len);
921 hif_drv->usr_conn_req.security = pstrHostIFconnectAttr->security;
922 hif_drv->usr_conn_req.auth_type = pstrHostIFconnectAttr->auth_type;
923 hif_drv->usr_conn_req.conn_result = pstrHostIFconnectAttr->result;
924 hif_drv->usr_conn_req.arg = pstrHostIFconnectAttr->arg;
926 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
927 strWIDList[u32WidsCount].type = WID_INT;
928 strWIDList[u32WidsCount].size = sizeof(u32);
929 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
932 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
933 strWIDList[u32WidsCount].type = WID_INT;
934 strWIDList[u32WidsCount].size = sizeof(u32);
935 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
938 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
939 strWIDList[u32WidsCount].type = WID_INT;
940 strWIDList[u32WidsCount].size = sizeof(u32);
941 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
945 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
946 strWIDList[u32WidsCount].type = WID_BIN_DATA;
947 strWIDList[u32WidsCount].val = hif_drv->usr_conn_req.ies;
948 strWIDList[u32WidsCount].size = hif_drv->usr_conn_req.ies_len;
951 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
952 info_element_size = hif_drv->usr_conn_req.ies_len;
953 info_element = kmalloc(info_element_size, GFP_KERNEL);
954 memcpy(info_element, hif_drv->usr_conn_req.ies,
958 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
959 strWIDList[u32WidsCount].type = WID_CHAR;
960 strWIDList[u32WidsCount].size = sizeof(char);
961 strWIDList[u32WidsCount].val = (s8 *)&hif_drv->usr_conn_req.security;
964 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
965 mode_11i = hif_drv->usr_conn_req.security;
967 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
968 strWIDList[u32WidsCount].type = WID_CHAR;
969 strWIDList[u32WidsCount].size = sizeof(char);
970 strWIDList[u32WidsCount].val = (s8 *)&hif_drv->usr_conn_req.auth_type;
973 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
974 auth_type = (u8)hif_drv->usr_conn_req.auth_type;
976 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
977 strWIDList[u32WidsCount].type = WID_STR;
978 strWIDList[u32WidsCount].size = 112;
979 strWIDList[u32WidsCount].val = kmalloc(strWIDList[u32WidsCount].size, GFP_KERNEL);
981 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
982 join_req_size = strWIDList[u32WidsCount].size;
983 join_req = kmalloc(join_req_size, GFP_KERNEL);
985 if (!strWIDList[u32WidsCount].val) {
990 pu8CurrByte = strWIDList[u32WidsCount].val;
992 if (pstrHostIFconnectAttr->ssid) {
993 memcpy(pu8CurrByte, pstrHostIFconnectAttr->ssid, pstrHostIFconnectAttr->ssid_len);
994 pu8CurrByte[pstrHostIFconnectAttr->ssid_len] = '\0';
996 pu8CurrByte += MAX_SSID_LEN;
997 *(pu8CurrByte++) = INFRASTRUCTURE;
999 if ((pstrHostIFconnectAttr->ch >= 1) && (pstrHostIFconnectAttr->ch <= 14)) {
1000 *(pu8CurrByte++) = pstrHostIFconnectAttr->ch;
1002 netdev_err(vif->ndev, "Channel out of range\n");
1003 *(pu8CurrByte++) = 0xFF;
1005 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1006 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1008 if (pstrHostIFconnectAttr->bssid)
1009 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
1012 if (pstrHostIFconnectAttr->bssid)
1013 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
1016 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1017 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1018 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1020 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
1021 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1023 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1024 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1026 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1027 hif_drv->usr_conn_req.ht_capable = ptstrJoinBssParam->ht_capable;
1029 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1030 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1031 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1033 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
1034 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1036 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
1037 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1039 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
1040 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1042 *(pu8CurrByte++) = REAL_JOIN_REQ;
1043 *(pu8CurrByte++) = ptstrJoinBssParam->noa_enabled;
1045 if (ptstrJoinBssParam->noa_enabled) {
1046 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1047 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1048 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1049 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1051 *(pu8CurrByte++) = ptstrJoinBssParam->opp_enabled;
1052 *(pu8CurrByte++) = ptstrJoinBssParam->idx;
1054 if (ptstrJoinBssParam->opp_enabled)
1055 *(pu8CurrByte++) = ptstrJoinBssParam->ct_window;
1057 *(pu8CurrByte++) = ptstrJoinBssParam->cnt;
1059 memcpy(pu8CurrByte, ptstrJoinBssParam->duration, sizeof(ptstrJoinBssParam->duration));
1060 pu8CurrByte += sizeof(ptstrJoinBssParam->duration);
1062 memcpy(pu8CurrByte, ptstrJoinBssParam->interval, sizeof(ptstrJoinBssParam->interval));
1063 pu8CurrByte += sizeof(ptstrJoinBssParam->interval);
1065 memcpy(pu8CurrByte, ptstrJoinBssParam->start_time, sizeof(ptstrJoinBssParam->start_time));
1066 pu8CurrByte += sizeof(ptstrJoinBssParam->start_time);
1069 pu8CurrByte = strWIDList[u32WidsCount].val;
1072 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1073 memcpy(join_req, pu8CurrByte, join_req_size);
1077 if (pstrHostIFconnectAttr->bssid)
1078 memcpy(wilc_connected_ssid,
1079 pstrHostIFconnectAttr->bssid, ETH_ALEN);
1081 result = wilc_send_config_pkt(vif, SET_CFG, strWIDList,
1083 wilc_get_vif_idx(vif));
1085 netdev_err(vif->ndev, "failed to send config packet\n");
1089 hif_drv->hif_state = HOST_IF_WAITING_CONN_RESP;
1094 struct connect_info strConnectInfo;
1096 del_timer(&hif_drv->connect_timer);
1098 memset(&strConnectInfo, 0, sizeof(struct connect_info));
1100 if (pstrHostIFconnectAttr->result) {
1101 if (pstrHostIFconnectAttr->bssid)
1102 memcpy(strConnectInfo.bssid, pstrHostIFconnectAttr->bssid, 6);
1104 if (pstrHostIFconnectAttr->ies) {
1105 strConnectInfo.req_ies_len = pstrHostIFconnectAttr->ies_len;
1106 strConnectInfo.req_ies = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
1107 memcpy(strConnectInfo.req_ies,
1108 pstrHostIFconnectAttr->ies,
1109 pstrHostIFconnectAttr->ies_len);
1112 pstrHostIFconnectAttr->result(CONN_DISCONN_EVENT_CONN_RESP,
1116 pstrHostIFconnectAttr->arg);
1117 hif_drv->hif_state = HOST_IF_IDLE;
1118 kfree(strConnectInfo.req_ies);
1119 strConnectInfo.req_ies = NULL;
1122 netdev_err(vif->ndev, "Connect callback is NULL\n");
1126 kfree(pstrHostIFconnectAttr->bssid);
1127 pstrHostIFconnectAttr->bssid = NULL;
1129 kfree(pstrHostIFconnectAttr->ssid);
1130 pstrHostIFconnectAttr->ssid = NULL;
1132 kfree(pstrHostIFconnectAttr->ies);
1133 pstrHostIFconnectAttr->ies = NULL;
1139 static s32 Handle_ConnectTimeout(struct wilc_vif *vif)
1142 struct connect_info strConnectInfo;
1144 u16 u16DummyReasonCode = 0;
1145 struct host_if_drv *hif_drv = vif->hif_drv;
1148 netdev_err(vif->ndev, "Driver handler is NULL\n");
1152 hif_drv->hif_state = HOST_IF_IDLE;
1154 scan_while_connected = false;
1156 memset(&strConnectInfo, 0, sizeof(struct connect_info));
1158 if (hif_drv->usr_conn_req.conn_result) {
1159 if (hif_drv->usr_conn_req.bssid) {
1160 memcpy(strConnectInfo.bssid,
1161 hif_drv->usr_conn_req.bssid, 6);
1164 if (hif_drv->usr_conn_req.ies) {
1165 strConnectInfo.req_ies_len = hif_drv->usr_conn_req.ies_len;
1166 strConnectInfo.req_ies = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL);
1167 memcpy(strConnectInfo.req_ies,
1168 hif_drv->usr_conn_req.ies,
1169 hif_drv->usr_conn_req.ies_len);
1172 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
1176 hif_drv->usr_conn_req.arg);
1178 kfree(strConnectInfo.req_ies);
1179 strConnectInfo.req_ies = NULL;
1181 netdev_err(vif->ndev, "Connect callback is NULL\n");
1184 wid.id = (u16)WID_DISCONNECT;
1185 wid.type = WID_CHAR;
1186 wid.val = (s8 *)&u16DummyReasonCode;
1187 wid.size = sizeof(char);
1189 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
1190 wilc_get_vif_idx(vif));
1192 netdev_err(vif->ndev, "Failed to send dissconect\n");
1194 hif_drv->usr_conn_req.ssid_len = 0;
1195 kfree(hif_drv->usr_conn_req.ssid);
1196 hif_drv->usr_conn_req.ssid = NULL;
1197 kfree(hif_drv->usr_conn_req.bssid);
1198 hif_drv->usr_conn_req.bssid = NULL;
1199 hif_drv->usr_conn_req.ies_len = 0;
1200 kfree(hif_drv->usr_conn_req.ies);
1201 hif_drv->usr_conn_req.ies = NULL;
1203 eth_zero_addr(wilc_connected_ssid);
1205 if (join_req && join_req_vif == vif) {
1210 if (info_element && join_req_vif == vif) {
1211 kfree(info_element);
1212 info_element = NULL;
1218 static s32 Handle_RcvdNtwrkInfo(struct wilc_vif *vif,
1219 struct rcvd_net_info *pstrRcvdNetworkInfo)
1222 bool bNewNtwrkFound;
1224 struct network_info *pstrNetworkInfo = NULL;
1225 void *pJoinParams = NULL;
1226 struct host_if_drv *hif_drv = vif->hif_drv;
1228 bNewNtwrkFound = true;
1230 if (hif_drv->usr_scan_req.scan_result) {
1231 wilc_parse_network_info(pstrRcvdNetworkInfo->buffer, &pstrNetworkInfo);
1232 if ((!pstrNetworkInfo) ||
1233 (!hif_drv->usr_scan_req.scan_result)) {
1234 netdev_err(vif->ndev, "driver is null\n");
1239 for (i = 0; i < hif_drv->usr_scan_req.rcvd_ch_cnt; i++) {
1240 if (memcmp(hif_drv->usr_scan_req.net_info[i].bssid,
1241 pstrNetworkInfo->bssid, 6) == 0) {
1242 if (pstrNetworkInfo->rssi <= hif_drv->usr_scan_req.net_info[i].rssi) {
1245 hif_drv->usr_scan_req.net_info[i].rssi = pstrNetworkInfo->rssi;
1246 bNewNtwrkFound = false;
1252 if (bNewNtwrkFound) {
1253 if (hif_drv->usr_scan_req.rcvd_ch_cnt < MAX_NUM_SCANNED_NETWORKS) {
1254 hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].rssi = pstrNetworkInfo->rssi;
1256 memcpy(hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].bssid,
1257 pstrNetworkInfo->bssid, 6);
1259 hif_drv->usr_scan_req.rcvd_ch_cnt++;
1261 pstrNetworkInfo->new_network = true;
1262 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
1264 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1265 hif_drv->usr_scan_req.arg,
1269 pstrNetworkInfo->new_network = false;
1270 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1271 hif_drv->usr_scan_req.arg, NULL);
1276 kfree(pstrRcvdNetworkInfo->buffer);
1277 pstrRcvdNetworkInfo->buffer = NULL;
1279 if (pstrNetworkInfo) {
1280 kfree(pstrNetworkInfo->ies);
1281 kfree(pstrNetworkInfo);
1287 static s32 host_int_get_assoc_res_info(struct wilc_vif *vif,
1288 u8 *pu8AssocRespInfo,
1289 u32 u32MaxAssocRespInfoLen,
1290 u32 *pu32RcvdAssocRespInfoLen);
1292 static s32 Handle_RcvdGnrlAsyncInfo(struct wilc_vif *vif,
1293 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
1299 u16 u16WidID = (u16)WID_NIL;
1302 u8 u8MacStatusReasonCode;
1303 u8 u8MacStatusAdditionalInfo;
1304 struct connect_info strConnectInfo;
1305 struct disconnect_info strDisconnectNotifInfo;
1307 struct host_if_drv *hif_drv = vif->hif_drv;
1310 netdev_err(vif->ndev, "Driver handler is NULL\n");
1314 if ((hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) ||
1315 (hif_drv->hif_state == HOST_IF_CONNECTED) ||
1316 hif_drv->usr_scan_req.scan_result) {
1317 if (!pstrRcvdGnrlAsyncInfo->buffer ||
1318 !hif_drv->usr_conn_req.conn_result) {
1319 netdev_err(vif->ndev, "driver is null\n");
1323 u8MsgType = pstrRcvdGnrlAsyncInfo->buffer[0];
1325 if ('I' != u8MsgType) {
1326 netdev_err(vif->ndev, "Received Message incorrect.\n");
1330 u8MsgID = pstrRcvdGnrlAsyncInfo->buffer[1];
1331 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[2], pstrRcvdGnrlAsyncInfo->buffer[3]);
1332 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[4], pstrRcvdGnrlAsyncInfo->buffer[5]);
1333 u8WidLen = pstrRcvdGnrlAsyncInfo->buffer[6];
1334 u8MacStatus = pstrRcvdGnrlAsyncInfo->buffer[7];
1335 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->buffer[8];
1336 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->buffer[9];
1337 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
1338 u32 u32RcvdAssocRespInfoLen = 0;
1339 struct connect_resp_info *pstrConnectRespInfo = NULL;
1341 memset(&strConnectInfo, 0, sizeof(struct connect_info));
1343 if (u8MacStatus == MAC_CONNECTED) {
1344 memset(rcv_assoc_resp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
1346 host_int_get_assoc_res_info(vif,
1348 MAX_ASSOC_RESP_FRAME_SIZE,
1349 &u32RcvdAssocRespInfoLen);
1351 if (u32RcvdAssocRespInfoLen != 0) {
1352 s32Err = wilc_parse_assoc_resp_info(rcv_assoc_resp, u32RcvdAssocRespInfoLen,
1353 &pstrConnectRespInfo);
1355 netdev_err(vif->ndev, "wilc_parse_assoc_resp_info() returned error %d\n", s32Err);
1357 strConnectInfo.status = pstrConnectRespInfo->status;
1359 if (strConnectInfo.status == SUCCESSFUL_STATUSCODE) {
1360 if (pstrConnectRespInfo->ies) {
1361 strConnectInfo.resp_ies_len = pstrConnectRespInfo->ies_len;
1362 strConnectInfo.resp_ies = kmalloc(pstrConnectRespInfo->ies_len, GFP_KERNEL);
1363 memcpy(strConnectInfo.resp_ies, pstrConnectRespInfo->ies,
1364 pstrConnectRespInfo->ies_len);
1368 if (pstrConnectRespInfo) {
1369 kfree(pstrConnectRespInfo->ies);
1370 kfree(pstrConnectRespInfo);
1376 if ((u8MacStatus == MAC_CONNECTED) &&
1377 (strConnectInfo.status != SUCCESSFUL_STATUSCODE)) {
1378 netdev_err(vif->ndev, "Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
1379 eth_zero_addr(wilc_connected_ssid);
1380 } else if (u8MacStatus == MAC_DISCONNECTED) {
1381 netdev_err(vif->ndev, "Received MAC status is MAC_DISCONNECTED\n");
1382 eth_zero_addr(wilc_connected_ssid);
1385 if (hif_drv->usr_conn_req.bssid) {
1386 memcpy(strConnectInfo.bssid, hif_drv->usr_conn_req.bssid, 6);
1388 if ((u8MacStatus == MAC_CONNECTED) &&
1389 (strConnectInfo.status == SUCCESSFUL_STATUSCODE)) {
1390 memcpy(hif_drv->assoc_bssid,
1391 hif_drv->usr_conn_req.bssid, ETH_ALEN);
1395 if (hif_drv->usr_conn_req.ies) {
1396 strConnectInfo.req_ies_len = hif_drv->usr_conn_req.ies_len;
1397 strConnectInfo.req_ies = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL);
1398 memcpy(strConnectInfo.req_ies,
1399 hif_drv->usr_conn_req.ies,
1400 hif_drv->usr_conn_req.ies_len);
1403 del_timer(&hif_drv->connect_timer);
1404 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
1408 hif_drv->usr_conn_req.arg);
1410 if ((u8MacStatus == MAC_CONNECTED) &&
1411 (strConnectInfo.status == SUCCESSFUL_STATUSCODE)) {
1412 wilc_set_power_mgmt(vif, 0, 0);
1414 hif_drv->hif_state = HOST_IF_CONNECTED;
1416 wilc_optaining_ip = true;
1417 mod_timer(&wilc_during_ip_timer,
1418 jiffies + msecs_to_jiffies(10000));
1420 hif_drv->hif_state = HOST_IF_IDLE;
1421 scan_while_connected = false;
1424 kfree(strConnectInfo.resp_ies);
1425 strConnectInfo.resp_ies = NULL;
1427 kfree(strConnectInfo.req_ies);
1428 strConnectInfo.req_ies = NULL;
1429 hif_drv->usr_conn_req.ssid_len = 0;
1430 kfree(hif_drv->usr_conn_req.ssid);
1431 hif_drv->usr_conn_req.ssid = NULL;
1432 kfree(hif_drv->usr_conn_req.bssid);
1433 hif_drv->usr_conn_req.bssid = NULL;
1434 hif_drv->usr_conn_req.ies_len = 0;
1435 kfree(hif_drv->usr_conn_req.ies);
1436 hif_drv->usr_conn_req.ies = NULL;
1437 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
1438 (hif_drv->hif_state == HOST_IF_CONNECTED)) {
1439 memset(&strDisconnectNotifInfo, 0, sizeof(struct disconnect_info));
1441 if (hif_drv->usr_scan_req.scan_result) {
1442 del_timer(&hif_drv->scan_timer);
1443 Handle_ScanDone(vif, SCAN_EVENT_ABORTED);
1446 strDisconnectNotifInfo.reason = 0;
1447 strDisconnectNotifInfo.ie = NULL;
1448 strDisconnectNotifInfo.ie_len = 0;
1450 if (hif_drv->usr_conn_req.conn_result) {
1451 wilc_optaining_ip = false;
1452 wilc_set_power_mgmt(vif, 0, 0);
1454 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1457 &strDisconnectNotifInfo,
1458 hif_drv->usr_conn_req.arg);
1460 netdev_err(vif->ndev, "Connect result NULL\n");
1463 eth_zero_addr(hif_drv->assoc_bssid);
1465 hif_drv->usr_conn_req.ssid_len = 0;
1466 kfree(hif_drv->usr_conn_req.ssid);
1467 hif_drv->usr_conn_req.ssid = NULL;
1468 kfree(hif_drv->usr_conn_req.bssid);
1469 hif_drv->usr_conn_req.bssid = NULL;
1470 hif_drv->usr_conn_req.ies_len = 0;
1471 kfree(hif_drv->usr_conn_req.ies);
1472 hif_drv->usr_conn_req.ies = NULL;
1474 if (join_req && join_req_vif == vif) {
1479 if (info_element && join_req_vif == vif) {
1480 kfree(info_element);
1481 info_element = NULL;
1484 hif_drv->hif_state = HOST_IF_IDLE;
1485 scan_while_connected = false;
1487 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
1488 (hif_drv->usr_scan_req.scan_result)) {
1489 del_timer(&hif_drv->scan_timer);
1490 if (hif_drv->usr_scan_req.scan_result)
1491 Handle_ScanDone(vif, SCAN_EVENT_ABORTED);
1495 kfree(pstrRcvdGnrlAsyncInfo->buffer);
1496 pstrRcvdGnrlAsyncInfo->buffer = NULL;
1501 static int Handle_Key(struct wilc_vif *vif,
1502 struct key_attr *pstrHostIFkeyAttr)
1506 struct wid strWIDList[5];
1511 struct host_if_drv *hif_drv = vif->hif_drv;
1513 switch (pstrHostIFkeyAttr->type) {
1516 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1517 strWIDList[0].id = (u16)WID_11I_MODE;
1518 strWIDList[0].type = WID_CHAR;
1519 strWIDList[0].size = sizeof(char);
1520 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.mode;
1522 strWIDList[1].id = WID_AUTH_TYPE;
1523 strWIDList[1].type = WID_CHAR;
1524 strWIDList[1].size = sizeof(char);
1525 strWIDList[1].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.auth_type;
1527 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2,
1532 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1533 pu8keybuf[1] = pstrHostIFkeyAttr->attr.wep.key_len;
1535 memcpy(&pu8keybuf[2], pstrHostIFkeyAttr->attr.wep.key,
1536 pstrHostIFkeyAttr->attr.wep.key_len);
1538 kfree(pstrHostIFkeyAttr->attr.wep.key);
1540 strWIDList[2].id = (u16)WID_WEP_KEY_VALUE;
1541 strWIDList[2].type = WID_STR;
1542 strWIDList[2].size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
1543 strWIDList[2].val = (s8 *)pu8keybuf;
1545 result = wilc_send_config_pkt(vif, SET_CFG,
1547 wilc_get_vif_idx(vif));
1549 } else if (pstrHostIFkeyAttr->action & ADDKEY) {
1550 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2, GFP_KERNEL);
1553 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1554 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->attr.wep.key_len, 1);
1555 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->attr.wep.key,
1556 pstrHostIFkeyAttr->attr.wep.key_len);
1557 kfree(pstrHostIFkeyAttr->attr.wep.key);
1559 wid.id = (u16)WID_ADD_WEP_KEY;
1561 wid.val = (s8 *)pu8keybuf;
1562 wid.size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
1564 result = wilc_send_config_pkt(vif, SET_CFG,
1566 wilc_get_vif_idx(vif));
1568 } else if (pstrHostIFkeyAttr->action & REMOVEKEY) {
1569 wid.id = (u16)WID_REMOVE_WEP_KEY;
1572 s8idxarray[0] = (s8)pstrHostIFkeyAttr->attr.wep.index;
1573 wid.val = s8idxarray;
1576 result = wilc_send_config_pkt(vif, SET_CFG,
1578 wilc_get_vif_idx(vif));
1579 } else if (pstrHostIFkeyAttr->action & DEFAULTKEY) {
1580 wid.id = (u16)WID_KEY_ID;
1581 wid.type = WID_CHAR;
1582 wid.val = (s8 *)&pstrHostIFkeyAttr->attr.wep.index;
1583 wid.size = sizeof(char);
1585 result = wilc_send_config_pkt(vif, SET_CFG,
1587 wilc_get_vif_idx(vif));
1589 complete(&hif_drv->comp_test_key_block);
1593 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1594 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1597 goto _WPARxGtk_end_case_;
1600 if (pstrHostIFkeyAttr->attr.wpa.seq)
1601 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1603 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1604 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1605 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1606 pstrHostIFkeyAttr->attr.wpa.key_len);
1608 strWIDList[0].id = (u16)WID_11I_MODE;
1609 strWIDList[0].type = WID_CHAR;
1610 strWIDList[0].size = sizeof(char);
1611 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode;
1613 strWIDList[1].id = (u16)WID_ADD_RX_GTK;
1614 strWIDList[1].type = WID_STR;
1615 strWIDList[1].val = (s8 *)pu8keybuf;
1616 strWIDList[1].size = RX_MIC_KEY_MSG_LEN;
1618 result = wilc_send_config_pkt(vif, SET_CFG,
1620 wilc_get_vif_idx(vif));
1623 complete(&hif_drv->comp_test_key_block);
1624 } else if (pstrHostIFkeyAttr->action & ADDKEY) {
1625 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1628 goto _WPARxGtk_end_case_;
1631 if (hif_drv->hif_state == HOST_IF_CONNECTED)
1632 memcpy(pu8keybuf, hif_drv->assoc_bssid, ETH_ALEN);
1634 netdev_err(vif->ndev, "Couldn't handle\n");
1636 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1637 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1638 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1639 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1640 pstrHostIFkeyAttr->attr.wpa.key_len);
1642 wid.id = (u16)WID_ADD_RX_GTK;
1644 wid.val = (s8 *)pu8keybuf;
1645 wid.size = RX_MIC_KEY_MSG_LEN;
1647 result = wilc_send_config_pkt(vif, SET_CFG,
1649 wilc_get_vif_idx(vif));
1652 complete(&hif_drv->comp_test_key_block);
1654 _WPARxGtk_end_case_:
1655 kfree(pstrHostIFkeyAttr->attr.wpa.key);
1656 kfree(pstrHostIFkeyAttr->attr.wpa.seq);
1663 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1664 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
1667 goto _WPAPtk_end_case_;
1670 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1671 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1672 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1673 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->attr.wpa.key,
1674 pstrHostIFkeyAttr->attr.wpa.key_len);
1676 strWIDList[0].id = (u16)WID_11I_MODE;
1677 strWIDList[0].type = WID_CHAR;
1678 strWIDList[0].size = sizeof(char);
1679 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode;
1681 strWIDList[1].id = (u16)WID_ADD_PTK;
1682 strWIDList[1].type = WID_STR;
1683 strWIDList[1].val = (s8 *)pu8keybuf;
1684 strWIDList[1].size = PTK_KEY_MSG_LEN + 1;
1686 result = wilc_send_config_pkt(vif, SET_CFG,
1688 wilc_get_vif_idx(vif));
1690 complete(&hif_drv->comp_test_key_block);
1691 } else if (pstrHostIFkeyAttr->action & ADDKEY) {
1692 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
1694 netdev_err(vif->ndev, "No buffer send PTK\n");
1696 goto _WPAPtk_end_case_;
1699 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1700 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1701 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->attr.wpa.key,
1702 pstrHostIFkeyAttr->attr.wpa.key_len);
1704 wid.id = (u16)WID_ADD_PTK;
1706 wid.val = (s8 *)pu8keybuf;
1707 wid.size = PTK_KEY_MSG_LEN;
1709 result = wilc_send_config_pkt(vif, SET_CFG,
1711 wilc_get_vif_idx(vif));
1713 complete(&hif_drv->comp_test_key_block);
1717 kfree(pstrHostIFkeyAttr->attr.wpa.key);
1724 pu8keybuf = kmalloc((pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
1726 netdev_err(vif->ndev, "No buffer to send PMKSA Key\n");
1730 pu8keybuf[0] = pstrHostIFkeyAttr->attr.pmkid.numpmkid;
1732 for (i = 0; i < pstrHostIFkeyAttr->attr.pmkid.numpmkid; i++) {
1733 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
1734 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
1737 wid.id = (u16)WID_PMKID_INFO;
1739 wid.val = (s8 *)pu8keybuf;
1740 wid.size = (pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
1742 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
1743 wilc_get_vif_idx(vif));
1750 netdev_err(vif->ndev, "Failed to send key config packet\n");
1755 static void Handle_Disconnect(struct wilc_vif *vif)
1758 struct host_if_drv *hif_drv = vif->hif_drv;
1761 u16 u16DummyReasonCode = 0;
1763 wid.id = (u16)WID_DISCONNECT;
1764 wid.type = WID_CHAR;
1765 wid.val = (s8 *)&u16DummyReasonCode;
1766 wid.size = sizeof(char);
1768 wilc_optaining_ip = false;
1769 wilc_set_power_mgmt(vif, 0, 0);
1771 eth_zero_addr(wilc_connected_ssid);
1773 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
1774 wilc_get_vif_idx(vif));
1777 netdev_err(vif->ndev, "Failed to send dissconect\n");
1779 struct disconnect_info strDisconnectNotifInfo;
1781 memset(&strDisconnectNotifInfo, 0, sizeof(struct disconnect_info));
1783 strDisconnectNotifInfo.reason = 0;
1784 strDisconnectNotifInfo.ie = NULL;
1785 strDisconnectNotifInfo.ie_len = 0;
1787 if (hif_drv->usr_scan_req.scan_result) {
1788 del_timer(&hif_drv->scan_timer);
1789 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED,
1791 hif_drv->usr_scan_req.arg,
1793 hif_drv->usr_scan_req.scan_result = NULL;
1796 if (hif_drv->usr_conn_req.conn_result) {
1797 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP)
1798 del_timer(&hif_drv->connect_timer);
1800 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1803 &strDisconnectNotifInfo,
1804 hif_drv->usr_conn_req.arg);
1806 netdev_err(vif->ndev, "conn_result = NULL\n");
1809 scan_while_connected = false;
1811 hif_drv->hif_state = HOST_IF_IDLE;
1813 eth_zero_addr(hif_drv->assoc_bssid);
1815 hif_drv->usr_conn_req.ssid_len = 0;
1816 kfree(hif_drv->usr_conn_req.ssid);
1817 hif_drv->usr_conn_req.ssid = NULL;
1818 kfree(hif_drv->usr_conn_req.bssid);
1819 hif_drv->usr_conn_req.bssid = NULL;
1820 hif_drv->usr_conn_req.ies_len = 0;
1821 kfree(hif_drv->usr_conn_req.ies);
1822 hif_drv->usr_conn_req.ies = NULL;
1824 if (join_req && join_req_vif == vif) {
1829 if (info_element && join_req_vif == vif) {
1830 kfree(info_element);
1831 info_element = NULL;
1835 complete(&hif_drv->comp_test_disconn_block);
1838 void wilc_resolve_disconnect_aberration(struct wilc_vif *vif)
1842 if ((vif->hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) ||
1843 (vif->hif_drv->hif_state == HOST_IF_CONNECTING))
1844 wilc_disconnect(vif, 1);
1847 static void Handle_GetRssi(struct wilc_vif *vif)
1852 wid.id = (u16)WID_RSSI;
1853 wid.type = WID_CHAR;
1855 wid.size = sizeof(char);
1857 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
1858 wilc_get_vif_idx(vif));
1860 netdev_err(vif->ndev, "Failed to get RSSI value\n");
1864 complete(&vif->hif_drv->comp_get_rssi);
1867 static s32 Handle_GetStatistics(struct wilc_vif *vif,
1868 struct rf_info *pstrStatistics)
1870 struct wid strWIDList[5];
1871 u32 u32WidsCount = 0, result = 0;
1873 strWIDList[u32WidsCount].id = WID_LINKSPEED;
1874 strWIDList[u32WidsCount].type = WID_CHAR;
1875 strWIDList[u32WidsCount].size = sizeof(char);
1876 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->link_speed;
1879 strWIDList[u32WidsCount].id = WID_RSSI;
1880 strWIDList[u32WidsCount].type = WID_CHAR;
1881 strWIDList[u32WidsCount].size = sizeof(char);
1882 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->rssi;
1885 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
1886 strWIDList[u32WidsCount].type = WID_INT;
1887 strWIDList[u32WidsCount].size = sizeof(u32);
1888 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_cnt;
1891 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
1892 strWIDList[u32WidsCount].type = WID_INT;
1893 strWIDList[u32WidsCount].size = sizeof(u32);
1894 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->rx_cnt;
1897 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
1898 strWIDList[u32WidsCount].type = WID_INT;
1899 strWIDList[u32WidsCount].size = sizeof(u32);
1900 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_fail_cnt;
1903 result = wilc_send_config_pkt(vif, GET_CFG, strWIDList,
1905 wilc_get_vif_idx(vif));
1908 netdev_err(vif->ndev, "Failed to send scan parameters\n");
1910 if (pstrStatistics->link_speed > TCP_ACK_FILTER_LINK_SPEED_THRESH &&
1911 pstrStatistics->link_speed != DEFAULT_LINK_SPEED)
1912 wilc_enable_tcp_ack_filter(true);
1913 else if (pstrStatistics->link_speed != DEFAULT_LINK_SPEED)
1914 wilc_enable_tcp_ack_filter(false);
1916 if (pstrStatistics != &vif->wilc->dummy_statistics)
1917 complete(&hif_wait_response);
1921 static s32 Handle_Get_InActiveTime(struct wilc_vif *vif,
1922 struct sta_inactive_t *strHostIfStaInactiveT)
1927 struct host_if_drv *hif_drv = vif->hif_drv;
1929 wid.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
1931 wid.size = ETH_ALEN;
1932 wid.val = kmalloc(wid.size, GFP_KERNEL);
1937 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
1939 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
1940 wilc_get_vif_idx(vif));
1943 netdev_err(vif->ndev, "Failed to SET incative time\n");
1947 wid.id = (u16)WID_GET_INACTIVE_TIME;
1949 wid.val = (s8 *)&inactive_time;
1950 wid.size = sizeof(u32);
1952 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
1953 wilc_get_vif_idx(vif));
1956 netdev_err(vif->ndev, "Failed to get incative time\n");
1960 complete(&hif_drv->comp_inactive_time);
1965 static void Handle_AddBeacon(struct wilc_vif *vif,
1966 struct beacon_attr *pstrSetBeaconParam)
1972 wid.id = (u16)WID_ADD_BEACON;
1974 wid.size = pstrSetBeaconParam->head_len + pstrSetBeaconParam->tail_len + 16;
1975 wid.val = kmalloc(wid.size, GFP_KERNEL);
1979 pu8CurrByte = wid.val;
1980 *pu8CurrByte++ = (pstrSetBeaconParam->interval & 0xFF);
1981 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 8) & 0xFF);
1982 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 16) & 0xFF);
1983 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 24) & 0xFF);
1985 *pu8CurrByte++ = (pstrSetBeaconParam->dtim_period & 0xFF);
1986 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 8) & 0xFF);
1987 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 16) & 0xFF);
1988 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 24) & 0xFF);
1990 *pu8CurrByte++ = (pstrSetBeaconParam->head_len & 0xFF);
1991 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 8) & 0xFF);
1992 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 16) & 0xFF);
1993 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 24) & 0xFF);
1995 memcpy(pu8CurrByte, pstrSetBeaconParam->head, pstrSetBeaconParam->head_len);
1996 pu8CurrByte += pstrSetBeaconParam->head_len;
1998 *pu8CurrByte++ = (pstrSetBeaconParam->tail_len & 0xFF);
1999 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 8) & 0xFF);
2000 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 16) & 0xFF);
2001 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 24) & 0xFF);
2003 if (pstrSetBeaconParam->tail)
2004 memcpy(pu8CurrByte, pstrSetBeaconParam->tail, pstrSetBeaconParam->tail_len);
2005 pu8CurrByte += pstrSetBeaconParam->tail_len;
2007 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2008 wilc_get_vif_idx(vif));
2010 netdev_err(vif->ndev, "Failed to send add beacon\n");
2014 kfree(pstrSetBeaconParam->head);
2015 kfree(pstrSetBeaconParam->tail);
2018 static void Handle_DelBeacon(struct wilc_vif *vif)
2024 wid.id = (u16)WID_DEL_BEACON;
2025 wid.type = WID_CHAR;
2026 wid.size = sizeof(char);
2027 wid.val = &del_beacon;
2032 pu8CurrByte = wid.val;
2034 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2035 wilc_get_vif_idx(vif));
2037 netdev_err(vif->ndev, "Failed to send delete beacon\n");
2040 static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
2041 struct add_sta_param *pstrStationParam)
2045 pu8CurrByte = pu8Buffer;
2047 memcpy(pu8CurrByte, pstrStationParam->bssid, ETH_ALEN);
2048 pu8CurrByte += ETH_ALEN;
2050 *pu8CurrByte++ = pstrStationParam->aid & 0xFF;
2051 *pu8CurrByte++ = (pstrStationParam->aid >> 8) & 0xFF;
2053 *pu8CurrByte++ = pstrStationParam->rates_len;
2054 if (pstrStationParam->rates_len > 0)
2055 memcpy(pu8CurrByte, pstrStationParam->rates,
2056 pstrStationParam->rates_len);
2057 pu8CurrByte += pstrStationParam->rates_len;
2059 *pu8CurrByte++ = pstrStationParam->ht_supported;
2060 *pu8CurrByte++ = pstrStationParam->ht_capa_info & 0xFF;
2061 *pu8CurrByte++ = (pstrStationParam->ht_capa_info >> 8) & 0xFF;
2063 *pu8CurrByte++ = pstrStationParam->ht_ampdu_params;
2064 memcpy(pu8CurrByte, pstrStationParam->ht_supp_mcs_set,
2065 WILC_SUPP_MCS_SET_SIZE);
2066 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
2068 *pu8CurrByte++ = pstrStationParam->ht_ext_params & 0xFF;
2069 *pu8CurrByte++ = (pstrStationParam->ht_ext_params >> 8) & 0xFF;
2071 *pu8CurrByte++ = pstrStationParam->ht_tx_bf_cap & 0xFF;
2072 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 8) & 0xFF;
2073 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 16) & 0xFF;
2074 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 24) & 0xFF;
2076 *pu8CurrByte++ = pstrStationParam->ht_ante_sel;
2078 *pu8CurrByte++ = pstrStationParam->flags_mask & 0xFF;
2079 *pu8CurrByte++ = (pstrStationParam->flags_mask >> 8) & 0xFF;
2081 *pu8CurrByte++ = pstrStationParam->flags_set & 0xFF;
2082 *pu8CurrByte++ = (pstrStationParam->flags_set >> 8) & 0xFF;
2084 return pu8CurrByte - pu8Buffer;
2087 static void Handle_AddStation(struct wilc_vif *vif,
2088 struct add_sta_param *pstrStationParam)
2094 wid.id = (u16)WID_ADD_STA;
2096 wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->rates_len;
2098 wid.val = kmalloc(wid.size, GFP_KERNEL);
2102 pu8CurrByte = wid.val;
2103 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2105 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2106 wilc_get_vif_idx(vif));
2108 netdev_err(vif->ndev, "Failed to send add station\n");
2111 kfree(pstrStationParam->rates);
2115 static void Handle_DelAllSta(struct wilc_vif *vif,
2116 struct del_all_sta *pstrDelAllStaParam)
2122 u8 au8Zero_Buff[6] = {0};
2124 wid.id = (u16)WID_DEL_ALL_STA;
2126 wid.size = (pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1;
2128 wid.val = kmalloc((pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1, GFP_KERNEL);
2132 pu8CurrByte = wid.val;
2134 *(pu8CurrByte++) = pstrDelAllStaParam->assoc_sta;
2136 for (i = 0; i < MAX_NUM_STA; i++) {
2137 if (memcmp(pstrDelAllStaParam->del_all_sta[i], au8Zero_Buff, ETH_ALEN))
2138 memcpy(pu8CurrByte, pstrDelAllStaParam->del_all_sta[i], ETH_ALEN);
2142 pu8CurrByte += ETH_ALEN;
2145 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2146 wilc_get_vif_idx(vif));
2148 netdev_err(vif->ndev, "Failed to send add station\n");
2153 complete(&hif_wait_response);
2156 static void Handle_DelStation(struct wilc_vif *vif,
2157 struct del_sta *pstrDelStaParam)
2163 wid.id = (u16)WID_REMOVE_STA;
2165 wid.size = ETH_ALEN;
2167 wid.val = kmalloc(wid.size, GFP_KERNEL);
2171 pu8CurrByte = wid.val;
2173 memcpy(pu8CurrByte, pstrDelStaParam->mac_addr, ETH_ALEN);
2175 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2176 wilc_get_vif_idx(vif));
2178 netdev_err(vif->ndev, "Failed to send add station\n");
2184 static void Handle_EditStation(struct wilc_vif *vif,
2185 struct add_sta_param *pstrStationParam)
2191 wid.id = (u16)WID_EDIT_STA;
2193 wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->rates_len;
2195 wid.val = kmalloc(wid.size, GFP_KERNEL);
2199 pu8CurrByte = wid.val;
2200 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2202 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2203 wilc_get_vif_idx(vif));
2205 netdev_err(vif->ndev, "Failed to send edit station\n");
2208 kfree(pstrStationParam->rates);
2212 static int Handle_RemainOnChan(struct wilc_vif *vif,
2213 struct remain_ch *pstrHostIfRemainOnChan)
2216 u8 u8remain_on_chan_flag;
2218 struct host_if_drv *hif_drv = vif->hif_drv;
2220 if (!hif_drv->remain_on_ch_pending) {
2221 hif_drv->remain_on_ch.arg = pstrHostIfRemainOnChan->arg;
2222 hif_drv->remain_on_ch.expired = pstrHostIfRemainOnChan->expired;
2223 hif_drv->remain_on_ch.ready = pstrHostIfRemainOnChan->ready;
2224 hif_drv->remain_on_ch.ch = pstrHostIfRemainOnChan->ch;
2225 hif_drv->remain_on_ch.id = pstrHostIfRemainOnChan->id;
2227 pstrHostIfRemainOnChan->ch = hif_drv->remain_on_ch.ch;
2230 if (hif_drv->usr_scan_req.scan_result) {
2231 hif_drv->remain_on_ch_pending = 1;
2235 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
2240 if (wilc_optaining_ip || wilc_connecting) {
2245 u8remain_on_chan_flag = true;
2246 wid.id = (u16)WID_REMAIN_ON_CHAN;
2249 wid.val = kmalloc(wid.size, GFP_KERNEL);
2255 wid.val[0] = u8remain_on_chan_flag;
2256 wid.val[1] = (s8)pstrHostIfRemainOnChan->ch;
2258 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2259 wilc_get_vif_idx(vif));
2261 netdev_err(vif->ndev, "Failed to set remain on channel\n");
2265 P2P_LISTEN_STATE = 1;
2266 hif_drv->remain_on_ch_timer.data = (unsigned long)vif;
2267 mod_timer(&hif_drv->remain_on_ch_timer,
2269 msecs_to_jiffies(pstrHostIfRemainOnChan->duration));
2271 if (hif_drv->remain_on_ch.ready)
2272 hif_drv->remain_on_ch.ready(hif_drv->remain_on_ch.arg);
2274 if (hif_drv->remain_on_ch_pending)
2275 hif_drv->remain_on_ch_pending = 0;
2281 static int Handle_RegisterFrame(struct wilc_vif *vif,
2282 struct reg_frame *pstrHostIfRegisterFrame)
2288 wid.id = (u16)WID_REGISTER_FRAME;
2290 wid.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
2294 pu8CurrByte = wid.val;
2296 *pu8CurrByte++ = pstrHostIfRegisterFrame->reg;
2297 *pu8CurrByte++ = pstrHostIfRegisterFrame->reg_id;
2298 memcpy(pu8CurrByte, &pstrHostIfRegisterFrame->frame_type, sizeof(u16));
2300 wid.size = sizeof(u16) + 2;
2302 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2303 wilc_get_vif_idx(vif));
2305 netdev_err(vif->ndev, "Failed to frame register\n");
2312 static u32 Handle_ListenStateExpired(struct wilc_vif *vif,
2313 struct remain_ch *pstrHostIfRemainOnChan)
2315 u8 u8remain_on_chan_flag;
2318 struct host_if_drv *hif_drv = vif->hif_drv;
2320 if (P2P_LISTEN_STATE) {
2321 u8remain_on_chan_flag = false;
2322 wid.id = (u16)WID_REMAIN_ON_CHAN;
2325 wid.val = kmalloc(wid.size, GFP_KERNEL);
2328 netdev_err(vif->ndev, "Failed to allocate memory\n");
2332 wid.val[0] = u8remain_on_chan_flag;
2333 wid.val[1] = FALSE_FRMWR_CHANNEL;
2335 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2336 wilc_get_vif_idx(vif));
2338 netdev_err(vif->ndev, "Failed to set remain channel\n");
2342 if (hif_drv->remain_on_ch.expired) {
2343 hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.arg,
2344 pstrHostIfRemainOnChan->id);
2346 P2P_LISTEN_STATE = 0;
2348 netdev_dbg(vif->ndev, "Not in listen state\n");
2356 static void ListenTimerCB(unsigned long arg)
2359 struct host_if_msg msg;
2360 struct wilc_vif *vif = (struct wilc_vif *)arg;
2362 del_timer(&vif->hif_drv->remain_on_ch_timer);
2364 memset(&msg, 0, sizeof(struct host_if_msg));
2365 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
2367 msg.body.remain_on_ch.id = vif->hif_drv->remain_on_ch.id;
2369 result = wilc_enqueue_cmd(&msg);
2371 netdev_err(vif->ndev, "wilc_mq_send fail\n");
2374 static void Handle_PowerManagement(struct wilc_vif *vif,
2375 struct power_mgmt_param *strPowerMgmtParam)
2381 wid.id = (u16)WID_POWER_MANAGEMENT;
2383 if (strPowerMgmtParam->enabled)
2384 s8PowerMode = MIN_FAST_PS;
2386 s8PowerMode = NO_POWERSAVE;
2388 wid.val = &s8PowerMode;
2389 wid.size = sizeof(char);
2391 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2392 wilc_get_vif_idx(vif));
2394 netdev_err(vif->ndev, "Failed to send power management\n");
2397 static void Handle_SetMulticastFilter(struct wilc_vif *vif,
2398 struct set_multicast *strHostIfSetMulti)
2404 wid.id = (u16)WID_SETUP_MULTICAST_FILTER;
2406 wid.size = sizeof(struct set_multicast) + ((strHostIfSetMulti->cnt) * ETH_ALEN);
2407 wid.val = kmalloc(wid.size, GFP_KERNEL);
2411 pu8CurrByte = wid.val;
2412 *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF);
2417 *pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF);
2418 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF);
2419 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 16) & 0xFF);
2420 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 24) & 0xFF);
2422 if ((strHostIfSetMulti->cnt) > 0)
2423 memcpy(pu8CurrByte, wilc_multicast_mac_addr_list,
2424 ((strHostIfSetMulti->cnt) * ETH_ALEN));
2426 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2427 wilc_get_vif_idx(vif));
2429 netdev_err(vif->ndev, "Failed to send setup multicast\n");
2435 static void handle_set_tx_pwr(struct wilc_vif *vif, u8 tx_pwr)
2440 wid.id = (u16)WID_TX_POWER;
2441 wid.type = WID_CHAR;
2443 wid.size = sizeof(char);
2445 ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2446 wilc_get_vif_idx(vif));
2448 netdev_err(vif->ndev, "Failed to set TX PWR\n");
2451 static void handle_get_tx_pwr(struct wilc_vif *vif, u8 *tx_pwr)
2456 wid.id = (u16)WID_TX_POWER;
2457 wid.type = WID_CHAR;
2458 wid.val = (s8 *)tx_pwr;
2459 wid.size = sizeof(char);
2461 ret = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
2462 wilc_get_vif_idx(vif));
2464 netdev_err(vif->ndev, "Failed to get TX PWR\n");
2466 complete(&hif_wait_response);
2469 static void host_if_work(struct work_struct *work)
2471 struct host_if_msg *msg;
2474 msg = container_of(work, struct host_if_msg, work);
2475 wilc = msg->vif->wilc;
2477 if (msg->id == HOST_IF_MSG_CONNECT &&
2478 msg->vif->hif_drv->usr_scan_req.scan_result) {
2479 wilc_enqueue_cmd(msg);
2480 usleep_range(2 * 1000, 2 * 1000);
2484 case HOST_IF_MSG_SCAN:
2485 handle_scan(msg->vif, &msg->body.scan_info);
2488 case HOST_IF_MSG_CONNECT:
2489 Handle_Connect(msg->vif, &msg->body.con_info);
2492 case HOST_IF_MSG_RCVD_NTWRK_INFO:
2493 Handle_RcvdNtwrkInfo(msg->vif, &msg->body.net_info);
2496 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
2497 Handle_RcvdGnrlAsyncInfo(msg->vif,
2498 &msg->body.async_info);
2501 case HOST_IF_MSG_KEY:
2502 Handle_Key(msg->vif, &msg->body.key_info);
2505 case HOST_IF_MSG_CFG_PARAMS:
2506 handle_cfg_param(msg->vif, &msg->body.cfg_info);
2509 case HOST_IF_MSG_SET_CHANNEL:
2510 handle_set_channel(msg->vif, &msg->body.channel_info);
2513 case HOST_IF_MSG_DISCONNECT:
2514 Handle_Disconnect(msg->vif);
2517 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
2518 del_timer(&msg->vif->hif_drv->scan_timer);
2520 if (!wilc_wlan_get_num_conn_ifcs(wilc))
2521 wilc_chip_sleep_manually(wilc);
2523 Handle_ScanDone(msg->vif, SCAN_EVENT_DONE);
2525 if (msg->vif->hif_drv->remain_on_ch_pending)
2526 Handle_RemainOnChan(msg->vif,
2527 &msg->body.remain_on_ch);
2531 case HOST_IF_MSG_GET_RSSI:
2532 Handle_GetRssi(msg->vif);
2535 case HOST_IF_MSG_GET_STATISTICS:
2536 Handle_GetStatistics(msg->vif,
2537 (struct rf_info *)msg->body.data);
2540 case HOST_IF_MSG_ADD_BEACON:
2541 Handle_AddBeacon(msg->vif, &msg->body.beacon_info);
2544 case HOST_IF_MSG_DEL_BEACON:
2545 Handle_DelBeacon(msg->vif);
2548 case HOST_IF_MSG_ADD_STATION:
2549 Handle_AddStation(msg->vif, &msg->body.add_sta_info);
2552 case HOST_IF_MSG_DEL_STATION:
2553 Handle_DelStation(msg->vif, &msg->body.del_sta_info);
2556 case HOST_IF_MSG_EDIT_STATION:
2557 Handle_EditStation(msg->vif, &msg->body.edit_sta_info);
2560 case HOST_IF_MSG_GET_INACTIVETIME:
2561 Handle_Get_InActiveTime(msg->vif, &msg->body.mac_info);
2564 case HOST_IF_MSG_SCAN_TIMER_FIRED:
2565 Handle_ScanDone(msg->vif, SCAN_EVENT_ABORTED);
2568 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
2569 Handle_ConnectTimeout(msg->vif);
2572 case HOST_IF_MSG_POWER_MGMT:
2573 Handle_PowerManagement(msg->vif,
2574 &msg->body.pwr_mgmt_info);
2577 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
2578 handle_set_wfi_drv_handler(msg->vif, &msg->body.drv);
2581 case HOST_IF_MSG_SET_OPERATION_MODE:
2582 handle_set_operation_mode(msg->vif, &msg->body.mode);
2585 case HOST_IF_MSG_SET_IPADDRESS:
2586 handle_set_ip_address(msg->vif,
2587 msg->body.ip_info.ip_addr,
2588 msg->body.ip_info.idx);
2591 case HOST_IF_MSG_GET_IPADDRESS:
2592 handle_get_ip_address(msg->vif, msg->body.ip_info.idx);
2595 case HOST_IF_MSG_GET_MAC_ADDRESS:
2596 handle_get_mac_address(msg->vif,
2597 &msg->body.get_mac_info);
2600 case HOST_IF_MSG_REMAIN_ON_CHAN:
2601 Handle_RemainOnChan(msg->vif, &msg->body.remain_on_ch);
2604 case HOST_IF_MSG_REGISTER_FRAME:
2605 Handle_RegisterFrame(msg->vif, &msg->body.reg_frame);
2608 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
2609 Handle_ListenStateExpired(msg->vif, &msg->body.remain_on_ch);
2612 case HOST_IF_MSG_SET_MULTICAST_FILTER:
2613 Handle_SetMulticastFilter(msg->vif, &msg->body.multicast_info);
2616 case HOST_IF_MSG_DEL_ALL_STA:
2617 Handle_DelAllSta(msg->vif, &msg->body.del_all_sta_info);
2620 case HOST_IF_MSG_SET_TX_POWER:
2621 handle_set_tx_pwr(msg->vif, msg->body.tx_power.tx_pwr);
2624 case HOST_IF_MSG_GET_TX_POWER:
2625 handle_get_tx_pwr(msg->vif, &msg->body.tx_power.tx_pwr);
2628 netdev_err(msg->vif->ndev, "[Host Interface] undefined\n");
2633 complete(&hif_thread_comp);
2636 static void TimerCB_Scan(unsigned long arg)
2638 struct wilc_vif *vif = (struct wilc_vif *)arg;
2639 struct host_if_msg msg;
2641 memset(&msg, 0, sizeof(struct host_if_msg));
2643 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
2645 wilc_enqueue_cmd(&msg);
2648 static void TimerCB_Connect(unsigned long arg)
2650 struct wilc_vif *vif = (struct wilc_vif *)arg;
2651 struct host_if_msg msg;
2653 memset(&msg, 0, sizeof(struct host_if_msg));
2655 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
2657 wilc_enqueue_cmd(&msg);
2660 s32 wilc_remove_key(struct host_if_drv *hif_drv, const u8 *pu8StaAddress)
2664 wid.id = (u16)WID_REMOVE_KEY;
2666 wid.val = (s8 *)pu8StaAddress;
2672 int wilc_remove_wep_key(struct wilc_vif *vif, u8 index)
2675 struct host_if_msg msg;
2676 struct host_if_drv *hif_drv = vif->hif_drv;
2680 netdev_err(vif->ndev, "Failed to send setup multicast\n");
2684 memset(&msg, 0, sizeof(struct host_if_msg));
2686 msg.id = HOST_IF_MSG_KEY;
2687 msg.body.key_info.type = WEP;
2688 msg.body.key_info.action = REMOVEKEY;
2690 msg.body.key_info.attr.wep.index = index;
2692 result = wilc_enqueue_cmd(&msg);
2694 netdev_err(vif->ndev, "Request to remove WEP key\n");
2696 wait_for_completion(&hif_drv->comp_test_key_block);
2701 int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index)
2704 struct host_if_msg msg;
2705 struct host_if_drv *hif_drv = vif->hif_drv;
2709 netdev_err(vif->ndev, "driver is null\n");
2713 memset(&msg, 0, sizeof(struct host_if_msg));
2715 msg.id = HOST_IF_MSG_KEY;
2716 msg.body.key_info.type = WEP;
2717 msg.body.key_info.action = DEFAULTKEY;
2719 msg.body.key_info.attr.wep.index = index;
2721 result = wilc_enqueue_cmd(&msg);
2723 netdev_err(vif->ndev, "Default key index\n");
2725 wait_for_completion(&hif_drv->comp_test_key_block);
2730 int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len,
2734 struct host_if_msg msg;
2735 struct host_if_drv *hif_drv = vif->hif_drv;
2738 netdev_err(vif->ndev, "driver is null\n");
2742 memset(&msg, 0, sizeof(struct host_if_msg));
2744 msg.id = HOST_IF_MSG_KEY;
2745 msg.body.key_info.type = WEP;
2746 msg.body.key_info.action = ADDKEY;
2748 msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
2749 if (!msg.body.key_info.attr.wep.key)
2752 msg.body.key_info.attr.wep.key_len = len;
2753 msg.body.key_info.attr.wep.index = index;
2755 result = wilc_enqueue_cmd(&msg);
2757 netdev_err(vif->ndev, "STA - WEP Key\n");
2758 wait_for_completion(&hif_drv->comp_test_key_block);
2763 int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len,
2764 u8 index, u8 mode, enum AUTHTYPE auth_type)
2767 struct host_if_msg msg;
2768 struct host_if_drv *hif_drv = vif->hif_drv;
2771 netdev_err(vif->ndev, "driver is null\n");
2775 memset(&msg, 0, sizeof(struct host_if_msg));
2777 msg.id = HOST_IF_MSG_KEY;
2778 msg.body.key_info.type = WEP;
2779 msg.body.key_info.action = ADDKEY_AP;
2781 msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
2782 if (!msg.body.key_info.attr.wep.key)
2785 msg.body.key_info.attr.wep.key_len = len;
2786 msg.body.key_info.attr.wep.index = index;
2787 msg.body.key_info.attr.wep.mode = mode;
2788 msg.body.key_info.attr.wep.auth_type = auth_type;
2790 result = wilc_enqueue_cmd(&msg);
2793 netdev_err(vif->ndev, "AP - WEP Key\n");
2795 wait_for_completion(&hif_drv->comp_test_key_block);
2800 int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
2801 const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
2802 u8 mode, u8 cipher_mode, u8 index)
2805 struct host_if_msg msg;
2806 struct host_if_drv *hif_drv = vif->hif_drv;
2807 u8 key_len = ptk_key_len;
2810 netdev_err(vif->ndev, "driver is null\n");
2815 key_len += RX_MIC_KEY_LEN;
2818 key_len += TX_MIC_KEY_LEN;
2820 memset(&msg, 0, sizeof(struct host_if_msg));
2822 msg.id = HOST_IF_MSG_KEY;
2823 msg.body.key_info.type = WPA_PTK;
2824 if (mode == AP_MODE) {
2825 msg.body.key_info.action = ADDKEY_AP;
2826 msg.body.key_info.attr.wpa.index = index;
2828 if (mode == STATION_MODE)
2829 msg.body.key_info.action = ADDKEY;
2831 msg.body.key_info.attr.wpa.key = kmemdup(ptk, ptk_key_len, GFP_KERNEL);
2832 if (!msg.body.key_info.attr.wpa.key)
2836 memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic, RX_MIC_KEY_LEN);
2839 memcpy(msg.body.key_info.attr.wpa.key + 24, tx_mic, TX_MIC_KEY_LEN);
2841 msg.body.key_info.attr.wpa.key_len = key_len;
2842 msg.body.key_info.attr.wpa.mac_addr = mac_addr;
2843 msg.body.key_info.attr.wpa.mode = cipher_mode;
2846 result = wilc_enqueue_cmd(&msg);
2849 netdev_err(vif->ndev, "PTK Key\n");
2851 wait_for_completion(&hif_drv->comp_test_key_block);
2856 int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
2857 u8 index, u32 key_rsc_len, const u8 *key_rsc,
2858 const u8 *rx_mic, const u8 *tx_mic, u8 mode,
2862 struct host_if_msg msg;
2863 struct host_if_drv *hif_drv = vif->hif_drv;
2864 u8 key_len = gtk_key_len;
2867 netdev_err(vif->ndev, "driver is null\n");
2870 memset(&msg, 0, sizeof(struct host_if_msg));
2873 key_len += RX_MIC_KEY_LEN;
2876 key_len += TX_MIC_KEY_LEN;
2879 msg.body.key_info.attr.wpa.seq = kmemdup(key_rsc,
2882 if (!msg.body.key_info.attr.wpa.seq)
2886 msg.id = HOST_IF_MSG_KEY;
2887 msg.body.key_info.type = WPA_RX_GTK;
2890 if (mode == AP_MODE) {
2891 msg.body.key_info.action = ADDKEY_AP;
2892 msg.body.key_info.attr.wpa.mode = cipher_mode;
2894 if (mode == STATION_MODE)
2895 msg.body.key_info.action = ADDKEY;
2897 msg.body.key_info.attr.wpa.key = kmemdup(rx_gtk,
2900 if (!msg.body.key_info.attr.wpa.key)
2904 memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic,
2908 memcpy(msg.body.key_info.attr.wpa.key + 24, tx_mic,
2911 msg.body.key_info.attr.wpa.index = index;
2912 msg.body.key_info.attr.wpa.key_len = key_len;
2913 msg.body.key_info.attr.wpa.seq_len = key_rsc_len;
2915 result = wilc_enqueue_cmd(&msg);
2917 netdev_err(vif->ndev, "RX GTK\n");
2919 wait_for_completion(&hif_drv->comp_test_key_block);
2924 int wilc_set_pmkid_info(struct wilc_vif *vif,
2925 struct host_if_pmkid_attr *pmkid)
2928 struct host_if_msg msg;
2931 memset(&msg, 0, sizeof(struct host_if_msg));
2933 msg.id = HOST_IF_MSG_KEY;
2934 msg.body.key_info.type = PMKSA;
2935 msg.body.key_info.action = ADDKEY;
2938 for (i = 0; i < pmkid->numpmkid; i++) {
2939 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].bssid,
2940 &pmkid->pmkidlist[i].bssid, ETH_ALEN);
2941 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].pmkid,
2942 &pmkid->pmkidlist[i].pmkid, PMKID_LEN);
2945 result = wilc_enqueue_cmd(&msg);
2947 netdev_err(vif->ndev, "PMKID Info\n");
2952 int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr)
2955 struct host_if_msg msg;
2957 memset(&msg, 0, sizeof(struct host_if_msg));
2959 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
2960 msg.body.get_mac_info.mac_addr = mac_addr;
2963 result = wilc_enqueue_cmd(&msg);
2965 netdev_err(vif->ndev, "Failed to send get mac address\n");
2969 wait_for_completion(&hif_wait_response);
2973 int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid,
2974 size_t ssid_len, const u8 *ies, size_t ies_len,
2975 wilc_connect_result connect_result, void *user_arg,
2976 u8 security, enum AUTHTYPE auth_type,
2977 u8 channel, void *join_params)
2980 struct host_if_msg msg;
2981 struct host_if_drv *hif_drv = vif->hif_drv;
2983 if (!hif_drv || !connect_result) {
2984 netdev_err(vif->ndev, "Driver is null\n");
2989 netdev_err(vif->ndev, "Unable to Join - JoinParams is NULL\n");
2993 memset(&msg, 0, sizeof(struct host_if_msg));
2995 msg.id = HOST_IF_MSG_CONNECT;
2997 msg.body.con_info.security = security;
2998 msg.body.con_info.auth_type = auth_type;
2999 msg.body.con_info.ch = channel;
3000 msg.body.con_info.result = connect_result;
3001 msg.body.con_info.arg = user_arg;
3002 msg.body.con_info.params = join_params;
3006 msg.body.con_info.bssid = kmemdup(bssid, 6, GFP_KERNEL);
3007 if (!msg.body.con_info.bssid)
3012 msg.body.con_info.ssid_len = ssid_len;
3013 msg.body.con_info.ssid = kmemdup(ssid, ssid_len, GFP_KERNEL);
3014 if (!msg.body.con_info.ssid)
3019 msg.body.con_info.ies_len = ies_len;
3020 msg.body.con_info.ies = kmemdup(ies, ies_len, GFP_KERNEL);
3021 if (!msg.body.con_info.ies)
3024 if (hif_drv->hif_state < HOST_IF_CONNECTING)
3025 hif_drv->hif_state = HOST_IF_CONNECTING;
3027 result = wilc_enqueue_cmd(&msg);
3029 netdev_err(vif->ndev, "send message: Set join request\n");
3033 hif_drv->connect_timer.data = (unsigned long)vif;
3034 mod_timer(&hif_drv->connect_timer,
3035 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
3040 int wilc_disconnect(struct wilc_vif *vif, u16 reason_code)
3043 struct host_if_msg msg;
3044 struct host_if_drv *hif_drv = vif->hif_drv;
3047 netdev_err(vif->ndev, "Driver is null\n");
3051 memset(&msg, 0, sizeof(struct host_if_msg));
3053 msg.id = HOST_IF_MSG_DISCONNECT;
3056 result = wilc_enqueue_cmd(&msg);
3058 netdev_err(vif->ndev, "Failed to send message: disconnect\n");
3060 wait_for_completion(&hif_drv->comp_test_disconn_block);
3065 static s32 host_int_get_assoc_res_info(struct wilc_vif *vif,
3066 u8 *pu8AssocRespInfo,
3067 u32 u32MaxAssocRespInfoLen,
3068 u32 *pu32RcvdAssocRespInfoLen)
3073 wid.id = (u16)WID_ASSOC_RES_INFO;
3075 wid.val = pu8AssocRespInfo;
3076 wid.size = u32MaxAssocRespInfoLen;
3078 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
3079 wilc_get_vif_idx(vif));
3081 *pu32RcvdAssocRespInfoLen = 0;
3082 netdev_err(vif->ndev, "Failed to send association response\n");
3086 *pu32RcvdAssocRespInfoLen = wid.size;
3090 int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel)
3093 struct host_if_msg msg;
3095 memset(&msg, 0, sizeof(struct host_if_msg));
3096 msg.id = HOST_IF_MSG_SET_CHANNEL;
3097 msg.body.channel_info.set_ch = channel;
3100 result = wilc_enqueue_cmd(&msg);
3102 netdev_err(vif->ndev, "wilc mq send fail\n");
3109 int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mac_idx)
3112 struct host_if_msg msg;
3114 memset(&msg, 0, sizeof(struct host_if_msg));
3115 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
3116 msg.body.drv.handler = index;
3117 msg.body.drv.mac_idx = mac_idx;
3120 result = wilc_enqueue_cmd(&msg);
3122 netdev_err(vif->ndev, "wilc mq send fail\n");
3129 int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode)
3132 struct host_if_msg msg;
3134 memset(&msg, 0, sizeof(struct host_if_msg));
3135 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
3136 msg.body.mode.mode = mode;
3139 result = wilc_enqueue_cmd(&msg);
3141 netdev_err(vif->ndev, "wilc mq send fail\n");
3148 s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
3149 u32 *pu32InactiveTime)
3152 struct host_if_msg msg;
3153 struct host_if_drv *hif_drv = vif->hif_drv;
3156 netdev_err(vif->ndev, "driver is null\n");
3160 memset(&msg, 0, sizeof(struct host_if_msg));
3161 memcpy(msg.body.mac_info.mac, mac, ETH_ALEN);
3163 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
3166 result = wilc_enqueue_cmd(&msg);
3168 netdev_err(vif->ndev, "Failed to send get host ch param\n");
3170 wait_for_completion(&hif_drv->comp_inactive_time);
3172 *pu32InactiveTime = inactive_time;
3177 int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level)
3180 struct host_if_msg msg;
3181 struct host_if_drv *hif_drv = vif->hif_drv;
3183 memset(&msg, 0, sizeof(struct host_if_msg));
3184 msg.id = HOST_IF_MSG_GET_RSSI;
3187 result = wilc_enqueue_cmd(&msg);
3189 netdev_err(vif->ndev, "Failed to send get host ch param\n");
3193 wait_for_completion(&hif_drv->comp_get_rssi);
3196 netdev_err(vif->ndev, "RSS pointer value is null\n");
3205 int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats)
3208 struct host_if_msg msg;
3210 memset(&msg, 0, sizeof(struct host_if_msg));
3211 msg.id = HOST_IF_MSG_GET_STATISTICS;
3212 msg.body.data = (char *)stats;
3215 result = wilc_enqueue_cmd(&msg);
3217 netdev_err(vif->ndev, "Failed to send get host channel\n");
3221 if (stats != &vif->wilc->dummy_statistics)
3222 wait_for_completion(&hif_wait_response);
3226 int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
3227 u8 *ch_freq_list, u8 ch_list_len, const u8 *ies,
3228 size_t ies_len, wilc_scan_result scan_result, void *user_arg,
3229 struct hidden_network *hidden_network)
3232 struct host_if_msg msg;
3233 struct scan_attr *scan_info = &msg.body.scan_info;
3234 struct host_if_drv *hif_drv = vif->hif_drv;
3236 if (!hif_drv || !scan_result) {
3237 netdev_err(vif->ndev, "hif_drv or scan_result = NULL\n");
3241 memset(&msg, 0, sizeof(struct host_if_msg));
3243 msg.id = HOST_IF_MSG_SCAN;
3245 if (hidden_network) {
3246 scan_info->hidden_network.net_info = hidden_network->net_info;
3247 scan_info->hidden_network.n_ssids = hidden_network->n_ssids;
3251 scan_info->src = scan_source;
3252 scan_info->type = scan_type;
3253 scan_info->result = scan_result;
3254 scan_info->arg = user_arg;
3256 scan_info->ch_list_len = ch_list_len;
3257 scan_info->ch_freq_list = kmemdup(ch_freq_list,
3260 if (!scan_info->ch_freq_list)
3263 scan_info->ies_len = ies_len;
3264 scan_info->ies = kmemdup(ies, ies_len, GFP_KERNEL);
3265 if (!scan_info->ies)
3268 result = wilc_enqueue_cmd(&msg);
3270 netdev_err(vif->ndev, "Error in sending message queue\n");
3274 hif_drv->scan_timer.data = (unsigned long)vif;
3275 mod_timer(&hif_drv->scan_timer,
3276 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
3281 int wilc_hif_set_cfg(struct wilc_vif *vif,
3282 struct cfg_param_attr *cfg_param)
3284 struct host_if_msg msg;
3285 struct host_if_drv *hif_drv = vif->hif_drv;
3288 netdev_err(vif->ndev, "hif_drv NULL\n");
3292 memset(&msg, 0, sizeof(struct host_if_msg));
3293 msg.id = HOST_IF_MSG_CFG_PARAMS;
3294 msg.body.cfg_info = *cfg_param;
3297 return wilc_enqueue_cmd(&msg);
3300 static void GetPeriodicRSSI(unsigned long arg)
3302 struct wilc_vif *vif = (struct wilc_vif *)arg;
3304 if (!vif->hif_drv) {
3305 netdev_err(vif->ndev, "Driver handler is NULL\n");
3309 if (vif->hif_drv->hif_state == HOST_IF_CONNECTED)
3310 wilc_get_statistics(vif, &vif->wilc->dummy_statistics);
3312 periodic_rssi.data = (unsigned long)vif;
3313 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
3316 int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
3319 struct host_if_drv *hif_drv;
3320 struct wilc_vif *vif;
3324 vif = netdev_priv(dev);
3327 scan_while_connected = false;
3329 init_completion(&hif_wait_response);
3331 hif_drv = kzalloc(sizeof(*hif_drv), GFP_KERNEL);
3336 *hif_drv_handler = hif_drv;
3337 for (i = 0; i < wilc->vif_num; i++)
3338 if (dev == wilc->vif[i]->ndev) {
3339 wilc->vif[i]->hif_drv = hif_drv;
3343 wilc_optaining_ip = false;
3345 if (clients_count == 0) {
3346 init_completion(&hif_thread_comp);
3347 init_completion(&hif_driver_comp);
3348 mutex_init(&hif_deinit_lock);
3351 init_completion(&hif_drv->comp_test_key_block);
3352 init_completion(&hif_drv->comp_test_disconn_block);
3353 init_completion(&hif_drv->comp_get_rssi);
3354 init_completion(&hif_drv->comp_inactive_time);
3356 if (clients_count == 0) {
3358 netdev_err(vif->ndev, "Failed to creat MQ\n");
3361 hif_workqueue = create_singlethread_workqueue("WILC_wq");
3362 if (!hif_workqueue) {
3363 netdev_err(vif->ndev, "Failed to create workqueue\n");
3368 setup_timer(&periodic_rssi, GetPeriodicRSSI,
3369 (unsigned long)vif);
3370 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
3373 setup_timer(&hif_drv->scan_timer, TimerCB_Scan, 0);
3374 setup_timer(&hif_drv->connect_timer, TimerCB_Connect, 0);
3375 setup_timer(&hif_drv->remain_on_ch_timer, ListenTimerCB, 0);
3377 mutex_init(&hif_drv->cfg_values_lock);
3378 mutex_lock(&hif_drv->cfg_values_lock);
3380 hif_drv->hif_state = HOST_IF_IDLE;
3381 hif_drv->cfg_values.site_survey_enabled = SITE_SURVEY_OFF;
3382 hif_drv->cfg_values.scan_source = DEFAULT_SCAN;
3383 hif_drv->cfg_values.active_scan_time = ACTIVE_SCAN_TIME;
3384 hif_drv->cfg_values.passive_scan_time = PASSIVE_SCAN_TIME;
3385 hif_drv->cfg_values.curr_tx_rate = AUTORATE;
3387 hif_drv->p2p_timeout = 0;
3389 mutex_unlock(&hif_drv->cfg_values_lock);
3397 int wilc_deinit(struct wilc_vif *vif)
3400 struct host_if_msg msg;
3401 struct host_if_drv *hif_drv = vif->hif_drv;
3404 netdev_err(vif->ndev, "hif_drv = NULL\n");
3408 mutex_lock(&hif_deinit_lock);
3410 terminated_handle = hif_drv;
3412 del_timer_sync(&hif_drv->scan_timer);
3413 del_timer_sync(&hif_drv->connect_timer);
3414 del_timer_sync(&periodic_rssi);
3415 del_timer_sync(&hif_drv->remain_on_ch_timer);
3417 wilc_set_wfi_drv_handler(vif, 0, 0);
3418 wait_for_completion(&hif_driver_comp);
3420 if (hif_drv->usr_scan_req.scan_result) {
3421 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, NULL,
3422 hif_drv->usr_scan_req.arg, NULL);
3423 hif_drv->usr_scan_req.scan_result = NULL;
3426 hif_drv->hif_state = HOST_IF_IDLE;
3428 scan_while_connected = false;
3430 memset(&msg, 0, sizeof(struct host_if_msg));
3432 if (clients_count == 1) {
3433 msg.id = HOST_IF_MSG_EXIT;
3436 result = wilc_enqueue_cmd(&msg);
3438 netdev_err(vif->ndev, "deinit : Error(%d)\n", result);
3440 wait_for_completion(&hif_thread_comp);
3442 destroy_workqueue(hif_workqueue);
3448 terminated_handle = NULL;
3449 mutex_unlock(&hif_deinit_lock);
3453 void wilc_network_info_received(struct wilc *wilc, u8 *pu8Buffer,
3457 struct host_if_msg msg;
3459 struct host_if_drv *hif_drv = NULL;
3460 struct wilc_vif *vif;
3462 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
3463 vif = wilc_get_vif_from_idx(wilc, id);
3466 hif_drv = vif->hif_drv;
3468 if (!hif_drv || hif_drv == terminated_handle) {
3469 netdev_err(vif->ndev, "driver not init[%p]\n", hif_drv);
3473 memset(&msg, 0, sizeof(struct host_if_msg));
3475 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
3478 msg.body.net_info.len = u32Length;
3479 msg.body.net_info.buffer = kmalloc(u32Length, GFP_KERNEL);
3480 memcpy(msg.body.net_info.buffer, pu8Buffer, u32Length);
3482 result = wilc_enqueue_cmd(&msg);
3484 netdev_err(vif->ndev, "message parameters (%d)\n", result);
3487 void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *pu8Buffer,
3491 struct host_if_msg msg;
3493 struct host_if_drv *hif_drv = NULL;
3494 struct wilc_vif *vif;
3496 mutex_lock(&hif_deinit_lock);
3498 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
3499 vif = wilc_get_vif_from_idx(wilc, id);
3501 mutex_unlock(&hif_deinit_lock);
3505 hif_drv = vif->hif_drv;
3507 if (!hif_drv || hif_drv == terminated_handle) {
3508 mutex_unlock(&hif_deinit_lock);
3512 if (!hif_drv->usr_conn_req.conn_result) {
3513 netdev_err(vif->ndev, "there is no current Connect Request\n");
3514 mutex_unlock(&hif_deinit_lock);
3518 memset(&msg, 0, sizeof(struct host_if_msg));
3520 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
3523 msg.body.async_info.len = u32Length;
3524 msg.body.async_info.buffer = kmalloc(u32Length, GFP_KERNEL);
3525 memcpy(msg.body.async_info.buffer, pu8Buffer, u32Length);
3527 result = wilc_enqueue_cmd(&msg);
3529 netdev_err(vif->ndev, "synchronous info (%d)\n", result);
3531 mutex_unlock(&hif_deinit_lock);
3534 void wilc_scan_complete_received(struct wilc *wilc, u8 *pu8Buffer,
3538 struct host_if_msg msg;
3540 struct host_if_drv *hif_drv = NULL;
3541 struct wilc_vif *vif;
3543 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
3544 vif = wilc_get_vif_from_idx(wilc, id);
3547 hif_drv = vif->hif_drv;
3549 if (!hif_drv || hif_drv == terminated_handle)
3552 if (hif_drv->usr_scan_req.scan_result) {
3553 memset(&msg, 0, sizeof(struct host_if_msg));
3555 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
3558 result = wilc_enqueue_cmd(&msg);
3560 netdev_err(vif->ndev, "complete param (%d)\n", result);
3564 int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id,
3565 u32 duration, u16 chan,
3566 wilc_remain_on_chan_expired expired,
3567 wilc_remain_on_chan_ready ready,
3571 struct host_if_msg msg;
3573 memset(&msg, 0, sizeof(struct host_if_msg));
3575 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
3576 msg.body.remain_on_ch.ch = chan;
3577 msg.body.remain_on_ch.expired = expired;
3578 msg.body.remain_on_ch.ready = ready;
3579 msg.body.remain_on_ch.arg = user_arg;
3580 msg.body.remain_on_ch.duration = duration;
3581 msg.body.remain_on_ch.id = session_id;
3584 result = wilc_enqueue_cmd(&msg);
3586 netdev_err(vif->ndev, "wilc mq send fail\n");
3591 int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id)
3594 struct host_if_msg msg;
3595 struct host_if_drv *hif_drv = vif->hif_drv;
3598 netdev_err(vif->ndev, "driver is null\n");
3602 del_timer(&hif_drv->remain_on_ch_timer);
3604 memset(&msg, 0, sizeof(struct host_if_msg));
3605 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
3607 msg.body.remain_on_ch.id = session_id;
3609 result = wilc_enqueue_cmd(&msg);
3611 netdev_err(vif->ndev, "wilc mq send fail\n");
3616 int wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg)
3619 struct host_if_msg msg;
3621 memset(&msg, 0, sizeof(struct host_if_msg));
3623 msg.id = HOST_IF_MSG_REGISTER_FRAME;
3624 switch (frame_type) {
3626 msg.body.reg_frame.reg_id = ACTION_FRM_IDX;
3630 msg.body.reg_frame.reg_id = PROBE_REQ_IDX;
3636 msg.body.reg_frame.frame_type = frame_type;
3637 msg.body.reg_frame.reg = reg;
3640 result = wilc_enqueue_cmd(&msg);
3642 netdev_err(vif->ndev, "wilc mq send fail\n");
3647 int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period,
3648 u32 head_len, u8 *head, u32 tail_len, u8 *tail)
3651 struct host_if_msg msg;
3652 struct beacon_attr *beacon_info = &msg.body.beacon_info;
3654 memset(&msg, 0, sizeof(struct host_if_msg));
3656 msg.id = HOST_IF_MSG_ADD_BEACON;
3658 beacon_info->interval = interval;
3659 beacon_info->dtim_period = dtim_period;
3660 beacon_info->head_len = head_len;
3661 beacon_info->head = kmemdup(head, head_len, GFP_KERNEL);
3662 if (!beacon_info->head) {
3666 beacon_info->tail_len = tail_len;
3669 beacon_info->tail = kmemdup(tail, tail_len, GFP_KERNEL);
3670 if (!beacon_info->tail) {
3675 beacon_info->tail = NULL;
3678 result = wilc_enqueue_cmd(&msg);
3680 netdev_err(vif->ndev, "wilc mq send fail\n");
3684 kfree(beacon_info->head);
3686 kfree(beacon_info->tail);
3692 int wilc_del_beacon(struct wilc_vif *vif)
3695 struct host_if_msg msg;
3697 msg.id = HOST_IF_MSG_DEL_BEACON;
3700 result = wilc_enqueue_cmd(&msg);
3702 netdev_err(vif->ndev, "wilc_mq_send fail\n");
3707 int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param)
3710 struct host_if_msg msg;
3711 struct add_sta_param *add_sta_info = &msg.body.add_sta_info;
3713 memset(&msg, 0, sizeof(struct host_if_msg));
3715 msg.id = HOST_IF_MSG_ADD_STATION;
3718 memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param));
3719 if (add_sta_info->rates_len > 0) {
3720 add_sta_info->rates = kmemdup(sta_param->rates,
3721 add_sta_info->rates_len,
3723 if (!add_sta_info->rates)
3727 result = wilc_enqueue_cmd(&msg);
3729 netdev_err(vif->ndev, "wilc_mq_send fail\n");
3733 int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr)
3736 struct host_if_msg msg;
3737 struct del_sta *del_sta_info = &msg.body.del_sta_info;
3739 memset(&msg, 0, sizeof(struct host_if_msg));
3741 msg.id = HOST_IF_MSG_DEL_STATION;
3745 eth_broadcast_addr(del_sta_info->mac_addr);
3747 memcpy(del_sta_info->mac_addr, mac_addr, ETH_ALEN);
3749 result = wilc_enqueue_cmd(&msg);
3751 netdev_err(vif->ndev, "wilc_mq_send fail\n");
3755 int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN])
3758 struct host_if_msg msg;
3759 struct del_all_sta *del_all_sta_info = &msg.body.del_all_sta_info;
3760 u8 zero_addr[ETH_ALEN] = {0};
3764 memset(&msg, 0, sizeof(struct host_if_msg));
3766 msg.id = HOST_IF_MSG_DEL_ALL_STA;
3769 for (i = 0; i < MAX_NUM_STA; i++) {
3770 if (memcmp(mac_addr[i], zero_addr, ETH_ALEN)) {
3771 memcpy(del_all_sta_info->del_all_sta[i], mac_addr[i], ETH_ALEN);
3778 del_all_sta_info->assoc_sta = assoc_sta;
3779 result = wilc_enqueue_cmd(&msg);
3782 netdev_err(vif->ndev, "wilc_mq_send fail\n");
3784 wait_for_completion(&hif_wait_response);
3789 int wilc_edit_station(struct wilc_vif *vif,
3790 struct add_sta_param *sta_param)
3793 struct host_if_msg msg;
3794 struct add_sta_param *add_sta_info = &msg.body.add_sta_info;
3796 memset(&msg, 0, sizeof(struct host_if_msg));
3798 msg.id = HOST_IF_MSG_EDIT_STATION;
3801 memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param));
3802 if (add_sta_info->rates_len > 0) {
3803 add_sta_info->rates = kmemdup(sta_param->rates,
3804 add_sta_info->rates_len,
3806 if (!add_sta_info->rates)
3810 result = wilc_enqueue_cmd(&msg);
3812 netdev_err(vif->ndev, "wilc_mq_send fail\n");
3817 int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout)
3820 struct host_if_msg msg;
3821 struct power_mgmt_param *pwr_mgmt_info = &msg.body.pwr_mgmt_info;
3823 if (wilc_wlan_get_num_conn_ifcs(vif->wilc) == 2 && enabled)
3826 memset(&msg, 0, sizeof(struct host_if_msg));
3828 msg.id = HOST_IF_MSG_POWER_MGMT;
3831 pwr_mgmt_info->enabled = enabled;
3832 pwr_mgmt_info->timeout = timeout;
3834 result = wilc_enqueue_cmd(&msg);
3836 netdev_err(vif->ndev, "wilc_mq_send fail\n");
3840 int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled,
3844 struct host_if_msg msg;
3845 struct set_multicast *multicast_filter_param = &msg.body.multicast_info;
3847 memset(&msg, 0, sizeof(struct host_if_msg));
3849 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
3852 multicast_filter_param->enabled = enabled;
3853 multicast_filter_param->cnt = count;
3855 result = wilc_enqueue_cmd(&msg);
3857 netdev_err(vif->ndev, "wilc_mq_send fail\n");
3861 static void *host_int_ParseJoinBssParam(struct network_info *ptstrNetworkInfo)
3863 struct join_bss_param *pNewJoinBssParam = NULL;
3872 u8 pcipherTotalCount = 0;
3873 u8 authTotalCount = 0;
3876 pu8IEs = ptstrNetworkInfo->ies;
3877 u16IEsLen = ptstrNetworkInfo->ies_len;
3879 pNewJoinBssParam = kzalloc(sizeof(*pNewJoinBssParam), GFP_KERNEL);
3880 if (pNewJoinBssParam) {
3881 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->dtim_period;
3882 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->beacon_period;
3883 pNewJoinBssParam->cap_info = ptstrNetworkInfo->cap_info;
3884 memcpy(pNewJoinBssParam->bssid, ptstrNetworkInfo->bssid, 6);
3885 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->ssid,
3886 ptstrNetworkInfo->ssid_len + 1);
3887 pNewJoinBssParam->ssid_len = ptstrNetworkInfo->ssid_len;
3888 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
3889 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
3891 while (index < u16IEsLen) {
3892 if (pu8IEs[index] == SUPP_RATES_IE) {
3893 suppRatesNo = pu8IEs[index + 1];
3894 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
3897 for (i = 0; i < suppRatesNo; i++)
3898 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
3900 index += suppRatesNo;
3902 } else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
3903 extSuppRatesNo = pu8IEs[index + 1];
3904 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
3905 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
3907 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
3909 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++)
3910 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
3912 index += extSuppRatesNo;
3914 } else if (pu8IEs[index] == HT_CAPABILITY_IE) {
3915 pNewJoinBssParam->ht_capable = true;
3916 index += pu8IEs[index + 1] + 2;
3918 } else if ((pu8IEs[index] == WMM_IE) &&
3919 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
3920 (pu8IEs[index + 4] == 0xF2) &&
3921 (pu8IEs[index + 5] == 0x02) &&
3922 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) &&
3923 (pu8IEs[index + 7] == 0x01)) {
3924 pNewJoinBssParam->wmm_cap = true;
3926 if (pu8IEs[index + 8] & BIT(7))
3927 pNewJoinBssParam->uapsd_cap = true;
3928 index += pu8IEs[index + 1] + 2;
3930 } else if ((pu8IEs[index] == P2P_IE) &&
3931 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
3932 (pu8IEs[index + 4] == 0x9a) &&
3933 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) {
3936 pNewJoinBssParam->tsf = ptstrNetworkInfo->tsf_lo;
3937 pNewJoinBssParam->noa_enabled = 1;
3938 pNewJoinBssParam->idx = pu8IEs[index + 9];
3940 if (pu8IEs[index + 10] & BIT(7)) {
3941 pNewJoinBssParam->opp_enabled = 1;
3942 pNewJoinBssParam->ct_window = pu8IEs[index + 10];
3944 pNewJoinBssParam->opp_enabled = 0;
3947 pNewJoinBssParam->cnt = pu8IEs[index + 11];
3948 u16P2P_count = index + 12;
3950 memcpy(pNewJoinBssParam->duration, pu8IEs + u16P2P_count, 4);
3953 memcpy(pNewJoinBssParam->interval, pu8IEs + u16P2P_count, 4);
3956 memcpy(pNewJoinBssParam->start_time, pu8IEs + u16P2P_count, 4);
3958 index += pu8IEs[index + 1] + 2;
3961 } else if ((pu8IEs[index] == RSN_IE) ||
3962 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
3963 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
3964 (pu8IEs[index + 5] == 0x01))) {
3965 u16 rsnIndex = index;
3967 if (pu8IEs[rsnIndex] == RSN_IE) {
3968 pNewJoinBssParam->mode_802_11i = 2;
3970 if (pNewJoinBssParam->mode_802_11i == 0)
3971 pNewJoinBssParam->mode_802_11i = 1;
3976 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
3978 jumpOffset = pu8IEs[rsnIndex] * 4;
3979 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
3982 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++)
3983 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
3985 pcipherTotalCount += pcipherCount;
3986 rsnIndex += jumpOffset;
3988 jumpOffset = pu8IEs[rsnIndex] * 4;
3990 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
3993 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++)
3994 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
3996 authTotalCount += authCount;
3997 rsnIndex += jumpOffset;
3999 if (pu8IEs[index] == RSN_IE) {
4000 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
4001 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
4004 pNewJoinBssParam->rsn_found = true;
4005 index += pu8IEs[index + 1] + 2;
4008 index += pu8IEs[index + 1] + 2;
4012 return (void *)pNewJoinBssParam;
4015 int wilc_setup_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx)
4018 struct host_if_msg msg;
4020 memset(&msg, 0, sizeof(struct host_if_msg));
4022 msg.id = HOST_IF_MSG_SET_IPADDRESS;
4024 msg.body.ip_info.ip_addr = ip_addr;
4026 msg.body.ip_info.idx = idx;
4028 result = wilc_enqueue_cmd(&msg);
4030 netdev_err(vif->ndev, "wilc_mq_send fail\n");
4035 static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx)
4038 struct host_if_msg msg;
4040 memset(&msg, 0, sizeof(struct host_if_msg));
4042 msg.id = HOST_IF_MSG_GET_IPADDRESS;
4044 msg.body.ip_info.ip_addr = ip_addr;
4046 msg.body.ip_info.idx = idx;
4048 result = wilc_enqueue_cmd(&msg);
4050 netdev_err(vif->ndev, "wilc_mq_send fail\n");
4055 int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power)
4058 struct host_if_msg msg;
4060 memset(&msg, 0, sizeof(struct host_if_msg));
4062 msg.id = HOST_IF_MSG_SET_TX_POWER;
4063 msg.body.tx_power.tx_pwr = tx_power;
4066 ret = wilc_enqueue_cmd(&msg);
4068 netdev_err(vif->ndev, "wilc_mq_send fail\n");
4073 int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power)
4076 struct host_if_msg msg;
4078 memset(&msg, 0, sizeof(struct host_if_msg));
4080 msg.id = HOST_IF_MSG_GET_TX_POWER;
4083 ret = wilc_enqueue_cmd(&msg);
4085 netdev_err(vif->ndev, "Failed to get TX PWR\n");
4087 wait_for_completion(&hif_wait_response);
4088 *tx_power = msg.body.tx_power.tx_pwr;