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 = kmalloc(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 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
1879 if (pstrHostIFkeyAttr->attr.wpa.seq != NULL)
1880 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1882 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1883 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1884 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1885 pstrHostIFkeyAttr->attr.wpa.key_len);
1887 strWIDList[0].id = (u16)WID_11I_MODE;
1888 strWIDList[0].type = WID_CHAR;
1889 strWIDList[0].size = sizeof(char);
1890 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wpa.mode));
1892 strWIDList[1].id = (u16)WID_ADD_RX_GTK;
1893 strWIDList[1].type = WID_STR;
1894 strWIDList[1].val = (s8 *)pu8keybuf;
1895 strWIDList[1].size = RX_MIC_KEY_MSG_LEN;
1897 s32Error = send_config_pkt(SET_CFG, strWIDList, 2,
1898 get_id_from_handler(hif_drv));
1901 up(&hif_drv->hSemTestKeyBlock);
1904 if (pstrHostIFkeyAttr->action & ADDKEY) {
1905 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
1907 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1908 if (pu8keybuf == NULL) {
1909 PRINT_ER("No buffer to send RxGTK Key\n");
1911 goto _WPARxGtk_end_case_;
1914 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
1916 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)
1917 memcpy(pu8keybuf, hif_drv->au8AssociatedBSSID, ETH_ALEN);
1919 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
1921 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1922 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1923 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1924 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1925 pstrHostIFkeyAttr->attr.wpa.key_len);
1927 strWID.id = (u16)WID_ADD_RX_GTK;
1928 strWID.type = WID_STR;
1929 strWID.val = (s8 *)pu8keybuf;
1930 strWID.size = RX_MIC_KEY_MSG_LEN;
1932 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1933 get_id_from_handler(hif_drv));
1936 up(&hif_drv->hSemTestKeyBlock);
1938 _WPARxGtk_end_case_:
1939 kfree(pstrHostIFkeyAttr->attr.wpa.key);
1940 kfree(pstrHostIFkeyAttr->attr.wpa.seq);
1947 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1950 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
1954 if (pu8keybuf == NULL) {
1955 PRINT_ER("No buffer to send PTK Key\n");
1957 goto _WPAPtk_end_case_;
1961 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1962 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1963 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1964 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->attr.wpa.key,
1965 pstrHostIFkeyAttr->attr.wpa.key_len);
1967 strWIDList[0].id = (u16)WID_11I_MODE;
1968 strWIDList[0].type = WID_CHAR;
1969 strWIDList[0].size = sizeof(char);
1970 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wpa.mode));
1972 strWIDList[1].id = (u16)WID_ADD_PTK;
1973 strWIDList[1].type = WID_STR;
1974 strWIDList[1].val = (s8 *)pu8keybuf;
1975 strWIDList[1].size = PTK_KEY_MSG_LEN + 1;
1977 s32Error = send_config_pkt(SET_CFG, strWIDList, 2,
1978 get_id_from_handler(hif_drv));
1980 up(&hif_drv->hSemTestKeyBlock);
1982 if (pstrHostIFkeyAttr->action & ADDKEY) {
1985 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
1989 if (pu8keybuf == NULL) {
1990 PRINT_ER("No buffer to send PTK Key\n");
1992 goto _WPAPtk_end_case_;
1996 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1997 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1998 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->attr.wpa.key,
1999 pstrHostIFkeyAttr->attr.wpa.key_len);
2001 strWID.id = (u16)WID_ADD_PTK;
2002 strWID.type = WID_STR;
2003 strWID.val = (s8 *)pu8keybuf;
2004 strWID.size = PTK_KEY_MSG_LEN;
2006 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2007 get_id_from_handler(hif_drv));
2009 up(&hif_drv->hSemTestKeyBlock);
2013 kfree(pstrHostIFkeyAttr->attr.wpa.key);
2022 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
2024 pu8keybuf = kmalloc((pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
2025 if (pu8keybuf == NULL) {
2026 PRINT_ER("No buffer to send PMKSA Key\n");
2030 pu8keybuf[0] = pstrHostIFkeyAttr->attr.pmkid.numpmkid;
2032 for (i = 0; i < pstrHostIFkeyAttr->attr.pmkid.numpmkid; i++) {
2033 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
2034 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
2037 strWID.id = (u16)WID_PMKID_INFO;
2038 strWID.type = WID_STR;
2039 strWID.val = (s8 *)pu8keybuf;
2040 strWID.size = (pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
2042 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2043 get_id_from_handler(hif_drv));
2050 PRINT_ER("Failed to send key config packet\n");
2056 static void Handle_Disconnect(struct host_if_drv *hif_drv)
2061 u16 u16DummyReasonCode = 0;
2063 strWID.id = (u16)WID_DISCONNECT;
2064 strWID.type = WID_CHAR;
2065 strWID.val = (s8 *)&u16DummyReasonCode;
2066 strWID.size = sizeof(char);
2070 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2072 g_obtainingIP = false;
2073 host_int_set_power_mgmt(hif_drv, 0, 0);
2075 eth_zero_addr(u8ConnectedSSID);
2077 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2078 get_id_from_handler(hif_drv));
2081 PRINT_ER("Failed to send dissconect config packet\n");
2083 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2085 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
2087 strDisconnectNotifInfo.u16reason = 0;
2088 strDisconnectNotifInfo.ie = NULL;
2089 strDisconnectNotifInfo.ie_len = 0;
2091 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
2092 del_timer(&hif_drv->hScanTimer);
2093 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
2094 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2096 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
2099 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2100 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2101 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
2102 del_timer(&hif_drv->hConnectTimer);
2105 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
2106 0, &strDisconnectNotifInfo, hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
2108 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
2111 gbScanWhileConnected = false;
2113 hif_drv->enuHostIFstate = HOST_IF_IDLE;
2115 eth_zero_addr(hif_drv->au8AssociatedBSSID);
2117 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
2118 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
2119 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
2120 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2121 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
2123 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
2124 kfree(gu8FlushedJoinReq);
2125 gu8FlushedJoinReq = NULL;
2127 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
2128 kfree(gu8FlushedInfoElemAsoc);
2129 gu8FlushedInfoElemAsoc = NULL;
2134 up(&hif_drv->hSemTestDisconnectBlock);
2138 void resolve_disconnect_aberration(struct host_if_drv *hif_drv)
2142 if ((hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (hif_drv->enuHostIFstate == HOST_IF_CONNECTING)) {
2143 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
2144 host_int_disconnect(hif_drv, 1);
2148 static s32 Handle_GetChnl(struct host_if_drv *hif_drv)
2154 strWID.id = (u16)WID_CURRENT_CHANNEL;
2155 strWID.type = WID_CHAR;
2156 strWID.val = (s8 *)&gu8Chnl;
2157 strWID.size = sizeof(char);
2159 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
2161 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2162 get_id_from_handler(hif_drv));
2165 PRINT_ER("Failed to get channel number\n");
2169 up(&hif_drv->hSemGetCHNL);
2177 static void Handle_GetRssi(struct host_if_drv *hif_drv)
2182 strWID.id = (u16)WID_RSSI;
2183 strWID.type = WID_CHAR;
2184 strWID.val = &gs8Rssi;
2185 strWID.size = sizeof(char);
2187 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
2189 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2190 get_id_from_handler(hif_drv));
2192 PRINT_ER("Failed to get RSSI value\n");
2196 up(&hif_drv->hSemGetRSSI);
2202 static void Handle_GetLinkspeed(struct host_if_drv *hif_drv)
2209 strWID.id = (u16)WID_LINKSPEED;
2210 strWID.type = WID_CHAR;
2211 strWID.val = &gs8lnkspd;
2212 strWID.size = sizeof(char);
2214 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
2216 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2217 get_id_from_handler(hif_drv));
2219 PRINT_ER("Failed to get LINKSPEED value\n");
2223 up(&(hif_drv->hSemGetLINKSPEED));
2228 s32 Handle_GetStatistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
2230 struct wid strWIDList[5];
2231 u32 u32WidsCount = 0, s32Error = 0;
2233 strWIDList[u32WidsCount].id = WID_LINKSPEED;
2234 strWIDList[u32WidsCount].type = WID_CHAR;
2235 strWIDList[u32WidsCount].size = sizeof(char);
2236 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u8LinkSpeed));
2239 strWIDList[u32WidsCount].id = WID_RSSI;
2240 strWIDList[u32WidsCount].type = WID_CHAR;
2241 strWIDList[u32WidsCount].size = sizeof(char);
2242 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->s8RSSI));
2245 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
2246 strWIDList[u32WidsCount].type = WID_INT;
2247 strWIDList[u32WidsCount].size = sizeof(u32);
2248 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32TxCount));
2251 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
2252 strWIDList[u32WidsCount].type = WID_INT;
2253 strWIDList[u32WidsCount].size = sizeof(u32);
2254 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32RxCount));
2257 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
2258 strWIDList[u32WidsCount].type = WID_INT;
2259 strWIDList[u32WidsCount].size = sizeof(u32);
2260 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32TxFailureCount));
2263 s32Error = send_config_pkt(GET_CFG, strWIDList, u32WidsCount,
2264 get_id_from_handler(hif_drv));
2267 PRINT_ER("Failed to send scan paramters config packet\n");
2274 static s32 Handle_Get_InActiveTime(struct host_if_drv *hif_drv,
2275 struct sta_inactive_t *strHostIfStaInactiveT)
2282 strWID.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
2283 strWID.type = WID_STR;
2284 strWID.size = ETH_ALEN;
2285 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2288 stamac = strWID.val;
2289 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
2292 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
2295 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2296 get_id_from_handler(hif_drv));
2299 PRINT_ER("Failed to SET incative time\n");
2304 strWID.id = (u16)WID_GET_INACTIVE_TIME;
2305 strWID.type = WID_INT;
2306 strWID.val = (s8 *)&gu32InactiveTime;
2307 strWID.size = sizeof(u32);
2310 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2311 get_id_from_handler(hif_drv));
2314 PRINT_ER("Failed to get incative time\n");
2319 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
2321 up(&hif_drv->hSemInactiveTime);
2329 static void Handle_AddBeacon(struct host_if_drv *hif_drv,
2330 struct beacon_attr *pstrSetBeaconParam)
2336 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
2338 strWID.id = (u16)WID_ADD_BEACON;
2339 strWID.type = WID_BIN;
2340 strWID.size = pstrSetBeaconParam->head_len + pstrSetBeaconParam->tail_len + 16;
2341 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2342 if (strWID.val == NULL)
2345 pu8CurrByte = strWID.val;
2346 *pu8CurrByte++ = (pstrSetBeaconParam->interval & 0xFF);
2347 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 8) & 0xFF);
2348 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 16) & 0xFF);
2349 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 24) & 0xFF);
2351 *pu8CurrByte++ = (pstrSetBeaconParam->dtim_period & 0xFF);
2352 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 8) & 0xFF);
2353 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 16) & 0xFF);
2354 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 24) & 0xFF);
2356 *pu8CurrByte++ = (pstrSetBeaconParam->head_len & 0xFF);
2357 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 8) & 0xFF);
2358 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 16) & 0xFF);
2359 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 24) & 0xFF);
2361 memcpy(pu8CurrByte, pstrSetBeaconParam->head, pstrSetBeaconParam->head_len);
2362 pu8CurrByte += pstrSetBeaconParam->head_len;
2364 *pu8CurrByte++ = (pstrSetBeaconParam->tail_len & 0xFF);
2365 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 8) & 0xFF);
2366 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 16) & 0xFF);
2367 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 24) & 0xFF);
2369 if (pstrSetBeaconParam->tail > 0)
2370 memcpy(pu8CurrByte, pstrSetBeaconParam->tail, pstrSetBeaconParam->tail_len);
2371 pu8CurrByte += pstrSetBeaconParam->tail_len;
2373 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2374 get_id_from_handler(hif_drv));
2376 PRINT_ER("Failed to send add beacon config packet\n");
2380 kfree(pstrSetBeaconParam->head);
2381 kfree(pstrSetBeaconParam->tail);
2384 static void Handle_DelBeacon(struct host_if_drv *hif_drv)
2390 strWID.id = (u16)WID_DEL_BEACON;
2391 strWID.type = WID_CHAR;
2392 strWID.size = sizeof(char);
2393 strWID.val = &gu8DelBcn;
2395 if (strWID.val == NULL)
2398 pu8CurrByte = strWID.val;
2400 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
2402 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2403 get_id_from_handler(hif_drv));
2405 PRINT_ER("Failed to send delete beacon config packet\n");
2408 static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
2409 struct add_sta_param *pstrStationParam)
2413 pu8CurrByte = pu8Buffer;
2415 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
2416 memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
2417 pu8CurrByte += ETH_ALEN;
2419 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
2420 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
2422 *pu8CurrByte++ = pstrStationParam->u8NumRates;
2423 if (pstrStationParam->u8NumRates > 0)
2424 memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
2425 pu8CurrByte += pstrStationParam->u8NumRates;
2427 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
2428 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
2429 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
2431 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
2432 memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
2433 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
2435 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
2436 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
2438 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
2439 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
2440 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
2441 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
2443 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
2445 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
2446 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
2448 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
2449 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
2451 return pu8CurrByte - pu8Buffer;
2454 static void Handle_AddStation(struct host_if_drv *hif_drv,
2455 struct add_sta_param *pstrStationParam)
2461 PRINT_D(HOSTINF_DBG, "Handling add station\n");
2462 strWID.id = (u16)WID_ADD_STA;
2463 strWID.type = WID_BIN;
2464 strWID.size = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
2466 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2467 if (strWID.val == NULL)
2470 pu8CurrByte = strWID.val;
2471 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2473 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2474 get_id_from_handler(hif_drv));
2476 PRINT_ER("Failed to send add station config packet\n");
2479 kfree(pstrStationParam->pu8Rates);
2483 static void Handle_DelAllSta(struct host_if_drv *hif_drv,
2484 struct del_all_sta *pstrDelAllStaParam)
2491 u8 au8Zero_Buff[6] = {0};
2493 strWID.id = (u16)WID_DEL_ALL_STA;
2494 strWID.type = WID_STR;
2495 strWID.size = (pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1;
2497 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
2499 strWID.val = kmalloc((pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1, GFP_KERNEL);
2500 if (strWID.val == NULL)
2503 pu8CurrByte = strWID.val;
2505 *(pu8CurrByte++) = pstrDelAllStaParam->assoc_sta;
2507 for (i = 0; i < MAX_NUM_STA; i++) {
2508 if (memcmp(pstrDelAllStaParam->del_all_sta[i], au8Zero_Buff, ETH_ALEN))
2509 memcpy(pu8CurrByte, pstrDelAllStaParam->del_all_sta[i], ETH_ALEN);
2513 pu8CurrByte += ETH_ALEN;
2516 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2517 get_id_from_handler(hif_drv));
2519 PRINT_ER("Failed to send add station config packet\n");
2527 static void Handle_DelStation(struct host_if_drv *hif_drv,
2528 struct del_sta *pstrDelStaParam)
2534 strWID.id = (u16)WID_REMOVE_STA;
2535 strWID.type = WID_BIN;
2536 strWID.size = ETH_ALEN;
2538 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
2540 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2541 if (strWID.val == NULL)
2544 pu8CurrByte = strWID.val;
2546 memcpy(pu8CurrByte, pstrDelStaParam->mac_addr, ETH_ALEN);
2548 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2549 get_id_from_handler(hif_drv));
2551 PRINT_ER("Failed to send add station config packet\n");
2557 static void Handle_EditStation(struct host_if_drv *hif_drv,
2558 struct add_sta_param *pstrStationParam)
2564 strWID.id = (u16)WID_EDIT_STA;
2565 strWID.type = WID_BIN;
2566 strWID.size = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
2568 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
2569 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2570 if (strWID.val == NULL)
2573 pu8CurrByte = strWID.val;
2574 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2576 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2577 get_id_from_handler(hif_drv));
2579 PRINT_ER("Failed to send edit station config packet\n");
2582 kfree(pstrStationParam->pu8Rates);
2586 static int Handle_RemainOnChan(struct host_if_drv *hif_drv,
2587 struct remain_ch *pstrHostIfRemainOnChan)
2590 u8 u8remain_on_chan_flag;
2593 if (!hif_drv->u8RemainOnChan_pendingreq) {
2594 hif_drv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
2595 hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
2596 hif_drv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
2597 hif_drv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
2598 hif_drv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
2600 pstrHostIfRemainOnChan->u16Channel = hif_drv->strHostIfRemainOnChan.u16Channel;
2603 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
2604 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
2605 hif_drv->u8RemainOnChan_pendingreq = 1;
2609 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2610 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
2615 if (g_obtainingIP || connecting) {
2616 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
2621 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
2623 u8remain_on_chan_flag = true;
2624 strWID.id = (u16)WID_REMAIN_ON_CHAN;
2625 strWID.type = WID_STR;
2627 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2629 if (strWID.val == NULL) {
2634 strWID.val[0] = u8remain_on_chan_flag;
2635 strWID.val[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
2637 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2638 get_id_from_handler(hif_drv));
2640 PRINT_ER("Failed to set remain on channel\n");
2644 P2P_LISTEN_STATE = 1;
2645 hif_drv->hRemainOnChannel.data = (unsigned long)hif_drv;
2646 mod_timer(&hif_drv->hRemainOnChannel,
2648 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
2650 if (hif_drv->strHostIfRemainOnChan.pRemainOnChanReady)
2651 hif_drv->strHostIfRemainOnChan.pRemainOnChanReady(hif_drv->strHostIfRemainOnChan.pVoid);
2653 if (hif_drv->u8RemainOnChan_pendingreq)
2654 hif_drv->u8RemainOnChan_pendingreq = 0;
2659 static int Handle_RegisterFrame(struct host_if_drv *hif_drv,
2660 struct reg_frame *pstrHostIfRegisterFrame)
2666 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
2668 strWID.id = (u16)WID_REGISTER_FRAME;
2669 strWID.type = WID_STR;
2670 strWID.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
2671 if (strWID.val == NULL)
2674 pu8CurrByte = strWID.val;
2676 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
2677 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
2678 memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
2681 strWID.size = sizeof(u16) + 2;
2683 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2684 get_id_from_handler(hif_drv));
2686 PRINT_ER("Failed to frame register config packet\n");
2694 #define FALSE_FRMWR_CHANNEL 100
2695 static u32 Handle_ListenStateExpired(struct host_if_drv *hif_drv,
2696 struct remain_ch *pstrHostIfRemainOnChan)
2698 u8 u8remain_on_chan_flag;
2702 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
2704 if (P2P_LISTEN_STATE) {
2705 u8remain_on_chan_flag = false;
2706 strWID.id = (u16)WID_REMAIN_ON_CHAN;
2707 strWID.type = WID_STR;
2709 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2711 if (strWID.val == NULL)
2712 PRINT_ER("Failed to allocate memory\n");
2714 strWID.val[0] = u8remain_on_chan_flag;
2715 strWID.val[1] = FALSE_FRMWR_CHANNEL;
2717 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2718 get_id_from_handler(hif_drv));
2719 if (s32Error != 0) {
2720 PRINT_ER("Failed to set remain on channel\n");
2724 if (hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired) {
2725 hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired(hif_drv->strHostIfRemainOnChan.pVoid
2726 , pstrHostIfRemainOnChan->u32ListenSessionID);
2728 P2P_LISTEN_STATE = 0;
2730 PRINT_D(GENERIC_DBG, "Not in listen state\n");
2738 static void ListenTimerCB(unsigned long arg)
2741 struct host_if_msg msg;
2742 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
2744 del_timer(&hif_drv->hRemainOnChannel);
2746 memset(&msg, 0, sizeof(struct host_if_msg));
2747 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
2749 msg.body.remain_on_ch.u32ListenSessionID = hif_drv->strHostIfRemainOnChan.u32ListenSessionID;
2751 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
2753 PRINT_ER("wilc_mq_send fail\n");
2756 static void Handle_PowerManagement(struct host_if_drv *hif_drv,
2757 struct power_mgmt_param *strPowerMgmtParam)
2763 strWID.id = (u16)WID_POWER_MANAGEMENT;
2765 if (strPowerMgmtParam->enabled == true)
2766 s8PowerMode = MIN_FAST_PS;
2768 s8PowerMode = NO_POWERSAVE;
2769 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
2770 strWID.val = &s8PowerMode;
2771 strWID.size = sizeof(char);
2773 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
2775 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2776 get_id_from_handler(hif_drv));
2778 PRINT_ER("Failed to send power management config packet\n");
2781 static void Handle_SetMulticastFilter(struct host_if_drv *hif_drv,
2782 struct set_multicast *strHostIfSetMulti)
2788 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
2790 strWID.id = (u16)WID_SETUP_MULTICAST_FILTER;
2791 strWID.type = WID_BIN;
2792 strWID.size = sizeof(struct set_multicast) + ((strHostIfSetMulti->cnt) * ETH_ALEN);
2793 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2794 if (strWID.val == NULL)
2797 pu8CurrByte = strWID.val;
2798 *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF);
2799 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 8) & 0xFF);
2800 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 16) & 0xFF);
2801 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 24) & 0xFF);
2803 *pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF);
2804 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF);
2805 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 16) & 0xFF);
2806 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 24) & 0xFF);
2808 if ((strHostIfSetMulti->cnt) > 0)
2809 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->cnt) * ETH_ALEN));
2811 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2812 get_id_from_handler(hif_drv));
2814 PRINT_ER("Failed to send setup multicast config packet\n");
2821 static s32 Handle_AddBASession(struct host_if_drv *hif_drv,
2822 struct ba_session_info *strHostIfBASessionInfo)
2826 int AddbaTimeout = 100;
2829 PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\nBufferSize == %d\nSessionTimeOut = %d\n",
2830 strHostIfBASessionInfo->au8Bssid[0],
2831 strHostIfBASessionInfo->au8Bssid[1],
2832 strHostIfBASessionInfo->au8Bssid[2],
2833 strHostIfBASessionInfo->u16BufferSize,
2834 strHostIfBASessionInfo->u16SessionTimeout,
2835 strHostIfBASessionInfo->u8Ted);
2837 strWID.id = (u16)WID_11E_P_ACTION_REQ;
2838 strWID.type = WID_STR;
2839 strWID.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2840 strWID.size = BLOCK_ACK_REQ_SIZE;
2845 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2847 *ptr++ = strHostIfBASessionInfo->u8Ted;
2849 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
2850 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
2851 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
2852 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
2853 *ptr++ = (AddbaTimeout & 0xFF);
2854 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
2858 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2859 get_id_from_handler(hif_drv));
2861 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
2864 strWID.id = (u16)WID_11E_P_ACTION_REQ;
2865 strWID.type = WID_STR;
2871 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2873 *ptr++ = strHostIfBASessionInfo->u8Ted;
2875 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
2876 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
2878 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2879 get_id_from_handler(hif_drv));
2881 if (strWID.val != NULL)
2888 static s32 Handle_DelAllRxBASessions(struct host_if_drv *hif_drv,
2889 struct ba_session_info *strHostIfBASessionInfo)
2895 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
2896 strHostIfBASessionInfo->au8Bssid[0],
2897 strHostIfBASessionInfo->au8Bssid[1],
2898 strHostIfBASessionInfo->au8Bssid[2],
2899 strHostIfBASessionInfo->u8Ted);
2901 strWID.id = (u16)WID_DEL_ALL_RX_BA;
2902 strWID.type = WID_STR;
2903 strWID.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2904 strWID.size = BLOCK_ACK_REQ_SIZE;
2909 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2911 *ptr++ = strHostIfBASessionInfo->u8Ted;
2915 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2916 get_id_from_handler(hif_drv));
2918 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
2921 if (strWID.val != NULL)
2930 static int hostIFthread(void *pvArg)
2933 struct host_if_msg msg;
2934 struct host_if_drv *hif_drv;
2936 memset(&msg, 0, sizeof(struct host_if_msg));
2939 wilc_mq_recv(&gMsgQHostIF, &msg, sizeof(struct host_if_msg), &u32Ret);
2940 hif_drv = (struct host_if_drv *)msg.drv;
2941 if (msg.id == HOST_IF_MSG_EXIT) {
2942 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
2946 if ((!g_wilc_initialized)) {
2947 PRINT_D(GENERIC_DBG, "--WAIT--");
2948 usleep_range(200 * 1000, 200 * 1000);
2949 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
2953 if (msg.id == HOST_IF_MSG_CONNECT && hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
2954 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
2955 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
2956 usleep_range(2 * 1000, 2 * 1000);
2961 case HOST_IF_MSG_Q_IDLE:
2962 Handle_wait_msg_q_empty();
2965 case HOST_IF_MSG_SCAN:
2966 Handle_Scan(msg.drv, &msg.body.scan_info);
2969 case HOST_IF_MSG_CONNECT:
2970 Handle_Connect(msg.drv, &msg.body.con_info);
2973 case HOST_IF_MSG_FLUSH_CONNECT:
2974 Handle_FlushConnect(msg.drv);
2977 case HOST_IF_MSG_RCVD_NTWRK_INFO:
2978 Handle_RcvdNtwrkInfo(msg.drv, &msg.body.net_info);
2981 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
2982 Handle_RcvdGnrlAsyncInfo(msg.drv, &msg.body.async_info);
2985 case HOST_IF_MSG_KEY:
2986 Handle_Key(msg.drv, &msg.body.key_info);
2989 case HOST_IF_MSG_CFG_PARAMS:
2991 Handle_CfgParam(msg.drv, &msg.body.cfg_info);
2994 case HOST_IF_MSG_SET_CHANNEL:
2995 Handle_SetChannel(msg.drv, &msg.body.channel_info);
2998 case HOST_IF_MSG_DISCONNECT:
2999 Handle_Disconnect(msg.drv);
3002 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
3003 del_timer(&hif_drv->hScanTimer);
3004 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
3006 if (!linux_wlan_get_num_conn_ifcs())
3007 chip_sleep_manually(INFINITE_SLEEP_TIME);
3009 Handle_ScanDone(msg.drv, SCAN_EVENT_DONE);
3011 if (hif_drv->u8RemainOnChan_pendingreq)
3012 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
3016 case HOST_IF_MSG_GET_RSSI:
3017 Handle_GetRssi(msg.drv);
3020 case HOST_IF_MSG_GET_LINKSPEED:
3021 Handle_GetLinkspeed(msg.drv);
3024 case HOST_IF_MSG_GET_STATISTICS:
3025 Handle_GetStatistics(msg.drv, (struct rf_info *)msg.body.data);
3028 case HOST_IF_MSG_GET_CHNL:
3029 Handle_GetChnl(msg.drv);
3032 case HOST_IF_MSG_ADD_BEACON:
3033 Handle_AddBeacon(msg.drv, &msg.body.beacon_info);
3036 case HOST_IF_MSG_DEL_BEACON:
3037 Handle_DelBeacon(msg.drv);
3040 case HOST_IF_MSG_ADD_STATION:
3041 Handle_AddStation(msg.drv, &msg.body.add_sta_info);
3044 case HOST_IF_MSG_DEL_STATION:
3045 Handle_DelStation(msg.drv, &msg.body.del_sta_info);
3048 case HOST_IF_MSG_EDIT_STATION:
3049 Handle_EditStation(msg.drv, &msg.body.edit_sta_info);
3052 case HOST_IF_MSG_GET_INACTIVETIME:
3053 Handle_Get_InActiveTime(msg.drv, &msg.body.mac_info);
3056 case HOST_IF_MSG_SCAN_TIMER_FIRED:
3057 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
3059 Handle_ScanDone(msg.drv, SCAN_EVENT_ABORTED);
3062 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
3063 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
3064 Handle_ConnectTimeout(msg.drv);
3067 case HOST_IF_MSG_POWER_MGMT:
3068 Handle_PowerManagement(msg.drv, &msg.body.pwr_mgmt_info);
3071 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
3072 Handle_SetWfiDrvHandler(msg.drv,
3076 case HOST_IF_MSG_SET_OPERATION_MODE:
3077 Handle_SetOperationMode(msg.drv, &msg.body.mode);
3080 case HOST_IF_MSG_SET_IPADDRESS:
3081 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
3082 Handle_set_IPAddress(msg.drv, msg.body.ip_info.ip_addr, msg.body.ip_info.idx);
3085 case HOST_IF_MSG_GET_IPADDRESS:
3086 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
3087 Handle_get_IPAddress(msg.drv, msg.body.ip_info.ip_addr, msg.body.ip_info.idx);
3090 case HOST_IF_MSG_SET_MAC_ADDRESS:
3091 Handle_SetMacAddress(msg.drv, &msg.body.set_mac_info);
3094 case HOST_IF_MSG_GET_MAC_ADDRESS:
3095 Handle_GetMacAddress(msg.drv, &msg.body.get_mac_info);
3098 case HOST_IF_MSG_REMAIN_ON_CHAN:
3099 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
3100 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
3103 case HOST_IF_MSG_REGISTER_FRAME:
3104 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
3105 Handle_RegisterFrame(msg.drv, &msg.body.reg_frame);
3108 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
3109 Handle_ListenStateExpired(msg.drv, &msg.body.remain_on_ch);
3112 case HOST_IF_MSG_SET_MULTICAST_FILTER:
3113 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
3114 Handle_SetMulticastFilter(msg.drv, &msg.body.multicast_info);
3117 case HOST_IF_MSG_ADD_BA_SESSION:
3118 Handle_AddBASession(msg.drv, &msg.body.session_info);
3121 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
3122 Handle_DelAllRxBASessions(msg.drv, &msg.body.session_info);
3125 case HOST_IF_MSG_DEL_ALL_STA:
3126 Handle_DelAllSta(msg.drv, &msg.body.del_all_sta_info);
3130 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
3135 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
3136 up(&hSemHostIFthrdEnd);
3140 static void TimerCB_Scan(unsigned long arg)
3142 void *pvArg = (void *)arg;
3143 struct host_if_msg msg;
3145 memset(&msg, 0, sizeof(struct host_if_msg));
3147 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
3149 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3152 static void TimerCB_Connect(unsigned long arg)
3154 void *pvArg = (void *)arg;
3155 struct host_if_msg msg;
3157 memset(&msg, 0, sizeof(struct host_if_msg));
3159 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
3161 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3164 s32 host_int_remove_key(struct host_if_drv *hif_drv, const u8 *pu8StaAddress)
3168 strWID.id = (u16)WID_REMOVE_KEY;
3169 strWID.type = WID_STR;
3170 strWID.val = (s8 *)pu8StaAddress;
3176 int host_int_remove_wep_key(struct host_if_drv *hif_drv, u8 index)
3179 struct host_if_msg msg;
3183 PRINT_ER("Failed to send setup multicast config packet\n");
3187 memset(&msg, 0, sizeof(struct host_if_msg));
3189 msg.id = HOST_IF_MSG_KEY;
3190 msg.body.key_info.type = WEP;
3191 msg.body.key_info.action = REMOVEKEY;
3193 msg.body.key_info.attr.wep.index = index;
3195 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3197 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
3198 down(&hif_drv->hSemTestKeyBlock);
3203 s32 host_int_set_WEPDefaultKeyID(struct host_if_drv *hif_drv, u8 u8Index)
3206 struct host_if_msg msg;
3211 PRINT_ER("driver is null\n");
3215 memset(&msg, 0, sizeof(struct host_if_msg));
3218 msg.id = HOST_IF_MSG_KEY;
3219 msg.body.key_info.type = WEP;
3220 msg.body.key_info.action = DEFAULTKEY;
3222 msg.body.key_info.attr.wep.index = u8Index;
3224 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3226 PRINT_ER("Error in sending message queue : Default key index\n");
3227 down(&hif_drv->hSemTestKeyBlock);
3232 s32 host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv,
3233 const u8 *pu8WepKey,
3239 struct host_if_msg msg;
3243 PRINT_ER("driver is null\n");
3247 memset(&msg, 0, sizeof(struct host_if_msg));
3250 msg.id = HOST_IF_MSG_KEY;
3251 msg.body.key_info.type = WEP;
3252 msg.body.key_info.action = ADDKEY;
3254 msg.body.key_info.attr.wep.key = kmalloc(u8WepKeylen, GFP_KERNEL);
3255 memcpy(msg.body.key_info.attr.wep.key, pu8WepKey, u8WepKeylen);
3256 msg.body.key_info.attr.wep.key_len = (u8WepKeylen);
3257 msg.body.key_info.attr.wep.index = u8Keyidx;
3259 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3261 PRINT_ER("Error in sending message queue :WEP Key\n");
3262 down(&hif_drv->hSemTestKeyBlock);
3268 s32 host_int_add_wep_key_bss_ap(struct host_if_drv *hif_drv,
3269 const u8 *pu8WepKey,
3273 enum AUTHTYPE tenuAuth_type)
3277 struct host_if_msg msg;
3282 PRINT_ER("driver is null\n");
3286 memset(&msg, 0, sizeof(struct host_if_msg));
3289 for (i = 0; i < u8WepKeylen; i++)
3290 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
3292 msg.id = HOST_IF_MSG_KEY;
3293 msg.body.key_info.type = WEP;
3294 msg.body.key_info.action = ADDKEY_AP;
3296 msg.body.key_info.attr.wep.key = kmalloc(u8WepKeylen, GFP_KERNEL);
3297 memcpy(msg.body.key_info.attr.wep.key, pu8WepKey, (u8WepKeylen));
3298 msg.body.key_info.attr.wep.key_len = (u8WepKeylen);
3299 msg.body.key_info.attr.wep.index = u8Keyidx;
3300 msg.body.key_info.attr.wep.mode = u8mode;
3301 msg.body.key_info.attr.wep.auth_type = tenuAuth_type;
3303 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3306 PRINT_ER("Error in sending message queue :WEP Key\n");
3307 down(&hif_drv->hSemTestKeyBlock);
3313 s32 host_int_add_ptk(struct host_if_drv *hif_drv, const u8 *pu8Ptk,
3314 u8 u8PtkKeylen, const u8 *mac_addr,
3315 const u8 *pu8RxMic, const u8 *pu8TxMic,
3316 u8 mode, u8 u8Ciphermode, u8 u8Idx)
3319 struct host_if_msg msg;
3320 u8 u8KeyLen = u8PtkKeylen;
3325 PRINT_ER("driver is null\n");
3328 if (pu8RxMic != NULL)
3329 u8KeyLen += RX_MIC_KEY_LEN;
3330 if (pu8TxMic != NULL)
3331 u8KeyLen += TX_MIC_KEY_LEN;
3333 memset(&msg, 0, sizeof(struct host_if_msg));
3336 msg.id = HOST_IF_MSG_KEY;
3337 msg.body.key_info.type = WPAPtk;
3338 if (mode == AP_MODE) {
3339 msg.body.key_info.action = ADDKEY_AP;
3340 msg.body.key_info.attr.wpa.index = u8Idx;
3342 if (mode == STATION_MODE)
3343 msg.body.key_info.action = ADDKEY;
3345 msg.body.key_info.attr.wpa.key = kmalloc(u8PtkKeylen, GFP_KERNEL);
3346 memcpy(msg.body.key_info.attr.wpa.key, pu8Ptk, u8PtkKeylen);
3348 if (pu8RxMic != NULL) {
3349 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic, RX_MIC_KEY_LEN);
3351 for (i = 0; i < RX_MIC_KEY_LEN; i++)
3352 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
3355 if (pu8TxMic != NULL) {
3356 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic, TX_MIC_KEY_LEN);
3358 for (i = 0; i < TX_MIC_KEY_LEN; i++)
3359 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
3363 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
3364 msg.body.key_info.attr.wpa.mac_addr = mac_addr;
3365 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
3368 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3371 PRINT_ER("Error in sending message queue: PTK Key\n");
3373 down(&hif_drv->hSemTestKeyBlock);
3378 s32 host_int_add_rx_gtk(struct host_if_drv *hif_drv, const u8 *pu8RxGtk,
3379 u8 u8GtkKeylen, u8 u8KeyIdx,
3380 u32 u32KeyRSClen, const u8 *KeyRSC,
3381 const u8 *pu8RxMic, const u8 *pu8TxMic,
3382 u8 mode, u8 u8Ciphermode)
3385 struct host_if_msg msg;
3386 u8 u8KeyLen = u8GtkKeylen;
3390 PRINT_ER("driver is null\n");
3393 memset(&msg, 0, sizeof(struct host_if_msg));
3396 if (pu8RxMic != NULL)
3397 u8KeyLen += RX_MIC_KEY_LEN;
3398 if (pu8TxMic != NULL)
3399 u8KeyLen += TX_MIC_KEY_LEN;
3400 if (KeyRSC != NULL) {
3401 msg.body.key_info.attr.wpa.seq = kmalloc(u32KeyRSClen, GFP_KERNEL);
3402 memcpy(msg.body.key_info.attr.wpa.seq, KeyRSC, u32KeyRSClen);
3406 msg.id = HOST_IF_MSG_KEY;
3407 msg.body.key_info.type = WPARxGtk;
3410 if (mode == AP_MODE) {
3411 msg.body.key_info.action = ADDKEY_AP;
3412 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
3414 if (mode == STATION_MODE)
3415 msg.body.key_info.action = ADDKEY;
3417 msg.body.key_info.attr.wpa.key = kmalloc(u8KeyLen, GFP_KERNEL);
3418 memcpy(msg.body.key_info.attr.wpa.key, pu8RxGtk, u8GtkKeylen);
3420 if (pu8RxMic != NULL) {
3421 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic, RX_MIC_KEY_LEN);
3423 if (pu8TxMic != NULL) {
3424 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic, TX_MIC_KEY_LEN);
3427 msg.body.key_info.attr.wpa.index = u8KeyIdx;
3428 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
3429 msg.body.key_info.attr.wpa.seq_len = u32KeyRSClen;
3431 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3433 PRINT_ER("Error in sending message queue: RX GTK\n");
3435 down(&hif_drv->hSemTestKeyBlock);
3440 s32 host_int_set_pmkid_info(struct host_if_drv *hif_drv, struct host_if_pmkid_attr *pu8PmkidInfoArray)
3443 struct host_if_msg msg;
3449 PRINT_ER("driver is null\n");
3453 memset(&msg, 0, sizeof(struct host_if_msg));
3455 msg.id = HOST_IF_MSG_KEY;
3456 msg.body.key_info.type = PMKSA;
3457 msg.body.key_info.action = ADDKEY;
3460 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
3461 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
3463 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
3467 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3469 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
3474 s32 host_int_get_pmkid_info(struct host_if_drv *hif_drv,
3475 u8 *pu8PmkidInfoArray,
3476 u32 u32PmkidInfoLen)
3480 strWID.id = (u16)WID_PMKID_INFO;
3481 strWID.type = WID_STR;
3482 strWID.size = u32PmkidInfoLen;
3483 strWID.val = pu8PmkidInfoArray;
3488 s32 host_int_set_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3494 if ((u8Psklength > 7) && (u8Psklength < 65)) {
3495 strWID.id = (u16)WID_11I_PSK;
3496 strWID.type = WID_STR;
3497 strWID.val = pu8PassPhrase;
3498 strWID.size = u8Psklength;
3504 s32 host_int_get_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
3507 struct host_if_msg msg;
3509 memset(&msg, 0, sizeof(struct host_if_msg));
3511 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
3512 msg.body.get_mac_info.u8MacAddress = pu8MacAddress;
3515 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3517 PRINT_ER("Failed to send get mac address\n");
3521 down(&hWaitResponse);
3525 s32 host_int_set_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
3528 struct host_if_msg msg;
3530 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
3532 memset(&msg, 0, sizeof(struct host_if_msg));
3533 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
3534 memcpy(msg.body.set_mac_info.u8MacAddress, pu8MacAddress, ETH_ALEN);
3537 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3539 PRINT_ER("Failed to send message queue: Set mac address\n");
3545 s32 host_int_get_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3546 u8 *pu8PassPhrase, u8 u8Psklength)
3550 strWID.id = (u16)WID_11I_PSK;
3551 strWID.type = WID_STR;
3552 strWID.size = u8Psklength;
3553 strWID.val = pu8PassPhrase;
3558 s32 host_int_set_start_scan_req(struct host_if_drv *hif_drv, u8 scanSource)
3562 strWID.id = (u16)WID_START_SCAN_REQ;
3563 strWID.type = WID_CHAR;
3564 strWID.val = (s8 *)&scanSource;
3565 strWID.size = sizeof(char);
3570 s32 host_int_get_start_scan_req(struct host_if_drv *hif_drv, u8 *pu8ScanSource)
3574 strWID.id = (u16)WID_START_SCAN_REQ;
3575 strWID.type = WID_CHAR;
3576 strWID.val = (s8 *)pu8ScanSource;
3577 strWID.size = sizeof(char);
3582 s32 host_int_set_join_req(struct host_if_drv *hif_drv, u8 *pu8bssid,
3583 const u8 *pu8ssid, size_t ssidLen,
3584 const u8 *pu8IEs, size_t IEsLen,
3585 wilc_connect_result pfConnectResult, void *pvUserArg,
3586 u8 u8security, enum AUTHTYPE tenuAuth_type,
3587 u8 u8channel, void *pJoinParams)
3590 struct host_if_msg msg;
3591 enum scan_conn_timer enuScanConnTimer;
3593 if (!hif_drv || pfConnectResult == NULL) {
3595 PRINT_ER("Driver is null\n");
3600 PRINT_ER("Driver is null\n");
3604 if (pJoinParams == NULL) {
3605 PRINT_ER("Unable to Join - JoinParams is NULL\n");
3609 memset(&msg, 0, sizeof(struct host_if_msg));
3611 msg.id = HOST_IF_MSG_CONNECT;
3613 msg.body.con_info.security = u8security;
3614 msg.body.con_info.auth_type = tenuAuth_type;
3615 msg.body.con_info.ch = u8channel;
3616 msg.body.con_info.result = pfConnectResult;
3617 msg.body.con_info.arg = pvUserArg;
3618 msg.body.con_info.params = pJoinParams;
3621 if (pu8bssid != NULL) {
3622 msg.body.con_info.bssid = kmalloc(6, GFP_KERNEL);
3623 memcpy(msg.body.con_info.bssid, pu8bssid, 6);
3626 if (pu8ssid != NULL) {
3627 msg.body.con_info.ssid_len = ssidLen;
3628 msg.body.con_info.ssid = kmalloc(ssidLen, GFP_KERNEL);
3629 memcpy(msg.body.con_info.ssid, pu8ssid, ssidLen);
3632 if (pu8IEs != NULL) {
3633 msg.body.con_info.ies_len = IEsLen;
3634 msg.body.con_info.ies = kmalloc(IEsLen, GFP_KERNEL);
3635 memcpy(msg.body.con_info.ies, pu8IEs, IEsLen);
3637 if (hif_drv->enuHostIFstate < HOST_IF_CONNECTING)
3638 hif_drv->enuHostIFstate = HOST_IF_CONNECTING;
3640 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", hif_drv->enuHostIFstate);
3642 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3644 PRINT_ER("Failed to send message queue: Set join request\n");
3648 enuScanConnTimer = CONNECT_TIMER;
3649 hif_drv->hConnectTimer.data = (unsigned long)hif_drv;
3650 mod_timer(&hif_drv->hConnectTimer,
3651 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
3656 s32 host_int_flush_join_req(struct host_if_drv *hif_drv)
3659 struct host_if_msg msg;
3661 if (!gu8FlushedJoinReq) {
3669 PRINT_ER("Driver is null\n");
3673 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
3676 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3678 PRINT_ER("Failed to send message queue: Flush join request\n");
3685 s32 host_int_disconnect(struct host_if_drv *hif_drv, u16 u16ReasonCode)
3688 struct host_if_msg msg;
3691 PRINT_ER("Driver is null\n");
3695 memset(&msg, 0, sizeof(struct host_if_msg));
3697 msg.id = HOST_IF_MSG_DISCONNECT;
3700 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3702 PRINT_ER("Failed to send message queue: disconnect\n");
3704 down(&hif_drv->hSemTestDisconnectBlock);
3709 s32 host_int_disconnect_station(struct host_if_drv *hif_drv, u8 assoc_id)
3713 strWID.id = (u16)WID_DISCONNECT;
3714 strWID.type = WID_CHAR;
3715 strWID.val = (s8 *)&assoc_id;
3716 strWID.size = sizeof(char);
3721 s32 host_int_get_assoc_req_info(struct host_if_drv *hif_drv, u8 *pu8AssocReqInfo,
3722 u32 u32AssocReqInfoLen)
3726 strWID.id = (u16)WID_ASSOC_REQ_INFO;
3727 strWID.type = WID_STR;
3728 strWID.val = pu8AssocReqInfo;
3729 strWID.size = u32AssocReqInfoLen;
3734 s32 host_int_get_assoc_res_info(struct host_if_drv *hif_drv, u8 *pu8AssocRespInfo,
3735 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
3741 PRINT_ER("Driver is null\n");
3745 strWID.id = (u16)WID_ASSOC_RES_INFO;
3746 strWID.type = WID_STR;
3747 strWID.val = pu8AssocRespInfo;
3748 strWID.size = u32MaxAssocRespInfoLen;
3750 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
3751 get_id_from_handler(hif_drv));
3753 *pu32RcvdAssocRespInfoLen = 0;
3754 PRINT_ER("Failed to send association response config packet\n");
3757 *pu32RcvdAssocRespInfoLen = strWID.size;
3763 s32 host_int_get_rx_power_level(struct host_if_drv *hif_drv, u8 *pu8RxPowerLevel,
3764 u32 u32RxPowerLevelLen)
3768 strWID.id = (u16)WID_RX_POWER_LEVEL;
3769 strWID.type = WID_STR;
3770 strWID.val = pu8RxPowerLevel;
3771 strWID.size = u32RxPowerLevelLen;
3776 int host_int_set_mac_chnl_num(struct host_if_drv *hif_drv, u8 channel)
3779 struct host_if_msg msg;
3782 PRINT_ER("driver is null\n");
3786 memset(&msg, 0, sizeof(struct host_if_msg));
3787 msg.id = HOST_IF_MSG_SET_CHANNEL;
3788 msg.body.channel_info.set_ch = channel;
3791 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3793 PRINT_ER("wilc mq send fail\n");
3800 int host_int_wait_msg_queue_idle(void)
3804 struct host_if_msg msg;
3805 memset(&msg, 0, sizeof(struct host_if_msg));
3806 msg.id = HOST_IF_MSG_Q_IDLE;
3807 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3809 PRINT_ER("wilc mq send fail\n");
3813 down(&hWaitResponse);
3818 int host_int_set_wfi_drv_handler(struct host_if_drv *hif_drv)
3822 struct host_if_msg msg;
3823 memset(&msg, 0, sizeof(struct host_if_msg));
3824 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
3825 msg.body.drv.u32Address = get_id_from_handler(hif_drv);
3828 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3830 PRINT_ER("wilc mq send fail\n");
3837 int host_int_set_operation_mode(struct host_if_drv *hif_drv, u32 mode)
3841 struct host_if_msg msg;
3842 memset(&msg, 0, sizeof(struct host_if_msg));
3843 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
3844 msg.body.mode.u32Mode = mode;
3847 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3849 PRINT_ER("wilc mq send fail\n");
3856 s32 host_int_get_host_chnl_num(struct host_if_drv *hif_drv, u8 *pu8ChNo)
3859 struct host_if_msg msg;
3862 PRINT_ER("driver is null\n");
3866 memset(&msg, 0, sizeof(struct host_if_msg));
3868 msg.id = HOST_IF_MSG_GET_CHNL;
3871 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3873 PRINT_ER("wilc mq send fail\n");
3874 down(&hif_drv->hSemGetCHNL);
3883 s32 host_int_get_inactive_time(struct host_if_drv *hif_drv,
3884 const u8 *mac, u32 *pu32InactiveTime)
3887 struct host_if_msg msg;
3890 PRINT_ER("driver is null\n");
3894 memset(&msg, 0, sizeof(struct host_if_msg));
3897 memcpy(msg.body.mac_info.mac,
3900 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
3903 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3905 PRINT_ER("Failed to send get host channel param's message queue ");
3907 down(&hif_drv->hSemInactiveTime);
3909 *pu32InactiveTime = gu32InactiveTime;
3914 s32 host_int_test_get_int_wid(struct host_if_drv *hif_drv, u32 *pu32TestMemAddr)
3921 PRINT_ER("driver is null\n");
3925 strWID.id = (u16)WID_MEMORY_ADDRESS;
3926 strWID.type = WID_INT;
3927 strWID.val = (s8 *)pu32TestMemAddr;
3928 strWID.size = sizeof(u32);
3930 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
3931 get_id_from_handler(hif_drv));
3934 PRINT_ER("Failed to get wid value\n");
3937 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
3944 s32 host_int_get_rssi(struct host_if_drv *hif_drv, s8 *ps8Rssi)
3947 struct host_if_msg msg;
3948 memset(&msg, 0, sizeof(struct host_if_msg));
3950 msg.id = HOST_IF_MSG_GET_RSSI;
3953 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3955 PRINT_ER("Failed to send get host channel param's message queue ");
3959 down(&hif_drv->hSemGetRSSI);
3962 if (ps8Rssi == NULL) {
3963 PRINT_ER("RSS pointer value is null");
3974 s32 host_int_get_link_speed(struct host_if_drv *hif_drv, s8 *ps8lnkspd)
3976 struct host_if_msg msg;
3978 memset(&msg, 0, sizeof(struct host_if_msg));
3980 msg.id = HOST_IF_MSG_GET_LINKSPEED;
3983 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3985 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
3989 down(&hif_drv->hSemGetLINKSPEED);
3992 if (ps8lnkspd == NULL) {
3993 PRINT_ER("LINKSPEED pointer value is null");
3998 *ps8lnkspd = gs8lnkspd;
4004 s32 host_int_get_statistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
4007 struct host_if_msg msg;
4008 memset(&msg, 0, sizeof(struct host_if_msg));
4010 msg.id = HOST_IF_MSG_GET_STATISTICS;
4011 msg.body.data = (char *)pstrStatistics;
4014 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4016 PRINT_ER("Failed to send get host channel param's message queue ");
4020 down(&hWaitResponse);
4024 s32 host_int_scan(struct host_if_drv *hif_drv, u8 u8ScanSource,
4025 u8 u8ScanType, u8 *pu8ChnlFreqList,
4026 u8 u8ChnlListLen, const u8 *pu8IEs,
4027 size_t IEsLen, wilc_scan_result ScanResult,
4028 void *pvUserArg, struct hidden_network *pstrHiddenNetwork)
4031 struct host_if_msg msg;
4032 enum scan_conn_timer enuScanConnTimer;
4034 if (!hif_drv || ScanResult == NULL) {
4035 PRINT_ER("hif_drv or ScanResult = NULL\n");
4039 memset(&msg, 0, sizeof(struct host_if_msg));
4041 msg.id = HOST_IF_MSG_SCAN;
4043 if (pstrHiddenNetwork != NULL) {
4044 msg.body.scan_info.hidden_network.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
4045 msg.body.scan_info.hidden_network.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
4048 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
4051 msg.body.scan_info.src = u8ScanSource;
4052 msg.body.scan_info.type = u8ScanType;
4053 msg.body.scan_info.result = ScanResult;
4054 msg.body.scan_info.arg = pvUserArg;
4056 msg.body.scan_info.ch_list_len = u8ChnlListLen;
4057 msg.body.scan_info.ch_freq_list = kmalloc(u8ChnlListLen, GFP_KERNEL);
4058 memcpy(msg.body.scan_info.ch_freq_list, pu8ChnlFreqList, u8ChnlListLen);
4060 msg.body.scan_info.ies_len = IEsLen;
4061 msg.body.scan_info.ies = kmalloc(IEsLen, GFP_KERNEL);
4062 memcpy(msg.body.scan_info.ies, pu8IEs, IEsLen);
4064 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4066 PRINT_ER("Error in sending message queue\n");
4070 enuScanConnTimer = SCAN_TIMER;
4071 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
4072 hif_drv->hScanTimer.data = (unsigned long)hif_drv;
4073 mod_timer(&hif_drv->hScanTimer,
4074 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
4080 s32 hif_set_cfg(struct host_if_drv *hif_drv,
4081 struct cfg_param_val *pstrCfgParamVal)
4085 struct host_if_msg msg;
4089 PRINT_ER("hif_drv NULL\n");
4093 memset(&msg, 0, sizeof(struct host_if_msg));
4094 msg.id = HOST_IF_MSG_CFG_PARAMS;
4095 msg.body.cfg_info.cfg_attr_info = *pstrCfgParamVal;
4098 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4104 s32 hif_get_cfg(struct host_if_drv *hif_drv, u16 u16WID, u16 *pu16WID_Value)
4108 down(&hif_drv->gtOsCfgValuesSem);
4111 PRINT_ER("hif_drv NULL\n");
4114 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
4118 *pu16WID_Value = (u16)hif_drv->strCfgValues.bss_type;
4122 *pu16WID_Value = (u16)hif_drv->strCfgValues.auth_type;
4125 case WID_AUTH_TIMEOUT:
4126 *pu16WID_Value = hif_drv->strCfgValues.auth_timeout;
4129 case WID_POWER_MANAGEMENT:
4130 *pu16WID_Value = (u16)hif_drv->strCfgValues.power_mgmt_mode;
4133 case WID_SHORT_RETRY_LIMIT:
4134 *pu16WID_Value = hif_drv->strCfgValues.short_retry_limit;
4137 case WID_LONG_RETRY_LIMIT:
4138 *pu16WID_Value = hif_drv->strCfgValues.long_retry_limit;
4141 case WID_FRAG_THRESHOLD:
4142 *pu16WID_Value = hif_drv->strCfgValues.frag_threshold;
4145 case WID_RTS_THRESHOLD:
4146 *pu16WID_Value = hif_drv->strCfgValues.rts_threshold;
4150 *pu16WID_Value = (u16)hif_drv->strCfgValues.preamble_type;
4153 case WID_SHORT_SLOT_ALLOWED:
4154 *pu16WID_Value = (u16) hif_drv->strCfgValues.short_slot_allowed;
4157 case WID_11N_TXOP_PROT_DISABLE:
4158 *pu16WID_Value = (u16)hif_drv->strCfgValues.txop_prot_disabled;
4161 case WID_BEACON_INTERVAL:
4162 *pu16WID_Value = hif_drv->strCfgValues.beacon_interval;
4165 case WID_DTIM_PERIOD:
4166 *pu16WID_Value = (u16)hif_drv->strCfgValues.dtim_period;
4169 case WID_SITE_SURVEY:
4170 *pu16WID_Value = (u16)hif_drv->strCfgValues.site_survey_enabled;
4173 case WID_SITE_SURVEY_SCAN_TIME:
4174 *pu16WID_Value = hif_drv->strCfgValues.site_survey_scan_time;
4177 case WID_ACTIVE_SCAN_TIME:
4178 *pu16WID_Value = hif_drv->strCfgValues.active_scan_time;
4181 case WID_PASSIVE_SCAN_TIME:
4182 *pu16WID_Value = hif_drv->strCfgValues.passive_scan_time;
4185 case WID_CURRENT_TX_RATE:
4186 *pu16WID_Value = hif_drv->strCfgValues.curr_tx_rate;
4193 up(&hif_drv->gtOsCfgValuesSem);
4199 void host_int_send_join_leave_info_to_host
4200 (u16 assocId, u8 *stationAddr, bool joining)
4204 static void GetPeriodicRSSI(unsigned long arg)
4206 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
4209 PRINT_ER("Driver handler is NULL\n");
4213 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED) {
4215 struct host_if_msg msg;
4217 memset(&msg, 0, sizeof(struct host_if_msg));
4219 msg.id = HOST_IF_MSG_GET_RSSI;
4222 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4224 PRINT_ER("Failed to send get host channel param's message queue ");
4228 g_hPeriodicRSSI.data = (unsigned long)hif_drv;
4229 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
4233 void host_int_send_network_info_to_host
4234 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
4238 static u32 clients_count;
4240 s32 host_int_init(struct host_if_drv **hif_drv_handler)
4243 struct host_if_drv *hif_drv;
4246 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
4248 gbScanWhileConnected = false;
4250 sema_init(&hWaitResponse, 0);
4252 hif_drv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
4257 *hif_drv_handler = hif_drv;
4258 err = add_handler_in_list(hif_drv);
4264 g_obtainingIP = false;
4266 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", hif_drv);
4267 if (clients_count == 0) {
4268 sema_init(&hSemHostIFthrdEnd, 0);
4269 sema_init(&hSemDeinitDrvHandle, 0);
4270 sema_init(&hSemHostIntDeinit, 1);
4273 sema_init(&hif_drv->hSemTestKeyBlock, 0);
4274 sema_init(&hif_drv->hSemTestDisconnectBlock, 0);
4275 sema_init(&hif_drv->hSemGetRSSI, 0);
4276 sema_init(&hif_drv->hSemGetLINKSPEED, 0);
4277 sema_init(&hif_drv->hSemGetCHNL, 0);
4278 sema_init(&hif_drv->hSemInactiveTime, 0);
4280 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
4282 if (clients_count == 0) {
4283 result = wilc_mq_create(&gMsgQHostIF);
4286 PRINT_ER("Failed to creat MQ\n");
4289 HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread");
4290 if (IS_ERR(HostIFthreadHandler)) {
4291 PRINT_ER("Failed to creat Thread\n");
4295 setup_timer(&g_hPeriodicRSSI, GetPeriodicRSSI,
4296 (unsigned long)hif_drv);
4297 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
4300 setup_timer(&hif_drv->hScanTimer, TimerCB_Scan, 0);
4302 setup_timer(&hif_drv->hConnectTimer, TimerCB_Connect, 0);
4304 setup_timer(&hif_drv->hRemainOnChannel, ListenTimerCB, 0);
4306 sema_init(&(hif_drv->gtOsCfgValuesSem), 1);
4307 down(&hif_drv->gtOsCfgValuesSem);
4309 hif_drv->enuHostIFstate = HOST_IF_IDLE;
4310 hif_drv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
4311 hif_drv->strCfgValues.scan_source = DEFAULT_SCAN;
4312 hif_drv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
4313 hif_drv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
4314 hif_drv->strCfgValues.curr_tx_rate = AUTORATE;
4316 hif_drv->u64P2p_MgmtTimeout = 0;
4318 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",
4320 hif_drv->strCfgValues.site_survey_enabled, hif_drv->strCfgValues.scan_source,
4321 hif_drv->strCfgValues.active_scan_time, hif_drv->strCfgValues.passive_scan_time,
4322 hif_drv->strCfgValues.curr_tx_rate);
4324 up(&hif_drv->gtOsCfgValuesSem);
4331 up(&hif_drv->gtOsCfgValuesSem);
4332 del_timer_sync(&hif_drv->hConnectTimer);
4333 del_timer_sync(&hif_drv->hScanTimer);
4334 kthread_stop(HostIFthreadHandler);
4336 wilc_mq_destroy(&gMsgQHostIF);
4341 s32 host_int_deinit(struct host_if_drv *hif_drv)
4344 struct host_if_msg msg;
4348 PRINT_ER("hif_drv = NULL\n");
4352 down(&hSemHostIntDeinit);
4354 terminated_handle = hif_drv;
4355 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
4357 if (del_timer_sync(&hif_drv->hScanTimer)) {
4358 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
4361 if (del_timer_sync(&hif_drv->hConnectTimer)) {
4362 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4366 if (del_timer_sync(&g_hPeriodicRSSI)) {
4367 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4370 del_timer_sync(&hif_drv->hRemainOnChannel);
4372 host_int_set_wfi_drv_handler(NULL);
4373 down(&hSemDeinitDrvHandle);
4375 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
4376 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
4377 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
4379 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
4382 hif_drv->enuHostIFstate = HOST_IF_IDLE;
4384 gbScanWhileConnected = false;
4386 memset(&msg, 0, sizeof(struct host_if_msg));
4388 if (clients_count == 1) {
4389 if (del_timer_sync(&g_hPeriodicRSSI)) {
4390 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4392 msg.id = HOST_IF_MSG_EXIT;
4396 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4398 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
4400 down(&hSemHostIFthrdEnd);
4402 wilc_mq_destroy(&gMsgQHostIF);
4405 down(&(hif_drv->gtOsCfgValuesSem));
4407 ret = remove_handler_in_list(hif_drv);
4414 terminated_handle = NULL;
4415 up(&hSemHostIntDeinit);
4419 void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
4422 struct host_if_msg msg;
4424 struct host_if_drv *hif_drv = NULL;
4426 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4427 hif_drv = get_handler_from_id(id);
4432 if (!hif_drv || hif_drv == terminated_handle) {
4433 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv);
4437 memset(&msg, 0, sizeof(struct host_if_msg));
4439 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
4442 msg.body.net_info.u32Length = u32Length;
4443 msg.body.net_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4444 memcpy(msg.body.net_info.buffer, pu8Buffer, u32Length);
4446 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4448 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
4451 void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
4454 struct host_if_msg msg;
4456 struct host_if_drv *hif_drv = NULL;
4458 down(&hSemHostIntDeinit);
4460 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4461 hif_drv = get_handler_from_id(id);
4462 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
4465 if (!hif_drv || hif_drv == terminated_handle) {
4466 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
4467 up(&hSemHostIntDeinit);
4471 if (!hif_drv->strWILC_UsrConnReq.pfUserConnectResult) {
4472 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
4473 up(&hSemHostIntDeinit);
4477 memset(&msg, 0, sizeof(struct host_if_msg));
4480 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
4483 msg.body.async_info.len = u32Length;
4484 msg.body.async_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4485 memcpy(msg.body.async_info.buffer, pu8Buffer, u32Length);
4487 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4489 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
4491 up(&hSemHostIntDeinit);
4494 void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
4497 struct host_if_msg msg;
4499 struct host_if_drv *hif_drv = NULL;
4501 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4502 hif_drv = get_handler_from_id(id);
4505 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", hif_drv);
4507 if (!hif_drv || hif_drv == terminated_handle)
4510 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
4511 memset(&msg, 0, sizeof(struct host_if_msg));
4513 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
4516 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4518 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
4526 s32 host_int_remain_on_channel(struct host_if_drv *hif_drv, u32 u32SessionID,
4527 u32 u32duration, u16 chan,
4528 wilc_remain_on_chan_expired RemainOnChanExpired,
4529 wilc_remain_on_chan_ready RemainOnChanReady,
4533 struct host_if_msg msg;
4536 PRINT_ER("driver is null\n");
4540 memset(&msg, 0, sizeof(struct host_if_msg));
4542 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
4543 msg.body.remain_on_ch.u16Channel = chan;
4544 msg.body.remain_on_ch.pRemainOnChanExpired = RemainOnChanExpired;
4545 msg.body.remain_on_ch.pRemainOnChanReady = RemainOnChanReady;
4546 msg.body.remain_on_ch.pVoid = pvUserArg;
4547 msg.body.remain_on_ch.u32duration = u32duration;
4548 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
4551 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4553 PRINT_ER("wilc mq send fail\n");
4558 s32 host_int_ListenStateExpired(struct host_if_drv *hif_drv, u32 u32SessionID)
4561 struct host_if_msg msg;
4564 PRINT_ER("driver is null\n");
4568 del_timer(&hif_drv->hRemainOnChannel);
4570 memset(&msg, 0, sizeof(struct host_if_msg));
4571 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
4573 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
4575 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4577 PRINT_ER("wilc mq send fail\n");
4582 s32 host_int_frame_register(struct host_if_drv *hif_drv, u16 u16FrameType, bool bReg)
4585 struct host_if_msg msg;
4588 PRINT_ER("driver is null\n");
4592 memset(&msg, 0, sizeof(struct host_if_msg));
4594 msg.id = HOST_IF_MSG_REGISTER_FRAME;
4595 switch (u16FrameType) {
4597 PRINT_D(HOSTINF_DBG, "ACTION\n");
4598 msg.body.reg_frame.u8Regid = ACTION_FRM_IDX;
4602 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
4603 msg.body.reg_frame.u8Regid = PROBE_REQ_IDX;
4607 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
4610 msg.body.reg_frame.u16FrameType = u16FrameType;
4611 msg.body.reg_frame.bReg = bReg;
4614 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4616 PRINT_ER("wilc mq send fail\n");
4623 s32 host_int_add_beacon(struct host_if_drv *hif_drv, u32 u32Interval,
4624 u32 u32DTIMPeriod, u32 u32HeadLen, u8 *pu8Head,
4625 u32 u32TailLen, u8 *pu8Tail)
4628 struct host_if_msg msg;
4629 struct beacon_attr *pstrSetBeaconParam = &msg.body.beacon_info;
4632 PRINT_ER("driver is null\n");
4636 memset(&msg, 0, sizeof(struct host_if_msg));
4638 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
4640 msg.id = HOST_IF_MSG_ADD_BEACON;
4642 pstrSetBeaconParam->interval = u32Interval;
4643 pstrSetBeaconParam->dtim_period = u32DTIMPeriod;
4644 pstrSetBeaconParam->head_len = u32HeadLen;
4645 pstrSetBeaconParam->head = kmalloc(u32HeadLen, GFP_KERNEL);
4646 if (pstrSetBeaconParam->head == NULL) {
4650 memcpy(pstrSetBeaconParam->head, pu8Head, u32HeadLen);
4651 pstrSetBeaconParam->tail_len = u32TailLen;
4653 if (u32TailLen > 0) {
4654 pstrSetBeaconParam->tail = kmalloc(u32TailLen, GFP_KERNEL);
4655 if (pstrSetBeaconParam->tail == NULL) {
4659 memcpy(pstrSetBeaconParam->tail, pu8Tail, u32TailLen);
4661 pstrSetBeaconParam->tail = NULL;
4664 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4666 PRINT_ER("wilc mq send fail\n");
4670 if (pstrSetBeaconParam->head != NULL)
4671 kfree(pstrSetBeaconParam->head);
4673 if (pstrSetBeaconParam->tail != NULL)
4674 kfree(pstrSetBeaconParam->tail);
4681 s32 host_int_del_beacon(struct host_if_drv *hif_drv)
4684 struct host_if_msg msg;
4687 PRINT_ER("driver is null\n");
4691 msg.id = HOST_IF_MSG_DEL_BEACON;
4693 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
4695 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4697 PRINT_ER("wilc_mq_send fail\n");
4702 s32 host_int_add_station(struct host_if_drv *hif_drv,
4703 struct add_sta_param *pstrStaParams)
4706 struct host_if_msg msg;
4707 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
4711 PRINT_ER("driver is null\n");
4715 memset(&msg, 0, sizeof(struct host_if_msg));
4717 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
4719 msg.id = HOST_IF_MSG_ADD_STATION;
4722 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
4723 if (pstrAddStationMsg->u8NumRates > 0) {
4724 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
4729 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
4730 pstrAddStationMsg->pu8Rates = rates;
4734 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4736 PRINT_ER("wilc_mq_send fail\n");
4740 s32 host_int_del_station(struct host_if_drv *hif_drv, const u8 *pu8MacAddr)
4743 struct host_if_msg msg;
4744 struct del_sta *pstrDelStationMsg = &msg.body.del_sta_info;
4747 PRINT_ER("driver is null\n");
4751 memset(&msg, 0, sizeof(struct host_if_msg));
4753 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
4755 msg.id = HOST_IF_MSG_DEL_STATION;
4758 if (pu8MacAddr == NULL)
4759 memset(pstrDelStationMsg->mac_addr, 255, ETH_ALEN);
4761 memcpy(pstrDelStationMsg->mac_addr, pu8MacAddr, ETH_ALEN);
4763 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4765 PRINT_ER("wilc_mq_send fail\n");
4769 s32 host_int_del_allstation(struct host_if_drv *hif_drv,
4770 u8 pu8MacAddr[][ETH_ALEN])
4773 struct host_if_msg msg;
4774 struct del_all_sta *pstrDelAllStationMsg = &msg.body.del_all_sta_info;
4775 u8 au8Zero_Buff[ETH_ALEN] = {0};
4781 PRINT_ER("driver is null\n");
4785 memset(&msg, 0, sizeof(struct host_if_msg));
4787 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
4789 msg.id = HOST_IF_MSG_DEL_ALL_STA;
4792 for (i = 0; i < MAX_NUM_STA; i++) {
4793 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
4794 memcpy(pstrDelAllStationMsg->del_all_sta[i], pu8MacAddr[i], ETH_ALEN);
4795 PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n",
4796 pstrDelAllStationMsg->del_all_sta[i][0],
4797 pstrDelAllStationMsg->del_all_sta[i][1],
4798 pstrDelAllStationMsg->del_all_sta[i][2],
4799 pstrDelAllStationMsg->del_all_sta[i][3],
4800 pstrDelAllStationMsg->del_all_sta[i][4],
4801 pstrDelAllStationMsg->del_all_sta[i][5]);
4806 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
4810 pstrDelAllStationMsg->assoc_sta = u8AssocNumb;
4811 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4815 PRINT_ER("wilc_mq_send fail\n");
4817 down(&hWaitResponse);
4823 s32 host_int_edit_station(struct host_if_drv *hif_drv,
4824 struct add_sta_param *pstrStaParams)
4827 struct host_if_msg msg;
4828 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
4831 PRINT_ER("driver is null\n");
4835 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
4837 memset(&msg, 0, sizeof(struct host_if_msg));
4839 msg.id = HOST_IF_MSG_EDIT_STATION;
4842 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
4843 if (pstrAddStationMsg->u8NumRates > 0) {
4844 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
4849 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
4850 pstrAddStationMsg->pu8Rates = rates;
4853 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4855 PRINT_ER("wilc_mq_send fail\n");
4860 s32 host_int_set_power_mgmt(struct host_if_drv *hif_drv,
4865 struct host_if_msg msg;
4866 struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.pwr_mgmt_info;
4868 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
4871 PRINT_ER("driver is null\n");
4875 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
4877 memset(&msg, 0, sizeof(struct host_if_msg));
4879 msg.id = HOST_IF_MSG_POWER_MGMT;
4882 pstrPowerMgmtParam->enabled = bIsEnabled;
4883 pstrPowerMgmtParam->timeout = u32Timeout;
4885 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4887 PRINT_ER("wilc_mq_send fail\n");
4891 s32 host_int_setup_multicast_filter(struct host_if_drv *hif_drv,
4896 struct host_if_msg msg;
4897 struct set_multicast *pstrMulticastFilterParam = &msg.body.multicast_info;
4901 PRINT_ER("driver is null\n");
4905 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
4907 memset(&msg, 0, sizeof(struct host_if_msg));
4909 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
4912 pstrMulticastFilterParam->enabled = bIsEnabled;
4913 pstrMulticastFilterParam->cnt = u32count;
4915 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4917 PRINT_ER("wilc_mq_send fail\n");
4921 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
4923 struct join_bss_param *pNewJoinBssParam = NULL;
4932 u8 pcipherTotalCount = 0;
4933 u8 authTotalCount = 0;
4936 pu8IEs = ptstrNetworkInfo->pu8IEs;
4937 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
4939 pNewJoinBssParam = kmalloc(sizeof(struct join_bss_param), GFP_KERNEL);
4940 if (pNewJoinBssParam != NULL) {
4941 memset(pNewJoinBssParam, 0, sizeof(struct join_bss_param));
4942 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
4943 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
4944 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
4945 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
4946 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
4947 pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen;
4948 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
4949 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
4951 while (index < u16IEsLen) {
4952 if (pu8IEs[index] == SUPP_RATES_IE) {
4953 suppRatesNo = pu8IEs[index + 1];
4954 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
4957 for (i = 0; i < suppRatesNo; i++) {
4958 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
4960 index += suppRatesNo;
4962 } else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
4963 extSuppRatesNo = pu8IEs[index + 1];
4964 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
4965 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
4967 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
4969 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
4970 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
4972 index += extSuppRatesNo;
4974 } else if (pu8IEs[index] == HT_CAPABILITY_IE) {
4975 pNewJoinBssParam->ht_capable = true;
4976 index += pu8IEs[index + 1] + 2;
4978 } else if ((pu8IEs[index] == WMM_IE) &&
4979 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
4980 (pu8IEs[index + 4] == 0xF2) &&
4981 (pu8IEs[index + 5] == 0x02) &&
4982 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) &&
4983 (pu8IEs[index + 7] == 0x01)) {
4984 pNewJoinBssParam->wmm_cap = true;
4986 if (pu8IEs[index + 8] & BIT(7))
4987 pNewJoinBssParam->uapsd_cap = true;
4988 index += pu8IEs[index + 1] + 2;
4990 } else if ((pu8IEs[index] == P2P_IE) &&
4991 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
4992 (pu8IEs[index + 4] == 0x9a) &&
4993 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) {
4996 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
4997 pNewJoinBssParam->u8NoaEnbaled = 1;
4998 pNewJoinBssParam->u8Index = pu8IEs[index + 9];
5000 if (pu8IEs[index + 10] & BIT(7)) {
5001 pNewJoinBssParam->u8OppEnable = 1;
5002 pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10];
5004 pNewJoinBssParam->u8OppEnable = 0;
5006 PRINT_D(GENERIC_DBG, "P2P Dump\n");
5007 for (i = 0; i < pu8IEs[index + 7]; i++)
5008 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
5010 pNewJoinBssParam->u8Count = pu8IEs[index + 11];
5011 u16P2P_count = index + 12;
5013 memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4);
5016 memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4);
5019 memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
5021 index += pu8IEs[index + 1] + 2;
5024 } else if ((pu8IEs[index] == RSN_IE) ||
5025 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
5026 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
5027 (pu8IEs[index + 5] == 0x01))) {
5028 u16 rsnIndex = index;
5030 if (pu8IEs[rsnIndex] == RSN_IE) {
5031 pNewJoinBssParam->mode_802_11i = 2;
5033 if (pNewJoinBssParam->mode_802_11i == 0)
5034 pNewJoinBssParam->mode_802_11i = 1;
5039 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
5041 jumpOffset = pu8IEs[rsnIndex] * 4;
5042 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
5045 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
5046 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
5048 pcipherTotalCount += pcipherCount;
5049 rsnIndex += jumpOffset;
5051 jumpOffset = pu8IEs[rsnIndex] * 4;
5053 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
5056 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
5057 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
5059 authTotalCount += authCount;
5060 rsnIndex += jumpOffset;
5062 if (pu8IEs[index] == RSN_IE) {
5063 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
5064 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
5067 pNewJoinBssParam->rsn_found = true;
5068 index += pu8IEs[index + 1] + 2;
5071 index += pu8IEs[index + 1] + 2;
5078 return (void *)pNewJoinBssParam;
5082 void host_int_freeJoinParams(void *pJoinParams)
5084 if ((struct bss_param *)pJoinParams != NULL)
5085 kfree((struct bss_param *)pJoinParams);
5087 PRINT_ER("Unable to FREE null pointer\n");
5090 s32 host_int_delBASession(struct host_if_drv *hif_drv, char *pBSSID, char TID)
5093 struct host_if_msg msg;
5094 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
5097 PRINT_ER("driver is null\n");
5101 memset(&msg, 0, sizeof(struct host_if_msg));
5103 msg.id = HOST_IF_MSG_DEL_BA_SESSION;
5105 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
5106 pBASessionInfo->u8Ted = TID;
5109 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5111 PRINT_ER("wilc_mq_send fail\n");
5113 down(&hWaitResponse);
5118 s32 host_int_del_All_Rx_BASession(struct host_if_drv *hif_drv,
5123 struct host_if_msg msg;
5124 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
5127 PRINT_ER("driver is null\n");
5131 memset(&msg, 0, sizeof(struct host_if_msg));
5133 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
5135 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
5136 pBASessionInfo->u8Ted = TID;
5139 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5141 PRINT_ER("wilc_mq_send fail\n");
5143 down(&hWaitResponse);
5148 s32 host_int_setup_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
5151 struct host_if_msg msg;
5156 PRINT_ER("driver is null\n");
5160 memset(&msg, 0, sizeof(struct host_if_msg));
5162 msg.id = HOST_IF_MSG_SET_IPADDRESS;
5164 msg.body.ip_info.ip_addr = u16ipadd;
5166 msg.body.ip_info.idx = idx;
5168 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5170 PRINT_ER("wilc_mq_send fail\n");
5177 s32 host_int_get_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
5180 struct host_if_msg msg;
5183 PRINT_ER("driver is null\n");
5187 memset(&msg, 0, sizeof(struct host_if_msg));
5189 msg.id = HOST_IF_MSG_GET_IPADDRESS;
5191 msg.body.ip_info.ip_addr = u16ipadd;
5193 msg.body.ip_info.idx = idx;
5195 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5197 PRINT_ER("wilc_mq_send fail\n");