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 static struct host_if_drv *wfidrv_list[NUM_CONCURRENT_IFC + 1];
233 struct host_if_drv *terminated_handle;
236 static struct task_struct *hif_thread_handler;
237 static WILC_MsgQueueHandle hif_msg_q;
238 static struct semaphore hif_sema_thread;
239 static struct semaphore hif_sema_driver;
240 static struct semaphore hWaitResponse;
241 struct semaphore hSemHostIntDeinit;
242 struct timer_list g_hPeriodicRSSI;
246 u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
248 static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE];
250 bool gbScanWhileConnected;
255 static u8 gs8SetIP[2][4];
256 static u8 gs8GetIP[2][4];
257 static u32 gu32InactiveTime;
259 static u32 gu32WidConnRstHack;
261 u8 *gu8FlushedJoinReq;
262 u8 *gu8FlushedInfoElemAsoc;
263 u8 gu8Flushed11iMode;
264 u8 gu8FlushedAuthType;
265 u32 gu32FlushedJoinReqSize;
266 u32 gu32FlushedInfoElemAsocSize;
267 struct host_if_drv *gu8FlushedJoinReqDrvHandler;
268 #define REAL_JOIN_REQ 0
269 #define FLUSHED_JOIN_REQ 1
270 #define FLUSHED_BYTE_POS 79
272 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
274 extern void chip_sleep_manually(u32 u32SleepTime);
275 extern int linux_wlan_get_num_conn_ifcs(void);
277 static int add_handler_in_list(struct host_if_drv *handler)
281 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
282 if (!wfidrv_list[i]) {
283 wfidrv_list[i] = handler;
291 static int remove_handler_in_list(struct host_if_drv *handler)
295 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
296 if (wfidrv_list[i] == handler) {
297 wfidrv_list[i] = NULL;
305 static int get_id_from_handler(struct host_if_drv *handler)
312 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
313 if (wfidrv_list[i] == handler)
320 static struct host_if_drv *get_handler_from_id(int id)
322 if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list))
324 return wfidrv_list[id];
327 static s32 Handle_SetChannel(struct host_if_drv *hif_drv,
328 struct channel_attr *pstrHostIFSetChan)
334 strWID.id = (u16)WID_CURRENT_CHANNEL;
335 strWID.type = WID_CHAR;
336 strWID.val = (char *)&(pstrHostIFSetChan->set_ch);
337 strWID.size = sizeof(char);
339 PRINT_D(HOSTINF_DBG, "Setting channel\n");
341 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
342 get_id_from_handler(hif_drv));
344 PRINT_ER("Failed to set channel\n");
351 static s32 Handle_SetWfiDrvHandler(struct host_if_drv *hif_drv,
352 struct drv_handler *pstrHostIfSetDrvHandler)
358 strWID.id = (u16)WID_SET_DRV_HANDLER;
359 strWID.type = WID_INT;
360 strWID.val = (s8 *)&(pstrHostIfSetDrvHandler->u32Address);
361 strWID.size = sizeof(u32);
363 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
364 pstrHostIfSetDrvHandler->u32Address);
367 up(&hif_sema_driver);
370 PRINT_ER("Failed to set driver handler\n");
377 static s32 Handle_SetOperationMode(struct host_if_drv *hif_drv,
378 struct op_mode *pstrHostIfSetOperationMode)
384 strWID.id = (u16)WID_SET_OPERATION_MODE;
385 strWID.type = WID_INT;
386 strWID.val = (s8 *)&(pstrHostIfSetOperationMode->u32Mode);
387 strWID.size = sizeof(u32);
389 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
390 get_id_from_handler(hif_drv));
393 if ((pstrHostIfSetOperationMode->u32Mode) == IDLE_MODE)
394 up(&hif_sema_driver);
397 PRINT_ER("Failed to set driver handler\n");
404 s32 Handle_set_IPAddress(struct host_if_drv *hif_drv, u8 *pu8IPAddr, u8 idx)
409 char firmwareIPAddress[4] = {0};
411 if (pu8IPAddr[0] < 192)
414 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n", idx, pu8IPAddr);
416 memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN);
418 strWID.id = (u16)WID_IP_ADDRESS;
419 strWID.type = WID_STR;
420 strWID.val = (u8 *)pu8IPAddr;
421 strWID.size = IP_ALEN;
423 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
424 get_id_from_handler(hif_drv));
427 host_int_get_ipaddress(hif_drv, firmwareIPAddress, idx);
430 PRINT_ER("Failed to set IP address\n");
434 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
439 s32 Handle_get_IPAddress(struct host_if_drv *hif_drv, u8 *pu8IPAddr, u8 idx)
445 strWID.id = (u16)WID_IP_ADDRESS;
446 strWID.type = WID_STR;
447 strWID.val = kmalloc(IP_ALEN, GFP_KERNEL);
448 strWID.size = IP_ALEN;
450 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
451 get_id_from_handler(hif_drv));
453 PRINT_INFO(HOSTINF_DBG, "%pI4\n", strWID.val);
455 memcpy(gs8GetIP[idx], strWID.val, IP_ALEN);
459 if (memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0)
460 host_int_setup_ipaddress(hif_drv, gs8SetIP[idx], idx);
463 PRINT_ER("Failed to get IP address\n");
467 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
468 PRINT_INFO(HOSTINF_DBG, "%pI4\n", gs8GetIP[idx]);
469 PRINT_INFO(HOSTINF_DBG, "\n");
474 static s32 Handle_SetMacAddress(struct host_if_drv *hif_drv,
475 struct set_mac_addr *pstrHostIfSetMacAddress)
480 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
482 if (mac_buf == NULL) {
483 PRINT_ER("No buffer to send mac address\n");
486 memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
488 strWID.id = (u16)WID_MAC_ADDR;
489 strWID.type = WID_STR;
490 strWID.val = mac_buf;
491 strWID.size = ETH_ALEN;
492 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", strWID.val);
494 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
495 get_id_from_handler(hif_drv));
497 PRINT_ER("Failed to set mac address\n");
505 static s32 Handle_GetMacAddress(struct host_if_drv *hif_drv,
506 struct get_mac_addr *pstrHostIfGetMacAddress)
512 strWID.id = (u16)WID_MAC_ADDR;
513 strWID.type = WID_STR;
514 strWID.val = pstrHostIfGetMacAddress->u8MacAddress;
515 strWID.size = ETH_ALEN;
517 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
518 get_id_from_handler(hif_drv));
520 PRINT_ER("Failed to get mac address\n");
528 static s32 Handle_CfgParam(struct host_if_drv *hif_drv,
529 struct cfg_param_attr *strHostIFCfgParamAttr)
532 struct wid strWIDList[32];
535 down(&hif_drv->gtOsCfgValuesSem);
538 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
540 if (strHostIFCfgParamAttr->cfg_attr_info.flag & BSS_TYPE) {
541 if (strHostIFCfgParamAttr->cfg_attr_info.bss_type < 6) {
542 strWIDList[u8WidCnt].id = WID_BSS_TYPE;
543 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.bss_type;
544 strWIDList[u8WidCnt].type = WID_CHAR;
545 strWIDList[u8WidCnt].size = sizeof(char);
546 hif_drv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->cfg_attr_info.bss_type;
548 PRINT_ER("check value 6 over\n");
554 if (strHostIFCfgParamAttr->cfg_attr_info.flag & AUTH_TYPE) {
555 if ((strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 1 || (strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 2 || (strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 5) {
556 strWIDList[u8WidCnt].id = WID_AUTH_TYPE;
557 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.auth_type;
558 strWIDList[u8WidCnt].type = WID_CHAR;
559 strWIDList[u8WidCnt].size = sizeof(char);
560 hif_drv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->cfg_attr_info.auth_type;
562 PRINT_ER("Impossible value \n");
568 if (strHostIFCfgParamAttr->cfg_attr_info.flag & AUTHEN_TIMEOUT) {
569 if (strHostIFCfgParamAttr->cfg_attr_info.auth_timeout > 0 && strHostIFCfgParamAttr->cfg_attr_info.auth_timeout < 65536) {
570 strWIDList[u8WidCnt].id = WID_AUTH_TIMEOUT;
571 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.auth_timeout;
572 strWIDList[u8WidCnt].type = WID_SHORT;
573 strWIDList[u8WidCnt].size = sizeof(u16);
574 hif_drv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->cfg_attr_info.auth_timeout;
576 PRINT_ER("Range(1 ~ 65535) over\n");
582 if (strHostIFCfgParamAttr->cfg_attr_info.flag & POWER_MANAGEMENT) {
583 if (strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode < 5) {
584 strWIDList[u8WidCnt].id = WID_POWER_MANAGEMENT;
585 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode;
586 strWIDList[u8WidCnt].type = WID_CHAR;
587 strWIDList[u8WidCnt].size = sizeof(char);
588 hif_drv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode;
590 PRINT_ER("Invalide power mode\n");
596 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RETRY_SHORT) {
597 if ((strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit > 0) && (strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit < 256)) {
598 strWIDList[u8WidCnt].id = WID_SHORT_RETRY_LIMIT;
599 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit;
600 strWIDList[u8WidCnt].type = WID_SHORT;
601 strWIDList[u8WidCnt].size = sizeof(u16);
602 hif_drv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit;
604 PRINT_ER("Range(1~256) over\n");
610 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RETRY_LONG) {
611 if ((strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit > 0) && (strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit < 256)) {
612 strWIDList[u8WidCnt].id = WID_LONG_RETRY_LIMIT;
613 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit;
615 strWIDList[u8WidCnt].type = WID_SHORT;
616 strWIDList[u8WidCnt].size = sizeof(u16);
617 hif_drv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit;
619 PRINT_ER("Range(1~256) over\n");
625 if (strHostIFCfgParamAttr->cfg_attr_info.flag & FRAG_THRESHOLD) {
627 if (strHostIFCfgParamAttr->cfg_attr_info.frag_threshold > 255 && strHostIFCfgParamAttr->cfg_attr_info.frag_threshold < 7937) {
628 strWIDList[u8WidCnt].id = WID_FRAG_THRESHOLD;
629 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.frag_threshold;
630 strWIDList[u8WidCnt].type = WID_SHORT;
631 strWIDList[u8WidCnt].size = sizeof(u16);
632 hif_drv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->cfg_attr_info.frag_threshold;
634 PRINT_ER("Threshold Range fail\n");
640 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RTS_THRESHOLD) {
641 if (strHostIFCfgParamAttr->cfg_attr_info.rts_threshold > 255 && strHostIFCfgParamAttr->cfg_attr_info.rts_threshold < 65536) {
642 strWIDList[u8WidCnt].id = WID_RTS_THRESHOLD;
643 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.rts_threshold;
644 strWIDList[u8WidCnt].type = WID_SHORT;
645 strWIDList[u8WidCnt].size = sizeof(u16);
646 hif_drv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->cfg_attr_info.rts_threshold;
648 PRINT_ER("Threshold Range fail\n");
654 if (strHostIFCfgParamAttr->cfg_attr_info.flag & PREAMBLE) {
655 if (strHostIFCfgParamAttr->cfg_attr_info.preamble_type < 3) {
656 strWIDList[u8WidCnt].id = WID_PREAMBLE;
657 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.preamble_type;
658 strWIDList[u8WidCnt].type = WID_CHAR;
659 strWIDList[u8WidCnt].size = sizeof(char);
660 hif_drv->strCfgValues.preamble_type = strHostIFCfgParamAttr->cfg_attr_info.preamble_type;
662 PRINT_ER("Preamle Range(0~2) over\n");
668 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SHORT_SLOT_ALLOWED) {
669 if (strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed < 2) {
670 strWIDList[u8WidCnt].id = WID_SHORT_SLOT_ALLOWED;
671 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed;
672 strWIDList[u8WidCnt].type = WID_CHAR;
673 strWIDList[u8WidCnt].size = sizeof(char);
674 hif_drv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed;
676 PRINT_ER("Short slot(2) over\n");
682 if (strHostIFCfgParamAttr->cfg_attr_info.flag & TXOP_PROT_DISABLE) {
683 if (strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled < 2) {
684 strWIDList[u8WidCnt].id = WID_11N_TXOP_PROT_DISABLE;
685 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled;
686 strWIDList[u8WidCnt].type = WID_CHAR;
687 strWIDList[u8WidCnt].size = sizeof(char);
688 hif_drv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled;
690 PRINT_ER("TXOP prot disable\n");
696 if (strHostIFCfgParamAttr->cfg_attr_info.flag & BEACON_INTERVAL) {
697 if (strHostIFCfgParamAttr->cfg_attr_info.beacon_interval > 0 && strHostIFCfgParamAttr->cfg_attr_info.beacon_interval < 65536) {
698 strWIDList[u8WidCnt].id = WID_BEACON_INTERVAL;
699 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.beacon_interval;
700 strWIDList[u8WidCnt].type = WID_SHORT;
701 strWIDList[u8WidCnt].size = sizeof(u16);
702 hif_drv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->cfg_attr_info.beacon_interval;
704 PRINT_ER("Beacon interval(1~65535) fail\n");
710 if (strHostIFCfgParamAttr->cfg_attr_info.flag & DTIM_PERIOD) {
711 if (strHostIFCfgParamAttr->cfg_attr_info.dtim_period > 0 && strHostIFCfgParamAttr->cfg_attr_info.dtim_period < 256) {
712 strWIDList[u8WidCnt].id = WID_DTIM_PERIOD;
713 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.dtim_period;
714 strWIDList[u8WidCnt].type = WID_CHAR;
715 strWIDList[u8WidCnt].size = sizeof(char);
716 hif_drv->strCfgValues.dtim_period = strHostIFCfgParamAttr->cfg_attr_info.dtim_period;
718 PRINT_ER("DTIM range(1~255) fail\n");
724 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SITE_SURVEY) {
725 if (strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled < 3) {
726 strWIDList[u8WidCnt].id = WID_SITE_SURVEY;
727 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled;
728 strWIDList[u8WidCnt].type = WID_CHAR;
729 strWIDList[u8WidCnt].size = sizeof(char);
730 hif_drv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled;
732 PRINT_ER("Site survey disable\n");
738 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SITE_SURVEY_SCAN_TIME) {
739 if (strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time < 65536) {
740 strWIDList[u8WidCnt].id = WID_SITE_SURVEY_SCAN_TIME;
741 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time;
742 strWIDList[u8WidCnt].type = WID_SHORT;
743 strWIDList[u8WidCnt].size = sizeof(u16);
744 hif_drv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time;
746 PRINT_ER("Site survey scan time(1~65535) over\n");
752 if (strHostIFCfgParamAttr->cfg_attr_info.flag & ACTIVE_SCANTIME) {
753 if (strHostIFCfgParamAttr->cfg_attr_info.active_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.active_scan_time < 65536) {
754 strWIDList[u8WidCnt].id = WID_ACTIVE_SCAN_TIME;
755 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.active_scan_time;
756 strWIDList[u8WidCnt].type = WID_SHORT;
757 strWIDList[u8WidCnt].size = sizeof(u16);
758 hif_drv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->cfg_attr_info.active_scan_time;
760 PRINT_ER("Active scan time(1~65535) over\n");
766 if (strHostIFCfgParamAttr->cfg_attr_info.flag & PASSIVE_SCANTIME) {
767 if (strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time < 65536) {
768 strWIDList[u8WidCnt].id = WID_PASSIVE_SCAN_TIME;
769 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time;
770 strWIDList[u8WidCnt].type = WID_SHORT;
771 strWIDList[u8WidCnt].size = sizeof(u16);
772 hif_drv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time;
774 PRINT_ER("Passive scan time(1~65535) over\n");
780 if (strHostIFCfgParamAttr->cfg_attr_info.flag & CURRENT_TX_RATE) {
781 enum CURRENT_TXRATE curr_tx_rate = strHostIFCfgParamAttr->cfg_attr_info.curr_tx_rate;
782 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
783 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
784 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
785 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
786 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
787 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
788 strWIDList[u8WidCnt].id = WID_CURRENT_TX_RATE;
789 strWIDList[u8WidCnt].val = (s8 *)&curr_tx_rate;
790 strWIDList[u8WidCnt].type = WID_SHORT;
791 strWIDList[u8WidCnt].size = sizeof(u16);
792 hif_drv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
794 PRINT_ER("out of TX rate\n");
800 s32Error = send_config_pkt(SET_CFG, strWIDList, u8WidCnt,
801 get_id_from_handler(hif_drv));
804 PRINT_ER("Error in setting CFG params\n");
807 up(&hif_drv->gtOsCfgValuesSem);
811 static s32 Handle_wait_msg_q_empty(void)
813 g_wilc_initialized = 0;
818 static s32 Handle_Scan(struct host_if_drv *hif_drv,
819 struct scan_attr *pstrHostIFscanAttr)
822 struct wid strWIDList[5];
823 u32 u32WidsCount = 0;
827 u8 *pu8HdnNtwrksWidVal = NULL;
829 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
830 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", hif_drv->enuHostIFstate);
832 hif_drv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->result;
833 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->arg;
835 if ((hif_drv->enuHostIFstate >= HOST_IF_SCANNING) && (hif_drv->enuHostIFstate < HOST_IF_CONNECTED)) {
836 PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", hif_drv->enuHostIFstate);
837 PRINT_ER("Already scan\n");
842 if (g_obtainingIP || connecting) {
843 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
844 PRINT_ER("Don't do obss scan\n");
849 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
852 hif_drv->strWILC_UsrScanReq.u32RcvdChCount = 0;
854 strWIDList[u32WidsCount].id = (u16)WID_SSID_PROBE_REQ;
855 strWIDList[u32WidsCount].type = WID_STR;
857 for (i = 0; i < pstrHostIFscanAttr->hidden_network.u8ssidnum; i++)
858 valuesize += ((pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
859 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
860 strWIDList[u32WidsCount].val = pu8HdnNtwrksWidVal;
861 if (strWIDList[u32WidsCount].val != NULL) {
862 pu8Buffer = strWIDList[u32WidsCount].val;
864 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.u8ssidnum;
866 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->hidden_network.u8ssidnum);
868 for (i = 0; i < pstrHostIFscanAttr->hidden_network.u8ssidnum; i++) {
869 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen;
870 memcpy(pu8Buffer, pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen);
871 pu8Buffer += pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen;
876 strWIDList[u32WidsCount].size = (s32)(valuesize + 1);
881 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_PROBE;
882 strWIDList[u32WidsCount].type = WID_BIN_DATA;
883 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ies;
884 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ies_len;
888 strWIDList[u32WidsCount].id = WID_SCAN_TYPE;
889 strWIDList[u32WidsCount].type = WID_CHAR;
890 strWIDList[u32WidsCount].size = sizeof(char);
891 strWIDList[u32WidsCount].val = (s8 *)(&(pstrHostIFscanAttr->type));
894 strWIDList[u32WidsCount].id = WID_SCAN_CHANNEL_LIST;
895 strWIDList[u32WidsCount].type = WID_BIN_DATA;
897 if (pstrHostIFscanAttr->ch_freq_list != NULL && pstrHostIFscanAttr->ch_list_len > 0) {
900 for (i = 0; i < pstrHostIFscanAttr->ch_list_len; i++) {
901 if (pstrHostIFscanAttr->ch_freq_list[i] > 0)
902 pstrHostIFscanAttr->ch_freq_list[i] = pstrHostIFscanAttr->ch_freq_list[i] - 1;
906 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ch_freq_list;
907 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ch_list_len;
910 strWIDList[u32WidsCount].id = WID_START_SCAN_REQ;
911 strWIDList[u32WidsCount].type = WID_CHAR;
912 strWIDList[u32WidsCount].size = sizeof(char);
913 strWIDList[u32WidsCount].val = (s8 *)(&(pstrHostIFscanAttr->src));
916 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)
917 gbScanWhileConnected = true;
918 else if (hif_drv->enuHostIFstate == HOST_IF_IDLE)
919 gbScanWhileConnected = false;
921 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
922 get_id_from_handler(hif_drv));
925 PRINT_ER("Failed to send scan paramters config packet\n");
927 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
931 del_timer(&hif_drv->hScanTimer);
932 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
935 kfree(pstrHostIFscanAttr->ch_freq_list);
936 pstrHostIFscanAttr->ch_freq_list = NULL;
938 kfree(pstrHostIFscanAttr->ies);
939 pstrHostIFscanAttr->ies = NULL;
940 kfree(pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo);
941 pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo = NULL;
943 kfree(pu8HdnNtwrksWidVal);
948 static s32 Handle_ScanDone(struct host_if_drv *hif_drv,
949 enum scan_event enuEvent)
952 u8 u8abort_running_scan;
956 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
958 if (enuEvent == SCAN_EVENT_ABORTED) {
959 PRINT_D(GENERIC_DBG, "Abort running scan\n");
960 u8abort_running_scan = 1;
961 strWID.id = (u16)WID_ABORT_RUNNING_SCAN;
962 strWID.type = WID_CHAR;
963 strWID.val = (s8 *)&u8abort_running_scan;
964 strWID.size = sizeof(char);
966 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
967 get_id_from_handler(hif_drv));
969 PRINT_ER("Failed to set abort running scan\n");
975 PRINT_ER("Driver handler is NULL\n");
979 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
980 hif_drv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
981 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
982 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
988 u8 u8ConnectedSSID[6] = {0};
989 static s32 Handle_Connect(struct host_if_drv *hif_drv,
990 struct connect_attr *pstrHostIFconnectAttr)
993 struct wid strWIDList[8];
994 u32 u32WidsCount = 0, dummyval = 0;
995 u8 *pu8CurrByte = NULL;
996 struct join_bss_param *ptstrJoinBssParam;
998 PRINT_D(GENERIC_DBG, "Handling connect request\n");
1000 if (memcmp(pstrHostIFconnectAttr->bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
1003 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1007 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1009 ptstrJoinBssParam = (struct join_bss_param *)pstrHostIFconnectAttr->params;
1010 if (ptstrJoinBssParam == NULL) {
1011 PRINT_ER("Required BSSID not found\n");
1016 if (pstrHostIFconnectAttr->bssid != NULL) {
1017 hif_drv->strWILC_UsrConnReq.pu8bssid = kmalloc(6, GFP_KERNEL);
1018 memcpy(hif_drv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->bssid, 6);
1021 hif_drv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssid_len;
1022 if (pstrHostIFconnectAttr->ssid != NULL) {
1023 hif_drv->strWILC_UsrConnReq.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssid_len + 1, GFP_KERNEL);
1024 memcpy(hif_drv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->ssid,
1025 pstrHostIFconnectAttr->ssid_len);
1026 hif_drv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssid_len] = '\0';
1029 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->ies_len;
1030 if (pstrHostIFconnectAttr->ies != NULL) {
1031 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
1032 memcpy(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->ies,
1033 pstrHostIFconnectAttr->ies_len);
1036 hif_drv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->security;
1037 hif_drv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->auth_type;
1038 hif_drv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->result;
1039 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->arg;
1041 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
1042 strWIDList[u32WidsCount].type = WID_INT;
1043 strWIDList[u32WidsCount].size = sizeof(u32);
1044 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1047 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
1048 strWIDList[u32WidsCount].type = WID_INT;
1049 strWIDList[u32WidsCount].size = sizeof(u32);
1050 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1053 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
1054 strWIDList[u32WidsCount].type = WID_INT;
1055 strWIDList[u32WidsCount].size = sizeof(u32);
1056 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1060 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
1061 strWIDList[u32WidsCount].type = WID_BIN_DATA;
1062 strWIDList[u32WidsCount].val = hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs;
1063 strWIDList[u32WidsCount].size = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1066 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1068 gu32FlushedInfoElemAsocSize = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1069 gu8FlushedInfoElemAsoc = kmalloc(gu32FlushedInfoElemAsocSize, GFP_KERNEL);
1070 memcpy(gu8FlushedInfoElemAsoc, hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
1071 gu32FlushedInfoElemAsocSize);
1074 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
1075 strWIDList[u32WidsCount].type = WID_CHAR;
1076 strWIDList[u32WidsCount].size = sizeof(char);
1077 strWIDList[u32WidsCount].val = (s8 *)(&(hif_drv->strWILC_UsrConnReq.u8security));
1080 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
1081 gu8Flushed11iMode = hif_drv->strWILC_UsrConnReq.u8security;
1083 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", hif_drv->strWILC_UsrConnReq.u8security);
1086 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
1087 strWIDList[u32WidsCount].type = WID_CHAR;
1088 strWIDList[u32WidsCount].size = sizeof(char);
1089 strWIDList[u32WidsCount].val = (s8 *)(&hif_drv->strWILC_UsrConnReq.tenuAuth_type);
1092 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
1093 gu8FlushedAuthType = (u8)hif_drv->strWILC_UsrConnReq.tenuAuth_type;
1095 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", hif_drv->strWILC_UsrConnReq.tenuAuth_type);
1096 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
1097 hif_drv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->ch);
1099 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
1100 strWIDList[u32WidsCount].type = WID_STR;
1101 strWIDList[u32WidsCount].size = 112;
1102 strWIDList[u32WidsCount].val = kmalloc(strWIDList[u32WidsCount].size, GFP_KERNEL);
1104 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1105 gu32FlushedJoinReqSize = strWIDList[u32WidsCount].size;
1106 gu8FlushedJoinReq = kmalloc(gu32FlushedJoinReqSize, GFP_KERNEL);
1108 if (strWIDList[u32WidsCount].val == NULL) {
1113 pu8CurrByte = strWIDList[u32WidsCount].val;
1116 if (pstrHostIFconnectAttr->ssid != NULL) {
1117 memcpy(pu8CurrByte, pstrHostIFconnectAttr->ssid, pstrHostIFconnectAttr->ssid_len);
1118 pu8CurrByte[pstrHostIFconnectAttr->ssid_len] = '\0';
1120 pu8CurrByte += MAX_SSID_LEN;
1121 *(pu8CurrByte++) = INFRASTRUCTURE;
1123 if ((pstrHostIFconnectAttr->ch >= 1) && (pstrHostIFconnectAttr->ch <= 14)) {
1124 *(pu8CurrByte++) = pstrHostIFconnectAttr->ch;
1126 PRINT_ER("Channel out of range\n");
1127 *(pu8CurrByte++) = 0xFF;
1129 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1130 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1131 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1133 if (pstrHostIFconnectAttr->bssid != NULL)
1134 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
1137 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1138 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1139 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1140 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1141 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1143 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
1144 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1146 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1147 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1148 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1150 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1151 hif_drv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
1153 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1154 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1155 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1156 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1157 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1158 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1160 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
1161 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1163 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
1164 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1166 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
1167 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1169 *(pu8CurrByte++) = REAL_JOIN_REQ;
1170 *(pu8CurrByte++) = ptstrJoinBssParam->noa_enabled;
1172 if (ptstrJoinBssParam->noa_enabled) {
1173 PRINT_D(HOSTINF_DBG, "NOA present\n");
1175 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1176 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1177 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1178 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1180 *(pu8CurrByte++) = ptstrJoinBssParam->opp_enabled;
1181 *(pu8CurrByte++) = ptstrJoinBssParam->idx;
1183 if (ptstrJoinBssParam->opp_enabled)
1184 *(pu8CurrByte++) = ptstrJoinBssParam->ct_window;
1186 *(pu8CurrByte++) = ptstrJoinBssParam->cnt;
1188 memcpy(pu8CurrByte, ptstrJoinBssParam->duration, sizeof(ptstrJoinBssParam->duration));
1189 pu8CurrByte += sizeof(ptstrJoinBssParam->duration);
1191 memcpy(pu8CurrByte, ptstrJoinBssParam->interval, sizeof(ptstrJoinBssParam->interval));
1192 pu8CurrByte += sizeof(ptstrJoinBssParam->interval);
1194 memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
1196 pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1199 PRINT_D(HOSTINF_DBG, "NOA not present\n");
1201 pu8CurrByte = strWIDList[u32WidsCount].val;
1203 gu32WidConnRstHack = 0;
1205 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1206 memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
1207 gu8FlushedJoinReqDrvHandler = hif_drv;
1210 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1212 if (pstrHostIFconnectAttr->bssid != NULL) {
1213 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->bssid, ETH_ALEN);
1215 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n", pstrHostIFconnectAttr->bssid);
1216 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", u8ConnectedSSID);
1219 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
1220 get_id_from_handler(hif_drv));
1222 PRINT_ER("failed to send config packet\n");
1226 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
1227 hif_drv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1232 tstrConnectInfo strConnectInfo;
1234 del_timer(&hif_drv->hConnectTimer);
1236 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
1238 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1240 if (pstrHostIFconnectAttr->result != NULL) {
1241 if (pstrHostIFconnectAttr->bssid != NULL)
1242 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->bssid, 6);
1244 if (pstrHostIFconnectAttr->ies != NULL) {
1245 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->ies_len;
1246 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
1247 memcpy(strConnectInfo.pu8ReqIEs,
1248 pstrHostIFconnectAttr->ies,
1249 pstrHostIFconnectAttr->ies_len);
1252 pstrHostIFconnectAttr->result(CONN_DISCONN_EVENT_CONN_RESP,
1256 pstrHostIFconnectAttr->arg);
1257 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1258 kfree(strConnectInfo.pu8ReqIEs);
1259 strConnectInfo.pu8ReqIEs = NULL;
1262 PRINT_ER("Connect callback function pointer is NULL\n");
1266 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
1267 kfree(pstrHostIFconnectAttr->bssid);
1268 pstrHostIFconnectAttr->bssid = NULL;
1270 kfree(pstrHostIFconnectAttr->ssid);
1271 pstrHostIFconnectAttr->ssid = NULL;
1273 kfree(pstrHostIFconnectAttr->ies);
1274 pstrHostIFconnectAttr->ies = NULL;
1280 static s32 Handle_FlushConnect(struct host_if_drv *hif_drv)
1283 struct wid strWIDList[5];
1284 u32 u32WidsCount = 0;
1285 u8 *pu8CurrByte = NULL;
1287 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
1288 strWIDList[u32WidsCount].type = WID_BIN_DATA;
1289 strWIDList[u32WidsCount].val = gu8FlushedInfoElemAsoc;
1290 strWIDList[u32WidsCount].size = gu32FlushedInfoElemAsocSize;
1293 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
1294 strWIDList[u32WidsCount].type = WID_CHAR;
1295 strWIDList[u32WidsCount].size = sizeof(char);
1296 strWIDList[u32WidsCount].val = (s8 *)(&(gu8Flushed11iMode));
1301 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
1302 strWIDList[u32WidsCount].type = WID_CHAR;
1303 strWIDList[u32WidsCount].size = sizeof(char);
1304 strWIDList[u32WidsCount].val = (s8 *)(&gu8FlushedAuthType);
1307 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
1308 strWIDList[u32WidsCount].type = WID_STR;
1309 strWIDList[u32WidsCount].size = gu32FlushedJoinReqSize;
1310 strWIDList[u32WidsCount].val = (s8 *)gu8FlushedJoinReq;
1311 pu8CurrByte = strWIDList[u32WidsCount].val;
1313 pu8CurrByte += FLUSHED_BYTE_POS;
1314 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1318 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
1319 get_id_from_handler(gu8FlushedJoinReqDrvHandler));
1321 PRINT_ER("failed to send config packet\n");
1328 static s32 Handle_ConnectTimeout(struct host_if_drv *hif_drv)
1331 tstrConnectInfo strConnectInfo;
1333 u16 u16DummyReasonCode = 0;
1336 PRINT_ER("Driver handler is NULL\n");
1340 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1342 gbScanWhileConnected = false;
1345 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1347 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
1348 if (hif_drv->strWILC_UsrConnReq.pu8bssid != NULL) {
1349 memcpy(strConnectInfo.au8bssid,
1350 hif_drv->strWILC_UsrConnReq.pu8bssid, 6);
1353 if (hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1354 strConnectInfo.ReqIEsLen = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1355 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
1356 memcpy(strConnectInfo.pu8ReqIEs,
1357 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
1358 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen);
1361 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1365 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
1367 kfree(strConnectInfo.pu8ReqIEs);
1368 strConnectInfo.pu8ReqIEs = NULL;
1370 PRINT_ER("Connect callback function pointer is NULL\n");
1373 strWID.id = (u16)WID_DISCONNECT;
1374 strWID.type = WID_CHAR;
1375 strWID.val = (s8 *)&u16DummyReasonCode;
1376 strWID.size = sizeof(char);
1378 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1380 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1381 get_id_from_handler(hif_drv));
1383 PRINT_ER("Failed to send dissconect config packet\n");
1385 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
1386 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
1387 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
1388 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1389 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
1391 eth_zero_addr(u8ConnectedSSID);
1393 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
1394 kfree(gu8FlushedJoinReq);
1395 gu8FlushedJoinReq = NULL;
1397 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
1398 kfree(gu8FlushedInfoElemAsoc);
1399 gu8FlushedInfoElemAsoc = NULL;
1405 static s32 Handle_RcvdNtwrkInfo(struct host_if_drv *hif_drv,
1406 struct rcvd_net_info *pstrRcvdNetworkInfo)
1409 bool bNewNtwrkFound;
1414 tstrNetworkInfo *pstrNetworkInfo = NULL;
1415 void *pJoinParams = NULL;
1417 bNewNtwrkFound = true;
1418 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
1420 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
1421 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
1422 parse_network_info(pstrRcvdNetworkInfo->buffer, &pstrNetworkInfo);
1423 if ((pstrNetworkInfo == NULL)
1424 || (hif_drv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
1425 PRINT_ER("driver is null\n");
1430 for (i = 0; i < hif_drv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
1432 if ((hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
1433 (pstrNetworkInfo->au8bssid != NULL)) {
1434 if (memcmp(hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
1435 pstrNetworkInfo->au8bssid, 6) == 0) {
1436 if (pstrNetworkInfo->s8rssi <= hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
1437 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
1440 hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
1441 bNewNtwrkFound = false;
1448 if (bNewNtwrkFound == true) {
1449 PRINT_D(HOSTINF_DBG, "New network found\n");
1451 if (hif_drv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
1452 hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
1454 if ((hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
1455 && (pstrNetworkInfo->au8bssid != NULL)) {
1456 memcpy(hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
1457 pstrNetworkInfo->au8bssid, 6);
1459 hif_drv->strWILC_UsrScanReq.u32RcvdChCount++;
1461 pstrNetworkInfo->bNewNetwork = true;
1462 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
1464 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1465 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid,
1471 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
1474 pstrNetworkInfo->bNewNetwork = false;
1475 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1476 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
1481 kfree(pstrRcvdNetworkInfo->buffer);
1482 pstrRcvdNetworkInfo->buffer = NULL;
1484 if (pstrNetworkInfo != NULL) {
1485 DeallocateNetworkInfo(pstrNetworkInfo);
1486 pstrNetworkInfo = NULL;
1492 static s32 Handle_RcvdGnrlAsyncInfo(struct host_if_drv *hif_drv,
1493 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
1499 u16 u16WidID = (u16)WID_NIL;
1502 u8 u8MacStatusReasonCode;
1503 u8 u8MacStatusAdditionalInfo;
1504 tstrConnectInfo strConnectInfo;
1505 tstrDisconnectNotifInfo strDisconnectNotifInfo;
1509 PRINT_ER("Driver handler is NULL\n");
1512 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", hif_drv->enuHostIFstate,
1513 pstrRcvdGnrlAsyncInfo->buffer[7]);
1515 if ((hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
1516 (hif_drv->enuHostIFstate == HOST_IF_CONNECTED) ||
1517 hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
1518 if ((pstrRcvdGnrlAsyncInfo->buffer == NULL) ||
1519 (hif_drv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
1520 PRINT_ER("driver is null\n");
1524 u8MsgType = pstrRcvdGnrlAsyncInfo->buffer[0];
1526 if ('I' != u8MsgType) {
1527 PRINT_ER("Received Message format incorrect.\n");
1531 u8MsgID = pstrRcvdGnrlAsyncInfo->buffer[1];
1532 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[2], pstrRcvdGnrlAsyncInfo->buffer[3]);
1533 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[4], pstrRcvdGnrlAsyncInfo->buffer[5]);
1534 u8WidLen = pstrRcvdGnrlAsyncInfo->buffer[6];
1535 u8MacStatus = pstrRcvdGnrlAsyncInfo->buffer[7];
1536 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->buffer[8];
1537 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->buffer[9];
1538 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
1539 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
1540 u32 u32RcvdAssocRespInfoLen;
1541 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
1543 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
1545 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1547 if (u8MacStatus == MAC_CONNECTED) {
1548 memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
1550 host_int_get_assoc_res_info(hif_drv,
1552 MAX_ASSOC_RESP_FRAME_SIZE,
1553 &u32RcvdAssocRespInfoLen);
1555 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
1557 if (u32RcvdAssocRespInfoLen != 0) {
1559 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
1560 s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
1561 &pstrConnectRespInfo);
1563 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
1565 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
1567 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
1568 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
1569 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
1570 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
1573 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL);
1574 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
1575 pstrConnectRespInfo->u16RespIEsLen);
1579 if (pstrConnectRespInfo != NULL) {
1580 DeallocateAssocRespInfo(pstrConnectRespInfo);
1581 pstrConnectRespInfo = NULL;
1587 if ((u8MacStatus == MAC_CONNECTED) &&
1588 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
1589 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
1590 eth_zero_addr(u8ConnectedSSID);
1592 } else if (u8MacStatus == MAC_DISCONNECTED) {
1593 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
1594 eth_zero_addr(u8ConnectedSSID);
1597 if (hif_drv->strWILC_UsrConnReq.pu8bssid != NULL) {
1598 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
1599 memcpy(strConnectInfo.au8bssid, hif_drv->strWILC_UsrConnReq.pu8bssid, 6);
1601 if ((u8MacStatus == MAC_CONNECTED) &&
1602 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
1603 memcpy(hif_drv->au8AssociatedBSSID,
1604 hif_drv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
1609 if (hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1610 strConnectInfo.ReqIEsLen = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1611 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
1612 memcpy(strConnectInfo.pu8ReqIEs,
1613 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
1614 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen);
1618 del_timer(&hif_drv->hConnectTimer);
1619 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1623 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
1625 if ((u8MacStatus == MAC_CONNECTED) &&
1626 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
1627 host_int_set_power_mgmt(hif_drv, 0, 0);
1629 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
1630 hif_drv->enuHostIFstate = HOST_IF_CONNECTED;
1632 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
1633 g_obtainingIP = true;
1634 mod_timer(&hDuringIpTimer,
1635 jiffies + msecs_to_jiffies(10000));
1637 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
1638 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1639 gbScanWhileConnected = false;
1642 kfree(strConnectInfo.pu8RespIEs);
1643 strConnectInfo.pu8RespIEs = NULL;
1645 kfree(strConnectInfo.pu8ReqIEs);
1646 strConnectInfo.pu8ReqIEs = NULL;
1647 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
1648 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
1649 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
1650 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1651 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
1652 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
1653 (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)) {
1654 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
1656 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
1658 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
1659 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
1660 del_timer(&hif_drv->hScanTimer);
1661 Handle_ScanDone((void *)hif_drv, SCAN_EVENT_ABORTED);
1664 strDisconnectNotifInfo.u16reason = 0;
1665 strDisconnectNotifInfo.ie = NULL;
1666 strDisconnectNotifInfo.ie_len = 0;
1668 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
1669 g_obtainingIP = false;
1670 host_int_set_power_mgmt(hif_drv, 0, 0);
1672 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1675 &strDisconnectNotifInfo,
1676 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
1679 PRINT_ER("Connect result callback function is NULL\n");
1682 eth_zero_addr(hif_drv->au8AssociatedBSSID);
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);
1690 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
1691 kfree(gu8FlushedJoinReq);
1692 gu8FlushedJoinReq = NULL;
1694 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
1695 kfree(gu8FlushedInfoElemAsoc);
1696 gu8FlushedInfoElemAsoc = NULL;
1699 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1700 gbScanWhileConnected = false;
1702 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
1703 (hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
1704 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
1705 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
1707 del_timer(&hif_drv->hScanTimer);
1708 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult)
1709 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
1715 kfree(pstrRcvdGnrlAsyncInfo->buffer);
1716 pstrRcvdGnrlAsyncInfo->buffer = NULL;
1721 static int Handle_Key(struct host_if_drv *hif_drv,
1722 struct key_attr *pstrHostIFkeyAttr)
1726 struct wid strWIDList[5];
1732 switch (pstrHostIFkeyAttr->type) {
1737 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1739 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
1740 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->attr.wep.index));
1741 strWIDList[0].id = (u16)WID_11I_MODE;
1742 strWIDList[0].type = WID_CHAR;
1743 strWIDList[0].size = sizeof(char);
1744 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.mode));
1746 strWIDList[1].id = WID_AUTH_TYPE;
1747 strWIDList[1].type = WID_CHAR;
1748 strWIDList[1].size = sizeof(char);
1749 strWIDList[1].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.auth_type));
1751 strWIDList[2].id = (u16)WID_KEY_ID;
1752 strWIDList[2].type = WID_CHAR;
1754 strWIDList[2].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.index));
1755 strWIDList[2].size = sizeof(char);
1757 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len, GFP_KERNEL);
1759 if (pu8keybuf == NULL) {
1760 PRINT_ER("No buffer to send Key\n");
1764 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wep.key,
1765 pstrHostIFkeyAttr->attr.wep.key_len);
1767 kfree(pstrHostIFkeyAttr->attr.wep.key);
1769 strWIDList[3].id = (u16)WID_WEP_KEY_VALUE;
1770 strWIDList[3].type = WID_STR;
1771 strWIDList[3].size = pstrHostIFkeyAttr->attr.wep.key_len;
1772 strWIDList[3].val = (s8 *)pu8keybuf;
1775 s32Error = send_config_pkt(SET_CFG, strWIDList, 4,
1776 get_id_from_handler(hif_drv));
1782 if (pstrHostIFkeyAttr->action & ADDKEY) {
1783 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
1784 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2, GFP_KERNEL);
1785 if (pu8keybuf == NULL) {
1786 PRINT_ER("No buffer to send Key\n");
1789 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1790 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->attr.wep.key_len, 1);
1791 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->attr.wep.key,
1792 pstrHostIFkeyAttr->attr.wep.key_len);
1793 kfree(pstrHostIFkeyAttr->attr.wep.key);
1795 strWID.id = (u16)WID_ADD_WEP_KEY;
1796 strWID.type = WID_STR;
1797 strWID.val = (s8 *)pu8keybuf;
1798 strWID.size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
1800 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1801 get_id_from_handler(hif_drv));
1803 } else if (pstrHostIFkeyAttr->action & REMOVEKEY) {
1805 PRINT_D(HOSTINF_DBG, "Removing key\n");
1806 strWID.id = (u16)WID_REMOVE_WEP_KEY;
1807 strWID.type = WID_STR;
1809 s8idxarray[0] = (s8)pstrHostIFkeyAttr->attr.wep.index;
1810 strWID.val = s8idxarray;
1813 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1814 get_id_from_handler(hif_drv));
1816 strWID.id = (u16)WID_KEY_ID;
1817 strWID.type = WID_CHAR;
1818 strWID.val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.index));
1819 strWID.size = sizeof(char);
1821 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
1823 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1824 get_id_from_handler(hif_drv));
1826 up(&hif_drv->hSemTestKeyBlock);
1830 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1831 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1832 if (pu8keybuf == NULL) {
1833 PRINT_ER("No buffer to send RxGTK Key\n");
1835 goto _WPARxGtk_end_case_;
1838 if (pstrHostIFkeyAttr->attr.wpa.seq != NULL)
1839 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1841 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1842 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1843 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1844 pstrHostIFkeyAttr->attr.wpa.key_len);
1846 strWIDList[0].id = (u16)WID_11I_MODE;
1847 strWIDList[0].type = WID_CHAR;
1848 strWIDList[0].size = sizeof(char);
1849 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wpa.mode));
1851 strWIDList[1].id = (u16)WID_ADD_RX_GTK;
1852 strWIDList[1].type = WID_STR;
1853 strWIDList[1].val = (s8 *)pu8keybuf;
1854 strWIDList[1].size = RX_MIC_KEY_MSG_LEN;
1856 s32Error = send_config_pkt(SET_CFG, strWIDList, 2,
1857 get_id_from_handler(hif_drv));
1860 up(&hif_drv->hSemTestKeyBlock);
1863 if (pstrHostIFkeyAttr->action & ADDKEY) {
1864 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
1866 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1867 if (pu8keybuf == NULL) {
1868 PRINT_ER("No buffer to send RxGTK Key\n");
1870 goto _WPARxGtk_end_case_;
1873 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)
1874 memcpy(pu8keybuf, hif_drv->au8AssociatedBSSID, ETH_ALEN);
1876 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
1878 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1879 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1880 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1881 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1882 pstrHostIFkeyAttr->attr.wpa.key_len);
1884 strWID.id = (u16)WID_ADD_RX_GTK;
1885 strWID.type = WID_STR;
1886 strWID.val = (s8 *)pu8keybuf;
1887 strWID.size = RX_MIC_KEY_MSG_LEN;
1889 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1890 get_id_from_handler(hif_drv));
1893 up(&hif_drv->hSemTestKeyBlock);
1895 _WPARxGtk_end_case_:
1896 kfree(pstrHostIFkeyAttr->attr.wpa.key);
1897 kfree(pstrHostIFkeyAttr->attr.wpa.seq);
1904 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1907 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
1911 if (pu8keybuf == NULL) {
1912 PRINT_ER("No buffer to send PTK Key\n");
1914 goto _WPAPtk_end_case_;
1918 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1919 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1920 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1921 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->attr.wpa.key,
1922 pstrHostIFkeyAttr->attr.wpa.key_len);
1924 strWIDList[0].id = (u16)WID_11I_MODE;
1925 strWIDList[0].type = WID_CHAR;
1926 strWIDList[0].size = sizeof(char);
1927 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wpa.mode));
1929 strWIDList[1].id = (u16)WID_ADD_PTK;
1930 strWIDList[1].type = WID_STR;
1931 strWIDList[1].val = (s8 *)pu8keybuf;
1932 strWIDList[1].size = PTK_KEY_MSG_LEN + 1;
1934 s32Error = send_config_pkt(SET_CFG, strWIDList, 2,
1935 get_id_from_handler(hif_drv));
1937 up(&hif_drv->hSemTestKeyBlock);
1939 if (pstrHostIFkeyAttr->action & ADDKEY) {
1942 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
1946 if (pu8keybuf == NULL) {
1947 PRINT_ER("No buffer to send PTK Key\n");
1949 goto _WPAPtk_end_case_;
1953 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1954 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1955 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->attr.wpa.key,
1956 pstrHostIFkeyAttr->attr.wpa.key_len);
1958 strWID.id = (u16)WID_ADD_PTK;
1959 strWID.type = WID_STR;
1960 strWID.val = (s8 *)pu8keybuf;
1961 strWID.size = PTK_KEY_MSG_LEN;
1963 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1964 get_id_from_handler(hif_drv));
1966 up(&hif_drv->hSemTestKeyBlock);
1970 kfree(pstrHostIFkeyAttr->attr.wpa.key);
1979 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
1981 pu8keybuf = kmalloc((pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
1982 if (pu8keybuf == NULL) {
1983 PRINT_ER("No buffer to send PMKSA Key\n");
1987 pu8keybuf[0] = pstrHostIFkeyAttr->attr.pmkid.numpmkid;
1989 for (i = 0; i < pstrHostIFkeyAttr->attr.pmkid.numpmkid; i++) {
1990 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
1991 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
1994 strWID.id = (u16)WID_PMKID_INFO;
1995 strWID.type = WID_STR;
1996 strWID.val = (s8 *)pu8keybuf;
1997 strWID.size = (pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
1999 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2000 get_id_from_handler(hif_drv));
2007 PRINT_ER("Failed to send key config packet\n");
2013 static void Handle_Disconnect(struct host_if_drv *hif_drv)
2018 u16 u16DummyReasonCode = 0;
2020 strWID.id = (u16)WID_DISCONNECT;
2021 strWID.type = WID_CHAR;
2022 strWID.val = (s8 *)&u16DummyReasonCode;
2023 strWID.size = sizeof(char);
2027 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2029 g_obtainingIP = false;
2030 host_int_set_power_mgmt(hif_drv, 0, 0);
2032 eth_zero_addr(u8ConnectedSSID);
2034 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2035 get_id_from_handler(hif_drv));
2038 PRINT_ER("Failed to send dissconect config packet\n");
2040 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2042 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
2044 strDisconnectNotifInfo.u16reason = 0;
2045 strDisconnectNotifInfo.ie = NULL;
2046 strDisconnectNotifInfo.ie_len = 0;
2048 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
2049 del_timer(&hif_drv->hScanTimer);
2050 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
2051 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2053 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
2056 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2057 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2058 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
2059 del_timer(&hif_drv->hConnectTimer);
2062 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
2063 0, &strDisconnectNotifInfo, hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
2065 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
2068 gbScanWhileConnected = false;
2070 hif_drv->enuHostIFstate = HOST_IF_IDLE;
2072 eth_zero_addr(hif_drv->au8AssociatedBSSID);
2074 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
2075 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
2076 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
2077 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2078 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
2080 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
2081 kfree(gu8FlushedJoinReq);
2082 gu8FlushedJoinReq = NULL;
2084 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
2085 kfree(gu8FlushedInfoElemAsoc);
2086 gu8FlushedInfoElemAsoc = NULL;
2091 up(&hif_drv->hSemTestDisconnectBlock);
2095 void resolve_disconnect_aberration(struct host_if_drv *hif_drv)
2099 if ((hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (hif_drv->enuHostIFstate == HOST_IF_CONNECTING)) {
2100 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
2101 host_int_disconnect(hif_drv, 1);
2105 static s32 Handle_GetChnl(struct host_if_drv *hif_drv)
2111 strWID.id = (u16)WID_CURRENT_CHANNEL;
2112 strWID.type = WID_CHAR;
2113 strWID.val = (s8 *)&gu8Chnl;
2114 strWID.size = sizeof(char);
2116 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
2118 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2119 get_id_from_handler(hif_drv));
2122 PRINT_ER("Failed to get channel number\n");
2126 up(&hif_drv->hSemGetCHNL);
2134 static void Handle_GetRssi(struct host_if_drv *hif_drv)
2139 strWID.id = (u16)WID_RSSI;
2140 strWID.type = WID_CHAR;
2141 strWID.val = &gs8Rssi;
2142 strWID.size = sizeof(char);
2144 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
2146 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2147 get_id_from_handler(hif_drv));
2149 PRINT_ER("Failed to get RSSI value\n");
2153 up(&hif_drv->hSemGetRSSI);
2159 static void Handle_GetLinkspeed(struct host_if_drv *hif_drv)
2166 strWID.id = (u16)WID_LINKSPEED;
2167 strWID.type = WID_CHAR;
2168 strWID.val = &gs8lnkspd;
2169 strWID.size = sizeof(char);
2171 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
2173 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2174 get_id_from_handler(hif_drv));
2176 PRINT_ER("Failed to get LINKSPEED value\n");
2180 up(&(hif_drv->hSemGetLINKSPEED));
2185 s32 Handle_GetStatistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
2187 struct wid strWIDList[5];
2188 u32 u32WidsCount = 0, s32Error = 0;
2190 strWIDList[u32WidsCount].id = WID_LINKSPEED;
2191 strWIDList[u32WidsCount].type = WID_CHAR;
2192 strWIDList[u32WidsCount].size = sizeof(char);
2193 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u8LinkSpeed));
2196 strWIDList[u32WidsCount].id = WID_RSSI;
2197 strWIDList[u32WidsCount].type = WID_CHAR;
2198 strWIDList[u32WidsCount].size = sizeof(char);
2199 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->s8RSSI));
2202 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
2203 strWIDList[u32WidsCount].type = WID_INT;
2204 strWIDList[u32WidsCount].size = sizeof(u32);
2205 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32TxCount));
2208 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
2209 strWIDList[u32WidsCount].type = WID_INT;
2210 strWIDList[u32WidsCount].size = sizeof(u32);
2211 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32RxCount));
2214 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
2215 strWIDList[u32WidsCount].type = WID_INT;
2216 strWIDList[u32WidsCount].size = sizeof(u32);
2217 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32TxFailureCount));
2220 s32Error = send_config_pkt(GET_CFG, strWIDList, u32WidsCount,
2221 get_id_from_handler(hif_drv));
2224 PRINT_ER("Failed to send scan paramters config packet\n");
2231 static s32 Handle_Get_InActiveTime(struct host_if_drv *hif_drv,
2232 struct sta_inactive_t *strHostIfStaInactiveT)
2239 strWID.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
2240 strWID.type = WID_STR;
2241 strWID.size = ETH_ALEN;
2242 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2245 stamac = strWID.val;
2246 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
2249 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
2252 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2253 get_id_from_handler(hif_drv));
2256 PRINT_ER("Failed to SET incative time\n");
2261 strWID.id = (u16)WID_GET_INACTIVE_TIME;
2262 strWID.type = WID_INT;
2263 strWID.val = (s8 *)&gu32InactiveTime;
2264 strWID.size = sizeof(u32);
2267 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2268 get_id_from_handler(hif_drv));
2271 PRINT_ER("Failed to get incative time\n");
2276 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
2278 up(&hif_drv->hSemInactiveTime);
2286 static void Handle_AddBeacon(struct host_if_drv *hif_drv,
2287 struct beacon_attr *pstrSetBeaconParam)
2293 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
2295 strWID.id = (u16)WID_ADD_BEACON;
2296 strWID.type = WID_BIN;
2297 strWID.size = pstrSetBeaconParam->head_len + pstrSetBeaconParam->tail_len + 16;
2298 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2299 if (strWID.val == NULL)
2302 pu8CurrByte = strWID.val;
2303 *pu8CurrByte++ = (pstrSetBeaconParam->interval & 0xFF);
2304 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 8) & 0xFF);
2305 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 16) & 0xFF);
2306 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 24) & 0xFF);
2308 *pu8CurrByte++ = (pstrSetBeaconParam->dtim_period & 0xFF);
2309 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 8) & 0xFF);
2310 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 16) & 0xFF);
2311 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 24) & 0xFF);
2313 *pu8CurrByte++ = (pstrSetBeaconParam->head_len & 0xFF);
2314 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 8) & 0xFF);
2315 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 16) & 0xFF);
2316 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 24) & 0xFF);
2318 memcpy(pu8CurrByte, pstrSetBeaconParam->head, pstrSetBeaconParam->head_len);
2319 pu8CurrByte += pstrSetBeaconParam->head_len;
2321 *pu8CurrByte++ = (pstrSetBeaconParam->tail_len & 0xFF);
2322 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 8) & 0xFF);
2323 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 16) & 0xFF);
2324 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 24) & 0xFF);
2326 if (pstrSetBeaconParam->tail > 0)
2327 memcpy(pu8CurrByte, pstrSetBeaconParam->tail, pstrSetBeaconParam->tail_len);
2328 pu8CurrByte += pstrSetBeaconParam->tail_len;
2330 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2331 get_id_from_handler(hif_drv));
2333 PRINT_ER("Failed to send add beacon config packet\n");
2337 kfree(pstrSetBeaconParam->head);
2338 kfree(pstrSetBeaconParam->tail);
2341 static void Handle_DelBeacon(struct host_if_drv *hif_drv)
2347 strWID.id = (u16)WID_DEL_BEACON;
2348 strWID.type = WID_CHAR;
2349 strWID.size = sizeof(char);
2350 strWID.val = &gu8DelBcn;
2352 if (strWID.val == NULL)
2355 pu8CurrByte = strWID.val;
2357 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
2359 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2360 get_id_from_handler(hif_drv));
2362 PRINT_ER("Failed to send delete beacon config packet\n");
2365 static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
2366 struct add_sta_param *pstrStationParam)
2370 pu8CurrByte = pu8Buffer;
2372 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
2373 memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
2374 pu8CurrByte += ETH_ALEN;
2376 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
2377 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
2379 *pu8CurrByte++ = pstrStationParam->u8NumRates;
2380 if (pstrStationParam->u8NumRates > 0)
2381 memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
2382 pu8CurrByte += pstrStationParam->u8NumRates;
2384 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
2385 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
2386 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
2388 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
2389 memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
2390 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
2392 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
2393 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
2395 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
2396 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
2397 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
2398 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
2400 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
2402 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
2403 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
2405 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
2406 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
2408 return pu8CurrByte - pu8Buffer;
2411 static void Handle_AddStation(struct host_if_drv *hif_drv,
2412 struct add_sta_param *pstrStationParam)
2418 PRINT_D(HOSTINF_DBG, "Handling add station\n");
2419 strWID.id = (u16)WID_ADD_STA;
2420 strWID.type = WID_BIN;
2421 strWID.size = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
2423 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2424 if (strWID.val == NULL)
2427 pu8CurrByte = strWID.val;
2428 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2430 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2431 get_id_from_handler(hif_drv));
2433 PRINT_ER("Failed to send add station config packet\n");
2436 kfree(pstrStationParam->pu8Rates);
2440 static void Handle_DelAllSta(struct host_if_drv *hif_drv,
2441 struct del_all_sta *pstrDelAllStaParam)
2448 u8 au8Zero_Buff[6] = {0};
2450 strWID.id = (u16)WID_DEL_ALL_STA;
2451 strWID.type = WID_STR;
2452 strWID.size = (pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1;
2454 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
2456 strWID.val = kmalloc((pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1, GFP_KERNEL);
2457 if (strWID.val == NULL)
2460 pu8CurrByte = strWID.val;
2462 *(pu8CurrByte++) = pstrDelAllStaParam->assoc_sta;
2464 for (i = 0; i < MAX_NUM_STA; i++) {
2465 if (memcmp(pstrDelAllStaParam->del_all_sta[i], au8Zero_Buff, ETH_ALEN))
2466 memcpy(pu8CurrByte, pstrDelAllStaParam->del_all_sta[i], ETH_ALEN);
2470 pu8CurrByte += ETH_ALEN;
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");
2484 static void Handle_DelStation(struct host_if_drv *hif_drv,
2485 struct del_sta *pstrDelStaParam)
2491 strWID.id = (u16)WID_REMOVE_STA;
2492 strWID.type = WID_BIN;
2493 strWID.size = ETH_ALEN;
2495 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
2497 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2498 if (strWID.val == NULL)
2501 pu8CurrByte = strWID.val;
2503 memcpy(pu8CurrByte, pstrDelStaParam->mac_addr, ETH_ALEN);
2505 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2506 get_id_from_handler(hif_drv));
2508 PRINT_ER("Failed to send add station config packet\n");
2514 static void Handle_EditStation(struct host_if_drv *hif_drv,
2515 struct add_sta_param *pstrStationParam)
2521 strWID.id = (u16)WID_EDIT_STA;
2522 strWID.type = WID_BIN;
2523 strWID.size = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
2525 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
2526 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2527 if (strWID.val == NULL)
2530 pu8CurrByte = strWID.val;
2531 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2533 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2534 get_id_from_handler(hif_drv));
2536 PRINT_ER("Failed to send edit station config packet\n");
2539 kfree(pstrStationParam->pu8Rates);
2543 static int Handle_RemainOnChan(struct host_if_drv *hif_drv,
2544 struct remain_ch *pstrHostIfRemainOnChan)
2547 u8 u8remain_on_chan_flag;
2550 if (!hif_drv->u8RemainOnChan_pendingreq) {
2551 hif_drv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
2552 hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
2553 hif_drv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
2554 hif_drv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
2555 hif_drv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
2557 pstrHostIfRemainOnChan->u16Channel = hif_drv->strHostIfRemainOnChan.u16Channel;
2560 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
2561 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
2562 hif_drv->u8RemainOnChan_pendingreq = 1;
2566 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2567 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
2572 if (g_obtainingIP || connecting) {
2573 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
2578 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
2580 u8remain_on_chan_flag = true;
2581 strWID.id = (u16)WID_REMAIN_ON_CHAN;
2582 strWID.type = WID_STR;
2584 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2586 if (strWID.val == NULL) {
2591 strWID.val[0] = u8remain_on_chan_flag;
2592 strWID.val[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
2594 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2595 get_id_from_handler(hif_drv));
2597 PRINT_ER("Failed to set remain on channel\n");
2601 P2P_LISTEN_STATE = 1;
2602 hif_drv->hRemainOnChannel.data = (unsigned long)hif_drv;
2603 mod_timer(&hif_drv->hRemainOnChannel,
2605 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
2607 if (hif_drv->strHostIfRemainOnChan.pRemainOnChanReady)
2608 hif_drv->strHostIfRemainOnChan.pRemainOnChanReady(hif_drv->strHostIfRemainOnChan.pVoid);
2610 if (hif_drv->u8RemainOnChan_pendingreq)
2611 hif_drv->u8RemainOnChan_pendingreq = 0;
2616 static int Handle_RegisterFrame(struct host_if_drv *hif_drv,
2617 struct reg_frame *pstrHostIfRegisterFrame)
2623 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
2625 strWID.id = (u16)WID_REGISTER_FRAME;
2626 strWID.type = WID_STR;
2627 strWID.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
2628 if (strWID.val == NULL)
2631 pu8CurrByte = strWID.val;
2633 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
2634 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
2635 memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
2638 strWID.size = sizeof(u16) + 2;
2640 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2641 get_id_from_handler(hif_drv));
2643 PRINT_ER("Failed to frame register config packet\n");
2651 #define FALSE_FRMWR_CHANNEL 100
2652 static u32 Handle_ListenStateExpired(struct host_if_drv *hif_drv,
2653 struct remain_ch *pstrHostIfRemainOnChan)
2655 u8 u8remain_on_chan_flag;
2659 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
2661 if (P2P_LISTEN_STATE) {
2662 u8remain_on_chan_flag = false;
2663 strWID.id = (u16)WID_REMAIN_ON_CHAN;
2664 strWID.type = WID_STR;
2666 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2668 if (strWID.val == NULL)
2669 PRINT_ER("Failed to allocate memory\n");
2671 strWID.val[0] = u8remain_on_chan_flag;
2672 strWID.val[1] = FALSE_FRMWR_CHANNEL;
2674 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2675 get_id_from_handler(hif_drv));
2676 if (s32Error != 0) {
2677 PRINT_ER("Failed to set remain on channel\n");
2681 if (hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired) {
2682 hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired(hif_drv->strHostIfRemainOnChan.pVoid
2683 , pstrHostIfRemainOnChan->u32ListenSessionID);
2685 P2P_LISTEN_STATE = 0;
2687 PRINT_D(GENERIC_DBG, "Not in listen state\n");
2695 static void ListenTimerCB(unsigned long arg)
2698 struct host_if_msg msg;
2699 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
2701 del_timer(&hif_drv->hRemainOnChannel);
2703 memset(&msg, 0, sizeof(struct host_if_msg));
2704 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
2706 msg.body.remain_on_ch.u32ListenSessionID = hif_drv->strHostIfRemainOnChan.u32ListenSessionID;
2708 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2710 PRINT_ER("wilc_mq_send fail\n");
2713 static void Handle_PowerManagement(struct host_if_drv *hif_drv,
2714 struct power_mgmt_param *strPowerMgmtParam)
2720 strWID.id = (u16)WID_POWER_MANAGEMENT;
2722 if (strPowerMgmtParam->enabled == true)
2723 s8PowerMode = MIN_FAST_PS;
2725 s8PowerMode = NO_POWERSAVE;
2726 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
2727 strWID.val = &s8PowerMode;
2728 strWID.size = sizeof(char);
2730 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
2732 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2733 get_id_from_handler(hif_drv));
2735 PRINT_ER("Failed to send power management config packet\n");
2738 static void Handle_SetMulticastFilter(struct host_if_drv *hif_drv,
2739 struct set_multicast *strHostIfSetMulti)
2745 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
2747 strWID.id = (u16)WID_SETUP_MULTICAST_FILTER;
2748 strWID.type = WID_BIN;
2749 strWID.size = sizeof(struct set_multicast) + ((strHostIfSetMulti->cnt) * ETH_ALEN);
2750 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2751 if (strWID.val == NULL)
2754 pu8CurrByte = strWID.val;
2755 *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF);
2756 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 8) & 0xFF);
2757 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 16) & 0xFF);
2758 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 24) & 0xFF);
2760 *pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF);
2761 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF);
2762 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 16) & 0xFF);
2763 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 24) & 0xFF);
2765 if ((strHostIfSetMulti->cnt) > 0)
2766 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->cnt) * ETH_ALEN));
2768 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2769 get_id_from_handler(hif_drv));
2771 PRINT_ER("Failed to send setup multicast config packet\n");
2778 static s32 Handle_AddBASession(struct host_if_drv *hif_drv,
2779 struct ba_session_info *strHostIfBASessionInfo)
2783 int AddbaTimeout = 100;
2786 PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\nBufferSize == %d\nSessionTimeOut = %d\n",
2787 strHostIfBASessionInfo->au8Bssid[0],
2788 strHostIfBASessionInfo->au8Bssid[1],
2789 strHostIfBASessionInfo->au8Bssid[2],
2790 strHostIfBASessionInfo->u16BufferSize,
2791 strHostIfBASessionInfo->u16SessionTimeout,
2792 strHostIfBASessionInfo->u8Ted);
2794 strWID.id = (u16)WID_11E_P_ACTION_REQ;
2795 strWID.type = WID_STR;
2796 strWID.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2797 strWID.size = BLOCK_ACK_REQ_SIZE;
2802 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2804 *ptr++ = strHostIfBASessionInfo->u8Ted;
2806 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
2807 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
2808 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
2809 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
2810 *ptr++ = (AddbaTimeout & 0xFF);
2811 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
2815 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2816 get_id_from_handler(hif_drv));
2818 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
2821 strWID.id = (u16)WID_11E_P_ACTION_REQ;
2822 strWID.type = WID_STR;
2828 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2830 *ptr++ = strHostIfBASessionInfo->u8Ted;
2832 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
2833 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
2835 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2836 get_id_from_handler(hif_drv));
2844 static s32 Handle_DelAllRxBASessions(struct host_if_drv *hif_drv,
2845 struct ba_session_info *strHostIfBASessionInfo)
2851 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
2852 strHostIfBASessionInfo->au8Bssid[0],
2853 strHostIfBASessionInfo->au8Bssid[1],
2854 strHostIfBASessionInfo->au8Bssid[2],
2855 strHostIfBASessionInfo->u8Ted);
2857 strWID.id = (u16)WID_DEL_ALL_RX_BA;
2858 strWID.type = WID_STR;
2859 strWID.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2860 strWID.size = BLOCK_ACK_REQ_SIZE;
2865 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2867 *ptr++ = strHostIfBASessionInfo->u8Ted;
2871 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2872 get_id_from_handler(hif_drv));
2874 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
2885 static int hostIFthread(void *pvArg)
2888 struct host_if_msg msg;
2889 struct host_if_drv *hif_drv;
2891 memset(&msg, 0, sizeof(struct host_if_msg));
2894 wilc_mq_recv(&hif_msg_q, &msg, sizeof(struct host_if_msg), &u32Ret);
2895 hif_drv = (struct host_if_drv *)msg.drv;
2896 if (msg.id == HOST_IF_MSG_EXIT) {
2897 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
2901 if ((!g_wilc_initialized)) {
2902 PRINT_D(GENERIC_DBG, "--WAIT--");
2903 usleep_range(200 * 1000, 200 * 1000);
2904 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2908 if (msg.id == HOST_IF_MSG_CONNECT && hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
2909 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
2910 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2911 usleep_range(2 * 1000, 2 * 1000);
2916 case HOST_IF_MSG_Q_IDLE:
2917 Handle_wait_msg_q_empty();
2920 case HOST_IF_MSG_SCAN:
2921 Handle_Scan(msg.drv, &msg.body.scan_info);
2924 case HOST_IF_MSG_CONNECT:
2925 Handle_Connect(msg.drv, &msg.body.con_info);
2928 case HOST_IF_MSG_FLUSH_CONNECT:
2929 Handle_FlushConnect(msg.drv);
2932 case HOST_IF_MSG_RCVD_NTWRK_INFO:
2933 Handle_RcvdNtwrkInfo(msg.drv, &msg.body.net_info);
2936 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
2937 Handle_RcvdGnrlAsyncInfo(msg.drv, &msg.body.async_info);
2940 case HOST_IF_MSG_KEY:
2941 Handle_Key(msg.drv, &msg.body.key_info);
2944 case HOST_IF_MSG_CFG_PARAMS:
2946 Handle_CfgParam(msg.drv, &msg.body.cfg_info);
2949 case HOST_IF_MSG_SET_CHANNEL:
2950 Handle_SetChannel(msg.drv, &msg.body.channel_info);
2953 case HOST_IF_MSG_DISCONNECT:
2954 Handle_Disconnect(msg.drv);
2957 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
2958 del_timer(&hif_drv->hScanTimer);
2959 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
2961 if (!linux_wlan_get_num_conn_ifcs())
2962 chip_sleep_manually(INFINITE_SLEEP_TIME);
2964 Handle_ScanDone(msg.drv, SCAN_EVENT_DONE);
2966 if (hif_drv->u8RemainOnChan_pendingreq)
2967 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
2971 case HOST_IF_MSG_GET_RSSI:
2972 Handle_GetRssi(msg.drv);
2975 case HOST_IF_MSG_GET_LINKSPEED:
2976 Handle_GetLinkspeed(msg.drv);
2979 case HOST_IF_MSG_GET_STATISTICS:
2980 Handle_GetStatistics(msg.drv, (struct rf_info *)msg.body.data);
2983 case HOST_IF_MSG_GET_CHNL:
2984 Handle_GetChnl(msg.drv);
2987 case HOST_IF_MSG_ADD_BEACON:
2988 Handle_AddBeacon(msg.drv, &msg.body.beacon_info);
2991 case HOST_IF_MSG_DEL_BEACON:
2992 Handle_DelBeacon(msg.drv);
2995 case HOST_IF_MSG_ADD_STATION:
2996 Handle_AddStation(msg.drv, &msg.body.add_sta_info);
2999 case HOST_IF_MSG_DEL_STATION:
3000 Handle_DelStation(msg.drv, &msg.body.del_sta_info);
3003 case HOST_IF_MSG_EDIT_STATION:
3004 Handle_EditStation(msg.drv, &msg.body.edit_sta_info);
3007 case HOST_IF_MSG_GET_INACTIVETIME:
3008 Handle_Get_InActiveTime(msg.drv, &msg.body.mac_info);
3011 case HOST_IF_MSG_SCAN_TIMER_FIRED:
3012 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
3014 Handle_ScanDone(msg.drv, SCAN_EVENT_ABORTED);
3017 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
3018 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
3019 Handle_ConnectTimeout(msg.drv);
3022 case HOST_IF_MSG_POWER_MGMT:
3023 Handle_PowerManagement(msg.drv, &msg.body.pwr_mgmt_info);
3026 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
3027 Handle_SetWfiDrvHandler(msg.drv,
3031 case HOST_IF_MSG_SET_OPERATION_MODE:
3032 Handle_SetOperationMode(msg.drv, &msg.body.mode);
3035 case HOST_IF_MSG_SET_IPADDRESS:
3036 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
3037 Handle_set_IPAddress(msg.drv, msg.body.ip_info.ip_addr, msg.body.ip_info.idx);
3040 case HOST_IF_MSG_GET_IPADDRESS:
3041 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
3042 Handle_get_IPAddress(msg.drv, msg.body.ip_info.ip_addr, msg.body.ip_info.idx);
3045 case HOST_IF_MSG_SET_MAC_ADDRESS:
3046 Handle_SetMacAddress(msg.drv, &msg.body.set_mac_info);
3049 case HOST_IF_MSG_GET_MAC_ADDRESS:
3050 Handle_GetMacAddress(msg.drv, &msg.body.get_mac_info);
3053 case HOST_IF_MSG_REMAIN_ON_CHAN:
3054 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
3055 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
3058 case HOST_IF_MSG_REGISTER_FRAME:
3059 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
3060 Handle_RegisterFrame(msg.drv, &msg.body.reg_frame);
3063 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
3064 Handle_ListenStateExpired(msg.drv, &msg.body.remain_on_ch);
3067 case HOST_IF_MSG_SET_MULTICAST_FILTER:
3068 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
3069 Handle_SetMulticastFilter(msg.drv, &msg.body.multicast_info);
3072 case HOST_IF_MSG_ADD_BA_SESSION:
3073 Handle_AddBASession(msg.drv, &msg.body.session_info);
3076 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
3077 Handle_DelAllRxBASessions(msg.drv, &msg.body.session_info);
3080 case HOST_IF_MSG_DEL_ALL_STA:
3081 Handle_DelAllSta(msg.drv, &msg.body.del_all_sta_info);
3085 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
3090 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
3091 up(&hif_sema_thread);
3095 static void TimerCB_Scan(unsigned long arg)
3097 void *pvArg = (void *)arg;
3098 struct host_if_msg msg;
3100 memset(&msg, 0, sizeof(struct host_if_msg));
3102 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
3104 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3107 static void TimerCB_Connect(unsigned long arg)
3109 void *pvArg = (void *)arg;
3110 struct host_if_msg msg;
3112 memset(&msg, 0, sizeof(struct host_if_msg));
3114 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
3116 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3119 s32 host_int_remove_key(struct host_if_drv *hif_drv, const u8 *pu8StaAddress)
3123 strWID.id = (u16)WID_REMOVE_KEY;
3124 strWID.type = WID_STR;
3125 strWID.val = (s8 *)pu8StaAddress;
3131 int host_int_remove_wep_key(struct host_if_drv *hif_drv, u8 index)
3134 struct host_if_msg msg;
3138 PRINT_ER("Failed to send setup multicast config packet\n");
3142 memset(&msg, 0, sizeof(struct host_if_msg));
3144 msg.id = HOST_IF_MSG_KEY;
3145 msg.body.key_info.type = WEP;
3146 msg.body.key_info.action = REMOVEKEY;
3148 msg.body.key_info.attr.wep.index = index;
3150 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3152 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
3153 down(&hif_drv->hSemTestKeyBlock);
3158 s32 host_int_set_WEPDefaultKeyID(struct host_if_drv *hif_drv, u8 u8Index)
3161 struct host_if_msg msg;
3166 PRINT_ER("driver is null\n");
3170 memset(&msg, 0, sizeof(struct host_if_msg));
3173 msg.id = HOST_IF_MSG_KEY;
3174 msg.body.key_info.type = WEP;
3175 msg.body.key_info.action = DEFAULTKEY;
3177 msg.body.key_info.attr.wep.index = u8Index;
3179 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3181 PRINT_ER("Error in sending message queue : Default key index\n");
3182 down(&hif_drv->hSemTestKeyBlock);
3187 s32 host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv,
3188 const u8 *pu8WepKey,
3194 struct host_if_msg msg;
3198 PRINT_ER("driver is null\n");
3202 memset(&msg, 0, sizeof(struct host_if_msg));
3205 msg.id = HOST_IF_MSG_KEY;
3206 msg.body.key_info.type = WEP;
3207 msg.body.key_info.action = ADDKEY;
3209 msg.body.key_info.attr.wep.key = kmalloc(u8WepKeylen, GFP_KERNEL);
3210 memcpy(msg.body.key_info.attr.wep.key, pu8WepKey, u8WepKeylen);
3211 msg.body.key_info.attr.wep.key_len = (u8WepKeylen);
3212 msg.body.key_info.attr.wep.index = u8Keyidx;
3214 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3216 PRINT_ER("Error in sending message queue :WEP Key\n");
3217 down(&hif_drv->hSemTestKeyBlock);
3223 s32 host_int_add_wep_key_bss_ap(struct host_if_drv *hif_drv,
3224 const u8 *pu8WepKey,
3228 enum AUTHTYPE tenuAuth_type)
3232 struct host_if_msg msg;
3237 PRINT_ER("driver is null\n");
3241 memset(&msg, 0, sizeof(struct host_if_msg));
3244 for (i = 0; i < u8WepKeylen; i++)
3245 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
3247 msg.id = HOST_IF_MSG_KEY;
3248 msg.body.key_info.type = WEP;
3249 msg.body.key_info.action = ADDKEY_AP;
3251 msg.body.key_info.attr.wep.key = kmalloc(u8WepKeylen, GFP_KERNEL);
3252 memcpy(msg.body.key_info.attr.wep.key, pu8WepKey, (u8WepKeylen));
3253 msg.body.key_info.attr.wep.key_len = (u8WepKeylen);
3254 msg.body.key_info.attr.wep.index = u8Keyidx;
3255 msg.body.key_info.attr.wep.mode = u8mode;
3256 msg.body.key_info.attr.wep.auth_type = tenuAuth_type;
3258 s32Error = wilc_mq_send(&hif_msg_q, &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_ptk(struct host_if_drv *hif_drv, const u8 *pu8Ptk,
3269 u8 u8PtkKeylen, const u8 *mac_addr,
3270 const u8 *pu8RxMic, const u8 *pu8TxMic,
3271 u8 mode, u8 u8Ciphermode, u8 u8Idx)
3274 struct host_if_msg msg;
3275 u8 u8KeyLen = u8PtkKeylen;
3280 PRINT_ER("driver is null\n");
3283 if (pu8RxMic != NULL)
3284 u8KeyLen += RX_MIC_KEY_LEN;
3285 if (pu8TxMic != NULL)
3286 u8KeyLen += TX_MIC_KEY_LEN;
3288 memset(&msg, 0, sizeof(struct host_if_msg));
3291 msg.id = HOST_IF_MSG_KEY;
3292 msg.body.key_info.type = WPAPtk;
3293 if (mode == AP_MODE) {
3294 msg.body.key_info.action = ADDKEY_AP;
3295 msg.body.key_info.attr.wpa.index = u8Idx;
3297 if (mode == STATION_MODE)
3298 msg.body.key_info.action = ADDKEY;
3300 msg.body.key_info.attr.wpa.key = kmalloc(u8PtkKeylen, GFP_KERNEL);
3301 memcpy(msg.body.key_info.attr.wpa.key, pu8Ptk, u8PtkKeylen);
3303 if (pu8RxMic != NULL) {
3304 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic, RX_MIC_KEY_LEN);
3306 for (i = 0; i < RX_MIC_KEY_LEN; i++)
3307 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
3310 if (pu8TxMic != NULL) {
3311 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic, TX_MIC_KEY_LEN);
3313 for (i = 0; i < TX_MIC_KEY_LEN; i++)
3314 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
3318 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
3319 msg.body.key_info.attr.wpa.mac_addr = mac_addr;
3320 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
3323 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3326 PRINT_ER("Error in sending message queue: PTK Key\n");
3328 down(&hif_drv->hSemTestKeyBlock);
3333 s32 host_int_add_rx_gtk(struct host_if_drv *hif_drv, const u8 *pu8RxGtk,
3334 u8 u8GtkKeylen, u8 u8KeyIdx,
3335 u32 u32KeyRSClen, const u8 *KeyRSC,
3336 const u8 *pu8RxMic, const u8 *pu8TxMic,
3337 u8 mode, u8 u8Ciphermode)
3340 struct host_if_msg msg;
3341 u8 u8KeyLen = u8GtkKeylen;
3345 PRINT_ER("driver is null\n");
3348 memset(&msg, 0, sizeof(struct host_if_msg));
3351 if (pu8RxMic != NULL)
3352 u8KeyLen += RX_MIC_KEY_LEN;
3353 if (pu8TxMic != NULL)
3354 u8KeyLen += TX_MIC_KEY_LEN;
3355 if (KeyRSC != NULL) {
3356 msg.body.key_info.attr.wpa.seq = kmalloc(u32KeyRSClen, GFP_KERNEL);
3357 memcpy(msg.body.key_info.attr.wpa.seq, KeyRSC, u32KeyRSClen);
3361 msg.id = HOST_IF_MSG_KEY;
3362 msg.body.key_info.type = WPARxGtk;
3365 if (mode == AP_MODE) {
3366 msg.body.key_info.action = ADDKEY_AP;
3367 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
3369 if (mode == STATION_MODE)
3370 msg.body.key_info.action = ADDKEY;
3372 msg.body.key_info.attr.wpa.key = kmalloc(u8KeyLen, GFP_KERNEL);
3373 memcpy(msg.body.key_info.attr.wpa.key, pu8RxGtk, u8GtkKeylen);
3375 if (pu8RxMic != NULL) {
3376 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic, RX_MIC_KEY_LEN);
3378 if (pu8TxMic != NULL) {
3379 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic, TX_MIC_KEY_LEN);
3382 msg.body.key_info.attr.wpa.index = u8KeyIdx;
3383 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
3384 msg.body.key_info.attr.wpa.seq_len = u32KeyRSClen;
3386 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3388 PRINT_ER("Error in sending message queue: RX GTK\n");
3390 down(&hif_drv->hSemTestKeyBlock);
3395 s32 host_int_set_pmkid_info(struct host_if_drv *hif_drv, struct host_if_pmkid_attr *pu8PmkidInfoArray)
3398 struct host_if_msg msg;
3404 PRINT_ER("driver is null\n");
3408 memset(&msg, 0, sizeof(struct host_if_msg));
3410 msg.id = HOST_IF_MSG_KEY;
3411 msg.body.key_info.type = PMKSA;
3412 msg.body.key_info.action = ADDKEY;
3415 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
3416 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
3418 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
3422 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3424 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
3429 s32 host_int_get_pmkid_info(struct host_if_drv *hif_drv,
3430 u8 *pu8PmkidInfoArray,
3431 u32 u32PmkidInfoLen)
3435 strWID.id = (u16)WID_PMKID_INFO;
3436 strWID.type = WID_STR;
3437 strWID.size = u32PmkidInfoLen;
3438 strWID.val = pu8PmkidInfoArray;
3443 s32 host_int_set_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3449 if ((u8Psklength > 7) && (u8Psklength < 65)) {
3450 strWID.id = (u16)WID_11I_PSK;
3451 strWID.type = WID_STR;
3452 strWID.val = pu8PassPhrase;
3453 strWID.size = u8Psklength;
3459 s32 host_int_get_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
3462 struct host_if_msg msg;
3464 memset(&msg, 0, sizeof(struct host_if_msg));
3466 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
3467 msg.body.get_mac_info.u8MacAddress = pu8MacAddress;
3470 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3472 PRINT_ER("Failed to send get mac address\n");
3476 down(&hWaitResponse);
3480 s32 host_int_set_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
3483 struct host_if_msg msg;
3485 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
3487 memset(&msg, 0, sizeof(struct host_if_msg));
3488 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
3489 memcpy(msg.body.set_mac_info.u8MacAddress, pu8MacAddress, ETH_ALEN);
3492 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3494 PRINT_ER("Failed to send message queue: Set mac address\n");
3500 s32 host_int_get_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3501 u8 *pu8PassPhrase, u8 u8Psklength)
3505 strWID.id = (u16)WID_11I_PSK;
3506 strWID.type = WID_STR;
3507 strWID.size = u8Psklength;
3508 strWID.val = pu8PassPhrase;
3513 s32 host_int_set_start_scan_req(struct host_if_drv *hif_drv, u8 scanSource)
3517 strWID.id = (u16)WID_START_SCAN_REQ;
3518 strWID.type = WID_CHAR;
3519 strWID.val = (s8 *)&scanSource;
3520 strWID.size = sizeof(char);
3525 s32 host_int_get_start_scan_req(struct host_if_drv *hif_drv, u8 *pu8ScanSource)
3529 strWID.id = (u16)WID_START_SCAN_REQ;
3530 strWID.type = WID_CHAR;
3531 strWID.val = (s8 *)pu8ScanSource;
3532 strWID.size = sizeof(char);
3537 s32 host_int_set_join_req(struct host_if_drv *hif_drv, u8 *pu8bssid,
3538 const u8 *pu8ssid, size_t ssidLen,
3539 const u8 *pu8IEs, size_t IEsLen,
3540 wilc_connect_result pfConnectResult, void *pvUserArg,
3541 u8 u8security, enum AUTHTYPE tenuAuth_type,
3542 u8 u8channel, void *pJoinParams)
3545 struct host_if_msg msg;
3547 if (!hif_drv || pfConnectResult == NULL) {
3549 PRINT_ER("Driver is null\n");
3553 if (pJoinParams == NULL) {
3554 PRINT_ER("Unable to Join - JoinParams is NULL\n");
3558 memset(&msg, 0, sizeof(struct host_if_msg));
3560 msg.id = HOST_IF_MSG_CONNECT;
3562 msg.body.con_info.security = u8security;
3563 msg.body.con_info.auth_type = tenuAuth_type;
3564 msg.body.con_info.ch = u8channel;
3565 msg.body.con_info.result = pfConnectResult;
3566 msg.body.con_info.arg = pvUserArg;
3567 msg.body.con_info.params = pJoinParams;
3570 if (pu8bssid != NULL) {
3571 msg.body.con_info.bssid = kmalloc(6, GFP_KERNEL);
3572 memcpy(msg.body.con_info.bssid, pu8bssid, 6);
3575 if (pu8ssid != NULL) {
3576 msg.body.con_info.ssid_len = ssidLen;
3577 msg.body.con_info.ssid = kmalloc(ssidLen, GFP_KERNEL);
3578 memcpy(msg.body.con_info.ssid, pu8ssid, ssidLen);
3581 if (pu8IEs != NULL) {
3582 msg.body.con_info.ies_len = IEsLen;
3583 msg.body.con_info.ies = kmalloc(IEsLen, GFP_KERNEL);
3584 memcpy(msg.body.con_info.ies, pu8IEs, IEsLen);
3586 if (hif_drv->enuHostIFstate < HOST_IF_CONNECTING)
3587 hif_drv->enuHostIFstate = HOST_IF_CONNECTING;
3589 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", hif_drv->enuHostIFstate);
3591 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3593 PRINT_ER("Failed to send message queue: Set join request\n");
3597 hif_drv->hConnectTimer.data = (unsigned long)hif_drv;
3598 mod_timer(&hif_drv->hConnectTimer,
3599 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
3604 s32 host_int_flush_join_req(struct host_if_drv *hif_drv)
3607 struct host_if_msg msg;
3609 if (!gu8FlushedJoinReq) {
3617 PRINT_ER("Driver is null\n");
3621 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
3624 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3626 PRINT_ER("Failed to send message queue: Flush join request\n");
3633 s32 host_int_disconnect(struct host_if_drv *hif_drv, u16 u16ReasonCode)
3636 struct host_if_msg msg;
3639 PRINT_ER("Driver is null\n");
3643 memset(&msg, 0, sizeof(struct host_if_msg));
3645 msg.id = HOST_IF_MSG_DISCONNECT;
3648 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3650 PRINT_ER("Failed to send message queue: disconnect\n");
3652 down(&hif_drv->hSemTestDisconnectBlock);
3657 s32 host_int_disconnect_station(struct host_if_drv *hif_drv, u8 assoc_id)
3661 strWID.id = (u16)WID_DISCONNECT;
3662 strWID.type = WID_CHAR;
3663 strWID.val = (s8 *)&assoc_id;
3664 strWID.size = sizeof(char);
3669 s32 host_int_get_assoc_req_info(struct host_if_drv *hif_drv, u8 *pu8AssocReqInfo,
3670 u32 u32AssocReqInfoLen)
3674 strWID.id = (u16)WID_ASSOC_REQ_INFO;
3675 strWID.type = WID_STR;
3676 strWID.val = pu8AssocReqInfo;
3677 strWID.size = u32AssocReqInfoLen;
3682 s32 host_int_get_assoc_res_info(struct host_if_drv *hif_drv, u8 *pu8AssocRespInfo,
3683 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
3689 PRINT_ER("Driver is null\n");
3693 strWID.id = (u16)WID_ASSOC_RES_INFO;
3694 strWID.type = WID_STR;
3695 strWID.val = pu8AssocRespInfo;
3696 strWID.size = u32MaxAssocRespInfoLen;
3698 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
3699 get_id_from_handler(hif_drv));
3701 *pu32RcvdAssocRespInfoLen = 0;
3702 PRINT_ER("Failed to send association response config packet\n");
3705 *pu32RcvdAssocRespInfoLen = strWID.size;
3711 s32 host_int_get_rx_power_level(struct host_if_drv *hif_drv, u8 *pu8RxPowerLevel,
3712 u32 u32RxPowerLevelLen)
3716 strWID.id = (u16)WID_RX_POWER_LEVEL;
3717 strWID.type = WID_STR;
3718 strWID.val = pu8RxPowerLevel;
3719 strWID.size = u32RxPowerLevelLen;
3724 int host_int_set_mac_chnl_num(struct host_if_drv *hif_drv, u8 channel)
3727 struct host_if_msg msg;
3730 PRINT_ER("driver is null\n");
3734 memset(&msg, 0, sizeof(struct host_if_msg));
3735 msg.id = HOST_IF_MSG_SET_CHANNEL;
3736 msg.body.channel_info.set_ch = channel;
3739 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3741 PRINT_ER("wilc mq send fail\n");
3748 int host_int_wait_msg_queue_idle(void)
3752 struct host_if_msg msg;
3753 memset(&msg, 0, sizeof(struct host_if_msg));
3754 msg.id = HOST_IF_MSG_Q_IDLE;
3755 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3757 PRINT_ER("wilc mq send fail\n");
3761 down(&hWaitResponse);
3766 int host_int_set_wfi_drv_handler(struct host_if_drv *hif_drv)
3770 struct host_if_msg msg;
3771 memset(&msg, 0, sizeof(struct host_if_msg));
3772 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
3773 msg.body.drv.u32Address = get_id_from_handler(hif_drv);
3776 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3778 PRINT_ER("wilc mq send fail\n");
3785 int host_int_set_operation_mode(struct host_if_drv *hif_drv, u32 mode)
3789 struct host_if_msg msg;
3790 memset(&msg, 0, sizeof(struct host_if_msg));
3791 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
3792 msg.body.mode.u32Mode = mode;
3795 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3797 PRINT_ER("wilc mq send fail\n");
3804 s32 host_int_get_host_chnl_num(struct host_if_drv *hif_drv, u8 *pu8ChNo)
3807 struct host_if_msg msg;
3810 PRINT_ER("driver is null\n");
3814 memset(&msg, 0, sizeof(struct host_if_msg));
3816 msg.id = HOST_IF_MSG_GET_CHNL;
3819 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3821 PRINT_ER("wilc mq send fail\n");
3822 down(&hif_drv->hSemGetCHNL);
3831 s32 host_int_get_inactive_time(struct host_if_drv *hif_drv,
3832 const u8 *mac, u32 *pu32InactiveTime)
3835 struct host_if_msg msg;
3838 PRINT_ER("driver is null\n");
3842 memset(&msg, 0, sizeof(struct host_if_msg));
3845 memcpy(msg.body.mac_info.mac,
3848 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
3851 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3853 PRINT_ER("Failed to send get host channel param's message queue ");
3855 down(&hif_drv->hSemInactiveTime);
3857 *pu32InactiveTime = gu32InactiveTime;
3862 s32 host_int_test_get_int_wid(struct host_if_drv *hif_drv, u32 *pu32TestMemAddr)
3869 PRINT_ER("driver is null\n");
3873 strWID.id = (u16)WID_MEMORY_ADDRESS;
3874 strWID.type = WID_INT;
3875 strWID.val = (s8 *)pu32TestMemAddr;
3876 strWID.size = sizeof(u32);
3878 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
3879 get_id_from_handler(hif_drv));
3882 PRINT_ER("Failed to get wid value\n");
3885 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
3892 s32 host_int_get_rssi(struct host_if_drv *hif_drv, s8 *ps8Rssi)
3895 struct host_if_msg msg;
3896 memset(&msg, 0, sizeof(struct host_if_msg));
3898 msg.id = HOST_IF_MSG_GET_RSSI;
3901 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3903 PRINT_ER("Failed to send get host channel param's message queue ");
3907 down(&hif_drv->hSemGetRSSI);
3910 if (ps8Rssi == NULL) {
3911 PRINT_ER("RSS pointer value is null");
3922 s32 host_int_get_link_speed(struct host_if_drv *hif_drv, s8 *ps8lnkspd)
3924 struct host_if_msg msg;
3926 memset(&msg, 0, sizeof(struct host_if_msg));
3928 msg.id = HOST_IF_MSG_GET_LINKSPEED;
3931 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3933 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
3937 down(&hif_drv->hSemGetLINKSPEED);
3940 if (ps8lnkspd == NULL) {
3941 PRINT_ER("LINKSPEED pointer value is null");
3946 *ps8lnkspd = gs8lnkspd;
3952 s32 host_int_get_statistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
3955 struct host_if_msg msg;
3956 memset(&msg, 0, sizeof(struct host_if_msg));
3958 msg.id = HOST_IF_MSG_GET_STATISTICS;
3959 msg.body.data = (char *)pstrStatistics;
3962 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3964 PRINT_ER("Failed to send get host channel param's message queue ");
3968 down(&hWaitResponse);
3972 s32 host_int_scan(struct host_if_drv *hif_drv, u8 u8ScanSource,
3973 u8 u8ScanType, u8 *pu8ChnlFreqList,
3974 u8 u8ChnlListLen, const u8 *pu8IEs,
3975 size_t IEsLen, wilc_scan_result ScanResult,
3976 void *pvUserArg, struct hidden_network *pstrHiddenNetwork)
3979 struct host_if_msg msg;
3981 if (!hif_drv || ScanResult == NULL) {
3982 PRINT_ER("hif_drv or ScanResult = NULL\n");
3986 memset(&msg, 0, sizeof(struct host_if_msg));
3988 msg.id = HOST_IF_MSG_SCAN;
3990 if (pstrHiddenNetwork != NULL) {
3991 msg.body.scan_info.hidden_network.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
3992 msg.body.scan_info.hidden_network.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
3995 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
3998 msg.body.scan_info.src = u8ScanSource;
3999 msg.body.scan_info.type = u8ScanType;
4000 msg.body.scan_info.result = ScanResult;
4001 msg.body.scan_info.arg = pvUserArg;
4003 msg.body.scan_info.ch_list_len = u8ChnlListLen;
4004 msg.body.scan_info.ch_freq_list = kmalloc(u8ChnlListLen, GFP_KERNEL);
4005 memcpy(msg.body.scan_info.ch_freq_list, pu8ChnlFreqList, u8ChnlListLen);
4007 msg.body.scan_info.ies_len = IEsLen;
4008 msg.body.scan_info.ies = kmalloc(IEsLen, GFP_KERNEL);
4009 memcpy(msg.body.scan_info.ies, pu8IEs, IEsLen);
4011 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4013 PRINT_ER("Error in sending message queue\n");
4017 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
4018 hif_drv->hScanTimer.data = (unsigned long)hif_drv;
4019 mod_timer(&hif_drv->hScanTimer,
4020 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
4026 s32 hif_set_cfg(struct host_if_drv *hif_drv,
4027 struct cfg_param_val *pstrCfgParamVal)
4031 struct host_if_msg msg;
4035 PRINT_ER("hif_drv NULL\n");
4039 memset(&msg, 0, sizeof(struct host_if_msg));
4040 msg.id = HOST_IF_MSG_CFG_PARAMS;
4041 msg.body.cfg_info.cfg_attr_info = *pstrCfgParamVal;
4044 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4050 s32 hif_get_cfg(struct host_if_drv *hif_drv, u16 u16WID, u16 *pu16WID_Value)
4054 down(&hif_drv->gtOsCfgValuesSem);
4057 PRINT_ER("hif_drv NULL\n");
4060 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
4064 *pu16WID_Value = (u16)hif_drv->strCfgValues.bss_type;
4068 *pu16WID_Value = (u16)hif_drv->strCfgValues.auth_type;
4071 case WID_AUTH_TIMEOUT:
4072 *pu16WID_Value = hif_drv->strCfgValues.auth_timeout;
4075 case WID_POWER_MANAGEMENT:
4076 *pu16WID_Value = (u16)hif_drv->strCfgValues.power_mgmt_mode;
4079 case WID_SHORT_RETRY_LIMIT:
4080 *pu16WID_Value = hif_drv->strCfgValues.short_retry_limit;
4083 case WID_LONG_RETRY_LIMIT:
4084 *pu16WID_Value = hif_drv->strCfgValues.long_retry_limit;
4087 case WID_FRAG_THRESHOLD:
4088 *pu16WID_Value = hif_drv->strCfgValues.frag_threshold;
4091 case WID_RTS_THRESHOLD:
4092 *pu16WID_Value = hif_drv->strCfgValues.rts_threshold;
4096 *pu16WID_Value = (u16)hif_drv->strCfgValues.preamble_type;
4099 case WID_SHORT_SLOT_ALLOWED:
4100 *pu16WID_Value = (u16) hif_drv->strCfgValues.short_slot_allowed;
4103 case WID_11N_TXOP_PROT_DISABLE:
4104 *pu16WID_Value = (u16)hif_drv->strCfgValues.txop_prot_disabled;
4107 case WID_BEACON_INTERVAL:
4108 *pu16WID_Value = hif_drv->strCfgValues.beacon_interval;
4111 case WID_DTIM_PERIOD:
4112 *pu16WID_Value = (u16)hif_drv->strCfgValues.dtim_period;
4115 case WID_SITE_SURVEY:
4116 *pu16WID_Value = (u16)hif_drv->strCfgValues.site_survey_enabled;
4119 case WID_SITE_SURVEY_SCAN_TIME:
4120 *pu16WID_Value = hif_drv->strCfgValues.site_survey_scan_time;
4123 case WID_ACTIVE_SCAN_TIME:
4124 *pu16WID_Value = hif_drv->strCfgValues.active_scan_time;
4127 case WID_PASSIVE_SCAN_TIME:
4128 *pu16WID_Value = hif_drv->strCfgValues.passive_scan_time;
4131 case WID_CURRENT_TX_RATE:
4132 *pu16WID_Value = hif_drv->strCfgValues.curr_tx_rate;
4139 up(&hif_drv->gtOsCfgValuesSem);
4145 void host_int_send_join_leave_info_to_host
4146 (u16 assocId, u8 *stationAddr, bool joining)
4150 static void GetPeriodicRSSI(unsigned long arg)
4152 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
4155 PRINT_ER("Driver handler is NULL\n");
4159 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED) {
4161 struct host_if_msg msg;
4163 memset(&msg, 0, sizeof(struct host_if_msg));
4165 msg.id = HOST_IF_MSG_GET_RSSI;
4168 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4170 PRINT_ER("Failed to send get host channel param's message queue ");
4174 g_hPeriodicRSSI.data = (unsigned long)hif_drv;
4175 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
4179 void host_int_send_network_info_to_host
4180 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
4184 static u32 clients_count;
4186 s32 host_int_init(struct host_if_drv **hif_drv_handler)
4189 struct host_if_drv *hif_drv;
4192 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
4194 gbScanWhileConnected = false;
4196 sema_init(&hWaitResponse, 0);
4198 hif_drv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
4203 *hif_drv_handler = hif_drv;
4204 err = add_handler_in_list(hif_drv);
4210 g_obtainingIP = false;
4212 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", hif_drv);
4213 if (clients_count == 0) {
4214 sema_init(&hif_sema_thread, 0);
4215 sema_init(&hif_sema_driver, 0);
4216 sema_init(&hSemHostIntDeinit, 1);
4219 sema_init(&hif_drv->hSemTestKeyBlock, 0);
4220 sema_init(&hif_drv->hSemTestDisconnectBlock, 0);
4221 sema_init(&hif_drv->hSemGetRSSI, 0);
4222 sema_init(&hif_drv->hSemGetLINKSPEED, 0);
4223 sema_init(&hif_drv->hSemGetCHNL, 0);
4224 sema_init(&hif_drv->hSemInactiveTime, 0);
4226 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
4228 if (clients_count == 0) {
4229 result = wilc_mq_create(&hif_msg_q);
4232 PRINT_ER("Failed to creat MQ\n");
4236 hif_thread_handler = kthread_run(hostIFthread, NULL, "WILC_kthread");
4238 if (IS_ERR(hif_thread_handler)) {
4239 PRINT_ER("Failed to creat Thread\n");
4243 setup_timer(&g_hPeriodicRSSI, GetPeriodicRSSI,
4244 (unsigned long)hif_drv);
4245 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
4248 setup_timer(&hif_drv->hScanTimer, TimerCB_Scan, 0);
4250 setup_timer(&hif_drv->hConnectTimer, TimerCB_Connect, 0);
4252 setup_timer(&hif_drv->hRemainOnChannel, ListenTimerCB, 0);
4254 sema_init(&(hif_drv->gtOsCfgValuesSem), 1);
4255 down(&hif_drv->gtOsCfgValuesSem);
4257 hif_drv->enuHostIFstate = HOST_IF_IDLE;
4258 hif_drv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
4259 hif_drv->strCfgValues.scan_source = DEFAULT_SCAN;
4260 hif_drv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
4261 hif_drv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
4262 hif_drv->strCfgValues.curr_tx_rate = AUTORATE;
4264 hif_drv->u64P2p_MgmtTimeout = 0;
4266 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",
4268 hif_drv->strCfgValues.site_survey_enabled, hif_drv->strCfgValues.scan_source,
4269 hif_drv->strCfgValues.active_scan_time, hif_drv->strCfgValues.passive_scan_time,
4270 hif_drv->strCfgValues.curr_tx_rate);
4272 up(&hif_drv->gtOsCfgValuesSem);
4279 up(&hif_drv->gtOsCfgValuesSem);
4280 del_timer_sync(&hif_drv->hConnectTimer);
4281 del_timer_sync(&hif_drv->hScanTimer);
4282 kthread_stop(hif_thread_handler);
4284 wilc_mq_destroy(&hif_msg_q);
4289 s32 host_int_deinit(struct host_if_drv *hif_drv)
4292 struct host_if_msg msg;
4296 PRINT_ER("hif_drv = NULL\n");
4300 down(&hSemHostIntDeinit);
4302 terminated_handle = hif_drv;
4303 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
4305 if (del_timer_sync(&hif_drv->hScanTimer)) {
4306 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
4309 if (del_timer_sync(&hif_drv->hConnectTimer)) {
4310 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4314 if (del_timer_sync(&g_hPeriodicRSSI)) {
4315 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4318 del_timer_sync(&hif_drv->hRemainOnChannel);
4320 host_int_set_wfi_drv_handler(NULL);
4321 down(&hif_sema_driver);
4323 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
4324 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
4325 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
4327 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
4330 hif_drv->enuHostIFstate = HOST_IF_IDLE;
4332 gbScanWhileConnected = false;
4334 memset(&msg, 0, sizeof(struct host_if_msg));
4336 if (clients_count == 1) {
4337 if (del_timer_sync(&g_hPeriodicRSSI)) {
4338 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4340 msg.id = HOST_IF_MSG_EXIT;
4343 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4345 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
4347 down(&hif_sema_thread);
4349 wilc_mq_destroy(&hif_msg_q);
4352 down(&(hif_drv->gtOsCfgValuesSem));
4354 ret = remove_handler_in_list(hif_drv);
4361 terminated_handle = NULL;
4362 up(&hSemHostIntDeinit);
4366 void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
4369 struct host_if_msg msg;
4371 struct host_if_drv *hif_drv = NULL;
4373 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4374 hif_drv = get_handler_from_id(id);
4379 if (!hif_drv || hif_drv == terminated_handle) {
4380 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv);
4384 memset(&msg, 0, sizeof(struct host_if_msg));
4386 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
4389 msg.body.net_info.len = u32Length;
4390 msg.body.net_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4391 memcpy(msg.body.net_info.buffer, pu8Buffer, u32Length);
4393 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4395 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
4398 void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
4401 struct host_if_msg msg;
4403 struct host_if_drv *hif_drv = NULL;
4405 down(&hSemHostIntDeinit);
4407 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4408 hif_drv = get_handler_from_id(id);
4409 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
4412 if (!hif_drv || hif_drv == terminated_handle) {
4413 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
4414 up(&hSemHostIntDeinit);
4418 if (!hif_drv->strWILC_UsrConnReq.pfUserConnectResult) {
4419 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
4420 up(&hSemHostIntDeinit);
4424 memset(&msg, 0, sizeof(struct host_if_msg));
4427 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
4430 msg.body.async_info.len = u32Length;
4431 msg.body.async_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4432 memcpy(msg.body.async_info.buffer, pu8Buffer, u32Length);
4434 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4436 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
4438 up(&hSemHostIntDeinit);
4441 void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
4444 struct host_if_msg msg;
4446 struct host_if_drv *hif_drv = NULL;
4448 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4449 hif_drv = get_handler_from_id(id);
4452 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", hif_drv);
4454 if (!hif_drv || hif_drv == terminated_handle)
4457 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
4458 memset(&msg, 0, sizeof(struct host_if_msg));
4460 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
4463 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4465 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
4473 s32 host_int_remain_on_channel(struct host_if_drv *hif_drv, u32 u32SessionID,
4474 u32 u32duration, u16 chan,
4475 wilc_remain_on_chan_expired RemainOnChanExpired,
4476 wilc_remain_on_chan_ready RemainOnChanReady,
4480 struct host_if_msg msg;
4483 PRINT_ER("driver is null\n");
4487 memset(&msg, 0, sizeof(struct host_if_msg));
4489 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
4490 msg.body.remain_on_ch.u16Channel = chan;
4491 msg.body.remain_on_ch.pRemainOnChanExpired = RemainOnChanExpired;
4492 msg.body.remain_on_ch.pRemainOnChanReady = RemainOnChanReady;
4493 msg.body.remain_on_ch.pVoid = pvUserArg;
4494 msg.body.remain_on_ch.u32duration = u32duration;
4495 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
4498 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4500 PRINT_ER("wilc mq send fail\n");
4505 s32 host_int_ListenStateExpired(struct host_if_drv *hif_drv, u32 u32SessionID)
4508 struct host_if_msg msg;
4511 PRINT_ER("driver is null\n");
4515 del_timer(&hif_drv->hRemainOnChannel);
4517 memset(&msg, 0, sizeof(struct host_if_msg));
4518 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
4520 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
4522 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4524 PRINT_ER("wilc mq send fail\n");
4529 s32 host_int_frame_register(struct host_if_drv *hif_drv, u16 u16FrameType, bool bReg)
4532 struct host_if_msg msg;
4535 PRINT_ER("driver is null\n");
4539 memset(&msg, 0, sizeof(struct host_if_msg));
4541 msg.id = HOST_IF_MSG_REGISTER_FRAME;
4542 switch (u16FrameType) {
4544 PRINT_D(HOSTINF_DBG, "ACTION\n");
4545 msg.body.reg_frame.u8Regid = ACTION_FRM_IDX;
4549 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
4550 msg.body.reg_frame.u8Regid = PROBE_REQ_IDX;
4554 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
4557 msg.body.reg_frame.u16FrameType = u16FrameType;
4558 msg.body.reg_frame.bReg = bReg;
4561 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4563 PRINT_ER("wilc mq send fail\n");
4570 s32 host_int_add_beacon(struct host_if_drv *hif_drv, u32 u32Interval,
4571 u32 u32DTIMPeriod, u32 u32HeadLen, u8 *pu8Head,
4572 u32 u32TailLen, u8 *pu8Tail)
4575 struct host_if_msg msg;
4576 struct beacon_attr *pstrSetBeaconParam = &msg.body.beacon_info;
4579 PRINT_ER("driver is null\n");
4583 memset(&msg, 0, sizeof(struct host_if_msg));
4585 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
4587 msg.id = HOST_IF_MSG_ADD_BEACON;
4589 pstrSetBeaconParam->interval = u32Interval;
4590 pstrSetBeaconParam->dtim_period = u32DTIMPeriod;
4591 pstrSetBeaconParam->head_len = u32HeadLen;
4592 pstrSetBeaconParam->head = kmalloc(u32HeadLen, GFP_KERNEL);
4593 if (pstrSetBeaconParam->head == NULL) {
4597 memcpy(pstrSetBeaconParam->head, pu8Head, u32HeadLen);
4598 pstrSetBeaconParam->tail_len = u32TailLen;
4600 if (u32TailLen > 0) {
4601 pstrSetBeaconParam->tail = kmalloc(u32TailLen, GFP_KERNEL);
4602 if (pstrSetBeaconParam->tail == NULL) {
4606 memcpy(pstrSetBeaconParam->tail, pu8Tail, u32TailLen);
4608 pstrSetBeaconParam->tail = NULL;
4611 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4613 PRINT_ER("wilc mq send fail\n");
4617 kfree(pstrSetBeaconParam->head);
4619 kfree(pstrSetBeaconParam->tail);
4626 s32 host_int_del_beacon(struct host_if_drv *hif_drv)
4629 struct host_if_msg msg;
4632 PRINT_ER("driver is null\n");
4636 msg.id = HOST_IF_MSG_DEL_BEACON;
4638 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
4640 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4642 PRINT_ER("wilc_mq_send fail\n");
4647 s32 host_int_add_station(struct host_if_drv *hif_drv,
4648 struct add_sta_param *pstrStaParams)
4651 struct host_if_msg msg;
4652 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
4656 PRINT_ER("driver is null\n");
4660 memset(&msg, 0, sizeof(struct host_if_msg));
4662 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
4664 msg.id = HOST_IF_MSG_ADD_STATION;
4667 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
4668 if (pstrAddStationMsg->u8NumRates > 0) {
4669 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
4674 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
4675 pstrAddStationMsg->pu8Rates = rates;
4678 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4680 PRINT_ER("wilc_mq_send fail\n");
4684 s32 host_int_del_station(struct host_if_drv *hif_drv, const u8 *pu8MacAddr)
4687 struct host_if_msg msg;
4688 struct del_sta *pstrDelStationMsg = &msg.body.del_sta_info;
4691 PRINT_ER("driver is null\n");
4695 memset(&msg, 0, sizeof(struct host_if_msg));
4697 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
4699 msg.id = HOST_IF_MSG_DEL_STATION;
4702 if (pu8MacAddr == NULL)
4703 memset(pstrDelStationMsg->mac_addr, 255, ETH_ALEN);
4705 memcpy(pstrDelStationMsg->mac_addr, pu8MacAddr, ETH_ALEN);
4707 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4709 PRINT_ER("wilc_mq_send fail\n");
4713 s32 host_int_del_allstation(struct host_if_drv *hif_drv,
4714 u8 pu8MacAddr[][ETH_ALEN])
4717 struct host_if_msg msg;
4718 struct del_all_sta *pstrDelAllStationMsg = &msg.body.del_all_sta_info;
4719 u8 au8Zero_Buff[ETH_ALEN] = {0};
4725 PRINT_ER("driver is null\n");
4729 memset(&msg, 0, sizeof(struct host_if_msg));
4731 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
4733 msg.id = HOST_IF_MSG_DEL_ALL_STA;
4736 for (i = 0; i < MAX_NUM_STA; i++) {
4737 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
4738 memcpy(pstrDelAllStationMsg->del_all_sta[i], pu8MacAddr[i], ETH_ALEN);
4739 PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n",
4740 pstrDelAllStationMsg->del_all_sta[i][0],
4741 pstrDelAllStationMsg->del_all_sta[i][1],
4742 pstrDelAllStationMsg->del_all_sta[i][2],
4743 pstrDelAllStationMsg->del_all_sta[i][3],
4744 pstrDelAllStationMsg->del_all_sta[i][4],
4745 pstrDelAllStationMsg->del_all_sta[i][5]);
4750 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
4754 pstrDelAllStationMsg->assoc_sta = u8AssocNumb;
4755 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4758 PRINT_ER("wilc_mq_send fail\n");
4760 down(&hWaitResponse);
4766 s32 host_int_edit_station(struct host_if_drv *hif_drv,
4767 struct add_sta_param *pstrStaParams)
4770 struct host_if_msg msg;
4771 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
4774 PRINT_ER("driver is null\n");
4778 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
4780 memset(&msg, 0, sizeof(struct host_if_msg));
4782 msg.id = HOST_IF_MSG_EDIT_STATION;
4785 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
4786 if (pstrAddStationMsg->u8NumRates > 0) {
4787 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
4792 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
4793 pstrAddStationMsg->pu8Rates = rates;
4796 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4798 PRINT_ER("wilc_mq_send fail\n");
4803 s32 host_int_set_power_mgmt(struct host_if_drv *hif_drv,
4808 struct host_if_msg msg;
4809 struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.pwr_mgmt_info;
4811 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
4814 PRINT_ER("driver is null\n");
4818 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
4820 memset(&msg, 0, sizeof(struct host_if_msg));
4822 msg.id = HOST_IF_MSG_POWER_MGMT;
4825 pstrPowerMgmtParam->enabled = bIsEnabled;
4826 pstrPowerMgmtParam->timeout = u32Timeout;
4828 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4830 PRINT_ER("wilc_mq_send fail\n");
4834 s32 host_int_setup_multicast_filter(struct host_if_drv *hif_drv,
4839 struct host_if_msg msg;
4840 struct set_multicast *pstrMulticastFilterParam = &msg.body.multicast_info;
4844 PRINT_ER("driver is null\n");
4848 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
4850 memset(&msg, 0, sizeof(struct host_if_msg));
4852 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
4855 pstrMulticastFilterParam->enabled = bIsEnabled;
4856 pstrMulticastFilterParam->cnt = u32count;
4858 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4860 PRINT_ER("wilc_mq_send fail\n");
4864 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
4866 struct join_bss_param *pNewJoinBssParam = NULL;
4875 u8 pcipherTotalCount = 0;
4876 u8 authTotalCount = 0;
4879 pu8IEs = ptstrNetworkInfo->pu8IEs;
4880 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
4882 pNewJoinBssParam = kzalloc(sizeof(struct join_bss_param), GFP_KERNEL);
4883 if (pNewJoinBssParam != NULL) {
4884 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
4885 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
4886 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
4887 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
4888 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
4889 pNewJoinBssParam->ssid_len = ptstrNetworkInfo->u8SsidLen;
4890 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
4891 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
4893 while (index < u16IEsLen) {
4894 if (pu8IEs[index] == SUPP_RATES_IE) {
4895 suppRatesNo = pu8IEs[index + 1];
4896 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
4899 for (i = 0; i < suppRatesNo; i++) {
4900 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
4902 index += suppRatesNo;
4904 } else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
4905 extSuppRatesNo = pu8IEs[index + 1];
4906 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
4907 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
4909 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
4911 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
4912 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
4914 index += extSuppRatesNo;
4916 } else if (pu8IEs[index] == HT_CAPABILITY_IE) {
4917 pNewJoinBssParam->ht_capable = true;
4918 index += pu8IEs[index + 1] + 2;
4920 } else if ((pu8IEs[index] == WMM_IE) &&
4921 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
4922 (pu8IEs[index + 4] == 0xF2) &&
4923 (pu8IEs[index + 5] == 0x02) &&
4924 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) &&
4925 (pu8IEs[index + 7] == 0x01)) {
4926 pNewJoinBssParam->wmm_cap = true;
4928 if (pu8IEs[index + 8] & BIT(7))
4929 pNewJoinBssParam->uapsd_cap = true;
4930 index += pu8IEs[index + 1] + 2;
4932 } else if ((pu8IEs[index] == P2P_IE) &&
4933 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
4934 (pu8IEs[index + 4] == 0x9a) &&
4935 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) {
4938 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
4939 pNewJoinBssParam->noa_enabled = 1;
4940 pNewJoinBssParam->idx = pu8IEs[index + 9];
4942 if (pu8IEs[index + 10] & BIT(7)) {
4943 pNewJoinBssParam->opp_enabled = 1;
4944 pNewJoinBssParam->ct_window = pu8IEs[index + 10];
4946 pNewJoinBssParam->opp_enabled = 0;
4949 PRINT_D(GENERIC_DBG, "P2P Dump\n");
4950 for (i = 0; i < pu8IEs[index + 7]; i++)
4951 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
4953 pNewJoinBssParam->cnt = pu8IEs[index + 11];
4954 u16P2P_count = index + 12;
4956 memcpy(pNewJoinBssParam->duration, pu8IEs + u16P2P_count, 4);
4959 memcpy(pNewJoinBssParam->interval, pu8IEs + u16P2P_count, 4);
4962 memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
4964 index += pu8IEs[index + 1] + 2;
4967 } else if ((pu8IEs[index] == RSN_IE) ||
4968 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
4969 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
4970 (pu8IEs[index + 5] == 0x01))) {
4971 u16 rsnIndex = index;
4973 if (pu8IEs[rsnIndex] == RSN_IE) {
4974 pNewJoinBssParam->mode_802_11i = 2;
4976 if (pNewJoinBssParam->mode_802_11i == 0)
4977 pNewJoinBssParam->mode_802_11i = 1;
4982 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
4984 jumpOffset = pu8IEs[rsnIndex] * 4;
4985 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
4988 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
4989 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
4991 pcipherTotalCount += pcipherCount;
4992 rsnIndex += jumpOffset;
4994 jumpOffset = pu8IEs[rsnIndex] * 4;
4996 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
4999 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
5000 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
5002 authTotalCount += authCount;
5003 rsnIndex += jumpOffset;
5005 if (pu8IEs[index] == RSN_IE) {
5006 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
5007 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
5010 pNewJoinBssParam->rsn_found = true;
5011 index += pu8IEs[index + 1] + 2;
5014 index += pu8IEs[index + 1] + 2;
5021 return (void *)pNewJoinBssParam;
5025 void host_int_freeJoinParams(void *pJoinParams)
5027 if ((struct bss_param *)pJoinParams != NULL)
5028 kfree((struct bss_param *)pJoinParams);
5030 PRINT_ER("Unable to FREE null pointer\n");
5033 s32 host_int_delBASession(struct host_if_drv *hif_drv, char *pBSSID, char TID)
5036 struct host_if_msg msg;
5037 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
5040 PRINT_ER("driver is null\n");
5044 memset(&msg, 0, sizeof(struct host_if_msg));
5046 msg.id = HOST_IF_MSG_DEL_BA_SESSION;
5048 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
5049 pBASessionInfo->u8Ted = TID;
5052 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
5054 PRINT_ER("wilc_mq_send fail\n");
5056 down(&hWaitResponse);
5061 s32 host_int_del_All_Rx_BASession(struct host_if_drv *hif_drv,
5066 struct host_if_msg msg;
5067 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
5070 PRINT_ER("driver is null\n");
5074 memset(&msg, 0, sizeof(struct host_if_msg));
5076 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
5078 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
5079 pBASessionInfo->u8Ted = TID;
5082 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
5084 PRINT_ER("wilc_mq_send fail\n");
5086 down(&hWaitResponse);
5091 s32 host_int_setup_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
5094 struct host_if_msg msg;
5099 PRINT_ER("driver is null\n");
5103 memset(&msg, 0, sizeof(struct host_if_msg));
5105 msg.id = HOST_IF_MSG_SET_IPADDRESS;
5107 msg.body.ip_info.ip_addr = u16ipadd;
5109 msg.body.ip_info.idx = idx;
5111 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
5113 PRINT_ER("wilc_mq_send fail\n");
5120 s32 host_int_get_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
5123 struct host_if_msg msg;
5126 PRINT_ER("driver is null\n");
5130 memset(&msg, 0, sizeof(struct host_if_msg));
5132 msg.id = HOST_IF_MSG_GET_IPADDRESS;
5134 msg.body.ip_info.ip_addr = u16ipadd;
5136 msg.body.ip_info.idx = idx;
5138 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
5140 PRINT_ER("wilc_mq_send fail\n");