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->pu8bssid, 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->pu8bssid != NULL) {
1035 hif_drv->strWILC_UsrConnReq.pu8bssid = kmalloc(6, GFP_KERNEL);
1036 memcpy(hif_drv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
1039 hif_drv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1040 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1041 hif_drv->strWILC_UsrConnReq.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssidLen + 1, GFP_KERNEL);
1042 memcpy(hif_drv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
1043 pstrHostIFconnectAttr->ssidLen);
1044 hif_drv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1047 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1048 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1049 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
1050 memcpy(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
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->pu8ssid, 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->pu8ssid, 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->pu8ssid, 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->pu8ssid, 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->pu8ssid != NULL) {
1135 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
1136 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\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->pu8bssid != NULL)
1152 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
1155 if (pstrHostIFconnectAttr->pu8bssid != NULL)
1156 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
1159 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1160 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1161 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1162 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1163 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1165 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
1166 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1168 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1169 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1170 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1172 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1173 hif_drv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
1175 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1176 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1177 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1178 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1179 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1180 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1182 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
1183 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1185 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
1186 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1188 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
1189 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1191 *(pu8CurrByte++) = REAL_JOIN_REQ;
1193 *(pu8CurrByte++) = ptstrJoinBssParam->u8NoaEnbaled;
1194 if (ptstrJoinBssParam->u8NoaEnbaled) {
1195 PRINT_D(HOSTINF_DBG, "NOA present\n");
1197 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1198 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1199 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1200 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1202 *(pu8CurrByte++) = ptstrJoinBssParam->u8Index;
1204 *(pu8CurrByte++) = ptstrJoinBssParam->u8OppEnable;
1206 if (ptstrJoinBssParam->u8OppEnable)
1207 *(pu8CurrByte++) = ptstrJoinBssParam->u8CtWindow;
1209 *(pu8CurrByte++) = ptstrJoinBssParam->u8Count;
1211 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Duration, sizeof(ptstrJoinBssParam->au8Duration));
1213 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Duration);
1215 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Interval, sizeof(ptstrJoinBssParam->au8Interval));
1217 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Interval);
1219 memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
1221 pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1224 PRINT_D(HOSTINF_DBG, "NOA not present\n");
1226 pu8CurrByte = strWIDList[u32WidsCount].val;
1228 gu32WidConnRstHack = 0;
1230 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1231 memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
1232 gu8FlushedJoinReqDrvHandler = hif_drv;
1235 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1237 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1238 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->pu8bssid, ETH_ALEN);
1240 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n", pstrHostIFconnectAttr->pu8bssid);
1241 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", u8ConnectedSSID);
1244 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
1245 get_id_from_handler(hif_drv));
1247 PRINT_ER("failed to send config packet\n");
1251 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
1252 hif_drv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1257 tstrConnectInfo strConnectInfo;
1259 del_timer(&hif_drv->hConnectTimer);
1261 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
1263 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1265 if (pstrHostIFconnectAttr->pfConnectResult != NULL) {
1266 if (pstrHostIFconnectAttr->pu8bssid != NULL)
1267 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
1269 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1270 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1271 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
1272 memcpy(strConnectInfo.pu8ReqIEs,
1273 pstrHostIFconnectAttr->pu8IEs,
1274 pstrHostIFconnectAttr->IEsLen);
1277 pstrHostIFconnectAttr->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1281 pstrHostIFconnectAttr->pvUserArg);
1282 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1283 if (strConnectInfo.pu8ReqIEs != NULL) {
1284 kfree(strConnectInfo.pu8ReqIEs);
1285 strConnectInfo.pu8ReqIEs = NULL;
1289 PRINT_ER("Connect callback function pointer is NULL\n");
1293 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
1294 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1295 kfree(pstrHostIFconnectAttr->pu8bssid);
1296 pstrHostIFconnectAttr->pu8bssid = NULL;
1299 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1300 kfree(pstrHostIFconnectAttr->pu8ssid);
1301 pstrHostIFconnectAttr->pu8ssid = NULL;
1304 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1305 kfree(pstrHostIFconnectAttr->pu8IEs);
1306 pstrHostIFconnectAttr->pu8IEs = NULL;
1309 if (pu8CurrByte != NULL)
1314 static s32 Handle_FlushConnect(struct host_if_drv *hif_drv)
1317 struct wid strWIDList[5];
1318 u32 u32WidsCount = 0;
1319 u8 *pu8CurrByte = NULL;
1321 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
1322 strWIDList[u32WidsCount].type = WID_BIN_DATA;
1323 strWIDList[u32WidsCount].val = gu8FlushedInfoElemAsoc;
1324 strWIDList[u32WidsCount].size = gu32FlushedInfoElemAsocSize;
1327 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
1328 strWIDList[u32WidsCount].type = WID_CHAR;
1329 strWIDList[u32WidsCount].size = sizeof(char);
1330 strWIDList[u32WidsCount].val = (s8 *)(&(gu8Flushed11iMode));
1335 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
1336 strWIDList[u32WidsCount].type = WID_CHAR;
1337 strWIDList[u32WidsCount].size = sizeof(char);
1338 strWIDList[u32WidsCount].val = (s8 *)(&gu8FlushedAuthType);
1341 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
1342 strWIDList[u32WidsCount].type = WID_STR;
1343 strWIDList[u32WidsCount].size = gu32FlushedJoinReqSize;
1344 strWIDList[u32WidsCount].val = (s8 *)gu8FlushedJoinReq;
1345 pu8CurrByte = strWIDList[u32WidsCount].val;
1347 pu8CurrByte += FLUSHED_BYTE_POS;
1348 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1352 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
1353 get_id_from_handler(gu8FlushedJoinReqDrvHandler));
1355 PRINT_ER("failed to send config packet\n");
1362 static s32 Handle_ConnectTimeout(struct host_if_drv *hif_drv)
1365 tstrConnectInfo strConnectInfo;
1367 u16 u16DummyReasonCode = 0;
1370 PRINT_ER("Driver handler is NULL\n");
1374 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1376 gbScanWhileConnected = false;
1379 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1381 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
1382 if (hif_drv->strWILC_UsrConnReq.pu8bssid != NULL) {
1383 memcpy(strConnectInfo.au8bssid,
1384 hif_drv->strWILC_UsrConnReq.pu8bssid, 6);
1387 if (hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1388 strConnectInfo.ReqIEsLen = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1389 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
1390 memcpy(strConnectInfo.pu8ReqIEs,
1391 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
1392 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen);
1395 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1399 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
1401 if (strConnectInfo.pu8ReqIEs != NULL) {
1402 kfree(strConnectInfo.pu8ReqIEs);
1403 strConnectInfo.pu8ReqIEs = NULL;
1406 PRINT_ER("Connect callback function pointer is NULL\n");
1409 strWID.id = (u16)WID_DISCONNECT;
1410 strWID.type = WID_CHAR;
1411 strWID.val = (s8 *)&u16DummyReasonCode;
1412 strWID.size = sizeof(char);
1414 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1416 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1417 get_id_from_handler(hif_drv));
1419 PRINT_ER("Failed to send dissconect config packet\n");
1421 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
1422 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
1423 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
1424 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1425 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
1427 eth_zero_addr(u8ConnectedSSID);
1429 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
1430 kfree(gu8FlushedJoinReq);
1431 gu8FlushedJoinReq = NULL;
1433 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
1434 kfree(gu8FlushedInfoElemAsoc);
1435 gu8FlushedInfoElemAsoc = NULL;
1441 static s32 Handle_RcvdNtwrkInfo(struct host_if_drv *hif_drv,
1442 struct rcvd_net_info *pstrRcvdNetworkInfo)
1445 bool bNewNtwrkFound;
1450 tstrNetworkInfo *pstrNetworkInfo = NULL;
1451 void *pJoinParams = NULL;
1453 bNewNtwrkFound = true;
1454 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
1456 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
1457 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
1458 parse_network_info(pstrRcvdNetworkInfo->pu8Buffer, &pstrNetworkInfo);
1459 if ((pstrNetworkInfo == NULL)
1460 || (hif_drv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
1461 PRINT_ER("driver is null\n");
1466 for (i = 0; i < hif_drv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
1468 if ((hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
1469 (pstrNetworkInfo->au8bssid != NULL)) {
1470 if (memcmp(hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
1471 pstrNetworkInfo->au8bssid, 6) == 0) {
1472 if (pstrNetworkInfo->s8rssi <= hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
1473 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
1476 hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
1477 bNewNtwrkFound = false;
1484 if (bNewNtwrkFound == true) {
1485 PRINT_D(HOSTINF_DBG, "New network found\n");
1487 if (hif_drv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
1488 hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
1490 if ((hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
1491 && (pstrNetworkInfo->au8bssid != NULL)) {
1492 memcpy(hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
1493 pstrNetworkInfo->au8bssid, 6);
1495 hif_drv->strWILC_UsrScanReq.u32RcvdChCount++;
1497 pstrNetworkInfo->bNewNetwork = true;
1498 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
1500 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1501 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid,
1507 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
1510 pstrNetworkInfo->bNewNetwork = false;
1511 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1512 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
1517 if (pstrRcvdNetworkInfo->pu8Buffer != NULL) {
1518 kfree(pstrRcvdNetworkInfo->pu8Buffer);
1519 pstrRcvdNetworkInfo->pu8Buffer = NULL;
1522 if (pstrNetworkInfo != NULL) {
1523 DeallocateNetworkInfo(pstrNetworkInfo);
1524 pstrNetworkInfo = NULL;
1530 static s32 Handle_RcvdGnrlAsyncInfo(struct host_if_drv *hif_drv,
1531 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
1537 u16 u16WidID = (u16)WID_NIL;
1540 u8 u8MacStatusReasonCode;
1541 u8 u8MacStatusAdditionalInfo;
1542 tstrConnectInfo strConnectInfo;
1543 tstrDisconnectNotifInfo strDisconnectNotifInfo;
1547 PRINT_ER("Driver handler is NULL\n");
1550 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", hif_drv->enuHostIFstate,
1551 pstrRcvdGnrlAsyncInfo->pu8Buffer[7]);
1553 if ((hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
1554 (hif_drv->enuHostIFstate == HOST_IF_CONNECTED) ||
1555 hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
1556 if ((pstrRcvdGnrlAsyncInfo->pu8Buffer == NULL) ||
1557 (hif_drv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
1558 PRINT_ER("driver is null\n");
1562 u8MsgType = pstrRcvdGnrlAsyncInfo->pu8Buffer[0];
1564 if ('I' != u8MsgType) {
1565 PRINT_ER("Received Message format incorrect.\n");
1569 u8MsgID = pstrRcvdGnrlAsyncInfo->pu8Buffer[1];
1570 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[2], pstrRcvdGnrlAsyncInfo->pu8Buffer[3]);
1571 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[4], pstrRcvdGnrlAsyncInfo->pu8Buffer[5]);
1572 u8WidLen = pstrRcvdGnrlAsyncInfo->pu8Buffer[6];
1573 u8MacStatus = pstrRcvdGnrlAsyncInfo->pu8Buffer[7];
1574 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->pu8Buffer[8];
1575 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->pu8Buffer[9];
1576 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
1577 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
1578 u32 u32RcvdAssocRespInfoLen;
1579 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
1581 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
1583 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1585 if (u8MacStatus == MAC_CONNECTED) {
1586 memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
1588 host_int_get_assoc_res_info(hif_drv,
1590 MAX_ASSOC_RESP_FRAME_SIZE,
1591 &u32RcvdAssocRespInfoLen);
1593 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
1595 if (u32RcvdAssocRespInfoLen != 0) {
1597 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
1598 s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
1599 &pstrConnectRespInfo);
1601 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
1603 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
1605 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
1606 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
1607 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
1608 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
1611 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL);
1612 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
1613 pstrConnectRespInfo->u16RespIEsLen);
1617 if (pstrConnectRespInfo != NULL) {
1618 DeallocateAssocRespInfo(pstrConnectRespInfo);
1619 pstrConnectRespInfo = NULL;
1625 if ((u8MacStatus == MAC_CONNECTED) &&
1626 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
1627 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
1628 eth_zero_addr(u8ConnectedSSID);
1630 } else if (u8MacStatus == MAC_DISCONNECTED) {
1631 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
1632 eth_zero_addr(u8ConnectedSSID);
1635 if (hif_drv->strWILC_UsrConnReq.pu8bssid != NULL) {
1636 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
1637 memcpy(strConnectInfo.au8bssid, hif_drv->strWILC_UsrConnReq.pu8bssid, 6);
1639 if ((u8MacStatus == MAC_CONNECTED) &&
1640 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
1641 memcpy(hif_drv->au8AssociatedBSSID,
1642 hif_drv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
1647 if (hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1648 strConnectInfo.ReqIEsLen = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1649 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
1650 memcpy(strConnectInfo.pu8ReqIEs,
1651 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
1652 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen);
1656 del_timer(&hif_drv->hConnectTimer);
1657 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1661 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
1663 if ((u8MacStatus == MAC_CONNECTED) &&
1664 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
1665 host_int_set_power_mgmt(hif_drv, 0, 0);
1667 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
1668 hif_drv->enuHostIFstate = HOST_IF_CONNECTED;
1670 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
1671 g_obtainingIP = true;
1672 mod_timer(&hDuringIpTimer,
1673 jiffies + msecs_to_jiffies(10000));
1675 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
1676 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1677 gbScanWhileConnected = false;
1680 if (strConnectInfo.pu8RespIEs != NULL) {
1681 kfree(strConnectInfo.pu8RespIEs);
1682 strConnectInfo.pu8RespIEs = NULL;
1685 if (strConnectInfo.pu8ReqIEs != NULL) {
1686 kfree(strConnectInfo.pu8ReqIEs);
1687 strConnectInfo.pu8ReqIEs = NULL;
1689 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
1690 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
1691 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
1692 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1693 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
1694 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
1695 (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)) {
1696 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
1698 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
1700 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
1701 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
1702 del_timer(&hif_drv->hScanTimer);
1703 Handle_ScanDone((void *)hif_drv, SCAN_EVENT_ABORTED);
1706 strDisconnectNotifInfo.u16reason = 0;
1707 strDisconnectNotifInfo.ie = NULL;
1708 strDisconnectNotifInfo.ie_len = 0;
1710 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
1711 g_obtainingIP = false;
1712 host_int_set_power_mgmt(hif_drv, 0, 0);
1714 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1717 &strDisconnectNotifInfo,
1718 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
1721 PRINT_ER("Connect result callback function is NULL\n");
1724 eth_zero_addr(hif_drv->au8AssociatedBSSID);
1726 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
1727 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
1728 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
1729 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1730 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
1732 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
1733 kfree(gu8FlushedJoinReq);
1734 gu8FlushedJoinReq = NULL;
1736 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
1737 kfree(gu8FlushedInfoElemAsoc);
1738 gu8FlushedInfoElemAsoc = NULL;
1741 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1742 gbScanWhileConnected = false;
1744 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
1745 (hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
1746 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
1747 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
1749 del_timer(&hif_drv->hScanTimer);
1750 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult)
1751 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
1757 if (pstrRcvdGnrlAsyncInfo->pu8Buffer != NULL) {
1758 kfree(pstrRcvdGnrlAsyncInfo->pu8Buffer);
1759 pstrRcvdGnrlAsyncInfo->pu8Buffer = NULL;
1765 static int Handle_Key(struct host_if_drv *hif_drv,
1766 struct key_attr *pstrHostIFkeyAttr)
1770 struct wid strWIDList[5];
1776 switch (pstrHostIFkeyAttr->type) {
1781 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1783 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
1784 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->attr.wep.index));
1785 strWIDList[0].id = (u16)WID_11I_MODE;
1786 strWIDList[0].type = WID_CHAR;
1787 strWIDList[0].size = sizeof(char);
1788 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.mode));
1790 strWIDList[1].id = WID_AUTH_TYPE;
1791 strWIDList[1].type = WID_CHAR;
1792 strWIDList[1].size = sizeof(char);
1793 strWIDList[1].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.auth_type));
1795 strWIDList[2].id = (u16)WID_KEY_ID;
1796 strWIDList[2].type = WID_CHAR;
1798 strWIDList[2].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.index));
1799 strWIDList[2].size = sizeof(char);
1801 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len, GFP_KERNEL);
1803 if (pu8keybuf == NULL) {
1804 PRINT_ER("No buffer to send Key\n");
1808 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wep.key,
1809 pstrHostIFkeyAttr->attr.wep.key_len);
1811 kfree(pstrHostIFkeyAttr->attr.wep.key);
1813 strWIDList[3].id = (u16)WID_WEP_KEY_VALUE;
1814 strWIDList[3].type = WID_STR;
1815 strWIDList[3].size = pstrHostIFkeyAttr->attr.wep.key_len;
1816 strWIDList[3].val = (s8 *)pu8keybuf;
1819 s32Error = send_config_pkt(SET_CFG, strWIDList, 4,
1820 get_id_from_handler(hif_drv));
1826 if (pstrHostIFkeyAttr->action & ADDKEY) {
1827 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
1828 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2, GFP_KERNEL);
1829 if (pu8keybuf == NULL) {
1830 PRINT_ER("No buffer to send Key\n");
1833 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1834 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->attr.wep.key_len, 1);
1835 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->attr.wep.key,
1836 pstrHostIFkeyAttr->attr.wep.key_len);
1837 kfree(pstrHostIFkeyAttr->attr.wep.key);
1839 strWID.id = (u16)WID_ADD_WEP_KEY;
1840 strWID.type = WID_STR;
1841 strWID.val = (s8 *)pu8keybuf;
1842 strWID.size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
1844 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1845 get_id_from_handler(hif_drv));
1847 } else if (pstrHostIFkeyAttr->action & REMOVEKEY) {
1849 PRINT_D(HOSTINF_DBG, "Removing key\n");
1850 strWID.id = (u16)WID_REMOVE_WEP_KEY;
1851 strWID.type = WID_STR;
1853 s8idxarray[0] = (s8)pstrHostIFkeyAttr->attr.wep.index;
1854 strWID.val = s8idxarray;
1857 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1858 get_id_from_handler(hif_drv));
1860 strWID.id = (u16)WID_KEY_ID;
1861 strWID.type = WID_CHAR;
1862 strWID.val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.index));
1863 strWID.size = sizeof(char);
1865 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
1867 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1868 get_id_from_handler(hif_drv));
1870 up(&hif_drv->hSemTestKeyBlock);
1874 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1875 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1876 if (pu8keybuf == NULL) {
1877 PRINT_ER("No buffer to send RxGTK Key\n");
1879 goto _WPARxGtk_end_case_;
1882 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
1884 if (pstrHostIFkeyAttr->attr.wpa.seq != NULL)
1885 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1887 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1888 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1889 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1890 pstrHostIFkeyAttr->attr.wpa.key_len);
1892 strWIDList[0].id = (u16)WID_11I_MODE;
1893 strWIDList[0].type = WID_CHAR;
1894 strWIDList[0].size = sizeof(char);
1895 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wpa.mode));
1897 strWIDList[1].id = (u16)WID_ADD_RX_GTK;
1898 strWIDList[1].type = WID_STR;
1899 strWIDList[1].val = (s8 *)pu8keybuf;
1900 strWIDList[1].size = RX_MIC_KEY_MSG_LEN;
1902 s32Error = send_config_pkt(SET_CFG, strWIDList, 2,
1903 get_id_from_handler(hif_drv));
1906 up(&hif_drv->hSemTestKeyBlock);
1909 if (pstrHostIFkeyAttr->action & ADDKEY) {
1910 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
1912 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1913 if (pu8keybuf == NULL) {
1914 PRINT_ER("No buffer to send RxGTK Key\n");
1916 goto _WPARxGtk_end_case_;
1919 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
1921 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)
1922 memcpy(pu8keybuf, hif_drv->au8AssociatedBSSID, ETH_ALEN);
1924 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
1926 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1927 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1928 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1929 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1930 pstrHostIFkeyAttr->attr.wpa.key_len);
1932 strWID.id = (u16)WID_ADD_RX_GTK;
1933 strWID.type = WID_STR;
1934 strWID.val = (s8 *)pu8keybuf;
1935 strWID.size = RX_MIC_KEY_MSG_LEN;
1937 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1938 get_id_from_handler(hif_drv));
1941 up(&hif_drv->hSemTestKeyBlock);
1943 _WPARxGtk_end_case_:
1944 kfree(pstrHostIFkeyAttr->attr.wpa.key);
1945 kfree(pstrHostIFkeyAttr->attr.wpa.seq);
1952 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1955 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
1959 if (pu8keybuf == NULL) {
1960 PRINT_ER("No buffer to send PTK Key\n");
1962 goto _WPAPtk_end_case_;
1966 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1967 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1968 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1969 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->attr.wpa.key,
1970 pstrHostIFkeyAttr->attr.wpa.key_len);
1972 strWIDList[0].id = (u16)WID_11I_MODE;
1973 strWIDList[0].type = WID_CHAR;
1974 strWIDList[0].size = sizeof(char);
1975 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wpa.mode));
1977 strWIDList[1].id = (u16)WID_ADD_PTK;
1978 strWIDList[1].type = WID_STR;
1979 strWIDList[1].val = (s8 *)pu8keybuf;
1980 strWIDList[1].size = PTK_KEY_MSG_LEN + 1;
1982 s32Error = send_config_pkt(SET_CFG, strWIDList, 2,
1983 get_id_from_handler(hif_drv));
1985 up(&hif_drv->hSemTestKeyBlock);
1987 if (pstrHostIFkeyAttr->action & ADDKEY) {
1990 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
1994 if (pu8keybuf == NULL) {
1995 PRINT_ER("No buffer to send PTK Key\n");
1997 goto _WPAPtk_end_case_;
2001 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
2002 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
2003 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->attr.wpa.key,
2004 pstrHostIFkeyAttr->attr.wpa.key_len);
2006 strWID.id = (u16)WID_ADD_PTK;
2007 strWID.type = WID_STR;
2008 strWID.val = (s8 *)pu8keybuf;
2009 strWID.size = PTK_KEY_MSG_LEN;
2011 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2012 get_id_from_handler(hif_drv));
2014 up(&hif_drv->hSemTestKeyBlock);
2018 kfree(pstrHostIFkeyAttr->attr.wpa.key);
2027 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
2029 pu8keybuf = kmalloc((pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
2030 if (pu8keybuf == NULL) {
2031 PRINT_ER("No buffer to send PMKSA Key\n");
2035 pu8keybuf[0] = pstrHostIFkeyAttr->attr.pmkid.numpmkid;
2037 for (i = 0; i < pstrHostIFkeyAttr->attr.pmkid.numpmkid; i++) {
2038 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
2039 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
2042 strWID.id = (u16)WID_PMKID_INFO;
2043 strWID.type = WID_STR;
2044 strWID.val = (s8 *)pu8keybuf;
2045 strWID.size = (pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
2047 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2048 get_id_from_handler(hif_drv));
2055 PRINT_ER("Failed to send key config packet\n");
2061 static void Handle_Disconnect(struct host_if_drv *hif_drv)
2066 u16 u16DummyReasonCode = 0;
2068 strWID.id = (u16)WID_DISCONNECT;
2069 strWID.type = WID_CHAR;
2070 strWID.val = (s8 *)&u16DummyReasonCode;
2071 strWID.size = sizeof(char);
2075 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2077 g_obtainingIP = false;
2078 host_int_set_power_mgmt(hif_drv, 0, 0);
2080 eth_zero_addr(u8ConnectedSSID);
2082 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2083 get_id_from_handler(hif_drv));
2086 PRINT_ER("Failed to send dissconect config packet\n");
2088 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2090 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
2092 strDisconnectNotifInfo.u16reason = 0;
2093 strDisconnectNotifInfo.ie = NULL;
2094 strDisconnectNotifInfo.ie_len = 0;
2096 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
2097 del_timer(&hif_drv->hScanTimer);
2098 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
2099 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2101 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
2104 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2105 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2106 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
2107 del_timer(&hif_drv->hConnectTimer);
2110 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
2111 0, &strDisconnectNotifInfo, hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
2113 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
2116 gbScanWhileConnected = false;
2118 hif_drv->enuHostIFstate = HOST_IF_IDLE;
2120 eth_zero_addr(hif_drv->au8AssociatedBSSID);
2122 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
2123 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
2124 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
2125 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2126 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
2128 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
2129 kfree(gu8FlushedJoinReq);
2130 gu8FlushedJoinReq = NULL;
2132 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
2133 kfree(gu8FlushedInfoElemAsoc);
2134 gu8FlushedInfoElemAsoc = NULL;
2139 up(&hif_drv->hSemTestDisconnectBlock);
2143 void resolve_disconnect_aberration(struct host_if_drv *hif_drv)
2147 if ((hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (hif_drv->enuHostIFstate == HOST_IF_CONNECTING)) {
2148 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
2149 host_int_disconnect(hif_drv, 1);
2153 static s32 Handle_GetChnl(struct host_if_drv *hif_drv)
2159 strWID.id = (u16)WID_CURRENT_CHANNEL;
2160 strWID.type = WID_CHAR;
2161 strWID.val = (s8 *)&gu8Chnl;
2162 strWID.size = sizeof(char);
2164 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
2166 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2167 get_id_from_handler(hif_drv));
2170 PRINT_ER("Failed to get channel number\n");
2174 up(&hif_drv->hSemGetCHNL);
2182 static void Handle_GetRssi(struct host_if_drv *hif_drv)
2187 strWID.id = (u16)WID_RSSI;
2188 strWID.type = WID_CHAR;
2189 strWID.val = &gs8Rssi;
2190 strWID.size = sizeof(char);
2192 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
2194 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2195 get_id_from_handler(hif_drv));
2197 PRINT_ER("Failed to get RSSI value\n");
2201 up(&hif_drv->hSemGetRSSI);
2207 static void Handle_GetLinkspeed(struct host_if_drv *hif_drv)
2214 strWID.id = (u16)WID_LINKSPEED;
2215 strWID.type = WID_CHAR;
2216 strWID.val = &gs8lnkspd;
2217 strWID.size = sizeof(char);
2219 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
2221 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2222 get_id_from_handler(hif_drv));
2224 PRINT_ER("Failed to get LINKSPEED value\n");
2228 up(&(hif_drv->hSemGetLINKSPEED));
2233 s32 Handle_GetStatistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
2235 struct wid strWIDList[5];
2236 u32 u32WidsCount = 0, s32Error = 0;
2238 strWIDList[u32WidsCount].id = WID_LINKSPEED;
2239 strWIDList[u32WidsCount].type = WID_CHAR;
2240 strWIDList[u32WidsCount].size = sizeof(char);
2241 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u8LinkSpeed));
2244 strWIDList[u32WidsCount].id = WID_RSSI;
2245 strWIDList[u32WidsCount].type = WID_CHAR;
2246 strWIDList[u32WidsCount].size = sizeof(char);
2247 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->s8RSSI));
2250 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
2251 strWIDList[u32WidsCount].type = WID_INT;
2252 strWIDList[u32WidsCount].size = sizeof(u32);
2253 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32TxCount));
2256 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
2257 strWIDList[u32WidsCount].type = WID_INT;
2258 strWIDList[u32WidsCount].size = sizeof(u32);
2259 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32RxCount));
2262 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
2263 strWIDList[u32WidsCount].type = WID_INT;
2264 strWIDList[u32WidsCount].size = sizeof(u32);
2265 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32TxFailureCount));
2268 s32Error = send_config_pkt(GET_CFG, strWIDList, u32WidsCount,
2269 get_id_from_handler(hif_drv));
2272 PRINT_ER("Failed to send scan paramters config packet\n");
2279 static s32 Handle_Get_InActiveTime(struct host_if_drv *hif_drv,
2280 struct sta_inactive_t *strHostIfStaInactiveT)
2287 strWID.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
2288 strWID.type = WID_STR;
2289 strWID.size = ETH_ALEN;
2290 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2293 stamac = strWID.val;
2294 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
2297 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
2300 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2301 get_id_from_handler(hif_drv));
2304 PRINT_ER("Failed to SET incative time\n");
2309 strWID.id = (u16)WID_GET_INACTIVE_TIME;
2310 strWID.type = WID_INT;
2311 strWID.val = (s8 *)&gu32InactiveTime;
2312 strWID.size = sizeof(u32);
2315 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2316 get_id_from_handler(hif_drv));
2319 PRINT_ER("Failed to get incative time\n");
2324 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
2326 up(&hif_drv->hSemInactiveTime);
2334 static void Handle_AddBeacon(struct host_if_drv *hif_drv,
2335 struct beacon_attr *pstrSetBeaconParam)
2341 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
2343 strWID.id = (u16)WID_ADD_BEACON;
2344 strWID.type = WID_BIN;
2345 strWID.size = pstrSetBeaconParam->u32HeadLen + pstrSetBeaconParam->u32TailLen + 16;
2346 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2347 if (strWID.val == NULL)
2350 pu8CurrByte = strWID.val;
2351 *pu8CurrByte++ = (pstrSetBeaconParam->u32Interval & 0xFF);
2352 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 8) & 0xFF);
2353 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 16) & 0xFF);
2354 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 24) & 0xFF);
2356 *pu8CurrByte++ = (pstrSetBeaconParam->u32DTIMPeriod & 0xFF);
2357 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 8) & 0xFF);
2358 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 16) & 0xFF);
2359 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 24) & 0xFF);
2361 *pu8CurrByte++ = (pstrSetBeaconParam->u32HeadLen & 0xFF);
2362 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 8) & 0xFF);
2363 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 16) & 0xFF);
2364 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 24) & 0xFF);
2366 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Head, pstrSetBeaconParam->u32HeadLen);
2367 pu8CurrByte += pstrSetBeaconParam->u32HeadLen;
2369 *pu8CurrByte++ = (pstrSetBeaconParam->u32TailLen & 0xFF);
2370 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 8) & 0xFF);
2371 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 16) & 0xFF);
2372 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 24) & 0xFF);
2374 if (pstrSetBeaconParam->pu8Tail > 0)
2375 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Tail, pstrSetBeaconParam->u32TailLen);
2376 pu8CurrByte += pstrSetBeaconParam->u32TailLen;
2378 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2379 get_id_from_handler(hif_drv));
2381 PRINT_ER("Failed to send add beacon config packet\n");
2385 kfree(pstrSetBeaconParam->pu8Head);
2386 kfree(pstrSetBeaconParam->pu8Tail);
2389 static void Handle_DelBeacon(struct host_if_drv *hif_drv)
2395 strWID.id = (u16)WID_DEL_BEACON;
2396 strWID.type = WID_CHAR;
2397 strWID.size = sizeof(char);
2398 strWID.val = &gu8DelBcn;
2400 if (strWID.val == NULL)
2403 pu8CurrByte = strWID.val;
2405 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
2407 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2408 get_id_from_handler(hif_drv));
2410 PRINT_ER("Failed to send delete beacon config packet\n");
2413 static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
2414 struct add_sta_param *pstrStationParam)
2418 pu8CurrByte = pu8Buffer;
2420 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
2421 memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
2422 pu8CurrByte += ETH_ALEN;
2424 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
2425 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
2427 *pu8CurrByte++ = pstrStationParam->u8NumRates;
2428 if (pstrStationParam->u8NumRates > 0)
2429 memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
2430 pu8CurrByte += pstrStationParam->u8NumRates;
2432 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
2433 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
2434 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
2436 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
2437 memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
2438 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
2440 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
2441 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
2443 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
2444 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
2445 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
2446 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
2448 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
2450 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
2451 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
2453 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
2454 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
2456 return pu8CurrByte - pu8Buffer;
2459 static void Handle_AddStation(struct host_if_drv *hif_drv,
2460 struct add_sta_param *pstrStationParam)
2466 PRINT_D(HOSTINF_DBG, "Handling add station\n");
2467 strWID.id = (u16)WID_ADD_STA;
2468 strWID.type = WID_BIN;
2469 strWID.size = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
2471 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2472 if (strWID.val == NULL)
2475 pu8CurrByte = strWID.val;
2476 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2478 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2479 get_id_from_handler(hif_drv));
2481 PRINT_ER("Failed to send add station config packet\n");
2484 kfree(pstrStationParam->pu8Rates);
2488 static void Handle_DelAllSta(struct host_if_drv *hif_drv,
2489 struct del_all_sta *pstrDelAllStaParam)
2496 u8 au8Zero_Buff[6] = {0};
2498 strWID.id = (u16)WID_DEL_ALL_STA;
2499 strWID.type = WID_STR;
2500 strWID.size = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1;
2502 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
2504 strWID.val = kmalloc((pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1, GFP_KERNEL);
2505 if (strWID.val == NULL)
2508 pu8CurrByte = strWID.val;
2510 *(pu8CurrByte++) = pstrDelAllStaParam->u8Num_AssocSta;
2512 for (i = 0; i < MAX_NUM_STA; i++) {
2513 if (memcmp(pstrDelAllStaParam->au8Sta_DelAllSta[i], au8Zero_Buff, ETH_ALEN))
2514 memcpy(pu8CurrByte, pstrDelAllStaParam->au8Sta_DelAllSta[i], ETH_ALEN);
2518 pu8CurrByte += ETH_ALEN;
2521 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2522 get_id_from_handler(hif_drv));
2524 PRINT_ER("Failed to send add station config packet\n");
2532 static void Handle_DelStation(struct host_if_drv *hif_drv,
2533 struct del_sta *pstrDelStaParam)
2539 strWID.id = (u16)WID_REMOVE_STA;
2540 strWID.type = WID_BIN;
2541 strWID.size = ETH_ALEN;
2543 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
2545 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2546 if (strWID.val == NULL)
2549 pu8CurrByte = strWID.val;
2551 memcpy(pu8CurrByte, pstrDelStaParam->au8MacAddr, ETH_ALEN);
2553 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2554 get_id_from_handler(hif_drv));
2556 PRINT_ER("Failed to send add station config packet\n");
2562 static void Handle_EditStation(struct host_if_drv *hif_drv,
2563 struct add_sta_param *pstrStationParam)
2569 strWID.id = (u16)WID_EDIT_STA;
2570 strWID.type = WID_BIN;
2571 strWID.size = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
2573 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
2574 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2575 if (strWID.val == NULL)
2578 pu8CurrByte = strWID.val;
2579 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2581 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2582 get_id_from_handler(hif_drv));
2584 PRINT_ER("Failed to send edit station config packet\n");
2587 kfree(pstrStationParam->pu8Rates);
2591 static int Handle_RemainOnChan(struct host_if_drv *hif_drv,
2592 struct remain_ch *pstrHostIfRemainOnChan)
2595 u8 u8remain_on_chan_flag;
2598 if (!hif_drv->u8RemainOnChan_pendingreq) {
2599 hif_drv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
2600 hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
2601 hif_drv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
2602 hif_drv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
2603 hif_drv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
2605 pstrHostIfRemainOnChan->u16Channel = hif_drv->strHostIfRemainOnChan.u16Channel;
2608 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
2609 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
2610 hif_drv->u8RemainOnChan_pendingreq = 1;
2614 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2615 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
2620 if (g_obtainingIP || connecting) {
2621 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
2626 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
2628 u8remain_on_chan_flag = true;
2629 strWID.id = (u16)WID_REMAIN_ON_CHAN;
2630 strWID.type = WID_STR;
2632 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2634 if (strWID.val == NULL) {
2639 strWID.val[0] = u8remain_on_chan_flag;
2640 strWID.val[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
2642 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2643 get_id_from_handler(hif_drv));
2645 PRINT_ER("Failed to set remain on channel\n");
2649 P2P_LISTEN_STATE = 1;
2650 hif_drv->hRemainOnChannel.data = (unsigned long)hif_drv;
2651 mod_timer(&hif_drv->hRemainOnChannel,
2653 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
2655 if (hif_drv->strHostIfRemainOnChan.pRemainOnChanReady)
2656 hif_drv->strHostIfRemainOnChan.pRemainOnChanReady(hif_drv->strHostIfRemainOnChan.pVoid);
2658 if (hif_drv->u8RemainOnChan_pendingreq)
2659 hif_drv->u8RemainOnChan_pendingreq = 0;
2664 static int Handle_RegisterFrame(struct host_if_drv *hif_drv,
2665 struct reg_frame *pstrHostIfRegisterFrame)
2671 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
2673 strWID.id = (u16)WID_REGISTER_FRAME;
2674 strWID.type = WID_STR;
2675 strWID.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
2676 if (strWID.val == NULL)
2679 pu8CurrByte = strWID.val;
2681 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
2682 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
2683 memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
2686 strWID.size = sizeof(u16) + 2;
2688 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2689 get_id_from_handler(hif_drv));
2691 PRINT_ER("Failed to frame register config packet\n");
2699 #define FALSE_FRMWR_CHANNEL 100
2700 static u32 Handle_ListenStateExpired(struct host_if_drv *hif_drv,
2701 struct remain_ch *pstrHostIfRemainOnChan)
2703 u8 u8remain_on_chan_flag;
2707 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
2709 if (P2P_LISTEN_STATE) {
2710 u8remain_on_chan_flag = false;
2711 strWID.id = (u16)WID_REMAIN_ON_CHAN;
2712 strWID.type = WID_STR;
2714 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2716 if (strWID.val == NULL)
2717 PRINT_ER("Failed to allocate memory\n");
2719 strWID.val[0] = u8remain_on_chan_flag;
2720 strWID.val[1] = FALSE_FRMWR_CHANNEL;
2722 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2723 get_id_from_handler(hif_drv));
2724 if (s32Error != 0) {
2725 PRINT_ER("Failed to set remain on channel\n");
2729 if (hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired) {
2730 hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired(hif_drv->strHostIfRemainOnChan.pVoid
2731 , pstrHostIfRemainOnChan->u32ListenSessionID);
2733 P2P_LISTEN_STATE = 0;
2735 PRINT_D(GENERIC_DBG, "Not in listen state\n");
2743 static void ListenTimerCB(unsigned long arg)
2746 struct host_if_msg msg;
2747 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
2749 del_timer(&hif_drv->hRemainOnChannel);
2751 memset(&msg, 0, sizeof(struct host_if_msg));
2752 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
2754 msg.body.remain_on_ch.u32ListenSessionID = hif_drv->strHostIfRemainOnChan.u32ListenSessionID;
2756 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
2758 PRINT_ER("wilc_mq_send fail\n");
2761 static void Handle_PowerManagement(struct host_if_drv *hif_drv,
2762 struct power_mgmt_param *strPowerMgmtParam)
2768 strWID.id = (u16)WID_POWER_MANAGEMENT;
2770 if (strPowerMgmtParam->bIsEnabled == true)
2771 s8PowerMode = MIN_FAST_PS;
2773 s8PowerMode = NO_POWERSAVE;
2774 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
2775 strWID.val = &s8PowerMode;
2776 strWID.size = sizeof(char);
2778 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
2780 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2781 get_id_from_handler(hif_drv));
2783 PRINT_ER("Failed to send power management config packet\n");
2786 static void Handle_SetMulticastFilter(struct host_if_drv *hif_drv,
2787 struct set_multicast *strHostIfSetMulti)
2793 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
2795 strWID.id = (u16)WID_SETUP_MULTICAST_FILTER;
2796 strWID.type = WID_BIN;
2797 strWID.size = sizeof(struct set_multicast) + ((strHostIfSetMulti->u32count) * ETH_ALEN);
2798 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2799 if (strWID.val == NULL)
2802 pu8CurrByte = strWID.val;
2803 *pu8CurrByte++ = (strHostIfSetMulti->bIsEnabled & 0xFF);
2804 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 8) & 0xFF);
2805 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 16) & 0xFF);
2806 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 24) & 0xFF);
2808 *pu8CurrByte++ = (strHostIfSetMulti->u32count & 0xFF);
2809 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 8) & 0xFF);
2810 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 16) & 0xFF);
2811 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 24) & 0xFF);
2813 if ((strHostIfSetMulti->u32count) > 0)
2814 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->u32count) * ETH_ALEN));
2816 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2817 get_id_from_handler(hif_drv));
2819 PRINT_ER("Failed to send setup multicast config packet\n");
2826 static s32 Handle_AddBASession(struct host_if_drv *hif_drv,
2827 struct ba_session_info *strHostIfBASessionInfo)
2831 int AddbaTimeout = 100;
2834 PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\nBufferSize == %d\nSessionTimeOut = %d\n",
2835 strHostIfBASessionInfo->au8Bssid[0],
2836 strHostIfBASessionInfo->au8Bssid[1],
2837 strHostIfBASessionInfo->au8Bssid[2],
2838 strHostIfBASessionInfo->u16BufferSize,
2839 strHostIfBASessionInfo->u16SessionTimeout,
2840 strHostIfBASessionInfo->u8Ted);
2842 strWID.id = (u16)WID_11E_P_ACTION_REQ;
2843 strWID.type = WID_STR;
2844 strWID.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2845 strWID.size = BLOCK_ACK_REQ_SIZE;
2850 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2852 *ptr++ = strHostIfBASessionInfo->u8Ted;
2854 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
2855 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
2856 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
2857 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
2858 *ptr++ = (AddbaTimeout & 0xFF);
2859 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
2863 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2864 get_id_from_handler(hif_drv));
2866 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
2869 strWID.id = (u16)WID_11E_P_ACTION_REQ;
2870 strWID.type = WID_STR;
2876 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2878 *ptr++ = strHostIfBASessionInfo->u8Ted;
2880 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
2881 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
2883 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2884 get_id_from_handler(hif_drv));
2886 if (strWID.val != NULL)
2893 static s32 Handle_DelAllRxBASessions(struct host_if_drv *hif_drv,
2894 struct ba_session_info *strHostIfBASessionInfo)
2900 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
2901 strHostIfBASessionInfo->au8Bssid[0],
2902 strHostIfBASessionInfo->au8Bssid[1],
2903 strHostIfBASessionInfo->au8Bssid[2],
2904 strHostIfBASessionInfo->u8Ted);
2906 strWID.id = (u16)WID_DEL_ALL_RX_BA;
2907 strWID.type = WID_STR;
2908 strWID.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2909 strWID.size = BLOCK_ACK_REQ_SIZE;
2914 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2916 *ptr++ = strHostIfBASessionInfo->u8Ted;
2920 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2921 get_id_from_handler(hif_drv));
2923 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
2926 if (strWID.val != NULL)
2935 static int hostIFthread(void *pvArg)
2938 struct host_if_msg msg;
2939 struct host_if_drv *hif_drv;
2941 memset(&msg, 0, sizeof(struct host_if_msg));
2944 wilc_mq_recv(&gMsgQHostIF, &msg, sizeof(struct host_if_msg), &u32Ret);
2945 hif_drv = (struct host_if_drv *)msg.drv;
2946 if (msg.id == HOST_IF_MSG_EXIT) {
2947 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
2951 if ((!g_wilc_initialized)) {
2952 PRINT_D(GENERIC_DBG, "--WAIT--");
2953 usleep_range(200 * 1000, 200 * 1000);
2954 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
2958 if (msg.id == HOST_IF_MSG_CONNECT && hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
2959 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
2960 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
2961 usleep_range(2 * 1000, 2 * 1000);
2966 case HOST_IF_MSG_Q_IDLE:
2967 Handle_wait_msg_q_empty();
2970 case HOST_IF_MSG_SCAN:
2971 Handle_Scan(msg.drv, &msg.body.scan_info);
2974 case HOST_IF_MSG_CONNECT:
2975 Handle_Connect(msg.drv, &msg.body.con_info);
2978 case HOST_IF_MSG_FLUSH_CONNECT:
2979 Handle_FlushConnect(msg.drv);
2982 case HOST_IF_MSG_RCVD_NTWRK_INFO:
2983 Handle_RcvdNtwrkInfo(msg.drv, &msg.body.net_info);
2986 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
2987 Handle_RcvdGnrlAsyncInfo(msg.drv, &msg.body.async_info);
2990 case HOST_IF_MSG_KEY:
2991 Handle_Key(msg.drv, &msg.body.key_info);
2994 case HOST_IF_MSG_CFG_PARAMS:
2996 Handle_CfgParam(msg.drv, &msg.body.cfg_info);
2999 case HOST_IF_MSG_SET_CHANNEL:
3000 Handle_SetChannel(msg.drv, &msg.body.channel_info);
3003 case HOST_IF_MSG_DISCONNECT:
3004 Handle_Disconnect(msg.drv);
3007 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
3008 del_timer(&hif_drv->hScanTimer);
3009 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
3011 if (!linux_wlan_get_num_conn_ifcs())
3012 chip_sleep_manually(INFINITE_SLEEP_TIME);
3014 Handle_ScanDone(msg.drv, SCAN_EVENT_DONE);
3016 if (hif_drv->u8RemainOnChan_pendingreq)
3017 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
3021 case HOST_IF_MSG_GET_RSSI:
3022 Handle_GetRssi(msg.drv);
3025 case HOST_IF_MSG_GET_LINKSPEED:
3026 Handle_GetLinkspeed(msg.drv);
3029 case HOST_IF_MSG_GET_STATISTICS:
3030 Handle_GetStatistics(msg.drv, (struct rf_info *)msg.body.data);
3033 case HOST_IF_MSG_GET_CHNL:
3034 Handle_GetChnl(msg.drv);
3037 case HOST_IF_MSG_ADD_BEACON:
3038 Handle_AddBeacon(msg.drv, &msg.body.beacon_info);
3041 case HOST_IF_MSG_DEL_BEACON:
3042 Handle_DelBeacon(msg.drv);
3045 case HOST_IF_MSG_ADD_STATION:
3046 Handle_AddStation(msg.drv, &msg.body.add_sta_info);
3049 case HOST_IF_MSG_DEL_STATION:
3050 Handle_DelStation(msg.drv, &msg.body.del_sta_info);
3053 case HOST_IF_MSG_EDIT_STATION:
3054 Handle_EditStation(msg.drv, &msg.body.edit_sta_info);
3057 case HOST_IF_MSG_GET_INACTIVETIME:
3058 Handle_Get_InActiveTime(msg.drv, &msg.body.mac_info);
3061 case HOST_IF_MSG_SCAN_TIMER_FIRED:
3062 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
3064 Handle_ScanDone(msg.drv, SCAN_EVENT_ABORTED);
3067 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
3068 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
3069 Handle_ConnectTimeout(msg.drv);
3072 case HOST_IF_MSG_POWER_MGMT:
3073 Handle_PowerManagement(msg.drv, &msg.body.pwr_mgmt_info);
3076 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
3077 Handle_SetWfiDrvHandler(msg.drv,
3081 case HOST_IF_MSG_SET_OPERATION_MODE:
3082 Handle_SetOperationMode(msg.drv, &msg.body.mode);
3085 case HOST_IF_MSG_SET_IPADDRESS:
3086 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
3087 Handle_set_IPAddress(msg.drv, msg.body.ip_info.au8IPAddr, msg.body.ip_info.idx);
3090 case HOST_IF_MSG_GET_IPADDRESS:
3091 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
3092 Handle_get_IPAddress(msg.drv, msg.body.ip_info.au8IPAddr, msg.body.ip_info.idx);
3095 case HOST_IF_MSG_SET_MAC_ADDRESS:
3096 Handle_SetMacAddress(msg.drv, &msg.body.set_mac_info);
3099 case HOST_IF_MSG_GET_MAC_ADDRESS:
3100 Handle_GetMacAddress(msg.drv, &msg.body.get_mac_info);
3103 case HOST_IF_MSG_REMAIN_ON_CHAN:
3104 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
3105 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
3108 case HOST_IF_MSG_REGISTER_FRAME:
3109 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
3110 Handle_RegisterFrame(msg.drv, &msg.body.reg_frame);
3113 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
3114 Handle_ListenStateExpired(msg.drv, &msg.body.remain_on_ch);
3117 case HOST_IF_MSG_SET_MULTICAST_FILTER:
3118 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
3119 Handle_SetMulticastFilter(msg.drv, &msg.body.multicast_info);
3122 case HOST_IF_MSG_ADD_BA_SESSION:
3123 Handle_AddBASession(msg.drv, &msg.body.session_info);
3126 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
3127 Handle_DelAllRxBASessions(msg.drv, &msg.body.session_info);
3130 case HOST_IF_MSG_DEL_ALL_STA:
3131 Handle_DelAllSta(msg.drv, &msg.body.del_all_sta_info);
3135 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
3140 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
3141 up(&hSemHostIFthrdEnd);
3145 static void TimerCB_Scan(unsigned long arg)
3147 void *pvArg = (void *)arg;
3148 struct host_if_msg msg;
3150 memset(&msg, 0, sizeof(struct host_if_msg));
3152 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
3154 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3157 static void TimerCB_Connect(unsigned long arg)
3159 void *pvArg = (void *)arg;
3160 struct host_if_msg msg;
3162 memset(&msg, 0, sizeof(struct host_if_msg));
3164 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
3166 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3169 s32 host_int_remove_key(struct host_if_drv *hif_drv, const u8 *pu8StaAddress)
3173 strWID.id = (u16)WID_REMOVE_KEY;
3174 strWID.type = WID_STR;
3175 strWID.val = (s8 *)pu8StaAddress;
3181 int host_int_remove_wep_key(struct host_if_drv *hif_drv, u8 index)
3184 struct host_if_msg msg;
3188 PRINT_ER("Failed to send setup multicast config packet\n");
3192 memset(&msg, 0, sizeof(struct host_if_msg));
3194 msg.id = HOST_IF_MSG_KEY;
3195 msg.body.key_info.type = WEP;
3196 msg.body.key_info.action = REMOVEKEY;
3198 msg.body.key_info.attr.wep.index = index;
3200 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3202 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
3203 down(&hif_drv->hSemTestKeyBlock);
3208 s32 host_int_set_WEPDefaultKeyID(struct host_if_drv *hif_drv, u8 u8Index)
3211 struct host_if_msg msg;
3216 PRINT_ER("driver is null\n");
3220 memset(&msg, 0, sizeof(struct host_if_msg));
3223 msg.id = HOST_IF_MSG_KEY;
3224 msg.body.key_info.type = WEP;
3225 msg.body.key_info.action = DEFAULTKEY;
3227 msg.body.key_info.attr.wep.index = u8Index;
3229 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3231 PRINT_ER("Error in sending message queue : Default key index\n");
3232 down(&hif_drv->hSemTestKeyBlock);
3237 s32 host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv,
3238 const u8 *pu8WepKey,
3244 struct host_if_msg msg;
3248 PRINT_ER("driver is null\n");
3252 memset(&msg, 0, sizeof(struct host_if_msg));
3255 msg.id = HOST_IF_MSG_KEY;
3256 msg.body.key_info.type = WEP;
3257 msg.body.key_info.action = ADDKEY;
3259 msg.body.key_info.attr.wep.key = kmalloc(u8WepKeylen, GFP_KERNEL);
3260 memcpy(msg.body.key_info.attr.wep.key, pu8WepKey, u8WepKeylen);
3261 msg.body.key_info.attr.wep.key_len = (u8WepKeylen);
3262 msg.body.key_info.attr.wep.index = u8Keyidx;
3264 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3266 PRINT_ER("Error in sending message queue :WEP Key\n");
3267 down(&hif_drv->hSemTestKeyBlock);
3273 s32 host_int_add_wep_key_bss_ap(struct host_if_drv *hif_drv,
3274 const u8 *pu8WepKey,
3278 enum AUTHTYPE tenuAuth_type)
3282 struct host_if_msg msg;
3287 PRINT_ER("driver is null\n");
3291 memset(&msg, 0, sizeof(struct host_if_msg));
3294 for (i = 0; i < u8WepKeylen; i++)
3295 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
3297 msg.id = HOST_IF_MSG_KEY;
3298 msg.body.key_info.type = WEP;
3299 msg.body.key_info.action = ADDKEY_AP;
3301 msg.body.key_info.attr.wep.key = kmalloc(u8WepKeylen, GFP_KERNEL);
3302 memcpy(msg.body.key_info.attr.wep.key, pu8WepKey, (u8WepKeylen));
3303 msg.body.key_info.attr.wep.key_len = (u8WepKeylen);
3304 msg.body.key_info.attr.wep.index = u8Keyidx;
3305 msg.body.key_info.attr.wep.mode = u8mode;
3306 msg.body.key_info.attr.wep.auth_type = tenuAuth_type;
3308 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3311 PRINT_ER("Error in sending message queue :WEP Key\n");
3312 down(&hif_drv->hSemTestKeyBlock);
3318 s32 host_int_add_ptk(struct host_if_drv *hif_drv, const u8 *pu8Ptk,
3319 u8 u8PtkKeylen, const u8 *mac_addr,
3320 const u8 *pu8RxMic, const u8 *pu8TxMic,
3321 u8 mode, u8 u8Ciphermode, u8 u8Idx)
3324 struct host_if_msg msg;
3325 u8 u8KeyLen = u8PtkKeylen;
3330 PRINT_ER("driver is null\n");
3333 if (pu8RxMic != NULL)
3334 u8KeyLen += RX_MIC_KEY_LEN;
3335 if (pu8TxMic != NULL)
3336 u8KeyLen += TX_MIC_KEY_LEN;
3338 memset(&msg, 0, sizeof(struct host_if_msg));
3341 msg.id = HOST_IF_MSG_KEY;
3342 msg.body.key_info.type = WPAPtk;
3343 if (mode == AP_MODE) {
3344 msg.body.key_info.action = ADDKEY_AP;
3345 msg.body.key_info.attr.wpa.index = u8Idx;
3347 if (mode == STATION_MODE)
3348 msg.body.key_info.action = ADDKEY;
3350 msg.body.key_info.attr.wpa.key = kmalloc(u8PtkKeylen, GFP_KERNEL);
3351 memcpy(msg.body.key_info.attr.wpa.key, pu8Ptk, u8PtkKeylen);
3353 if (pu8RxMic != NULL) {
3354 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic, RX_MIC_KEY_LEN);
3356 for (i = 0; i < RX_MIC_KEY_LEN; i++)
3357 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
3360 if (pu8TxMic != NULL) {
3361 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic, TX_MIC_KEY_LEN);
3363 for (i = 0; i < TX_MIC_KEY_LEN; i++)
3364 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
3368 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
3369 msg.body.key_info.attr.wpa.mac_addr = mac_addr;
3370 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
3373 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3376 PRINT_ER("Error in sending message queue: PTK Key\n");
3378 down(&hif_drv->hSemTestKeyBlock);
3383 s32 host_int_add_rx_gtk(struct host_if_drv *hif_drv, const u8 *pu8RxGtk,
3384 u8 u8GtkKeylen, u8 u8KeyIdx,
3385 u32 u32KeyRSClen, const u8 *KeyRSC,
3386 const u8 *pu8RxMic, const u8 *pu8TxMic,
3387 u8 mode, u8 u8Ciphermode)
3390 struct host_if_msg msg;
3391 u8 u8KeyLen = u8GtkKeylen;
3395 PRINT_ER("driver is null\n");
3398 memset(&msg, 0, sizeof(struct host_if_msg));
3401 if (pu8RxMic != NULL)
3402 u8KeyLen += RX_MIC_KEY_LEN;
3403 if (pu8TxMic != NULL)
3404 u8KeyLen += TX_MIC_KEY_LEN;
3405 if (KeyRSC != NULL) {
3406 msg.body.key_info.attr.wpa.seq = kmalloc(u32KeyRSClen, GFP_KERNEL);
3407 memcpy(msg.body.key_info.attr.wpa.seq, KeyRSC, u32KeyRSClen);
3411 msg.id = HOST_IF_MSG_KEY;
3412 msg.body.key_info.type = WPARxGtk;
3415 if (mode == AP_MODE) {
3416 msg.body.key_info.action = ADDKEY_AP;
3417 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
3419 if (mode == STATION_MODE)
3420 msg.body.key_info.action = ADDKEY;
3422 msg.body.key_info.attr.wpa.key = kmalloc(u8KeyLen, GFP_KERNEL);
3423 memcpy(msg.body.key_info.attr.wpa.key, pu8RxGtk, u8GtkKeylen);
3425 if (pu8RxMic != NULL) {
3426 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic, RX_MIC_KEY_LEN);
3428 if (pu8TxMic != NULL) {
3429 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic, TX_MIC_KEY_LEN);
3432 msg.body.key_info.attr.wpa.index = u8KeyIdx;
3433 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
3434 msg.body.key_info.attr.wpa.seq_len = u32KeyRSClen;
3436 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3438 PRINT_ER("Error in sending message queue: RX GTK\n");
3440 down(&hif_drv->hSemTestKeyBlock);
3445 s32 host_int_set_pmkid_info(struct host_if_drv *hif_drv, struct host_if_pmkid_attr *pu8PmkidInfoArray)
3448 struct host_if_msg msg;
3454 PRINT_ER("driver is null\n");
3458 memset(&msg, 0, sizeof(struct host_if_msg));
3460 msg.id = HOST_IF_MSG_KEY;
3461 msg.body.key_info.type = PMKSA;
3462 msg.body.key_info.action = ADDKEY;
3465 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
3466 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
3468 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
3472 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3474 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
3479 s32 host_int_get_pmkid_info(struct host_if_drv *hif_drv,
3480 u8 *pu8PmkidInfoArray,
3481 u32 u32PmkidInfoLen)
3485 strWID.id = (u16)WID_PMKID_INFO;
3486 strWID.type = WID_STR;
3487 strWID.size = u32PmkidInfoLen;
3488 strWID.val = pu8PmkidInfoArray;
3493 s32 host_int_set_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3499 if ((u8Psklength > 7) && (u8Psklength < 65)) {
3500 strWID.id = (u16)WID_11I_PSK;
3501 strWID.type = WID_STR;
3502 strWID.val = pu8PassPhrase;
3503 strWID.size = u8Psklength;
3509 s32 host_int_get_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
3512 struct host_if_msg msg;
3514 memset(&msg, 0, sizeof(struct host_if_msg));
3516 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
3517 msg.body.get_mac_info.u8MacAddress = pu8MacAddress;
3520 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3522 PRINT_ER("Failed to send get mac address\n");
3526 down(&hWaitResponse);
3530 s32 host_int_set_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
3533 struct host_if_msg msg;
3535 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
3537 memset(&msg, 0, sizeof(struct host_if_msg));
3538 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
3539 memcpy(msg.body.set_mac_info.u8MacAddress, pu8MacAddress, ETH_ALEN);
3542 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3544 PRINT_ER("Failed to send message queue: Set mac address\n");
3550 s32 host_int_get_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3551 u8 *pu8PassPhrase, u8 u8Psklength)
3555 strWID.id = (u16)WID_11I_PSK;
3556 strWID.type = WID_STR;
3557 strWID.size = u8Psklength;
3558 strWID.val = pu8PassPhrase;
3563 s32 host_int_set_start_scan_req(struct host_if_drv *hif_drv, u8 scanSource)
3567 strWID.id = (u16)WID_START_SCAN_REQ;
3568 strWID.type = WID_CHAR;
3569 strWID.val = (s8 *)&scanSource;
3570 strWID.size = sizeof(char);
3575 s32 host_int_get_start_scan_req(struct host_if_drv *hif_drv, u8 *pu8ScanSource)
3579 strWID.id = (u16)WID_START_SCAN_REQ;
3580 strWID.type = WID_CHAR;
3581 strWID.val = (s8 *)pu8ScanSource;
3582 strWID.size = sizeof(char);
3587 s32 host_int_set_join_req(struct host_if_drv *hif_drv, u8 *pu8bssid,
3588 const u8 *pu8ssid, size_t ssidLen,
3589 const u8 *pu8IEs, size_t IEsLen,
3590 wilc_connect_result pfConnectResult, void *pvUserArg,
3591 u8 u8security, enum AUTHTYPE tenuAuth_type,
3592 u8 u8channel, void *pJoinParams)
3595 struct host_if_msg msg;
3596 enum scan_conn_timer enuScanConnTimer;
3598 if (!hif_drv || pfConnectResult == NULL) {
3600 PRINT_ER("Driver is null\n");
3605 PRINT_ER("Driver is null\n");
3609 if (pJoinParams == NULL) {
3610 PRINT_ER("Unable to Join - JoinParams is NULL\n");
3614 memset(&msg, 0, sizeof(struct host_if_msg));
3616 msg.id = HOST_IF_MSG_CONNECT;
3618 msg.body.con_info.u8security = u8security;
3619 msg.body.con_info.tenuAuth_type = tenuAuth_type;
3620 msg.body.con_info.u8channel = u8channel;
3621 msg.body.con_info.pfConnectResult = pfConnectResult;
3622 msg.body.con_info.pvUserArg = pvUserArg;
3623 msg.body.con_info.pJoinParams = pJoinParams;
3626 if (pu8bssid != NULL) {
3627 msg.body.con_info.pu8bssid = kmalloc(6, GFP_KERNEL);
3628 memcpy(msg.body.con_info.pu8bssid,
3632 if (pu8ssid != NULL) {
3633 msg.body.con_info.ssidLen = ssidLen;
3634 msg.body.con_info.pu8ssid = kmalloc(ssidLen, GFP_KERNEL);
3635 memcpy(msg.body.con_info.pu8ssid,
3640 if (pu8IEs != NULL) {
3641 msg.body.con_info.IEsLen = IEsLen;
3642 msg.body.con_info.pu8IEs = kmalloc(IEsLen, GFP_KERNEL);
3643 memcpy(msg.body.con_info.pu8IEs,
3646 if (hif_drv->enuHostIFstate < HOST_IF_CONNECTING)
3647 hif_drv->enuHostIFstate = HOST_IF_CONNECTING;
3649 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", hif_drv->enuHostIFstate);
3651 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3653 PRINT_ER("Failed to send message queue: Set join request\n");
3657 enuScanConnTimer = CONNECT_TIMER;
3658 hif_drv->hConnectTimer.data = (unsigned long)hif_drv;
3659 mod_timer(&hif_drv->hConnectTimer,
3660 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
3665 s32 host_int_flush_join_req(struct host_if_drv *hif_drv)
3668 struct host_if_msg msg;
3670 if (!gu8FlushedJoinReq) {
3678 PRINT_ER("Driver is null\n");
3682 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
3685 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3687 PRINT_ER("Failed to send message queue: Flush join request\n");
3694 s32 host_int_disconnect(struct host_if_drv *hif_drv, u16 u16ReasonCode)
3697 struct host_if_msg msg;
3700 PRINT_ER("Driver is null\n");
3704 memset(&msg, 0, sizeof(struct host_if_msg));
3706 msg.id = HOST_IF_MSG_DISCONNECT;
3709 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3711 PRINT_ER("Failed to send message queue: disconnect\n");
3713 down(&hif_drv->hSemTestDisconnectBlock);
3718 s32 host_int_disconnect_station(struct host_if_drv *hif_drv, u8 assoc_id)
3722 strWID.id = (u16)WID_DISCONNECT;
3723 strWID.type = WID_CHAR;
3724 strWID.val = (s8 *)&assoc_id;
3725 strWID.size = sizeof(char);
3730 s32 host_int_get_assoc_req_info(struct host_if_drv *hif_drv, u8 *pu8AssocReqInfo,
3731 u32 u32AssocReqInfoLen)
3735 strWID.id = (u16)WID_ASSOC_REQ_INFO;
3736 strWID.type = WID_STR;
3737 strWID.val = pu8AssocReqInfo;
3738 strWID.size = u32AssocReqInfoLen;
3743 s32 host_int_get_assoc_res_info(struct host_if_drv *hif_drv, u8 *pu8AssocRespInfo,
3744 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
3750 PRINT_ER("Driver is null\n");
3754 strWID.id = (u16)WID_ASSOC_RES_INFO;
3755 strWID.type = WID_STR;
3756 strWID.val = pu8AssocRespInfo;
3757 strWID.size = u32MaxAssocRespInfoLen;
3759 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
3760 get_id_from_handler(hif_drv));
3762 *pu32RcvdAssocRespInfoLen = 0;
3763 PRINT_ER("Failed to send association response config packet\n");
3766 *pu32RcvdAssocRespInfoLen = strWID.size;
3772 s32 host_int_get_rx_power_level(struct host_if_drv *hif_drv, u8 *pu8RxPowerLevel,
3773 u32 u32RxPowerLevelLen)
3777 strWID.id = (u16)WID_RX_POWER_LEVEL;
3778 strWID.type = WID_STR;
3779 strWID.val = pu8RxPowerLevel;
3780 strWID.size = u32RxPowerLevelLen;
3785 int host_int_set_mac_chnl_num(struct host_if_drv *hif_drv, u8 channel)
3788 struct host_if_msg msg;
3791 PRINT_ER("driver is null\n");
3795 memset(&msg, 0, sizeof(struct host_if_msg));
3796 msg.id = HOST_IF_MSG_SET_CHANNEL;
3797 msg.body.channel_info.u8SetChan = channel;
3800 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3802 PRINT_ER("wilc mq send fail\n");
3809 int host_int_wait_msg_queue_idle(void)
3813 struct host_if_msg msg;
3814 memset(&msg, 0, sizeof(struct host_if_msg));
3815 msg.id = HOST_IF_MSG_Q_IDLE;
3816 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3818 PRINT_ER("wilc mq send fail\n");
3822 down(&hWaitResponse);
3827 int host_int_set_wfi_drv_handler(struct host_if_drv *hif_drv)
3831 struct host_if_msg msg;
3832 memset(&msg, 0, sizeof(struct host_if_msg));
3833 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
3834 msg.body.drv.u32Address = get_id_from_handler(hif_drv);
3837 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3839 PRINT_ER("wilc mq send fail\n");
3846 int host_int_set_operation_mode(struct host_if_drv *hif_drv, u32 mode)
3850 struct host_if_msg msg;
3851 memset(&msg, 0, sizeof(struct host_if_msg));
3852 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
3853 msg.body.mode.u32Mode = mode;
3856 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3858 PRINT_ER("wilc mq send fail\n");
3865 s32 host_int_get_host_chnl_num(struct host_if_drv *hif_drv, u8 *pu8ChNo)
3868 struct host_if_msg msg;
3871 PRINT_ER("driver is null\n");
3875 memset(&msg, 0, sizeof(struct host_if_msg));
3877 msg.id = HOST_IF_MSG_GET_CHNL;
3880 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3882 PRINT_ER("wilc mq send fail\n");
3883 down(&hif_drv->hSemGetCHNL);
3892 s32 host_int_get_inactive_time(struct host_if_drv *hif_drv,
3893 const u8 *mac, u32 *pu32InactiveTime)
3896 struct host_if_msg msg;
3899 PRINT_ER("driver is null\n");
3903 memset(&msg, 0, sizeof(struct host_if_msg));
3906 memcpy(msg.body.mac_info.mac,
3909 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
3912 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3914 PRINT_ER("Failed to send get host channel param's message queue ");
3916 down(&hif_drv->hSemInactiveTime);
3918 *pu32InactiveTime = gu32InactiveTime;
3923 s32 host_int_test_get_int_wid(struct host_if_drv *hif_drv, u32 *pu32TestMemAddr)
3930 PRINT_ER("driver is null\n");
3934 strWID.id = (u16)WID_MEMORY_ADDRESS;
3935 strWID.type = WID_INT;
3936 strWID.val = (s8 *)pu32TestMemAddr;
3937 strWID.size = sizeof(u32);
3939 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
3940 get_id_from_handler(hif_drv));
3943 PRINT_ER("Failed to get wid value\n");
3946 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
3953 s32 host_int_get_rssi(struct host_if_drv *hif_drv, s8 *ps8Rssi)
3956 struct host_if_msg msg;
3957 memset(&msg, 0, sizeof(struct host_if_msg));
3959 msg.id = HOST_IF_MSG_GET_RSSI;
3962 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3964 PRINT_ER("Failed to send get host channel param's message queue ");
3968 down(&hif_drv->hSemGetRSSI);
3971 if (ps8Rssi == NULL) {
3972 PRINT_ER("RSS pointer value is null");
3983 s32 host_int_get_link_speed(struct host_if_drv *hif_drv, s8 *ps8lnkspd)
3985 struct host_if_msg msg;
3987 memset(&msg, 0, sizeof(struct host_if_msg));
3989 msg.id = HOST_IF_MSG_GET_LINKSPEED;
3992 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3994 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
3998 down(&hif_drv->hSemGetLINKSPEED);
4001 if (ps8lnkspd == NULL) {
4002 PRINT_ER("LINKSPEED pointer value is null");
4007 *ps8lnkspd = gs8lnkspd;
4013 s32 host_int_get_statistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
4016 struct host_if_msg msg;
4017 memset(&msg, 0, sizeof(struct host_if_msg));
4019 msg.id = HOST_IF_MSG_GET_STATISTICS;
4020 msg.body.data = (char *)pstrStatistics;
4023 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4025 PRINT_ER("Failed to send get host channel param's message queue ");
4029 down(&hWaitResponse);
4033 s32 host_int_scan(struct host_if_drv *hif_drv, u8 u8ScanSource,
4034 u8 u8ScanType, u8 *pu8ChnlFreqList,
4035 u8 u8ChnlListLen, const u8 *pu8IEs,
4036 size_t IEsLen, wilc_scan_result ScanResult,
4037 void *pvUserArg, struct hidden_network *pstrHiddenNetwork)
4040 struct host_if_msg msg;
4041 enum scan_conn_timer enuScanConnTimer;
4043 if (!hif_drv || ScanResult == NULL) {
4044 PRINT_ER("hif_drv or ScanResult = NULL\n");
4048 memset(&msg, 0, sizeof(struct host_if_msg));
4050 msg.id = HOST_IF_MSG_SCAN;
4052 if (pstrHiddenNetwork != NULL) {
4053 msg.body.scan_info.hidden_network.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
4054 msg.body.scan_info.hidden_network.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
4057 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
4060 msg.body.scan_info.src = u8ScanSource;
4061 msg.body.scan_info.type = u8ScanType;
4062 msg.body.scan_info.result = ScanResult;
4063 msg.body.scan_info.arg = pvUserArg;
4065 msg.body.scan_info.ch_list_len = u8ChnlListLen;
4066 msg.body.scan_info.ch_freq_list = kmalloc(u8ChnlListLen, GFP_KERNEL);
4067 memcpy(msg.body.scan_info.ch_freq_list, pu8ChnlFreqList, u8ChnlListLen);
4069 msg.body.scan_info.ies_len = IEsLen;
4070 msg.body.scan_info.ies = kmalloc(IEsLen, GFP_KERNEL);
4071 memcpy(msg.body.scan_info.ies, pu8IEs, IEsLen);
4073 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4075 PRINT_ER("Error in sending message queue\n");
4079 enuScanConnTimer = SCAN_TIMER;
4080 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
4081 hif_drv->hScanTimer.data = (unsigned long)hif_drv;
4082 mod_timer(&hif_drv->hScanTimer,
4083 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
4089 s32 hif_set_cfg(struct host_if_drv *hif_drv,
4090 struct cfg_param_val *pstrCfgParamVal)
4094 struct host_if_msg msg;
4098 PRINT_ER("hif_drv NULL\n");
4102 memset(&msg, 0, sizeof(struct host_if_msg));
4103 msg.id = HOST_IF_MSG_CFG_PARAMS;
4104 msg.body.cfg_info.cfg_attr_info = *pstrCfgParamVal;
4107 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4113 s32 hif_get_cfg(struct host_if_drv *hif_drv, u16 u16WID, u16 *pu16WID_Value)
4117 down(&hif_drv->gtOsCfgValuesSem);
4120 PRINT_ER("hif_drv NULL\n");
4123 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
4127 *pu16WID_Value = (u16)hif_drv->strCfgValues.bss_type;
4131 *pu16WID_Value = (u16)hif_drv->strCfgValues.auth_type;
4134 case WID_AUTH_TIMEOUT:
4135 *pu16WID_Value = hif_drv->strCfgValues.auth_timeout;
4138 case WID_POWER_MANAGEMENT:
4139 *pu16WID_Value = (u16)hif_drv->strCfgValues.power_mgmt_mode;
4142 case WID_SHORT_RETRY_LIMIT:
4143 *pu16WID_Value = hif_drv->strCfgValues.short_retry_limit;
4146 case WID_LONG_RETRY_LIMIT:
4147 *pu16WID_Value = hif_drv->strCfgValues.long_retry_limit;
4150 case WID_FRAG_THRESHOLD:
4151 *pu16WID_Value = hif_drv->strCfgValues.frag_threshold;
4154 case WID_RTS_THRESHOLD:
4155 *pu16WID_Value = hif_drv->strCfgValues.rts_threshold;
4159 *pu16WID_Value = (u16)hif_drv->strCfgValues.preamble_type;
4162 case WID_SHORT_SLOT_ALLOWED:
4163 *pu16WID_Value = (u16) hif_drv->strCfgValues.short_slot_allowed;
4166 case WID_11N_TXOP_PROT_DISABLE:
4167 *pu16WID_Value = (u16)hif_drv->strCfgValues.txop_prot_disabled;
4170 case WID_BEACON_INTERVAL:
4171 *pu16WID_Value = hif_drv->strCfgValues.beacon_interval;
4174 case WID_DTIM_PERIOD:
4175 *pu16WID_Value = (u16)hif_drv->strCfgValues.dtim_period;
4178 case WID_SITE_SURVEY:
4179 *pu16WID_Value = (u16)hif_drv->strCfgValues.site_survey_enabled;
4182 case WID_SITE_SURVEY_SCAN_TIME:
4183 *pu16WID_Value = hif_drv->strCfgValues.site_survey_scan_time;
4186 case WID_ACTIVE_SCAN_TIME:
4187 *pu16WID_Value = hif_drv->strCfgValues.active_scan_time;
4190 case WID_PASSIVE_SCAN_TIME:
4191 *pu16WID_Value = hif_drv->strCfgValues.passive_scan_time;
4194 case WID_CURRENT_TX_RATE:
4195 *pu16WID_Value = hif_drv->strCfgValues.curr_tx_rate;
4202 up(&hif_drv->gtOsCfgValuesSem);
4208 void host_int_send_join_leave_info_to_host
4209 (u16 assocId, u8 *stationAddr, bool joining)
4213 static void GetPeriodicRSSI(unsigned long arg)
4215 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
4218 PRINT_ER("Driver handler is NULL\n");
4222 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED) {
4224 struct host_if_msg msg;
4226 memset(&msg, 0, sizeof(struct host_if_msg));
4228 msg.id = HOST_IF_MSG_GET_RSSI;
4231 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4233 PRINT_ER("Failed to send get host channel param's message queue ");
4237 g_hPeriodicRSSI.data = (unsigned long)hif_drv;
4238 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
4242 void host_int_send_network_info_to_host
4243 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
4247 static u32 clients_count;
4249 s32 host_int_init(struct host_if_drv **hif_drv_handler)
4252 struct host_if_drv *hif_drv;
4255 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
4257 gbScanWhileConnected = false;
4259 sema_init(&hWaitResponse, 0);
4261 hif_drv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
4266 *hif_drv_handler = hif_drv;
4267 err = add_handler_in_list(hif_drv);
4273 g_obtainingIP = false;
4275 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", hif_drv);
4276 if (clients_count == 0) {
4277 sema_init(&hSemHostIFthrdEnd, 0);
4278 sema_init(&hSemDeinitDrvHandle, 0);
4279 sema_init(&hSemHostIntDeinit, 1);
4282 sema_init(&hif_drv->hSemTestKeyBlock, 0);
4283 sema_init(&hif_drv->hSemTestDisconnectBlock, 0);
4284 sema_init(&hif_drv->hSemGetRSSI, 0);
4285 sema_init(&hif_drv->hSemGetLINKSPEED, 0);
4286 sema_init(&hif_drv->hSemGetCHNL, 0);
4287 sema_init(&hif_drv->hSemInactiveTime, 0);
4289 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
4291 if (clients_count == 0) {
4292 result = wilc_mq_create(&gMsgQHostIF);
4295 PRINT_ER("Failed to creat MQ\n");
4298 HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread");
4299 if (IS_ERR(HostIFthreadHandler)) {
4300 PRINT_ER("Failed to creat Thread\n");
4304 setup_timer(&g_hPeriodicRSSI, GetPeriodicRSSI,
4305 (unsigned long)hif_drv);
4306 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
4309 setup_timer(&hif_drv->hScanTimer, TimerCB_Scan, 0);
4311 setup_timer(&hif_drv->hConnectTimer, TimerCB_Connect, 0);
4313 setup_timer(&hif_drv->hRemainOnChannel, ListenTimerCB, 0);
4315 sema_init(&(hif_drv->gtOsCfgValuesSem), 1);
4316 down(&hif_drv->gtOsCfgValuesSem);
4318 hif_drv->enuHostIFstate = HOST_IF_IDLE;
4319 hif_drv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
4320 hif_drv->strCfgValues.scan_source = DEFAULT_SCAN;
4321 hif_drv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
4322 hif_drv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
4323 hif_drv->strCfgValues.curr_tx_rate = AUTORATE;
4325 hif_drv->u64P2p_MgmtTimeout = 0;
4327 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",
4329 hif_drv->strCfgValues.site_survey_enabled, hif_drv->strCfgValues.scan_source,
4330 hif_drv->strCfgValues.active_scan_time, hif_drv->strCfgValues.passive_scan_time,
4331 hif_drv->strCfgValues.curr_tx_rate);
4333 up(&hif_drv->gtOsCfgValuesSem);
4340 up(&hif_drv->gtOsCfgValuesSem);
4341 del_timer_sync(&hif_drv->hConnectTimer);
4342 del_timer_sync(&hif_drv->hScanTimer);
4343 kthread_stop(HostIFthreadHandler);
4345 wilc_mq_destroy(&gMsgQHostIF);
4350 s32 host_int_deinit(struct host_if_drv *hif_drv)
4353 struct host_if_msg msg;
4357 PRINT_ER("hif_drv = NULL\n");
4361 down(&hSemHostIntDeinit);
4363 terminated_handle = hif_drv;
4364 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
4366 if (del_timer_sync(&hif_drv->hScanTimer)) {
4367 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
4370 if (del_timer_sync(&hif_drv->hConnectTimer)) {
4371 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4375 if (del_timer_sync(&g_hPeriodicRSSI)) {
4376 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4379 del_timer_sync(&hif_drv->hRemainOnChannel);
4381 host_int_set_wfi_drv_handler(NULL);
4382 down(&hSemDeinitDrvHandle);
4384 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
4385 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
4386 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
4388 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
4391 hif_drv->enuHostIFstate = HOST_IF_IDLE;
4393 gbScanWhileConnected = false;
4395 memset(&msg, 0, sizeof(struct host_if_msg));
4397 if (clients_count == 1) {
4398 if (del_timer_sync(&g_hPeriodicRSSI)) {
4399 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4401 msg.id = HOST_IF_MSG_EXIT;
4405 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4407 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
4409 down(&hSemHostIFthrdEnd);
4411 wilc_mq_destroy(&gMsgQHostIF);
4414 down(&(hif_drv->gtOsCfgValuesSem));
4416 ret = remove_handler_in_list(hif_drv);
4423 terminated_handle = NULL;
4424 up(&hSemHostIntDeinit);
4428 void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
4431 struct host_if_msg msg;
4433 struct host_if_drv *hif_drv = NULL;
4435 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4436 hif_drv = get_handler_from_id(id);
4441 if (!hif_drv || hif_drv == terminated_handle) {
4442 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv);
4446 memset(&msg, 0, sizeof(struct host_if_msg));
4448 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
4451 msg.body.net_info.u32Length = u32Length;
4452 msg.body.net_info.pu8Buffer = kmalloc(u32Length, GFP_KERNEL);
4453 memcpy(msg.body.net_info.pu8Buffer,
4454 pu8Buffer, u32Length);
4456 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4458 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
4461 void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
4464 struct host_if_msg msg;
4466 struct host_if_drv *hif_drv = NULL;
4468 down(&hSemHostIntDeinit);
4470 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4471 hif_drv = get_handler_from_id(id);
4472 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
4475 if (!hif_drv || hif_drv == terminated_handle) {
4476 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
4477 up(&hSemHostIntDeinit);
4481 if (!hif_drv->strWILC_UsrConnReq.pfUserConnectResult) {
4482 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
4483 up(&hSemHostIntDeinit);
4487 memset(&msg, 0, sizeof(struct host_if_msg));
4490 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
4494 msg.body.async_info.u32Length = u32Length;
4495 msg.body.async_info.pu8Buffer = kmalloc(u32Length, GFP_KERNEL);
4496 memcpy(msg.body.async_info.pu8Buffer,
4497 pu8Buffer, u32Length);
4499 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4501 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
4503 up(&hSemHostIntDeinit);
4506 void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
4509 struct host_if_msg msg;
4511 struct host_if_drv *hif_drv = NULL;
4513 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4514 hif_drv = get_handler_from_id(id);
4517 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", hif_drv);
4519 if (!hif_drv || hif_drv == terminated_handle)
4522 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
4523 memset(&msg, 0, sizeof(struct host_if_msg));
4525 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
4528 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4530 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
4538 s32 host_int_remain_on_channel(struct host_if_drv *hif_drv, u32 u32SessionID,
4539 u32 u32duration, u16 chan,
4540 wilc_remain_on_chan_expired RemainOnChanExpired,
4541 wilc_remain_on_chan_ready RemainOnChanReady,
4545 struct host_if_msg msg;
4548 PRINT_ER("driver is null\n");
4552 memset(&msg, 0, sizeof(struct host_if_msg));
4554 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
4555 msg.body.remain_on_ch.u16Channel = chan;
4556 msg.body.remain_on_ch.pRemainOnChanExpired = RemainOnChanExpired;
4557 msg.body.remain_on_ch.pRemainOnChanReady = RemainOnChanReady;
4558 msg.body.remain_on_ch.pVoid = pvUserArg;
4559 msg.body.remain_on_ch.u32duration = u32duration;
4560 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
4563 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4565 PRINT_ER("wilc mq send fail\n");
4570 s32 host_int_ListenStateExpired(struct host_if_drv *hif_drv, u32 u32SessionID)
4573 struct host_if_msg msg;
4576 PRINT_ER("driver is null\n");
4580 del_timer(&hif_drv->hRemainOnChannel);
4582 memset(&msg, 0, sizeof(struct host_if_msg));
4583 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
4585 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
4587 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4589 PRINT_ER("wilc mq send fail\n");
4594 s32 host_int_frame_register(struct host_if_drv *hif_drv, u16 u16FrameType, bool bReg)
4597 struct host_if_msg msg;
4600 PRINT_ER("driver is null\n");
4604 memset(&msg, 0, sizeof(struct host_if_msg));
4606 msg.id = HOST_IF_MSG_REGISTER_FRAME;
4607 switch (u16FrameType) {
4609 PRINT_D(HOSTINF_DBG, "ACTION\n");
4610 msg.body.reg_frame.u8Regid = ACTION_FRM_IDX;
4614 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
4615 msg.body.reg_frame.u8Regid = PROBE_REQ_IDX;
4619 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
4622 msg.body.reg_frame.u16FrameType = u16FrameType;
4623 msg.body.reg_frame.bReg = bReg;
4626 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4628 PRINT_ER("wilc mq send fail\n");
4635 s32 host_int_add_beacon(struct host_if_drv *hif_drv, u32 u32Interval,
4636 u32 u32DTIMPeriod, u32 u32HeadLen, u8 *pu8Head,
4637 u32 u32TailLen, u8 *pu8Tail)
4640 struct host_if_msg msg;
4641 struct beacon_attr *pstrSetBeaconParam = &msg.body.beacon_info;
4644 PRINT_ER("driver is null\n");
4648 memset(&msg, 0, sizeof(struct host_if_msg));
4650 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
4652 msg.id = HOST_IF_MSG_ADD_BEACON;
4654 pstrSetBeaconParam->u32Interval = u32Interval;
4655 pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
4656 pstrSetBeaconParam->u32HeadLen = u32HeadLen;
4657 pstrSetBeaconParam->pu8Head = kmalloc(u32HeadLen, GFP_KERNEL);
4658 if (pstrSetBeaconParam->pu8Head == NULL) {
4662 memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
4663 pstrSetBeaconParam->u32TailLen = u32TailLen;
4665 if (u32TailLen > 0) {
4666 pstrSetBeaconParam->pu8Tail = kmalloc(u32TailLen, GFP_KERNEL);
4667 if (pstrSetBeaconParam->pu8Tail == NULL) {
4671 memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen);
4673 pstrSetBeaconParam->pu8Tail = NULL;
4676 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4678 PRINT_ER("wilc mq send fail\n");
4682 if (pstrSetBeaconParam->pu8Head != NULL)
4683 kfree(pstrSetBeaconParam->pu8Head);
4685 if (pstrSetBeaconParam->pu8Tail != NULL)
4686 kfree(pstrSetBeaconParam->pu8Tail);
4693 s32 host_int_del_beacon(struct host_if_drv *hif_drv)
4696 struct host_if_msg msg;
4699 PRINT_ER("driver is null\n");
4703 msg.id = HOST_IF_MSG_DEL_BEACON;
4705 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
4707 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4709 PRINT_ER("wilc_mq_send fail\n");
4714 s32 host_int_add_station(struct host_if_drv *hif_drv,
4715 struct add_sta_param *pstrStaParams)
4718 struct host_if_msg msg;
4719 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
4723 PRINT_ER("driver is null\n");
4727 memset(&msg, 0, sizeof(struct host_if_msg));
4729 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
4731 msg.id = HOST_IF_MSG_ADD_STATION;
4734 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
4735 if (pstrAddStationMsg->u8NumRates > 0) {
4736 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
4741 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
4742 pstrAddStationMsg->pu8Rates = rates;
4746 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4748 PRINT_ER("wilc_mq_send fail\n");
4752 s32 host_int_del_station(struct host_if_drv *hif_drv, const u8 *pu8MacAddr)
4755 struct host_if_msg msg;
4756 struct del_sta *pstrDelStationMsg = &msg.body.del_sta_info;
4759 PRINT_ER("driver is null\n");
4763 memset(&msg, 0, sizeof(struct host_if_msg));
4765 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
4767 msg.id = HOST_IF_MSG_DEL_STATION;
4770 if (pu8MacAddr == NULL)
4771 memset(pstrDelStationMsg->au8MacAddr, 255, ETH_ALEN);
4773 memcpy(pstrDelStationMsg->au8MacAddr, pu8MacAddr, ETH_ALEN);
4775 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4777 PRINT_ER("wilc_mq_send fail\n");
4781 s32 host_int_del_allstation(struct host_if_drv *hif_drv,
4782 u8 pu8MacAddr[][ETH_ALEN])
4785 struct host_if_msg msg;
4786 struct del_all_sta *pstrDelAllStationMsg = &msg.body.del_all_sta_info;
4787 u8 au8Zero_Buff[ETH_ALEN] = {0};
4793 PRINT_ER("driver is null\n");
4797 memset(&msg, 0, sizeof(struct host_if_msg));
4799 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
4801 msg.id = HOST_IF_MSG_DEL_ALL_STA;
4804 for (i = 0; i < MAX_NUM_STA; i++) {
4805 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
4806 memcpy(pstrDelAllStationMsg->au8Sta_DelAllSta[i], pu8MacAddr[i], ETH_ALEN);
4807 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],
4808 pstrDelAllStationMsg->au8Sta_DelAllSta[i][5]);
4813 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
4817 pstrDelAllStationMsg->u8Num_AssocSta = u8AssocNumb;
4818 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4822 PRINT_ER("wilc_mq_send fail\n");
4824 down(&hWaitResponse);
4830 s32 host_int_edit_station(struct host_if_drv *hif_drv,
4831 struct add_sta_param *pstrStaParams)
4834 struct host_if_msg msg;
4835 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
4838 PRINT_ER("driver is null\n");
4842 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
4844 memset(&msg, 0, sizeof(struct host_if_msg));
4846 msg.id = HOST_IF_MSG_EDIT_STATION;
4849 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
4850 if (pstrAddStationMsg->u8NumRates > 0) {
4851 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
4856 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
4857 pstrAddStationMsg->pu8Rates = rates;
4860 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4862 PRINT_ER("wilc_mq_send fail\n");
4867 s32 host_int_set_power_mgmt(struct host_if_drv *hif_drv,
4872 struct host_if_msg msg;
4873 struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.pwr_mgmt_info;
4875 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
4878 PRINT_ER("driver is null\n");
4882 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
4884 memset(&msg, 0, sizeof(struct host_if_msg));
4886 msg.id = HOST_IF_MSG_POWER_MGMT;
4889 pstrPowerMgmtParam->bIsEnabled = bIsEnabled;
4890 pstrPowerMgmtParam->u32Timeout = u32Timeout;
4893 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4895 PRINT_ER("wilc_mq_send fail\n");
4899 s32 host_int_setup_multicast_filter(struct host_if_drv *hif_drv,
4904 struct host_if_msg msg;
4905 struct set_multicast *pstrMulticastFilterParam = &msg.body.multicast_info;
4909 PRINT_ER("driver is null\n");
4913 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
4915 memset(&msg, 0, sizeof(struct host_if_msg));
4917 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
4920 pstrMulticastFilterParam->bIsEnabled = bIsEnabled;
4921 pstrMulticastFilterParam->u32count = u32count;
4923 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4925 PRINT_ER("wilc_mq_send fail\n");
4929 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
4931 struct join_bss_param *pNewJoinBssParam = NULL;
4940 u8 pcipherTotalCount = 0;
4941 u8 authTotalCount = 0;
4944 pu8IEs = ptstrNetworkInfo->pu8IEs;
4945 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
4947 pNewJoinBssParam = kmalloc(sizeof(struct join_bss_param), GFP_KERNEL);
4948 if (pNewJoinBssParam != NULL) {
4949 memset(pNewJoinBssParam, 0, sizeof(struct join_bss_param));
4950 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
4951 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
4952 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
4953 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
4954 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
4955 pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen;
4956 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
4957 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
4959 while (index < u16IEsLen) {
4960 if (pu8IEs[index] == SUPP_RATES_IE) {
4961 suppRatesNo = pu8IEs[index + 1];
4962 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
4965 for (i = 0; i < suppRatesNo; i++) {
4966 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
4968 index += suppRatesNo;
4970 } else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
4971 extSuppRatesNo = pu8IEs[index + 1];
4972 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
4973 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
4975 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
4977 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
4978 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
4980 index += extSuppRatesNo;
4982 } else if (pu8IEs[index] == HT_CAPABILITY_IE) {
4983 pNewJoinBssParam->ht_capable = true;
4984 index += pu8IEs[index + 1] + 2;
4986 } else if ((pu8IEs[index] == WMM_IE) &&
4987 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
4988 (pu8IEs[index + 4] == 0xF2) &&
4989 (pu8IEs[index + 5] == 0x02) &&
4990 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) &&
4991 (pu8IEs[index + 7] == 0x01)) {
4992 pNewJoinBssParam->wmm_cap = true;
4994 if (pu8IEs[index + 8] & BIT(7))
4995 pNewJoinBssParam->uapsd_cap = true;
4996 index += pu8IEs[index + 1] + 2;
4998 } else if ((pu8IEs[index] == P2P_IE) &&
4999 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
5000 (pu8IEs[index + 4] == 0x9a) &&
5001 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) {
5004 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
5005 pNewJoinBssParam->u8NoaEnbaled = 1;
5006 pNewJoinBssParam->u8Index = pu8IEs[index + 9];
5008 if (pu8IEs[index + 10] & BIT(7)) {
5009 pNewJoinBssParam->u8OppEnable = 1;
5010 pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10];
5012 pNewJoinBssParam->u8OppEnable = 0;
5014 PRINT_D(GENERIC_DBG, "P2P Dump\n");
5015 for (i = 0; i < pu8IEs[index + 7]; i++)
5016 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
5018 pNewJoinBssParam->u8Count = pu8IEs[index + 11];
5019 u16P2P_count = index + 12;
5021 memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4);
5024 memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4);
5027 memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
5029 index += pu8IEs[index + 1] + 2;
5032 } else if ((pu8IEs[index] == RSN_IE) ||
5033 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
5034 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
5035 (pu8IEs[index + 5] == 0x01))) {
5036 u16 rsnIndex = index;
5038 if (pu8IEs[rsnIndex] == RSN_IE) {
5039 pNewJoinBssParam->mode_802_11i = 2;
5041 if (pNewJoinBssParam->mode_802_11i == 0)
5042 pNewJoinBssParam->mode_802_11i = 1;
5047 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
5049 jumpOffset = pu8IEs[rsnIndex] * 4;
5050 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
5053 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
5054 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
5056 pcipherTotalCount += pcipherCount;
5057 rsnIndex += jumpOffset;
5059 jumpOffset = pu8IEs[rsnIndex] * 4;
5061 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
5064 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
5065 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
5067 authTotalCount += authCount;
5068 rsnIndex += jumpOffset;
5070 if (pu8IEs[index] == RSN_IE) {
5071 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
5072 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
5075 pNewJoinBssParam->rsn_found = true;
5076 index += pu8IEs[index + 1] + 2;
5079 index += pu8IEs[index + 1] + 2;
5086 return (void *)pNewJoinBssParam;
5090 void host_int_freeJoinParams(void *pJoinParams)
5092 if ((struct bss_param *)pJoinParams != NULL)
5093 kfree((struct bss_param *)pJoinParams);
5095 PRINT_ER("Unable to FREE null pointer\n");
5098 s32 host_int_delBASession(struct host_if_drv *hif_drv, char *pBSSID, char TID)
5101 struct host_if_msg msg;
5102 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
5105 PRINT_ER("driver is null\n");
5109 memset(&msg, 0, sizeof(struct host_if_msg));
5111 msg.id = HOST_IF_MSG_DEL_BA_SESSION;
5113 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
5114 pBASessionInfo->u8Ted = TID;
5117 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5119 PRINT_ER("wilc_mq_send fail\n");
5121 down(&hWaitResponse);
5126 s32 host_int_del_All_Rx_BASession(struct host_if_drv *hif_drv,
5131 struct host_if_msg msg;
5132 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
5135 PRINT_ER("driver is null\n");
5139 memset(&msg, 0, sizeof(struct host_if_msg));
5141 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
5143 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
5144 pBASessionInfo->u8Ted = TID;
5147 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5149 PRINT_ER("wilc_mq_send fail\n");
5151 down(&hWaitResponse);
5156 s32 host_int_setup_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
5159 struct host_if_msg msg;
5164 PRINT_ER("driver is null\n");
5168 memset(&msg, 0, sizeof(struct host_if_msg));
5170 msg.id = HOST_IF_MSG_SET_IPADDRESS;
5172 msg.body.ip_info.au8IPAddr = u16ipadd;
5174 msg.body.ip_info.idx = idx;
5176 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5178 PRINT_ER("wilc_mq_send fail\n");
5185 s32 host_int_get_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
5188 struct host_if_msg msg;
5191 PRINT_ER("driver is null\n");
5195 memset(&msg, 0, sizeof(struct host_if_msg));
5197 msg.id = HOST_IF_MSG_GET_IPADDRESS;
5199 msg.body.ip_info.au8IPAddr = u16ipadd;
5201 msg.body.ip_info.idx = idx;
5203 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5205 PRINT_ER("wilc_mq_send fail\n");