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>
13 extern struct timer_list hDuringIpTimer;
15 extern u8 g_wilc_initialized;
17 #define HOST_IF_MSG_SCAN 0
18 #define HOST_IF_MSG_CONNECT 1
19 #define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
20 #define HOST_IF_MSG_KEY 3
21 #define HOST_IF_MSG_RCVD_NTWRK_INFO 4
22 #define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
23 #define HOST_IF_MSG_CFG_PARAMS 6
24 #define HOST_IF_MSG_SET_CHANNEL 7
25 #define HOST_IF_MSG_DISCONNECT 8
26 #define HOST_IF_MSG_GET_RSSI 9
27 #define HOST_IF_MSG_GET_CHNL 10
28 #define HOST_IF_MSG_ADD_BEACON 11
29 #define HOST_IF_MSG_DEL_BEACON 12
30 #define HOST_IF_MSG_ADD_STATION 13
31 #define HOST_IF_MSG_DEL_STATION 14
32 #define HOST_IF_MSG_EDIT_STATION 15
33 #define HOST_IF_MSG_SCAN_TIMER_FIRED 16
34 #define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
35 #define HOST_IF_MSG_POWER_MGMT 18
36 #define HOST_IF_MSG_GET_INACTIVETIME 19
37 #define HOST_IF_MSG_REMAIN_ON_CHAN 20
38 #define HOST_IF_MSG_REGISTER_FRAME 21
39 #define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
40 #define HOST_IF_MSG_GET_LINKSPEED 23
41 #define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
42 #define HOST_IF_MSG_SET_MAC_ADDRESS 25
43 #define HOST_IF_MSG_GET_MAC_ADDRESS 26
44 #define HOST_IF_MSG_SET_OPERATION_MODE 27
45 #define HOST_IF_MSG_SET_IPADDRESS 28
46 #define HOST_IF_MSG_GET_IPADDRESS 29
47 #define HOST_IF_MSG_FLUSH_CONNECT 30
48 #define HOST_IF_MSG_GET_STATISTICS 31
49 #define HOST_IF_MSG_SET_MULTICAST_FILTER 32
50 #define HOST_IF_MSG_ADD_BA_SESSION 33
51 #define HOST_IF_MSG_DEL_BA_SESSION 34
52 #define HOST_IF_MSG_Q_IDLE 35
53 #define HOST_IF_MSG_DEL_ALL_STA 36
54 #define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
55 #define HOST_IF_MSG_EXIT 100
57 #define HOST_IF_SCAN_TIMEOUT 4000
58 #define HOST_IF_CONNECT_TIMEOUT 9500
60 #define BA_SESSION_DEFAULT_BUFFER_SIZE 16
61 #define BA_SESSION_DEFAULT_TIMEOUT 1000
62 #define BLOCK_ACK_REQ_SIZE 0x14
64 struct cfg_param_attr {
65 struct cfg_param_val cfg_attr_info;
68 struct host_if_wpa_attr {
78 struct host_if_wep_attr {
83 enum AUTHTYPE auth_type;
86 union host_if_key_attr {
87 struct host_if_wep_attr wep;
88 struct host_if_wpa_attr wpa;
89 struct host_if_pmkid_attr pmkid;
95 union host_if_key_attr attr;
105 wilc_scan_result result;
107 struct hidden_network hidden_network;
110 struct connect_attr {
117 wilc_connect_result pfConnectResult;
119 enum AUTHTYPE tenuAuth_type;
124 struct rcvd_async_info {
129 struct channel_attr {
142 struct set_multicast {
148 u8 au8Sta_DelAllSta[MAX_NUM_STA][ETH_ALEN];
153 u8 au8MacAddr[ETH_ALEN];
156 struct power_mgmt_param {
167 struct sta_inactive_t {
172 struct scan_attr scan_info;
173 struct connect_attr con_info;
174 struct rcvd_net_info net_info;
175 struct rcvd_async_info async_info;
176 struct key_attr key_info;
177 struct cfg_param_attr cfg_info;
178 struct channel_attr channel_info;
179 struct beacon_attr beacon_info;
180 struct add_sta_param add_sta_info;
181 struct del_sta del_sta_info;
182 struct add_sta_param edit_sta_info;
183 struct power_mgmt_param pwr_mgmt_info;
184 struct sta_inactive_t mac_info;
185 struct set_ip_addr ip_info;
186 struct drv_handler drv;
187 struct set_multicast multicast_info;
189 struct set_mac_addr set_mac_info;
190 struct get_mac_addr get_mac_info;
191 struct ba_session_info session_info;
192 struct remain_ch remain_on_ch;
193 struct reg_frame reg_frame;
195 struct del_all_sta del_all_sta_info;
200 union message_body body;
201 struct host_if_drv *drv;
204 struct join_bss_param {
210 char ssid[MAX_SSID_LEN];
212 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
219 u8 rsn_pcip_policy[3];
220 u8 rsn_auth_policy[3];
233 enum scan_conn_timer {
236 SCAN_CONNECT_TIMER_FORCE_32BIT = 0xFFFFFFFF
239 static struct host_if_drv *wfidrv_list[NUM_CONCURRENT_IFC + 1];
240 struct host_if_drv *terminated_handle;
241 struct host_if_drv *gWFiDrvHandle;
244 static struct task_struct *HostIFthreadHandler;
245 static WILC_MsgQueueHandle gMsgQHostIF;
246 static struct semaphore hSemHostIFthrdEnd;
248 struct semaphore hSemDeinitDrvHandle;
249 static struct semaphore hWaitResponse;
250 struct semaphore hSemHostIntDeinit;
251 struct timer_list g_hPeriodicRSSI;
255 u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
257 static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE];
259 bool gbScanWhileConnected;
264 static u8 gs8SetIP[2][4];
265 static u8 gs8GetIP[2][4];
266 static u32 gu32InactiveTime;
268 static u32 gu32WidConnRstHack;
270 u8 *gu8FlushedJoinReq;
271 u8 *gu8FlushedInfoElemAsoc;
272 u8 gu8Flushed11iMode;
273 u8 gu8FlushedAuthType;
274 u32 gu32FlushedJoinReqSize;
275 u32 gu32FlushedInfoElemAsocSize;
276 struct host_if_drv *gu8FlushedJoinReqDrvHandler;
277 #define REAL_JOIN_REQ 0
278 #define FLUSHED_JOIN_REQ 1
279 #define FLUSHED_BYTE_POS 79
281 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
283 extern void chip_sleep_manually(u32 u32SleepTime);
284 extern int linux_wlan_get_num_conn_ifcs(void);
286 static int add_handler_in_list(struct host_if_drv *handler)
290 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
291 if (!wfidrv_list[i]) {
292 wfidrv_list[i] = handler;
300 static int remove_handler_in_list(struct host_if_drv *handler)
304 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
305 if (wfidrv_list[i] == handler) {
306 wfidrv_list[i] = NULL;
314 static int get_id_from_handler(struct host_if_drv *handler)
321 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
322 if (wfidrv_list[i] == handler)
329 static struct host_if_drv *get_handler_from_id(int id)
331 if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list))
333 return wfidrv_list[id];
336 static s32 Handle_SetChannel(struct host_if_drv *hif_drv,
337 struct channel_attr *pstrHostIFSetChan)
343 strWID.id = (u16)WID_CURRENT_CHANNEL;
344 strWID.type = WID_CHAR;
345 strWID.val = (char *)&(pstrHostIFSetChan->u8SetChan);
346 strWID.size = sizeof(char);
348 PRINT_D(HOSTINF_DBG, "Setting channel\n");
350 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
351 get_id_from_handler(hif_drv));
353 PRINT_ER("Failed to set channel\n");
360 static s32 Handle_SetWfiDrvHandler(struct host_if_drv *hif_drv,
361 struct drv_handler *pstrHostIfSetDrvHandler)
367 strWID.id = (u16)WID_SET_DRV_HANDLER;
368 strWID.type = WID_INT;
369 strWID.val = (s8 *)&(pstrHostIfSetDrvHandler->u32Address);
370 strWID.size = sizeof(u32);
372 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
373 pstrHostIfSetDrvHandler->u32Address);
376 up(&hSemDeinitDrvHandle);
380 PRINT_ER("Failed to set driver handler\n");
387 static s32 Handle_SetOperationMode(struct host_if_drv *hif_drv,
388 struct op_mode *pstrHostIfSetOperationMode)
394 strWID.id = (u16)WID_SET_OPERATION_MODE;
395 strWID.type = WID_INT;
396 strWID.val = (s8 *)&(pstrHostIfSetOperationMode->u32Mode);
397 strWID.size = sizeof(u32);
399 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
400 get_id_from_handler(hif_drv));
403 if ((pstrHostIfSetOperationMode->u32Mode) == IDLE_MODE)
404 up(&hSemDeinitDrvHandle);
408 PRINT_ER("Failed to set driver handler\n");
415 s32 Handle_set_IPAddress(struct host_if_drv *hif_drv, u8 *pu8IPAddr, u8 idx)
420 char firmwareIPAddress[4] = {0};
422 if (pu8IPAddr[0] < 192)
425 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n", idx, pu8IPAddr);
427 memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN);
429 strWID.id = (u16)WID_IP_ADDRESS;
430 strWID.type = WID_STR;
431 strWID.val = (u8 *)pu8IPAddr;
432 strWID.size = IP_ALEN;
434 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
435 get_id_from_handler(hif_drv));
438 host_int_get_ipaddress(hif_drv, firmwareIPAddress, idx);
441 PRINT_ER("Failed to set IP address\n");
445 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
450 s32 Handle_get_IPAddress(struct host_if_drv *hif_drv, u8 *pu8IPAddr, u8 idx)
456 strWID.id = (u16)WID_IP_ADDRESS;
457 strWID.type = WID_STR;
458 strWID.val = kmalloc(IP_ALEN, GFP_KERNEL);
459 strWID.size = IP_ALEN;
461 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
462 get_id_from_handler(hif_drv));
464 PRINT_INFO(HOSTINF_DBG, "%pI4\n", strWID.val);
466 memcpy(gs8GetIP[idx], strWID.val, IP_ALEN);
470 if (memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0)
471 host_int_setup_ipaddress(hif_drv, gs8SetIP[idx], idx);
474 PRINT_ER("Failed to get IP address\n");
478 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
479 PRINT_INFO(HOSTINF_DBG, "%pI4\n", gs8GetIP[idx]);
480 PRINT_INFO(HOSTINF_DBG, "\n");
485 static s32 Handle_SetMacAddress(struct host_if_drv *hif_drv,
486 struct set_mac_addr *pstrHostIfSetMacAddress)
491 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
493 if (mac_buf == NULL) {
494 PRINT_ER("No buffer to send mac address\n");
497 memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
499 strWID.id = (u16)WID_MAC_ADDR;
500 strWID.type = WID_STR;
501 strWID.val = mac_buf;
502 strWID.size = ETH_ALEN;
503 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", strWID.val);
505 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
506 get_id_from_handler(hif_drv));
508 PRINT_ER("Failed to set mac address\n");
516 static s32 Handle_GetMacAddress(struct host_if_drv *hif_drv,
517 struct get_mac_addr *pstrHostIfGetMacAddress)
523 strWID.id = (u16)WID_MAC_ADDR;
524 strWID.type = WID_STR;
525 strWID.val = pstrHostIfGetMacAddress->u8MacAddress;
526 strWID.size = ETH_ALEN;
528 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
529 get_id_from_handler(hif_drv));
531 PRINT_ER("Failed to get mac address\n");
539 static s32 Handle_CfgParam(struct host_if_drv *hif_drv,
540 struct cfg_param_attr *strHostIFCfgParamAttr)
543 struct wid strWIDList[32];
546 down(&hif_drv->gtOsCfgValuesSem);
549 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
551 if (strHostIFCfgParamAttr->cfg_attr_info.flag & BSS_TYPE) {
552 if (strHostIFCfgParamAttr->cfg_attr_info.bss_type < 6) {
553 strWIDList[u8WidCnt].id = WID_BSS_TYPE;
554 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.bss_type;
555 strWIDList[u8WidCnt].type = WID_CHAR;
556 strWIDList[u8WidCnt].size = sizeof(char);
557 hif_drv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->cfg_attr_info.bss_type;
559 PRINT_ER("check value 6 over\n");
565 if (strHostIFCfgParamAttr->cfg_attr_info.flag & AUTH_TYPE) {
566 if ((strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 1 || (strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 2 || (strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 5) {
567 strWIDList[u8WidCnt].id = WID_AUTH_TYPE;
568 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.auth_type;
569 strWIDList[u8WidCnt].type = WID_CHAR;
570 strWIDList[u8WidCnt].size = sizeof(char);
571 hif_drv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->cfg_attr_info.auth_type;
573 PRINT_ER("Impossible value \n");
579 if (strHostIFCfgParamAttr->cfg_attr_info.flag & AUTHEN_TIMEOUT) {
580 if (strHostIFCfgParamAttr->cfg_attr_info.auth_timeout > 0 && strHostIFCfgParamAttr->cfg_attr_info.auth_timeout < 65536) {
581 strWIDList[u8WidCnt].id = WID_AUTH_TIMEOUT;
582 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.auth_timeout;
583 strWIDList[u8WidCnt].type = WID_SHORT;
584 strWIDList[u8WidCnt].size = sizeof(u16);
585 hif_drv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->cfg_attr_info.auth_timeout;
587 PRINT_ER("Range(1 ~ 65535) over\n");
593 if (strHostIFCfgParamAttr->cfg_attr_info.flag & POWER_MANAGEMENT) {
594 if (strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode < 5) {
595 strWIDList[u8WidCnt].id = WID_POWER_MANAGEMENT;
596 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode;
597 strWIDList[u8WidCnt].type = WID_CHAR;
598 strWIDList[u8WidCnt].size = sizeof(char);
599 hif_drv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode;
601 PRINT_ER("Invalide power mode\n");
607 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RETRY_SHORT) {
608 if ((strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit > 0) && (strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit < 256)) {
609 strWIDList[u8WidCnt].id = WID_SHORT_RETRY_LIMIT;
610 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit;
611 strWIDList[u8WidCnt].type = WID_SHORT;
612 strWIDList[u8WidCnt].size = sizeof(u16);
613 hif_drv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit;
615 PRINT_ER("Range(1~256) over\n");
621 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RETRY_LONG) {
622 if ((strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit > 0) && (strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit < 256)) {
623 strWIDList[u8WidCnt].id = WID_LONG_RETRY_LIMIT;
624 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit;
626 strWIDList[u8WidCnt].type = WID_SHORT;
627 strWIDList[u8WidCnt].size = sizeof(u16);
628 hif_drv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit;
630 PRINT_ER("Range(1~256) over\n");
636 if (strHostIFCfgParamAttr->cfg_attr_info.flag & FRAG_THRESHOLD) {
638 if (strHostIFCfgParamAttr->cfg_attr_info.frag_threshold > 255 && strHostIFCfgParamAttr->cfg_attr_info.frag_threshold < 7937) {
639 strWIDList[u8WidCnt].id = WID_FRAG_THRESHOLD;
640 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.frag_threshold;
641 strWIDList[u8WidCnt].type = WID_SHORT;
642 strWIDList[u8WidCnt].size = sizeof(u16);
643 hif_drv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->cfg_attr_info.frag_threshold;
645 PRINT_ER("Threshold Range fail\n");
651 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RTS_THRESHOLD) {
652 if (strHostIFCfgParamAttr->cfg_attr_info.rts_threshold > 255 && strHostIFCfgParamAttr->cfg_attr_info.rts_threshold < 65536) {
653 strWIDList[u8WidCnt].id = WID_RTS_THRESHOLD;
654 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.rts_threshold;
655 strWIDList[u8WidCnt].type = WID_SHORT;
656 strWIDList[u8WidCnt].size = sizeof(u16);
657 hif_drv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->cfg_attr_info.rts_threshold;
659 PRINT_ER("Threshold Range fail\n");
665 if (strHostIFCfgParamAttr->cfg_attr_info.flag & PREAMBLE) {
666 if (strHostIFCfgParamAttr->cfg_attr_info.preamble_type < 3) {
667 strWIDList[u8WidCnt].id = WID_PREAMBLE;
668 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.preamble_type;
669 strWIDList[u8WidCnt].type = WID_CHAR;
670 strWIDList[u8WidCnt].size = sizeof(char);
671 hif_drv->strCfgValues.preamble_type = strHostIFCfgParamAttr->cfg_attr_info.preamble_type;
673 PRINT_ER("Preamle Range(0~2) over\n");
679 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SHORT_SLOT_ALLOWED) {
680 if (strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed < 2) {
681 strWIDList[u8WidCnt].id = WID_SHORT_SLOT_ALLOWED;
682 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed;
683 strWIDList[u8WidCnt].type = WID_CHAR;
684 strWIDList[u8WidCnt].size = sizeof(char);
685 hif_drv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed;
687 PRINT_ER("Short slot(2) over\n");
693 if (strHostIFCfgParamAttr->cfg_attr_info.flag & TXOP_PROT_DISABLE) {
694 if (strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled < 2) {
695 strWIDList[u8WidCnt].id = WID_11N_TXOP_PROT_DISABLE;
696 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled;
697 strWIDList[u8WidCnt].type = WID_CHAR;
698 strWIDList[u8WidCnt].size = sizeof(char);
699 hif_drv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled;
701 PRINT_ER("TXOP prot disable\n");
707 if (strHostIFCfgParamAttr->cfg_attr_info.flag & BEACON_INTERVAL) {
708 if (strHostIFCfgParamAttr->cfg_attr_info.beacon_interval > 0 && strHostIFCfgParamAttr->cfg_attr_info.beacon_interval < 65536) {
709 strWIDList[u8WidCnt].id = WID_BEACON_INTERVAL;
710 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.beacon_interval;
711 strWIDList[u8WidCnt].type = WID_SHORT;
712 strWIDList[u8WidCnt].size = sizeof(u16);
713 hif_drv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->cfg_attr_info.beacon_interval;
715 PRINT_ER("Beacon interval(1~65535) fail\n");
721 if (strHostIFCfgParamAttr->cfg_attr_info.flag & DTIM_PERIOD) {
722 if (strHostIFCfgParamAttr->cfg_attr_info.dtim_period > 0 && strHostIFCfgParamAttr->cfg_attr_info.dtim_period < 256) {
723 strWIDList[u8WidCnt].id = WID_DTIM_PERIOD;
724 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.dtim_period;
725 strWIDList[u8WidCnt].type = WID_CHAR;
726 strWIDList[u8WidCnt].size = sizeof(char);
727 hif_drv->strCfgValues.dtim_period = strHostIFCfgParamAttr->cfg_attr_info.dtim_period;
729 PRINT_ER("DTIM range(1~255) fail\n");
735 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SITE_SURVEY) {
736 if (strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled < 3) {
737 strWIDList[u8WidCnt].id = WID_SITE_SURVEY;
738 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled;
739 strWIDList[u8WidCnt].type = WID_CHAR;
740 strWIDList[u8WidCnt].size = sizeof(char);
741 hif_drv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled;
743 PRINT_ER("Site survey disable\n");
749 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SITE_SURVEY_SCAN_TIME) {
750 if (strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time < 65536) {
751 strWIDList[u8WidCnt].id = WID_SITE_SURVEY_SCAN_TIME;
752 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time;
753 strWIDList[u8WidCnt].type = WID_SHORT;
754 strWIDList[u8WidCnt].size = sizeof(u16);
755 hif_drv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time;
757 PRINT_ER("Site survey scan time(1~65535) over\n");
763 if (strHostIFCfgParamAttr->cfg_attr_info.flag & ACTIVE_SCANTIME) {
764 if (strHostIFCfgParamAttr->cfg_attr_info.active_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.active_scan_time < 65536) {
765 strWIDList[u8WidCnt].id = WID_ACTIVE_SCAN_TIME;
766 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.active_scan_time;
767 strWIDList[u8WidCnt].type = WID_SHORT;
768 strWIDList[u8WidCnt].size = sizeof(u16);
769 hif_drv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->cfg_attr_info.active_scan_time;
771 PRINT_ER("Active scan time(1~65535) over\n");
777 if (strHostIFCfgParamAttr->cfg_attr_info.flag & PASSIVE_SCANTIME) {
778 if (strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time < 65536) {
779 strWIDList[u8WidCnt].id = WID_PASSIVE_SCAN_TIME;
780 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time;
781 strWIDList[u8WidCnt].type = WID_SHORT;
782 strWIDList[u8WidCnt].size = sizeof(u16);
783 hif_drv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time;
785 PRINT_ER("Passive scan time(1~65535) over\n");
791 if (strHostIFCfgParamAttr->cfg_attr_info.flag & CURRENT_TX_RATE) {
792 enum CURRENT_TXRATE curr_tx_rate = strHostIFCfgParamAttr->cfg_attr_info.curr_tx_rate;
793 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
794 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
795 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
796 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
797 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
798 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
799 strWIDList[u8WidCnt].id = WID_CURRENT_TX_RATE;
800 strWIDList[u8WidCnt].val = (s8 *)&curr_tx_rate;
801 strWIDList[u8WidCnt].type = WID_SHORT;
802 strWIDList[u8WidCnt].size = sizeof(u16);
803 hif_drv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
805 PRINT_ER("out of TX rate\n");
811 s32Error = send_config_pkt(SET_CFG, strWIDList, u8WidCnt,
812 get_id_from_handler(hif_drv));
815 PRINT_ER("Error in setting CFG params\n");
818 up(&hif_drv->gtOsCfgValuesSem);
822 static s32 Handle_wait_msg_q_empty(void)
824 g_wilc_initialized = 0;
829 static s32 Handle_Scan(struct host_if_drv *hif_drv,
830 struct scan_attr *pstrHostIFscanAttr)
833 struct wid strWIDList[5];
834 u32 u32WidsCount = 0;
838 u8 *pu8HdnNtwrksWidVal = NULL;
840 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
841 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", hif_drv->enuHostIFstate);
843 hif_drv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->result;
844 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->arg;
846 if ((hif_drv->enuHostIFstate >= HOST_IF_SCANNING) && (hif_drv->enuHostIFstate < HOST_IF_CONNECTED)) {
847 PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", hif_drv->enuHostIFstate);
848 PRINT_ER("Already scan\n");
853 if (g_obtainingIP || connecting) {
854 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
855 PRINT_ER("Don't do obss scan\n");
860 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
863 hif_drv->strWILC_UsrScanReq.u32RcvdChCount = 0;
865 strWIDList[u32WidsCount].id = (u16)WID_SSID_PROBE_REQ;
866 strWIDList[u32WidsCount].type = WID_STR;
868 for (i = 0; i < pstrHostIFscanAttr->hidden_network.u8ssidnum; i++)
869 valuesize += ((pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
870 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
871 strWIDList[u32WidsCount].val = pu8HdnNtwrksWidVal;
872 if (strWIDList[u32WidsCount].val != NULL) {
873 pu8Buffer = strWIDList[u32WidsCount].val;
875 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.u8ssidnum;
877 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->hidden_network.u8ssidnum);
879 for (i = 0; i < pstrHostIFscanAttr->hidden_network.u8ssidnum; i++) {
880 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen;
881 memcpy(pu8Buffer, pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen);
882 pu8Buffer += pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen;
887 strWIDList[u32WidsCount].size = (s32)(valuesize + 1);
892 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_PROBE;
893 strWIDList[u32WidsCount].type = WID_BIN_DATA;
894 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ies;
895 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ies_len;
899 strWIDList[u32WidsCount].id = WID_SCAN_TYPE;
900 strWIDList[u32WidsCount].type = WID_CHAR;
901 strWIDList[u32WidsCount].size = sizeof(char);
902 strWIDList[u32WidsCount].val = (s8 *)(&(pstrHostIFscanAttr->type));
905 strWIDList[u32WidsCount].id = WID_SCAN_CHANNEL_LIST;
906 strWIDList[u32WidsCount].type = WID_BIN_DATA;
908 if (pstrHostIFscanAttr->ch_freq_list != NULL && pstrHostIFscanAttr->ch_list_len > 0) {
911 for (i = 0; i < pstrHostIFscanAttr->ch_list_len; i++) {
912 if (pstrHostIFscanAttr->ch_freq_list[i] > 0)
913 pstrHostIFscanAttr->ch_freq_list[i] = pstrHostIFscanAttr->ch_freq_list[i] - 1;
917 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ch_freq_list;
918 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ch_list_len;
921 strWIDList[u32WidsCount].id = WID_START_SCAN_REQ;
922 strWIDList[u32WidsCount].type = WID_CHAR;
923 strWIDList[u32WidsCount].size = sizeof(char);
924 strWIDList[u32WidsCount].val = (s8 *)(&(pstrHostIFscanAttr->src));
927 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)
928 gbScanWhileConnected = true;
929 else if (hif_drv->enuHostIFstate == HOST_IF_IDLE)
930 gbScanWhileConnected = false;
932 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
933 get_id_from_handler(hif_drv));
936 PRINT_ER("Failed to send scan paramters config packet\n");
938 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
942 del_timer(&hif_drv->hScanTimer);
943 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
946 if (pstrHostIFscanAttr->ch_freq_list != NULL) {
947 kfree(pstrHostIFscanAttr->ch_freq_list);
948 pstrHostIFscanAttr->ch_freq_list = NULL;
951 if (pstrHostIFscanAttr->ies != NULL) {
952 kfree(pstrHostIFscanAttr->ies);
953 pstrHostIFscanAttr->ies = NULL;
955 if (pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo != NULL) {
956 kfree(pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo);
957 pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo = NULL;
960 if (pu8HdnNtwrksWidVal != NULL)
961 kfree(pu8HdnNtwrksWidVal);
966 static s32 Handle_ScanDone(struct host_if_drv *hif_drv,
967 enum scan_event enuEvent)
970 u8 u8abort_running_scan;
974 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
976 if (enuEvent == SCAN_EVENT_ABORTED) {
977 PRINT_D(GENERIC_DBG, "Abort running scan\n");
978 u8abort_running_scan = 1;
979 strWID.id = (u16)WID_ABORT_RUNNING_SCAN;
980 strWID.type = WID_CHAR;
981 strWID.val = (s8 *)&u8abort_running_scan;
982 strWID.size = sizeof(char);
984 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
985 get_id_from_handler(hif_drv));
987 PRINT_ER("Failed to set abort running scan\n");
993 PRINT_ER("Driver handler is NULL\n");
997 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
998 hif_drv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
999 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
1000 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
1006 u8 u8ConnectedSSID[6] = {0};
1007 static s32 Handle_Connect(struct host_if_drv *hif_drv,
1008 struct connect_attr *pstrHostIFconnectAttr)
1011 struct wid strWIDList[8];
1012 u32 u32WidsCount = 0, dummyval = 0;
1013 u8 *pu8CurrByte = NULL;
1014 struct join_bss_param *ptstrJoinBssParam;
1016 PRINT_D(GENERIC_DBG, "Handling connect request\n");
1018 if (memcmp(pstrHostIFconnectAttr->bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
1021 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1025 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1027 ptstrJoinBssParam = (struct join_bss_param *)pstrHostIFconnectAttr->pJoinParams;
1028 if (ptstrJoinBssParam == NULL) {
1029 PRINT_ER("Required BSSID not found\n");
1034 if (pstrHostIFconnectAttr->bssid != NULL) {
1035 hif_drv->strWILC_UsrConnReq.pu8bssid = kmalloc(6, GFP_KERNEL);
1036 memcpy(hif_drv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->bssid, 6);
1039 hif_drv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssid_len;
1040 if (pstrHostIFconnectAttr->ssid != NULL) {
1041 hif_drv->strWILC_UsrConnReq.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssid_len + 1, GFP_KERNEL);
1042 memcpy(hif_drv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->ssid,
1043 pstrHostIFconnectAttr->ssid_len);
1044 hif_drv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssid_len] = '\0';
1047 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1048 if (pstrHostIFconnectAttr->ies != NULL) {
1049 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
1050 memcpy(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->ies,
1051 pstrHostIFconnectAttr->IEsLen);
1054 hif_drv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1055 hif_drv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1056 hif_drv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1057 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1059 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
1060 strWIDList[u32WidsCount].type = WID_INT;
1061 strWIDList[u32WidsCount].size = sizeof(u32);
1062 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1065 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
1066 strWIDList[u32WidsCount].type = WID_INT;
1067 strWIDList[u32WidsCount].size = sizeof(u32);
1068 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1071 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
1072 strWIDList[u32WidsCount].type = WID_INT;
1073 strWIDList[u32WidsCount].size = sizeof(u32);
1074 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1078 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
1079 strWIDList[u32WidsCount].type = WID_BIN_DATA;
1080 strWIDList[u32WidsCount].val = hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs;
1081 strWIDList[u32WidsCount].size = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1084 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1086 gu32FlushedInfoElemAsocSize = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1087 gu8FlushedInfoElemAsoc = kmalloc(gu32FlushedInfoElemAsocSize, GFP_KERNEL);
1088 memcpy(gu8FlushedInfoElemAsoc, hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
1089 gu32FlushedInfoElemAsocSize);
1092 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
1093 strWIDList[u32WidsCount].type = WID_CHAR;
1094 strWIDList[u32WidsCount].size = sizeof(char);
1095 strWIDList[u32WidsCount].val = (s8 *)(&(hif_drv->strWILC_UsrConnReq.u8security));
1098 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
1099 gu8Flushed11iMode = hif_drv->strWILC_UsrConnReq.u8security;
1101 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", hif_drv->strWILC_UsrConnReq.u8security);
1104 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
1105 strWIDList[u32WidsCount].type = WID_CHAR;
1106 strWIDList[u32WidsCount].size = sizeof(char);
1107 strWIDList[u32WidsCount].val = (s8 *)(&hif_drv->strWILC_UsrConnReq.tenuAuth_type);
1110 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
1111 gu8FlushedAuthType = (u8)hif_drv->strWILC_UsrConnReq.tenuAuth_type;
1113 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", hif_drv->strWILC_UsrConnReq.tenuAuth_type);
1114 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
1115 hif_drv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->u8channel);
1117 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
1118 strWIDList[u32WidsCount].type = WID_STR;
1119 strWIDList[u32WidsCount].size = 112;
1120 strWIDList[u32WidsCount].val = kmalloc(strWIDList[u32WidsCount].size, GFP_KERNEL);
1122 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1123 gu32FlushedJoinReqSize = strWIDList[u32WidsCount].size;
1124 gu8FlushedJoinReq = kmalloc(gu32FlushedJoinReqSize, GFP_KERNEL);
1126 if (strWIDList[u32WidsCount].val == NULL) {
1131 pu8CurrByte = strWIDList[u32WidsCount].val;
1134 if (pstrHostIFconnectAttr->ssid != NULL) {
1135 memcpy(pu8CurrByte, pstrHostIFconnectAttr->ssid, pstrHostIFconnectAttr->ssid_len);
1136 pu8CurrByte[pstrHostIFconnectAttr->ssid_len] = '\0';
1138 pu8CurrByte += MAX_SSID_LEN;
1139 *(pu8CurrByte++) = INFRASTRUCTURE;
1141 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1142 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1144 PRINT_ER("Channel out of range\n");
1145 *(pu8CurrByte++) = 0xFF;
1147 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1148 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1149 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1151 if (pstrHostIFconnectAttr->bssid != NULL)
1152 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
1155 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1156 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1157 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1158 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1159 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1161 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
1162 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1164 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1165 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1166 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1168 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1169 hif_drv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
1171 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1172 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1173 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1174 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1175 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1176 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1178 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
1179 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1181 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
1182 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1184 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
1185 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1187 *(pu8CurrByte++) = REAL_JOIN_REQ;
1189 *(pu8CurrByte++) = ptstrJoinBssParam->u8NoaEnbaled;
1190 if (ptstrJoinBssParam->u8NoaEnbaled) {
1191 PRINT_D(HOSTINF_DBG, "NOA present\n");
1193 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1194 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1195 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1196 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1198 *(pu8CurrByte++) = ptstrJoinBssParam->u8Index;
1200 *(pu8CurrByte++) = ptstrJoinBssParam->u8OppEnable;
1202 if (ptstrJoinBssParam->u8OppEnable)
1203 *(pu8CurrByte++) = ptstrJoinBssParam->u8CtWindow;
1205 *(pu8CurrByte++) = ptstrJoinBssParam->u8Count;
1207 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Duration, sizeof(ptstrJoinBssParam->au8Duration));
1209 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Duration);
1211 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Interval, sizeof(ptstrJoinBssParam->au8Interval));
1213 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Interval);
1215 memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
1217 pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1220 PRINT_D(HOSTINF_DBG, "NOA not present\n");
1222 pu8CurrByte = strWIDList[u32WidsCount].val;
1224 gu32WidConnRstHack = 0;
1226 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1227 memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
1228 gu8FlushedJoinReqDrvHandler = hif_drv;
1231 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1233 if (pstrHostIFconnectAttr->bssid != NULL) {
1234 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->bssid, ETH_ALEN);
1236 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n", pstrHostIFconnectAttr->bssid);
1237 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", u8ConnectedSSID);
1240 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
1241 get_id_from_handler(hif_drv));
1243 PRINT_ER("failed to send config packet\n");
1247 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
1248 hif_drv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1253 tstrConnectInfo strConnectInfo;
1255 del_timer(&hif_drv->hConnectTimer);
1257 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
1259 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1261 if (pstrHostIFconnectAttr->pfConnectResult != NULL) {
1262 if (pstrHostIFconnectAttr->bssid != NULL)
1263 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->bssid, 6);
1265 if (pstrHostIFconnectAttr->ies != NULL) {
1266 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1267 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
1268 memcpy(strConnectInfo.pu8ReqIEs,
1269 pstrHostIFconnectAttr->ies,
1270 pstrHostIFconnectAttr->IEsLen);
1273 pstrHostIFconnectAttr->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1277 pstrHostIFconnectAttr->pvUserArg);
1278 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1279 if (strConnectInfo.pu8ReqIEs != NULL) {
1280 kfree(strConnectInfo.pu8ReqIEs);
1281 strConnectInfo.pu8ReqIEs = NULL;
1285 PRINT_ER("Connect callback function pointer is NULL\n");
1289 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
1290 if (pstrHostIFconnectAttr->bssid != NULL) {
1291 kfree(pstrHostIFconnectAttr->bssid);
1292 pstrHostIFconnectAttr->bssid = NULL;
1295 if (pstrHostIFconnectAttr->ssid != NULL) {
1296 kfree(pstrHostIFconnectAttr->ssid);
1297 pstrHostIFconnectAttr->ssid = NULL;
1300 if (pstrHostIFconnectAttr->ies != NULL) {
1301 kfree(pstrHostIFconnectAttr->ies);
1302 pstrHostIFconnectAttr->ies = NULL;
1305 if (pu8CurrByte != NULL)
1310 static s32 Handle_FlushConnect(struct host_if_drv *hif_drv)
1313 struct wid strWIDList[5];
1314 u32 u32WidsCount = 0;
1315 u8 *pu8CurrByte = NULL;
1317 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
1318 strWIDList[u32WidsCount].type = WID_BIN_DATA;
1319 strWIDList[u32WidsCount].val = gu8FlushedInfoElemAsoc;
1320 strWIDList[u32WidsCount].size = gu32FlushedInfoElemAsocSize;
1323 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
1324 strWIDList[u32WidsCount].type = WID_CHAR;
1325 strWIDList[u32WidsCount].size = sizeof(char);
1326 strWIDList[u32WidsCount].val = (s8 *)(&(gu8Flushed11iMode));
1331 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
1332 strWIDList[u32WidsCount].type = WID_CHAR;
1333 strWIDList[u32WidsCount].size = sizeof(char);
1334 strWIDList[u32WidsCount].val = (s8 *)(&gu8FlushedAuthType);
1337 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
1338 strWIDList[u32WidsCount].type = WID_STR;
1339 strWIDList[u32WidsCount].size = gu32FlushedJoinReqSize;
1340 strWIDList[u32WidsCount].val = (s8 *)gu8FlushedJoinReq;
1341 pu8CurrByte = strWIDList[u32WidsCount].val;
1343 pu8CurrByte += FLUSHED_BYTE_POS;
1344 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1348 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
1349 get_id_from_handler(gu8FlushedJoinReqDrvHandler));
1351 PRINT_ER("failed to send config packet\n");
1358 static s32 Handle_ConnectTimeout(struct host_if_drv *hif_drv)
1361 tstrConnectInfo strConnectInfo;
1363 u16 u16DummyReasonCode = 0;
1366 PRINT_ER("Driver handler is NULL\n");
1370 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1372 gbScanWhileConnected = false;
1375 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1377 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
1378 if (hif_drv->strWILC_UsrConnReq.pu8bssid != NULL) {
1379 memcpy(strConnectInfo.au8bssid,
1380 hif_drv->strWILC_UsrConnReq.pu8bssid, 6);
1383 if (hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1384 strConnectInfo.ReqIEsLen = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1385 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
1386 memcpy(strConnectInfo.pu8ReqIEs,
1387 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
1388 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen);
1391 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1395 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
1397 if (strConnectInfo.pu8ReqIEs != NULL) {
1398 kfree(strConnectInfo.pu8ReqIEs);
1399 strConnectInfo.pu8ReqIEs = NULL;
1402 PRINT_ER("Connect callback function pointer is NULL\n");
1405 strWID.id = (u16)WID_DISCONNECT;
1406 strWID.type = WID_CHAR;
1407 strWID.val = (s8 *)&u16DummyReasonCode;
1408 strWID.size = sizeof(char);
1410 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1412 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1413 get_id_from_handler(hif_drv));
1415 PRINT_ER("Failed to send dissconect config packet\n");
1417 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
1418 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
1419 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
1420 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1421 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
1423 eth_zero_addr(u8ConnectedSSID);
1425 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
1426 kfree(gu8FlushedJoinReq);
1427 gu8FlushedJoinReq = NULL;
1429 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
1430 kfree(gu8FlushedInfoElemAsoc);
1431 gu8FlushedInfoElemAsoc = NULL;
1437 static s32 Handle_RcvdNtwrkInfo(struct host_if_drv *hif_drv,
1438 struct rcvd_net_info *pstrRcvdNetworkInfo)
1441 bool bNewNtwrkFound;
1446 tstrNetworkInfo *pstrNetworkInfo = NULL;
1447 void *pJoinParams = NULL;
1449 bNewNtwrkFound = true;
1450 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
1452 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
1453 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
1454 parse_network_info(pstrRcvdNetworkInfo->pu8Buffer, &pstrNetworkInfo);
1455 if ((pstrNetworkInfo == NULL)
1456 || (hif_drv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
1457 PRINT_ER("driver is null\n");
1462 for (i = 0; i < hif_drv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
1464 if ((hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
1465 (pstrNetworkInfo->au8bssid != NULL)) {
1466 if (memcmp(hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
1467 pstrNetworkInfo->au8bssid, 6) == 0) {
1468 if (pstrNetworkInfo->s8rssi <= hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
1469 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
1472 hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
1473 bNewNtwrkFound = false;
1480 if (bNewNtwrkFound == true) {
1481 PRINT_D(HOSTINF_DBG, "New network found\n");
1483 if (hif_drv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
1484 hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
1486 if ((hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
1487 && (pstrNetworkInfo->au8bssid != NULL)) {
1488 memcpy(hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
1489 pstrNetworkInfo->au8bssid, 6);
1491 hif_drv->strWILC_UsrScanReq.u32RcvdChCount++;
1493 pstrNetworkInfo->bNewNetwork = true;
1494 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
1496 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1497 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid,
1503 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
1506 pstrNetworkInfo->bNewNetwork = false;
1507 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1508 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
1513 if (pstrRcvdNetworkInfo->pu8Buffer != NULL) {
1514 kfree(pstrRcvdNetworkInfo->pu8Buffer);
1515 pstrRcvdNetworkInfo->pu8Buffer = NULL;
1518 if (pstrNetworkInfo != NULL) {
1519 DeallocateNetworkInfo(pstrNetworkInfo);
1520 pstrNetworkInfo = NULL;
1526 static s32 Handle_RcvdGnrlAsyncInfo(struct host_if_drv *hif_drv,
1527 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
1533 u16 u16WidID = (u16)WID_NIL;
1536 u8 u8MacStatusReasonCode;
1537 u8 u8MacStatusAdditionalInfo;
1538 tstrConnectInfo strConnectInfo;
1539 tstrDisconnectNotifInfo strDisconnectNotifInfo;
1543 PRINT_ER("Driver handler is NULL\n");
1546 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", hif_drv->enuHostIFstate,
1547 pstrRcvdGnrlAsyncInfo->pu8Buffer[7]);
1549 if ((hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
1550 (hif_drv->enuHostIFstate == HOST_IF_CONNECTED) ||
1551 hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
1552 if ((pstrRcvdGnrlAsyncInfo->pu8Buffer == NULL) ||
1553 (hif_drv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
1554 PRINT_ER("driver is null\n");
1558 u8MsgType = pstrRcvdGnrlAsyncInfo->pu8Buffer[0];
1560 if ('I' != u8MsgType) {
1561 PRINT_ER("Received Message format incorrect.\n");
1565 u8MsgID = pstrRcvdGnrlAsyncInfo->pu8Buffer[1];
1566 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[2], pstrRcvdGnrlAsyncInfo->pu8Buffer[3]);
1567 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[4], pstrRcvdGnrlAsyncInfo->pu8Buffer[5]);
1568 u8WidLen = pstrRcvdGnrlAsyncInfo->pu8Buffer[6];
1569 u8MacStatus = pstrRcvdGnrlAsyncInfo->pu8Buffer[7];
1570 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->pu8Buffer[8];
1571 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->pu8Buffer[9];
1572 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
1573 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
1574 u32 u32RcvdAssocRespInfoLen;
1575 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
1577 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
1579 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1581 if (u8MacStatus == MAC_CONNECTED) {
1582 memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
1584 host_int_get_assoc_res_info(hif_drv,
1586 MAX_ASSOC_RESP_FRAME_SIZE,
1587 &u32RcvdAssocRespInfoLen);
1589 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
1591 if (u32RcvdAssocRespInfoLen != 0) {
1593 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
1594 s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
1595 &pstrConnectRespInfo);
1597 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
1599 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
1601 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
1602 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
1603 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
1604 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
1607 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL);
1608 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
1609 pstrConnectRespInfo->u16RespIEsLen);
1613 if (pstrConnectRespInfo != NULL) {
1614 DeallocateAssocRespInfo(pstrConnectRespInfo);
1615 pstrConnectRespInfo = NULL;
1621 if ((u8MacStatus == MAC_CONNECTED) &&
1622 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
1623 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
1624 eth_zero_addr(u8ConnectedSSID);
1626 } else if (u8MacStatus == MAC_DISCONNECTED) {
1627 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
1628 eth_zero_addr(u8ConnectedSSID);
1631 if (hif_drv->strWILC_UsrConnReq.pu8bssid != NULL) {
1632 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
1633 memcpy(strConnectInfo.au8bssid, hif_drv->strWILC_UsrConnReq.pu8bssid, 6);
1635 if ((u8MacStatus == MAC_CONNECTED) &&
1636 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
1637 memcpy(hif_drv->au8AssociatedBSSID,
1638 hif_drv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
1643 if (hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1644 strConnectInfo.ReqIEsLen = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1645 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
1646 memcpy(strConnectInfo.pu8ReqIEs,
1647 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
1648 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen);
1652 del_timer(&hif_drv->hConnectTimer);
1653 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1657 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
1659 if ((u8MacStatus == MAC_CONNECTED) &&
1660 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
1661 host_int_set_power_mgmt(hif_drv, 0, 0);
1663 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
1664 hif_drv->enuHostIFstate = HOST_IF_CONNECTED;
1666 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
1667 g_obtainingIP = true;
1668 mod_timer(&hDuringIpTimer,
1669 jiffies + msecs_to_jiffies(10000));
1671 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
1672 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1673 gbScanWhileConnected = false;
1676 if (strConnectInfo.pu8RespIEs != NULL) {
1677 kfree(strConnectInfo.pu8RespIEs);
1678 strConnectInfo.pu8RespIEs = NULL;
1681 if (strConnectInfo.pu8ReqIEs != NULL) {
1682 kfree(strConnectInfo.pu8ReqIEs);
1683 strConnectInfo.pu8ReqIEs = NULL;
1685 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
1686 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
1687 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
1688 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1689 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
1690 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
1691 (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)) {
1692 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
1694 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
1696 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
1697 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
1698 del_timer(&hif_drv->hScanTimer);
1699 Handle_ScanDone((void *)hif_drv, SCAN_EVENT_ABORTED);
1702 strDisconnectNotifInfo.u16reason = 0;
1703 strDisconnectNotifInfo.ie = NULL;
1704 strDisconnectNotifInfo.ie_len = 0;
1706 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
1707 g_obtainingIP = false;
1708 host_int_set_power_mgmt(hif_drv, 0, 0);
1710 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1713 &strDisconnectNotifInfo,
1714 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
1717 PRINT_ER("Connect result callback function is NULL\n");
1720 eth_zero_addr(hif_drv->au8AssociatedBSSID);
1722 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
1723 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
1724 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
1725 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1726 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
1728 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
1729 kfree(gu8FlushedJoinReq);
1730 gu8FlushedJoinReq = NULL;
1732 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
1733 kfree(gu8FlushedInfoElemAsoc);
1734 gu8FlushedInfoElemAsoc = NULL;
1737 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1738 gbScanWhileConnected = false;
1740 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
1741 (hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
1742 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
1743 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
1745 del_timer(&hif_drv->hScanTimer);
1746 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult)
1747 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
1753 if (pstrRcvdGnrlAsyncInfo->pu8Buffer != NULL) {
1754 kfree(pstrRcvdGnrlAsyncInfo->pu8Buffer);
1755 pstrRcvdGnrlAsyncInfo->pu8Buffer = NULL;
1761 static int Handle_Key(struct host_if_drv *hif_drv,
1762 struct key_attr *pstrHostIFkeyAttr)
1766 struct wid strWIDList[5];
1772 switch (pstrHostIFkeyAttr->type) {
1777 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1779 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
1780 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->attr.wep.index));
1781 strWIDList[0].id = (u16)WID_11I_MODE;
1782 strWIDList[0].type = WID_CHAR;
1783 strWIDList[0].size = sizeof(char);
1784 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.mode));
1786 strWIDList[1].id = WID_AUTH_TYPE;
1787 strWIDList[1].type = WID_CHAR;
1788 strWIDList[1].size = sizeof(char);
1789 strWIDList[1].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.auth_type));
1791 strWIDList[2].id = (u16)WID_KEY_ID;
1792 strWIDList[2].type = WID_CHAR;
1794 strWIDList[2].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.index));
1795 strWIDList[2].size = sizeof(char);
1797 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len, GFP_KERNEL);
1799 if (pu8keybuf == NULL) {
1800 PRINT_ER("No buffer to send Key\n");
1804 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wep.key,
1805 pstrHostIFkeyAttr->attr.wep.key_len);
1807 kfree(pstrHostIFkeyAttr->attr.wep.key);
1809 strWIDList[3].id = (u16)WID_WEP_KEY_VALUE;
1810 strWIDList[3].type = WID_STR;
1811 strWIDList[3].size = pstrHostIFkeyAttr->attr.wep.key_len;
1812 strWIDList[3].val = (s8 *)pu8keybuf;
1815 s32Error = send_config_pkt(SET_CFG, strWIDList, 4,
1816 get_id_from_handler(hif_drv));
1822 if (pstrHostIFkeyAttr->action & ADDKEY) {
1823 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
1824 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2, GFP_KERNEL);
1825 if (pu8keybuf == NULL) {
1826 PRINT_ER("No buffer to send Key\n");
1829 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1830 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->attr.wep.key_len, 1);
1831 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->attr.wep.key,
1832 pstrHostIFkeyAttr->attr.wep.key_len);
1833 kfree(pstrHostIFkeyAttr->attr.wep.key);
1835 strWID.id = (u16)WID_ADD_WEP_KEY;
1836 strWID.type = WID_STR;
1837 strWID.val = (s8 *)pu8keybuf;
1838 strWID.size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
1840 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1841 get_id_from_handler(hif_drv));
1843 } else if (pstrHostIFkeyAttr->action & REMOVEKEY) {
1845 PRINT_D(HOSTINF_DBG, "Removing key\n");
1846 strWID.id = (u16)WID_REMOVE_WEP_KEY;
1847 strWID.type = WID_STR;
1849 s8idxarray[0] = (s8)pstrHostIFkeyAttr->attr.wep.index;
1850 strWID.val = s8idxarray;
1853 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1854 get_id_from_handler(hif_drv));
1856 strWID.id = (u16)WID_KEY_ID;
1857 strWID.type = WID_CHAR;
1858 strWID.val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.index));
1859 strWID.size = sizeof(char);
1861 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
1863 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1864 get_id_from_handler(hif_drv));
1866 up(&hif_drv->hSemTestKeyBlock);
1870 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1871 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1872 if (pu8keybuf == NULL) {
1873 PRINT_ER("No buffer to send RxGTK Key\n");
1875 goto _WPARxGtk_end_case_;
1878 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
1880 if (pstrHostIFkeyAttr->attr.wpa.seq != NULL)
1881 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1883 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1884 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1885 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1886 pstrHostIFkeyAttr->attr.wpa.key_len);
1888 strWIDList[0].id = (u16)WID_11I_MODE;
1889 strWIDList[0].type = WID_CHAR;
1890 strWIDList[0].size = sizeof(char);
1891 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wpa.mode));
1893 strWIDList[1].id = (u16)WID_ADD_RX_GTK;
1894 strWIDList[1].type = WID_STR;
1895 strWIDList[1].val = (s8 *)pu8keybuf;
1896 strWIDList[1].size = RX_MIC_KEY_MSG_LEN;
1898 s32Error = send_config_pkt(SET_CFG, strWIDList, 2,
1899 get_id_from_handler(hif_drv));
1902 up(&hif_drv->hSemTestKeyBlock);
1905 if (pstrHostIFkeyAttr->action & ADDKEY) {
1906 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
1908 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1909 if (pu8keybuf == NULL) {
1910 PRINT_ER("No buffer to send RxGTK Key\n");
1912 goto _WPARxGtk_end_case_;
1915 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
1917 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)
1918 memcpy(pu8keybuf, hif_drv->au8AssociatedBSSID, ETH_ALEN);
1920 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
1922 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1923 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1924 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1925 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1926 pstrHostIFkeyAttr->attr.wpa.key_len);
1928 strWID.id = (u16)WID_ADD_RX_GTK;
1929 strWID.type = WID_STR;
1930 strWID.val = (s8 *)pu8keybuf;
1931 strWID.size = RX_MIC_KEY_MSG_LEN;
1933 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1934 get_id_from_handler(hif_drv));
1937 up(&hif_drv->hSemTestKeyBlock);
1939 _WPARxGtk_end_case_:
1940 kfree(pstrHostIFkeyAttr->attr.wpa.key);
1941 kfree(pstrHostIFkeyAttr->attr.wpa.seq);
1948 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1951 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
1955 if (pu8keybuf == NULL) {
1956 PRINT_ER("No buffer to send PTK Key\n");
1958 goto _WPAPtk_end_case_;
1962 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1963 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1964 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1965 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->attr.wpa.key,
1966 pstrHostIFkeyAttr->attr.wpa.key_len);
1968 strWIDList[0].id = (u16)WID_11I_MODE;
1969 strWIDList[0].type = WID_CHAR;
1970 strWIDList[0].size = sizeof(char);
1971 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wpa.mode));
1973 strWIDList[1].id = (u16)WID_ADD_PTK;
1974 strWIDList[1].type = WID_STR;
1975 strWIDList[1].val = (s8 *)pu8keybuf;
1976 strWIDList[1].size = PTK_KEY_MSG_LEN + 1;
1978 s32Error = send_config_pkt(SET_CFG, strWIDList, 2,
1979 get_id_from_handler(hif_drv));
1981 up(&hif_drv->hSemTestKeyBlock);
1983 if (pstrHostIFkeyAttr->action & ADDKEY) {
1986 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
1990 if (pu8keybuf == NULL) {
1991 PRINT_ER("No buffer to send PTK Key\n");
1993 goto _WPAPtk_end_case_;
1997 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1998 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1999 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->attr.wpa.key,
2000 pstrHostIFkeyAttr->attr.wpa.key_len);
2002 strWID.id = (u16)WID_ADD_PTK;
2003 strWID.type = WID_STR;
2004 strWID.val = (s8 *)pu8keybuf;
2005 strWID.size = PTK_KEY_MSG_LEN;
2007 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2008 get_id_from_handler(hif_drv));
2010 up(&hif_drv->hSemTestKeyBlock);
2014 kfree(pstrHostIFkeyAttr->attr.wpa.key);
2023 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
2025 pu8keybuf = kmalloc((pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
2026 if (pu8keybuf == NULL) {
2027 PRINT_ER("No buffer to send PMKSA Key\n");
2031 pu8keybuf[0] = pstrHostIFkeyAttr->attr.pmkid.numpmkid;
2033 for (i = 0; i < pstrHostIFkeyAttr->attr.pmkid.numpmkid; i++) {
2034 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
2035 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
2038 strWID.id = (u16)WID_PMKID_INFO;
2039 strWID.type = WID_STR;
2040 strWID.val = (s8 *)pu8keybuf;
2041 strWID.size = (pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
2043 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2044 get_id_from_handler(hif_drv));
2051 PRINT_ER("Failed to send key config packet\n");
2057 static void Handle_Disconnect(struct host_if_drv *hif_drv)
2062 u16 u16DummyReasonCode = 0;
2064 strWID.id = (u16)WID_DISCONNECT;
2065 strWID.type = WID_CHAR;
2066 strWID.val = (s8 *)&u16DummyReasonCode;
2067 strWID.size = sizeof(char);
2071 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2073 g_obtainingIP = false;
2074 host_int_set_power_mgmt(hif_drv, 0, 0);
2076 eth_zero_addr(u8ConnectedSSID);
2078 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2079 get_id_from_handler(hif_drv));
2082 PRINT_ER("Failed to send dissconect config packet\n");
2084 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2086 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
2088 strDisconnectNotifInfo.u16reason = 0;
2089 strDisconnectNotifInfo.ie = NULL;
2090 strDisconnectNotifInfo.ie_len = 0;
2092 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
2093 del_timer(&hif_drv->hScanTimer);
2094 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
2095 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2097 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
2100 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2101 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2102 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
2103 del_timer(&hif_drv->hConnectTimer);
2106 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
2107 0, &strDisconnectNotifInfo, hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
2109 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
2112 gbScanWhileConnected = false;
2114 hif_drv->enuHostIFstate = HOST_IF_IDLE;
2116 eth_zero_addr(hif_drv->au8AssociatedBSSID);
2118 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
2119 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
2120 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
2121 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2122 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
2124 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
2125 kfree(gu8FlushedJoinReq);
2126 gu8FlushedJoinReq = NULL;
2128 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
2129 kfree(gu8FlushedInfoElemAsoc);
2130 gu8FlushedInfoElemAsoc = NULL;
2135 up(&hif_drv->hSemTestDisconnectBlock);
2139 void resolve_disconnect_aberration(struct host_if_drv *hif_drv)
2143 if ((hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (hif_drv->enuHostIFstate == HOST_IF_CONNECTING)) {
2144 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
2145 host_int_disconnect(hif_drv, 1);
2149 static s32 Handle_GetChnl(struct host_if_drv *hif_drv)
2155 strWID.id = (u16)WID_CURRENT_CHANNEL;
2156 strWID.type = WID_CHAR;
2157 strWID.val = (s8 *)&gu8Chnl;
2158 strWID.size = sizeof(char);
2160 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
2162 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2163 get_id_from_handler(hif_drv));
2166 PRINT_ER("Failed to get channel number\n");
2170 up(&hif_drv->hSemGetCHNL);
2178 static void Handle_GetRssi(struct host_if_drv *hif_drv)
2183 strWID.id = (u16)WID_RSSI;
2184 strWID.type = WID_CHAR;
2185 strWID.val = &gs8Rssi;
2186 strWID.size = sizeof(char);
2188 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
2190 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2191 get_id_from_handler(hif_drv));
2193 PRINT_ER("Failed to get RSSI value\n");
2197 up(&hif_drv->hSemGetRSSI);
2203 static void Handle_GetLinkspeed(struct host_if_drv *hif_drv)
2210 strWID.id = (u16)WID_LINKSPEED;
2211 strWID.type = WID_CHAR;
2212 strWID.val = &gs8lnkspd;
2213 strWID.size = sizeof(char);
2215 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
2217 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2218 get_id_from_handler(hif_drv));
2220 PRINT_ER("Failed to get LINKSPEED value\n");
2224 up(&(hif_drv->hSemGetLINKSPEED));
2229 s32 Handle_GetStatistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
2231 struct wid strWIDList[5];
2232 u32 u32WidsCount = 0, s32Error = 0;
2234 strWIDList[u32WidsCount].id = WID_LINKSPEED;
2235 strWIDList[u32WidsCount].type = WID_CHAR;
2236 strWIDList[u32WidsCount].size = sizeof(char);
2237 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u8LinkSpeed));
2240 strWIDList[u32WidsCount].id = WID_RSSI;
2241 strWIDList[u32WidsCount].type = WID_CHAR;
2242 strWIDList[u32WidsCount].size = sizeof(char);
2243 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->s8RSSI));
2246 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
2247 strWIDList[u32WidsCount].type = WID_INT;
2248 strWIDList[u32WidsCount].size = sizeof(u32);
2249 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32TxCount));
2252 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
2253 strWIDList[u32WidsCount].type = WID_INT;
2254 strWIDList[u32WidsCount].size = sizeof(u32);
2255 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32RxCount));
2258 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
2259 strWIDList[u32WidsCount].type = WID_INT;
2260 strWIDList[u32WidsCount].size = sizeof(u32);
2261 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32TxFailureCount));
2264 s32Error = send_config_pkt(GET_CFG, strWIDList, u32WidsCount,
2265 get_id_from_handler(hif_drv));
2268 PRINT_ER("Failed to send scan paramters config packet\n");
2275 static s32 Handle_Get_InActiveTime(struct host_if_drv *hif_drv,
2276 struct sta_inactive_t *strHostIfStaInactiveT)
2283 strWID.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
2284 strWID.type = WID_STR;
2285 strWID.size = ETH_ALEN;
2286 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2289 stamac = strWID.val;
2290 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
2293 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
2296 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2297 get_id_from_handler(hif_drv));
2300 PRINT_ER("Failed to SET incative time\n");
2305 strWID.id = (u16)WID_GET_INACTIVE_TIME;
2306 strWID.type = WID_INT;
2307 strWID.val = (s8 *)&gu32InactiveTime;
2308 strWID.size = sizeof(u32);
2311 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2312 get_id_from_handler(hif_drv));
2315 PRINT_ER("Failed to get incative time\n");
2320 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
2322 up(&hif_drv->hSemInactiveTime);
2330 static void Handle_AddBeacon(struct host_if_drv *hif_drv,
2331 struct beacon_attr *pstrSetBeaconParam)
2337 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
2339 strWID.id = (u16)WID_ADD_BEACON;
2340 strWID.type = WID_BIN;
2341 strWID.size = pstrSetBeaconParam->u32HeadLen + pstrSetBeaconParam->u32TailLen + 16;
2342 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2343 if (strWID.val == NULL)
2346 pu8CurrByte = strWID.val;
2347 *pu8CurrByte++ = (pstrSetBeaconParam->u32Interval & 0xFF);
2348 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 8) & 0xFF);
2349 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 16) & 0xFF);
2350 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 24) & 0xFF);
2352 *pu8CurrByte++ = (pstrSetBeaconParam->u32DTIMPeriod & 0xFF);
2353 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 8) & 0xFF);
2354 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 16) & 0xFF);
2355 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 24) & 0xFF);
2357 *pu8CurrByte++ = (pstrSetBeaconParam->u32HeadLen & 0xFF);
2358 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 8) & 0xFF);
2359 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 16) & 0xFF);
2360 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 24) & 0xFF);
2362 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Head, pstrSetBeaconParam->u32HeadLen);
2363 pu8CurrByte += pstrSetBeaconParam->u32HeadLen;
2365 *pu8CurrByte++ = (pstrSetBeaconParam->u32TailLen & 0xFF);
2366 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 8) & 0xFF);
2367 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 16) & 0xFF);
2368 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 24) & 0xFF);
2370 if (pstrSetBeaconParam->pu8Tail > 0)
2371 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Tail, pstrSetBeaconParam->u32TailLen);
2372 pu8CurrByte += pstrSetBeaconParam->u32TailLen;
2374 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2375 get_id_from_handler(hif_drv));
2377 PRINT_ER("Failed to send add beacon config packet\n");
2381 kfree(pstrSetBeaconParam->pu8Head);
2382 kfree(pstrSetBeaconParam->pu8Tail);
2385 static void Handle_DelBeacon(struct host_if_drv *hif_drv)
2391 strWID.id = (u16)WID_DEL_BEACON;
2392 strWID.type = WID_CHAR;
2393 strWID.size = sizeof(char);
2394 strWID.val = &gu8DelBcn;
2396 if (strWID.val == NULL)
2399 pu8CurrByte = strWID.val;
2401 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
2403 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2404 get_id_from_handler(hif_drv));
2406 PRINT_ER("Failed to send delete beacon config packet\n");
2409 static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
2410 struct add_sta_param *pstrStationParam)
2414 pu8CurrByte = pu8Buffer;
2416 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
2417 memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
2418 pu8CurrByte += ETH_ALEN;
2420 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
2421 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
2423 *pu8CurrByte++ = pstrStationParam->u8NumRates;
2424 if (pstrStationParam->u8NumRates > 0)
2425 memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
2426 pu8CurrByte += pstrStationParam->u8NumRates;
2428 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
2429 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
2430 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
2432 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
2433 memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
2434 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
2436 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
2437 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
2439 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
2440 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
2441 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
2442 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
2444 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
2446 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
2447 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
2449 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
2450 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
2452 return pu8CurrByte - pu8Buffer;
2455 static void Handle_AddStation(struct host_if_drv *hif_drv,
2456 struct add_sta_param *pstrStationParam)
2462 PRINT_D(HOSTINF_DBG, "Handling add station\n");
2463 strWID.id = (u16)WID_ADD_STA;
2464 strWID.type = WID_BIN;
2465 strWID.size = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
2467 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2468 if (strWID.val == NULL)
2471 pu8CurrByte = strWID.val;
2472 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2474 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2475 get_id_from_handler(hif_drv));
2477 PRINT_ER("Failed to send add station config packet\n");
2480 kfree(pstrStationParam->pu8Rates);
2484 static void Handle_DelAllSta(struct host_if_drv *hif_drv,
2485 struct del_all_sta *pstrDelAllStaParam)
2492 u8 au8Zero_Buff[6] = {0};
2494 strWID.id = (u16)WID_DEL_ALL_STA;
2495 strWID.type = WID_STR;
2496 strWID.size = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1;
2498 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
2500 strWID.val = kmalloc((pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1, GFP_KERNEL);
2501 if (strWID.val == NULL)
2504 pu8CurrByte = strWID.val;
2506 *(pu8CurrByte++) = pstrDelAllStaParam->u8Num_AssocSta;
2508 for (i = 0; i < MAX_NUM_STA; i++) {
2509 if (memcmp(pstrDelAllStaParam->au8Sta_DelAllSta[i], au8Zero_Buff, ETH_ALEN))
2510 memcpy(pu8CurrByte, pstrDelAllStaParam->au8Sta_DelAllSta[i], ETH_ALEN);
2514 pu8CurrByte += ETH_ALEN;
2517 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2518 get_id_from_handler(hif_drv));
2520 PRINT_ER("Failed to send add station config packet\n");
2528 static void Handle_DelStation(struct host_if_drv *hif_drv,
2529 struct del_sta *pstrDelStaParam)
2535 strWID.id = (u16)WID_REMOVE_STA;
2536 strWID.type = WID_BIN;
2537 strWID.size = ETH_ALEN;
2539 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
2541 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2542 if (strWID.val == NULL)
2545 pu8CurrByte = strWID.val;
2547 memcpy(pu8CurrByte, pstrDelStaParam->au8MacAddr, ETH_ALEN);
2549 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2550 get_id_from_handler(hif_drv));
2552 PRINT_ER("Failed to send add station config packet\n");
2558 static void Handle_EditStation(struct host_if_drv *hif_drv,
2559 struct add_sta_param *pstrStationParam)
2565 strWID.id = (u16)WID_EDIT_STA;
2566 strWID.type = WID_BIN;
2567 strWID.size = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
2569 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
2570 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2571 if (strWID.val == NULL)
2574 pu8CurrByte = strWID.val;
2575 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2577 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2578 get_id_from_handler(hif_drv));
2580 PRINT_ER("Failed to send edit station config packet\n");
2583 kfree(pstrStationParam->pu8Rates);
2587 static int Handle_RemainOnChan(struct host_if_drv *hif_drv,
2588 struct remain_ch *pstrHostIfRemainOnChan)
2591 u8 u8remain_on_chan_flag;
2594 if (!hif_drv->u8RemainOnChan_pendingreq) {
2595 hif_drv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
2596 hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
2597 hif_drv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
2598 hif_drv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
2599 hif_drv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
2601 pstrHostIfRemainOnChan->u16Channel = hif_drv->strHostIfRemainOnChan.u16Channel;
2604 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
2605 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
2606 hif_drv->u8RemainOnChan_pendingreq = 1;
2610 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2611 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
2616 if (g_obtainingIP || connecting) {
2617 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
2622 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
2624 u8remain_on_chan_flag = true;
2625 strWID.id = (u16)WID_REMAIN_ON_CHAN;
2626 strWID.type = WID_STR;
2628 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2630 if (strWID.val == NULL) {
2635 strWID.val[0] = u8remain_on_chan_flag;
2636 strWID.val[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
2638 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2639 get_id_from_handler(hif_drv));
2641 PRINT_ER("Failed to set remain on channel\n");
2645 P2P_LISTEN_STATE = 1;
2646 hif_drv->hRemainOnChannel.data = (unsigned long)hif_drv;
2647 mod_timer(&hif_drv->hRemainOnChannel,
2649 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
2651 if (hif_drv->strHostIfRemainOnChan.pRemainOnChanReady)
2652 hif_drv->strHostIfRemainOnChan.pRemainOnChanReady(hif_drv->strHostIfRemainOnChan.pVoid);
2654 if (hif_drv->u8RemainOnChan_pendingreq)
2655 hif_drv->u8RemainOnChan_pendingreq = 0;
2660 static int Handle_RegisterFrame(struct host_if_drv *hif_drv,
2661 struct reg_frame *pstrHostIfRegisterFrame)
2667 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
2669 strWID.id = (u16)WID_REGISTER_FRAME;
2670 strWID.type = WID_STR;
2671 strWID.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
2672 if (strWID.val == NULL)
2675 pu8CurrByte = strWID.val;
2677 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
2678 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
2679 memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
2682 strWID.size = sizeof(u16) + 2;
2684 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2685 get_id_from_handler(hif_drv));
2687 PRINT_ER("Failed to frame register config packet\n");
2695 #define FALSE_FRMWR_CHANNEL 100
2696 static u32 Handle_ListenStateExpired(struct host_if_drv *hif_drv,
2697 struct remain_ch *pstrHostIfRemainOnChan)
2699 u8 u8remain_on_chan_flag;
2703 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
2705 if (P2P_LISTEN_STATE) {
2706 u8remain_on_chan_flag = false;
2707 strWID.id = (u16)WID_REMAIN_ON_CHAN;
2708 strWID.type = WID_STR;
2710 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2712 if (strWID.val == NULL)
2713 PRINT_ER("Failed to allocate memory\n");
2715 strWID.val[0] = u8remain_on_chan_flag;
2716 strWID.val[1] = FALSE_FRMWR_CHANNEL;
2718 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2719 get_id_from_handler(hif_drv));
2720 if (s32Error != 0) {
2721 PRINT_ER("Failed to set remain on channel\n");
2725 if (hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired) {
2726 hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired(hif_drv->strHostIfRemainOnChan.pVoid
2727 , pstrHostIfRemainOnChan->u32ListenSessionID);
2729 P2P_LISTEN_STATE = 0;
2731 PRINT_D(GENERIC_DBG, "Not in listen state\n");
2739 static void ListenTimerCB(unsigned long arg)
2742 struct host_if_msg msg;
2743 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
2745 del_timer(&hif_drv->hRemainOnChannel);
2747 memset(&msg, 0, sizeof(struct host_if_msg));
2748 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
2750 msg.body.remain_on_ch.u32ListenSessionID = hif_drv->strHostIfRemainOnChan.u32ListenSessionID;
2752 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
2754 PRINT_ER("wilc_mq_send fail\n");
2757 static void Handle_PowerManagement(struct host_if_drv *hif_drv,
2758 struct power_mgmt_param *strPowerMgmtParam)
2764 strWID.id = (u16)WID_POWER_MANAGEMENT;
2766 if (strPowerMgmtParam->bIsEnabled == true)
2767 s8PowerMode = MIN_FAST_PS;
2769 s8PowerMode = NO_POWERSAVE;
2770 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
2771 strWID.val = &s8PowerMode;
2772 strWID.size = sizeof(char);
2774 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
2776 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2777 get_id_from_handler(hif_drv));
2779 PRINT_ER("Failed to send power management config packet\n");
2782 static void Handle_SetMulticastFilter(struct host_if_drv *hif_drv,
2783 struct set_multicast *strHostIfSetMulti)
2789 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
2791 strWID.id = (u16)WID_SETUP_MULTICAST_FILTER;
2792 strWID.type = WID_BIN;
2793 strWID.size = sizeof(struct set_multicast) + ((strHostIfSetMulti->u32count) * ETH_ALEN);
2794 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2795 if (strWID.val == NULL)
2798 pu8CurrByte = strWID.val;
2799 *pu8CurrByte++ = (strHostIfSetMulti->bIsEnabled & 0xFF);
2800 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 8) & 0xFF);
2801 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 16) & 0xFF);
2802 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 24) & 0xFF);
2804 *pu8CurrByte++ = (strHostIfSetMulti->u32count & 0xFF);
2805 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 8) & 0xFF);
2806 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 16) & 0xFF);
2807 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 24) & 0xFF);
2809 if ((strHostIfSetMulti->u32count) > 0)
2810 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->u32count) * ETH_ALEN));
2812 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2813 get_id_from_handler(hif_drv));
2815 PRINT_ER("Failed to send setup multicast config packet\n");
2822 static s32 Handle_AddBASession(struct host_if_drv *hif_drv,
2823 struct ba_session_info *strHostIfBASessionInfo)
2827 int AddbaTimeout = 100;
2830 PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\nBufferSize == %d\nSessionTimeOut = %d\n",
2831 strHostIfBASessionInfo->au8Bssid[0],
2832 strHostIfBASessionInfo->au8Bssid[1],
2833 strHostIfBASessionInfo->au8Bssid[2],
2834 strHostIfBASessionInfo->u16BufferSize,
2835 strHostIfBASessionInfo->u16SessionTimeout,
2836 strHostIfBASessionInfo->u8Ted);
2838 strWID.id = (u16)WID_11E_P_ACTION_REQ;
2839 strWID.type = WID_STR;
2840 strWID.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2841 strWID.size = BLOCK_ACK_REQ_SIZE;
2846 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2848 *ptr++ = strHostIfBASessionInfo->u8Ted;
2850 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
2851 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
2852 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
2853 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
2854 *ptr++ = (AddbaTimeout & 0xFF);
2855 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
2859 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2860 get_id_from_handler(hif_drv));
2862 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
2865 strWID.id = (u16)WID_11E_P_ACTION_REQ;
2866 strWID.type = WID_STR;
2872 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2874 *ptr++ = strHostIfBASessionInfo->u8Ted;
2876 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
2877 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
2879 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2880 get_id_from_handler(hif_drv));
2882 if (strWID.val != NULL)
2889 static s32 Handle_DelAllRxBASessions(struct host_if_drv *hif_drv,
2890 struct ba_session_info *strHostIfBASessionInfo)
2896 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
2897 strHostIfBASessionInfo->au8Bssid[0],
2898 strHostIfBASessionInfo->au8Bssid[1],
2899 strHostIfBASessionInfo->au8Bssid[2],
2900 strHostIfBASessionInfo->u8Ted);
2902 strWID.id = (u16)WID_DEL_ALL_RX_BA;
2903 strWID.type = WID_STR;
2904 strWID.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2905 strWID.size = BLOCK_ACK_REQ_SIZE;
2910 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2912 *ptr++ = strHostIfBASessionInfo->u8Ted;
2916 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2917 get_id_from_handler(hif_drv));
2919 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
2922 if (strWID.val != NULL)
2931 static int hostIFthread(void *pvArg)
2934 struct host_if_msg msg;
2935 struct host_if_drv *hif_drv;
2937 memset(&msg, 0, sizeof(struct host_if_msg));
2940 wilc_mq_recv(&gMsgQHostIF, &msg, sizeof(struct host_if_msg), &u32Ret);
2941 hif_drv = (struct host_if_drv *)msg.drv;
2942 if (msg.id == HOST_IF_MSG_EXIT) {
2943 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
2947 if ((!g_wilc_initialized)) {
2948 PRINT_D(GENERIC_DBG, "--WAIT--");
2949 usleep_range(200 * 1000, 200 * 1000);
2950 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
2954 if (msg.id == HOST_IF_MSG_CONNECT && hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
2955 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
2956 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
2957 usleep_range(2 * 1000, 2 * 1000);
2962 case HOST_IF_MSG_Q_IDLE:
2963 Handle_wait_msg_q_empty();
2966 case HOST_IF_MSG_SCAN:
2967 Handle_Scan(msg.drv, &msg.body.scan_info);
2970 case HOST_IF_MSG_CONNECT:
2971 Handle_Connect(msg.drv, &msg.body.con_info);
2974 case HOST_IF_MSG_FLUSH_CONNECT:
2975 Handle_FlushConnect(msg.drv);
2978 case HOST_IF_MSG_RCVD_NTWRK_INFO:
2979 Handle_RcvdNtwrkInfo(msg.drv, &msg.body.net_info);
2982 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
2983 Handle_RcvdGnrlAsyncInfo(msg.drv, &msg.body.async_info);
2986 case HOST_IF_MSG_KEY:
2987 Handle_Key(msg.drv, &msg.body.key_info);
2990 case HOST_IF_MSG_CFG_PARAMS:
2992 Handle_CfgParam(msg.drv, &msg.body.cfg_info);
2995 case HOST_IF_MSG_SET_CHANNEL:
2996 Handle_SetChannel(msg.drv, &msg.body.channel_info);
2999 case HOST_IF_MSG_DISCONNECT:
3000 Handle_Disconnect(msg.drv);
3003 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
3004 del_timer(&hif_drv->hScanTimer);
3005 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
3007 if (!linux_wlan_get_num_conn_ifcs())
3008 chip_sleep_manually(INFINITE_SLEEP_TIME);
3010 Handle_ScanDone(msg.drv, SCAN_EVENT_DONE);
3012 if (hif_drv->u8RemainOnChan_pendingreq)
3013 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
3017 case HOST_IF_MSG_GET_RSSI:
3018 Handle_GetRssi(msg.drv);
3021 case HOST_IF_MSG_GET_LINKSPEED:
3022 Handle_GetLinkspeed(msg.drv);
3025 case HOST_IF_MSG_GET_STATISTICS:
3026 Handle_GetStatistics(msg.drv, (struct rf_info *)msg.body.data);
3029 case HOST_IF_MSG_GET_CHNL:
3030 Handle_GetChnl(msg.drv);
3033 case HOST_IF_MSG_ADD_BEACON:
3034 Handle_AddBeacon(msg.drv, &msg.body.beacon_info);
3037 case HOST_IF_MSG_DEL_BEACON:
3038 Handle_DelBeacon(msg.drv);
3041 case HOST_IF_MSG_ADD_STATION:
3042 Handle_AddStation(msg.drv, &msg.body.add_sta_info);
3045 case HOST_IF_MSG_DEL_STATION:
3046 Handle_DelStation(msg.drv, &msg.body.del_sta_info);
3049 case HOST_IF_MSG_EDIT_STATION:
3050 Handle_EditStation(msg.drv, &msg.body.edit_sta_info);
3053 case HOST_IF_MSG_GET_INACTIVETIME:
3054 Handle_Get_InActiveTime(msg.drv, &msg.body.mac_info);
3057 case HOST_IF_MSG_SCAN_TIMER_FIRED:
3058 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
3060 Handle_ScanDone(msg.drv, SCAN_EVENT_ABORTED);
3063 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
3064 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
3065 Handle_ConnectTimeout(msg.drv);
3068 case HOST_IF_MSG_POWER_MGMT:
3069 Handle_PowerManagement(msg.drv, &msg.body.pwr_mgmt_info);
3072 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
3073 Handle_SetWfiDrvHandler(msg.drv,
3077 case HOST_IF_MSG_SET_OPERATION_MODE:
3078 Handle_SetOperationMode(msg.drv, &msg.body.mode);
3081 case HOST_IF_MSG_SET_IPADDRESS:
3082 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
3083 Handle_set_IPAddress(msg.drv, msg.body.ip_info.au8IPAddr, msg.body.ip_info.idx);
3086 case HOST_IF_MSG_GET_IPADDRESS:
3087 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
3088 Handle_get_IPAddress(msg.drv, msg.body.ip_info.au8IPAddr, msg.body.ip_info.idx);
3091 case HOST_IF_MSG_SET_MAC_ADDRESS:
3092 Handle_SetMacAddress(msg.drv, &msg.body.set_mac_info);
3095 case HOST_IF_MSG_GET_MAC_ADDRESS:
3096 Handle_GetMacAddress(msg.drv, &msg.body.get_mac_info);
3099 case HOST_IF_MSG_REMAIN_ON_CHAN:
3100 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
3101 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
3104 case HOST_IF_MSG_REGISTER_FRAME:
3105 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
3106 Handle_RegisterFrame(msg.drv, &msg.body.reg_frame);
3109 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
3110 Handle_ListenStateExpired(msg.drv, &msg.body.remain_on_ch);
3113 case HOST_IF_MSG_SET_MULTICAST_FILTER:
3114 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
3115 Handle_SetMulticastFilter(msg.drv, &msg.body.multicast_info);
3118 case HOST_IF_MSG_ADD_BA_SESSION:
3119 Handle_AddBASession(msg.drv, &msg.body.session_info);
3122 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
3123 Handle_DelAllRxBASessions(msg.drv, &msg.body.session_info);
3126 case HOST_IF_MSG_DEL_ALL_STA:
3127 Handle_DelAllSta(msg.drv, &msg.body.del_all_sta_info);
3131 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
3136 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
3137 up(&hSemHostIFthrdEnd);
3141 static void TimerCB_Scan(unsigned long arg)
3143 void *pvArg = (void *)arg;
3144 struct host_if_msg msg;
3146 memset(&msg, 0, sizeof(struct host_if_msg));
3148 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
3150 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3153 static void TimerCB_Connect(unsigned long arg)
3155 void *pvArg = (void *)arg;
3156 struct host_if_msg msg;
3158 memset(&msg, 0, sizeof(struct host_if_msg));
3160 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
3162 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3165 s32 host_int_remove_key(struct host_if_drv *hif_drv, const u8 *pu8StaAddress)
3169 strWID.id = (u16)WID_REMOVE_KEY;
3170 strWID.type = WID_STR;
3171 strWID.val = (s8 *)pu8StaAddress;
3177 int host_int_remove_wep_key(struct host_if_drv *hif_drv, u8 index)
3180 struct host_if_msg msg;
3184 PRINT_ER("Failed to send setup multicast config packet\n");
3188 memset(&msg, 0, sizeof(struct host_if_msg));
3190 msg.id = HOST_IF_MSG_KEY;
3191 msg.body.key_info.type = WEP;
3192 msg.body.key_info.action = REMOVEKEY;
3194 msg.body.key_info.attr.wep.index = index;
3196 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3198 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
3199 down(&hif_drv->hSemTestKeyBlock);
3204 s32 host_int_set_WEPDefaultKeyID(struct host_if_drv *hif_drv, u8 u8Index)
3207 struct host_if_msg msg;
3212 PRINT_ER("driver is null\n");
3216 memset(&msg, 0, sizeof(struct host_if_msg));
3219 msg.id = HOST_IF_MSG_KEY;
3220 msg.body.key_info.type = WEP;
3221 msg.body.key_info.action = DEFAULTKEY;
3223 msg.body.key_info.attr.wep.index = u8Index;
3225 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3227 PRINT_ER("Error in sending message queue : Default key index\n");
3228 down(&hif_drv->hSemTestKeyBlock);
3233 s32 host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv,
3234 const u8 *pu8WepKey,
3240 struct host_if_msg msg;
3244 PRINT_ER("driver is null\n");
3248 memset(&msg, 0, sizeof(struct host_if_msg));
3251 msg.id = HOST_IF_MSG_KEY;
3252 msg.body.key_info.type = WEP;
3253 msg.body.key_info.action = ADDKEY;
3255 msg.body.key_info.attr.wep.key = kmalloc(u8WepKeylen, GFP_KERNEL);
3256 memcpy(msg.body.key_info.attr.wep.key, pu8WepKey, u8WepKeylen);
3257 msg.body.key_info.attr.wep.key_len = (u8WepKeylen);
3258 msg.body.key_info.attr.wep.index = u8Keyidx;
3260 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3262 PRINT_ER("Error in sending message queue :WEP Key\n");
3263 down(&hif_drv->hSemTestKeyBlock);
3269 s32 host_int_add_wep_key_bss_ap(struct host_if_drv *hif_drv,
3270 const u8 *pu8WepKey,
3274 enum AUTHTYPE tenuAuth_type)
3278 struct host_if_msg msg;
3283 PRINT_ER("driver is null\n");
3287 memset(&msg, 0, sizeof(struct host_if_msg));
3290 for (i = 0; i < u8WepKeylen; i++)
3291 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
3293 msg.id = HOST_IF_MSG_KEY;
3294 msg.body.key_info.type = WEP;
3295 msg.body.key_info.action = ADDKEY_AP;
3297 msg.body.key_info.attr.wep.key = kmalloc(u8WepKeylen, GFP_KERNEL);
3298 memcpy(msg.body.key_info.attr.wep.key, pu8WepKey, (u8WepKeylen));
3299 msg.body.key_info.attr.wep.key_len = (u8WepKeylen);
3300 msg.body.key_info.attr.wep.index = u8Keyidx;
3301 msg.body.key_info.attr.wep.mode = u8mode;
3302 msg.body.key_info.attr.wep.auth_type = tenuAuth_type;
3304 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3307 PRINT_ER("Error in sending message queue :WEP Key\n");
3308 down(&hif_drv->hSemTestKeyBlock);
3314 s32 host_int_add_ptk(struct host_if_drv *hif_drv, const u8 *pu8Ptk,
3315 u8 u8PtkKeylen, const u8 *mac_addr,
3316 const u8 *pu8RxMic, const u8 *pu8TxMic,
3317 u8 mode, u8 u8Ciphermode, u8 u8Idx)
3320 struct host_if_msg msg;
3321 u8 u8KeyLen = u8PtkKeylen;
3326 PRINT_ER("driver is null\n");
3329 if (pu8RxMic != NULL)
3330 u8KeyLen += RX_MIC_KEY_LEN;
3331 if (pu8TxMic != NULL)
3332 u8KeyLen += TX_MIC_KEY_LEN;
3334 memset(&msg, 0, sizeof(struct host_if_msg));
3337 msg.id = HOST_IF_MSG_KEY;
3338 msg.body.key_info.type = WPAPtk;
3339 if (mode == AP_MODE) {
3340 msg.body.key_info.action = ADDKEY_AP;
3341 msg.body.key_info.attr.wpa.index = u8Idx;
3343 if (mode == STATION_MODE)
3344 msg.body.key_info.action = ADDKEY;
3346 msg.body.key_info.attr.wpa.key = kmalloc(u8PtkKeylen, GFP_KERNEL);
3347 memcpy(msg.body.key_info.attr.wpa.key, pu8Ptk, u8PtkKeylen);
3349 if (pu8RxMic != NULL) {
3350 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic, RX_MIC_KEY_LEN);
3352 for (i = 0; i < RX_MIC_KEY_LEN; i++)
3353 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
3356 if (pu8TxMic != NULL) {
3357 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic, TX_MIC_KEY_LEN);
3359 for (i = 0; i < TX_MIC_KEY_LEN; i++)
3360 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
3364 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
3365 msg.body.key_info.attr.wpa.mac_addr = mac_addr;
3366 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
3369 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3372 PRINT_ER("Error in sending message queue: PTK Key\n");
3374 down(&hif_drv->hSemTestKeyBlock);
3379 s32 host_int_add_rx_gtk(struct host_if_drv *hif_drv, const u8 *pu8RxGtk,
3380 u8 u8GtkKeylen, u8 u8KeyIdx,
3381 u32 u32KeyRSClen, const u8 *KeyRSC,
3382 const u8 *pu8RxMic, const u8 *pu8TxMic,
3383 u8 mode, u8 u8Ciphermode)
3386 struct host_if_msg msg;
3387 u8 u8KeyLen = u8GtkKeylen;
3391 PRINT_ER("driver is null\n");
3394 memset(&msg, 0, sizeof(struct host_if_msg));
3397 if (pu8RxMic != NULL)
3398 u8KeyLen += RX_MIC_KEY_LEN;
3399 if (pu8TxMic != NULL)
3400 u8KeyLen += TX_MIC_KEY_LEN;
3401 if (KeyRSC != NULL) {
3402 msg.body.key_info.attr.wpa.seq = kmalloc(u32KeyRSClen, GFP_KERNEL);
3403 memcpy(msg.body.key_info.attr.wpa.seq, KeyRSC, u32KeyRSClen);
3407 msg.id = HOST_IF_MSG_KEY;
3408 msg.body.key_info.type = WPARxGtk;
3411 if (mode == AP_MODE) {
3412 msg.body.key_info.action = ADDKEY_AP;
3413 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
3415 if (mode == STATION_MODE)
3416 msg.body.key_info.action = ADDKEY;
3418 msg.body.key_info.attr.wpa.key = kmalloc(u8KeyLen, GFP_KERNEL);
3419 memcpy(msg.body.key_info.attr.wpa.key, pu8RxGtk, u8GtkKeylen);
3421 if (pu8RxMic != NULL) {
3422 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic, RX_MIC_KEY_LEN);
3424 if (pu8TxMic != NULL) {
3425 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic, TX_MIC_KEY_LEN);
3428 msg.body.key_info.attr.wpa.index = u8KeyIdx;
3429 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
3430 msg.body.key_info.attr.wpa.seq_len = u32KeyRSClen;
3432 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3434 PRINT_ER("Error in sending message queue: RX GTK\n");
3436 down(&hif_drv->hSemTestKeyBlock);
3441 s32 host_int_set_pmkid_info(struct host_if_drv *hif_drv, struct host_if_pmkid_attr *pu8PmkidInfoArray)
3444 struct host_if_msg msg;
3450 PRINT_ER("driver is null\n");
3454 memset(&msg, 0, sizeof(struct host_if_msg));
3456 msg.id = HOST_IF_MSG_KEY;
3457 msg.body.key_info.type = PMKSA;
3458 msg.body.key_info.action = ADDKEY;
3461 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
3462 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
3464 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
3468 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3470 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
3475 s32 host_int_get_pmkid_info(struct host_if_drv *hif_drv,
3476 u8 *pu8PmkidInfoArray,
3477 u32 u32PmkidInfoLen)
3481 strWID.id = (u16)WID_PMKID_INFO;
3482 strWID.type = WID_STR;
3483 strWID.size = u32PmkidInfoLen;
3484 strWID.val = pu8PmkidInfoArray;
3489 s32 host_int_set_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3495 if ((u8Psklength > 7) && (u8Psklength < 65)) {
3496 strWID.id = (u16)WID_11I_PSK;
3497 strWID.type = WID_STR;
3498 strWID.val = pu8PassPhrase;
3499 strWID.size = u8Psklength;
3505 s32 host_int_get_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
3508 struct host_if_msg msg;
3510 memset(&msg, 0, sizeof(struct host_if_msg));
3512 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
3513 msg.body.get_mac_info.u8MacAddress = pu8MacAddress;
3516 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3518 PRINT_ER("Failed to send get mac address\n");
3522 down(&hWaitResponse);
3526 s32 host_int_set_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
3529 struct host_if_msg msg;
3531 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
3533 memset(&msg, 0, sizeof(struct host_if_msg));
3534 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
3535 memcpy(msg.body.set_mac_info.u8MacAddress, pu8MacAddress, ETH_ALEN);
3538 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3540 PRINT_ER("Failed to send message queue: Set mac address\n");
3546 s32 host_int_get_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3547 u8 *pu8PassPhrase, u8 u8Psklength)
3551 strWID.id = (u16)WID_11I_PSK;
3552 strWID.type = WID_STR;
3553 strWID.size = u8Psklength;
3554 strWID.val = pu8PassPhrase;
3559 s32 host_int_set_start_scan_req(struct host_if_drv *hif_drv, u8 scanSource)
3563 strWID.id = (u16)WID_START_SCAN_REQ;
3564 strWID.type = WID_CHAR;
3565 strWID.val = (s8 *)&scanSource;
3566 strWID.size = sizeof(char);
3571 s32 host_int_get_start_scan_req(struct host_if_drv *hif_drv, u8 *pu8ScanSource)
3575 strWID.id = (u16)WID_START_SCAN_REQ;
3576 strWID.type = WID_CHAR;
3577 strWID.val = (s8 *)pu8ScanSource;
3578 strWID.size = sizeof(char);
3583 s32 host_int_set_join_req(struct host_if_drv *hif_drv, u8 *pu8bssid,
3584 const u8 *pu8ssid, size_t ssidLen,
3585 const u8 *pu8IEs, size_t IEsLen,
3586 wilc_connect_result pfConnectResult, void *pvUserArg,
3587 u8 u8security, enum AUTHTYPE tenuAuth_type,
3588 u8 u8channel, void *pJoinParams)
3591 struct host_if_msg msg;
3592 enum scan_conn_timer enuScanConnTimer;
3594 if (!hif_drv || pfConnectResult == NULL) {
3596 PRINT_ER("Driver is null\n");
3601 PRINT_ER("Driver is null\n");
3605 if (pJoinParams == NULL) {
3606 PRINT_ER("Unable to Join - JoinParams is NULL\n");
3610 memset(&msg, 0, sizeof(struct host_if_msg));
3612 msg.id = HOST_IF_MSG_CONNECT;
3614 msg.body.con_info.u8security = u8security;
3615 msg.body.con_info.tenuAuth_type = tenuAuth_type;
3616 msg.body.con_info.u8channel = u8channel;
3617 msg.body.con_info.pfConnectResult = pfConnectResult;
3618 msg.body.con_info.pvUserArg = pvUserArg;
3619 msg.body.con_info.pJoinParams = pJoinParams;
3622 if (pu8bssid != NULL) {
3623 msg.body.con_info.bssid = kmalloc(6, GFP_KERNEL);
3624 memcpy(msg.body.con_info.bssid, pu8bssid, 6);
3627 if (pu8ssid != NULL) {
3628 msg.body.con_info.ssid_len = ssidLen;
3629 msg.body.con_info.ssid = kmalloc(ssidLen, GFP_KERNEL);
3630 memcpy(msg.body.con_info.ssid, pu8ssid, ssidLen);
3633 if (pu8IEs != NULL) {
3634 msg.body.con_info.IEsLen = IEsLen;
3635 msg.body.con_info.ies = kmalloc(IEsLen, GFP_KERNEL);
3636 memcpy(msg.body.con_info.ies, pu8IEs, IEsLen);
3638 if (hif_drv->enuHostIFstate < HOST_IF_CONNECTING)
3639 hif_drv->enuHostIFstate = HOST_IF_CONNECTING;
3641 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", hif_drv->enuHostIFstate);
3643 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3645 PRINT_ER("Failed to send message queue: Set join request\n");
3649 enuScanConnTimer = CONNECT_TIMER;
3650 hif_drv->hConnectTimer.data = (unsigned long)hif_drv;
3651 mod_timer(&hif_drv->hConnectTimer,
3652 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
3657 s32 host_int_flush_join_req(struct host_if_drv *hif_drv)
3660 struct host_if_msg msg;
3662 if (!gu8FlushedJoinReq) {
3670 PRINT_ER("Driver is null\n");
3674 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
3677 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3679 PRINT_ER("Failed to send message queue: Flush join request\n");
3686 s32 host_int_disconnect(struct host_if_drv *hif_drv, u16 u16ReasonCode)
3689 struct host_if_msg msg;
3692 PRINT_ER("Driver is null\n");
3696 memset(&msg, 0, sizeof(struct host_if_msg));
3698 msg.id = HOST_IF_MSG_DISCONNECT;
3701 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3703 PRINT_ER("Failed to send message queue: disconnect\n");
3705 down(&hif_drv->hSemTestDisconnectBlock);
3710 s32 host_int_disconnect_station(struct host_if_drv *hif_drv, u8 assoc_id)
3714 strWID.id = (u16)WID_DISCONNECT;
3715 strWID.type = WID_CHAR;
3716 strWID.val = (s8 *)&assoc_id;
3717 strWID.size = sizeof(char);
3722 s32 host_int_get_assoc_req_info(struct host_if_drv *hif_drv, u8 *pu8AssocReqInfo,
3723 u32 u32AssocReqInfoLen)
3727 strWID.id = (u16)WID_ASSOC_REQ_INFO;
3728 strWID.type = WID_STR;
3729 strWID.val = pu8AssocReqInfo;
3730 strWID.size = u32AssocReqInfoLen;
3735 s32 host_int_get_assoc_res_info(struct host_if_drv *hif_drv, u8 *pu8AssocRespInfo,
3736 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
3742 PRINT_ER("Driver is null\n");
3746 strWID.id = (u16)WID_ASSOC_RES_INFO;
3747 strWID.type = WID_STR;
3748 strWID.val = pu8AssocRespInfo;
3749 strWID.size = u32MaxAssocRespInfoLen;
3751 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
3752 get_id_from_handler(hif_drv));
3754 *pu32RcvdAssocRespInfoLen = 0;
3755 PRINT_ER("Failed to send association response config packet\n");
3758 *pu32RcvdAssocRespInfoLen = strWID.size;
3764 s32 host_int_get_rx_power_level(struct host_if_drv *hif_drv, u8 *pu8RxPowerLevel,
3765 u32 u32RxPowerLevelLen)
3769 strWID.id = (u16)WID_RX_POWER_LEVEL;
3770 strWID.type = WID_STR;
3771 strWID.val = pu8RxPowerLevel;
3772 strWID.size = u32RxPowerLevelLen;
3777 int host_int_set_mac_chnl_num(struct host_if_drv *hif_drv, u8 channel)
3780 struct host_if_msg msg;
3783 PRINT_ER("driver is null\n");
3787 memset(&msg, 0, sizeof(struct host_if_msg));
3788 msg.id = HOST_IF_MSG_SET_CHANNEL;
3789 msg.body.channel_info.u8SetChan = channel;
3792 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3794 PRINT_ER("wilc mq send fail\n");
3801 int host_int_wait_msg_queue_idle(void)
3805 struct host_if_msg msg;
3806 memset(&msg, 0, sizeof(struct host_if_msg));
3807 msg.id = HOST_IF_MSG_Q_IDLE;
3808 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3810 PRINT_ER("wilc mq send fail\n");
3814 down(&hWaitResponse);
3819 int host_int_set_wfi_drv_handler(struct host_if_drv *hif_drv)
3823 struct host_if_msg msg;
3824 memset(&msg, 0, sizeof(struct host_if_msg));
3825 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
3826 msg.body.drv.u32Address = get_id_from_handler(hif_drv);
3829 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3831 PRINT_ER("wilc mq send fail\n");
3838 int host_int_set_operation_mode(struct host_if_drv *hif_drv, u32 mode)
3842 struct host_if_msg msg;
3843 memset(&msg, 0, sizeof(struct host_if_msg));
3844 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
3845 msg.body.mode.u32Mode = mode;
3848 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3850 PRINT_ER("wilc mq send fail\n");
3857 s32 host_int_get_host_chnl_num(struct host_if_drv *hif_drv, u8 *pu8ChNo)
3860 struct host_if_msg msg;
3863 PRINT_ER("driver is null\n");
3867 memset(&msg, 0, sizeof(struct host_if_msg));
3869 msg.id = HOST_IF_MSG_GET_CHNL;
3872 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3874 PRINT_ER("wilc mq send fail\n");
3875 down(&hif_drv->hSemGetCHNL);
3884 s32 host_int_get_inactive_time(struct host_if_drv *hif_drv,
3885 const u8 *mac, u32 *pu32InactiveTime)
3888 struct host_if_msg msg;
3891 PRINT_ER("driver is null\n");
3895 memset(&msg, 0, sizeof(struct host_if_msg));
3898 memcpy(msg.body.mac_info.mac,
3901 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
3904 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3906 PRINT_ER("Failed to send get host channel param's message queue ");
3908 down(&hif_drv->hSemInactiveTime);
3910 *pu32InactiveTime = gu32InactiveTime;
3915 s32 host_int_test_get_int_wid(struct host_if_drv *hif_drv, u32 *pu32TestMemAddr)
3922 PRINT_ER("driver is null\n");
3926 strWID.id = (u16)WID_MEMORY_ADDRESS;
3927 strWID.type = WID_INT;
3928 strWID.val = (s8 *)pu32TestMemAddr;
3929 strWID.size = sizeof(u32);
3931 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
3932 get_id_from_handler(hif_drv));
3935 PRINT_ER("Failed to get wid value\n");
3938 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
3945 s32 host_int_get_rssi(struct host_if_drv *hif_drv, s8 *ps8Rssi)
3948 struct host_if_msg msg;
3949 memset(&msg, 0, sizeof(struct host_if_msg));
3951 msg.id = HOST_IF_MSG_GET_RSSI;
3954 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3956 PRINT_ER("Failed to send get host channel param's message queue ");
3960 down(&hif_drv->hSemGetRSSI);
3963 if (ps8Rssi == NULL) {
3964 PRINT_ER("RSS pointer value is null");
3975 s32 host_int_get_link_speed(struct host_if_drv *hif_drv, s8 *ps8lnkspd)
3977 struct host_if_msg msg;
3979 memset(&msg, 0, sizeof(struct host_if_msg));
3981 msg.id = HOST_IF_MSG_GET_LINKSPEED;
3984 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3986 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
3990 down(&hif_drv->hSemGetLINKSPEED);
3993 if (ps8lnkspd == NULL) {
3994 PRINT_ER("LINKSPEED pointer value is null");
3999 *ps8lnkspd = gs8lnkspd;
4005 s32 host_int_get_statistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
4008 struct host_if_msg msg;
4009 memset(&msg, 0, sizeof(struct host_if_msg));
4011 msg.id = HOST_IF_MSG_GET_STATISTICS;
4012 msg.body.data = (char *)pstrStatistics;
4015 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4017 PRINT_ER("Failed to send get host channel param's message queue ");
4021 down(&hWaitResponse);
4025 s32 host_int_scan(struct host_if_drv *hif_drv, u8 u8ScanSource,
4026 u8 u8ScanType, u8 *pu8ChnlFreqList,
4027 u8 u8ChnlListLen, const u8 *pu8IEs,
4028 size_t IEsLen, wilc_scan_result ScanResult,
4029 void *pvUserArg, struct hidden_network *pstrHiddenNetwork)
4032 struct host_if_msg msg;
4033 enum scan_conn_timer enuScanConnTimer;
4035 if (!hif_drv || ScanResult == NULL) {
4036 PRINT_ER("hif_drv or ScanResult = NULL\n");
4040 memset(&msg, 0, sizeof(struct host_if_msg));
4042 msg.id = HOST_IF_MSG_SCAN;
4044 if (pstrHiddenNetwork != NULL) {
4045 msg.body.scan_info.hidden_network.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
4046 msg.body.scan_info.hidden_network.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
4049 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
4052 msg.body.scan_info.src = u8ScanSource;
4053 msg.body.scan_info.type = u8ScanType;
4054 msg.body.scan_info.result = ScanResult;
4055 msg.body.scan_info.arg = pvUserArg;
4057 msg.body.scan_info.ch_list_len = u8ChnlListLen;
4058 msg.body.scan_info.ch_freq_list = kmalloc(u8ChnlListLen, GFP_KERNEL);
4059 memcpy(msg.body.scan_info.ch_freq_list, pu8ChnlFreqList, u8ChnlListLen);
4061 msg.body.scan_info.ies_len = IEsLen;
4062 msg.body.scan_info.ies = kmalloc(IEsLen, GFP_KERNEL);
4063 memcpy(msg.body.scan_info.ies, pu8IEs, IEsLen);
4065 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4067 PRINT_ER("Error in sending message queue\n");
4071 enuScanConnTimer = SCAN_TIMER;
4072 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
4073 hif_drv->hScanTimer.data = (unsigned long)hif_drv;
4074 mod_timer(&hif_drv->hScanTimer,
4075 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
4081 s32 hif_set_cfg(struct host_if_drv *hif_drv,
4082 struct cfg_param_val *pstrCfgParamVal)
4086 struct host_if_msg msg;
4090 PRINT_ER("hif_drv NULL\n");
4094 memset(&msg, 0, sizeof(struct host_if_msg));
4095 msg.id = HOST_IF_MSG_CFG_PARAMS;
4096 msg.body.cfg_info.cfg_attr_info = *pstrCfgParamVal;
4099 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4105 s32 hif_get_cfg(struct host_if_drv *hif_drv, u16 u16WID, u16 *pu16WID_Value)
4109 down(&hif_drv->gtOsCfgValuesSem);
4112 PRINT_ER("hif_drv NULL\n");
4115 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
4119 *pu16WID_Value = (u16)hif_drv->strCfgValues.bss_type;
4123 *pu16WID_Value = (u16)hif_drv->strCfgValues.auth_type;
4126 case WID_AUTH_TIMEOUT:
4127 *pu16WID_Value = hif_drv->strCfgValues.auth_timeout;
4130 case WID_POWER_MANAGEMENT:
4131 *pu16WID_Value = (u16)hif_drv->strCfgValues.power_mgmt_mode;
4134 case WID_SHORT_RETRY_LIMIT:
4135 *pu16WID_Value = hif_drv->strCfgValues.short_retry_limit;
4138 case WID_LONG_RETRY_LIMIT:
4139 *pu16WID_Value = hif_drv->strCfgValues.long_retry_limit;
4142 case WID_FRAG_THRESHOLD:
4143 *pu16WID_Value = hif_drv->strCfgValues.frag_threshold;
4146 case WID_RTS_THRESHOLD:
4147 *pu16WID_Value = hif_drv->strCfgValues.rts_threshold;
4151 *pu16WID_Value = (u16)hif_drv->strCfgValues.preamble_type;
4154 case WID_SHORT_SLOT_ALLOWED:
4155 *pu16WID_Value = (u16) hif_drv->strCfgValues.short_slot_allowed;
4158 case WID_11N_TXOP_PROT_DISABLE:
4159 *pu16WID_Value = (u16)hif_drv->strCfgValues.txop_prot_disabled;
4162 case WID_BEACON_INTERVAL:
4163 *pu16WID_Value = hif_drv->strCfgValues.beacon_interval;
4166 case WID_DTIM_PERIOD:
4167 *pu16WID_Value = (u16)hif_drv->strCfgValues.dtim_period;
4170 case WID_SITE_SURVEY:
4171 *pu16WID_Value = (u16)hif_drv->strCfgValues.site_survey_enabled;
4174 case WID_SITE_SURVEY_SCAN_TIME:
4175 *pu16WID_Value = hif_drv->strCfgValues.site_survey_scan_time;
4178 case WID_ACTIVE_SCAN_TIME:
4179 *pu16WID_Value = hif_drv->strCfgValues.active_scan_time;
4182 case WID_PASSIVE_SCAN_TIME:
4183 *pu16WID_Value = hif_drv->strCfgValues.passive_scan_time;
4186 case WID_CURRENT_TX_RATE:
4187 *pu16WID_Value = hif_drv->strCfgValues.curr_tx_rate;
4194 up(&hif_drv->gtOsCfgValuesSem);
4200 void host_int_send_join_leave_info_to_host
4201 (u16 assocId, u8 *stationAddr, bool joining)
4205 static void GetPeriodicRSSI(unsigned long arg)
4207 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
4210 PRINT_ER("Driver handler is NULL\n");
4214 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED) {
4216 struct host_if_msg msg;
4218 memset(&msg, 0, sizeof(struct host_if_msg));
4220 msg.id = HOST_IF_MSG_GET_RSSI;
4223 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4225 PRINT_ER("Failed to send get host channel param's message queue ");
4229 g_hPeriodicRSSI.data = (unsigned long)hif_drv;
4230 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
4234 void host_int_send_network_info_to_host
4235 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
4239 static u32 clients_count;
4241 s32 host_int_init(struct host_if_drv **hif_drv_handler)
4244 struct host_if_drv *hif_drv;
4247 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
4249 gbScanWhileConnected = false;
4251 sema_init(&hWaitResponse, 0);
4253 hif_drv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
4258 *hif_drv_handler = hif_drv;
4259 err = add_handler_in_list(hif_drv);
4265 g_obtainingIP = false;
4267 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", hif_drv);
4268 if (clients_count == 0) {
4269 sema_init(&hSemHostIFthrdEnd, 0);
4270 sema_init(&hSemDeinitDrvHandle, 0);
4271 sema_init(&hSemHostIntDeinit, 1);
4274 sema_init(&hif_drv->hSemTestKeyBlock, 0);
4275 sema_init(&hif_drv->hSemTestDisconnectBlock, 0);
4276 sema_init(&hif_drv->hSemGetRSSI, 0);
4277 sema_init(&hif_drv->hSemGetLINKSPEED, 0);
4278 sema_init(&hif_drv->hSemGetCHNL, 0);
4279 sema_init(&hif_drv->hSemInactiveTime, 0);
4281 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
4283 if (clients_count == 0) {
4284 result = wilc_mq_create(&gMsgQHostIF);
4287 PRINT_ER("Failed to creat MQ\n");
4290 HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread");
4291 if (IS_ERR(HostIFthreadHandler)) {
4292 PRINT_ER("Failed to creat Thread\n");
4296 setup_timer(&g_hPeriodicRSSI, GetPeriodicRSSI,
4297 (unsigned long)hif_drv);
4298 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
4301 setup_timer(&hif_drv->hScanTimer, TimerCB_Scan, 0);
4303 setup_timer(&hif_drv->hConnectTimer, TimerCB_Connect, 0);
4305 setup_timer(&hif_drv->hRemainOnChannel, ListenTimerCB, 0);
4307 sema_init(&(hif_drv->gtOsCfgValuesSem), 1);
4308 down(&hif_drv->gtOsCfgValuesSem);
4310 hif_drv->enuHostIFstate = HOST_IF_IDLE;
4311 hif_drv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
4312 hif_drv->strCfgValues.scan_source = DEFAULT_SCAN;
4313 hif_drv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
4314 hif_drv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
4315 hif_drv->strCfgValues.curr_tx_rate = AUTORATE;
4317 hif_drv->u64P2p_MgmtTimeout = 0;
4319 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",
4321 hif_drv->strCfgValues.site_survey_enabled, hif_drv->strCfgValues.scan_source,
4322 hif_drv->strCfgValues.active_scan_time, hif_drv->strCfgValues.passive_scan_time,
4323 hif_drv->strCfgValues.curr_tx_rate);
4325 up(&hif_drv->gtOsCfgValuesSem);
4332 up(&hif_drv->gtOsCfgValuesSem);
4333 del_timer_sync(&hif_drv->hConnectTimer);
4334 del_timer_sync(&hif_drv->hScanTimer);
4335 kthread_stop(HostIFthreadHandler);
4337 wilc_mq_destroy(&gMsgQHostIF);
4342 s32 host_int_deinit(struct host_if_drv *hif_drv)
4345 struct host_if_msg msg;
4349 PRINT_ER("hif_drv = NULL\n");
4353 down(&hSemHostIntDeinit);
4355 terminated_handle = hif_drv;
4356 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
4358 if (del_timer_sync(&hif_drv->hScanTimer)) {
4359 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
4362 if (del_timer_sync(&hif_drv->hConnectTimer)) {
4363 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4367 if (del_timer_sync(&g_hPeriodicRSSI)) {
4368 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4371 del_timer_sync(&hif_drv->hRemainOnChannel);
4373 host_int_set_wfi_drv_handler(NULL);
4374 down(&hSemDeinitDrvHandle);
4376 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
4377 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
4378 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
4380 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
4383 hif_drv->enuHostIFstate = HOST_IF_IDLE;
4385 gbScanWhileConnected = false;
4387 memset(&msg, 0, sizeof(struct host_if_msg));
4389 if (clients_count == 1) {
4390 if (del_timer_sync(&g_hPeriodicRSSI)) {
4391 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4393 msg.id = HOST_IF_MSG_EXIT;
4397 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4399 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
4401 down(&hSemHostIFthrdEnd);
4403 wilc_mq_destroy(&gMsgQHostIF);
4406 down(&(hif_drv->gtOsCfgValuesSem));
4408 ret = remove_handler_in_list(hif_drv);
4415 terminated_handle = NULL;
4416 up(&hSemHostIntDeinit);
4420 void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
4423 struct host_if_msg msg;
4425 struct host_if_drv *hif_drv = NULL;
4427 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4428 hif_drv = get_handler_from_id(id);
4433 if (!hif_drv || hif_drv == terminated_handle) {
4434 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv);
4438 memset(&msg, 0, sizeof(struct host_if_msg));
4440 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
4443 msg.body.net_info.u32Length = u32Length;
4444 msg.body.net_info.pu8Buffer = kmalloc(u32Length, GFP_KERNEL);
4445 memcpy(msg.body.net_info.pu8Buffer,
4446 pu8Buffer, u32Length);
4448 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4450 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
4453 void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
4456 struct host_if_msg msg;
4458 struct host_if_drv *hif_drv = NULL;
4460 down(&hSemHostIntDeinit);
4462 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4463 hif_drv = get_handler_from_id(id);
4464 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
4467 if (!hif_drv || hif_drv == terminated_handle) {
4468 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
4469 up(&hSemHostIntDeinit);
4473 if (!hif_drv->strWILC_UsrConnReq.pfUserConnectResult) {
4474 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
4475 up(&hSemHostIntDeinit);
4479 memset(&msg, 0, sizeof(struct host_if_msg));
4482 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
4486 msg.body.async_info.u32Length = u32Length;
4487 msg.body.async_info.pu8Buffer = kmalloc(u32Length, GFP_KERNEL);
4488 memcpy(msg.body.async_info.pu8Buffer,
4489 pu8Buffer, u32Length);
4491 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4493 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
4495 up(&hSemHostIntDeinit);
4498 void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
4501 struct host_if_msg msg;
4503 struct host_if_drv *hif_drv = NULL;
4505 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4506 hif_drv = get_handler_from_id(id);
4509 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", hif_drv);
4511 if (!hif_drv || hif_drv == terminated_handle)
4514 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
4515 memset(&msg, 0, sizeof(struct host_if_msg));
4517 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
4520 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4522 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
4530 s32 host_int_remain_on_channel(struct host_if_drv *hif_drv, u32 u32SessionID,
4531 u32 u32duration, u16 chan,
4532 wilc_remain_on_chan_expired RemainOnChanExpired,
4533 wilc_remain_on_chan_ready RemainOnChanReady,
4537 struct host_if_msg msg;
4540 PRINT_ER("driver is null\n");
4544 memset(&msg, 0, sizeof(struct host_if_msg));
4546 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
4547 msg.body.remain_on_ch.u16Channel = chan;
4548 msg.body.remain_on_ch.pRemainOnChanExpired = RemainOnChanExpired;
4549 msg.body.remain_on_ch.pRemainOnChanReady = RemainOnChanReady;
4550 msg.body.remain_on_ch.pVoid = pvUserArg;
4551 msg.body.remain_on_ch.u32duration = u32duration;
4552 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
4555 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4557 PRINT_ER("wilc mq send fail\n");
4562 s32 host_int_ListenStateExpired(struct host_if_drv *hif_drv, u32 u32SessionID)
4565 struct host_if_msg msg;
4568 PRINT_ER("driver is null\n");
4572 del_timer(&hif_drv->hRemainOnChannel);
4574 memset(&msg, 0, sizeof(struct host_if_msg));
4575 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
4577 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
4579 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4581 PRINT_ER("wilc mq send fail\n");
4586 s32 host_int_frame_register(struct host_if_drv *hif_drv, u16 u16FrameType, bool bReg)
4589 struct host_if_msg msg;
4592 PRINT_ER("driver is null\n");
4596 memset(&msg, 0, sizeof(struct host_if_msg));
4598 msg.id = HOST_IF_MSG_REGISTER_FRAME;
4599 switch (u16FrameType) {
4601 PRINT_D(HOSTINF_DBG, "ACTION\n");
4602 msg.body.reg_frame.u8Regid = ACTION_FRM_IDX;
4606 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
4607 msg.body.reg_frame.u8Regid = PROBE_REQ_IDX;
4611 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
4614 msg.body.reg_frame.u16FrameType = u16FrameType;
4615 msg.body.reg_frame.bReg = bReg;
4618 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4620 PRINT_ER("wilc mq send fail\n");
4627 s32 host_int_add_beacon(struct host_if_drv *hif_drv, u32 u32Interval,
4628 u32 u32DTIMPeriod, u32 u32HeadLen, u8 *pu8Head,
4629 u32 u32TailLen, u8 *pu8Tail)
4632 struct host_if_msg msg;
4633 struct beacon_attr *pstrSetBeaconParam = &msg.body.beacon_info;
4636 PRINT_ER("driver is null\n");
4640 memset(&msg, 0, sizeof(struct host_if_msg));
4642 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
4644 msg.id = HOST_IF_MSG_ADD_BEACON;
4646 pstrSetBeaconParam->u32Interval = u32Interval;
4647 pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
4648 pstrSetBeaconParam->u32HeadLen = u32HeadLen;
4649 pstrSetBeaconParam->pu8Head = kmalloc(u32HeadLen, GFP_KERNEL);
4650 if (pstrSetBeaconParam->pu8Head == NULL) {
4654 memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
4655 pstrSetBeaconParam->u32TailLen = u32TailLen;
4657 if (u32TailLen > 0) {
4658 pstrSetBeaconParam->pu8Tail = kmalloc(u32TailLen, GFP_KERNEL);
4659 if (pstrSetBeaconParam->pu8Tail == NULL) {
4663 memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen);
4665 pstrSetBeaconParam->pu8Tail = NULL;
4668 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4670 PRINT_ER("wilc mq send fail\n");
4674 if (pstrSetBeaconParam->pu8Head != NULL)
4675 kfree(pstrSetBeaconParam->pu8Head);
4677 if (pstrSetBeaconParam->pu8Tail != NULL)
4678 kfree(pstrSetBeaconParam->pu8Tail);
4685 s32 host_int_del_beacon(struct host_if_drv *hif_drv)
4688 struct host_if_msg msg;
4691 PRINT_ER("driver is null\n");
4695 msg.id = HOST_IF_MSG_DEL_BEACON;
4697 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
4699 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4701 PRINT_ER("wilc_mq_send fail\n");
4706 s32 host_int_add_station(struct host_if_drv *hif_drv,
4707 struct add_sta_param *pstrStaParams)
4710 struct host_if_msg msg;
4711 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
4715 PRINT_ER("driver is null\n");
4719 memset(&msg, 0, sizeof(struct host_if_msg));
4721 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
4723 msg.id = HOST_IF_MSG_ADD_STATION;
4726 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
4727 if (pstrAddStationMsg->u8NumRates > 0) {
4728 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
4733 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
4734 pstrAddStationMsg->pu8Rates = rates;
4738 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4740 PRINT_ER("wilc_mq_send fail\n");
4744 s32 host_int_del_station(struct host_if_drv *hif_drv, const u8 *pu8MacAddr)
4747 struct host_if_msg msg;
4748 struct del_sta *pstrDelStationMsg = &msg.body.del_sta_info;
4751 PRINT_ER("driver is null\n");
4755 memset(&msg, 0, sizeof(struct host_if_msg));
4757 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
4759 msg.id = HOST_IF_MSG_DEL_STATION;
4762 if (pu8MacAddr == NULL)
4763 memset(pstrDelStationMsg->au8MacAddr, 255, ETH_ALEN);
4765 memcpy(pstrDelStationMsg->au8MacAddr, pu8MacAddr, ETH_ALEN);
4767 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4769 PRINT_ER("wilc_mq_send fail\n");
4773 s32 host_int_del_allstation(struct host_if_drv *hif_drv,
4774 u8 pu8MacAddr[][ETH_ALEN])
4777 struct host_if_msg msg;
4778 struct del_all_sta *pstrDelAllStationMsg = &msg.body.del_all_sta_info;
4779 u8 au8Zero_Buff[ETH_ALEN] = {0};
4785 PRINT_ER("driver is null\n");
4789 memset(&msg, 0, sizeof(struct host_if_msg));
4791 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
4793 msg.id = HOST_IF_MSG_DEL_ALL_STA;
4796 for (i = 0; i < MAX_NUM_STA; i++) {
4797 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
4798 memcpy(pstrDelAllStationMsg->au8Sta_DelAllSta[i], pu8MacAddr[i], ETH_ALEN);
4799 PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n", pstrDelAllStationMsg->au8Sta_DelAllSta[i][0], pstrDelAllStationMsg->au8Sta_DelAllSta[i][1], pstrDelAllStationMsg->au8Sta_DelAllSta[i][2], pstrDelAllStationMsg->au8Sta_DelAllSta[i][3], pstrDelAllStationMsg->au8Sta_DelAllSta[i][4],
4800 pstrDelAllStationMsg->au8Sta_DelAllSta[i][5]);
4805 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
4809 pstrDelAllStationMsg->u8Num_AssocSta = u8AssocNumb;
4810 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4814 PRINT_ER("wilc_mq_send fail\n");
4816 down(&hWaitResponse);
4822 s32 host_int_edit_station(struct host_if_drv *hif_drv,
4823 struct add_sta_param *pstrStaParams)
4826 struct host_if_msg msg;
4827 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
4830 PRINT_ER("driver is null\n");
4834 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
4836 memset(&msg, 0, sizeof(struct host_if_msg));
4838 msg.id = HOST_IF_MSG_EDIT_STATION;
4841 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
4842 if (pstrAddStationMsg->u8NumRates > 0) {
4843 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
4848 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
4849 pstrAddStationMsg->pu8Rates = rates;
4852 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4854 PRINT_ER("wilc_mq_send fail\n");
4859 s32 host_int_set_power_mgmt(struct host_if_drv *hif_drv,
4864 struct host_if_msg msg;
4865 struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.pwr_mgmt_info;
4867 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
4870 PRINT_ER("driver is null\n");
4874 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
4876 memset(&msg, 0, sizeof(struct host_if_msg));
4878 msg.id = HOST_IF_MSG_POWER_MGMT;
4881 pstrPowerMgmtParam->bIsEnabled = bIsEnabled;
4882 pstrPowerMgmtParam->u32Timeout = u32Timeout;
4885 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4887 PRINT_ER("wilc_mq_send fail\n");
4891 s32 host_int_setup_multicast_filter(struct host_if_drv *hif_drv,
4896 struct host_if_msg msg;
4897 struct set_multicast *pstrMulticastFilterParam = &msg.body.multicast_info;
4901 PRINT_ER("driver is null\n");
4905 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
4907 memset(&msg, 0, sizeof(struct host_if_msg));
4909 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
4912 pstrMulticastFilterParam->bIsEnabled = bIsEnabled;
4913 pstrMulticastFilterParam->u32count = u32count;
4915 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4917 PRINT_ER("wilc_mq_send fail\n");
4921 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
4923 struct join_bss_param *pNewJoinBssParam = NULL;
4932 u8 pcipherTotalCount = 0;
4933 u8 authTotalCount = 0;
4936 pu8IEs = ptstrNetworkInfo->pu8IEs;
4937 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
4939 pNewJoinBssParam = kmalloc(sizeof(struct join_bss_param), GFP_KERNEL);
4940 if (pNewJoinBssParam != NULL) {
4941 memset(pNewJoinBssParam, 0, sizeof(struct join_bss_param));
4942 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
4943 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
4944 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
4945 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
4946 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
4947 pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen;
4948 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
4949 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
4951 while (index < u16IEsLen) {
4952 if (pu8IEs[index] == SUPP_RATES_IE) {
4953 suppRatesNo = pu8IEs[index + 1];
4954 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
4957 for (i = 0; i < suppRatesNo; i++) {
4958 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
4960 index += suppRatesNo;
4962 } else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
4963 extSuppRatesNo = pu8IEs[index + 1];
4964 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
4965 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
4967 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
4969 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
4970 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
4972 index += extSuppRatesNo;
4974 } else if (pu8IEs[index] == HT_CAPABILITY_IE) {
4975 pNewJoinBssParam->ht_capable = true;
4976 index += pu8IEs[index + 1] + 2;
4978 } else if ((pu8IEs[index] == WMM_IE) &&
4979 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
4980 (pu8IEs[index + 4] == 0xF2) &&
4981 (pu8IEs[index + 5] == 0x02) &&
4982 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) &&
4983 (pu8IEs[index + 7] == 0x01)) {
4984 pNewJoinBssParam->wmm_cap = true;
4986 if (pu8IEs[index + 8] & BIT(7))
4987 pNewJoinBssParam->uapsd_cap = true;
4988 index += pu8IEs[index + 1] + 2;
4990 } else if ((pu8IEs[index] == P2P_IE) &&
4991 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
4992 (pu8IEs[index + 4] == 0x9a) &&
4993 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) {
4996 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
4997 pNewJoinBssParam->u8NoaEnbaled = 1;
4998 pNewJoinBssParam->u8Index = pu8IEs[index + 9];
5000 if (pu8IEs[index + 10] & BIT(7)) {
5001 pNewJoinBssParam->u8OppEnable = 1;
5002 pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10];
5004 pNewJoinBssParam->u8OppEnable = 0;
5006 PRINT_D(GENERIC_DBG, "P2P Dump\n");
5007 for (i = 0; i < pu8IEs[index + 7]; i++)
5008 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
5010 pNewJoinBssParam->u8Count = pu8IEs[index + 11];
5011 u16P2P_count = index + 12;
5013 memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4);
5016 memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4);
5019 memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
5021 index += pu8IEs[index + 1] + 2;
5024 } else if ((pu8IEs[index] == RSN_IE) ||
5025 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
5026 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
5027 (pu8IEs[index + 5] == 0x01))) {
5028 u16 rsnIndex = index;
5030 if (pu8IEs[rsnIndex] == RSN_IE) {
5031 pNewJoinBssParam->mode_802_11i = 2;
5033 if (pNewJoinBssParam->mode_802_11i == 0)
5034 pNewJoinBssParam->mode_802_11i = 1;
5039 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
5041 jumpOffset = pu8IEs[rsnIndex] * 4;
5042 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
5045 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
5046 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
5048 pcipherTotalCount += pcipherCount;
5049 rsnIndex += jumpOffset;
5051 jumpOffset = pu8IEs[rsnIndex] * 4;
5053 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
5056 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
5057 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
5059 authTotalCount += authCount;
5060 rsnIndex += jumpOffset;
5062 if (pu8IEs[index] == RSN_IE) {
5063 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
5064 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
5067 pNewJoinBssParam->rsn_found = true;
5068 index += pu8IEs[index + 1] + 2;
5071 index += pu8IEs[index + 1] + 2;
5078 return (void *)pNewJoinBssParam;
5082 void host_int_freeJoinParams(void *pJoinParams)
5084 if ((struct bss_param *)pJoinParams != NULL)
5085 kfree((struct bss_param *)pJoinParams);
5087 PRINT_ER("Unable to FREE null pointer\n");
5090 s32 host_int_delBASession(struct host_if_drv *hif_drv, char *pBSSID, char TID)
5093 struct host_if_msg msg;
5094 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
5097 PRINT_ER("driver is null\n");
5101 memset(&msg, 0, sizeof(struct host_if_msg));
5103 msg.id = HOST_IF_MSG_DEL_BA_SESSION;
5105 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
5106 pBASessionInfo->u8Ted = TID;
5109 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5111 PRINT_ER("wilc_mq_send fail\n");
5113 down(&hWaitResponse);
5118 s32 host_int_del_All_Rx_BASession(struct host_if_drv *hif_drv,
5123 struct host_if_msg msg;
5124 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
5127 PRINT_ER("driver is null\n");
5131 memset(&msg, 0, sizeof(struct host_if_msg));
5133 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
5135 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
5136 pBASessionInfo->u8Ted = TID;
5139 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5141 PRINT_ER("wilc_mq_send fail\n");
5143 down(&hWaitResponse);
5148 s32 host_int_setup_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
5151 struct host_if_msg msg;
5156 PRINT_ER("driver is null\n");
5160 memset(&msg, 0, sizeof(struct host_if_msg));
5162 msg.id = HOST_IF_MSG_SET_IPADDRESS;
5164 msg.body.ip_info.au8IPAddr = u16ipadd;
5166 msg.body.ip_info.idx = idx;
5168 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5170 PRINT_ER("wilc_mq_send fail\n");
5177 s32 host_int_get_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
5180 struct host_if_msg msg;
5183 PRINT_ER("driver is null\n");
5187 memset(&msg, 0, sizeof(struct host_if_msg));
5189 msg.id = HOST_IF_MSG_GET_IPADDRESS;
5191 msg.body.ip_info.au8IPAddr = u16ipadd;
5193 msg.body.ip_info.idx = idx;
5195 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5197 PRINT_ER("wilc_mq_send fail\n");