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 result;
119 enum AUTHTYPE auth_type;
124 struct rcvd_async_info {
129 struct channel_attr {
142 struct set_multicast {
148 u8 del_all_sta[MAX_NUM_STA][ETH_ALEN];
153 u8 mac_addr[ETH_ALEN];
156 struct power_mgmt_param {
166 struct sta_inactive_t {
171 struct scan_attr scan_info;
172 struct connect_attr con_info;
173 struct rcvd_net_info net_info;
174 struct rcvd_async_info async_info;
175 struct key_attr key_info;
176 struct cfg_param_attr cfg_info;
177 struct channel_attr channel_info;
178 struct beacon_attr beacon_info;
179 struct add_sta_param add_sta_info;
180 struct del_sta del_sta_info;
181 struct add_sta_param edit_sta_info;
182 struct power_mgmt_param pwr_mgmt_info;
183 struct sta_inactive_t mac_info;
184 struct set_ip_addr ip_info;
185 struct drv_handler drv;
186 struct set_multicast multicast_info;
188 struct set_mac_addr set_mac_info;
189 struct get_mac_addr get_mac_info;
190 struct ba_session_info session_info;
191 struct remain_ch remain_on_ch;
192 struct reg_frame reg_frame;
194 struct del_all_sta del_all_sta_info;
199 union message_body body;
200 struct host_if_drv *drv;
203 struct join_bss_param {
209 char ssid[MAX_SSID_LEN];
211 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
218 u8 rsn_pcip_policy[3];
219 u8 rsn_auth_policy[3];
232 enum scan_conn_timer {
235 SCAN_CONNECT_TIMER_FORCE_32BIT = 0xFFFFFFFF
238 static struct host_if_drv *wfidrv_list[NUM_CONCURRENT_IFC + 1];
239 struct host_if_drv *terminated_handle;
240 struct host_if_drv *gWFiDrvHandle;
243 static struct task_struct *HostIFthreadHandler;
244 static WILC_MsgQueueHandle gMsgQHostIF;
245 static struct semaphore hSemHostIFthrdEnd;
247 struct semaphore hSemDeinitDrvHandle;
248 static struct semaphore hWaitResponse;
249 struct semaphore hSemHostIntDeinit;
250 struct timer_list g_hPeriodicRSSI;
254 u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
256 static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE];
258 bool gbScanWhileConnected;
263 static u8 gs8SetIP[2][4];
264 static u8 gs8GetIP[2][4];
265 static u32 gu32InactiveTime;
267 static u32 gu32WidConnRstHack;
269 u8 *gu8FlushedJoinReq;
270 u8 *gu8FlushedInfoElemAsoc;
271 u8 gu8Flushed11iMode;
272 u8 gu8FlushedAuthType;
273 u32 gu32FlushedJoinReqSize;
274 u32 gu32FlushedInfoElemAsocSize;
275 struct host_if_drv *gu8FlushedJoinReqDrvHandler;
276 #define REAL_JOIN_REQ 0
277 #define FLUSHED_JOIN_REQ 1
278 #define FLUSHED_BYTE_POS 79
280 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
282 extern void chip_sleep_manually(u32 u32SleepTime);
283 extern int linux_wlan_get_num_conn_ifcs(void);
285 static int add_handler_in_list(struct host_if_drv *handler)
289 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
290 if (!wfidrv_list[i]) {
291 wfidrv_list[i] = handler;
299 static int remove_handler_in_list(struct host_if_drv *handler)
303 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
304 if (wfidrv_list[i] == handler) {
305 wfidrv_list[i] = NULL;
313 static int get_id_from_handler(struct host_if_drv *handler)
320 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
321 if (wfidrv_list[i] == handler)
328 static struct host_if_drv *get_handler_from_id(int id)
330 if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list))
332 return wfidrv_list[id];
335 static s32 Handle_SetChannel(struct host_if_drv *hif_drv,
336 struct channel_attr *pstrHostIFSetChan)
342 strWID.id = (u16)WID_CURRENT_CHANNEL;
343 strWID.type = WID_CHAR;
344 strWID.val = (char *)&(pstrHostIFSetChan->set_ch);
345 strWID.size = sizeof(char);
347 PRINT_D(HOSTINF_DBG, "Setting channel\n");
349 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
350 get_id_from_handler(hif_drv));
352 PRINT_ER("Failed to set channel\n");
359 static s32 Handle_SetWfiDrvHandler(struct host_if_drv *hif_drv,
360 struct drv_handler *pstrHostIfSetDrvHandler)
366 strWID.id = (u16)WID_SET_DRV_HANDLER;
367 strWID.type = WID_INT;
368 strWID.val = (s8 *)&(pstrHostIfSetDrvHandler->u32Address);
369 strWID.size = sizeof(u32);
371 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
372 pstrHostIfSetDrvHandler->u32Address);
375 up(&hSemDeinitDrvHandle);
379 PRINT_ER("Failed to set driver handler\n");
386 static s32 Handle_SetOperationMode(struct host_if_drv *hif_drv,
387 struct op_mode *pstrHostIfSetOperationMode)
393 strWID.id = (u16)WID_SET_OPERATION_MODE;
394 strWID.type = WID_INT;
395 strWID.val = (s8 *)&(pstrHostIfSetOperationMode->u32Mode);
396 strWID.size = sizeof(u32);
398 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
399 get_id_from_handler(hif_drv));
402 if ((pstrHostIfSetOperationMode->u32Mode) == IDLE_MODE)
403 up(&hSemDeinitDrvHandle);
407 PRINT_ER("Failed to set driver handler\n");
414 s32 Handle_set_IPAddress(struct host_if_drv *hif_drv, u8 *pu8IPAddr, u8 idx)
419 char firmwareIPAddress[4] = {0};
421 if (pu8IPAddr[0] < 192)
424 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n", idx, pu8IPAddr);
426 memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN);
428 strWID.id = (u16)WID_IP_ADDRESS;
429 strWID.type = WID_STR;
430 strWID.val = (u8 *)pu8IPAddr;
431 strWID.size = IP_ALEN;
433 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
434 get_id_from_handler(hif_drv));
437 host_int_get_ipaddress(hif_drv, firmwareIPAddress, idx);
440 PRINT_ER("Failed to set IP address\n");
444 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
449 s32 Handle_get_IPAddress(struct host_if_drv *hif_drv, u8 *pu8IPAddr, u8 idx)
455 strWID.id = (u16)WID_IP_ADDRESS;
456 strWID.type = WID_STR;
457 strWID.val = kmalloc(IP_ALEN, GFP_KERNEL);
458 strWID.size = IP_ALEN;
460 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
461 get_id_from_handler(hif_drv));
463 PRINT_INFO(HOSTINF_DBG, "%pI4\n", strWID.val);
465 memcpy(gs8GetIP[idx], strWID.val, IP_ALEN);
469 if (memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0)
470 host_int_setup_ipaddress(hif_drv, gs8SetIP[idx], idx);
473 PRINT_ER("Failed to get IP address\n");
477 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
478 PRINT_INFO(HOSTINF_DBG, "%pI4\n", gs8GetIP[idx]);
479 PRINT_INFO(HOSTINF_DBG, "\n");
484 static s32 Handle_SetMacAddress(struct host_if_drv *hif_drv,
485 struct set_mac_addr *pstrHostIfSetMacAddress)
490 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
492 if (mac_buf == NULL) {
493 PRINT_ER("No buffer to send mac address\n");
496 memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
498 strWID.id = (u16)WID_MAC_ADDR;
499 strWID.type = WID_STR;
500 strWID.val = mac_buf;
501 strWID.size = ETH_ALEN;
502 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", strWID.val);
504 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
505 get_id_from_handler(hif_drv));
507 PRINT_ER("Failed to set mac address\n");
515 static s32 Handle_GetMacAddress(struct host_if_drv *hif_drv,
516 struct get_mac_addr *pstrHostIfGetMacAddress)
522 strWID.id = (u16)WID_MAC_ADDR;
523 strWID.type = WID_STR;
524 strWID.val = pstrHostIfGetMacAddress->u8MacAddress;
525 strWID.size = ETH_ALEN;
527 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
528 get_id_from_handler(hif_drv));
530 PRINT_ER("Failed to get mac address\n");
538 static s32 Handle_CfgParam(struct host_if_drv *hif_drv,
539 struct cfg_param_attr *strHostIFCfgParamAttr)
542 struct wid strWIDList[32];
545 down(&hif_drv->gtOsCfgValuesSem);
548 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
550 if (strHostIFCfgParamAttr->cfg_attr_info.flag & BSS_TYPE) {
551 if (strHostIFCfgParamAttr->cfg_attr_info.bss_type < 6) {
552 strWIDList[u8WidCnt].id = WID_BSS_TYPE;
553 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.bss_type;
554 strWIDList[u8WidCnt].type = WID_CHAR;
555 strWIDList[u8WidCnt].size = sizeof(char);
556 hif_drv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->cfg_attr_info.bss_type;
558 PRINT_ER("check value 6 over\n");
564 if (strHostIFCfgParamAttr->cfg_attr_info.flag & AUTH_TYPE) {
565 if ((strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 1 || (strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 2 || (strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 5) {
566 strWIDList[u8WidCnt].id = WID_AUTH_TYPE;
567 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.auth_type;
568 strWIDList[u8WidCnt].type = WID_CHAR;
569 strWIDList[u8WidCnt].size = sizeof(char);
570 hif_drv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->cfg_attr_info.auth_type;
572 PRINT_ER("Impossible value \n");
578 if (strHostIFCfgParamAttr->cfg_attr_info.flag & AUTHEN_TIMEOUT) {
579 if (strHostIFCfgParamAttr->cfg_attr_info.auth_timeout > 0 && strHostIFCfgParamAttr->cfg_attr_info.auth_timeout < 65536) {
580 strWIDList[u8WidCnt].id = WID_AUTH_TIMEOUT;
581 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.auth_timeout;
582 strWIDList[u8WidCnt].type = WID_SHORT;
583 strWIDList[u8WidCnt].size = sizeof(u16);
584 hif_drv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->cfg_attr_info.auth_timeout;
586 PRINT_ER("Range(1 ~ 65535) over\n");
592 if (strHostIFCfgParamAttr->cfg_attr_info.flag & POWER_MANAGEMENT) {
593 if (strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode < 5) {
594 strWIDList[u8WidCnt].id = WID_POWER_MANAGEMENT;
595 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode;
596 strWIDList[u8WidCnt].type = WID_CHAR;
597 strWIDList[u8WidCnt].size = sizeof(char);
598 hif_drv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode;
600 PRINT_ER("Invalide power mode\n");
606 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RETRY_SHORT) {
607 if ((strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit > 0) && (strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit < 256)) {
608 strWIDList[u8WidCnt].id = WID_SHORT_RETRY_LIMIT;
609 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit;
610 strWIDList[u8WidCnt].type = WID_SHORT;
611 strWIDList[u8WidCnt].size = sizeof(u16);
612 hif_drv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit;
614 PRINT_ER("Range(1~256) over\n");
620 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RETRY_LONG) {
621 if ((strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit > 0) && (strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit < 256)) {
622 strWIDList[u8WidCnt].id = WID_LONG_RETRY_LIMIT;
623 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit;
625 strWIDList[u8WidCnt].type = WID_SHORT;
626 strWIDList[u8WidCnt].size = sizeof(u16);
627 hif_drv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit;
629 PRINT_ER("Range(1~256) over\n");
635 if (strHostIFCfgParamAttr->cfg_attr_info.flag & FRAG_THRESHOLD) {
637 if (strHostIFCfgParamAttr->cfg_attr_info.frag_threshold > 255 && strHostIFCfgParamAttr->cfg_attr_info.frag_threshold < 7937) {
638 strWIDList[u8WidCnt].id = WID_FRAG_THRESHOLD;
639 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.frag_threshold;
640 strWIDList[u8WidCnt].type = WID_SHORT;
641 strWIDList[u8WidCnt].size = sizeof(u16);
642 hif_drv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->cfg_attr_info.frag_threshold;
644 PRINT_ER("Threshold Range fail\n");
650 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RTS_THRESHOLD) {
651 if (strHostIFCfgParamAttr->cfg_attr_info.rts_threshold > 255 && strHostIFCfgParamAttr->cfg_attr_info.rts_threshold < 65536) {
652 strWIDList[u8WidCnt].id = WID_RTS_THRESHOLD;
653 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.rts_threshold;
654 strWIDList[u8WidCnt].type = WID_SHORT;
655 strWIDList[u8WidCnt].size = sizeof(u16);
656 hif_drv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->cfg_attr_info.rts_threshold;
658 PRINT_ER("Threshold Range fail\n");
664 if (strHostIFCfgParamAttr->cfg_attr_info.flag & PREAMBLE) {
665 if (strHostIFCfgParamAttr->cfg_attr_info.preamble_type < 3) {
666 strWIDList[u8WidCnt].id = WID_PREAMBLE;
667 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.preamble_type;
668 strWIDList[u8WidCnt].type = WID_CHAR;
669 strWIDList[u8WidCnt].size = sizeof(char);
670 hif_drv->strCfgValues.preamble_type = strHostIFCfgParamAttr->cfg_attr_info.preamble_type;
672 PRINT_ER("Preamle Range(0~2) over\n");
678 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SHORT_SLOT_ALLOWED) {
679 if (strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed < 2) {
680 strWIDList[u8WidCnt].id = WID_SHORT_SLOT_ALLOWED;
681 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed;
682 strWIDList[u8WidCnt].type = WID_CHAR;
683 strWIDList[u8WidCnt].size = sizeof(char);
684 hif_drv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed;
686 PRINT_ER("Short slot(2) over\n");
692 if (strHostIFCfgParamAttr->cfg_attr_info.flag & TXOP_PROT_DISABLE) {
693 if (strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled < 2) {
694 strWIDList[u8WidCnt].id = WID_11N_TXOP_PROT_DISABLE;
695 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled;
696 strWIDList[u8WidCnt].type = WID_CHAR;
697 strWIDList[u8WidCnt].size = sizeof(char);
698 hif_drv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled;
700 PRINT_ER("TXOP prot disable\n");
706 if (strHostIFCfgParamAttr->cfg_attr_info.flag & BEACON_INTERVAL) {
707 if (strHostIFCfgParamAttr->cfg_attr_info.beacon_interval > 0 && strHostIFCfgParamAttr->cfg_attr_info.beacon_interval < 65536) {
708 strWIDList[u8WidCnt].id = WID_BEACON_INTERVAL;
709 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.beacon_interval;
710 strWIDList[u8WidCnt].type = WID_SHORT;
711 strWIDList[u8WidCnt].size = sizeof(u16);
712 hif_drv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->cfg_attr_info.beacon_interval;
714 PRINT_ER("Beacon interval(1~65535) fail\n");
720 if (strHostIFCfgParamAttr->cfg_attr_info.flag & DTIM_PERIOD) {
721 if (strHostIFCfgParamAttr->cfg_attr_info.dtim_period > 0 && strHostIFCfgParamAttr->cfg_attr_info.dtim_period < 256) {
722 strWIDList[u8WidCnt].id = WID_DTIM_PERIOD;
723 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.dtim_period;
724 strWIDList[u8WidCnt].type = WID_CHAR;
725 strWIDList[u8WidCnt].size = sizeof(char);
726 hif_drv->strCfgValues.dtim_period = strHostIFCfgParamAttr->cfg_attr_info.dtim_period;
728 PRINT_ER("DTIM range(1~255) fail\n");
734 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SITE_SURVEY) {
735 if (strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled < 3) {
736 strWIDList[u8WidCnt].id = WID_SITE_SURVEY;
737 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled;
738 strWIDList[u8WidCnt].type = WID_CHAR;
739 strWIDList[u8WidCnt].size = sizeof(char);
740 hif_drv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled;
742 PRINT_ER("Site survey disable\n");
748 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SITE_SURVEY_SCAN_TIME) {
749 if (strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time < 65536) {
750 strWIDList[u8WidCnt].id = WID_SITE_SURVEY_SCAN_TIME;
751 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time;
752 strWIDList[u8WidCnt].type = WID_SHORT;
753 strWIDList[u8WidCnt].size = sizeof(u16);
754 hif_drv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time;
756 PRINT_ER("Site survey scan time(1~65535) over\n");
762 if (strHostIFCfgParamAttr->cfg_attr_info.flag & ACTIVE_SCANTIME) {
763 if (strHostIFCfgParamAttr->cfg_attr_info.active_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.active_scan_time < 65536) {
764 strWIDList[u8WidCnt].id = WID_ACTIVE_SCAN_TIME;
765 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.active_scan_time;
766 strWIDList[u8WidCnt].type = WID_SHORT;
767 strWIDList[u8WidCnt].size = sizeof(u16);
768 hif_drv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->cfg_attr_info.active_scan_time;
770 PRINT_ER("Active scan time(1~65535) over\n");
776 if (strHostIFCfgParamAttr->cfg_attr_info.flag & PASSIVE_SCANTIME) {
777 if (strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time < 65536) {
778 strWIDList[u8WidCnt].id = WID_PASSIVE_SCAN_TIME;
779 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time;
780 strWIDList[u8WidCnt].type = WID_SHORT;
781 strWIDList[u8WidCnt].size = sizeof(u16);
782 hif_drv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time;
784 PRINT_ER("Passive scan time(1~65535) over\n");
790 if (strHostIFCfgParamAttr->cfg_attr_info.flag & CURRENT_TX_RATE) {
791 enum CURRENT_TXRATE curr_tx_rate = strHostIFCfgParamAttr->cfg_attr_info.curr_tx_rate;
792 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
793 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
794 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
795 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
796 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
797 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
798 strWIDList[u8WidCnt].id = WID_CURRENT_TX_RATE;
799 strWIDList[u8WidCnt].val = (s8 *)&curr_tx_rate;
800 strWIDList[u8WidCnt].type = WID_SHORT;
801 strWIDList[u8WidCnt].size = sizeof(u16);
802 hif_drv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
804 PRINT_ER("out of TX rate\n");
810 s32Error = send_config_pkt(SET_CFG, strWIDList, u8WidCnt,
811 get_id_from_handler(hif_drv));
814 PRINT_ER("Error in setting CFG params\n");
817 up(&hif_drv->gtOsCfgValuesSem);
821 static s32 Handle_wait_msg_q_empty(void)
823 g_wilc_initialized = 0;
828 static s32 Handle_Scan(struct host_if_drv *hif_drv,
829 struct scan_attr *pstrHostIFscanAttr)
832 struct wid strWIDList[5];
833 u32 u32WidsCount = 0;
837 u8 *pu8HdnNtwrksWidVal = NULL;
839 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
840 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", hif_drv->enuHostIFstate);
842 hif_drv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->result;
843 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->arg;
845 if ((hif_drv->enuHostIFstate >= HOST_IF_SCANNING) && (hif_drv->enuHostIFstate < HOST_IF_CONNECTED)) {
846 PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", hif_drv->enuHostIFstate);
847 PRINT_ER("Already scan\n");
852 if (g_obtainingIP || connecting) {
853 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
854 PRINT_ER("Don't do obss scan\n");
859 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
862 hif_drv->strWILC_UsrScanReq.u32RcvdChCount = 0;
864 strWIDList[u32WidsCount].id = (u16)WID_SSID_PROBE_REQ;
865 strWIDList[u32WidsCount].type = WID_STR;
867 for (i = 0; i < pstrHostIFscanAttr->hidden_network.u8ssidnum; i++)
868 valuesize += ((pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
869 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
870 strWIDList[u32WidsCount].val = pu8HdnNtwrksWidVal;
871 if (strWIDList[u32WidsCount].val != NULL) {
872 pu8Buffer = strWIDList[u32WidsCount].val;
874 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.u8ssidnum;
876 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->hidden_network.u8ssidnum);
878 for (i = 0; i < pstrHostIFscanAttr->hidden_network.u8ssidnum; i++) {
879 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen;
880 memcpy(pu8Buffer, pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen);
881 pu8Buffer += pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen;
886 strWIDList[u32WidsCount].size = (s32)(valuesize + 1);
891 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_PROBE;
892 strWIDList[u32WidsCount].type = WID_BIN_DATA;
893 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ies;
894 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ies_len;
898 strWIDList[u32WidsCount].id = WID_SCAN_TYPE;
899 strWIDList[u32WidsCount].type = WID_CHAR;
900 strWIDList[u32WidsCount].size = sizeof(char);
901 strWIDList[u32WidsCount].val = (s8 *)(&(pstrHostIFscanAttr->type));
904 strWIDList[u32WidsCount].id = WID_SCAN_CHANNEL_LIST;
905 strWIDList[u32WidsCount].type = WID_BIN_DATA;
907 if (pstrHostIFscanAttr->ch_freq_list != NULL && pstrHostIFscanAttr->ch_list_len > 0) {
910 for (i = 0; i < pstrHostIFscanAttr->ch_list_len; i++) {
911 if (pstrHostIFscanAttr->ch_freq_list[i] > 0)
912 pstrHostIFscanAttr->ch_freq_list[i] = pstrHostIFscanAttr->ch_freq_list[i] - 1;
916 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ch_freq_list;
917 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ch_list_len;
920 strWIDList[u32WidsCount].id = WID_START_SCAN_REQ;
921 strWIDList[u32WidsCount].type = WID_CHAR;
922 strWIDList[u32WidsCount].size = sizeof(char);
923 strWIDList[u32WidsCount].val = (s8 *)(&(pstrHostIFscanAttr->src));
926 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)
927 gbScanWhileConnected = true;
928 else if (hif_drv->enuHostIFstate == HOST_IF_IDLE)
929 gbScanWhileConnected = false;
931 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
932 get_id_from_handler(hif_drv));
935 PRINT_ER("Failed to send scan paramters config packet\n");
937 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
941 del_timer(&hif_drv->hScanTimer);
942 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
945 if (pstrHostIFscanAttr->ch_freq_list != NULL) {
946 kfree(pstrHostIFscanAttr->ch_freq_list);
947 pstrHostIFscanAttr->ch_freq_list = NULL;
950 if (pstrHostIFscanAttr->ies != NULL) {
951 kfree(pstrHostIFscanAttr->ies);
952 pstrHostIFscanAttr->ies = NULL;
954 if (pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo != NULL) {
955 kfree(pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo);
956 pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo = NULL;
959 if (pu8HdnNtwrksWidVal != NULL)
960 kfree(pu8HdnNtwrksWidVal);
965 static s32 Handle_ScanDone(struct host_if_drv *hif_drv,
966 enum scan_event enuEvent)
969 u8 u8abort_running_scan;
973 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
975 if (enuEvent == SCAN_EVENT_ABORTED) {
976 PRINT_D(GENERIC_DBG, "Abort running scan\n");
977 u8abort_running_scan = 1;
978 strWID.id = (u16)WID_ABORT_RUNNING_SCAN;
979 strWID.type = WID_CHAR;
980 strWID.val = (s8 *)&u8abort_running_scan;
981 strWID.size = sizeof(char);
983 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
984 get_id_from_handler(hif_drv));
986 PRINT_ER("Failed to set abort running scan\n");
992 PRINT_ER("Driver handler is NULL\n");
996 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
997 hif_drv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
998 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
999 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
1005 u8 u8ConnectedSSID[6] = {0};
1006 static s32 Handle_Connect(struct host_if_drv *hif_drv,
1007 struct connect_attr *pstrHostIFconnectAttr)
1010 struct wid strWIDList[8];
1011 u32 u32WidsCount = 0, dummyval = 0;
1012 u8 *pu8CurrByte = NULL;
1013 struct join_bss_param *ptstrJoinBssParam;
1015 PRINT_D(GENERIC_DBG, "Handling connect request\n");
1017 if (memcmp(pstrHostIFconnectAttr->bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
1020 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1024 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1026 ptstrJoinBssParam = (struct join_bss_param *)pstrHostIFconnectAttr->params;
1027 if (ptstrJoinBssParam == NULL) {
1028 PRINT_ER("Required BSSID not found\n");
1033 if (pstrHostIFconnectAttr->bssid != NULL) {
1034 hif_drv->strWILC_UsrConnReq.pu8bssid = kmalloc(6, GFP_KERNEL);
1035 memcpy(hif_drv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->bssid, 6);
1038 hif_drv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssid_len;
1039 if (pstrHostIFconnectAttr->ssid != NULL) {
1040 hif_drv->strWILC_UsrConnReq.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssid_len + 1, GFP_KERNEL);
1041 memcpy(hif_drv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->ssid,
1042 pstrHostIFconnectAttr->ssid_len);
1043 hif_drv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssid_len] = '\0';
1046 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->ies_len;
1047 if (pstrHostIFconnectAttr->ies != NULL) {
1048 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
1049 memcpy(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->ies,
1050 pstrHostIFconnectAttr->ies_len);
1053 hif_drv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->security;
1054 hif_drv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->auth_type;
1055 hif_drv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->result;
1056 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->arg;
1058 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
1059 strWIDList[u32WidsCount].type = WID_INT;
1060 strWIDList[u32WidsCount].size = sizeof(u32);
1061 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1064 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
1065 strWIDList[u32WidsCount].type = WID_INT;
1066 strWIDList[u32WidsCount].size = sizeof(u32);
1067 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1070 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
1071 strWIDList[u32WidsCount].type = WID_INT;
1072 strWIDList[u32WidsCount].size = sizeof(u32);
1073 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1077 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
1078 strWIDList[u32WidsCount].type = WID_BIN_DATA;
1079 strWIDList[u32WidsCount].val = hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs;
1080 strWIDList[u32WidsCount].size = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1083 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1085 gu32FlushedInfoElemAsocSize = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1086 gu8FlushedInfoElemAsoc = kmalloc(gu32FlushedInfoElemAsocSize, GFP_KERNEL);
1087 memcpy(gu8FlushedInfoElemAsoc, hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
1088 gu32FlushedInfoElemAsocSize);
1091 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
1092 strWIDList[u32WidsCount].type = WID_CHAR;
1093 strWIDList[u32WidsCount].size = sizeof(char);
1094 strWIDList[u32WidsCount].val = (s8 *)(&(hif_drv->strWILC_UsrConnReq.u8security));
1097 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
1098 gu8Flushed11iMode = hif_drv->strWILC_UsrConnReq.u8security;
1100 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", hif_drv->strWILC_UsrConnReq.u8security);
1103 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
1104 strWIDList[u32WidsCount].type = WID_CHAR;
1105 strWIDList[u32WidsCount].size = sizeof(char);
1106 strWIDList[u32WidsCount].val = (s8 *)(&hif_drv->strWILC_UsrConnReq.tenuAuth_type);
1109 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
1110 gu8FlushedAuthType = (u8)hif_drv->strWILC_UsrConnReq.tenuAuth_type;
1112 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", hif_drv->strWILC_UsrConnReq.tenuAuth_type);
1113 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
1114 hif_drv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->ch);
1116 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
1117 strWIDList[u32WidsCount].type = WID_STR;
1118 strWIDList[u32WidsCount].size = 112;
1119 strWIDList[u32WidsCount].val = kmalloc(strWIDList[u32WidsCount].size, GFP_KERNEL);
1121 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1122 gu32FlushedJoinReqSize = strWIDList[u32WidsCount].size;
1123 gu8FlushedJoinReq = kmalloc(gu32FlushedJoinReqSize, GFP_KERNEL);
1125 if (strWIDList[u32WidsCount].val == NULL) {
1130 pu8CurrByte = strWIDList[u32WidsCount].val;
1133 if (pstrHostIFconnectAttr->ssid != NULL) {
1134 memcpy(pu8CurrByte, pstrHostIFconnectAttr->ssid, pstrHostIFconnectAttr->ssid_len);
1135 pu8CurrByte[pstrHostIFconnectAttr->ssid_len] = '\0';
1137 pu8CurrByte += MAX_SSID_LEN;
1138 *(pu8CurrByte++) = INFRASTRUCTURE;
1140 if ((pstrHostIFconnectAttr->ch >= 1) && (pstrHostIFconnectAttr->ch <= 14)) {
1141 *(pu8CurrByte++) = pstrHostIFconnectAttr->ch;
1143 PRINT_ER("Channel out of range\n");
1144 *(pu8CurrByte++) = 0xFF;
1146 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1147 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1148 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1150 if (pstrHostIFconnectAttr->bssid != NULL)
1151 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
1154 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1155 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1156 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1157 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1158 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1160 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
1161 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1163 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1164 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1165 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1167 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1168 hif_drv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
1170 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1171 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1172 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1173 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1174 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1175 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1177 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
1178 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1180 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
1181 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1183 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
1184 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1186 *(pu8CurrByte++) = REAL_JOIN_REQ;
1188 *(pu8CurrByte++) = ptstrJoinBssParam->u8NoaEnbaled;
1189 if (ptstrJoinBssParam->u8NoaEnbaled) {
1190 PRINT_D(HOSTINF_DBG, "NOA present\n");
1192 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1193 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1194 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1195 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1197 *(pu8CurrByte++) = ptstrJoinBssParam->u8Index;
1199 *(pu8CurrByte++) = ptstrJoinBssParam->u8OppEnable;
1201 if (ptstrJoinBssParam->u8OppEnable)
1202 *(pu8CurrByte++) = ptstrJoinBssParam->u8CtWindow;
1204 *(pu8CurrByte++) = ptstrJoinBssParam->u8Count;
1206 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Duration, sizeof(ptstrJoinBssParam->au8Duration));
1208 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Duration);
1210 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Interval, sizeof(ptstrJoinBssParam->au8Interval));
1212 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Interval);
1214 memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
1216 pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1219 PRINT_D(HOSTINF_DBG, "NOA not present\n");
1221 pu8CurrByte = strWIDList[u32WidsCount].val;
1223 gu32WidConnRstHack = 0;
1225 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1226 memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
1227 gu8FlushedJoinReqDrvHandler = hif_drv;
1230 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1232 if (pstrHostIFconnectAttr->bssid != NULL) {
1233 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->bssid, ETH_ALEN);
1235 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n", pstrHostIFconnectAttr->bssid);
1236 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", u8ConnectedSSID);
1239 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
1240 get_id_from_handler(hif_drv));
1242 PRINT_ER("failed to send config packet\n");
1246 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
1247 hif_drv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1252 tstrConnectInfo strConnectInfo;
1254 del_timer(&hif_drv->hConnectTimer);
1256 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
1258 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1260 if (pstrHostIFconnectAttr->result != NULL) {
1261 if (pstrHostIFconnectAttr->bssid != NULL)
1262 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->bssid, 6);
1264 if (pstrHostIFconnectAttr->ies != NULL) {
1265 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->ies_len;
1266 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
1267 memcpy(strConnectInfo.pu8ReqIEs,
1268 pstrHostIFconnectAttr->ies,
1269 pstrHostIFconnectAttr->ies_len);
1272 pstrHostIFconnectAttr->result(CONN_DISCONN_EVENT_CONN_RESP,
1276 pstrHostIFconnectAttr->arg);
1277 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1278 if (strConnectInfo.pu8ReqIEs != NULL) {
1279 kfree(strConnectInfo.pu8ReqIEs);
1280 strConnectInfo.pu8ReqIEs = NULL;
1284 PRINT_ER("Connect callback function pointer is NULL\n");
1288 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
1289 if (pstrHostIFconnectAttr->bssid != NULL) {
1290 kfree(pstrHostIFconnectAttr->bssid);
1291 pstrHostIFconnectAttr->bssid = NULL;
1294 if (pstrHostIFconnectAttr->ssid != NULL) {
1295 kfree(pstrHostIFconnectAttr->ssid);
1296 pstrHostIFconnectAttr->ssid = NULL;
1299 if (pstrHostIFconnectAttr->ies != NULL) {
1300 kfree(pstrHostIFconnectAttr->ies);
1301 pstrHostIFconnectAttr->ies = NULL;
1304 if (pu8CurrByte != NULL)
1309 static s32 Handle_FlushConnect(struct host_if_drv *hif_drv)
1312 struct wid strWIDList[5];
1313 u32 u32WidsCount = 0;
1314 u8 *pu8CurrByte = NULL;
1316 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
1317 strWIDList[u32WidsCount].type = WID_BIN_DATA;
1318 strWIDList[u32WidsCount].val = gu8FlushedInfoElemAsoc;
1319 strWIDList[u32WidsCount].size = gu32FlushedInfoElemAsocSize;
1322 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
1323 strWIDList[u32WidsCount].type = WID_CHAR;
1324 strWIDList[u32WidsCount].size = sizeof(char);
1325 strWIDList[u32WidsCount].val = (s8 *)(&(gu8Flushed11iMode));
1330 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
1331 strWIDList[u32WidsCount].type = WID_CHAR;
1332 strWIDList[u32WidsCount].size = sizeof(char);
1333 strWIDList[u32WidsCount].val = (s8 *)(&gu8FlushedAuthType);
1336 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
1337 strWIDList[u32WidsCount].type = WID_STR;
1338 strWIDList[u32WidsCount].size = gu32FlushedJoinReqSize;
1339 strWIDList[u32WidsCount].val = (s8 *)gu8FlushedJoinReq;
1340 pu8CurrByte = strWIDList[u32WidsCount].val;
1342 pu8CurrByte += FLUSHED_BYTE_POS;
1343 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1347 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
1348 get_id_from_handler(gu8FlushedJoinReqDrvHandler));
1350 PRINT_ER("failed to send config packet\n");
1357 static s32 Handle_ConnectTimeout(struct host_if_drv *hif_drv)
1360 tstrConnectInfo strConnectInfo;
1362 u16 u16DummyReasonCode = 0;
1365 PRINT_ER("Driver handler is NULL\n");
1369 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1371 gbScanWhileConnected = false;
1374 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1376 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
1377 if (hif_drv->strWILC_UsrConnReq.pu8bssid != NULL) {
1378 memcpy(strConnectInfo.au8bssid,
1379 hif_drv->strWILC_UsrConnReq.pu8bssid, 6);
1382 if (hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1383 strConnectInfo.ReqIEsLen = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1384 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
1385 memcpy(strConnectInfo.pu8ReqIEs,
1386 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
1387 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen);
1390 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1394 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
1396 if (strConnectInfo.pu8ReqIEs != NULL) {
1397 kfree(strConnectInfo.pu8ReqIEs);
1398 strConnectInfo.pu8ReqIEs = NULL;
1401 PRINT_ER("Connect callback function pointer is NULL\n");
1404 strWID.id = (u16)WID_DISCONNECT;
1405 strWID.type = WID_CHAR;
1406 strWID.val = (s8 *)&u16DummyReasonCode;
1407 strWID.size = sizeof(char);
1409 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1411 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1412 get_id_from_handler(hif_drv));
1414 PRINT_ER("Failed to send dissconect config packet\n");
1416 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
1417 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
1418 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
1419 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1420 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
1422 eth_zero_addr(u8ConnectedSSID);
1424 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
1425 kfree(gu8FlushedJoinReq);
1426 gu8FlushedJoinReq = NULL;
1428 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
1429 kfree(gu8FlushedInfoElemAsoc);
1430 gu8FlushedInfoElemAsoc = NULL;
1436 static s32 Handle_RcvdNtwrkInfo(struct host_if_drv *hif_drv,
1437 struct rcvd_net_info *pstrRcvdNetworkInfo)
1440 bool bNewNtwrkFound;
1445 tstrNetworkInfo *pstrNetworkInfo = NULL;
1446 void *pJoinParams = NULL;
1448 bNewNtwrkFound = true;
1449 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
1451 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
1452 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
1453 parse_network_info(pstrRcvdNetworkInfo->buffer, &pstrNetworkInfo);
1454 if ((pstrNetworkInfo == NULL)
1455 || (hif_drv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
1456 PRINT_ER("driver is null\n");
1461 for (i = 0; i < hif_drv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
1463 if ((hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
1464 (pstrNetworkInfo->au8bssid != NULL)) {
1465 if (memcmp(hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
1466 pstrNetworkInfo->au8bssid, 6) == 0) {
1467 if (pstrNetworkInfo->s8rssi <= hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
1468 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
1471 hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
1472 bNewNtwrkFound = false;
1479 if (bNewNtwrkFound == true) {
1480 PRINT_D(HOSTINF_DBG, "New network found\n");
1482 if (hif_drv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
1483 hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
1485 if ((hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
1486 && (pstrNetworkInfo->au8bssid != NULL)) {
1487 memcpy(hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
1488 pstrNetworkInfo->au8bssid, 6);
1490 hif_drv->strWILC_UsrScanReq.u32RcvdChCount++;
1492 pstrNetworkInfo->bNewNetwork = true;
1493 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
1495 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1496 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid,
1502 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
1505 pstrNetworkInfo->bNewNetwork = false;
1506 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1507 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
1512 if (pstrRcvdNetworkInfo->buffer != NULL) {
1513 kfree(pstrRcvdNetworkInfo->buffer);
1514 pstrRcvdNetworkInfo->buffer = NULL;
1517 if (pstrNetworkInfo != NULL) {
1518 DeallocateNetworkInfo(pstrNetworkInfo);
1519 pstrNetworkInfo = NULL;
1525 static s32 Handle_RcvdGnrlAsyncInfo(struct host_if_drv *hif_drv,
1526 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
1532 u16 u16WidID = (u16)WID_NIL;
1535 u8 u8MacStatusReasonCode;
1536 u8 u8MacStatusAdditionalInfo;
1537 tstrConnectInfo strConnectInfo;
1538 tstrDisconnectNotifInfo strDisconnectNotifInfo;
1542 PRINT_ER("Driver handler is NULL\n");
1545 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", hif_drv->enuHostIFstate,
1546 pstrRcvdGnrlAsyncInfo->buffer[7]);
1548 if ((hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
1549 (hif_drv->enuHostIFstate == HOST_IF_CONNECTED) ||
1550 hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
1551 if ((pstrRcvdGnrlAsyncInfo->buffer == NULL) ||
1552 (hif_drv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
1553 PRINT_ER("driver is null\n");
1557 u8MsgType = pstrRcvdGnrlAsyncInfo->buffer[0];
1559 if ('I' != u8MsgType) {
1560 PRINT_ER("Received Message format incorrect.\n");
1564 u8MsgID = pstrRcvdGnrlAsyncInfo->buffer[1];
1565 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[2], pstrRcvdGnrlAsyncInfo->buffer[3]);
1566 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[4], pstrRcvdGnrlAsyncInfo->buffer[5]);
1567 u8WidLen = pstrRcvdGnrlAsyncInfo->buffer[6];
1568 u8MacStatus = pstrRcvdGnrlAsyncInfo->buffer[7];
1569 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->buffer[8];
1570 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->buffer[9];
1571 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
1572 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
1573 u32 u32RcvdAssocRespInfoLen;
1574 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
1576 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
1578 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1580 if (u8MacStatus == MAC_CONNECTED) {
1581 memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
1583 host_int_get_assoc_res_info(hif_drv,
1585 MAX_ASSOC_RESP_FRAME_SIZE,
1586 &u32RcvdAssocRespInfoLen);
1588 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
1590 if (u32RcvdAssocRespInfoLen != 0) {
1592 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
1593 s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
1594 &pstrConnectRespInfo);
1596 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
1598 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
1600 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
1601 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
1602 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
1603 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
1606 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL);
1607 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
1608 pstrConnectRespInfo->u16RespIEsLen);
1612 if (pstrConnectRespInfo != NULL) {
1613 DeallocateAssocRespInfo(pstrConnectRespInfo);
1614 pstrConnectRespInfo = NULL;
1620 if ((u8MacStatus == MAC_CONNECTED) &&
1621 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
1622 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
1623 eth_zero_addr(u8ConnectedSSID);
1625 } else if (u8MacStatus == MAC_DISCONNECTED) {
1626 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
1627 eth_zero_addr(u8ConnectedSSID);
1630 if (hif_drv->strWILC_UsrConnReq.pu8bssid != NULL) {
1631 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
1632 memcpy(strConnectInfo.au8bssid, hif_drv->strWILC_UsrConnReq.pu8bssid, 6);
1634 if ((u8MacStatus == MAC_CONNECTED) &&
1635 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
1636 memcpy(hif_drv->au8AssociatedBSSID,
1637 hif_drv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
1642 if (hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1643 strConnectInfo.ReqIEsLen = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1644 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
1645 memcpy(strConnectInfo.pu8ReqIEs,
1646 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
1647 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen);
1651 del_timer(&hif_drv->hConnectTimer);
1652 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1656 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
1658 if ((u8MacStatus == MAC_CONNECTED) &&
1659 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
1660 host_int_set_power_mgmt(hif_drv, 0, 0);
1662 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
1663 hif_drv->enuHostIFstate = HOST_IF_CONNECTED;
1665 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
1666 g_obtainingIP = true;
1667 mod_timer(&hDuringIpTimer,
1668 jiffies + msecs_to_jiffies(10000));
1670 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
1671 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1672 gbScanWhileConnected = false;
1675 if (strConnectInfo.pu8RespIEs != NULL) {
1676 kfree(strConnectInfo.pu8RespIEs);
1677 strConnectInfo.pu8RespIEs = NULL;
1680 if (strConnectInfo.pu8ReqIEs != NULL) {
1681 kfree(strConnectInfo.pu8ReqIEs);
1682 strConnectInfo.pu8ReqIEs = NULL;
1684 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
1685 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
1686 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
1687 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1688 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
1689 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
1690 (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)) {
1691 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
1693 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
1695 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
1696 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
1697 del_timer(&hif_drv->hScanTimer);
1698 Handle_ScanDone((void *)hif_drv, SCAN_EVENT_ABORTED);
1701 strDisconnectNotifInfo.u16reason = 0;
1702 strDisconnectNotifInfo.ie = NULL;
1703 strDisconnectNotifInfo.ie_len = 0;
1705 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
1706 g_obtainingIP = false;
1707 host_int_set_power_mgmt(hif_drv, 0, 0);
1709 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1712 &strDisconnectNotifInfo,
1713 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
1716 PRINT_ER("Connect result callback function is NULL\n");
1719 eth_zero_addr(hif_drv->au8AssociatedBSSID);
1721 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
1722 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
1723 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
1724 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1725 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
1727 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
1728 kfree(gu8FlushedJoinReq);
1729 gu8FlushedJoinReq = NULL;
1731 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
1732 kfree(gu8FlushedInfoElemAsoc);
1733 gu8FlushedInfoElemAsoc = NULL;
1736 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1737 gbScanWhileConnected = false;
1739 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
1740 (hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
1741 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
1742 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
1744 del_timer(&hif_drv->hScanTimer);
1745 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult)
1746 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
1752 if (pstrRcvdGnrlAsyncInfo->buffer != NULL) {
1753 kfree(pstrRcvdGnrlAsyncInfo->buffer);
1754 pstrRcvdGnrlAsyncInfo->buffer = NULL;
1760 static int Handle_Key(struct host_if_drv *hif_drv,
1761 struct key_attr *pstrHostIFkeyAttr)
1765 struct wid strWIDList[5];
1771 switch (pstrHostIFkeyAttr->type) {
1776 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1778 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
1779 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->attr.wep.index));
1780 strWIDList[0].id = (u16)WID_11I_MODE;
1781 strWIDList[0].type = WID_CHAR;
1782 strWIDList[0].size = sizeof(char);
1783 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.mode));
1785 strWIDList[1].id = WID_AUTH_TYPE;
1786 strWIDList[1].type = WID_CHAR;
1787 strWIDList[1].size = sizeof(char);
1788 strWIDList[1].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.auth_type));
1790 strWIDList[2].id = (u16)WID_KEY_ID;
1791 strWIDList[2].type = WID_CHAR;
1793 strWIDList[2].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.index));
1794 strWIDList[2].size = sizeof(char);
1796 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len, GFP_KERNEL);
1798 if (pu8keybuf == NULL) {
1799 PRINT_ER("No buffer to send Key\n");
1803 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wep.key,
1804 pstrHostIFkeyAttr->attr.wep.key_len);
1806 kfree(pstrHostIFkeyAttr->attr.wep.key);
1808 strWIDList[3].id = (u16)WID_WEP_KEY_VALUE;
1809 strWIDList[3].type = WID_STR;
1810 strWIDList[3].size = pstrHostIFkeyAttr->attr.wep.key_len;
1811 strWIDList[3].val = (s8 *)pu8keybuf;
1814 s32Error = send_config_pkt(SET_CFG, strWIDList, 4,
1815 get_id_from_handler(hif_drv));
1821 if (pstrHostIFkeyAttr->action & ADDKEY) {
1822 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
1823 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2, GFP_KERNEL);
1824 if (pu8keybuf == NULL) {
1825 PRINT_ER("No buffer to send Key\n");
1828 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1829 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->attr.wep.key_len, 1);
1830 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->attr.wep.key,
1831 pstrHostIFkeyAttr->attr.wep.key_len);
1832 kfree(pstrHostIFkeyAttr->attr.wep.key);
1834 strWID.id = (u16)WID_ADD_WEP_KEY;
1835 strWID.type = WID_STR;
1836 strWID.val = (s8 *)pu8keybuf;
1837 strWID.size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
1839 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1840 get_id_from_handler(hif_drv));
1842 } else if (pstrHostIFkeyAttr->action & REMOVEKEY) {
1844 PRINT_D(HOSTINF_DBG, "Removing key\n");
1845 strWID.id = (u16)WID_REMOVE_WEP_KEY;
1846 strWID.type = WID_STR;
1848 s8idxarray[0] = (s8)pstrHostIFkeyAttr->attr.wep.index;
1849 strWID.val = s8idxarray;
1852 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1853 get_id_from_handler(hif_drv));
1855 strWID.id = (u16)WID_KEY_ID;
1856 strWID.type = WID_CHAR;
1857 strWID.val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.index));
1858 strWID.size = sizeof(char);
1860 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
1862 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1863 get_id_from_handler(hif_drv));
1865 up(&hif_drv->hSemTestKeyBlock);
1869 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1870 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1871 if (pu8keybuf == NULL) {
1872 PRINT_ER("No buffer to send RxGTK Key\n");
1874 goto _WPARxGtk_end_case_;
1877 if (pstrHostIFkeyAttr->attr.wpa.seq != NULL)
1878 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1880 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1881 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1882 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1883 pstrHostIFkeyAttr->attr.wpa.key_len);
1885 strWIDList[0].id = (u16)WID_11I_MODE;
1886 strWIDList[0].type = WID_CHAR;
1887 strWIDList[0].size = sizeof(char);
1888 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wpa.mode));
1890 strWIDList[1].id = (u16)WID_ADD_RX_GTK;
1891 strWIDList[1].type = WID_STR;
1892 strWIDList[1].val = (s8 *)pu8keybuf;
1893 strWIDList[1].size = RX_MIC_KEY_MSG_LEN;
1895 s32Error = send_config_pkt(SET_CFG, strWIDList, 2,
1896 get_id_from_handler(hif_drv));
1899 up(&hif_drv->hSemTestKeyBlock);
1902 if (pstrHostIFkeyAttr->action & ADDKEY) {
1903 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
1905 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1906 if (pu8keybuf == NULL) {
1907 PRINT_ER("No buffer to send RxGTK Key\n");
1909 goto _WPARxGtk_end_case_;
1912 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)
1913 memcpy(pu8keybuf, hif_drv->au8AssociatedBSSID, ETH_ALEN);
1915 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
1917 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1918 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1919 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1920 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1921 pstrHostIFkeyAttr->attr.wpa.key_len);
1923 strWID.id = (u16)WID_ADD_RX_GTK;
1924 strWID.type = WID_STR;
1925 strWID.val = (s8 *)pu8keybuf;
1926 strWID.size = RX_MIC_KEY_MSG_LEN;
1928 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1929 get_id_from_handler(hif_drv));
1932 up(&hif_drv->hSemTestKeyBlock);
1934 _WPARxGtk_end_case_:
1935 kfree(pstrHostIFkeyAttr->attr.wpa.key);
1936 kfree(pstrHostIFkeyAttr->attr.wpa.seq);
1943 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1946 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
1950 if (pu8keybuf == NULL) {
1951 PRINT_ER("No buffer to send PTK Key\n");
1953 goto _WPAPtk_end_case_;
1957 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1958 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1959 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1960 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->attr.wpa.key,
1961 pstrHostIFkeyAttr->attr.wpa.key_len);
1963 strWIDList[0].id = (u16)WID_11I_MODE;
1964 strWIDList[0].type = WID_CHAR;
1965 strWIDList[0].size = sizeof(char);
1966 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wpa.mode));
1968 strWIDList[1].id = (u16)WID_ADD_PTK;
1969 strWIDList[1].type = WID_STR;
1970 strWIDList[1].val = (s8 *)pu8keybuf;
1971 strWIDList[1].size = PTK_KEY_MSG_LEN + 1;
1973 s32Error = send_config_pkt(SET_CFG, strWIDList, 2,
1974 get_id_from_handler(hif_drv));
1976 up(&hif_drv->hSemTestKeyBlock);
1978 if (pstrHostIFkeyAttr->action & ADDKEY) {
1981 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
1985 if (pu8keybuf == NULL) {
1986 PRINT_ER("No buffer to send PTK Key\n");
1988 goto _WPAPtk_end_case_;
1992 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1993 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1994 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->attr.wpa.key,
1995 pstrHostIFkeyAttr->attr.wpa.key_len);
1997 strWID.id = (u16)WID_ADD_PTK;
1998 strWID.type = WID_STR;
1999 strWID.val = (s8 *)pu8keybuf;
2000 strWID.size = PTK_KEY_MSG_LEN;
2002 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2003 get_id_from_handler(hif_drv));
2005 up(&hif_drv->hSemTestKeyBlock);
2009 kfree(pstrHostIFkeyAttr->attr.wpa.key);
2018 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
2020 pu8keybuf = kmalloc((pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
2021 if (pu8keybuf == NULL) {
2022 PRINT_ER("No buffer to send PMKSA Key\n");
2026 pu8keybuf[0] = pstrHostIFkeyAttr->attr.pmkid.numpmkid;
2028 for (i = 0; i < pstrHostIFkeyAttr->attr.pmkid.numpmkid; i++) {
2029 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
2030 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
2033 strWID.id = (u16)WID_PMKID_INFO;
2034 strWID.type = WID_STR;
2035 strWID.val = (s8 *)pu8keybuf;
2036 strWID.size = (pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
2038 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2039 get_id_from_handler(hif_drv));
2046 PRINT_ER("Failed to send key config packet\n");
2052 static void Handle_Disconnect(struct host_if_drv *hif_drv)
2057 u16 u16DummyReasonCode = 0;
2059 strWID.id = (u16)WID_DISCONNECT;
2060 strWID.type = WID_CHAR;
2061 strWID.val = (s8 *)&u16DummyReasonCode;
2062 strWID.size = sizeof(char);
2066 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2068 g_obtainingIP = false;
2069 host_int_set_power_mgmt(hif_drv, 0, 0);
2071 eth_zero_addr(u8ConnectedSSID);
2073 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2074 get_id_from_handler(hif_drv));
2077 PRINT_ER("Failed to send dissconect config packet\n");
2079 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2081 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
2083 strDisconnectNotifInfo.u16reason = 0;
2084 strDisconnectNotifInfo.ie = NULL;
2085 strDisconnectNotifInfo.ie_len = 0;
2087 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
2088 del_timer(&hif_drv->hScanTimer);
2089 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
2090 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2092 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
2095 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2096 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2097 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
2098 del_timer(&hif_drv->hConnectTimer);
2101 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
2102 0, &strDisconnectNotifInfo, hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
2104 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
2107 gbScanWhileConnected = false;
2109 hif_drv->enuHostIFstate = HOST_IF_IDLE;
2111 eth_zero_addr(hif_drv->au8AssociatedBSSID);
2113 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
2114 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
2115 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
2116 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2117 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
2119 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
2120 kfree(gu8FlushedJoinReq);
2121 gu8FlushedJoinReq = NULL;
2123 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
2124 kfree(gu8FlushedInfoElemAsoc);
2125 gu8FlushedInfoElemAsoc = NULL;
2130 up(&hif_drv->hSemTestDisconnectBlock);
2134 void resolve_disconnect_aberration(struct host_if_drv *hif_drv)
2138 if ((hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (hif_drv->enuHostIFstate == HOST_IF_CONNECTING)) {
2139 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
2140 host_int_disconnect(hif_drv, 1);
2144 static s32 Handle_GetChnl(struct host_if_drv *hif_drv)
2150 strWID.id = (u16)WID_CURRENT_CHANNEL;
2151 strWID.type = WID_CHAR;
2152 strWID.val = (s8 *)&gu8Chnl;
2153 strWID.size = sizeof(char);
2155 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
2157 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2158 get_id_from_handler(hif_drv));
2161 PRINT_ER("Failed to get channel number\n");
2165 up(&hif_drv->hSemGetCHNL);
2173 static void Handle_GetRssi(struct host_if_drv *hif_drv)
2178 strWID.id = (u16)WID_RSSI;
2179 strWID.type = WID_CHAR;
2180 strWID.val = &gs8Rssi;
2181 strWID.size = sizeof(char);
2183 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
2185 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2186 get_id_from_handler(hif_drv));
2188 PRINT_ER("Failed to get RSSI value\n");
2192 up(&hif_drv->hSemGetRSSI);
2198 static void Handle_GetLinkspeed(struct host_if_drv *hif_drv)
2205 strWID.id = (u16)WID_LINKSPEED;
2206 strWID.type = WID_CHAR;
2207 strWID.val = &gs8lnkspd;
2208 strWID.size = sizeof(char);
2210 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
2212 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2213 get_id_from_handler(hif_drv));
2215 PRINT_ER("Failed to get LINKSPEED value\n");
2219 up(&(hif_drv->hSemGetLINKSPEED));
2224 s32 Handle_GetStatistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
2226 struct wid strWIDList[5];
2227 u32 u32WidsCount = 0, s32Error = 0;
2229 strWIDList[u32WidsCount].id = WID_LINKSPEED;
2230 strWIDList[u32WidsCount].type = WID_CHAR;
2231 strWIDList[u32WidsCount].size = sizeof(char);
2232 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u8LinkSpeed));
2235 strWIDList[u32WidsCount].id = WID_RSSI;
2236 strWIDList[u32WidsCount].type = WID_CHAR;
2237 strWIDList[u32WidsCount].size = sizeof(char);
2238 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->s8RSSI));
2241 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
2242 strWIDList[u32WidsCount].type = WID_INT;
2243 strWIDList[u32WidsCount].size = sizeof(u32);
2244 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32TxCount));
2247 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
2248 strWIDList[u32WidsCount].type = WID_INT;
2249 strWIDList[u32WidsCount].size = sizeof(u32);
2250 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32RxCount));
2253 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
2254 strWIDList[u32WidsCount].type = WID_INT;
2255 strWIDList[u32WidsCount].size = sizeof(u32);
2256 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32TxFailureCount));
2259 s32Error = send_config_pkt(GET_CFG, strWIDList, u32WidsCount,
2260 get_id_from_handler(hif_drv));
2263 PRINT_ER("Failed to send scan paramters config packet\n");
2270 static s32 Handle_Get_InActiveTime(struct host_if_drv *hif_drv,
2271 struct sta_inactive_t *strHostIfStaInactiveT)
2278 strWID.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
2279 strWID.type = WID_STR;
2280 strWID.size = ETH_ALEN;
2281 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2284 stamac = strWID.val;
2285 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
2288 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
2291 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2292 get_id_from_handler(hif_drv));
2295 PRINT_ER("Failed to SET incative time\n");
2300 strWID.id = (u16)WID_GET_INACTIVE_TIME;
2301 strWID.type = WID_INT;
2302 strWID.val = (s8 *)&gu32InactiveTime;
2303 strWID.size = sizeof(u32);
2306 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2307 get_id_from_handler(hif_drv));
2310 PRINT_ER("Failed to get incative time\n");
2315 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
2317 up(&hif_drv->hSemInactiveTime);
2325 static void Handle_AddBeacon(struct host_if_drv *hif_drv,
2326 struct beacon_attr *pstrSetBeaconParam)
2332 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
2334 strWID.id = (u16)WID_ADD_BEACON;
2335 strWID.type = WID_BIN;
2336 strWID.size = pstrSetBeaconParam->head_len + pstrSetBeaconParam->tail_len + 16;
2337 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2338 if (strWID.val == NULL)
2341 pu8CurrByte = strWID.val;
2342 *pu8CurrByte++ = (pstrSetBeaconParam->interval & 0xFF);
2343 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 8) & 0xFF);
2344 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 16) & 0xFF);
2345 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 24) & 0xFF);
2347 *pu8CurrByte++ = (pstrSetBeaconParam->dtim_period & 0xFF);
2348 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 8) & 0xFF);
2349 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 16) & 0xFF);
2350 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 24) & 0xFF);
2352 *pu8CurrByte++ = (pstrSetBeaconParam->head_len & 0xFF);
2353 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 8) & 0xFF);
2354 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 16) & 0xFF);
2355 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 24) & 0xFF);
2357 memcpy(pu8CurrByte, pstrSetBeaconParam->head, pstrSetBeaconParam->head_len);
2358 pu8CurrByte += pstrSetBeaconParam->head_len;
2360 *pu8CurrByte++ = (pstrSetBeaconParam->tail_len & 0xFF);
2361 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 8) & 0xFF);
2362 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 16) & 0xFF);
2363 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 24) & 0xFF);
2365 if (pstrSetBeaconParam->tail > 0)
2366 memcpy(pu8CurrByte, pstrSetBeaconParam->tail, pstrSetBeaconParam->tail_len);
2367 pu8CurrByte += pstrSetBeaconParam->tail_len;
2369 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2370 get_id_from_handler(hif_drv));
2372 PRINT_ER("Failed to send add beacon config packet\n");
2376 kfree(pstrSetBeaconParam->head);
2377 kfree(pstrSetBeaconParam->tail);
2380 static void Handle_DelBeacon(struct host_if_drv *hif_drv)
2386 strWID.id = (u16)WID_DEL_BEACON;
2387 strWID.type = WID_CHAR;
2388 strWID.size = sizeof(char);
2389 strWID.val = &gu8DelBcn;
2391 if (strWID.val == NULL)
2394 pu8CurrByte = strWID.val;
2396 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
2398 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2399 get_id_from_handler(hif_drv));
2401 PRINT_ER("Failed to send delete beacon config packet\n");
2404 static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
2405 struct add_sta_param *pstrStationParam)
2409 pu8CurrByte = pu8Buffer;
2411 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
2412 memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
2413 pu8CurrByte += ETH_ALEN;
2415 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
2416 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
2418 *pu8CurrByte++ = pstrStationParam->u8NumRates;
2419 if (pstrStationParam->u8NumRates > 0)
2420 memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
2421 pu8CurrByte += pstrStationParam->u8NumRates;
2423 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
2424 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
2425 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
2427 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
2428 memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
2429 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
2431 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
2432 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
2434 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
2435 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
2436 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
2437 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
2439 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
2441 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
2442 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
2444 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
2445 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
2447 return pu8CurrByte - pu8Buffer;
2450 static void Handle_AddStation(struct host_if_drv *hif_drv,
2451 struct add_sta_param *pstrStationParam)
2457 PRINT_D(HOSTINF_DBG, "Handling add station\n");
2458 strWID.id = (u16)WID_ADD_STA;
2459 strWID.type = WID_BIN;
2460 strWID.size = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
2462 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2463 if (strWID.val == NULL)
2466 pu8CurrByte = strWID.val;
2467 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2469 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2470 get_id_from_handler(hif_drv));
2472 PRINT_ER("Failed to send add station config packet\n");
2475 kfree(pstrStationParam->pu8Rates);
2479 static void Handle_DelAllSta(struct host_if_drv *hif_drv,
2480 struct del_all_sta *pstrDelAllStaParam)
2487 u8 au8Zero_Buff[6] = {0};
2489 strWID.id = (u16)WID_DEL_ALL_STA;
2490 strWID.type = WID_STR;
2491 strWID.size = (pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1;
2493 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
2495 strWID.val = kmalloc((pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1, GFP_KERNEL);
2496 if (strWID.val == NULL)
2499 pu8CurrByte = strWID.val;
2501 *(pu8CurrByte++) = pstrDelAllStaParam->assoc_sta;
2503 for (i = 0; i < MAX_NUM_STA; i++) {
2504 if (memcmp(pstrDelAllStaParam->del_all_sta[i], au8Zero_Buff, ETH_ALEN))
2505 memcpy(pu8CurrByte, pstrDelAllStaParam->del_all_sta[i], ETH_ALEN);
2509 pu8CurrByte += ETH_ALEN;
2512 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2513 get_id_from_handler(hif_drv));
2515 PRINT_ER("Failed to send add station config packet\n");
2523 static void Handle_DelStation(struct host_if_drv *hif_drv,
2524 struct del_sta *pstrDelStaParam)
2530 strWID.id = (u16)WID_REMOVE_STA;
2531 strWID.type = WID_BIN;
2532 strWID.size = ETH_ALEN;
2534 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
2536 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2537 if (strWID.val == NULL)
2540 pu8CurrByte = strWID.val;
2542 memcpy(pu8CurrByte, pstrDelStaParam->mac_addr, ETH_ALEN);
2544 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2545 get_id_from_handler(hif_drv));
2547 PRINT_ER("Failed to send add station config packet\n");
2553 static void Handle_EditStation(struct host_if_drv *hif_drv,
2554 struct add_sta_param *pstrStationParam)
2560 strWID.id = (u16)WID_EDIT_STA;
2561 strWID.type = WID_BIN;
2562 strWID.size = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
2564 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
2565 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2566 if (strWID.val == NULL)
2569 pu8CurrByte = strWID.val;
2570 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2572 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2573 get_id_from_handler(hif_drv));
2575 PRINT_ER("Failed to send edit station config packet\n");
2578 kfree(pstrStationParam->pu8Rates);
2582 static int Handle_RemainOnChan(struct host_if_drv *hif_drv,
2583 struct remain_ch *pstrHostIfRemainOnChan)
2586 u8 u8remain_on_chan_flag;
2589 if (!hif_drv->u8RemainOnChan_pendingreq) {
2590 hif_drv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
2591 hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
2592 hif_drv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
2593 hif_drv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
2594 hif_drv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
2596 pstrHostIfRemainOnChan->u16Channel = hif_drv->strHostIfRemainOnChan.u16Channel;
2599 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
2600 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
2601 hif_drv->u8RemainOnChan_pendingreq = 1;
2605 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2606 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
2611 if (g_obtainingIP || connecting) {
2612 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
2617 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
2619 u8remain_on_chan_flag = true;
2620 strWID.id = (u16)WID_REMAIN_ON_CHAN;
2621 strWID.type = WID_STR;
2623 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2625 if (strWID.val == NULL) {
2630 strWID.val[0] = u8remain_on_chan_flag;
2631 strWID.val[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
2633 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2634 get_id_from_handler(hif_drv));
2636 PRINT_ER("Failed to set remain on channel\n");
2640 P2P_LISTEN_STATE = 1;
2641 hif_drv->hRemainOnChannel.data = (unsigned long)hif_drv;
2642 mod_timer(&hif_drv->hRemainOnChannel,
2644 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
2646 if (hif_drv->strHostIfRemainOnChan.pRemainOnChanReady)
2647 hif_drv->strHostIfRemainOnChan.pRemainOnChanReady(hif_drv->strHostIfRemainOnChan.pVoid);
2649 if (hif_drv->u8RemainOnChan_pendingreq)
2650 hif_drv->u8RemainOnChan_pendingreq = 0;
2655 static int Handle_RegisterFrame(struct host_if_drv *hif_drv,
2656 struct reg_frame *pstrHostIfRegisterFrame)
2662 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
2664 strWID.id = (u16)WID_REGISTER_FRAME;
2665 strWID.type = WID_STR;
2666 strWID.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
2667 if (strWID.val == NULL)
2670 pu8CurrByte = strWID.val;
2672 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
2673 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
2674 memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
2677 strWID.size = sizeof(u16) + 2;
2679 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2680 get_id_from_handler(hif_drv));
2682 PRINT_ER("Failed to frame register config packet\n");
2690 #define FALSE_FRMWR_CHANNEL 100
2691 static u32 Handle_ListenStateExpired(struct host_if_drv *hif_drv,
2692 struct remain_ch *pstrHostIfRemainOnChan)
2694 u8 u8remain_on_chan_flag;
2698 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
2700 if (P2P_LISTEN_STATE) {
2701 u8remain_on_chan_flag = false;
2702 strWID.id = (u16)WID_REMAIN_ON_CHAN;
2703 strWID.type = WID_STR;
2705 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2707 if (strWID.val == NULL)
2708 PRINT_ER("Failed to allocate memory\n");
2710 strWID.val[0] = u8remain_on_chan_flag;
2711 strWID.val[1] = FALSE_FRMWR_CHANNEL;
2713 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2714 get_id_from_handler(hif_drv));
2715 if (s32Error != 0) {
2716 PRINT_ER("Failed to set remain on channel\n");
2720 if (hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired) {
2721 hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired(hif_drv->strHostIfRemainOnChan.pVoid
2722 , pstrHostIfRemainOnChan->u32ListenSessionID);
2724 P2P_LISTEN_STATE = 0;
2726 PRINT_D(GENERIC_DBG, "Not in listen state\n");
2734 static void ListenTimerCB(unsigned long arg)
2737 struct host_if_msg msg;
2738 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
2740 del_timer(&hif_drv->hRemainOnChannel);
2742 memset(&msg, 0, sizeof(struct host_if_msg));
2743 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
2745 msg.body.remain_on_ch.u32ListenSessionID = hif_drv->strHostIfRemainOnChan.u32ListenSessionID;
2747 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
2749 PRINT_ER("wilc_mq_send fail\n");
2752 static void Handle_PowerManagement(struct host_if_drv *hif_drv,
2753 struct power_mgmt_param *strPowerMgmtParam)
2759 strWID.id = (u16)WID_POWER_MANAGEMENT;
2761 if (strPowerMgmtParam->enabled == true)
2762 s8PowerMode = MIN_FAST_PS;
2764 s8PowerMode = NO_POWERSAVE;
2765 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
2766 strWID.val = &s8PowerMode;
2767 strWID.size = sizeof(char);
2769 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
2771 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2772 get_id_from_handler(hif_drv));
2774 PRINT_ER("Failed to send power management config packet\n");
2777 static void Handle_SetMulticastFilter(struct host_if_drv *hif_drv,
2778 struct set_multicast *strHostIfSetMulti)
2784 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
2786 strWID.id = (u16)WID_SETUP_MULTICAST_FILTER;
2787 strWID.type = WID_BIN;
2788 strWID.size = sizeof(struct set_multicast) + ((strHostIfSetMulti->cnt) * ETH_ALEN);
2789 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2790 if (strWID.val == NULL)
2793 pu8CurrByte = strWID.val;
2794 *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF);
2795 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 8) & 0xFF);
2796 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 16) & 0xFF);
2797 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 24) & 0xFF);
2799 *pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF);
2800 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF);
2801 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 16) & 0xFF);
2802 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 24) & 0xFF);
2804 if ((strHostIfSetMulti->cnt) > 0)
2805 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->cnt) * ETH_ALEN));
2807 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2808 get_id_from_handler(hif_drv));
2810 PRINT_ER("Failed to send setup multicast config packet\n");
2817 static s32 Handle_AddBASession(struct host_if_drv *hif_drv,
2818 struct ba_session_info *strHostIfBASessionInfo)
2822 int AddbaTimeout = 100;
2825 PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\nBufferSize == %d\nSessionTimeOut = %d\n",
2826 strHostIfBASessionInfo->au8Bssid[0],
2827 strHostIfBASessionInfo->au8Bssid[1],
2828 strHostIfBASessionInfo->au8Bssid[2],
2829 strHostIfBASessionInfo->u16BufferSize,
2830 strHostIfBASessionInfo->u16SessionTimeout,
2831 strHostIfBASessionInfo->u8Ted);
2833 strWID.id = (u16)WID_11E_P_ACTION_REQ;
2834 strWID.type = WID_STR;
2835 strWID.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2836 strWID.size = BLOCK_ACK_REQ_SIZE;
2841 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2843 *ptr++ = strHostIfBASessionInfo->u8Ted;
2845 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
2846 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
2847 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
2848 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
2849 *ptr++ = (AddbaTimeout & 0xFF);
2850 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
2854 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2855 get_id_from_handler(hif_drv));
2857 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
2860 strWID.id = (u16)WID_11E_P_ACTION_REQ;
2861 strWID.type = WID_STR;
2867 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2869 *ptr++ = strHostIfBASessionInfo->u8Ted;
2871 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
2872 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
2874 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2875 get_id_from_handler(hif_drv));
2877 if (strWID.val != NULL)
2884 static s32 Handle_DelAllRxBASessions(struct host_if_drv *hif_drv,
2885 struct ba_session_info *strHostIfBASessionInfo)
2891 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
2892 strHostIfBASessionInfo->au8Bssid[0],
2893 strHostIfBASessionInfo->au8Bssid[1],
2894 strHostIfBASessionInfo->au8Bssid[2],
2895 strHostIfBASessionInfo->u8Ted);
2897 strWID.id = (u16)WID_DEL_ALL_RX_BA;
2898 strWID.type = WID_STR;
2899 strWID.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2900 strWID.size = BLOCK_ACK_REQ_SIZE;
2905 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2907 *ptr++ = strHostIfBASessionInfo->u8Ted;
2911 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2912 get_id_from_handler(hif_drv));
2914 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
2917 if (strWID.val != NULL)
2926 static int hostIFthread(void *pvArg)
2929 struct host_if_msg msg;
2930 struct host_if_drv *hif_drv;
2932 memset(&msg, 0, sizeof(struct host_if_msg));
2935 wilc_mq_recv(&gMsgQHostIF, &msg, sizeof(struct host_if_msg), &u32Ret);
2936 hif_drv = (struct host_if_drv *)msg.drv;
2937 if (msg.id == HOST_IF_MSG_EXIT) {
2938 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
2942 if ((!g_wilc_initialized)) {
2943 PRINT_D(GENERIC_DBG, "--WAIT--");
2944 usleep_range(200 * 1000, 200 * 1000);
2945 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
2949 if (msg.id == HOST_IF_MSG_CONNECT && hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
2950 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
2951 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
2952 usleep_range(2 * 1000, 2 * 1000);
2957 case HOST_IF_MSG_Q_IDLE:
2958 Handle_wait_msg_q_empty();
2961 case HOST_IF_MSG_SCAN:
2962 Handle_Scan(msg.drv, &msg.body.scan_info);
2965 case HOST_IF_MSG_CONNECT:
2966 Handle_Connect(msg.drv, &msg.body.con_info);
2969 case HOST_IF_MSG_FLUSH_CONNECT:
2970 Handle_FlushConnect(msg.drv);
2973 case HOST_IF_MSG_RCVD_NTWRK_INFO:
2974 Handle_RcvdNtwrkInfo(msg.drv, &msg.body.net_info);
2977 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
2978 Handle_RcvdGnrlAsyncInfo(msg.drv, &msg.body.async_info);
2981 case HOST_IF_MSG_KEY:
2982 Handle_Key(msg.drv, &msg.body.key_info);
2985 case HOST_IF_MSG_CFG_PARAMS:
2987 Handle_CfgParam(msg.drv, &msg.body.cfg_info);
2990 case HOST_IF_MSG_SET_CHANNEL:
2991 Handle_SetChannel(msg.drv, &msg.body.channel_info);
2994 case HOST_IF_MSG_DISCONNECT:
2995 Handle_Disconnect(msg.drv);
2998 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
2999 del_timer(&hif_drv->hScanTimer);
3000 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
3002 if (!linux_wlan_get_num_conn_ifcs())
3003 chip_sleep_manually(INFINITE_SLEEP_TIME);
3005 Handle_ScanDone(msg.drv, SCAN_EVENT_DONE);
3007 if (hif_drv->u8RemainOnChan_pendingreq)
3008 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
3012 case HOST_IF_MSG_GET_RSSI:
3013 Handle_GetRssi(msg.drv);
3016 case HOST_IF_MSG_GET_LINKSPEED:
3017 Handle_GetLinkspeed(msg.drv);
3020 case HOST_IF_MSG_GET_STATISTICS:
3021 Handle_GetStatistics(msg.drv, (struct rf_info *)msg.body.data);
3024 case HOST_IF_MSG_GET_CHNL:
3025 Handle_GetChnl(msg.drv);
3028 case HOST_IF_MSG_ADD_BEACON:
3029 Handle_AddBeacon(msg.drv, &msg.body.beacon_info);
3032 case HOST_IF_MSG_DEL_BEACON:
3033 Handle_DelBeacon(msg.drv);
3036 case HOST_IF_MSG_ADD_STATION:
3037 Handle_AddStation(msg.drv, &msg.body.add_sta_info);
3040 case HOST_IF_MSG_DEL_STATION:
3041 Handle_DelStation(msg.drv, &msg.body.del_sta_info);
3044 case HOST_IF_MSG_EDIT_STATION:
3045 Handle_EditStation(msg.drv, &msg.body.edit_sta_info);
3048 case HOST_IF_MSG_GET_INACTIVETIME:
3049 Handle_Get_InActiveTime(msg.drv, &msg.body.mac_info);
3052 case HOST_IF_MSG_SCAN_TIMER_FIRED:
3053 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
3055 Handle_ScanDone(msg.drv, SCAN_EVENT_ABORTED);
3058 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
3059 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
3060 Handle_ConnectTimeout(msg.drv);
3063 case HOST_IF_MSG_POWER_MGMT:
3064 Handle_PowerManagement(msg.drv, &msg.body.pwr_mgmt_info);
3067 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
3068 Handle_SetWfiDrvHandler(msg.drv,
3072 case HOST_IF_MSG_SET_OPERATION_MODE:
3073 Handle_SetOperationMode(msg.drv, &msg.body.mode);
3076 case HOST_IF_MSG_SET_IPADDRESS:
3077 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
3078 Handle_set_IPAddress(msg.drv, msg.body.ip_info.ip_addr, msg.body.ip_info.idx);
3081 case HOST_IF_MSG_GET_IPADDRESS:
3082 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
3083 Handle_get_IPAddress(msg.drv, msg.body.ip_info.ip_addr, msg.body.ip_info.idx);
3086 case HOST_IF_MSG_SET_MAC_ADDRESS:
3087 Handle_SetMacAddress(msg.drv, &msg.body.set_mac_info);
3090 case HOST_IF_MSG_GET_MAC_ADDRESS:
3091 Handle_GetMacAddress(msg.drv, &msg.body.get_mac_info);
3094 case HOST_IF_MSG_REMAIN_ON_CHAN:
3095 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
3096 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
3099 case HOST_IF_MSG_REGISTER_FRAME:
3100 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
3101 Handle_RegisterFrame(msg.drv, &msg.body.reg_frame);
3104 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
3105 Handle_ListenStateExpired(msg.drv, &msg.body.remain_on_ch);
3108 case HOST_IF_MSG_SET_MULTICAST_FILTER:
3109 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
3110 Handle_SetMulticastFilter(msg.drv, &msg.body.multicast_info);
3113 case HOST_IF_MSG_ADD_BA_SESSION:
3114 Handle_AddBASession(msg.drv, &msg.body.session_info);
3117 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
3118 Handle_DelAllRxBASessions(msg.drv, &msg.body.session_info);
3121 case HOST_IF_MSG_DEL_ALL_STA:
3122 Handle_DelAllSta(msg.drv, &msg.body.del_all_sta_info);
3126 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
3131 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
3132 up(&hSemHostIFthrdEnd);
3136 static void TimerCB_Scan(unsigned long arg)
3138 void *pvArg = (void *)arg;
3139 struct host_if_msg msg;
3141 memset(&msg, 0, sizeof(struct host_if_msg));
3143 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
3145 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3148 static void TimerCB_Connect(unsigned long arg)
3150 void *pvArg = (void *)arg;
3151 struct host_if_msg msg;
3153 memset(&msg, 0, sizeof(struct host_if_msg));
3155 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
3157 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3160 s32 host_int_remove_key(struct host_if_drv *hif_drv, const u8 *pu8StaAddress)
3164 strWID.id = (u16)WID_REMOVE_KEY;
3165 strWID.type = WID_STR;
3166 strWID.val = (s8 *)pu8StaAddress;
3172 int host_int_remove_wep_key(struct host_if_drv *hif_drv, u8 index)
3175 struct host_if_msg msg;
3179 PRINT_ER("Failed to send setup multicast config packet\n");
3183 memset(&msg, 0, sizeof(struct host_if_msg));
3185 msg.id = HOST_IF_MSG_KEY;
3186 msg.body.key_info.type = WEP;
3187 msg.body.key_info.action = REMOVEKEY;
3189 msg.body.key_info.attr.wep.index = index;
3191 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3193 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
3194 down(&hif_drv->hSemTestKeyBlock);
3199 s32 host_int_set_WEPDefaultKeyID(struct host_if_drv *hif_drv, u8 u8Index)
3202 struct host_if_msg msg;
3207 PRINT_ER("driver is null\n");
3211 memset(&msg, 0, sizeof(struct host_if_msg));
3214 msg.id = HOST_IF_MSG_KEY;
3215 msg.body.key_info.type = WEP;
3216 msg.body.key_info.action = DEFAULTKEY;
3218 msg.body.key_info.attr.wep.index = u8Index;
3220 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3222 PRINT_ER("Error in sending message queue : Default key index\n");
3223 down(&hif_drv->hSemTestKeyBlock);
3228 s32 host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv,
3229 const u8 *pu8WepKey,
3235 struct host_if_msg msg;
3239 PRINT_ER("driver is null\n");
3243 memset(&msg, 0, sizeof(struct host_if_msg));
3246 msg.id = HOST_IF_MSG_KEY;
3247 msg.body.key_info.type = WEP;
3248 msg.body.key_info.action = ADDKEY;
3250 msg.body.key_info.attr.wep.key = kmalloc(u8WepKeylen, GFP_KERNEL);
3251 memcpy(msg.body.key_info.attr.wep.key, pu8WepKey, u8WepKeylen);
3252 msg.body.key_info.attr.wep.key_len = (u8WepKeylen);
3253 msg.body.key_info.attr.wep.index = u8Keyidx;
3255 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3257 PRINT_ER("Error in sending message queue :WEP Key\n");
3258 down(&hif_drv->hSemTestKeyBlock);
3264 s32 host_int_add_wep_key_bss_ap(struct host_if_drv *hif_drv,
3265 const u8 *pu8WepKey,
3269 enum AUTHTYPE tenuAuth_type)
3273 struct host_if_msg msg;
3278 PRINT_ER("driver is null\n");
3282 memset(&msg, 0, sizeof(struct host_if_msg));
3285 for (i = 0; i < u8WepKeylen; i++)
3286 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
3288 msg.id = HOST_IF_MSG_KEY;
3289 msg.body.key_info.type = WEP;
3290 msg.body.key_info.action = ADDKEY_AP;
3292 msg.body.key_info.attr.wep.key = kmalloc(u8WepKeylen, GFP_KERNEL);
3293 memcpy(msg.body.key_info.attr.wep.key, pu8WepKey, (u8WepKeylen));
3294 msg.body.key_info.attr.wep.key_len = (u8WepKeylen);
3295 msg.body.key_info.attr.wep.index = u8Keyidx;
3296 msg.body.key_info.attr.wep.mode = u8mode;
3297 msg.body.key_info.attr.wep.auth_type = tenuAuth_type;
3299 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3302 PRINT_ER("Error in sending message queue :WEP Key\n");
3303 down(&hif_drv->hSemTestKeyBlock);
3309 s32 host_int_add_ptk(struct host_if_drv *hif_drv, const u8 *pu8Ptk,
3310 u8 u8PtkKeylen, const u8 *mac_addr,
3311 const u8 *pu8RxMic, const u8 *pu8TxMic,
3312 u8 mode, u8 u8Ciphermode, u8 u8Idx)
3315 struct host_if_msg msg;
3316 u8 u8KeyLen = u8PtkKeylen;
3321 PRINT_ER("driver is null\n");
3324 if (pu8RxMic != NULL)
3325 u8KeyLen += RX_MIC_KEY_LEN;
3326 if (pu8TxMic != NULL)
3327 u8KeyLen += TX_MIC_KEY_LEN;
3329 memset(&msg, 0, sizeof(struct host_if_msg));
3332 msg.id = HOST_IF_MSG_KEY;
3333 msg.body.key_info.type = WPAPtk;
3334 if (mode == AP_MODE) {
3335 msg.body.key_info.action = ADDKEY_AP;
3336 msg.body.key_info.attr.wpa.index = u8Idx;
3338 if (mode == STATION_MODE)
3339 msg.body.key_info.action = ADDKEY;
3341 msg.body.key_info.attr.wpa.key = kmalloc(u8PtkKeylen, GFP_KERNEL);
3342 memcpy(msg.body.key_info.attr.wpa.key, pu8Ptk, u8PtkKeylen);
3344 if (pu8RxMic != NULL) {
3345 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic, RX_MIC_KEY_LEN);
3347 for (i = 0; i < RX_MIC_KEY_LEN; i++)
3348 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
3351 if (pu8TxMic != NULL) {
3352 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic, TX_MIC_KEY_LEN);
3354 for (i = 0; i < TX_MIC_KEY_LEN; i++)
3355 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
3359 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
3360 msg.body.key_info.attr.wpa.mac_addr = mac_addr;
3361 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
3364 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3367 PRINT_ER("Error in sending message queue: PTK Key\n");
3369 down(&hif_drv->hSemTestKeyBlock);
3374 s32 host_int_add_rx_gtk(struct host_if_drv *hif_drv, const u8 *pu8RxGtk,
3375 u8 u8GtkKeylen, u8 u8KeyIdx,
3376 u32 u32KeyRSClen, const u8 *KeyRSC,
3377 const u8 *pu8RxMic, const u8 *pu8TxMic,
3378 u8 mode, u8 u8Ciphermode)
3381 struct host_if_msg msg;
3382 u8 u8KeyLen = u8GtkKeylen;
3386 PRINT_ER("driver is null\n");
3389 memset(&msg, 0, sizeof(struct host_if_msg));
3392 if (pu8RxMic != NULL)
3393 u8KeyLen += RX_MIC_KEY_LEN;
3394 if (pu8TxMic != NULL)
3395 u8KeyLen += TX_MIC_KEY_LEN;
3396 if (KeyRSC != NULL) {
3397 msg.body.key_info.attr.wpa.seq = kmalloc(u32KeyRSClen, GFP_KERNEL);
3398 memcpy(msg.body.key_info.attr.wpa.seq, KeyRSC, u32KeyRSClen);
3402 msg.id = HOST_IF_MSG_KEY;
3403 msg.body.key_info.type = WPARxGtk;
3406 if (mode == AP_MODE) {
3407 msg.body.key_info.action = ADDKEY_AP;
3408 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
3410 if (mode == STATION_MODE)
3411 msg.body.key_info.action = ADDKEY;
3413 msg.body.key_info.attr.wpa.key = kmalloc(u8KeyLen, GFP_KERNEL);
3414 memcpy(msg.body.key_info.attr.wpa.key, pu8RxGtk, u8GtkKeylen);
3416 if (pu8RxMic != NULL) {
3417 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic, RX_MIC_KEY_LEN);
3419 if (pu8TxMic != NULL) {
3420 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic, TX_MIC_KEY_LEN);
3423 msg.body.key_info.attr.wpa.index = u8KeyIdx;
3424 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
3425 msg.body.key_info.attr.wpa.seq_len = u32KeyRSClen;
3427 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3429 PRINT_ER("Error in sending message queue: RX GTK\n");
3431 down(&hif_drv->hSemTestKeyBlock);
3436 s32 host_int_set_pmkid_info(struct host_if_drv *hif_drv, struct host_if_pmkid_attr *pu8PmkidInfoArray)
3439 struct host_if_msg msg;
3445 PRINT_ER("driver is null\n");
3449 memset(&msg, 0, sizeof(struct host_if_msg));
3451 msg.id = HOST_IF_MSG_KEY;
3452 msg.body.key_info.type = PMKSA;
3453 msg.body.key_info.action = ADDKEY;
3456 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
3457 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
3459 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
3463 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3465 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
3470 s32 host_int_get_pmkid_info(struct host_if_drv *hif_drv,
3471 u8 *pu8PmkidInfoArray,
3472 u32 u32PmkidInfoLen)
3476 strWID.id = (u16)WID_PMKID_INFO;
3477 strWID.type = WID_STR;
3478 strWID.size = u32PmkidInfoLen;
3479 strWID.val = pu8PmkidInfoArray;
3484 s32 host_int_set_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3490 if ((u8Psklength > 7) && (u8Psklength < 65)) {
3491 strWID.id = (u16)WID_11I_PSK;
3492 strWID.type = WID_STR;
3493 strWID.val = pu8PassPhrase;
3494 strWID.size = u8Psklength;
3500 s32 host_int_get_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
3503 struct host_if_msg msg;
3505 memset(&msg, 0, sizeof(struct host_if_msg));
3507 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
3508 msg.body.get_mac_info.u8MacAddress = pu8MacAddress;
3511 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3513 PRINT_ER("Failed to send get mac address\n");
3517 down(&hWaitResponse);
3521 s32 host_int_set_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
3524 struct host_if_msg msg;
3526 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
3528 memset(&msg, 0, sizeof(struct host_if_msg));
3529 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
3530 memcpy(msg.body.set_mac_info.u8MacAddress, pu8MacAddress, ETH_ALEN);
3533 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3535 PRINT_ER("Failed to send message queue: Set mac address\n");
3541 s32 host_int_get_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3542 u8 *pu8PassPhrase, u8 u8Psklength)
3546 strWID.id = (u16)WID_11I_PSK;
3547 strWID.type = WID_STR;
3548 strWID.size = u8Psklength;
3549 strWID.val = pu8PassPhrase;
3554 s32 host_int_set_start_scan_req(struct host_if_drv *hif_drv, u8 scanSource)
3558 strWID.id = (u16)WID_START_SCAN_REQ;
3559 strWID.type = WID_CHAR;
3560 strWID.val = (s8 *)&scanSource;
3561 strWID.size = sizeof(char);
3566 s32 host_int_get_start_scan_req(struct host_if_drv *hif_drv, u8 *pu8ScanSource)
3570 strWID.id = (u16)WID_START_SCAN_REQ;
3571 strWID.type = WID_CHAR;
3572 strWID.val = (s8 *)pu8ScanSource;
3573 strWID.size = sizeof(char);
3578 s32 host_int_set_join_req(struct host_if_drv *hif_drv, u8 *pu8bssid,
3579 const u8 *pu8ssid, size_t ssidLen,
3580 const u8 *pu8IEs, size_t IEsLen,
3581 wilc_connect_result pfConnectResult, void *pvUserArg,
3582 u8 u8security, enum AUTHTYPE tenuAuth_type,
3583 u8 u8channel, void *pJoinParams)
3586 struct host_if_msg msg;
3587 enum scan_conn_timer enuScanConnTimer;
3589 if (!hif_drv || pfConnectResult == NULL) {
3591 PRINT_ER("Driver is null\n");
3595 if (pJoinParams == NULL) {
3596 PRINT_ER("Unable to Join - JoinParams is NULL\n");
3600 memset(&msg, 0, sizeof(struct host_if_msg));
3602 msg.id = HOST_IF_MSG_CONNECT;
3604 msg.body.con_info.security = u8security;
3605 msg.body.con_info.auth_type = tenuAuth_type;
3606 msg.body.con_info.ch = u8channel;
3607 msg.body.con_info.result = pfConnectResult;
3608 msg.body.con_info.arg = pvUserArg;
3609 msg.body.con_info.params = pJoinParams;
3612 if (pu8bssid != NULL) {
3613 msg.body.con_info.bssid = kmalloc(6, GFP_KERNEL);
3614 memcpy(msg.body.con_info.bssid, pu8bssid, 6);
3617 if (pu8ssid != NULL) {
3618 msg.body.con_info.ssid_len = ssidLen;
3619 msg.body.con_info.ssid = kmalloc(ssidLen, GFP_KERNEL);
3620 memcpy(msg.body.con_info.ssid, pu8ssid, ssidLen);
3623 if (pu8IEs != NULL) {
3624 msg.body.con_info.ies_len = IEsLen;
3625 msg.body.con_info.ies = kmalloc(IEsLen, GFP_KERNEL);
3626 memcpy(msg.body.con_info.ies, pu8IEs, IEsLen);
3628 if (hif_drv->enuHostIFstate < HOST_IF_CONNECTING)
3629 hif_drv->enuHostIFstate = HOST_IF_CONNECTING;
3631 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", hif_drv->enuHostIFstate);
3633 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3635 PRINT_ER("Failed to send message queue: Set join request\n");
3639 enuScanConnTimer = CONNECT_TIMER;
3640 hif_drv->hConnectTimer.data = (unsigned long)hif_drv;
3641 mod_timer(&hif_drv->hConnectTimer,
3642 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
3647 s32 host_int_flush_join_req(struct host_if_drv *hif_drv)
3650 struct host_if_msg msg;
3652 if (!gu8FlushedJoinReq) {
3660 PRINT_ER("Driver is null\n");
3664 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
3667 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3669 PRINT_ER("Failed to send message queue: Flush join request\n");
3676 s32 host_int_disconnect(struct host_if_drv *hif_drv, u16 u16ReasonCode)
3679 struct host_if_msg msg;
3682 PRINT_ER("Driver is null\n");
3686 memset(&msg, 0, sizeof(struct host_if_msg));
3688 msg.id = HOST_IF_MSG_DISCONNECT;
3691 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3693 PRINT_ER("Failed to send message queue: disconnect\n");
3695 down(&hif_drv->hSemTestDisconnectBlock);
3700 s32 host_int_disconnect_station(struct host_if_drv *hif_drv, u8 assoc_id)
3704 strWID.id = (u16)WID_DISCONNECT;
3705 strWID.type = WID_CHAR;
3706 strWID.val = (s8 *)&assoc_id;
3707 strWID.size = sizeof(char);
3712 s32 host_int_get_assoc_req_info(struct host_if_drv *hif_drv, u8 *pu8AssocReqInfo,
3713 u32 u32AssocReqInfoLen)
3717 strWID.id = (u16)WID_ASSOC_REQ_INFO;
3718 strWID.type = WID_STR;
3719 strWID.val = pu8AssocReqInfo;
3720 strWID.size = u32AssocReqInfoLen;
3725 s32 host_int_get_assoc_res_info(struct host_if_drv *hif_drv, u8 *pu8AssocRespInfo,
3726 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
3732 PRINT_ER("Driver is null\n");
3736 strWID.id = (u16)WID_ASSOC_RES_INFO;
3737 strWID.type = WID_STR;
3738 strWID.val = pu8AssocRespInfo;
3739 strWID.size = u32MaxAssocRespInfoLen;
3741 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
3742 get_id_from_handler(hif_drv));
3744 *pu32RcvdAssocRespInfoLen = 0;
3745 PRINT_ER("Failed to send association response config packet\n");
3748 *pu32RcvdAssocRespInfoLen = strWID.size;
3754 s32 host_int_get_rx_power_level(struct host_if_drv *hif_drv, u8 *pu8RxPowerLevel,
3755 u32 u32RxPowerLevelLen)
3759 strWID.id = (u16)WID_RX_POWER_LEVEL;
3760 strWID.type = WID_STR;
3761 strWID.val = pu8RxPowerLevel;
3762 strWID.size = u32RxPowerLevelLen;
3767 int host_int_set_mac_chnl_num(struct host_if_drv *hif_drv, u8 channel)
3770 struct host_if_msg msg;
3773 PRINT_ER("driver is null\n");
3777 memset(&msg, 0, sizeof(struct host_if_msg));
3778 msg.id = HOST_IF_MSG_SET_CHANNEL;
3779 msg.body.channel_info.set_ch = channel;
3782 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3784 PRINT_ER("wilc mq send fail\n");
3791 int host_int_wait_msg_queue_idle(void)
3795 struct host_if_msg msg;
3796 memset(&msg, 0, sizeof(struct host_if_msg));
3797 msg.id = HOST_IF_MSG_Q_IDLE;
3798 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3800 PRINT_ER("wilc mq send fail\n");
3804 down(&hWaitResponse);
3809 int host_int_set_wfi_drv_handler(struct host_if_drv *hif_drv)
3813 struct host_if_msg msg;
3814 memset(&msg, 0, sizeof(struct host_if_msg));
3815 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
3816 msg.body.drv.u32Address = get_id_from_handler(hif_drv);
3819 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3821 PRINT_ER("wilc mq send fail\n");
3828 int host_int_set_operation_mode(struct host_if_drv *hif_drv, u32 mode)
3832 struct host_if_msg msg;
3833 memset(&msg, 0, sizeof(struct host_if_msg));
3834 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
3835 msg.body.mode.u32Mode = mode;
3838 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3840 PRINT_ER("wilc mq send fail\n");
3847 s32 host_int_get_host_chnl_num(struct host_if_drv *hif_drv, u8 *pu8ChNo)
3850 struct host_if_msg msg;
3853 PRINT_ER("driver is null\n");
3857 memset(&msg, 0, sizeof(struct host_if_msg));
3859 msg.id = HOST_IF_MSG_GET_CHNL;
3862 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3864 PRINT_ER("wilc mq send fail\n");
3865 down(&hif_drv->hSemGetCHNL);
3874 s32 host_int_get_inactive_time(struct host_if_drv *hif_drv,
3875 const u8 *mac, u32 *pu32InactiveTime)
3878 struct host_if_msg msg;
3881 PRINT_ER("driver is null\n");
3885 memset(&msg, 0, sizeof(struct host_if_msg));
3888 memcpy(msg.body.mac_info.mac,
3891 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
3894 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3896 PRINT_ER("Failed to send get host channel param's message queue ");
3898 down(&hif_drv->hSemInactiveTime);
3900 *pu32InactiveTime = gu32InactiveTime;
3905 s32 host_int_test_get_int_wid(struct host_if_drv *hif_drv, u32 *pu32TestMemAddr)
3912 PRINT_ER("driver is null\n");
3916 strWID.id = (u16)WID_MEMORY_ADDRESS;
3917 strWID.type = WID_INT;
3918 strWID.val = (s8 *)pu32TestMemAddr;
3919 strWID.size = sizeof(u32);
3921 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
3922 get_id_from_handler(hif_drv));
3925 PRINT_ER("Failed to get wid value\n");
3928 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
3935 s32 host_int_get_rssi(struct host_if_drv *hif_drv, s8 *ps8Rssi)
3938 struct host_if_msg msg;
3939 memset(&msg, 0, sizeof(struct host_if_msg));
3941 msg.id = HOST_IF_MSG_GET_RSSI;
3944 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3946 PRINT_ER("Failed to send get host channel param's message queue ");
3950 down(&hif_drv->hSemGetRSSI);
3953 if (ps8Rssi == NULL) {
3954 PRINT_ER("RSS pointer value is null");
3965 s32 host_int_get_link_speed(struct host_if_drv *hif_drv, s8 *ps8lnkspd)
3967 struct host_if_msg msg;
3969 memset(&msg, 0, sizeof(struct host_if_msg));
3971 msg.id = HOST_IF_MSG_GET_LINKSPEED;
3974 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3976 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
3980 down(&hif_drv->hSemGetLINKSPEED);
3983 if (ps8lnkspd == NULL) {
3984 PRINT_ER("LINKSPEED pointer value is null");
3989 *ps8lnkspd = gs8lnkspd;
3995 s32 host_int_get_statistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
3998 struct host_if_msg msg;
3999 memset(&msg, 0, sizeof(struct host_if_msg));
4001 msg.id = HOST_IF_MSG_GET_STATISTICS;
4002 msg.body.data = (char *)pstrStatistics;
4005 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4007 PRINT_ER("Failed to send get host channel param's message queue ");
4011 down(&hWaitResponse);
4015 s32 host_int_scan(struct host_if_drv *hif_drv, u8 u8ScanSource,
4016 u8 u8ScanType, u8 *pu8ChnlFreqList,
4017 u8 u8ChnlListLen, const u8 *pu8IEs,
4018 size_t IEsLen, wilc_scan_result ScanResult,
4019 void *pvUserArg, struct hidden_network *pstrHiddenNetwork)
4022 struct host_if_msg msg;
4023 enum scan_conn_timer enuScanConnTimer;
4025 if (!hif_drv || ScanResult == NULL) {
4026 PRINT_ER("hif_drv or ScanResult = NULL\n");
4030 memset(&msg, 0, sizeof(struct host_if_msg));
4032 msg.id = HOST_IF_MSG_SCAN;
4034 if (pstrHiddenNetwork != NULL) {
4035 msg.body.scan_info.hidden_network.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
4036 msg.body.scan_info.hidden_network.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
4039 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
4042 msg.body.scan_info.src = u8ScanSource;
4043 msg.body.scan_info.type = u8ScanType;
4044 msg.body.scan_info.result = ScanResult;
4045 msg.body.scan_info.arg = pvUserArg;
4047 msg.body.scan_info.ch_list_len = u8ChnlListLen;
4048 msg.body.scan_info.ch_freq_list = kmalloc(u8ChnlListLen, GFP_KERNEL);
4049 memcpy(msg.body.scan_info.ch_freq_list, pu8ChnlFreqList, u8ChnlListLen);
4051 msg.body.scan_info.ies_len = IEsLen;
4052 msg.body.scan_info.ies = kmalloc(IEsLen, GFP_KERNEL);
4053 memcpy(msg.body.scan_info.ies, pu8IEs, IEsLen);
4055 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4057 PRINT_ER("Error in sending message queue\n");
4061 enuScanConnTimer = SCAN_TIMER;
4062 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
4063 hif_drv->hScanTimer.data = (unsigned long)hif_drv;
4064 mod_timer(&hif_drv->hScanTimer,
4065 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
4071 s32 hif_set_cfg(struct host_if_drv *hif_drv,
4072 struct cfg_param_val *pstrCfgParamVal)
4076 struct host_if_msg msg;
4080 PRINT_ER("hif_drv NULL\n");
4084 memset(&msg, 0, sizeof(struct host_if_msg));
4085 msg.id = HOST_IF_MSG_CFG_PARAMS;
4086 msg.body.cfg_info.cfg_attr_info = *pstrCfgParamVal;
4089 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4095 s32 hif_get_cfg(struct host_if_drv *hif_drv, u16 u16WID, u16 *pu16WID_Value)
4099 down(&hif_drv->gtOsCfgValuesSem);
4102 PRINT_ER("hif_drv NULL\n");
4105 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
4109 *pu16WID_Value = (u16)hif_drv->strCfgValues.bss_type;
4113 *pu16WID_Value = (u16)hif_drv->strCfgValues.auth_type;
4116 case WID_AUTH_TIMEOUT:
4117 *pu16WID_Value = hif_drv->strCfgValues.auth_timeout;
4120 case WID_POWER_MANAGEMENT:
4121 *pu16WID_Value = (u16)hif_drv->strCfgValues.power_mgmt_mode;
4124 case WID_SHORT_RETRY_LIMIT:
4125 *pu16WID_Value = hif_drv->strCfgValues.short_retry_limit;
4128 case WID_LONG_RETRY_LIMIT:
4129 *pu16WID_Value = hif_drv->strCfgValues.long_retry_limit;
4132 case WID_FRAG_THRESHOLD:
4133 *pu16WID_Value = hif_drv->strCfgValues.frag_threshold;
4136 case WID_RTS_THRESHOLD:
4137 *pu16WID_Value = hif_drv->strCfgValues.rts_threshold;
4141 *pu16WID_Value = (u16)hif_drv->strCfgValues.preamble_type;
4144 case WID_SHORT_SLOT_ALLOWED:
4145 *pu16WID_Value = (u16) hif_drv->strCfgValues.short_slot_allowed;
4148 case WID_11N_TXOP_PROT_DISABLE:
4149 *pu16WID_Value = (u16)hif_drv->strCfgValues.txop_prot_disabled;
4152 case WID_BEACON_INTERVAL:
4153 *pu16WID_Value = hif_drv->strCfgValues.beacon_interval;
4156 case WID_DTIM_PERIOD:
4157 *pu16WID_Value = (u16)hif_drv->strCfgValues.dtim_period;
4160 case WID_SITE_SURVEY:
4161 *pu16WID_Value = (u16)hif_drv->strCfgValues.site_survey_enabled;
4164 case WID_SITE_SURVEY_SCAN_TIME:
4165 *pu16WID_Value = hif_drv->strCfgValues.site_survey_scan_time;
4168 case WID_ACTIVE_SCAN_TIME:
4169 *pu16WID_Value = hif_drv->strCfgValues.active_scan_time;
4172 case WID_PASSIVE_SCAN_TIME:
4173 *pu16WID_Value = hif_drv->strCfgValues.passive_scan_time;
4176 case WID_CURRENT_TX_RATE:
4177 *pu16WID_Value = hif_drv->strCfgValues.curr_tx_rate;
4184 up(&hif_drv->gtOsCfgValuesSem);
4190 void host_int_send_join_leave_info_to_host
4191 (u16 assocId, u8 *stationAddr, bool joining)
4195 static void GetPeriodicRSSI(unsigned long arg)
4197 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
4200 PRINT_ER("Driver handler is NULL\n");
4204 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED) {
4206 struct host_if_msg msg;
4208 memset(&msg, 0, sizeof(struct host_if_msg));
4210 msg.id = HOST_IF_MSG_GET_RSSI;
4213 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4215 PRINT_ER("Failed to send get host channel param's message queue ");
4219 g_hPeriodicRSSI.data = (unsigned long)hif_drv;
4220 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
4224 void host_int_send_network_info_to_host
4225 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
4229 static u32 clients_count;
4231 s32 host_int_init(struct host_if_drv **hif_drv_handler)
4234 struct host_if_drv *hif_drv;
4237 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
4239 gbScanWhileConnected = false;
4241 sema_init(&hWaitResponse, 0);
4243 hif_drv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
4248 *hif_drv_handler = hif_drv;
4249 err = add_handler_in_list(hif_drv);
4255 g_obtainingIP = false;
4257 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", hif_drv);
4258 if (clients_count == 0) {
4259 sema_init(&hSemHostIFthrdEnd, 0);
4260 sema_init(&hSemDeinitDrvHandle, 0);
4261 sema_init(&hSemHostIntDeinit, 1);
4264 sema_init(&hif_drv->hSemTestKeyBlock, 0);
4265 sema_init(&hif_drv->hSemTestDisconnectBlock, 0);
4266 sema_init(&hif_drv->hSemGetRSSI, 0);
4267 sema_init(&hif_drv->hSemGetLINKSPEED, 0);
4268 sema_init(&hif_drv->hSemGetCHNL, 0);
4269 sema_init(&hif_drv->hSemInactiveTime, 0);
4271 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
4273 if (clients_count == 0) {
4274 result = wilc_mq_create(&gMsgQHostIF);
4277 PRINT_ER("Failed to creat MQ\n");
4280 HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread");
4281 if (IS_ERR(HostIFthreadHandler)) {
4282 PRINT_ER("Failed to creat Thread\n");
4286 setup_timer(&g_hPeriodicRSSI, GetPeriodicRSSI,
4287 (unsigned long)hif_drv);
4288 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
4291 setup_timer(&hif_drv->hScanTimer, TimerCB_Scan, 0);
4293 setup_timer(&hif_drv->hConnectTimer, TimerCB_Connect, 0);
4295 setup_timer(&hif_drv->hRemainOnChannel, ListenTimerCB, 0);
4297 sema_init(&(hif_drv->gtOsCfgValuesSem), 1);
4298 down(&hif_drv->gtOsCfgValuesSem);
4300 hif_drv->enuHostIFstate = HOST_IF_IDLE;
4301 hif_drv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
4302 hif_drv->strCfgValues.scan_source = DEFAULT_SCAN;
4303 hif_drv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
4304 hif_drv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
4305 hif_drv->strCfgValues.curr_tx_rate = AUTORATE;
4307 hif_drv->u64P2p_MgmtTimeout = 0;
4309 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",
4311 hif_drv->strCfgValues.site_survey_enabled, hif_drv->strCfgValues.scan_source,
4312 hif_drv->strCfgValues.active_scan_time, hif_drv->strCfgValues.passive_scan_time,
4313 hif_drv->strCfgValues.curr_tx_rate);
4315 up(&hif_drv->gtOsCfgValuesSem);
4322 up(&hif_drv->gtOsCfgValuesSem);
4323 del_timer_sync(&hif_drv->hConnectTimer);
4324 del_timer_sync(&hif_drv->hScanTimer);
4325 kthread_stop(HostIFthreadHandler);
4327 wilc_mq_destroy(&gMsgQHostIF);
4332 s32 host_int_deinit(struct host_if_drv *hif_drv)
4335 struct host_if_msg msg;
4339 PRINT_ER("hif_drv = NULL\n");
4343 down(&hSemHostIntDeinit);
4345 terminated_handle = hif_drv;
4346 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
4348 if (del_timer_sync(&hif_drv->hScanTimer)) {
4349 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
4352 if (del_timer_sync(&hif_drv->hConnectTimer)) {
4353 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4357 if (del_timer_sync(&g_hPeriodicRSSI)) {
4358 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4361 del_timer_sync(&hif_drv->hRemainOnChannel);
4363 host_int_set_wfi_drv_handler(NULL);
4364 down(&hSemDeinitDrvHandle);
4366 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
4367 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
4368 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
4370 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
4373 hif_drv->enuHostIFstate = HOST_IF_IDLE;
4375 gbScanWhileConnected = false;
4377 memset(&msg, 0, sizeof(struct host_if_msg));
4379 if (clients_count == 1) {
4380 if (del_timer_sync(&g_hPeriodicRSSI)) {
4381 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4383 msg.id = HOST_IF_MSG_EXIT;
4387 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4389 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
4391 down(&hSemHostIFthrdEnd);
4393 wilc_mq_destroy(&gMsgQHostIF);
4396 down(&(hif_drv->gtOsCfgValuesSem));
4398 ret = remove_handler_in_list(hif_drv);
4405 terminated_handle = NULL;
4406 up(&hSemHostIntDeinit);
4410 void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
4413 struct host_if_msg msg;
4415 struct host_if_drv *hif_drv = NULL;
4417 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4418 hif_drv = get_handler_from_id(id);
4423 if (!hif_drv || hif_drv == terminated_handle) {
4424 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv);
4428 memset(&msg, 0, sizeof(struct host_if_msg));
4430 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
4433 msg.body.net_info.len = u32Length;
4434 msg.body.net_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4435 memcpy(msg.body.net_info.buffer, pu8Buffer, u32Length);
4437 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4439 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
4442 void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
4445 struct host_if_msg msg;
4447 struct host_if_drv *hif_drv = NULL;
4449 down(&hSemHostIntDeinit);
4451 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4452 hif_drv = get_handler_from_id(id);
4453 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
4456 if (!hif_drv || hif_drv == terminated_handle) {
4457 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
4458 up(&hSemHostIntDeinit);
4462 if (!hif_drv->strWILC_UsrConnReq.pfUserConnectResult) {
4463 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
4464 up(&hSemHostIntDeinit);
4468 memset(&msg, 0, sizeof(struct host_if_msg));
4471 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
4474 msg.body.async_info.len = u32Length;
4475 msg.body.async_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4476 memcpy(msg.body.async_info.buffer, pu8Buffer, u32Length);
4478 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4480 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
4482 up(&hSemHostIntDeinit);
4485 void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
4488 struct host_if_msg msg;
4490 struct host_if_drv *hif_drv = NULL;
4492 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4493 hif_drv = get_handler_from_id(id);
4496 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", hif_drv);
4498 if (!hif_drv || hif_drv == terminated_handle)
4501 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
4502 memset(&msg, 0, sizeof(struct host_if_msg));
4504 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
4507 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4509 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
4517 s32 host_int_remain_on_channel(struct host_if_drv *hif_drv, u32 u32SessionID,
4518 u32 u32duration, u16 chan,
4519 wilc_remain_on_chan_expired RemainOnChanExpired,
4520 wilc_remain_on_chan_ready RemainOnChanReady,
4524 struct host_if_msg msg;
4527 PRINT_ER("driver is null\n");
4531 memset(&msg, 0, sizeof(struct host_if_msg));
4533 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
4534 msg.body.remain_on_ch.u16Channel = chan;
4535 msg.body.remain_on_ch.pRemainOnChanExpired = RemainOnChanExpired;
4536 msg.body.remain_on_ch.pRemainOnChanReady = RemainOnChanReady;
4537 msg.body.remain_on_ch.pVoid = pvUserArg;
4538 msg.body.remain_on_ch.u32duration = u32duration;
4539 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
4542 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4544 PRINT_ER("wilc mq send fail\n");
4549 s32 host_int_ListenStateExpired(struct host_if_drv *hif_drv, u32 u32SessionID)
4552 struct host_if_msg msg;
4555 PRINT_ER("driver is null\n");
4559 del_timer(&hif_drv->hRemainOnChannel);
4561 memset(&msg, 0, sizeof(struct host_if_msg));
4562 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
4564 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
4566 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4568 PRINT_ER("wilc mq send fail\n");
4573 s32 host_int_frame_register(struct host_if_drv *hif_drv, u16 u16FrameType, bool bReg)
4576 struct host_if_msg msg;
4579 PRINT_ER("driver is null\n");
4583 memset(&msg, 0, sizeof(struct host_if_msg));
4585 msg.id = HOST_IF_MSG_REGISTER_FRAME;
4586 switch (u16FrameType) {
4588 PRINT_D(HOSTINF_DBG, "ACTION\n");
4589 msg.body.reg_frame.u8Regid = ACTION_FRM_IDX;
4593 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
4594 msg.body.reg_frame.u8Regid = PROBE_REQ_IDX;
4598 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
4601 msg.body.reg_frame.u16FrameType = u16FrameType;
4602 msg.body.reg_frame.bReg = bReg;
4605 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4607 PRINT_ER("wilc mq send fail\n");
4614 s32 host_int_add_beacon(struct host_if_drv *hif_drv, u32 u32Interval,
4615 u32 u32DTIMPeriod, u32 u32HeadLen, u8 *pu8Head,
4616 u32 u32TailLen, u8 *pu8Tail)
4619 struct host_if_msg msg;
4620 struct beacon_attr *pstrSetBeaconParam = &msg.body.beacon_info;
4623 PRINT_ER("driver is null\n");
4627 memset(&msg, 0, sizeof(struct host_if_msg));
4629 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
4631 msg.id = HOST_IF_MSG_ADD_BEACON;
4633 pstrSetBeaconParam->interval = u32Interval;
4634 pstrSetBeaconParam->dtim_period = u32DTIMPeriod;
4635 pstrSetBeaconParam->head_len = u32HeadLen;
4636 pstrSetBeaconParam->head = kmalloc(u32HeadLen, GFP_KERNEL);
4637 if (pstrSetBeaconParam->head == NULL) {
4641 memcpy(pstrSetBeaconParam->head, pu8Head, u32HeadLen);
4642 pstrSetBeaconParam->tail_len = u32TailLen;
4644 if (u32TailLen > 0) {
4645 pstrSetBeaconParam->tail = kmalloc(u32TailLen, GFP_KERNEL);
4646 if (pstrSetBeaconParam->tail == NULL) {
4650 memcpy(pstrSetBeaconParam->tail, pu8Tail, u32TailLen);
4652 pstrSetBeaconParam->tail = NULL;
4655 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4657 PRINT_ER("wilc mq send fail\n");
4661 if (pstrSetBeaconParam->head != NULL)
4662 kfree(pstrSetBeaconParam->head);
4664 if (pstrSetBeaconParam->tail != NULL)
4665 kfree(pstrSetBeaconParam->tail);
4672 s32 host_int_del_beacon(struct host_if_drv *hif_drv)
4675 struct host_if_msg msg;
4678 PRINT_ER("driver is null\n");
4682 msg.id = HOST_IF_MSG_DEL_BEACON;
4684 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
4686 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4688 PRINT_ER("wilc_mq_send fail\n");
4693 s32 host_int_add_station(struct host_if_drv *hif_drv,
4694 struct add_sta_param *pstrStaParams)
4697 struct host_if_msg msg;
4698 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
4702 PRINT_ER("driver is null\n");
4706 memset(&msg, 0, sizeof(struct host_if_msg));
4708 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
4710 msg.id = HOST_IF_MSG_ADD_STATION;
4713 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
4714 if (pstrAddStationMsg->u8NumRates > 0) {
4715 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
4720 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
4721 pstrAddStationMsg->pu8Rates = rates;
4725 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4727 PRINT_ER("wilc_mq_send fail\n");
4731 s32 host_int_del_station(struct host_if_drv *hif_drv, const u8 *pu8MacAddr)
4734 struct host_if_msg msg;
4735 struct del_sta *pstrDelStationMsg = &msg.body.del_sta_info;
4738 PRINT_ER("driver is null\n");
4742 memset(&msg, 0, sizeof(struct host_if_msg));
4744 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
4746 msg.id = HOST_IF_MSG_DEL_STATION;
4749 if (pu8MacAddr == NULL)
4750 memset(pstrDelStationMsg->mac_addr, 255, ETH_ALEN);
4752 memcpy(pstrDelStationMsg->mac_addr, pu8MacAddr, ETH_ALEN);
4754 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4756 PRINT_ER("wilc_mq_send fail\n");
4760 s32 host_int_del_allstation(struct host_if_drv *hif_drv,
4761 u8 pu8MacAddr[][ETH_ALEN])
4764 struct host_if_msg msg;
4765 struct del_all_sta *pstrDelAllStationMsg = &msg.body.del_all_sta_info;
4766 u8 au8Zero_Buff[ETH_ALEN] = {0};
4772 PRINT_ER("driver is null\n");
4776 memset(&msg, 0, sizeof(struct host_if_msg));
4778 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
4780 msg.id = HOST_IF_MSG_DEL_ALL_STA;
4783 for (i = 0; i < MAX_NUM_STA; i++) {
4784 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
4785 memcpy(pstrDelAllStationMsg->del_all_sta[i], pu8MacAddr[i], ETH_ALEN);
4786 PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n",
4787 pstrDelAllStationMsg->del_all_sta[i][0],
4788 pstrDelAllStationMsg->del_all_sta[i][1],
4789 pstrDelAllStationMsg->del_all_sta[i][2],
4790 pstrDelAllStationMsg->del_all_sta[i][3],
4791 pstrDelAllStationMsg->del_all_sta[i][4],
4792 pstrDelAllStationMsg->del_all_sta[i][5]);
4797 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
4801 pstrDelAllStationMsg->assoc_sta = u8AssocNumb;
4802 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4806 PRINT_ER("wilc_mq_send fail\n");
4808 down(&hWaitResponse);
4814 s32 host_int_edit_station(struct host_if_drv *hif_drv,
4815 struct add_sta_param *pstrStaParams)
4818 struct host_if_msg msg;
4819 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
4822 PRINT_ER("driver is null\n");
4826 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
4828 memset(&msg, 0, sizeof(struct host_if_msg));
4830 msg.id = HOST_IF_MSG_EDIT_STATION;
4833 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
4834 if (pstrAddStationMsg->u8NumRates > 0) {
4835 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
4840 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
4841 pstrAddStationMsg->pu8Rates = rates;
4844 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4846 PRINT_ER("wilc_mq_send fail\n");
4851 s32 host_int_set_power_mgmt(struct host_if_drv *hif_drv,
4856 struct host_if_msg msg;
4857 struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.pwr_mgmt_info;
4859 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
4862 PRINT_ER("driver is null\n");
4866 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
4868 memset(&msg, 0, sizeof(struct host_if_msg));
4870 msg.id = HOST_IF_MSG_POWER_MGMT;
4873 pstrPowerMgmtParam->enabled = bIsEnabled;
4874 pstrPowerMgmtParam->timeout = u32Timeout;
4876 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4878 PRINT_ER("wilc_mq_send fail\n");
4882 s32 host_int_setup_multicast_filter(struct host_if_drv *hif_drv,
4887 struct host_if_msg msg;
4888 struct set_multicast *pstrMulticastFilterParam = &msg.body.multicast_info;
4892 PRINT_ER("driver is null\n");
4896 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
4898 memset(&msg, 0, sizeof(struct host_if_msg));
4900 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
4903 pstrMulticastFilterParam->enabled = bIsEnabled;
4904 pstrMulticastFilterParam->cnt = u32count;
4906 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4908 PRINT_ER("wilc_mq_send fail\n");
4912 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
4914 struct join_bss_param *pNewJoinBssParam = NULL;
4923 u8 pcipherTotalCount = 0;
4924 u8 authTotalCount = 0;
4927 pu8IEs = ptstrNetworkInfo->pu8IEs;
4928 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
4930 pNewJoinBssParam = kzalloc(sizeof(struct join_bss_param), GFP_KERNEL);
4931 if (pNewJoinBssParam != NULL) {
4932 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
4933 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
4934 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
4935 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
4936 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
4937 pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen;
4938 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
4939 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
4941 while (index < u16IEsLen) {
4942 if (pu8IEs[index] == SUPP_RATES_IE) {
4943 suppRatesNo = pu8IEs[index + 1];
4944 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
4947 for (i = 0; i < suppRatesNo; i++) {
4948 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
4950 index += suppRatesNo;
4952 } else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
4953 extSuppRatesNo = pu8IEs[index + 1];
4954 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
4955 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
4957 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
4959 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
4960 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
4962 index += extSuppRatesNo;
4964 } else if (pu8IEs[index] == HT_CAPABILITY_IE) {
4965 pNewJoinBssParam->ht_capable = true;
4966 index += pu8IEs[index + 1] + 2;
4968 } else if ((pu8IEs[index] == WMM_IE) &&
4969 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
4970 (pu8IEs[index + 4] == 0xF2) &&
4971 (pu8IEs[index + 5] == 0x02) &&
4972 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) &&
4973 (pu8IEs[index + 7] == 0x01)) {
4974 pNewJoinBssParam->wmm_cap = true;
4976 if (pu8IEs[index + 8] & BIT(7))
4977 pNewJoinBssParam->uapsd_cap = true;
4978 index += pu8IEs[index + 1] + 2;
4980 } else if ((pu8IEs[index] == P2P_IE) &&
4981 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
4982 (pu8IEs[index + 4] == 0x9a) &&
4983 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) {
4986 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
4987 pNewJoinBssParam->u8NoaEnbaled = 1;
4988 pNewJoinBssParam->u8Index = pu8IEs[index + 9];
4990 if (pu8IEs[index + 10] & BIT(7)) {
4991 pNewJoinBssParam->u8OppEnable = 1;
4992 pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10];
4994 pNewJoinBssParam->u8OppEnable = 0;
4996 PRINT_D(GENERIC_DBG, "P2P Dump\n");
4997 for (i = 0; i < pu8IEs[index + 7]; i++)
4998 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
5000 pNewJoinBssParam->u8Count = pu8IEs[index + 11];
5001 u16P2P_count = index + 12;
5003 memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4);
5006 memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4);
5009 memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
5011 index += pu8IEs[index + 1] + 2;
5014 } else if ((pu8IEs[index] == RSN_IE) ||
5015 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
5016 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
5017 (pu8IEs[index + 5] == 0x01))) {
5018 u16 rsnIndex = index;
5020 if (pu8IEs[rsnIndex] == RSN_IE) {
5021 pNewJoinBssParam->mode_802_11i = 2;
5023 if (pNewJoinBssParam->mode_802_11i == 0)
5024 pNewJoinBssParam->mode_802_11i = 1;
5029 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
5031 jumpOffset = pu8IEs[rsnIndex] * 4;
5032 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
5035 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
5036 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
5038 pcipherTotalCount += pcipherCount;
5039 rsnIndex += jumpOffset;
5041 jumpOffset = pu8IEs[rsnIndex] * 4;
5043 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
5046 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
5047 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
5049 authTotalCount += authCount;
5050 rsnIndex += jumpOffset;
5052 if (pu8IEs[index] == RSN_IE) {
5053 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
5054 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
5057 pNewJoinBssParam->rsn_found = true;
5058 index += pu8IEs[index + 1] + 2;
5061 index += pu8IEs[index + 1] + 2;
5068 return (void *)pNewJoinBssParam;
5072 void host_int_freeJoinParams(void *pJoinParams)
5074 if ((struct bss_param *)pJoinParams != NULL)
5075 kfree((struct bss_param *)pJoinParams);
5077 PRINT_ER("Unable to FREE null pointer\n");
5080 s32 host_int_delBASession(struct host_if_drv *hif_drv, char *pBSSID, char TID)
5083 struct host_if_msg msg;
5084 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
5087 PRINT_ER("driver is null\n");
5091 memset(&msg, 0, sizeof(struct host_if_msg));
5093 msg.id = HOST_IF_MSG_DEL_BA_SESSION;
5095 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
5096 pBASessionInfo->u8Ted = TID;
5099 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5101 PRINT_ER("wilc_mq_send fail\n");
5103 down(&hWaitResponse);
5108 s32 host_int_del_All_Rx_BASession(struct host_if_drv *hif_drv,
5113 struct host_if_msg msg;
5114 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
5117 PRINT_ER("driver is null\n");
5121 memset(&msg, 0, sizeof(struct host_if_msg));
5123 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
5125 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
5126 pBASessionInfo->u8Ted = TID;
5129 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5131 PRINT_ER("wilc_mq_send fail\n");
5133 down(&hWaitResponse);
5138 s32 host_int_setup_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
5141 struct host_if_msg msg;
5146 PRINT_ER("driver is null\n");
5150 memset(&msg, 0, sizeof(struct host_if_msg));
5152 msg.id = HOST_IF_MSG_SET_IPADDRESS;
5154 msg.body.ip_info.ip_addr = u16ipadd;
5156 msg.body.ip_info.idx = idx;
5158 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5160 PRINT_ER("wilc_mq_send fail\n");
5167 s32 host_int_get_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
5170 struct host_if_msg msg;
5173 PRINT_ER("driver is null\n");
5177 memset(&msg, 0, sizeof(struct host_if_msg));
5179 msg.id = HOST_IF_MSG_GET_IPADDRESS;
5181 msg.body.ip_info.ip_addr = u16ipadd;
5183 msg.body.ip_info.idx = idx;
5185 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5187 PRINT_ER("wilc_mq_send fail\n");