1 #include <linux/slab.h>
2 #include <linux/time.h>
3 #include <linux/kthread.h>
4 #include <linux/delay.h>
5 #include "host_interface.h"
6 #include "coreconfigurator.h"
7 #include "wilc_wlan_if.h"
8 #include "wilc_msgqueue.h"
9 #include <linux/etherdevice.h>
10 #include "wilc_wfi_netdevice.h"
14 extern struct timer_list hDuringIpTimer;
16 extern u8 g_wilc_initialized;
18 #define HOST_IF_MSG_SCAN 0
19 #define HOST_IF_MSG_CONNECT 1
20 #define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
21 #define HOST_IF_MSG_KEY 3
22 #define HOST_IF_MSG_RCVD_NTWRK_INFO 4
23 #define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
24 #define HOST_IF_MSG_CFG_PARAMS 6
25 #define HOST_IF_MSG_SET_CHANNEL 7
26 #define HOST_IF_MSG_DISCONNECT 8
27 #define HOST_IF_MSG_GET_RSSI 9
28 #define HOST_IF_MSG_GET_CHNL 10
29 #define HOST_IF_MSG_ADD_BEACON 11
30 #define HOST_IF_MSG_DEL_BEACON 12
31 #define HOST_IF_MSG_ADD_STATION 13
32 #define HOST_IF_MSG_DEL_STATION 14
33 #define HOST_IF_MSG_EDIT_STATION 15
34 #define HOST_IF_MSG_SCAN_TIMER_FIRED 16
35 #define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
36 #define HOST_IF_MSG_POWER_MGMT 18
37 #define HOST_IF_MSG_GET_INACTIVETIME 19
38 #define HOST_IF_MSG_REMAIN_ON_CHAN 20
39 #define HOST_IF_MSG_REGISTER_FRAME 21
40 #define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
41 #define HOST_IF_MSG_GET_LINKSPEED 23
42 #define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
43 #define HOST_IF_MSG_SET_MAC_ADDRESS 25
44 #define HOST_IF_MSG_GET_MAC_ADDRESS 26
45 #define HOST_IF_MSG_SET_OPERATION_MODE 27
46 #define HOST_IF_MSG_SET_IPADDRESS 28
47 #define HOST_IF_MSG_GET_IPADDRESS 29
48 #define HOST_IF_MSG_FLUSH_CONNECT 30
49 #define HOST_IF_MSG_GET_STATISTICS 31
50 #define HOST_IF_MSG_SET_MULTICAST_FILTER 32
51 #define HOST_IF_MSG_ADD_BA_SESSION 33
52 #define HOST_IF_MSG_DEL_BA_SESSION 34
53 #define HOST_IF_MSG_Q_IDLE 35
54 #define HOST_IF_MSG_DEL_ALL_STA 36
55 #define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
56 #define HOST_IF_MSG_EXIT 100
58 #define HOST_IF_SCAN_TIMEOUT 4000
59 #define HOST_IF_CONNECT_TIMEOUT 9500
61 #define BA_SESSION_DEFAULT_BUFFER_SIZE 16
62 #define BA_SESSION_DEFAULT_TIMEOUT 1000
63 #define BLOCK_ACK_REQ_SIZE 0x14
64 #define FALSE_FRMWR_CHANNEL 100
66 struct cfg_param_attr {
67 struct cfg_param_val cfg_attr_info;
70 struct host_if_wpa_attr {
80 struct host_if_wep_attr {
85 enum AUTHTYPE auth_type;
88 union host_if_key_attr {
89 struct host_if_wep_attr wep;
90 struct host_if_wpa_attr wpa;
91 struct host_if_pmkid_attr pmkid;
97 union host_if_key_attr attr;
107 wilc_scan_result result;
109 struct hidden_network hidden_network;
112 struct connect_attr {
119 wilc_connect_result result;
121 enum AUTHTYPE auth_type;
126 struct rcvd_async_info {
131 struct channel_attr {
144 struct set_multicast {
150 u8 del_all_sta[MAX_NUM_STA][ETH_ALEN];
155 u8 mac_addr[ETH_ALEN];
158 struct power_mgmt_param {
168 struct sta_inactive_t {
173 struct scan_attr scan_info;
174 struct connect_attr con_info;
175 struct rcvd_net_info net_info;
176 struct rcvd_async_info async_info;
177 struct key_attr key_info;
178 struct cfg_param_attr cfg_info;
179 struct channel_attr channel_info;
180 struct beacon_attr beacon_info;
181 struct add_sta_param add_sta_info;
182 struct del_sta del_sta_info;
183 struct add_sta_param edit_sta_info;
184 struct power_mgmt_param pwr_mgmt_info;
185 struct sta_inactive_t mac_info;
186 struct set_ip_addr ip_info;
187 struct drv_handler drv;
188 struct set_multicast multicast_info;
190 struct set_mac_addr set_mac_info;
191 struct get_mac_addr get_mac_info;
192 struct ba_session_info session_info;
193 struct remain_ch remain_on_ch;
194 struct reg_frame reg_frame;
196 struct del_all_sta del_all_sta_info;
201 union message_body body;
202 struct host_if_drv *drv;
205 struct join_bss_param {
211 char ssid[MAX_SSID_LEN];
213 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
220 u8 rsn_pcip_policy[3];
221 u8 rsn_auth_policy[3];
234 static struct host_if_drv *wfidrv_list[NUM_CONCURRENT_IFC + 1];
235 struct host_if_drv *terminated_handle;
238 static struct task_struct *hif_thread_handler;
239 static WILC_MsgQueueHandle hif_msg_q;
240 static struct semaphore hif_sema_thread;
241 static struct semaphore hif_sema_driver;
242 static struct semaphore hif_sema_wait_response;
243 static struct semaphore hif_sema_deinit;
244 static struct timer_list periodic_rssi;
246 u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
248 static u8 rcv_assoc_resp[MAX_ASSOC_RESP_FRAME_SIZE];
250 static bool scan_while_connected;
253 static s8 link_speed;
255 static u8 set_ip[2][4];
256 static u8 get_ip[2][4];
257 static u32 inactive_time;
258 static u8 del_beacon;
259 static u32 clients_count;
266 static u32 info_element_size;
267 static struct host_if_drv *join_req_drv;
268 #define REAL_JOIN_REQ 0
269 #define FLUSHED_JOIN_REQ 1
270 #define FLUSHED_BYTE_POS 79
272 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
274 extern void chip_sleep_manually(u32 u32SleepTime);
275 extern int linux_wlan_get_num_conn_ifcs(void);
277 static int add_handler_in_list(struct host_if_drv *handler)
281 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
282 if (!wfidrv_list[i]) {
283 wfidrv_list[i] = handler;
291 static int remove_handler_in_list(struct host_if_drv *handler)
295 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
296 if (wfidrv_list[i] == handler) {
297 wfidrv_list[i] = NULL;
305 static int get_id_from_handler(struct host_if_drv *handler)
312 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
313 if (wfidrv_list[i] == handler)
320 static struct host_if_drv *get_handler_from_id(int id)
322 if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list))
324 return wfidrv_list[id];
327 static s32 Handle_SetChannel(struct host_if_drv *hif_drv,
328 struct channel_attr *pstrHostIFSetChan)
333 wid.id = (u16)WID_CURRENT_CHANNEL;
335 wid.val = (char *)&pstrHostIFSetChan->set_ch;
336 wid.size = sizeof(char);
338 PRINT_D(HOSTINF_DBG, "Setting channel\n");
340 result = send_config_pkt(SET_CFG, &wid, 1,
341 get_id_from_handler(hif_drv));
344 PRINT_ER("Failed to set channel\n");
351 static s32 Handle_SetWfiDrvHandler(struct host_if_drv *hif_drv,
352 struct drv_handler *pstrHostIfSetDrvHandler)
357 wid.id = (u16)WID_SET_DRV_HANDLER;
359 wid.val = (s8 *)&pstrHostIfSetDrvHandler->handler;
360 wid.size = sizeof(u32);
362 result = send_config_pkt(SET_CFG, &wid, 1,
363 pstrHostIfSetDrvHandler->handler);
366 up(&hif_sema_driver);
369 PRINT_ER("Failed to set driver handler\n");
376 static s32 Handle_SetOperationMode(struct host_if_drv *hif_drv,
377 struct op_mode *pstrHostIfSetOperationMode)
382 wid.id = (u16)WID_SET_OPERATION_MODE;
384 wid.val = (s8 *)&pstrHostIfSetOperationMode->mode;
385 wid.size = sizeof(u32);
387 result = send_config_pkt(SET_CFG, &wid, 1,
388 get_id_from_handler(hif_drv));
390 if ((pstrHostIfSetOperationMode->mode) == IDLE_MODE)
391 up(&hif_sema_driver);
394 PRINT_ER("Failed to set driver handler\n");
401 s32 Handle_set_IPAddress(struct host_if_drv *hif_drv, u8 *pu8IPAddr, u8 idx)
405 char firmwareIPAddress[4] = {0};
407 if (pu8IPAddr[0] < 192)
410 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n", idx, pu8IPAddr);
412 memcpy(set_ip[idx], pu8IPAddr, IP_ALEN);
414 wid.id = (u16)WID_IP_ADDRESS;
416 wid.val = (u8 *)pu8IPAddr;
419 result = send_config_pkt(SET_CFG, &wid, 1,
420 get_id_from_handler(hif_drv));
422 host_int_get_ipaddress(hif_drv, firmwareIPAddress, idx);
425 PRINT_ER("Failed to set IP address\n");
429 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
434 s32 Handle_get_IPAddress(struct host_if_drv *hif_drv, u8 *pu8IPAddr, u8 idx)
439 wid.id = (u16)WID_IP_ADDRESS;
441 wid.val = kmalloc(IP_ALEN, GFP_KERNEL);
444 result = send_config_pkt(GET_CFG, &wid, 1,
445 get_id_from_handler(hif_drv));
447 PRINT_INFO(HOSTINF_DBG, "%pI4\n", wid.val);
449 memcpy(get_ip[idx], wid.val, IP_ALEN);
453 if (memcmp(get_ip[idx], set_ip[idx], IP_ALEN) != 0)
454 host_int_setup_ipaddress(hif_drv, set_ip[idx], idx);
457 PRINT_ER("Failed to get IP address\n");
461 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
462 PRINT_INFO(HOSTINF_DBG, "%pI4\n", get_ip[idx]);
463 PRINT_INFO(HOSTINF_DBG, "\n");
468 static s32 Handle_SetMacAddress(struct host_if_drv *hif_drv,
469 struct set_mac_addr *pstrHostIfSetMacAddress)
473 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
476 PRINT_ER("No buffer to send mac address\n");
479 memcpy(mac_buf, pstrHostIfSetMacAddress->mac_addr, ETH_ALEN);
481 wid.id = (u16)WID_MAC_ADDR;
485 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", wid.val);
487 result = send_config_pkt(SET_CFG, &wid, 1,
488 get_id_from_handler(hif_drv));
490 PRINT_ER("Failed to set mac address\n");
498 static s32 Handle_GetMacAddress(struct host_if_drv *hif_drv,
499 struct get_mac_addr *pstrHostIfGetMacAddress)
504 wid.id = (u16)WID_MAC_ADDR;
506 wid.val = pstrHostIfGetMacAddress->mac_addr;
509 result = send_config_pkt(GET_CFG, &wid, 1,
510 get_id_from_handler(hif_drv));
513 PRINT_ER("Failed to get mac address\n");
516 up(&hif_sema_wait_response);
521 static s32 Handle_CfgParam(struct host_if_drv *hif_drv,
522 struct cfg_param_attr *strHostIFCfgParamAttr)
525 struct wid strWIDList[32];
528 down(&hif_drv->gtOsCfgValuesSem);
530 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
532 if (strHostIFCfgParamAttr->cfg_attr_info.flag & BSS_TYPE) {
533 if (strHostIFCfgParamAttr->cfg_attr_info.bss_type < 6) {
534 strWIDList[u8WidCnt].id = WID_BSS_TYPE;
535 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.bss_type;
536 strWIDList[u8WidCnt].type = WID_CHAR;
537 strWIDList[u8WidCnt].size = sizeof(char);
538 hif_drv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->cfg_attr_info.bss_type;
540 PRINT_ER("check value 6 over\n");
546 if (strHostIFCfgParamAttr->cfg_attr_info.flag & AUTH_TYPE) {
547 if ((strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 1 || (strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 2 || (strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 5) {
548 strWIDList[u8WidCnt].id = WID_AUTH_TYPE;
549 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.auth_type;
550 strWIDList[u8WidCnt].type = WID_CHAR;
551 strWIDList[u8WidCnt].size = sizeof(char);
552 hif_drv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->cfg_attr_info.auth_type;
554 PRINT_ER("Impossible value \n");
560 if (strHostIFCfgParamAttr->cfg_attr_info.flag & AUTHEN_TIMEOUT) {
561 if (strHostIFCfgParamAttr->cfg_attr_info.auth_timeout > 0 && strHostIFCfgParamAttr->cfg_attr_info.auth_timeout < 65536) {
562 strWIDList[u8WidCnt].id = WID_AUTH_TIMEOUT;
563 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.auth_timeout;
564 strWIDList[u8WidCnt].type = WID_SHORT;
565 strWIDList[u8WidCnt].size = sizeof(u16);
566 hif_drv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->cfg_attr_info.auth_timeout;
568 PRINT_ER("Range(1 ~ 65535) over\n");
574 if (strHostIFCfgParamAttr->cfg_attr_info.flag & POWER_MANAGEMENT) {
575 if (strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode < 5) {
576 strWIDList[u8WidCnt].id = WID_POWER_MANAGEMENT;
577 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode;
578 strWIDList[u8WidCnt].type = WID_CHAR;
579 strWIDList[u8WidCnt].size = sizeof(char);
580 hif_drv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode;
582 PRINT_ER("Invalide power mode\n");
588 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RETRY_SHORT) {
589 if ((strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit > 0) && (strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit < 256)) {
590 strWIDList[u8WidCnt].id = WID_SHORT_RETRY_LIMIT;
591 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit;
592 strWIDList[u8WidCnt].type = WID_SHORT;
593 strWIDList[u8WidCnt].size = sizeof(u16);
594 hif_drv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit;
596 PRINT_ER("Range(1~256) over\n");
602 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RETRY_LONG) {
603 if ((strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit > 0) && (strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit < 256)) {
604 strWIDList[u8WidCnt].id = WID_LONG_RETRY_LIMIT;
605 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit;
607 strWIDList[u8WidCnt].type = WID_SHORT;
608 strWIDList[u8WidCnt].size = sizeof(u16);
609 hif_drv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit;
611 PRINT_ER("Range(1~256) over\n");
617 if (strHostIFCfgParamAttr->cfg_attr_info.flag & FRAG_THRESHOLD) {
618 if (strHostIFCfgParamAttr->cfg_attr_info.frag_threshold > 255 && strHostIFCfgParamAttr->cfg_attr_info.frag_threshold < 7937) {
619 strWIDList[u8WidCnt].id = WID_FRAG_THRESHOLD;
620 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.frag_threshold;
621 strWIDList[u8WidCnt].type = WID_SHORT;
622 strWIDList[u8WidCnt].size = sizeof(u16);
623 hif_drv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->cfg_attr_info.frag_threshold;
625 PRINT_ER("Threshold Range fail\n");
631 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RTS_THRESHOLD) {
632 if (strHostIFCfgParamAttr->cfg_attr_info.rts_threshold > 255 && strHostIFCfgParamAttr->cfg_attr_info.rts_threshold < 65536) {
633 strWIDList[u8WidCnt].id = WID_RTS_THRESHOLD;
634 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.rts_threshold;
635 strWIDList[u8WidCnt].type = WID_SHORT;
636 strWIDList[u8WidCnt].size = sizeof(u16);
637 hif_drv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->cfg_attr_info.rts_threshold;
639 PRINT_ER("Threshold Range fail\n");
645 if (strHostIFCfgParamAttr->cfg_attr_info.flag & PREAMBLE) {
646 if (strHostIFCfgParamAttr->cfg_attr_info.preamble_type < 3) {
647 strWIDList[u8WidCnt].id = WID_PREAMBLE;
648 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.preamble_type;
649 strWIDList[u8WidCnt].type = WID_CHAR;
650 strWIDList[u8WidCnt].size = sizeof(char);
651 hif_drv->strCfgValues.preamble_type = strHostIFCfgParamAttr->cfg_attr_info.preamble_type;
653 PRINT_ER("Preamle Range(0~2) over\n");
659 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SHORT_SLOT_ALLOWED) {
660 if (strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed < 2) {
661 strWIDList[u8WidCnt].id = WID_SHORT_SLOT_ALLOWED;
662 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed;
663 strWIDList[u8WidCnt].type = WID_CHAR;
664 strWIDList[u8WidCnt].size = sizeof(char);
665 hif_drv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed;
667 PRINT_ER("Short slot(2) over\n");
673 if (strHostIFCfgParamAttr->cfg_attr_info.flag & TXOP_PROT_DISABLE) {
674 if (strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled < 2) {
675 strWIDList[u8WidCnt].id = WID_11N_TXOP_PROT_DISABLE;
676 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled;
677 strWIDList[u8WidCnt].type = WID_CHAR;
678 strWIDList[u8WidCnt].size = sizeof(char);
679 hif_drv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled;
681 PRINT_ER("TXOP prot disable\n");
687 if (strHostIFCfgParamAttr->cfg_attr_info.flag & BEACON_INTERVAL) {
688 if (strHostIFCfgParamAttr->cfg_attr_info.beacon_interval > 0 && strHostIFCfgParamAttr->cfg_attr_info.beacon_interval < 65536) {
689 strWIDList[u8WidCnt].id = WID_BEACON_INTERVAL;
690 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.beacon_interval;
691 strWIDList[u8WidCnt].type = WID_SHORT;
692 strWIDList[u8WidCnt].size = sizeof(u16);
693 hif_drv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->cfg_attr_info.beacon_interval;
695 PRINT_ER("Beacon interval(1~65535) fail\n");
701 if (strHostIFCfgParamAttr->cfg_attr_info.flag & DTIM_PERIOD) {
702 if (strHostIFCfgParamAttr->cfg_attr_info.dtim_period > 0 && strHostIFCfgParamAttr->cfg_attr_info.dtim_period < 256) {
703 strWIDList[u8WidCnt].id = WID_DTIM_PERIOD;
704 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.dtim_period;
705 strWIDList[u8WidCnt].type = WID_CHAR;
706 strWIDList[u8WidCnt].size = sizeof(char);
707 hif_drv->strCfgValues.dtim_period = strHostIFCfgParamAttr->cfg_attr_info.dtim_period;
709 PRINT_ER("DTIM range(1~255) fail\n");
715 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SITE_SURVEY) {
716 if (strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled < 3) {
717 strWIDList[u8WidCnt].id = WID_SITE_SURVEY;
718 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled;
719 strWIDList[u8WidCnt].type = WID_CHAR;
720 strWIDList[u8WidCnt].size = sizeof(char);
721 hif_drv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled;
723 PRINT_ER("Site survey disable\n");
729 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SITE_SURVEY_SCAN_TIME) {
730 if (strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time < 65536) {
731 strWIDList[u8WidCnt].id = WID_SITE_SURVEY_SCAN_TIME;
732 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time;
733 strWIDList[u8WidCnt].type = WID_SHORT;
734 strWIDList[u8WidCnt].size = sizeof(u16);
735 hif_drv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time;
737 PRINT_ER("Site survey scan time(1~65535) over\n");
743 if (strHostIFCfgParamAttr->cfg_attr_info.flag & ACTIVE_SCANTIME) {
744 if (strHostIFCfgParamAttr->cfg_attr_info.active_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.active_scan_time < 65536) {
745 strWIDList[u8WidCnt].id = WID_ACTIVE_SCAN_TIME;
746 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.active_scan_time;
747 strWIDList[u8WidCnt].type = WID_SHORT;
748 strWIDList[u8WidCnt].size = sizeof(u16);
749 hif_drv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->cfg_attr_info.active_scan_time;
751 PRINT_ER("Active scan time(1~65535) over\n");
757 if (strHostIFCfgParamAttr->cfg_attr_info.flag & PASSIVE_SCANTIME) {
758 if (strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time < 65536) {
759 strWIDList[u8WidCnt].id = WID_PASSIVE_SCAN_TIME;
760 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time;
761 strWIDList[u8WidCnt].type = WID_SHORT;
762 strWIDList[u8WidCnt].size = sizeof(u16);
763 hif_drv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time;
765 PRINT_ER("Passive scan time(1~65535) over\n");
771 if (strHostIFCfgParamAttr->cfg_attr_info.flag & CURRENT_TX_RATE) {
772 enum CURRENT_TXRATE curr_tx_rate = strHostIFCfgParamAttr->cfg_attr_info.curr_tx_rate;
774 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
775 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
776 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
777 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
778 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
779 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
780 strWIDList[u8WidCnt].id = WID_CURRENT_TX_RATE;
781 strWIDList[u8WidCnt].val = (s8 *)&curr_tx_rate;
782 strWIDList[u8WidCnt].type = WID_SHORT;
783 strWIDList[u8WidCnt].size = sizeof(u16);
784 hif_drv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
786 PRINT_ER("out of TX rate\n");
793 result = send_config_pkt(SET_CFG, strWIDList, u8WidCnt,
794 get_id_from_handler(hif_drv));
797 PRINT_ER("Error in setting CFG params\n");
800 up(&hif_drv->gtOsCfgValuesSem);
804 static s32 Handle_wait_msg_q_empty(void)
806 g_wilc_initialized = 0;
807 up(&hif_sema_wait_response);
811 static s32 Handle_Scan(struct host_if_drv *hif_drv,
812 struct scan_attr *pstrHostIFscanAttr)
815 struct wid strWIDList[5];
816 u32 u32WidsCount = 0;
820 u8 *pu8HdnNtwrksWidVal = NULL;
822 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
823 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", hif_drv->enuHostIFstate);
825 hif_drv->usr_scan_req.pfUserScanResult = pstrHostIFscanAttr->result;
826 hif_drv->usr_scan_req.u32UserScanPvoid = pstrHostIFscanAttr->arg;
828 if ((hif_drv->enuHostIFstate >= HOST_IF_SCANNING) && (hif_drv->enuHostIFstate < HOST_IF_CONNECTED)) {
829 PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", hif_drv->enuHostIFstate);
830 PRINT_ER("Already scan\n");
835 if (g_obtainingIP || connecting) {
836 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
837 PRINT_ER("Don't do obss scan\n");
842 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
844 hif_drv->usr_scan_req.u32RcvdChCount = 0;
846 strWIDList[u32WidsCount].id = (u16)WID_SSID_PROBE_REQ;
847 strWIDList[u32WidsCount].type = WID_STR;
849 for (i = 0; i < pstrHostIFscanAttr->hidden_network.u8ssidnum; i++)
850 valuesize += ((pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
851 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
852 strWIDList[u32WidsCount].val = pu8HdnNtwrksWidVal;
853 if (strWIDList[u32WidsCount].val) {
854 pu8Buffer = strWIDList[u32WidsCount].val;
856 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.u8ssidnum;
858 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->hidden_network.u8ssidnum);
860 for (i = 0; i < pstrHostIFscanAttr->hidden_network.u8ssidnum; i++) {
861 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen;
862 memcpy(pu8Buffer, pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen);
863 pu8Buffer += pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen;
866 strWIDList[u32WidsCount].size = (s32)(valuesize + 1);
871 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_PROBE;
872 strWIDList[u32WidsCount].type = WID_BIN_DATA;
873 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ies;
874 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ies_len;
878 strWIDList[u32WidsCount].id = WID_SCAN_TYPE;
879 strWIDList[u32WidsCount].type = WID_CHAR;
880 strWIDList[u32WidsCount].size = sizeof(char);
881 strWIDList[u32WidsCount].val = (s8 *)&pstrHostIFscanAttr->type;
884 strWIDList[u32WidsCount].id = WID_SCAN_CHANNEL_LIST;
885 strWIDList[u32WidsCount].type = WID_BIN_DATA;
887 if (pstrHostIFscanAttr->ch_freq_list &&
888 pstrHostIFscanAttr->ch_list_len > 0) {
891 for (i = 0; i < pstrHostIFscanAttr->ch_list_len; i++) {
892 if (pstrHostIFscanAttr->ch_freq_list[i] > 0)
893 pstrHostIFscanAttr->ch_freq_list[i] = pstrHostIFscanAttr->ch_freq_list[i] - 1;
897 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ch_freq_list;
898 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ch_list_len;
901 strWIDList[u32WidsCount].id = WID_START_SCAN_REQ;
902 strWIDList[u32WidsCount].type = WID_CHAR;
903 strWIDList[u32WidsCount].size = sizeof(char);
904 strWIDList[u32WidsCount].val = (s8 *)&pstrHostIFscanAttr->src;
907 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)
908 scan_while_connected = true;
909 else if (hif_drv->enuHostIFstate == HOST_IF_IDLE)
910 scan_while_connected = false;
912 result = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
913 get_id_from_handler(hif_drv));
916 PRINT_ER("Failed to send scan paramters config packet\n");
918 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
922 del_timer(&hif_drv->hScanTimer);
923 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
926 kfree(pstrHostIFscanAttr->ch_freq_list);
927 pstrHostIFscanAttr->ch_freq_list = NULL;
929 kfree(pstrHostIFscanAttr->ies);
930 pstrHostIFscanAttr->ies = NULL;
931 kfree(pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo);
932 pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo = NULL;
934 kfree(pu8HdnNtwrksWidVal);
939 static s32 Handle_ScanDone(struct host_if_drv *hif_drv,
940 enum scan_event enuEvent)
943 u8 u8abort_running_scan;
946 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
948 if (enuEvent == SCAN_EVENT_ABORTED) {
949 PRINT_D(GENERIC_DBG, "Abort running scan\n");
950 u8abort_running_scan = 1;
951 wid.id = (u16)WID_ABORT_RUNNING_SCAN;
953 wid.val = (s8 *)&u8abort_running_scan;
954 wid.size = sizeof(char);
956 result = send_config_pkt(SET_CFG, &wid, 1,
957 get_id_from_handler(hif_drv));
960 PRINT_ER("Failed to set abort running scan\n");
966 PRINT_ER("Driver handler is NULL\n");
970 if (hif_drv->usr_scan_req.pfUserScanResult) {
971 hif_drv->usr_scan_req.pfUserScanResult(enuEvent, NULL,
972 hif_drv->usr_scan_req.u32UserScanPvoid, NULL);
973 hif_drv->usr_scan_req.pfUserScanResult = NULL;
979 u8 u8ConnectedSSID[6] = {0};
980 static s32 Handle_Connect(struct host_if_drv *hif_drv,
981 struct connect_attr *pstrHostIFconnectAttr)
984 struct wid strWIDList[8];
985 u32 u32WidsCount = 0, dummyval = 0;
986 u8 *pu8CurrByte = NULL;
987 struct join_bss_param *ptstrJoinBssParam;
989 PRINT_D(GENERIC_DBG, "Handling connect request\n");
991 if (memcmp(pstrHostIFconnectAttr->bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
993 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
997 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
999 ptstrJoinBssParam = (struct join_bss_param *)pstrHostIFconnectAttr->params;
1000 if (!ptstrJoinBssParam) {
1001 PRINT_ER("Required BSSID not found\n");
1006 if (pstrHostIFconnectAttr->bssid) {
1007 hif_drv->usr_conn_req.pu8bssid = kmalloc(6, GFP_KERNEL);
1008 memcpy(hif_drv->usr_conn_req.pu8bssid, pstrHostIFconnectAttr->bssid, 6);
1011 hif_drv->usr_conn_req.ssidLen = pstrHostIFconnectAttr->ssid_len;
1012 if (pstrHostIFconnectAttr->ssid) {
1013 hif_drv->usr_conn_req.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssid_len + 1, GFP_KERNEL);
1014 memcpy(hif_drv->usr_conn_req.pu8ssid,
1015 pstrHostIFconnectAttr->ssid,
1016 pstrHostIFconnectAttr->ssid_len);
1017 hif_drv->usr_conn_req.pu8ssid[pstrHostIFconnectAttr->ssid_len] = '\0';
1020 hif_drv->usr_conn_req.ConnReqIEsLen = pstrHostIFconnectAttr->ies_len;
1021 if (pstrHostIFconnectAttr->ies) {
1022 hif_drv->usr_conn_req.pu8ConnReqIEs = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
1023 memcpy(hif_drv->usr_conn_req.pu8ConnReqIEs,
1024 pstrHostIFconnectAttr->ies,
1025 pstrHostIFconnectAttr->ies_len);
1028 hif_drv->usr_conn_req.u8security = pstrHostIFconnectAttr->security;
1029 hif_drv->usr_conn_req.tenuAuth_type = pstrHostIFconnectAttr->auth_type;
1030 hif_drv->usr_conn_req.pfUserConnectResult = pstrHostIFconnectAttr->result;
1031 hif_drv->usr_conn_req.u32UserConnectPvoid = pstrHostIFconnectAttr->arg;
1033 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
1034 strWIDList[u32WidsCount].type = WID_INT;
1035 strWIDList[u32WidsCount].size = sizeof(u32);
1036 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1039 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
1040 strWIDList[u32WidsCount].type = WID_INT;
1041 strWIDList[u32WidsCount].size = sizeof(u32);
1042 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1045 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
1046 strWIDList[u32WidsCount].type = WID_INT;
1047 strWIDList[u32WidsCount].size = sizeof(u32);
1048 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1052 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
1053 strWIDList[u32WidsCount].type = WID_BIN_DATA;
1054 strWIDList[u32WidsCount].val = hif_drv->usr_conn_req.pu8ConnReqIEs;
1055 strWIDList[u32WidsCount].size = hif_drv->usr_conn_req.ConnReqIEsLen;
1058 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1059 info_element_size = hif_drv->usr_conn_req.ConnReqIEsLen;
1060 info_element = kmalloc(info_element_size, GFP_KERNEL);
1061 memcpy(info_element, hif_drv->usr_conn_req.pu8ConnReqIEs,
1065 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
1066 strWIDList[u32WidsCount].type = WID_CHAR;
1067 strWIDList[u32WidsCount].size = sizeof(char);
1068 strWIDList[u32WidsCount].val = (s8 *)&hif_drv->usr_conn_req.u8security;
1071 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
1072 mode_11i = hif_drv->usr_conn_req.u8security;
1074 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", hif_drv->usr_conn_req.u8security);
1076 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
1077 strWIDList[u32WidsCount].type = WID_CHAR;
1078 strWIDList[u32WidsCount].size = sizeof(char);
1079 strWIDList[u32WidsCount].val = (s8 *)(&hif_drv->usr_conn_req.tenuAuth_type);
1082 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
1083 auth_type = (u8)hif_drv->usr_conn_req.tenuAuth_type;
1085 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", hif_drv->usr_conn_req.tenuAuth_type);
1086 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
1087 hif_drv->usr_conn_req.pu8ssid, pstrHostIFconnectAttr->ch);
1089 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
1090 strWIDList[u32WidsCount].type = WID_STR;
1091 strWIDList[u32WidsCount].size = 112;
1092 strWIDList[u32WidsCount].val = kmalloc(strWIDList[u32WidsCount].size, GFP_KERNEL);
1094 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1095 join_req_size = strWIDList[u32WidsCount].size;
1096 join_req = kmalloc(join_req_size, GFP_KERNEL);
1098 if (!strWIDList[u32WidsCount].val) {
1103 pu8CurrByte = strWIDList[u32WidsCount].val;
1105 if (pstrHostIFconnectAttr->ssid) {
1106 memcpy(pu8CurrByte, pstrHostIFconnectAttr->ssid, pstrHostIFconnectAttr->ssid_len);
1107 pu8CurrByte[pstrHostIFconnectAttr->ssid_len] = '\0';
1109 pu8CurrByte += MAX_SSID_LEN;
1110 *(pu8CurrByte++) = INFRASTRUCTURE;
1112 if ((pstrHostIFconnectAttr->ch >= 1) && (pstrHostIFconnectAttr->ch <= 14)) {
1113 *(pu8CurrByte++) = pstrHostIFconnectAttr->ch;
1115 PRINT_ER("Channel out of range\n");
1116 *(pu8CurrByte++) = 0xFF;
1118 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1119 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1120 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1122 if (pstrHostIFconnectAttr->bssid)
1123 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
1126 if (pstrHostIFconnectAttr->bssid)
1127 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
1130 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1131 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1132 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1133 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1134 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1136 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
1137 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1139 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1140 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1141 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1143 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1144 hif_drv->usr_conn_req.IsHTCapable = ptstrJoinBssParam->ht_capable;
1146 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1147 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1148 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1149 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1150 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1151 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1153 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
1154 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1156 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
1157 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1159 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
1160 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1162 *(pu8CurrByte++) = REAL_JOIN_REQ;
1163 *(pu8CurrByte++) = ptstrJoinBssParam->noa_enabled;
1165 if (ptstrJoinBssParam->noa_enabled) {
1166 PRINT_D(HOSTINF_DBG, "NOA present\n");
1168 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1169 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1170 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1171 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1173 *(pu8CurrByte++) = ptstrJoinBssParam->opp_enabled;
1174 *(pu8CurrByte++) = ptstrJoinBssParam->idx;
1176 if (ptstrJoinBssParam->opp_enabled)
1177 *(pu8CurrByte++) = ptstrJoinBssParam->ct_window;
1179 *(pu8CurrByte++) = ptstrJoinBssParam->cnt;
1181 memcpy(pu8CurrByte, ptstrJoinBssParam->duration, sizeof(ptstrJoinBssParam->duration));
1182 pu8CurrByte += sizeof(ptstrJoinBssParam->duration);
1184 memcpy(pu8CurrByte, ptstrJoinBssParam->interval, sizeof(ptstrJoinBssParam->interval));
1185 pu8CurrByte += sizeof(ptstrJoinBssParam->interval);
1187 memcpy(pu8CurrByte, ptstrJoinBssParam->start_time, sizeof(ptstrJoinBssParam->start_time));
1188 pu8CurrByte += sizeof(ptstrJoinBssParam->start_time);
1190 PRINT_D(HOSTINF_DBG, "NOA not present\n");
1192 pu8CurrByte = strWIDList[u32WidsCount].val;
1195 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1196 memcpy(join_req, pu8CurrByte, join_req_size);
1197 join_req_drv = hif_drv;
1200 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1202 if (pstrHostIFconnectAttr->bssid) {
1203 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->bssid, ETH_ALEN);
1205 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n", pstrHostIFconnectAttr->bssid);
1206 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", u8ConnectedSSID);
1209 result = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
1210 get_id_from_handler(hif_drv));
1212 PRINT_ER("failed to send config packet\n");
1216 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
1217 hif_drv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1222 tstrConnectInfo strConnectInfo;
1224 del_timer(&hif_drv->hConnectTimer);
1226 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
1228 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1230 if (pstrHostIFconnectAttr->result) {
1231 if (pstrHostIFconnectAttr->bssid)
1232 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->bssid, 6);
1234 if (pstrHostIFconnectAttr->ies) {
1235 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->ies_len;
1236 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
1237 memcpy(strConnectInfo.pu8ReqIEs,
1238 pstrHostIFconnectAttr->ies,
1239 pstrHostIFconnectAttr->ies_len);
1242 pstrHostIFconnectAttr->result(CONN_DISCONN_EVENT_CONN_RESP,
1246 pstrHostIFconnectAttr->arg);
1247 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1248 kfree(strConnectInfo.pu8ReqIEs);
1249 strConnectInfo.pu8ReqIEs = NULL;
1252 PRINT_ER("Connect callback function pointer is NULL\n");
1256 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
1257 kfree(pstrHostIFconnectAttr->bssid);
1258 pstrHostIFconnectAttr->bssid = NULL;
1260 kfree(pstrHostIFconnectAttr->ssid);
1261 pstrHostIFconnectAttr->ssid = NULL;
1263 kfree(pstrHostIFconnectAttr->ies);
1264 pstrHostIFconnectAttr->ies = NULL;
1270 static s32 Handle_FlushConnect(struct host_if_drv *hif_drv)
1273 struct wid strWIDList[5];
1274 u32 u32WidsCount = 0;
1275 u8 *pu8CurrByte = NULL;
1277 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
1278 strWIDList[u32WidsCount].type = WID_BIN_DATA;
1279 strWIDList[u32WidsCount].val = info_element;
1280 strWIDList[u32WidsCount].size = info_element_size;
1283 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
1284 strWIDList[u32WidsCount].type = WID_CHAR;
1285 strWIDList[u32WidsCount].size = sizeof(char);
1286 strWIDList[u32WidsCount].val = (s8 *)(&(mode_11i));
1289 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
1290 strWIDList[u32WidsCount].type = WID_CHAR;
1291 strWIDList[u32WidsCount].size = sizeof(char);
1292 strWIDList[u32WidsCount].val = (s8 *)(&auth_type);
1295 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
1296 strWIDList[u32WidsCount].type = WID_STR;
1297 strWIDList[u32WidsCount].size = join_req_size;
1298 strWIDList[u32WidsCount].val = (s8 *)join_req;
1299 pu8CurrByte = strWIDList[u32WidsCount].val;
1301 pu8CurrByte += FLUSHED_BYTE_POS;
1302 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1306 result = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
1307 get_id_from_handler(join_req_drv));
1309 PRINT_ER("failed to send config packet\n");
1316 static s32 Handle_ConnectTimeout(struct host_if_drv *hif_drv)
1319 tstrConnectInfo strConnectInfo;
1321 u16 u16DummyReasonCode = 0;
1324 PRINT_ER("Driver handler is NULL\n");
1328 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1330 scan_while_connected = false;
1332 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1334 if (hif_drv->usr_conn_req.pfUserConnectResult) {
1335 if (hif_drv->usr_conn_req.pu8bssid) {
1336 memcpy(strConnectInfo.au8bssid,
1337 hif_drv->usr_conn_req.pu8bssid, 6);
1340 if (hif_drv->usr_conn_req.pu8ConnReqIEs) {
1341 strConnectInfo.ReqIEsLen = hif_drv->usr_conn_req.ConnReqIEsLen;
1342 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->usr_conn_req.ConnReqIEsLen, GFP_KERNEL);
1343 memcpy(strConnectInfo.pu8ReqIEs,
1344 hif_drv->usr_conn_req.pu8ConnReqIEs,
1345 hif_drv->usr_conn_req.ConnReqIEsLen);
1348 hif_drv->usr_conn_req.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1352 hif_drv->usr_conn_req.u32UserConnectPvoid);
1354 kfree(strConnectInfo.pu8ReqIEs);
1355 strConnectInfo.pu8ReqIEs = NULL;
1357 PRINT_ER("Connect callback function pointer is NULL\n");
1360 wid.id = (u16)WID_DISCONNECT;
1361 wid.type = WID_CHAR;
1362 wid.val = (s8 *)&u16DummyReasonCode;
1363 wid.size = sizeof(char);
1365 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1367 result = send_config_pkt(SET_CFG, &wid, 1,
1368 get_id_from_handler(hif_drv));
1370 PRINT_ER("Failed to send dissconect config packet\n");
1372 hif_drv->usr_conn_req.ssidLen = 0;
1373 kfree(hif_drv->usr_conn_req.pu8ssid);
1374 kfree(hif_drv->usr_conn_req.pu8bssid);
1375 hif_drv->usr_conn_req.ConnReqIEsLen = 0;
1376 kfree(hif_drv->usr_conn_req.pu8ConnReqIEs);
1378 eth_zero_addr(u8ConnectedSSID);
1380 if (join_req && join_req_drv == hif_drv) {
1385 if (info_element && join_req_drv == hif_drv) {
1386 kfree(info_element);
1387 info_element = NULL;
1393 static s32 Handle_RcvdNtwrkInfo(struct host_if_drv *hif_drv,
1394 struct rcvd_net_info *pstrRcvdNetworkInfo)
1397 bool bNewNtwrkFound;
1399 tstrNetworkInfo *pstrNetworkInfo = NULL;
1400 void *pJoinParams = NULL;
1402 bNewNtwrkFound = true;
1403 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
1405 if (hif_drv->usr_scan_req.pfUserScanResult) {
1406 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
1407 parse_network_info(pstrRcvdNetworkInfo->buffer, &pstrNetworkInfo);
1408 if ((!pstrNetworkInfo) ||
1409 (!hif_drv->usr_scan_req.pfUserScanResult)) {
1410 PRINT_ER("driver is null\n");
1415 for (i = 0; i < hif_drv->usr_scan_req.u32RcvdChCount; i++) {
1416 if ((hif_drv->usr_scan_req.astrFoundNetworkInfo[i].au8bssid) &&
1417 (pstrNetworkInfo->au8bssid)) {
1418 if (memcmp(hif_drv->usr_scan_req.astrFoundNetworkInfo[i].au8bssid,
1419 pstrNetworkInfo->au8bssid, 6) == 0) {
1420 if (pstrNetworkInfo->s8rssi <= hif_drv->usr_scan_req.astrFoundNetworkInfo[i].s8rssi) {
1421 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
1424 hif_drv->usr_scan_req.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
1425 bNewNtwrkFound = false;
1432 if (bNewNtwrkFound) {
1433 PRINT_D(HOSTINF_DBG, "New network found\n");
1435 if (hif_drv->usr_scan_req.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
1436 hif_drv->usr_scan_req.astrFoundNetworkInfo[hif_drv->usr_scan_req.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
1438 if (hif_drv->usr_scan_req.astrFoundNetworkInfo[hif_drv->usr_scan_req.u32RcvdChCount].au8bssid &&
1439 pstrNetworkInfo->au8bssid) {
1440 memcpy(hif_drv->usr_scan_req.astrFoundNetworkInfo[hif_drv->usr_scan_req.u32RcvdChCount].au8bssid,
1441 pstrNetworkInfo->au8bssid, 6);
1443 hif_drv->usr_scan_req.u32RcvdChCount++;
1445 pstrNetworkInfo->bNewNetwork = true;
1446 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
1448 hif_drv->usr_scan_req.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1449 hif_drv->usr_scan_req.u32UserScanPvoid,
1453 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
1456 pstrNetworkInfo->bNewNetwork = false;
1457 hif_drv->usr_scan_req.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1458 hif_drv->usr_scan_req.u32UserScanPvoid, NULL);
1463 kfree(pstrRcvdNetworkInfo->buffer);
1464 pstrRcvdNetworkInfo->buffer = NULL;
1466 if (pstrNetworkInfo) {
1467 DeallocateNetworkInfo(pstrNetworkInfo);
1468 pstrNetworkInfo = NULL;
1474 static s32 Handle_RcvdGnrlAsyncInfo(struct host_if_drv *hif_drv,
1475 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
1481 u16 u16WidID = (u16)WID_NIL;
1484 u8 u8MacStatusReasonCode;
1485 u8 u8MacStatusAdditionalInfo;
1486 tstrConnectInfo strConnectInfo;
1487 tstrDisconnectNotifInfo strDisconnectNotifInfo;
1491 PRINT_ER("Driver handler is NULL\n");
1494 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", hif_drv->enuHostIFstate,
1495 pstrRcvdGnrlAsyncInfo->buffer[7]);
1497 if ((hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
1498 (hif_drv->enuHostIFstate == HOST_IF_CONNECTED) ||
1499 hif_drv->usr_scan_req.pfUserScanResult) {
1500 if (!pstrRcvdGnrlAsyncInfo->buffer ||
1501 !hif_drv->usr_conn_req.pfUserConnectResult) {
1502 PRINT_ER("driver is null\n");
1506 u8MsgType = pstrRcvdGnrlAsyncInfo->buffer[0];
1508 if ('I' != u8MsgType) {
1509 PRINT_ER("Received Message format incorrect.\n");
1513 u8MsgID = pstrRcvdGnrlAsyncInfo->buffer[1];
1514 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[2], pstrRcvdGnrlAsyncInfo->buffer[3]);
1515 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[4], pstrRcvdGnrlAsyncInfo->buffer[5]);
1516 u8WidLen = pstrRcvdGnrlAsyncInfo->buffer[6];
1517 u8MacStatus = pstrRcvdGnrlAsyncInfo->buffer[7];
1518 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->buffer[8];
1519 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->buffer[9];
1520 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
1521 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
1522 u32 u32RcvdAssocRespInfoLen;
1523 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
1525 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
1527 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1529 if (u8MacStatus == MAC_CONNECTED) {
1530 memset(rcv_assoc_resp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
1532 host_int_get_assoc_res_info(hif_drv,
1534 MAX_ASSOC_RESP_FRAME_SIZE,
1535 &u32RcvdAssocRespInfoLen);
1537 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
1539 if (u32RcvdAssocRespInfoLen != 0) {
1540 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
1541 s32Err = ParseAssocRespInfo(rcv_assoc_resp, u32RcvdAssocRespInfoLen,
1542 &pstrConnectRespInfo);
1544 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
1546 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
1548 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
1549 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
1550 if (pstrConnectRespInfo->pu8RespIEs) {
1551 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
1552 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL);
1553 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
1554 pstrConnectRespInfo->u16RespIEsLen);
1558 if (pstrConnectRespInfo) {
1559 DeallocateAssocRespInfo(pstrConnectRespInfo);
1560 pstrConnectRespInfo = NULL;
1566 if ((u8MacStatus == MAC_CONNECTED) &&
1567 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
1568 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
1569 eth_zero_addr(u8ConnectedSSID);
1571 } else if (u8MacStatus == MAC_DISCONNECTED) {
1572 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
1573 eth_zero_addr(u8ConnectedSSID);
1576 if (hif_drv->usr_conn_req.pu8bssid) {
1577 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
1578 memcpy(strConnectInfo.au8bssid, hif_drv->usr_conn_req.pu8bssid, 6);
1580 if ((u8MacStatus == MAC_CONNECTED) &&
1581 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
1582 memcpy(hif_drv->au8AssociatedBSSID,
1583 hif_drv->usr_conn_req.pu8bssid, ETH_ALEN);
1587 if (hif_drv->usr_conn_req.pu8ConnReqIEs) {
1588 strConnectInfo.ReqIEsLen = hif_drv->usr_conn_req.ConnReqIEsLen;
1589 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->usr_conn_req.ConnReqIEsLen, GFP_KERNEL);
1590 memcpy(strConnectInfo.pu8ReqIEs,
1591 hif_drv->usr_conn_req.pu8ConnReqIEs,
1592 hif_drv->usr_conn_req.ConnReqIEsLen);
1595 del_timer(&hif_drv->hConnectTimer);
1596 hif_drv->usr_conn_req.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1600 hif_drv->usr_conn_req.u32UserConnectPvoid);
1602 if ((u8MacStatus == MAC_CONNECTED) &&
1603 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
1604 host_int_set_power_mgmt(hif_drv, 0, 0);
1606 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
1607 hif_drv->enuHostIFstate = HOST_IF_CONNECTED;
1609 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
1610 g_obtainingIP = true;
1611 mod_timer(&hDuringIpTimer,
1612 jiffies + msecs_to_jiffies(10000));
1614 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
1615 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1616 scan_while_connected = false;
1619 kfree(strConnectInfo.pu8RespIEs);
1620 strConnectInfo.pu8RespIEs = NULL;
1622 kfree(strConnectInfo.pu8ReqIEs);
1623 strConnectInfo.pu8ReqIEs = NULL;
1624 hif_drv->usr_conn_req.ssidLen = 0;
1625 kfree(hif_drv->usr_conn_req.pu8ssid);
1626 kfree(hif_drv->usr_conn_req.pu8bssid);
1627 hif_drv->usr_conn_req.ConnReqIEsLen = 0;
1628 kfree(hif_drv->usr_conn_req.pu8ConnReqIEs);
1629 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
1630 (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)) {
1631 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
1633 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
1635 if (hif_drv->usr_scan_req.pfUserScanResult) {
1636 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
1637 del_timer(&hif_drv->hScanTimer);
1638 Handle_ScanDone((void *)hif_drv, SCAN_EVENT_ABORTED);
1641 strDisconnectNotifInfo.u16reason = 0;
1642 strDisconnectNotifInfo.ie = NULL;
1643 strDisconnectNotifInfo.ie_len = 0;
1645 if (hif_drv->usr_conn_req.pfUserConnectResult) {
1646 g_obtainingIP = false;
1647 host_int_set_power_mgmt(hif_drv, 0, 0);
1649 hif_drv->usr_conn_req.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1652 &strDisconnectNotifInfo,
1653 hif_drv->usr_conn_req.u32UserConnectPvoid);
1655 PRINT_ER("Connect result callback function is NULL\n");
1658 eth_zero_addr(hif_drv->au8AssociatedBSSID);
1660 hif_drv->usr_conn_req.ssidLen = 0;
1661 kfree(hif_drv->usr_conn_req.pu8ssid);
1662 kfree(hif_drv->usr_conn_req.pu8bssid);
1663 hif_drv->usr_conn_req.ConnReqIEsLen = 0;
1664 kfree(hif_drv->usr_conn_req.pu8ConnReqIEs);
1666 if (join_req && join_req_drv == hif_drv) {
1671 if (info_element && join_req_drv == hif_drv) {
1672 kfree(info_element);
1673 info_element = NULL;
1676 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1677 scan_while_connected = false;
1679 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
1680 (hif_drv->usr_scan_req.pfUserScanResult)) {
1681 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
1682 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
1684 del_timer(&hif_drv->hScanTimer);
1685 if (hif_drv->usr_scan_req.pfUserScanResult)
1686 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
1690 kfree(pstrRcvdGnrlAsyncInfo->buffer);
1691 pstrRcvdGnrlAsyncInfo->buffer = NULL;
1696 static int Handle_Key(struct host_if_drv *hif_drv,
1697 struct key_attr *pstrHostIFkeyAttr)
1701 struct wid strWIDList[5];
1707 switch (pstrHostIFkeyAttr->type) {
1710 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1711 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
1712 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", pstrHostIFkeyAttr->attr.wep.index);
1713 strWIDList[0].id = (u16)WID_11I_MODE;
1714 strWIDList[0].type = WID_CHAR;
1715 strWIDList[0].size = sizeof(char);
1716 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.mode;
1718 strWIDList[1].id = WID_AUTH_TYPE;
1719 strWIDList[1].type = WID_CHAR;
1720 strWIDList[1].size = sizeof(char);
1721 strWIDList[1].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.auth_type;
1723 strWIDList[2].id = (u16)WID_KEY_ID;
1724 strWIDList[2].type = WID_CHAR;
1726 strWIDList[2].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.index;
1727 strWIDList[2].size = sizeof(char);
1729 pu8keybuf = kmemdup(pstrHostIFkeyAttr->attr.wep.key,
1730 pstrHostIFkeyAttr->attr.wep.key_len,
1733 if (pu8keybuf == NULL) {
1734 PRINT_ER("No buffer to send Key\n");
1738 kfree(pstrHostIFkeyAttr->attr.wep.key);
1740 strWIDList[3].id = (u16)WID_WEP_KEY_VALUE;
1741 strWIDList[3].type = WID_STR;
1742 strWIDList[3].size = pstrHostIFkeyAttr->attr.wep.key_len;
1743 strWIDList[3].val = (s8 *)pu8keybuf;
1745 result = send_config_pkt(SET_CFG, strWIDList, 4,
1746 get_id_from_handler(hif_drv));
1750 if (pstrHostIFkeyAttr->action & ADDKEY) {
1751 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
1752 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2, GFP_KERNEL);
1754 PRINT_ER("No buffer to send Key\n");
1757 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1758 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->attr.wep.key_len, 1);
1759 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->attr.wep.key,
1760 pstrHostIFkeyAttr->attr.wep.key_len);
1761 kfree(pstrHostIFkeyAttr->attr.wep.key);
1763 wid.id = (u16)WID_ADD_WEP_KEY;
1765 wid.val = (s8 *)pu8keybuf;
1766 wid.size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
1768 result = send_config_pkt(SET_CFG, &wid, 1,
1769 get_id_from_handler(hif_drv));
1771 } else if (pstrHostIFkeyAttr->action & REMOVEKEY) {
1772 PRINT_D(HOSTINF_DBG, "Removing key\n");
1773 wid.id = (u16)WID_REMOVE_WEP_KEY;
1776 s8idxarray[0] = (s8)pstrHostIFkeyAttr->attr.wep.index;
1777 wid.val = s8idxarray;
1780 result = send_config_pkt(SET_CFG, &wid, 1,
1781 get_id_from_handler(hif_drv));
1783 wid.id = (u16)WID_KEY_ID;
1784 wid.type = WID_CHAR;
1785 wid.val = (s8 *)&pstrHostIFkeyAttr->attr.wep.index;
1786 wid.size = sizeof(char);
1788 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
1790 result = send_config_pkt(SET_CFG, &wid, 1,
1791 get_id_from_handler(hif_drv));
1793 up(&hif_drv->hSemTestKeyBlock);
1797 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1798 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1800 PRINT_ER("No buffer to send RxGTK Key\n");
1802 goto _WPARxGtk_end_case_;
1805 if (pstrHostIFkeyAttr->attr.wpa.seq)
1806 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1808 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1809 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1810 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1811 pstrHostIFkeyAttr->attr.wpa.key_len);
1813 strWIDList[0].id = (u16)WID_11I_MODE;
1814 strWIDList[0].type = WID_CHAR;
1815 strWIDList[0].size = sizeof(char);
1816 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode;
1818 strWIDList[1].id = (u16)WID_ADD_RX_GTK;
1819 strWIDList[1].type = WID_STR;
1820 strWIDList[1].val = (s8 *)pu8keybuf;
1821 strWIDList[1].size = RX_MIC_KEY_MSG_LEN;
1823 result = send_config_pkt(SET_CFG, strWIDList, 2,
1824 get_id_from_handler(hif_drv));
1827 up(&hif_drv->hSemTestKeyBlock);
1830 if (pstrHostIFkeyAttr->action & ADDKEY) {
1831 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
1833 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1834 if (pu8keybuf == NULL) {
1835 PRINT_ER("No buffer to send RxGTK Key\n");
1837 goto _WPARxGtk_end_case_;
1840 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)
1841 memcpy(pu8keybuf, hif_drv->au8AssociatedBSSID, ETH_ALEN);
1843 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
1845 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1846 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1847 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1848 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1849 pstrHostIFkeyAttr->attr.wpa.key_len);
1851 wid.id = (u16)WID_ADD_RX_GTK;
1853 wid.val = (s8 *)pu8keybuf;
1854 wid.size = RX_MIC_KEY_MSG_LEN;
1856 result = send_config_pkt(SET_CFG, &wid, 1,
1857 get_id_from_handler(hif_drv));
1860 up(&hif_drv->hSemTestKeyBlock);
1862 _WPARxGtk_end_case_:
1863 kfree(pstrHostIFkeyAttr->attr.wpa.key);
1864 kfree(pstrHostIFkeyAttr->attr.wpa.seq);
1871 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1872 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
1874 PRINT_ER("No buffer to send PTK Key\n");
1876 goto _WPAPtk_end_case_;
1879 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1880 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1881 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1882 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->attr.wpa.key,
1883 pstrHostIFkeyAttr->attr.wpa.key_len);
1885 strWIDList[0].id = (u16)WID_11I_MODE;
1886 strWIDList[0].type = WID_CHAR;
1887 strWIDList[0].size = sizeof(char);
1888 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode;
1890 strWIDList[1].id = (u16)WID_ADD_PTK;
1891 strWIDList[1].type = WID_STR;
1892 strWIDList[1].val = (s8 *)pu8keybuf;
1893 strWIDList[1].size = PTK_KEY_MSG_LEN + 1;
1895 result = send_config_pkt(SET_CFG, strWIDList, 2,
1896 get_id_from_handler(hif_drv));
1898 up(&hif_drv->hSemTestKeyBlock);
1900 if (pstrHostIFkeyAttr->action & ADDKEY) {
1901 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
1903 PRINT_ER("No buffer to send PTK Key\n");
1905 goto _WPAPtk_end_case_;
1908 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1909 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1910 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->attr.wpa.key,
1911 pstrHostIFkeyAttr->attr.wpa.key_len);
1913 wid.id = (u16)WID_ADD_PTK;
1915 wid.val = (s8 *)pu8keybuf;
1916 wid.size = PTK_KEY_MSG_LEN;
1918 result = send_config_pkt(SET_CFG, &wid, 1,
1919 get_id_from_handler(hif_drv));
1921 up(&hif_drv->hSemTestKeyBlock);
1925 kfree(pstrHostIFkeyAttr->attr.wpa.key);
1933 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
1935 pu8keybuf = kmalloc((pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
1937 PRINT_ER("No buffer to send PMKSA Key\n");
1941 pu8keybuf[0] = pstrHostIFkeyAttr->attr.pmkid.numpmkid;
1943 for (i = 0; i < pstrHostIFkeyAttr->attr.pmkid.numpmkid; i++) {
1944 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
1945 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
1948 wid.id = (u16)WID_PMKID_INFO;
1950 wid.val = (s8 *)pu8keybuf;
1951 wid.size = (pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
1953 result = send_config_pkt(SET_CFG, &wid, 1,
1954 get_id_from_handler(hif_drv));
1961 PRINT_ER("Failed to send key config packet\n");
1966 static void Handle_Disconnect(struct host_if_drv *hif_drv)
1971 u16 u16DummyReasonCode = 0;
1973 wid.id = (u16)WID_DISCONNECT;
1974 wid.type = WID_CHAR;
1975 wid.val = (s8 *)&u16DummyReasonCode;
1976 wid.size = sizeof(char);
1978 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1980 g_obtainingIP = false;
1981 host_int_set_power_mgmt(hif_drv, 0, 0);
1983 eth_zero_addr(u8ConnectedSSID);
1985 result = send_config_pkt(SET_CFG, &wid, 1,
1986 get_id_from_handler(hif_drv));
1989 PRINT_ER("Failed to send dissconect config packet\n");
1991 tstrDisconnectNotifInfo strDisconnectNotifInfo;
1993 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
1995 strDisconnectNotifInfo.u16reason = 0;
1996 strDisconnectNotifInfo.ie = NULL;
1997 strDisconnectNotifInfo.ie_len = 0;
1999 if (hif_drv->usr_scan_req.pfUserScanResult) {
2000 del_timer(&hif_drv->hScanTimer);
2001 hif_drv->usr_scan_req.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
2002 hif_drv->usr_scan_req.u32UserScanPvoid, NULL);
2004 hif_drv->usr_scan_req.pfUserScanResult = NULL;
2007 if (hif_drv->usr_conn_req.pfUserConnectResult) {
2008 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2009 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
2010 del_timer(&hif_drv->hConnectTimer);
2013 hif_drv->usr_conn_req.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
2014 0, &strDisconnectNotifInfo, hif_drv->usr_conn_req.u32UserConnectPvoid);
2016 PRINT_ER("usr_conn_req.pfUserConnectResult = NULL\n");
2019 scan_while_connected = false;
2021 hif_drv->enuHostIFstate = HOST_IF_IDLE;
2023 eth_zero_addr(hif_drv->au8AssociatedBSSID);
2025 hif_drv->usr_conn_req.ssidLen = 0;
2026 kfree(hif_drv->usr_conn_req.pu8ssid);
2027 kfree(hif_drv->usr_conn_req.pu8bssid);
2028 hif_drv->usr_conn_req.ConnReqIEsLen = 0;
2029 kfree(hif_drv->usr_conn_req.pu8ConnReqIEs);
2031 if (join_req && join_req_drv == hif_drv) {
2036 if (info_element && join_req_drv == hif_drv) {
2037 kfree(info_element);
2038 info_element = NULL;
2042 up(&hif_drv->hSemTestDisconnectBlock);
2045 void resolve_disconnect_aberration(struct host_if_drv *hif_drv)
2049 if ((hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (hif_drv->enuHostIFstate == HOST_IF_CONNECTING)) {
2050 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
2051 host_int_disconnect(hif_drv, 1);
2055 static s32 Handle_GetChnl(struct host_if_drv *hif_drv)
2060 wid.id = (u16)WID_CURRENT_CHANNEL;
2061 wid.type = WID_CHAR;
2062 wid.val = (s8 *)&ch_no;
2063 wid.size = sizeof(char);
2065 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
2067 result = send_config_pkt(GET_CFG, &wid, 1,
2068 get_id_from_handler(hif_drv));
2071 PRINT_ER("Failed to get channel number\n");
2075 up(&hif_drv->hSemGetCHNL);
2080 static void Handle_GetRssi(struct host_if_drv *hif_drv)
2085 wid.id = (u16)WID_RSSI;
2086 wid.type = WID_CHAR;
2088 wid.size = sizeof(char);
2090 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
2092 result = send_config_pkt(GET_CFG, &wid, 1,
2093 get_id_from_handler(hif_drv));
2095 PRINT_ER("Failed to get RSSI value\n");
2099 up(&hif_drv->hSemGetRSSI);
2102 static void Handle_GetLinkspeed(struct host_if_drv *hif_drv)
2109 wid.id = (u16)WID_LINKSPEED;
2110 wid.type = WID_CHAR;
2111 wid.val = &link_speed;
2112 wid.size = sizeof(char);
2114 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
2116 result = send_config_pkt(GET_CFG, &wid, 1,
2117 get_id_from_handler(hif_drv));
2119 PRINT_ER("Failed to get LINKSPEED value\n");
2123 up(&hif_drv->hSemGetLINKSPEED);
2126 s32 Handle_GetStatistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
2128 struct wid strWIDList[5];
2129 u32 u32WidsCount = 0, result = 0;
2131 strWIDList[u32WidsCount].id = WID_LINKSPEED;
2132 strWIDList[u32WidsCount].type = WID_CHAR;
2133 strWIDList[u32WidsCount].size = sizeof(char);
2134 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->u8LinkSpeed;
2137 strWIDList[u32WidsCount].id = WID_RSSI;
2138 strWIDList[u32WidsCount].type = WID_CHAR;
2139 strWIDList[u32WidsCount].size = sizeof(char);
2140 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->s8RSSI;
2143 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
2144 strWIDList[u32WidsCount].type = WID_INT;
2145 strWIDList[u32WidsCount].size = sizeof(u32);
2146 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->u32TxCount;
2149 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
2150 strWIDList[u32WidsCount].type = WID_INT;
2151 strWIDList[u32WidsCount].size = sizeof(u32);
2152 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->u32RxCount;
2155 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
2156 strWIDList[u32WidsCount].type = WID_INT;
2157 strWIDList[u32WidsCount].size = sizeof(u32);
2158 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->u32TxFailureCount;
2161 result = send_config_pkt(GET_CFG, strWIDList, u32WidsCount,
2162 get_id_from_handler(hif_drv));
2165 PRINT_ER("Failed to send scan paramters config packet\n");
2167 up(&hif_sema_wait_response);
2171 static s32 Handle_Get_InActiveTime(struct host_if_drv *hif_drv,
2172 struct sta_inactive_t *strHostIfStaInactiveT)
2178 wid.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
2180 wid.size = ETH_ALEN;
2181 wid.val = kmalloc(wid.size, GFP_KERNEL);
2184 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
2186 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
2188 result = send_config_pkt(SET_CFG, &wid, 1,
2189 get_id_from_handler(hif_drv));
2192 PRINT_ER("Failed to SET incative time\n");
2196 wid.id = (u16)WID_GET_INACTIVE_TIME;
2198 wid.val = (s8 *)&inactive_time;
2199 wid.size = sizeof(u32);
2201 result = send_config_pkt(GET_CFG, &wid, 1,
2202 get_id_from_handler(hif_drv));
2205 PRINT_ER("Failed to get incative time\n");
2209 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", inactive_time);
2211 up(&hif_drv->hSemInactiveTime);
2216 static void Handle_AddBeacon(struct host_if_drv *hif_drv,
2217 struct beacon_attr *pstrSetBeaconParam)
2223 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
2225 wid.id = (u16)WID_ADD_BEACON;
2227 wid.size = pstrSetBeaconParam->head_len + pstrSetBeaconParam->tail_len + 16;
2228 wid.val = kmalloc(wid.size, GFP_KERNEL);
2232 pu8CurrByte = wid.val;
2233 *pu8CurrByte++ = (pstrSetBeaconParam->interval & 0xFF);
2234 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 8) & 0xFF);
2235 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 16) & 0xFF);
2236 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 24) & 0xFF);
2238 *pu8CurrByte++ = (pstrSetBeaconParam->dtim_period & 0xFF);
2239 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 8) & 0xFF);
2240 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 16) & 0xFF);
2241 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 24) & 0xFF);
2243 *pu8CurrByte++ = (pstrSetBeaconParam->head_len & 0xFF);
2244 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 8) & 0xFF);
2245 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 16) & 0xFF);
2246 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 24) & 0xFF);
2248 memcpy(pu8CurrByte, pstrSetBeaconParam->head, pstrSetBeaconParam->head_len);
2249 pu8CurrByte += pstrSetBeaconParam->head_len;
2251 *pu8CurrByte++ = (pstrSetBeaconParam->tail_len & 0xFF);
2252 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 8) & 0xFF);
2253 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 16) & 0xFF);
2254 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 24) & 0xFF);
2256 if (pstrSetBeaconParam->tail > 0)
2257 memcpy(pu8CurrByte, pstrSetBeaconParam->tail, pstrSetBeaconParam->tail_len);
2258 pu8CurrByte += pstrSetBeaconParam->tail_len;
2260 result = send_config_pkt(SET_CFG, &wid, 1,
2261 get_id_from_handler(hif_drv));
2263 PRINT_ER("Failed to send add beacon config packet\n");
2267 kfree(pstrSetBeaconParam->head);
2268 kfree(pstrSetBeaconParam->tail);
2271 static void Handle_DelBeacon(struct host_if_drv *hif_drv)
2277 wid.id = (u16)WID_DEL_BEACON;
2278 wid.type = WID_CHAR;
2279 wid.size = sizeof(char);
2280 wid.val = &del_beacon;
2285 pu8CurrByte = wid.val;
2287 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
2289 result = send_config_pkt(SET_CFG, &wid, 1,
2290 get_id_from_handler(hif_drv));
2292 PRINT_ER("Failed to send delete beacon config packet\n");
2295 static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
2296 struct add_sta_param *pstrStationParam)
2300 pu8CurrByte = pu8Buffer;
2302 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
2303 memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
2304 pu8CurrByte += ETH_ALEN;
2306 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
2307 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
2309 *pu8CurrByte++ = pstrStationParam->u8NumRates;
2310 if (pstrStationParam->u8NumRates > 0)
2311 memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
2312 pu8CurrByte += pstrStationParam->u8NumRates;
2314 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
2315 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
2316 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
2318 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
2319 memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
2320 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
2322 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
2323 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
2325 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
2326 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
2327 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
2328 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
2330 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
2332 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
2333 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
2335 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
2336 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
2338 return pu8CurrByte - pu8Buffer;
2341 static void Handle_AddStation(struct host_if_drv *hif_drv,
2342 struct add_sta_param *pstrStationParam)
2348 PRINT_D(HOSTINF_DBG, "Handling add station\n");
2349 wid.id = (u16)WID_ADD_STA;
2351 wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
2353 wid.val = kmalloc(wid.size, GFP_KERNEL);
2357 pu8CurrByte = wid.val;
2358 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2360 result = send_config_pkt(SET_CFG, &wid, 1,
2361 get_id_from_handler(hif_drv));
2363 PRINT_ER("Failed to send add station config packet\n");
2366 kfree(pstrStationParam->pu8Rates);
2370 static void Handle_DelAllSta(struct host_if_drv *hif_drv,
2371 struct del_all_sta *pstrDelAllStaParam)
2377 u8 au8Zero_Buff[6] = {0};
2379 wid.id = (u16)WID_DEL_ALL_STA;
2381 wid.size = (pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1;
2383 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
2385 wid.val = kmalloc((pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1, GFP_KERNEL);
2389 pu8CurrByte = wid.val;
2391 *(pu8CurrByte++) = pstrDelAllStaParam->assoc_sta;
2393 for (i = 0; i < MAX_NUM_STA; i++) {
2394 if (memcmp(pstrDelAllStaParam->del_all_sta[i], au8Zero_Buff, ETH_ALEN))
2395 memcpy(pu8CurrByte, pstrDelAllStaParam->del_all_sta[i], ETH_ALEN);
2399 pu8CurrByte += ETH_ALEN;
2402 result = send_config_pkt(SET_CFG, &wid, 1,
2403 get_id_from_handler(hif_drv));
2405 PRINT_ER("Failed to send add station config packet\n");
2410 up(&hif_sema_wait_response);
2413 static void Handle_DelStation(struct host_if_drv *hif_drv,
2414 struct del_sta *pstrDelStaParam)
2420 wid.id = (u16)WID_REMOVE_STA;
2422 wid.size = ETH_ALEN;
2424 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
2426 wid.val = kmalloc(wid.size, GFP_KERNEL);
2430 pu8CurrByte = wid.val;
2432 memcpy(pu8CurrByte, pstrDelStaParam->mac_addr, ETH_ALEN);
2434 result = send_config_pkt(SET_CFG, &wid, 1,
2435 get_id_from_handler(hif_drv));
2437 PRINT_ER("Failed to send add station config packet\n");
2443 static void Handle_EditStation(struct host_if_drv *hif_drv,
2444 struct add_sta_param *pstrStationParam)
2450 wid.id = (u16)WID_EDIT_STA;
2452 wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
2454 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
2455 wid.val = kmalloc(wid.size, GFP_KERNEL);
2459 pu8CurrByte = wid.val;
2460 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2462 result = send_config_pkt(SET_CFG, &wid, 1,
2463 get_id_from_handler(hif_drv));
2465 PRINT_ER("Failed to send edit station config packet\n");
2468 kfree(pstrStationParam->pu8Rates);
2472 static int Handle_RemainOnChan(struct host_if_drv *hif_drv,
2473 struct remain_ch *pstrHostIfRemainOnChan)
2476 u8 u8remain_on_chan_flag;
2479 if (!hif_drv->remain_on_ch_pending) {
2480 hif_drv->remain_on_ch.pVoid = pstrHostIfRemainOnChan->pVoid;
2481 hif_drv->remain_on_ch.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
2482 hif_drv->remain_on_ch.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
2483 hif_drv->remain_on_ch.u16Channel = pstrHostIfRemainOnChan->u16Channel;
2484 hif_drv->remain_on_ch.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
2486 pstrHostIfRemainOnChan->u16Channel = hif_drv->remain_on_ch.u16Channel;
2489 if (hif_drv->usr_scan_req.pfUserScanResult) {
2490 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
2491 hif_drv->remain_on_ch_pending = 1;
2495 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2496 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
2501 if (g_obtainingIP || connecting) {
2502 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
2507 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
2509 u8remain_on_chan_flag = true;
2510 wid.id = (u16)WID_REMAIN_ON_CHAN;
2513 wid.val = kmalloc(wid.size, GFP_KERNEL);
2519 wid.val[0] = u8remain_on_chan_flag;
2520 wid.val[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
2522 result = send_config_pkt(SET_CFG, &wid, 1,
2523 get_id_from_handler(hif_drv));
2525 PRINT_ER("Failed to set remain on channel\n");
2529 P2P_LISTEN_STATE = 1;
2530 hif_drv->hRemainOnChannel.data = (unsigned long)hif_drv;
2531 mod_timer(&hif_drv->hRemainOnChannel,
2533 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
2535 if (hif_drv->remain_on_ch.pRemainOnChanReady)
2536 hif_drv->remain_on_ch.pRemainOnChanReady(hif_drv->remain_on_ch.pVoid);
2538 if (hif_drv->remain_on_ch_pending)
2539 hif_drv->remain_on_ch_pending = 0;
2545 static int Handle_RegisterFrame(struct host_if_drv *hif_drv,
2546 struct reg_frame *pstrHostIfRegisterFrame)
2552 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
2554 wid.id = (u16)WID_REGISTER_FRAME;
2556 wid.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
2560 pu8CurrByte = wid.val;
2562 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
2563 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
2564 memcpy(pu8CurrByte, &pstrHostIfRegisterFrame->u16FrameType,
2567 wid.size = sizeof(u16) + 2;
2569 result = send_config_pkt(SET_CFG, &wid, 1,
2570 get_id_from_handler(hif_drv));
2572 PRINT_ER("Failed to frame register config packet\n");
2579 static u32 Handle_ListenStateExpired(struct host_if_drv *hif_drv,
2580 struct remain_ch *pstrHostIfRemainOnChan)
2582 u8 u8remain_on_chan_flag;
2586 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
2588 if (P2P_LISTEN_STATE) {
2589 u8remain_on_chan_flag = false;
2590 wid.id = (u16)WID_REMAIN_ON_CHAN;
2593 wid.val = kmalloc(wid.size, GFP_KERNEL);
2596 PRINT_ER("Failed to allocate memory\n");
2598 wid.val[0] = u8remain_on_chan_flag;
2599 wid.val[1] = FALSE_FRMWR_CHANNEL;
2601 result = send_config_pkt(SET_CFG, &wid, 1,
2602 get_id_from_handler(hif_drv));
2604 PRINT_ER("Failed to set remain on channel\n");
2608 if (hif_drv->remain_on_ch.pRemainOnChanExpired) {
2609 hif_drv->remain_on_ch.pRemainOnChanExpired(hif_drv->remain_on_ch.pVoid,
2610 pstrHostIfRemainOnChan->u32ListenSessionID);
2612 P2P_LISTEN_STATE = 0;
2614 PRINT_D(GENERIC_DBG, "Not in listen state\n");
2622 static void ListenTimerCB(unsigned long arg)
2625 struct host_if_msg msg;
2626 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
2628 del_timer(&hif_drv->hRemainOnChannel);
2630 memset(&msg, 0, sizeof(struct host_if_msg));
2631 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
2633 msg.body.remain_on_ch.u32ListenSessionID = hif_drv->remain_on_ch.u32ListenSessionID;
2635 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2637 PRINT_ER("wilc_mq_send fail\n");
2640 static void Handle_PowerManagement(struct host_if_drv *hif_drv,
2641 struct power_mgmt_param *strPowerMgmtParam)
2647 wid.id = (u16)WID_POWER_MANAGEMENT;
2649 if (strPowerMgmtParam->enabled)
2650 s8PowerMode = MIN_FAST_PS;
2652 s8PowerMode = NO_POWERSAVE;
2653 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
2654 wid.val = &s8PowerMode;
2655 wid.size = sizeof(char);
2657 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
2659 result = send_config_pkt(SET_CFG, &wid, 1,
2660 get_id_from_handler(hif_drv));
2662 PRINT_ER("Failed to send power management config packet\n");
2665 static void Handle_SetMulticastFilter(struct host_if_drv *hif_drv,
2666 struct set_multicast *strHostIfSetMulti)
2672 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
2674 wid.id = (u16)WID_SETUP_MULTICAST_FILTER;
2676 wid.size = sizeof(struct set_multicast) + ((strHostIfSetMulti->cnt) * ETH_ALEN);
2677 wid.val = kmalloc(wid.size, GFP_KERNEL);
2681 pu8CurrByte = wid.val;
2682 *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF);
2683 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 8) & 0xFF);
2684 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 16) & 0xFF);
2685 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 24) & 0xFF);
2687 *pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF);
2688 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF);
2689 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 16) & 0xFF);
2690 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 24) & 0xFF);
2692 if ((strHostIfSetMulti->cnt) > 0)
2693 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->cnt) * ETH_ALEN));
2695 result = send_config_pkt(SET_CFG, &wid, 1,
2696 get_id_from_handler(hif_drv));
2698 PRINT_ER("Failed to send setup multicast config packet\n");
2704 static s32 Handle_AddBASession(struct host_if_drv *hif_drv,
2705 struct ba_session_info *strHostIfBASessionInfo)
2709 int AddbaTimeout = 100;
2712 PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\nBufferSize == %d\nSessionTimeOut = %d\n",
2713 strHostIfBASessionInfo->au8Bssid[0],
2714 strHostIfBASessionInfo->au8Bssid[1],
2715 strHostIfBASessionInfo->au8Bssid[2],
2716 strHostIfBASessionInfo->u16BufferSize,
2717 strHostIfBASessionInfo->u16SessionTimeout,
2718 strHostIfBASessionInfo->u8Ted);
2720 wid.id = (u16)WID_11E_P_ACTION_REQ;
2722 wid.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2723 wid.size = BLOCK_ACK_REQ_SIZE;
2728 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2730 *ptr++ = strHostIfBASessionInfo->u8Ted;
2732 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
2733 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
2734 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
2735 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
2736 *ptr++ = (AddbaTimeout & 0xFF);
2737 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
2741 result = send_config_pkt(SET_CFG, &wid, 1,
2742 get_id_from_handler(hif_drv));
2744 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
2746 wid.id = (u16)WID_11E_P_ACTION_REQ;
2753 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2755 *ptr++ = strHostIfBASessionInfo->u8Ted;
2757 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
2758 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
2760 result = send_config_pkt(SET_CFG, &wid, 1,
2761 get_id_from_handler(hif_drv));
2768 static s32 Handle_DelAllRxBASessions(struct host_if_drv *hif_drv,
2769 struct ba_session_info *strHostIfBASessionInfo)
2775 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
2776 strHostIfBASessionInfo->au8Bssid[0],
2777 strHostIfBASessionInfo->au8Bssid[1],
2778 strHostIfBASessionInfo->au8Bssid[2],
2779 strHostIfBASessionInfo->u8Ted);
2781 wid.id = (u16)WID_DEL_ALL_RX_BA;
2783 wid.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2784 wid.size = BLOCK_ACK_REQ_SIZE;
2789 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2791 *ptr++ = strHostIfBASessionInfo->u8Ted;
2795 result = send_config_pkt(SET_CFG, &wid, 1,
2796 get_id_from_handler(hif_drv));
2798 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
2802 up(&hif_sema_wait_response);
2807 static int hostIFthread(void *pvArg)
2810 struct host_if_msg msg;
2811 struct host_if_drv *hif_drv;
2813 memset(&msg, 0, sizeof(struct host_if_msg));
2816 wilc_mq_recv(&hif_msg_q, &msg, sizeof(struct host_if_msg), &u32Ret);
2817 hif_drv = (struct host_if_drv *)msg.drv;
2818 if (msg.id == HOST_IF_MSG_EXIT) {
2819 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
2823 if ((!g_wilc_initialized)) {
2824 PRINT_D(GENERIC_DBG, "--WAIT--");
2825 usleep_range(200 * 1000, 200 * 1000);
2826 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2830 if (msg.id == HOST_IF_MSG_CONNECT &&
2831 hif_drv->usr_scan_req.pfUserScanResult) {
2832 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
2833 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2834 usleep_range(2 * 1000, 2 * 1000);
2839 case HOST_IF_MSG_Q_IDLE:
2840 Handle_wait_msg_q_empty();
2843 case HOST_IF_MSG_SCAN:
2844 Handle_Scan(msg.drv, &msg.body.scan_info);
2847 case HOST_IF_MSG_CONNECT:
2848 Handle_Connect(msg.drv, &msg.body.con_info);
2851 case HOST_IF_MSG_FLUSH_CONNECT:
2852 Handle_FlushConnect(msg.drv);
2855 case HOST_IF_MSG_RCVD_NTWRK_INFO:
2856 Handle_RcvdNtwrkInfo(msg.drv, &msg.body.net_info);
2859 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
2860 Handle_RcvdGnrlAsyncInfo(msg.drv, &msg.body.async_info);
2863 case HOST_IF_MSG_KEY:
2864 Handle_Key(msg.drv, &msg.body.key_info);
2867 case HOST_IF_MSG_CFG_PARAMS:
2869 Handle_CfgParam(msg.drv, &msg.body.cfg_info);
2872 case HOST_IF_MSG_SET_CHANNEL:
2873 Handle_SetChannel(msg.drv, &msg.body.channel_info);
2876 case HOST_IF_MSG_DISCONNECT:
2877 Handle_Disconnect(msg.drv);
2880 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
2881 del_timer(&hif_drv->hScanTimer);
2882 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
2884 if (!linux_wlan_get_num_conn_ifcs())
2885 chip_sleep_manually(INFINITE_SLEEP_TIME);
2887 Handle_ScanDone(msg.drv, SCAN_EVENT_DONE);
2889 if (hif_drv->remain_on_ch_pending)
2890 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
2894 case HOST_IF_MSG_GET_RSSI:
2895 Handle_GetRssi(msg.drv);
2898 case HOST_IF_MSG_GET_LINKSPEED:
2899 Handle_GetLinkspeed(msg.drv);
2902 case HOST_IF_MSG_GET_STATISTICS:
2903 Handle_GetStatistics(msg.drv, (struct rf_info *)msg.body.data);
2906 case HOST_IF_MSG_GET_CHNL:
2907 Handle_GetChnl(msg.drv);
2910 case HOST_IF_MSG_ADD_BEACON:
2911 Handle_AddBeacon(msg.drv, &msg.body.beacon_info);
2914 case HOST_IF_MSG_DEL_BEACON:
2915 Handle_DelBeacon(msg.drv);
2918 case HOST_IF_MSG_ADD_STATION:
2919 Handle_AddStation(msg.drv, &msg.body.add_sta_info);
2922 case HOST_IF_MSG_DEL_STATION:
2923 Handle_DelStation(msg.drv, &msg.body.del_sta_info);
2926 case HOST_IF_MSG_EDIT_STATION:
2927 Handle_EditStation(msg.drv, &msg.body.edit_sta_info);
2930 case HOST_IF_MSG_GET_INACTIVETIME:
2931 Handle_Get_InActiveTime(msg.drv, &msg.body.mac_info);
2934 case HOST_IF_MSG_SCAN_TIMER_FIRED:
2935 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
2937 Handle_ScanDone(msg.drv, SCAN_EVENT_ABORTED);
2940 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
2941 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
2942 Handle_ConnectTimeout(msg.drv);
2945 case HOST_IF_MSG_POWER_MGMT:
2946 Handle_PowerManagement(msg.drv, &msg.body.pwr_mgmt_info);
2949 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
2950 Handle_SetWfiDrvHandler(msg.drv,
2954 case HOST_IF_MSG_SET_OPERATION_MODE:
2955 Handle_SetOperationMode(msg.drv, &msg.body.mode);
2958 case HOST_IF_MSG_SET_IPADDRESS:
2959 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
2960 Handle_set_IPAddress(msg.drv, msg.body.ip_info.ip_addr, msg.body.ip_info.idx);
2963 case HOST_IF_MSG_GET_IPADDRESS:
2964 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
2965 Handle_get_IPAddress(msg.drv, msg.body.ip_info.ip_addr, msg.body.ip_info.idx);
2968 case HOST_IF_MSG_SET_MAC_ADDRESS:
2969 Handle_SetMacAddress(msg.drv, &msg.body.set_mac_info);
2972 case HOST_IF_MSG_GET_MAC_ADDRESS:
2973 Handle_GetMacAddress(msg.drv, &msg.body.get_mac_info);
2976 case HOST_IF_MSG_REMAIN_ON_CHAN:
2977 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
2978 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
2981 case HOST_IF_MSG_REGISTER_FRAME:
2982 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
2983 Handle_RegisterFrame(msg.drv, &msg.body.reg_frame);
2986 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
2987 Handle_ListenStateExpired(msg.drv, &msg.body.remain_on_ch);
2990 case HOST_IF_MSG_SET_MULTICAST_FILTER:
2991 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
2992 Handle_SetMulticastFilter(msg.drv, &msg.body.multicast_info);
2995 case HOST_IF_MSG_ADD_BA_SESSION:
2996 Handle_AddBASession(msg.drv, &msg.body.session_info);
2999 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
3000 Handle_DelAllRxBASessions(msg.drv, &msg.body.session_info);
3003 case HOST_IF_MSG_DEL_ALL_STA:
3004 Handle_DelAllSta(msg.drv, &msg.body.del_all_sta_info);
3008 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
3013 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
3014 up(&hif_sema_thread);
3018 static void TimerCB_Scan(unsigned long arg)
3020 void *pvArg = (void *)arg;
3021 struct host_if_msg msg;
3023 memset(&msg, 0, sizeof(struct host_if_msg));
3025 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
3027 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3030 static void TimerCB_Connect(unsigned long arg)
3032 void *pvArg = (void *)arg;
3033 struct host_if_msg msg;
3035 memset(&msg, 0, sizeof(struct host_if_msg));
3037 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
3039 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3042 s32 host_int_remove_key(struct host_if_drv *hif_drv, const u8 *pu8StaAddress)
3046 wid.id = (u16)WID_REMOVE_KEY;
3048 wid.val = (s8 *)pu8StaAddress;
3054 int host_int_remove_wep_key(struct host_if_drv *hif_drv, u8 index)
3057 struct host_if_msg msg;
3061 PRINT_ER("Failed to send setup multicast config packet\n");
3065 memset(&msg, 0, sizeof(struct host_if_msg));
3067 msg.id = HOST_IF_MSG_KEY;
3068 msg.body.key_info.type = WEP;
3069 msg.body.key_info.action = REMOVEKEY;
3071 msg.body.key_info.attr.wep.index = index;
3073 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3075 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
3076 down(&hif_drv->hSemTestKeyBlock);
3081 int host_int_set_wep_default_key(struct host_if_drv *hif_drv, u8 index)
3084 struct host_if_msg msg;
3088 PRINT_ER("driver is null\n");
3092 memset(&msg, 0, sizeof(struct host_if_msg));
3094 msg.id = HOST_IF_MSG_KEY;
3095 msg.body.key_info.type = WEP;
3096 msg.body.key_info.action = DEFAULTKEY;
3098 msg.body.key_info.attr.wep.index = index;
3100 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3102 PRINT_ER("Error in sending message queue : Default key index\n");
3103 down(&hif_drv->hSemTestKeyBlock);
3108 int host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv,
3114 struct host_if_msg msg;
3117 PRINT_ER("driver is null\n");
3121 memset(&msg, 0, sizeof(struct host_if_msg));
3123 msg.id = HOST_IF_MSG_KEY;
3124 msg.body.key_info.type = WEP;
3125 msg.body.key_info.action = ADDKEY;
3127 msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
3128 if (!msg.body.key_info.attr.wep.key)
3131 msg.body.key_info.attr.wep.key_len = len;
3132 msg.body.key_info.attr.wep.index = index;
3134 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3136 PRINT_ER("Error in sending message queue :WEP Key\n");
3137 down(&hif_drv->hSemTestKeyBlock);
3142 int host_int_add_wep_key_bss_ap(struct host_if_drv *hif_drv,
3147 enum AUTHTYPE auth_type)
3150 struct host_if_msg msg;
3154 PRINT_ER("driver is null\n");
3158 memset(&msg, 0, sizeof(struct host_if_msg));
3161 for (i = 0; i < len; i++)
3162 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", key[i]);
3164 msg.id = HOST_IF_MSG_KEY;
3165 msg.body.key_info.type = WEP;
3166 msg.body.key_info.action = ADDKEY_AP;
3168 msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
3169 if (!msg.body.key_info.attr.wep.key)
3172 msg.body.key_info.attr.wep.key_len = len;
3173 msg.body.key_info.attr.wep.index = index;
3174 msg.body.key_info.attr.wep.mode = mode;
3175 msg.body.key_info.attr.wep.auth_type = auth_type;
3177 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3180 PRINT_ER("Error in sending message queue :WEP Key\n");
3181 down(&hif_drv->hSemTestKeyBlock);
3186 s32 host_int_add_ptk(struct host_if_drv *hif_drv, const u8 *pu8Ptk,
3187 u8 u8PtkKeylen, const u8 *mac_addr,
3188 const u8 *pu8RxMic, const u8 *pu8TxMic,
3189 u8 mode, u8 u8Ciphermode, u8 u8Idx)
3192 struct host_if_msg msg;
3193 u8 u8KeyLen = u8PtkKeylen;
3197 PRINT_ER("driver is null\n");
3202 u8KeyLen += RX_MIC_KEY_LEN;
3205 u8KeyLen += TX_MIC_KEY_LEN;
3207 memset(&msg, 0, sizeof(struct host_if_msg));
3209 msg.id = HOST_IF_MSG_KEY;
3210 msg.body.key_info.type = WPAPtk;
3211 if (mode == AP_MODE) {
3212 msg.body.key_info.action = ADDKEY_AP;
3213 msg.body.key_info.attr.wpa.index = u8Idx;
3215 if (mode == STATION_MODE)
3216 msg.body.key_info.action = ADDKEY;
3218 msg.body.key_info.attr.wpa.key = kmalloc(u8PtkKeylen, GFP_KERNEL);
3219 memcpy(msg.body.key_info.attr.wpa.key, pu8Ptk, u8PtkKeylen);
3222 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic, RX_MIC_KEY_LEN);
3224 for (i = 0; i < RX_MIC_KEY_LEN; i++)
3225 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
3229 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic, TX_MIC_KEY_LEN);
3231 for (i = 0; i < TX_MIC_KEY_LEN; i++)
3232 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
3236 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
3237 msg.body.key_info.attr.wpa.mac_addr = mac_addr;
3238 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
3241 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3244 PRINT_ER("Error in sending message queue: PTK Key\n");
3246 down(&hif_drv->hSemTestKeyBlock);
3251 s32 host_int_add_rx_gtk(struct host_if_drv *hif_drv, const u8 *pu8RxGtk,
3252 u8 u8GtkKeylen, u8 u8KeyIdx,
3253 u32 u32KeyRSClen, const u8 *KeyRSC,
3254 const u8 *pu8RxMic, const u8 *pu8TxMic,
3255 u8 mode, u8 u8Ciphermode)
3258 struct host_if_msg msg;
3259 u8 u8KeyLen = u8GtkKeylen;
3262 PRINT_ER("driver is null\n");
3265 memset(&msg, 0, sizeof(struct host_if_msg));
3268 u8KeyLen += RX_MIC_KEY_LEN;
3271 u8KeyLen += TX_MIC_KEY_LEN;
3274 msg.body.key_info.attr.wpa.seq = kmalloc(u32KeyRSClen, GFP_KERNEL);
3275 memcpy(msg.body.key_info.attr.wpa.seq, KeyRSC, u32KeyRSClen);
3278 msg.id = HOST_IF_MSG_KEY;
3279 msg.body.key_info.type = WPARxGtk;
3282 if (mode == AP_MODE) {
3283 msg.body.key_info.action = ADDKEY_AP;
3284 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
3286 if (mode == STATION_MODE)
3287 msg.body.key_info.action = ADDKEY;
3289 msg.body.key_info.attr.wpa.key = kmalloc(u8KeyLen, GFP_KERNEL);
3290 memcpy(msg.body.key_info.attr.wpa.key, pu8RxGtk, u8GtkKeylen);
3293 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic,
3297 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic,
3300 msg.body.key_info.attr.wpa.index = u8KeyIdx;
3301 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
3302 msg.body.key_info.attr.wpa.seq_len = u32KeyRSClen;
3304 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3306 PRINT_ER("Error in sending message queue: RX GTK\n");
3308 down(&hif_drv->hSemTestKeyBlock);
3313 s32 host_int_set_pmkid_info(struct host_if_drv *hif_drv, struct host_if_pmkid_attr *pu8PmkidInfoArray)
3316 struct host_if_msg msg;
3320 PRINT_ER("driver is null\n");
3324 memset(&msg, 0, sizeof(struct host_if_msg));
3326 msg.id = HOST_IF_MSG_KEY;
3327 msg.body.key_info.type = PMKSA;
3328 msg.body.key_info.action = ADDKEY;
3331 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
3332 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].bssid,
3333 &pu8PmkidInfoArray->pmkidlist[i].bssid, ETH_ALEN);
3334 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].pmkid,
3335 &pu8PmkidInfoArray->pmkidlist[i].pmkid, PMKID_LEN);
3338 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3340 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
3345 s32 host_int_get_pmkid_info(struct host_if_drv *hif_drv,
3346 u8 *pu8PmkidInfoArray,
3347 u32 u32PmkidInfoLen)
3351 wid.id = (u16)WID_PMKID_INFO;
3353 wid.size = u32PmkidInfoLen;
3354 wid.val = pu8PmkidInfoArray;
3359 s32 host_int_set_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3365 if ((u8Psklength > 7) && (u8Psklength < 65)) {
3366 wid.id = (u16)WID_11I_PSK;
3368 wid.val = pu8PassPhrase;
3369 wid.size = u8Psklength;
3375 s32 host_int_get_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
3378 struct host_if_msg msg;
3380 memset(&msg, 0, sizeof(struct host_if_msg));
3382 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
3383 msg.body.get_mac_info.mac_addr = pu8MacAddress;
3386 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3388 PRINT_ER("Failed to send get mac address\n");
3392 down(&hif_sema_wait_response);
3396 s32 host_int_set_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
3399 struct host_if_msg msg;
3401 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
3403 memset(&msg, 0, sizeof(struct host_if_msg));
3404 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
3405 memcpy(msg.body.set_mac_info.mac_addr, pu8MacAddress, ETH_ALEN);
3408 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3410 PRINT_ER("Failed to send message queue: Set mac address\n");
3415 s32 host_int_get_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3416 u8 *pu8PassPhrase, u8 u8Psklength)
3420 wid.id = (u16)WID_11I_PSK;
3422 wid.size = u8Psklength;
3423 wid.val = pu8PassPhrase;
3428 s32 host_int_set_start_scan_req(struct host_if_drv *hif_drv, u8 scanSource)
3432 wid.id = (u16)WID_START_SCAN_REQ;
3433 wid.type = WID_CHAR;
3434 wid.val = (s8 *)&scanSource;
3435 wid.size = sizeof(char);
3440 s32 host_int_get_start_scan_req(struct host_if_drv *hif_drv, u8 *pu8ScanSource)
3444 wid.id = (u16)WID_START_SCAN_REQ;
3445 wid.type = WID_CHAR;
3446 wid.val = (s8 *)pu8ScanSource;
3447 wid.size = sizeof(char);
3452 s32 host_int_set_join_req(struct host_if_drv *hif_drv, u8 *pu8bssid,
3453 const u8 *pu8ssid, size_t ssidLen,
3454 const u8 *pu8IEs, size_t IEsLen,
3455 wilc_connect_result pfConnectResult, void *pvUserArg,
3456 u8 u8security, enum AUTHTYPE tenuAuth_type,
3457 u8 u8channel, void *pJoinParams)
3460 struct host_if_msg msg;
3462 if (!hif_drv || !pfConnectResult) {
3463 PRINT_ER("Driver is null\n");
3468 PRINT_ER("Unable to Join - JoinParams is NULL\n");
3472 memset(&msg, 0, sizeof(struct host_if_msg));
3474 msg.id = HOST_IF_MSG_CONNECT;
3476 msg.body.con_info.security = u8security;
3477 msg.body.con_info.auth_type = tenuAuth_type;
3478 msg.body.con_info.ch = u8channel;
3479 msg.body.con_info.result = pfConnectResult;
3480 msg.body.con_info.arg = pvUserArg;
3481 msg.body.con_info.params = pJoinParams;
3485 msg.body.con_info.bssid = kmalloc(6, GFP_KERNEL);
3486 memcpy(msg.body.con_info.bssid, pu8bssid, 6);
3490 msg.body.con_info.ssid_len = ssidLen;
3491 msg.body.con_info.ssid = kmalloc(ssidLen, GFP_KERNEL);
3492 memcpy(msg.body.con_info.ssid, pu8ssid, ssidLen);
3496 msg.body.con_info.ies_len = IEsLen;
3497 msg.body.con_info.ies = kmalloc(IEsLen, GFP_KERNEL);
3498 memcpy(msg.body.con_info.ies, pu8IEs, IEsLen);
3500 if (hif_drv->enuHostIFstate < HOST_IF_CONNECTING)
3501 hif_drv->enuHostIFstate = HOST_IF_CONNECTING;
3503 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", hif_drv->enuHostIFstate);
3505 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3507 PRINT_ER("Failed to send message queue: Set join request\n");
3511 hif_drv->hConnectTimer.data = (unsigned long)hif_drv;
3512 mod_timer(&hif_drv->hConnectTimer,
3513 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
3518 s32 host_int_flush_join_req(struct host_if_drv *hif_drv)
3521 struct host_if_msg msg;
3527 PRINT_ER("Driver is null\n");
3531 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
3534 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3536 PRINT_ER("Failed to send message queue: Flush join request\n");
3543 s32 host_int_disconnect(struct host_if_drv *hif_drv, u16 u16ReasonCode)
3546 struct host_if_msg msg;
3549 PRINT_ER("Driver is null\n");
3553 memset(&msg, 0, sizeof(struct host_if_msg));
3555 msg.id = HOST_IF_MSG_DISCONNECT;
3558 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3560 PRINT_ER("Failed to send message queue: disconnect\n");
3562 down(&hif_drv->hSemTestDisconnectBlock);
3567 s32 host_int_disconnect_station(struct host_if_drv *hif_drv, u8 assoc_id)
3571 wid.id = (u16)WID_DISCONNECT;
3572 wid.type = WID_CHAR;
3573 wid.val = (s8 *)&assoc_id;
3574 wid.size = sizeof(char);
3579 s32 host_int_get_assoc_req_info(struct host_if_drv *hif_drv,
3580 u8 *pu8AssocReqInfo,
3581 u32 u32AssocReqInfoLen)
3585 wid.id = (u16)WID_ASSOC_REQ_INFO;
3587 wid.val = pu8AssocReqInfo;
3588 wid.size = u32AssocReqInfoLen;
3593 s32 host_int_get_assoc_res_info(struct host_if_drv *hif_drv,
3594 u8 *pu8AssocRespInfo,
3595 u32 u32MaxAssocRespInfoLen,
3596 u32 *pu32RcvdAssocRespInfoLen)
3602 PRINT_ER("Driver is null\n");
3606 wid.id = (u16)WID_ASSOC_RES_INFO;
3608 wid.val = pu8AssocRespInfo;
3609 wid.size = u32MaxAssocRespInfoLen;
3611 result = send_config_pkt(GET_CFG, &wid, 1,
3612 get_id_from_handler(hif_drv));
3614 *pu32RcvdAssocRespInfoLen = 0;
3615 PRINT_ER("Failed to send association response config packet\n");
3618 *pu32RcvdAssocRespInfoLen = wid.size;
3624 s32 host_int_get_rx_power_level(struct host_if_drv *hif_drv,
3625 u8 *pu8RxPowerLevel,
3626 u32 u32RxPowerLevelLen)
3630 wid.id = (u16)WID_RX_POWER_LEVEL;
3632 wid.val = pu8RxPowerLevel;
3633 wid.size = u32RxPowerLevelLen;
3638 int host_int_set_mac_chnl_num(struct host_if_drv *hif_drv, u8 channel)
3641 struct host_if_msg msg;
3644 PRINT_ER("driver is null\n");
3648 memset(&msg, 0, sizeof(struct host_if_msg));
3649 msg.id = HOST_IF_MSG_SET_CHANNEL;
3650 msg.body.channel_info.set_ch = channel;
3653 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3655 PRINT_ER("wilc mq send fail\n");
3662 int host_int_wait_msg_queue_idle(void)
3665 struct host_if_msg msg;
3667 memset(&msg, 0, sizeof(struct host_if_msg));
3668 msg.id = HOST_IF_MSG_Q_IDLE;
3669 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3671 PRINT_ER("wilc mq send fail\n");
3675 down(&hif_sema_wait_response);
3680 int host_int_set_wfi_drv_handler(struct host_if_drv *hif_drv)
3683 struct host_if_msg msg;
3685 memset(&msg, 0, sizeof(struct host_if_msg));
3686 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
3687 msg.body.drv.handler = get_id_from_handler(hif_drv);
3690 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3692 PRINT_ER("wilc mq send fail\n");
3699 int host_int_set_operation_mode(struct host_if_drv *hif_drv, u32 mode)
3702 struct host_if_msg msg;
3704 memset(&msg, 0, sizeof(struct host_if_msg));
3705 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
3706 msg.body.mode.mode = mode;
3709 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3711 PRINT_ER("wilc mq send fail\n");
3718 s32 host_int_get_host_chnl_num(struct host_if_drv *hif_drv, u8 *pu8ChNo)
3721 struct host_if_msg msg;
3724 PRINT_ER("driver is null\n");
3728 memset(&msg, 0, sizeof(struct host_if_msg));
3730 msg.id = HOST_IF_MSG_GET_CHNL;
3733 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3735 PRINT_ER("wilc mq send fail\n");
3736 down(&hif_drv->hSemGetCHNL);
3743 s32 host_int_get_inactive_time(struct host_if_drv *hif_drv,
3744 const u8 *mac, u32 *pu32InactiveTime)
3747 struct host_if_msg msg;
3750 PRINT_ER("driver is null\n");
3754 memset(&msg, 0, sizeof(struct host_if_msg));
3755 memcpy(msg.body.mac_info.mac, mac, ETH_ALEN);
3757 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
3760 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3762 PRINT_ER("Failed to send get host channel param's message queue ");
3764 down(&hif_drv->hSemInactiveTime);
3766 *pu32InactiveTime = inactive_time;
3771 s32 host_int_test_get_int_wid(struct host_if_drv *hif_drv, u32 *pu32TestMemAddr)
3777 PRINT_ER("driver is null\n");
3781 wid.id = (u16)WID_MEMORY_ADDRESS;
3783 wid.val = (s8 *)pu32TestMemAddr;
3784 wid.size = sizeof(u32);
3786 result = send_config_pkt(GET_CFG, &wid, 1,
3787 get_id_from_handler(hif_drv));
3790 PRINT_ER("Failed to get wid value\n");
3793 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
3799 s32 host_int_get_rssi(struct host_if_drv *hif_drv, s8 *ps8Rssi)
3802 struct host_if_msg msg;
3804 memset(&msg, 0, sizeof(struct host_if_msg));
3805 msg.id = HOST_IF_MSG_GET_RSSI;
3808 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3810 PRINT_ER("Failed to send get host channel param's message queue ");
3814 down(&hif_drv->hSemGetRSSI);
3817 PRINT_ER("RSS pointer value is null");
3826 s32 host_int_get_link_speed(struct host_if_drv *hif_drv, s8 *ps8lnkspd)
3828 struct host_if_msg msg;
3831 memset(&msg, 0, sizeof(struct host_if_msg));
3832 msg.id = HOST_IF_MSG_GET_LINKSPEED;
3835 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3837 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
3841 down(&hif_drv->hSemGetLINKSPEED);
3844 PRINT_ER("LINKSPEED pointer value is null");
3848 *ps8lnkspd = link_speed;
3853 s32 host_int_get_statistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
3856 struct host_if_msg msg;
3858 memset(&msg, 0, sizeof(struct host_if_msg));
3859 msg.id = HOST_IF_MSG_GET_STATISTICS;
3860 msg.body.data = (char *)pstrStatistics;
3863 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3865 PRINT_ER("Failed to send get host channel param's message queue ");
3869 down(&hif_sema_wait_response);
3873 s32 host_int_scan(struct host_if_drv *hif_drv, u8 u8ScanSource,
3874 u8 u8ScanType, u8 *pu8ChnlFreqList,
3875 u8 u8ChnlListLen, const u8 *pu8IEs,
3876 size_t IEsLen, wilc_scan_result ScanResult,
3877 void *pvUserArg, struct hidden_network *pstrHiddenNetwork)
3880 struct host_if_msg msg;
3882 if (!hif_drv || !ScanResult) {
3883 PRINT_ER("hif_drv or ScanResult = NULL\n");
3887 memset(&msg, 0, sizeof(struct host_if_msg));
3889 msg.id = HOST_IF_MSG_SCAN;
3891 if (pstrHiddenNetwork) {
3892 msg.body.scan_info.hidden_network.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
3893 msg.body.scan_info.hidden_network.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
3896 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
3899 msg.body.scan_info.src = u8ScanSource;
3900 msg.body.scan_info.type = u8ScanType;
3901 msg.body.scan_info.result = ScanResult;
3902 msg.body.scan_info.arg = pvUserArg;
3904 msg.body.scan_info.ch_list_len = u8ChnlListLen;
3905 msg.body.scan_info.ch_freq_list = kmalloc(u8ChnlListLen, GFP_KERNEL);
3906 memcpy(msg.body.scan_info.ch_freq_list, pu8ChnlFreqList, u8ChnlListLen);
3908 msg.body.scan_info.ies_len = IEsLen;
3909 msg.body.scan_info.ies = kmalloc(IEsLen, GFP_KERNEL);
3910 memcpy(msg.body.scan_info.ies, pu8IEs, IEsLen);
3912 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3914 PRINT_ER("Error in sending message queue\n");
3918 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
3919 hif_drv->hScanTimer.data = (unsigned long)hif_drv;
3920 mod_timer(&hif_drv->hScanTimer,
3921 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
3926 s32 hif_set_cfg(struct host_if_drv *hif_drv,
3927 struct cfg_param_val *pstrCfgParamVal)
3930 struct host_if_msg msg;
3933 PRINT_ER("hif_drv NULL\n");
3937 memset(&msg, 0, sizeof(struct host_if_msg));
3938 msg.id = HOST_IF_MSG_CFG_PARAMS;
3939 msg.body.cfg_info.cfg_attr_info = *pstrCfgParamVal;
3942 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3947 s32 hif_get_cfg(struct host_if_drv *hif_drv, u16 u16WID, u16 *pu16WID_Value)
3951 down(&hif_drv->gtOsCfgValuesSem);
3954 PRINT_ER("hif_drv NULL\n");
3957 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
3960 *pu16WID_Value = (u16)hif_drv->strCfgValues.bss_type;
3964 *pu16WID_Value = (u16)hif_drv->strCfgValues.auth_type;
3967 case WID_AUTH_TIMEOUT:
3968 *pu16WID_Value = hif_drv->strCfgValues.auth_timeout;
3971 case WID_POWER_MANAGEMENT:
3972 *pu16WID_Value = (u16)hif_drv->strCfgValues.power_mgmt_mode;
3975 case WID_SHORT_RETRY_LIMIT:
3976 *pu16WID_Value = hif_drv->strCfgValues.short_retry_limit;
3979 case WID_LONG_RETRY_LIMIT:
3980 *pu16WID_Value = hif_drv->strCfgValues.long_retry_limit;
3983 case WID_FRAG_THRESHOLD:
3984 *pu16WID_Value = hif_drv->strCfgValues.frag_threshold;
3987 case WID_RTS_THRESHOLD:
3988 *pu16WID_Value = hif_drv->strCfgValues.rts_threshold;
3992 *pu16WID_Value = (u16)hif_drv->strCfgValues.preamble_type;
3995 case WID_SHORT_SLOT_ALLOWED:
3996 *pu16WID_Value = (u16) hif_drv->strCfgValues.short_slot_allowed;
3999 case WID_11N_TXOP_PROT_DISABLE:
4000 *pu16WID_Value = (u16)hif_drv->strCfgValues.txop_prot_disabled;
4003 case WID_BEACON_INTERVAL:
4004 *pu16WID_Value = hif_drv->strCfgValues.beacon_interval;
4007 case WID_DTIM_PERIOD:
4008 *pu16WID_Value = (u16)hif_drv->strCfgValues.dtim_period;
4011 case WID_SITE_SURVEY:
4012 *pu16WID_Value = (u16)hif_drv->strCfgValues.site_survey_enabled;
4015 case WID_SITE_SURVEY_SCAN_TIME:
4016 *pu16WID_Value = hif_drv->strCfgValues.site_survey_scan_time;
4019 case WID_ACTIVE_SCAN_TIME:
4020 *pu16WID_Value = hif_drv->strCfgValues.active_scan_time;
4023 case WID_PASSIVE_SCAN_TIME:
4024 *pu16WID_Value = hif_drv->strCfgValues.passive_scan_time;
4027 case WID_CURRENT_TX_RATE:
4028 *pu16WID_Value = hif_drv->strCfgValues.curr_tx_rate;
4035 up(&hif_drv->gtOsCfgValuesSem);
4040 static void GetPeriodicRSSI(unsigned long arg)
4042 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
4045 PRINT_ER("Driver handler is NULL\n");
4049 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED) {
4051 struct host_if_msg msg;
4053 memset(&msg, 0, sizeof(struct host_if_msg));
4055 msg.id = HOST_IF_MSG_GET_RSSI;
4058 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4060 PRINT_ER("Failed to send get host channel param's message queue ");
4064 periodic_rssi.data = (unsigned long)hif_drv;
4065 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
4068 s32 host_int_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
4071 struct host_if_drv *hif_drv;
4073 perInterface_wlan_t *nic;
4076 nic = netdev_priv(dev);
4079 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
4081 scan_while_connected = false;
4083 sema_init(&hif_sema_wait_response, 0);
4085 hif_drv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
4090 *hif_drv_handler = hif_drv;
4091 err = add_handler_in_list(hif_drv);
4097 g_obtainingIP = false;
4099 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", hif_drv);
4100 if (clients_count == 0) {
4101 sema_init(&hif_sema_thread, 0);
4102 sema_init(&hif_sema_driver, 0);
4103 sema_init(&hif_sema_deinit, 1);
4106 sema_init(&hif_drv->hSemTestKeyBlock, 0);
4107 sema_init(&hif_drv->hSemTestDisconnectBlock, 0);
4108 sema_init(&hif_drv->hSemGetRSSI, 0);
4109 sema_init(&hif_drv->hSemGetLINKSPEED, 0);
4110 sema_init(&hif_drv->hSemGetCHNL, 0);
4111 sema_init(&hif_drv->hSemInactiveTime, 0);
4113 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
4115 if (clients_count == 0) {
4116 result = wilc_mq_create(&hif_msg_q);
4119 PRINT_ER("Failed to creat MQ\n");
4123 hif_thread_handler = kthread_run(hostIFthread, wilc,
4126 if (IS_ERR(hif_thread_handler)) {
4127 PRINT_ER("Failed to creat Thread\n");
4131 setup_timer(&periodic_rssi, GetPeriodicRSSI,
4132 (unsigned long)hif_drv);
4133 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
4136 setup_timer(&hif_drv->hScanTimer, TimerCB_Scan, 0);
4138 setup_timer(&hif_drv->hConnectTimer, TimerCB_Connect, 0);
4140 setup_timer(&hif_drv->hRemainOnChannel, ListenTimerCB, 0);
4142 sema_init(&hif_drv->gtOsCfgValuesSem, 1);
4143 down(&hif_drv->gtOsCfgValuesSem);
4145 hif_drv->enuHostIFstate = HOST_IF_IDLE;
4146 hif_drv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
4147 hif_drv->strCfgValues.scan_source = DEFAULT_SCAN;
4148 hif_drv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
4149 hif_drv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
4150 hif_drv->strCfgValues.curr_tx_rate = AUTORATE;
4152 hif_drv->u64P2p_MgmtTimeout = 0;
4154 PRINT_INFO(HOSTINF_DBG, "Initialization values, Site survey value: %d\n Scan source: %d\n Active scan time: %d\n Passive scan time: %d\nCurrent tx Rate = %d\n",
4156 hif_drv->strCfgValues.site_survey_enabled, hif_drv->strCfgValues.scan_source,
4157 hif_drv->strCfgValues.active_scan_time, hif_drv->strCfgValues.passive_scan_time,
4158 hif_drv->strCfgValues.curr_tx_rate);
4160 up(&hif_drv->gtOsCfgValuesSem);
4167 up(&hif_drv->gtOsCfgValuesSem);
4168 del_timer_sync(&hif_drv->hConnectTimer);
4169 del_timer_sync(&hif_drv->hScanTimer);
4170 kthread_stop(hif_thread_handler);
4172 wilc_mq_destroy(&hif_msg_q);
4177 s32 host_int_deinit(struct host_if_drv *hif_drv)
4180 struct host_if_msg msg;
4184 PRINT_ER("hif_drv = NULL\n");
4188 down(&hif_sema_deinit);
4190 terminated_handle = hif_drv;
4191 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
4193 if (del_timer_sync(&hif_drv->hScanTimer))
4194 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
4196 if (del_timer_sync(&hif_drv->hConnectTimer))
4197 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4199 if (del_timer_sync(&periodic_rssi))
4200 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4202 del_timer_sync(&hif_drv->hRemainOnChannel);
4204 host_int_set_wfi_drv_handler(NULL);
4205 down(&hif_sema_driver);
4207 if (hif_drv->usr_scan_req.pfUserScanResult) {
4208 hif_drv->usr_scan_req.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
4209 hif_drv->usr_scan_req.u32UserScanPvoid, NULL);
4211 hif_drv->usr_scan_req.pfUserScanResult = NULL;
4214 hif_drv->enuHostIFstate = HOST_IF_IDLE;
4216 scan_while_connected = false;
4218 memset(&msg, 0, sizeof(struct host_if_msg));
4220 if (clients_count == 1) {
4221 if (del_timer_sync(&periodic_rssi))
4222 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4224 msg.id = HOST_IF_MSG_EXIT;
4227 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4229 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", result);
4231 down(&hif_sema_thread);
4233 wilc_mq_destroy(&hif_msg_q);
4236 down(&hif_drv->gtOsCfgValuesSem);
4238 ret = remove_handler_in_list(hif_drv);
4245 terminated_handle = NULL;
4246 up(&hif_sema_deinit);
4250 void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
4253 struct host_if_msg msg;
4255 struct host_if_drv *hif_drv = NULL;
4257 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4258 hif_drv = get_handler_from_id(id);
4260 if (!hif_drv || hif_drv == terminated_handle) {
4261 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv);
4265 memset(&msg, 0, sizeof(struct host_if_msg));
4267 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
4270 msg.body.net_info.len = u32Length;
4271 msg.body.net_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4272 memcpy(msg.body.net_info.buffer, pu8Buffer, u32Length);
4274 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4276 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", result);
4279 void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
4282 struct host_if_msg msg;
4284 struct host_if_drv *hif_drv = NULL;
4286 down(&hif_sema_deinit);
4288 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4289 hif_drv = get_handler_from_id(id);
4290 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
4292 if (!hif_drv || hif_drv == terminated_handle) {
4293 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
4294 up(&hif_sema_deinit);
4298 if (!hif_drv->usr_conn_req.pfUserConnectResult) {
4299 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
4300 up(&hif_sema_deinit);
4304 memset(&msg, 0, sizeof(struct host_if_msg));
4306 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
4309 msg.body.async_info.len = u32Length;
4310 msg.body.async_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4311 memcpy(msg.body.async_info.buffer, pu8Buffer, u32Length);
4313 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4315 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", result);
4317 up(&hif_sema_deinit);
4320 void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
4323 struct host_if_msg msg;
4325 struct host_if_drv *hif_drv = NULL;
4327 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4328 hif_drv = get_handler_from_id(id);
4330 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", hif_drv);
4332 if (!hif_drv || hif_drv == terminated_handle)
4335 if (hif_drv->usr_scan_req.pfUserScanResult) {
4336 memset(&msg, 0, sizeof(struct host_if_msg));
4338 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
4341 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4343 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", result);
4349 s32 host_int_remain_on_channel(struct host_if_drv *hif_drv, u32 u32SessionID,
4350 u32 u32duration, u16 chan,
4351 wilc_remain_on_chan_expired RemainOnChanExpired,
4352 wilc_remain_on_chan_ready RemainOnChanReady,
4356 struct host_if_msg msg;
4359 PRINT_ER("driver is null\n");
4363 memset(&msg, 0, sizeof(struct host_if_msg));
4365 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
4366 msg.body.remain_on_ch.u16Channel = chan;
4367 msg.body.remain_on_ch.pRemainOnChanExpired = RemainOnChanExpired;
4368 msg.body.remain_on_ch.pRemainOnChanReady = RemainOnChanReady;
4369 msg.body.remain_on_ch.pVoid = pvUserArg;
4370 msg.body.remain_on_ch.u32duration = u32duration;
4371 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
4374 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4376 PRINT_ER("wilc mq send fail\n");
4381 s32 host_int_ListenStateExpired(struct host_if_drv *hif_drv, u32 u32SessionID)
4384 struct host_if_msg msg;
4387 PRINT_ER("driver is null\n");
4391 del_timer(&hif_drv->hRemainOnChannel);
4393 memset(&msg, 0, sizeof(struct host_if_msg));
4394 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
4396 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
4398 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4400 PRINT_ER("wilc mq send fail\n");
4405 s32 host_int_frame_register(struct host_if_drv *hif_drv, u16 u16FrameType, bool bReg)
4408 struct host_if_msg msg;
4411 PRINT_ER("driver is null\n");
4415 memset(&msg, 0, sizeof(struct host_if_msg));
4417 msg.id = HOST_IF_MSG_REGISTER_FRAME;
4418 switch (u16FrameType) {
4420 PRINT_D(HOSTINF_DBG, "ACTION\n");
4421 msg.body.reg_frame.u8Regid = ACTION_FRM_IDX;
4425 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
4426 msg.body.reg_frame.u8Regid = PROBE_REQ_IDX;
4430 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
4433 msg.body.reg_frame.u16FrameType = u16FrameType;
4434 msg.body.reg_frame.bReg = bReg;
4437 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4439 PRINT_ER("wilc mq send fail\n");
4444 s32 host_int_add_beacon(struct host_if_drv *hif_drv, u32 u32Interval,
4445 u32 u32DTIMPeriod, u32 u32HeadLen, u8 *pu8Head,
4446 u32 u32TailLen, u8 *pu8Tail)
4449 struct host_if_msg msg;
4450 struct beacon_attr *pstrSetBeaconParam = &msg.body.beacon_info;
4453 PRINT_ER("driver is null\n");
4457 memset(&msg, 0, sizeof(struct host_if_msg));
4459 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
4461 msg.id = HOST_IF_MSG_ADD_BEACON;
4463 pstrSetBeaconParam->interval = u32Interval;
4464 pstrSetBeaconParam->dtim_period = u32DTIMPeriod;
4465 pstrSetBeaconParam->head_len = u32HeadLen;
4466 pstrSetBeaconParam->head = kmemdup(pu8Head, u32HeadLen, GFP_KERNEL);
4467 if (!pstrSetBeaconParam->head) {
4471 pstrSetBeaconParam->tail_len = u32TailLen;
4473 if (u32TailLen > 0) {
4474 pstrSetBeaconParam->tail = kmemdup(pu8Tail, u32TailLen,
4476 if (!pstrSetBeaconParam->tail) {
4481 pstrSetBeaconParam->tail = NULL;
4484 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4486 PRINT_ER("wilc mq send fail\n");
4490 kfree(pstrSetBeaconParam->head);
4492 kfree(pstrSetBeaconParam->tail);
4498 s32 host_int_del_beacon(struct host_if_drv *hif_drv)
4501 struct host_if_msg msg;
4504 PRINT_ER("driver is null\n");
4508 msg.id = HOST_IF_MSG_DEL_BEACON;
4510 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
4512 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4514 PRINT_ER("wilc_mq_send fail\n");
4519 s32 host_int_add_station(struct host_if_drv *hif_drv,
4520 struct add_sta_param *pstrStaParams)
4523 struct host_if_msg msg;
4524 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
4527 PRINT_ER("driver is null\n");
4531 memset(&msg, 0, sizeof(struct host_if_msg));
4533 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
4535 msg.id = HOST_IF_MSG_ADD_STATION;
4538 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
4539 if (pstrAddStationMsg->u8NumRates > 0) {
4540 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
4545 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
4546 pstrAddStationMsg->pu8Rates = rates;
4549 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4551 PRINT_ER("wilc_mq_send fail\n");
4555 s32 host_int_del_station(struct host_if_drv *hif_drv, const u8 *pu8MacAddr)
4558 struct host_if_msg msg;
4559 struct del_sta *pstrDelStationMsg = &msg.body.del_sta_info;
4562 PRINT_ER("driver is null\n");
4566 memset(&msg, 0, sizeof(struct host_if_msg));
4568 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
4570 msg.id = HOST_IF_MSG_DEL_STATION;
4574 eth_broadcast_addr(pstrDelStationMsg->mac_addr);
4576 memcpy(pstrDelStationMsg->mac_addr, pu8MacAddr, ETH_ALEN);
4578 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4580 PRINT_ER("wilc_mq_send fail\n");
4584 s32 host_int_del_allstation(struct host_if_drv *hif_drv,
4585 u8 pu8MacAddr[][ETH_ALEN])
4588 struct host_if_msg msg;
4589 struct del_all_sta *pstrDelAllStationMsg = &msg.body.del_all_sta_info;
4590 u8 au8Zero_Buff[ETH_ALEN] = {0};
4595 PRINT_ER("driver is null\n");
4599 memset(&msg, 0, sizeof(struct host_if_msg));
4601 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
4603 msg.id = HOST_IF_MSG_DEL_ALL_STA;
4606 for (i = 0; i < MAX_NUM_STA; i++) {
4607 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
4608 memcpy(pstrDelAllStationMsg->del_all_sta[i], pu8MacAddr[i], ETH_ALEN);
4609 PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n",
4610 pstrDelAllStationMsg->del_all_sta[i][0],
4611 pstrDelAllStationMsg->del_all_sta[i][1],
4612 pstrDelAllStationMsg->del_all_sta[i][2],
4613 pstrDelAllStationMsg->del_all_sta[i][3],
4614 pstrDelAllStationMsg->del_all_sta[i][4],
4615 pstrDelAllStationMsg->del_all_sta[i][5]);
4620 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
4624 pstrDelAllStationMsg->assoc_sta = u8AssocNumb;
4625 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4628 PRINT_ER("wilc_mq_send fail\n");
4630 down(&hif_sema_wait_response);
4635 s32 host_int_edit_station(struct host_if_drv *hif_drv,
4636 struct add_sta_param *pstrStaParams)
4639 struct host_if_msg msg;
4640 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
4643 PRINT_ER("driver is null\n");
4647 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
4649 memset(&msg, 0, sizeof(struct host_if_msg));
4651 msg.id = HOST_IF_MSG_EDIT_STATION;
4654 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
4655 if (pstrAddStationMsg->u8NumRates > 0) {
4656 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
4661 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
4662 pstrAddStationMsg->pu8Rates = rates;
4665 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4667 PRINT_ER("wilc_mq_send fail\n");
4672 s32 host_int_set_power_mgmt(struct host_if_drv *hif_drv,
4677 struct host_if_msg msg;
4678 struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.pwr_mgmt_info;
4680 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
4683 PRINT_ER("driver is null\n");
4687 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
4689 memset(&msg, 0, sizeof(struct host_if_msg));
4691 msg.id = HOST_IF_MSG_POWER_MGMT;
4694 pstrPowerMgmtParam->enabled = bIsEnabled;
4695 pstrPowerMgmtParam->timeout = u32Timeout;
4697 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4699 PRINT_ER("wilc_mq_send fail\n");
4703 s32 host_int_setup_multicast_filter(struct host_if_drv *hif_drv,
4708 struct host_if_msg msg;
4709 struct set_multicast *pstrMulticastFilterParam = &msg.body.multicast_info;
4712 PRINT_ER("driver is null\n");
4716 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
4718 memset(&msg, 0, sizeof(struct host_if_msg));
4720 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
4723 pstrMulticastFilterParam->enabled = bIsEnabled;
4724 pstrMulticastFilterParam->cnt = u32count;
4726 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4728 PRINT_ER("wilc_mq_send fail\n");
4732 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
4734 struct join_bss_param *pNewJoinBssParam = NULL;
4743 u8 pcipherTotalCount = 0;
4744 u8 authTotalCount = 0;
4747 pu8IEs = ptstrNetworkInfo->pu8IEs;
4748 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
4750 pNewJoinBssParam = kzalloc(sizeof(struct join_bss_param), GFP_KERNEL);
4751 if (pNewJoinBssParam) {
4752 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
4753 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
4754 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
4755 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
4756 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
4757 pNewJoinBssParam->ssid_len = ptstrNetworkInfo->u8SsidLen;
4758 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
4759 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
4761 while (index < u16IEsLen) {
4762 if (pu8IEs[index] == SUPP_RATES_IE) {
4763 suppRatesNo = pu8IEs[index + 1];
4764 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
4767 for (i = 0; i < suppRatesNo; i++)
4768 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
4770 index += suppRatesNo;
4772 } else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
4773 extSuppRatesNo = pu8IEs[index + 1];
4774 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
4775 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
4777 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
4779 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++)
4780 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
4782 index += extSuppRatesNo;
4784 } else if (pu8IEs[index] == HT_CAPABILITY_IE) {
4785 pNewJoinBssParam->ht_capable = true;
4786 index += pu8IEs[index + 1] + 2;
4788 } else if ((pu8IEs[index] == WMM_IE) &&
4789 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
4790 (pu8IEs[index + 4] == 0xF2) &&
4791 (pu8IEs[index + 5] == 0x02) &&
4792 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) &&
4793 (pu8IEs[index + 7] == 0x01)) {
4794 pNewJoinBssParam->wmm_cap = true;
4796 if (pu8IEs[index + 8] & BIT(7))
4797 pNewJoinBssParam->uapsd_cap = true;
4798 index += pu8IEs[index + 1] + 2;
4800 } else if ((pu8IEs[index] == P2P_IE) &&
4801 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
4802 (pu8IEs[index + 4] == 0x9a) &&
4803 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) {
4806 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
4807 pNewJoinBssParam->noa_enabled = 1;
4808 pNewJoinBssParam->idx = pu8IEs[index + 9];
4810 if (pu8IEs[index + 10] & BIT(7)) {
4811 pNewJoinBssParam->opp_enabled = 1;
4812 pNewJoinBssParam->ct_window = pu8IEs[index + 10];
4814 pNewJoinBssParam->opp_enabled = 0;
4817 PRINT_D(GENERIC_DBG, "P2P Dump\n");
4818 for (i = 0; i < pu8IEs[index + 7]; i++)
4819 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
4821 pNewJoinBssParam->cnt = pu8IEs[index + 11];
4822 u16P2P_count = index + 12;
4824 memcpy(pNewJoinBssParam->duration, pu8IEs + u16P2P_count, 4);
4827 memcpy(pNewJoinBssParam->interval, pu8IEs + u16P2P_count, 4);
4830 memcpy(pNewJoinBssParam->start_time, pu8IEs + u16P2P_count, 4);
4832 index += pu8IEs[index + 1] + 2;
4835 } else if ((pu8IEs[index] == RSN_IE) ||
4836 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
4837 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
4838 (pu8IEs[index + 5] == 0x01))) {
4839 u16 rsnIndex = index;
4841 if (pu8IEs[rsnIndex] == RSN_IE) {
4842 pNewJoinBssParam->mode_802_11i = 2;
4844 if (pNewJoinBssParam->mode_802_11i == 0)
4845 pNewJoinBssParam->mode_802_11i = 1;
4850 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
4852 jumpOffset = pu8IEs[rsnIndex] * 4;
4853 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
4856 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++)
4857 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
4859 pcipherTotalCount += pcipherCount;
4860 rsnIndex += jumpOffset;
4862 jumpOffset = pu8IEs[rsnIndex] * 4;
4864 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
4867 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++)
4868 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
4870 authTotalCount += authCount;
4871 rsnIndex += jumpOffset;
4873 if (pu8IEs[index] == RSN_IE) {
4874 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
4875 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
4878 pNewJoinBssParam->rsn_found = true;
4879 index += pu8IEs[index + 1] + 2;
4882 index += pu8IEs[index + 1] + 2;
4886 return (void *)pNewJoinBssParam;
4889 void host_int_freeJoinParams(void *pJoinParams)
4891 if ((struct bss_param *)pJoinParams)
4892 kfree((struct bss_param *)pJoinParams);
4894 PRINT_ER("Unable to FREE null pointer\n");
4897 s32 host_int_delBASession(struct host_if_drv *hif_drv, char *pBSSID, char TID)
4900 struct host_if_msg msg;
4901 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
4904 PRINT_ER("driver is null\n");
4908 memset(&msg, 0, sizeof(struct host_if_msg));
4910 msg.id = HOST_IF_MSG_DEL_BA_SESSION;
4912 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
4913 pBASessionInfo->u8Ted = TID;
4916 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4918 PRINT_ER("wilc_mq_send fail\n");
4920 down(&hif_sema_wait_response);
4925 s32 host_int_del_All_Rx_BASession(struct host_if_drv *hif_drv,
4930 struct host_if_msg msg;
4931 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
4934 PRINT_ER("driver is null\n");
4938 memset(&msg, 0, sizeof(struct host_if_msg));
4940 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
4942 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
4943 pBASessionInfo->u8Ted = TID;
4946 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4948 PRINT_ER("wilc_mq_send fail\n");
4950 down(&hif_sema_wait_response);
4955 s32 host_int_setup_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
4958 struct host_if_msg msg;
4963 PRINT_ER("driver is null\n");
4967 memset(&msg, 0, sizeof(struct host_if_msg));
4969 msg.id = HOST_IF_MSG_SET_IPADDRESS;
4971 msg.body.ip_info.ip_addr = u16ipadd;
4973 msg.body.ip_info.idx = idx;
4975 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4977 PRINT_ER("wilc_mq_send fail\n");
4982 s32 host_int_get_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
4985 struct host_if_msg msg;
4988 PRINT_ER("driver is null\n");
4992 memset(&msg, 0, sizeof(struct host_if_msg));
4994 msg.id = HOST_IF_MSG_GET_IPADDRESS;
4996 msg.body.ip_info.ip_addr = u16ipadd;
4998 msg.body.ip_info.idx = idx;
5000 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
5002 PRINT_ER("wilc_mq_send fail\n");