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 hif_sema_wait_response;
241 static struct semaphore hif_sema_deinit;
242 static struct timer_list periodic_rssi;
244 u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
246 static u8 rcv_assoc_resp[MAX_ASSOC_RESP_FRAME_SIZE];
248 static bool scan_while_connected;
251 static s8 link_speed;
253 static u8 gs8SetIP[2][4];
254 static u8 gs8GetIP[2][4];
255 static u32 gu32InactiveTime;
257 static u32 gu32WidConnRstHack;
259 u8 *gu8FlushedJoinReq;
260 u8 *gu8FlushedInfoElemAsoc;
261 u8 gu8Flushed11iMode;
262 u8 gu8FlushedAuthType;
263 u32 gu32FlushedJoinReqSize;
264 u32 gu32FlushedInfoElemAsocSize;
265 struct host_if_drv *gu8FlushedJoinReqDrvHandler;
266 #define REAL_JOIN_REQ 0
267 #define FLUSHED_JOIN_REQ 1
268 #define FLUSHED_BYTE_POS 79
270 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
272 extern void chip_sleep_manually(u32 u32SleepTime);
273 extern int linux_wlan_get_num_conn_ifcs(void);
275 static int add_handler_in_list(struct host_if_drv *handler)
279 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
280 if (!wfidrv_list[i]) {
281 wfidrv_list[i] = handler;
289 static int remove_handler_in_list(struct host_if_drv *handler)
293 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
294 if (wfidrv_list[i] == handler) {
295 wfidrv_list[i] = NULL;
303 static int get_id_from_handler(struct host_if_drv *handler)
310 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
311 if (wfidrv_list[i] == handler)
318 static struct host_if_drv *get_handler_from_id(int id)
320 if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list))
322 return wfidrv_list[id];
325 static s32 Handle_SetChannel(struct host_if_drv *hif_drv,
326 struct channel_attr *pstrHostIFSetChan)
332 strWID.id = (u16)WID_CURRENT_CHANNEL;
333 strWID.type = WID_CHAR;
334 strWID.val = (char *)&(pstrHostIFSetChan->set_ch);
335 strWID.size = sizeof(char);
337 PRINT_D(HOSTINF_DBG, "Setting channel\n");
339 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
340 get_id_from_handler(hif_drv));
342 PRINT_ER("Failed to set channel\n");
349 static s32 Handle_SetWfiDrvHandler(struct host_if_drv *hif_drv,
350 struct drv_handler *pstrHostIfSetDrvHandler)
356 strWID.id = (u16)WID_SET_DRV_HANDLER;
357 strWID.type = WID_INT;
358 strWID.val = (s8 *)&(pstrHostIfSetDrvHandler->u32Address);
359 strWID.size = sizeof(u32);
361 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
362 pstrHostIfSetDrvHandler->u32Address);
365 up(&hif_sema_driver);
368 PRINT_ER("Failed to set driver handler\n");
375 static s32 Handle_SetOperationMode(struct host_if_drv *hif_drv,
376 struct op_mode *pstrHostIfSetOperationMode)
382 strWID.id = (u16)WID_SET_OPERATION_MODE;
383 strWID.type = WID_INT;
384 strWID.val = (s8 *)&(pstrHostIfSetOperationMode->u32Mode);
385 strWID.size = sizeof(u32);
387 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
388 get_id_from_handler(hif_drv));
391 if ((pstrHostIfSetOperationMode->u32Mode) == IDLE_MODE)
392 up(&hif_sema_driver);
395 PRINT_ER("Failed to set driver handler\n");
402 s32 Handle_set_IPAddress(struct host_if_drv *hif_drv, u8 *pu8IPAddr, u8 idx)
407 char firmwareIPAddress[4] = {0};
409 if (pu8IPAddr[0] < 192)
412 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n", idx, pu8IPAddr);
414 memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN);
416 strWID.id = (u16)WID_IP_ADDRESS;
417 strWID.type = WID_STR;
418 strWID.val = (u8 *)pu8IPAddr;
419 strWID.size = IP_ALEN;
421 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
422 get_id_from_handler(hif_drv));
425 host_int_get_ipaddress(hif_drv, firmwareIPAddress, idx);
428 PRINT_ER("Failed to set IP address\n");
432 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
437 s32 Handle_get_IPAddress(struct host_if_drv *hif_drv, u8 *pu8IPAddr, u8 idx)
443 strWID.id = (u16)WID_IP_ADDRESS;
444 strWID.type = WID_STR;
445 strWID.val = kmalloc(IP_ALEN, GFP_KERNEL);
446 strWID.size = IP_ALEN;
448 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
449 get_id_from_handler(hif_drv));
451 PRINT_INFO(HOSTINF_DBG, "%pI4\n", strWID.val);
453 memcpy(gs8GetIP[idx], strWID.val, IP_ALEN);
457 if (memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0)
458 host_int_setup_ipaddress(hif_drv, gs8SetIP[idx], idx);
461 PRINT_ER("Failed to get IP address\n");
465 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
466 PRINT_INFO(HOSTINF_DBG, "%pI4\n", gs8GetIP[idx]);
467 PRINT_INFO(HOSTINF_DBG, "\n");
472 static s32 Handle_SetMacAddress(struct host_if_drv *hif_drv,
473 struct set_mac_addr *pstrHostIfSetMacAddress)
478 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
480 if (mac_buf == NULL) {
481 PRINT_ER("No buffer to send mac address\n");
484 memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
486 strWID.id = (u16)WID_MAC_ADDR;
487 strWID.type = WID_STR;
488 strWID.val = mac_buf;
489 strWID.size = ETH_ALEN;
490 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", strWID.val);
492 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
493 get_id_from_handler(hif_drv));
495 PRINT_ER("Failed to set mac address\n");
503 static s32 Handle_GetMacAddress(struct host_if_drv *hif_drv,
504 struct get_mac_addr *pstrHostIfGetMacAddress)
510 strWID.id = (u16)WID_MAC_ADDR;
511 strWID.type = WID_STR;
512 strWID.val = pstrHostIfGetMacAddress->u8MacAddress;
513 strWID.size = ETH_ALEN;
515 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
516 get_id_from_handler(hif_drv));
518 PRINT_ER("Failed to get mac address\n");
521 up(&hif_sema_wait_response);
526 static s32 Handle_CfgParam(struct host_if_drv *hif_drv,
527 struct cfg_param_attr *strHostIFCfgParamAttr)
530 struct wid strWIDList[32];
533 down(&hif_drv->gtOsCfgValuesSem);
536 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
538 if (strHostIFCfgParamAttr->cfg_attr_info.flag & BSS_TYPE) {
539 if (strHostIFCfgParamAttr->cfg_attr_info.bss_type < 6) {
540 strWIDList[u8WidCnt].id = WID_BSS_TYPE;
541 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.bss_type;
542 strWIDList[u8WidCnt].type = WID_CHAR;
543 strWIDList[u8WidCnt].size = sizeof(char);
544 hif_drv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->cfg_attr_info.bss_type;
546 PRINT_ER("check value 6 over\n");
552 if (strHostIFCfgParamAttr->cfg_attr_info.flag & AUTH_TYPE) {
553 if ((strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 1 || (strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 2 || (strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 5) {
554 strWIDList[u8WidCnt].id = WID_AUTH_TYPE;
555 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.auth_type;
556 strWIDList[u8WidCnt].type = WID_CHAR;
557 strWIDList[u8WidCnt].size = sizeof(char);
558 hif_drv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->cfg_attr_info.auth_type;
560 PRINT_ER("Impossible value \n");
566 if (strHostIFCfgParamAttr->cfg_attr_info.flag & AUTHEN_TIMEOUT) {
567 if (strHostIFCfgParamAttr->cfg_attr_info.auth_timeout > 0 && strHostIFCfgParamAttr->cfg_attr_info.auth_timeout < 65536) {
568 strWIDList[u8WidCnt].id = WID_AUTH_TIMEOUT;
569 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.auth_timeout;
570 strWIDList[u8WidCnt].type = WID_SHORT;
571 strWIDList[u8WidCnt].size = sizeof(u16);
572 hif_drv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->cfg_attr_info.auth_timeout;
574 PRINT_ER("Range(1 ~ 65535) over\n");
580 if (strHostIFCfgParamAttr->cfg_attr_info.flag & POWER_MANAGEMENT) {
581 if (strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode < 5) {
582 strWIDList[u8WidCnt].id = WID_POWER_MANAGEMENT;
583 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode;
584 strWIDList[u8WidCnt].type = WID_CHAR;
585 strWIDList[u8WidCnt].size = sizeof(char);
586 hif_drv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode;
588 PRINT_ER("Invalide power mode\n");
594 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RETRY_SHORT) {
595 if ((strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit > 0) && (strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit < 256)) {
596 strWIDList[u8WidCnt].id = WID_SHORT_RETRY_LIMIT;
597 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit;
598 strWIDList[u8WidCnt].type = WID_SHORT;
599 strWIDList[u8WidCnt].size = sizeof(u16);
600 hif_drv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit;
602 PRINT_ER("Range(1~256) over\n");
608 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RETRY_LONG) {
609 if ((strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit > 0) && (strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit < 256)) {
610 strWIDList[u8WidCnt].id = WID_LONG_RETRY_LIMIT;
611 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit;
613 strWIDList[u8WidCnt].type = WID_SHORT;
614 strWIDList[u8WidCnt].size = sizeof(u16);
615 hif_drv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit;
617 PRINT_ER("Range(1~256) over\n");
623 if (strHostIFCfgParamAttr->cfg_attr_info.flag & FRAG_THRESHOLD) {
625 if (strHostIFCfgParamAttr->cfg_attr_info.frag_threshold > 255 && strHostIFCfgParamAttr->cfg_attr_info.frag_threshold < 7937) {
626 strWIDList[u8WidCnt].id = WID_FRAG_THRESHOLD;
627 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.frag_threshold;
628 strWIDList[u8WidCnt].type = WID_SHORT;
629 strWIDList[u8WidCnt].size = sizeof(u16);
630 hif_drv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->cfg_attr_info.frag_threshold;
632 PRINT_ER("Threshold Range fail\n");
638 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RTS_THRESHOLD) {
639 if (strHostIFCfgParamAttr->cfg_attr_info.rts_threshold > 255 && strHostIFCfgParamAttr->cfg_attr_info.rts_threshold < 65536) {
640 strWIDList[u8WidCnt].id = WID_RTS_THRESHOLD;
641 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.rts_threshold;
642 strWIDList[u8WidCnt].type = WID_SHORT;
643 strWIDList[u8WidCnt].size = sizeof(u16);
644 hif_drv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->cfg_attr_info.rts_threshold;
646 PRINT_ER("Threshold Range fail\n");
652 if (strHostIFCfgParamAttr->cfg_attr_info.flag & PREAMBLE) {
653 if (strHostIFCfgParamAttr->cfg_attr_info.preamble_type < 3) {
654 strWIDList[u8WidCnt].id = WID_PREAMBLE;
655 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.preamble_type;
656 strWIDList[u8WidCnt].type = WID_CHAR;
657 strWIDList[u8WidCnt].size = sizeof(char);
658 hif_drv->strCfgValues.preamble_type = strHostIFCfgParamAttr->cfg_attr_info.preamble_type;
660 PRINT_ER("Preamle Range(0~2) over\n");
666 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SHORT_SLOT_ALLOWED) {
667 if (strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed < 2) {
668 strWIDList[u8WidCnt].id = WID_SHORT_SLOT_ALLOWED;
669 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed;
670 strWIDList[u8WidCnt].type = WID_CHAR;
671 strWIDList[u8WidCnt].size = sizeof(char);
672 hif_drv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed;
674 PRINT_ER("Short slot(2) over\n");
680 if (strHostIFCfgParamAttr->cfg_attr_info.flag & TXOP_PROT_DISABLE) {
681 if (strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled < 2) {
682 strWIDList[u8WidCnt].id = WID_11N_TXOP_PROT_DISABLE;
683 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled;
684 strWIDList[u8WidCnt].type = WID_CHAR;
685 strWIDList[u8WidCnt].size = sizeof(char);
686 hif_drv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled;
688 PRINT_ER("TXOP prot disable\n");
694 if (strHostIFCfgParamAttr->cfg_attr_info.flag & BEACON_INTERVAL) {
695 if (strHostIFCfgParamAttr->cfg_attr_info.beacon_interval > 0 && strHostIFCfgParamAttr->cfg_attr_info.beacon_interval < 65536) {
696 strWIDList[u8WidCnt].id = WID_BEACON_INTERVAL;
697 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.beacon_interval;
698 strWIDList[u8WidCnt].type = WID_SHORT;
699 strWIDList[u8WidCnt].size = sizeof(u16);
700 hif_drv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->cfg_attr_info.beacon_interval;
702 PRINT_ER("Beacon interval(1~65535) fail\n");
708 if (strHostIFCfgParamAttr->cfg_attr_info.flag & DTIM_PERIOD) {
709 if (strHostIFCfgParamAttr->cfg_attr_info.dtim_period > 0 && strHostIFCfgParamAttr->cfg_attr_info.dtim_period < 256) {
710 strWIDList[u8WidCnt].id = WID_DTIM_PERIOD;
711 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.dtim_period;
712 strWIDList[u8WidCnt].type = WID_CHAR;
713 strWIDList[u8WidCnt].size = sizeof(char);
714 hif_drv->strCfgValues.dtim_period = strHostIFCfgParamAttr->cfg_attr_info.dtim_period;
716 PRINT_ER("DTIM range(1~255) fail\n");
722 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SITE_SURVEY) {
723 if (strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled < 3) {
724 strWIDList[u8WidCnt].id = WID_SITE_SURVEY;
725 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled;
726 strWIDList[u8WidCnt].type = WID_CHAR;
727 strWIDList[u8WidCnt].size = sizeof(char);
728 hif_drv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled;
730 PRINT_ER("Site survey disable\n");
736 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SITE_SURVEY_SCAN_TIME) {
737 if (strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time < 65536) {
738 strWIDList[u8WidCnt].id = WID_SITE_SURVEY_SCAN_TIME;
739 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time;
740 strWIDList[u8WidCnt].type = WID_SHORT;
741 strWIDList[u8WidCnt].size = sizeof(u16);
742 hif_drv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time;
744 PRINT_ER("Site survey scan time(1~65535) over\n");
750 if (strHostIFCfgParamAttr->cfg_attr_info.flag & ACTIVE_SCANTIME) {
751 if (strHostIFCfgParamAttr->cfg_attr_info.active_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.active_scan_time < 65536) {
752 strWIDList[u8WidCnt].id = WID_ACTIVE_SCAN_TIME;
753 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.active_scan_time;
754 strWIDList[u8WidCnt].type = WID_SHORT;
755 strWIDList[u8WidCnt].size = sizeof(u16);
756 hif_drv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->cfg_attr_info.active_scan_time;
758 PRINT_ER("Active scan time(1~65535) over\n");
764 if (strHostIFCfgParamAttr->cfg_attr_info.flag & PASSIVE_SCANTIME) {
765 if (strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time < 65536) {
766 strWIDList[u8WidCnt].id = WID_PASSIVE_SCAN_TIME;
767 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time;
768 strWIDList[u8WidCnt].type = WID_SHORT;
769 strWIDList[u8WidCnt].size = sizeof(u16);
770 hif_drv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time;
772 PRINT_ER("Passive scan time(1~65535) over\n");
778 if (strHostIFCfgParamAttr->cfg_attr_info.flag & CURRENT_TX_RATE) {
779 enum CURRENT_TXRATE curr_tx_rate = strHostIFCfgParamAttr->cfg_attr_info.curr_tx_rate;
780 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
781 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
782 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
783 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
784 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
785 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
786 strWIDList[u8WidCnt].id = WID_CURRENT_TX_RATE;
787 strWIDList[u8WidCnt].val = (s8 *)&curr_tx_rate;
788 strWIDList[u8WidCnt].type = WID_SHORT;
789 strWIDList[u8WidCnt].size = sizeof(u16);
790 hif_drv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
792 PRINT_ER("out of TX rate\n");
798 s32Error = send_config_pkt(SET_CFG, strWIDList, u8WidCnt,
799 get_id_from_handler(hif_drv));
802 PRINT_ER("Error in setting CFG params\n");
805 up(&hif_drv->gtOsCfgValuesSem);
809 static s32 Handle_wait_msg_q_empty(void)
811 g_wilc_initialized = 0;
812 up(&hif_sema_wait_response);
816 static s32 Handle_Scan(struct host_if_drv *hif_drv,
817 struct scan_attr *pstrHostIFscanAttr)
820 struct wid strWIDList[5];
821 u32 u32WidsCount = 0;
825 u8 *pu8HdnNtwrksWidVal = NULL;
827 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
828 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", hif_drv->enuHostIFstate);
830 hif_drv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->result;
831 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->arg;
833 if ((hif_drv->enuHostIFstate >= HOST_IF_SCANNING) && (hif_drv->enuHostIFstate < HOST_IF_CONNECTED)) {
834 PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", hif_drv->enuHostIFstate);
835 PRINT_ER("Already scan\n");
840 if (g_obtainingIP || connecting) {
841 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
842 PRINT_ER("Don't do obss scan\n");
847 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
850 hif_drv->strWILC_UsrScanReq.u32RcvdChCount = 0;
852 strWIDList[u32WidsCount].id = (u16)WID_SSID_PROBE_REQ;
853 strWIDList[u32WidsCount].type = WID_STR;
855 for (i = 0; i < pstrHostIFscanAttr->hidden_network.u8ssidnum; i++)
856 valuesize += ((pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
857 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
858 strWIDList[u32WidsCount].val = pu8HdnNtwrksWidVal;
859 if (strWIDList[u32WidsCount].val != NULL) {
860 pu8Buffer = strWIDList[u32WidsCount].val;
862 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.u8ssidnum;
864 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->hidden_network.u8ssidnum);
866 for (i = 0; i < pstrHostIFscanAttr->hidden_network.u8ssidnum; i++) {
867 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen;
868 memcpy(pu8Buffer, pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen);
869 pu8Buffer += pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen;
874 strWIDList[u32WidsCount].size = (s32)(valuesize + 1);
879 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_PROBE;
880 strWIDList[u32WidsCount].type = WID_BIN_DATA;
881 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ies;
882 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ies_len;
886 strWIDList[u32WidsCount].id = WID_SCAN_TYPE;
887 strWIDList[u32WidsCount].type = WID_CHAR;
888 strWIDList[u32WidsCount].size = sizeof(char);
889 strWIDList[u32WidsCount].val = (s8 *)(&(pstrHostIFscanAttr->type));
892 strWIDList[u32WidsCount].id = WID_SCAN_CHANNEL_LIST;
893 strWIDList[u32WidsCount].type = WID_BIN_DATA;
895 if (pstrHostIFscanAttr->ch_freq_list != NULL && pstrHostIFscanAttr->ch_list_len > 0) {
898 for (i = 0; i < pstrHostIFscanAttr->ch_list_len; i++) {
899 if (pstrHostIFscanAttr->ch_freq_list[i] > 0)
900 pstrHostIFscanAttr->ch_freq_list[i] = pstrHostIFscanAttr->ch_freq_list[i] - 1;
904 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ch_freq_list;
905 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ch_list_len;
908 strWIDList[u32WidsCount].id = WID_START_SCAN_REQ;
909 strWIDList[u32WidsCount].type = WID_CHAR;
910 strWIDList[u32WidsCount].size = sizeof(char);
911 strWIDList[u32WidsCount].val = (s8 *)(&(pstrHostIFscanAttr->src));
914 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)
915 scan_while_connected = true;
916 else if (hif_drv->enuHostIFstate == HOST_IF_IDLE)
917 scan_while_connected = false;
919 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
920 get_id_from_handler(hif_drv));
923 PRINT_ER("Failed to send scan paramters config packet\n");
925 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
929 del_timer(&hif_drv->hScanTimer);
930 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
933 kfree(pstrHostIFscanAttr->ch_freq_list);
934 pstrHostIFscanAttr->ch_freq_list = NULL;
936 kfree(pstrHostIFscanAttr->ies);
937 pstrHostIFscanAttr->ies = NULL;
938 kfree(pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo);
939 pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo = NULL;
941 kfree(pu8HdnNtwrksWidVal);
946 static s32 Handle_ScanDone(struct host_if_drv *hif_drv,
947 enum scan_event enuEvent)
950 u8 u8abort_running_scan;
954 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
956 if (enuEvent == SCAN_EVENT_ABORTED) {
957 PRINT_D(GENERIC_DBG, "Abort running scan\n");
958 u8abort_running_scan = 1;
959 strWID.id = (u16)WID_ABORT_RUNNING_SCAN;
960 strWID.type = WID_CHAR;
961 strWID.val = (s8 *)&u8abort_running_scan;
962 strWID.size = sizeof(char);
964 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
965 get_id_from_handler(hif_drv));
967 PRINT_ER("Failed to set abort running scan\n");
973 PRINT_ER("Driver handler is NULL\n");
977 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
978 hif_drv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
979 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
980 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
986 u8 u8ConnectedSSID[6] = {0};
987 static s32 Handle_Connect(struct host_if_drv *hif_drv,
988 struct connect_attr *pstrHostIFconnectAttr)
991 struct wid strWIDList[8];
992 u32 u32WidsCount = 0, dummyval = 0;
993 u8 *pu8CurrByte = NULL;
994 struct join_bss_param *ptstrJoinBssParam;
996 PRINT_D(GENERIC_DBG, "Handling connect request\n");
998 if (memcmp(pstrHostIFconnectAttr->bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
1001 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1005 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1007 ptstrJoinBssParam = (struct join_bss_param *)pstrHostIFconnectAttr->params;
1008 if (ptstrJoinBssParam == NULL) {
1009 PRINT_ER("Required BSSID not found\n");
1014 if (pstrHostIFconnectAttr->bssid != NULL) {
1015 hif_drv->strWILC_UsrConnReq.pu8bssid = kmalloc(6, GFP_KERNEL);
1016 memcpy(hif_drv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->bssid, 6);
1019 hif_drv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssid_len;
1020 if (pstrHostIFconnectAttr->ssid != NULL) {
1021 hif_drv->strWILC_UsrConnReq.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssid_len + 1, GFP_KERNEL);
1022 memcpy(hif_drv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->ssid,
1023 pstrHostIFconnectAttr->ssid_len);
1024 hif_drv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssid_len] = '\0';
1027 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->ies_len;
1028 if (pstrHostIFconnectAttr->ies != NULL) {
1029 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
1030 memcpy(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->ies,
1031 pstrHostIFconnectAttr->ies_len);
1034 hif_drv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->security;
1035 hif_drv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->auth_type;
1036 hif_drv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->result;
1037 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->arg;
1039 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
1040 strWIDList[u32WidsCount].type = WID_INT;
1041 strWIDList[u32WidsCount].size = sizeof(u32);
1042 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1045 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
1046 strWIDList[u32WidsCount].type = WID_INT;
1047 strWIDList[u32WidsCount].size = sizeof(u32);
1048 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1051 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
1052 strWIDList[u32WidsCount].type = WID_INT;
1053 strWIDList[u32WidsCount].size = sizeof(u32);
1054 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1058 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
1059 strWIDList[u32WidsCount].type = WID_BIN_DATA;
1060 strWIDList[u32WidsCount].val = hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs;
1061 strWIDList[u32WidsCount].size = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1064 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1066 gu32FlushedInfoElemAsocSize = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1067 gu8FlushedInfoElemAsoc = kmalloc(gu32FlushedInfoElemAsocSize, GFP_KERNEL);
1068 memcpy(gu8FlushedInfoElemAsoc, hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
1069 gu32FlushedInfoElemAsocSize);
1072 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
1073 strWIDList[u32WidsCount].type = WID_CHAR;
1074 strWIDList[u32WidsCount].size = sizeof(char);
1075 strWIDList[u32WidsCount].val = (s8 *)(&(hif_drv->strWILC_UsrConnReq.u8security));
1078 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
1079 gu8Flushed11iMode = hif_drv->strWILC_UsrConnReq.u8security;
1081 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", hif_drv->strWILC_UsrConnReq.u8security);
1084 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
1085 strWIDList[u32WidsCount].type = WID_CHAR;
1086 strWIDList[u32WidsCount].size = sizeof(char);
1087 strWIDList[u32WidsCount].val = (s8 *)(&hif_drv->strWILC_UsrConnReq.tenuAuth_type);
1090 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
1091 gu8FlushedAuthType = (u8)hif_drv->strWILC_UsrConnReq.tenuAuth_type;
1093 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", hif_drv->strWILC_UsrConnReq.tenuAuth_type);
1094 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
1095 hif_drv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->ch);
1097 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
1098 strWIDList[u32WidsCount].type = WID_STR;
1099 strWIDList[u32WidsCount].size = 112;
1100 strWIDList[u32WidsCount].val = kmalloc(strWIDList[u32WidsCount].size, GFP_KERNEL);
1102 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1103 gu32FlushedJoinReqSize = strWIDList[u32WidsCount].size;
1104 gu8FlushedJoinReq = kmalloc(gu32FlushedJoinReqSize, GFP_KERNEL);
1106 if (strWIDList[u32WidsCount].val == NULL) {
1111 pu8CurrByte = strWIDList[u32WidsCount].val;
1114 if (pstrHostIFconnectAttr->ssid != NULL) {
1115 memcpy(pu8CurrByte, pstrHostIFconnectAttr->ssid, pstrHostIFconnectAttr->ssid_len);
1116 pu8CurrByte[pstrHostIFconnectAttr->ssid_len] = '\0';
1118 pu8CurrByte += MAX_SSID_LEN;
1119 *(pu8CurrByte++) = INFRASTRUCTURE;
1121 if ((pstrHostIFconnectAttr->ch >= 1) && (pstrHostIFconnectAttr->ch <= 14)) {
1122 *(pu8CurrByte++) = pstrHostIFconnectAttr->ch;
1124 PRINT_ER("Channel out of range\n");
1125 *(pu8CurrByte++) = 0xFF;
1127 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1128 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1129 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1131 if (pstrHostIFconnectAttr->bssid != NULL)
1132 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
1135 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1136 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1137 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1138 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1139 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1141 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
1142 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1144 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1145 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1146 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1148 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1149 hif_drv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
1151 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1152 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1153 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1154 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1155 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1156 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1158 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
1159 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1161 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
1162 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1164 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
1165 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1167 *(pu8CurrByte++) = REAL_JOIN_REQ;
1168 *(pu8CurrByte++) = ptstrJoinBssParam->noa_enabled;
1170 if (ptstrJoinBssParam->noa_enabled) {
1171 PRINT_D(HOSTINF_DBG, "NOA present\n");
1173 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1174 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1175 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1176 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1178 *(pu8CurrByte++) = ptstrJoinBssParam->opp_enabled;
1179 *(pu8CurrByte++) = ptstrJoinBssParam->idx;
1181 if (ptstrJoinBssParam->opp_enabled)
1182 *(pu8CurrByte++) = ptstrJoinBssParam->ct_window;
1184 *(pu8CurrByte++) = ptstrJoinBssParam->cnt;
1186 memcpy(pu8CurrByte, ptstrJoinBssParam->duration, sizeof(ptstrJoinBssParam->duration));
1187 pu8CurrByte += sizeof(ptstrJoinBssParam->duration);
1189 memcpy(pu8CurrByte, ptstrJoinBssParam->interval, sizeof(ptstrJoinBssParam->interval));
1190 pu8CurrByte += sizeof(ptstrJoinBssParam->interval);
1192 memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
1194 pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1197 PRINT_D(HOSTINF_DBG, "NOA not present\n");
1199 pu8CurrByte = strWIDList[u32WidsCount].val;
1201 gu32WidConnRstHack = 0;
1203 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1204 memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
1205 gu8FlushedJoinReqDrvHandler = hif_drv;
1208 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1210 if (pstrHostIFconnectAttr->bssid != NULL) {
1211 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->bssid, ETH_ALEN);
1213 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n", pstrHostIFconnectAttr->bssid);
1214 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", u8ConnectedSSID);
1217 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
1218 get_id_from_handler(hif_drv));
1220 PRINT_ER("failed to send config packet\n");
1224 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
1225 hif_drv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1230 tstrConnectInfo strConnectInfo;
1232 del_timer(&hif_drv->hConnectTimer);
1234 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
1236 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1238 if (pstrHostIFconnectAttr->result != NULL) {
1239 if (pstrHostIFconnectAttr->bssid != NULL)
1240 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->bssid, 6);
1242 if (pstrHostIFconnectAttr->ies != NULL) {
1243 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->ies_len;
1244 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
1245 memcpy(strConnectInfo.pu8ReqIEs,
1246 pstrHostIFconnectAttr->ies,
1247 pstrHostIFconnectAttr->ies_len);
1250 pstrHostIFconnectAttr->result(CONN_DISCONN_EVENT_CONN_RESP,
1254 pstrHostIFconnectAttr->arg);
1255 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1256 kfree(strConnectInfo.pu8ReqIEs);
1257 strConnectInfo.pu8ReqIEs = NULL;
1260 PRINT_ER("Connect callback function pointer is NULL\n");
1264 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
1265 kfree(pstrHostIFconnectAttr->bssid);
1266 pstrHostIFconnectAttr->bssid = NULL;
1268 kfree(pstrHostIFconnectAttr->ssid);
1269 pstrHostIFconnectAttr->ssid = NULL;
1271 kfree(pstrHostIFconnectAttr->ies);
1272 pstrHostIFconnectAttr->ies = NULL;
1278 static s32 Handle_FlushConnect(struct host_if_drv *hif_drv)
1281 struct wid strWIDList[5];
1282 u32 u32WidsCount = 0;
1283 u8 *pu8CurrByte = NULL;
1285 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
1286 strWIDList[u32WidsCount].type = WID_BIN_DATA;
1287 strWIDList[u32WidsCount].val = gu8FlushedInfoElemAsoc;
1288 strWIDList[u32WidsCount].size = gu32FlushedInfoElemAsocSize;
1291 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
1292 strWIDList[u32WidsCount].type = WID_CHAR;
1293 strWIDList[u32WidsCount].size = sizeof(char);
1294 strWIDList[u32WidsCount].val = (s8 *)(&(gu8Flushed11iMode));
1299 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
1300 strWIDList[u32WidsCount].type = WID_CHAR;
1301 strWIDList[u32WidsCount].size = sizeof(char);
1302 strWIDList[u32WidsCount].val = (s8 *)(&gu8FlushedAuthType);
1305 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
1306 strWIDList[u32WidsCount].type = WID_STR;
1307 strWIDList[u32WidsCount].size = gu32FlushedJoinReqSize;
1308 strWIDList[u32WidsCount].val = (s8 *)gu8FlushedJoinReq;
1309 pu8CurrByte = strWIDList[u32WidsCount].val;
1311 pu8CurrByte += FLUSHED_BYTE_POS;
1312 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1316 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
1317 get_id_from_handler(gu8FlushedJoinReqDrvHandler));
1319 PRINT_ER("failed to send config packet\n");
1326 static s32 Handle_ConnectTimeout(struct host_if_drv *hif_drv)
1329 tstrConnectInfo strConnectInfo;
1331 u16 u16DummyReasonCode = 0;
1334 PRINT_ER("Driver handler is NULL\n");
1338 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1340 scan_while_connected = false;
1342 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1344 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
1345 if (hif_drv->strWILC_UsrConnReq.pu8bssid != NULL) {
1346 memcpy(strConnectInfo.au8bssid,
1347 hif_drv->strWILC_UsrConnReq.pu8bssid, 6);
1350 if (hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1351 strConnectInfo.ReqIEsLen = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1352 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
1353 memcpy(strConnectInfo.pu8ReqIEs,
1354 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
1355 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen);
1358 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1362 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
1364 kfree(strConnectInfo.pu8ReqIEs);
1365 strConnectInfo.pu8ReqIEs = NULL;
1367 PRINT_ER("Connect callback function pointer is NULL\n");
1370 strWID.id = (u16)WID_DISCONNECT;
1371 strWID.type = WID_CHAR;
1372 strWID.val = (s8 *)&u16DummyReasonCode;
1373 strWID.size = sizeof(char);
1375 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1377 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1378 get_id_from_handler(hif_drv));
1380 PRINT_ER("Failed to send dissconect config packet\n");
1382 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
1383 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
1384 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
1385 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1386 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
1388 eth_zero_addr(u8ConnectedSSID);
1390 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
1391 kfree(gu8FlushedJoinReq);
1392 gu8FlushedJoinReq = NULL;
1394 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
1395 kfree(gu8FlushedInfoElemAsoc);
1396 gu8FlushedInfoElemAsoc = NULL;
1402 static s32 Handle_RcvdNtwrkInfo(struct host_if_drv *hif_drv,
1403 struct rcvd_net_info *pstrRcvdNetworkInfo)
1406 bool bNewNtwrkFound;
1411 tstrNetworkInfo *pstrNetworkInfo = NULL;
1412 void *pJoinParams = NULL;
1414 bNewNtwrkFound = true;
1415 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
1417 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
1418 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
1419 parse_network_info(pstrRcvdNetworkInfo->buffer, &pstrNetworkInfo);
1420 if ((pstrNetworkInfo == NULL)
1421 || (hif_drv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
1422 PRINT_ER("driver is null\n");
1427 for (i = 0; i < hif_drv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
1429 if ((hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
1430 (pstrNetworkInfo->au8bssid != NULL)) {
1431 if (memcmp(hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
1432 pstrNetworkInfo->au8bssid, 6) == 0) {
1433 if (pstrNetworkInfo->s8rssi <= hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
1434 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
1437 hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
1438 bNewNtwrkFound = false;
1445 if (bNewNtwrkFound == true) {
1446 PRINT_D(HOSTINF_DBG, "New network found\n");
1448 if (hif_drv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
1449 hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
1451 if ((hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
1452 && (pstrNetworkInfo->au8bssid != NULL)) {
1453 memcpy(hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
1454 pstrNetworkInfo->au8bssid, 6);
1456 hif_drv->strWILC_UsrScanReq.u32RcvdChCount++;
1458 pstrNetworkInfo->bNewNetwork = true;
1459 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
1461 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1462 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid,
1468 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
1471 pstrNetworkInfo->bNewNetwork = false;
1472 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1473 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
1478 kfree(pstrRcvdNetworkInfo->buffer);
1479 pstrRcvdNetworkInfo->buffer = NULL;
1481 if (pstrNetworkInfo != NULL) {
1482 DeallocateNetworkInfo(pstrNetworkInfo);
1483 pstrNetworkInfo = NULL;
1489 static s32 Handle_RcvdGnrlAsyncInfo(struct host_if_drv *hif_drv,
1490 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
1496 u16 u16WidID = (u16)WID_NIL;
1499 u8 u8MacStatusReasonCode;
1500 u8 u8MacStatusAdditionalInfo;
1501 tstrConnectInfo strConnectInfo;
1502 tstrDisconnectNotifInfo strDisconnectNotifInfo;
1506 PRINT_ER("Driver handler is NULL\n");
1509 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", hif_drv->enuHostIFstate,
1510 pstrRcvdGnrlAsyncInfo->buffer[7]);
1512 if ((hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
1513 (hif_drv->enuHostIFstate == HOST_IF_CONNECTED) ||
1514 hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
1515 if ((pstrRcvdGnrlAsyncInfo->buffer == NULL) ||
1516 (hif_drv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
1517 PRINT_ER("driver is null\n");
1521 u8MsgType = pstrRcvdGnrlAsyncInfo->buffer[0];
1523 if ('I' != u8MsgType) {
1524 PRINT_ER("Received Message format incorrect.\n");
1528 u8MsgID = pstrRcvdGnrlAsyncInfo->buffer[1];
1529 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[2], pstrRcvdGnrlAsyncInfo->buffer[3]);
1530 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[4], pstrRcvdGnrlAsyncInfo->buffer[5]);
1531 u8WidLen = pstrRcvdGnrlAsyncInfo->buffer[6];
1532 u8MacStatus = pstrRcvdGnrlAsyncInfo->buffer[7];
1533 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->buffer[8];
1534 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->buffer[9];
1535 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
1536 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
1537 u32 u32RcvdAssocRespInfoLen;
1538 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
1540 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
1542 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1544 if (u8MacStatus == MAC_CONNECTED) {
1545 memset(rcv_assoc_resp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
1547 host_int_get_assoc_res_info(hif_drv,
1549 MAX_ASSOC_RESP_FRAME_SIZE,
1550 &u32RcvdAssocRespInfoLen);
1552 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
1554 if (u32RcvdAssocRespInfoLen != 0) {
1556 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
1557 s32Err = ParseAssocRespInfo(rcv_assoc_resp, u32RcvdAssocRespInfoLen,
1558 &pstrConnectRespInfo);
1560 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
1562 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
1564 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
1565 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
1566 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
1567 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
1570 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL);
1571 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
1572 pstrConnectRespInfo->u16RespIEsLen);
1576 if (pstrConnectRespInfo != NULL) {
1577 DeallocateAssocRespInfo(pstrConnectRespInfo);
1578 pstrConnectRespInfo = NULL;
1584 if ((u8MacStatus == MAC_CONNECTED) &&
1585 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
1586 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
1587 eth_zero_addr(u8ConnectedSSID);
1589 } else if (u8MacStatus == MAC_DISCONNECTED) {
1590 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
1591 eth_zero_addr(u8ConnectedSSID);
1594 if (hif_drv->strWILC_UsrConnReq.pu8bssid != NULL) {
1595 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
1596 memcpy(strConnectInfo.au8bssid, hif_drv->strWILC_UsrConnReq.pu8bssid, 6);
1598 if ((u8MacStatus == MAC_CONNECTED) &&
1599 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
1600 memcpy(hif_drv->au8AssociatedBSSID,
1601 hif_drv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
1606 if (hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1607 strConnectInfo.ReqIEsLen = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1608 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
1609 memcpy(strConnectInfo.pu8ReqIEs,
1610 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
1611 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen);
1615 del_timer(&hif_drv->hConnectTimer);
1616 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1620 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
1622 if ((u8MacStatus == MAC_CONNECTED) &&
1623 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
1624 host_int_set_power_mgmt(hif_drv, 0, 0);
1626 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
1627 hif_drv->enuHostIFstate = HOST_IF_CONNECTED;
1629 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
1630 g_obtainingIP = true;
1631 mod_timer(&hDuringIpTimer,
1632 jiffies + msecs_to_jiffies(10000));
1634 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
1635 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1636 scan_while_connected = false;
1639 kfree(strConnectInfo.pu8RespIEs);
1640 strConnectInfo.pu8RespIEs = NULL;
1642 kfree(strConnectInfo.pu8ReqIEs);
1643 strConnectInfo.pu8ReqIEs = NULL;
1644 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
1645 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
1646 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
1647 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1648 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
1649 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
1650 (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)) {
1651 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
1653 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
1655 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
1656 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
1657 del_timer(&hif_drv->hScanTimer);
1658 Handle_ScanDone((void *)hif_drv, SCAN_EVENT_ABORTED);
1661 strDisconnectNotifInfo.u16reason = 0;
1662 strDisconnectNotifInfo.ie = NULL;
1663 strDisconnectNotifInfo.ie_len = 0;
1665 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
1666 g_obtainingIP = false;
1667 host_int_set_power_mgmt(hif_drv, 0, 0);
1669 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1672 &strDisconnectNotifInfo,
1673 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
1676 PRINT_ER("Connect result callback function is NULL\n");
1679 eth_zero_addr(hif_drv->au8AssociatedBSSID);
1681 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
1682 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
1683 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
1684 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1685 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
1687 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
1688 kfree(gu8FlushedJoinReq);
1689 gu8FlushedJoinReq = NULL;
1691 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
1692 kfree(gu8FlushedInfoElemAsoc);
1693 gu8FlushedInfoElemAsoc = NULL;
1696 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1697 scan_while_connected = false;
1699 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
1700 (hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
1701 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
1702 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
1704 del_timer(&hif_drv->hScanTimer);
1705 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult)
1706 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
1712 kfree(pstrRcvdGnrlAsyncInfo->buffer);
1713 pstrRcvdGnrlAsyncInfo->buffer = NULL;
1718 static int Handle_Key(struct host_if_drv *hif_drv,
1719 struct key_attr *pstrHostIFkeyAttr)
1723 struct wid strWIDList[5];
1729 switch (pstrHostIFkeyAttr->type) {
1734 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1736 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
1737 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->attr.wep.index));
1738 strWIDList[0].id = (u16)WID_11I_MODE;
1739 strWIDList[0].type = WID_CHAR;
1740 strWIDList[0].size = sizeof(char);
1741 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.mode));
1743 strWIDList[1].id = WID_AUTH_TYPE;
1744 strWIDList[1].type = WID_CHAR;
1745 strWIDList[1].size = sizeof(char);
1746 strWIDList[1].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.auth_type));
1748 strWIDList[2].id = (u16)WID_KEY_ID;
1749 strWIDList[2].type = WID_CHAR;
1751 strWIDList[2].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.index));
1752 strWIDList[2].size = sizeof(char);
1754 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len, GFP_KERNEL);
1756 if (pu8keybuf == NULL) {
1757 PRINT_ER("No buffer to send Key\n");
1761 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wep.key,
1762 pstrHostIFkeyAttr->attr.wep.key_len);
1764 kfree(pstrHostIFkeyAttr->attr.wep.key);
1766 strWIDList[3].id = (u16)WID_WEP_KEY_VALUE;
1767 strWIDList[3].type = WID_STR;
1768 strWIDList[3].size = pstrHostIFkeyAttr->attr.wep.key_len;
1769 strWIDList[3].val = (s8 *)pu8keybuf;
1772 s32Error = send_config_pkt(SET_CFG, strWIDList, 4,
1773 get_id_from_handler(hif_drv));
1779 if (pstrHostIFkeyAttr->action & ADDKEY) {
1780 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
1781 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2, GFP_KERNEL);
1782 if (pu8keybuf == NULL) {
1783 PRINT_ER("No buffer to send Key\n");
1786 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1787 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->attr.wep.key_len, 1);
1788 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->attr.wep.key,
1789 pstrHostIFkeyAttr->attr.wep.key_len);
1790 kfree(pstrHostIFkeyAttr->attr.wep.key);
1792 strWID.id = (u16)WID_ADD_WEP_KEY;
1793 strWID.type = WID_STR;
1794 strWID.val = (s8 *)pu8keybuf;
1795 strWID.size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
1797 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1798 get_id_from_handler(hif_drv));
1800 } else if (pstrHostIFkeyAttr->action & REMOVEKEY) {
1802 PRINT_D(HOSTINF_DBG, "Removing key\n");
1803 strWID.id = (u16)WID_REMOVE_WEP_KEY;
1804 strWID.type = WID_STR;
1806 s8idxarray[0] = (s8)pstrHostIFkeyAttr->attr.wep.index;
1807 strWID.val = s8idxarray;
1810 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1811 get_id_from_handler(hif_drv));
1813 strWID.id = (u16)WID_KEY_ID;
1814 strWID.type = WID_CHAR;
1815 strWID.val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.index));
1816 strWID.size = sizeof(char);
1818 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
1820 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1821 get_id_from_handler(hif_drv));
1823 up(&hif_drv->hSemTestKeyBlock);
1827 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1828 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1829 if (pu8keybuf == NULL) {
1830 PRINT_ER("No buffer to send RxGTK Key\n");
1832 goto _WPARxGtk_end_case_;
1835 if (pstrHostIFkeyAttr->attr.wpa.seq != NULL)
1836 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1838 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1839 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1840 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1841 pstrHostIFkeyAttr->attr.wpa.key_len);
1843 strWIDList[0].id = (u16)WID_11I_MODE;
1844 strWIDList[0].type = WID_CHAR;
1845 strWIDList[0].size = sizeof(char);
1846 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wpa.mode));
1848 strWIDList[1].id = (u16)WID_ADD_RX_GTK;
1849 strWIDList[1].type = WID_STR;
1850 strWIDList[1].val = (s8 *)pu8keybuf;
1851 strWIDList[1].size = RX_MIC_KEY_MSG_LEN;
1853 s32Error = send_config_pkt(SET_CFG, strWIDList, 2,
1854 get_id_from_handler(hif_drv));
1857 up(&hif_drv->hSemTestKeyBlock);
1860 if (pstrHostIFkeyAttr->action & ADDKEY) {
1861 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
1863 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1864 if (pu8keybuf == NULL) {
1865 PRINT_ER("No buffer to send RxGTK Key\n");
1867 goto _WPARxGtk_end_case_;
1870 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)
1871 memcpy(pu8keybuf, hif_drv->au8AssociatedBSSID, ETH_ALEN);
1873 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
1875 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1876 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1877 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1878 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1879 pstrHostIFkeyAttr->attr.wpa.key_len);
1881 strWID.id = (u16)WID_ADD_RX_GTK;
1882 strWID.type = WID_STR;
1883 strWID.val = (s8 *)pu8keybuf;
1884 strWID.size = RX_MIC_KEY_MSG_LEN;
1886 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1887 get_id_from_handler(hif_drv));
1890 up(&hif_drv->hSemTestKeyBlock);
1892 _WPARxGtk_end_case_:
1893 kfree(pstrHostIFkeyAttr->attr.wpa.key);
1894 kfree(pstrHostIFkeyAttr->attr.wpa.seq);
1901 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1904 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
1908 if (pu8keybuf == NULL) {
1909 PRINT_ER("No buffer to send PTK Key\n");
1911 goto _WPAPtk_end_case_;
1915 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1916 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1917 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1918 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->attr.wpa.key,
1919 pstrHostIFkeyAttr->attr.wpa.key_len);
1921 strWIDList[0].id = (u16)WID_11I_MODE;
1922 strWIDList[0].type = WID_CHAR;
1923 strWIDList[0].size = sizeof(char);
1924 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wpa.mode));
1926 strWIDList[1].id = (u16)WID_ADD_PTK;
1927 strWIDList[1].type = WID_STR;
1928 strWIDList[1].val = (s8 *)pu8keybuf;
1929 strWIDList[1].size = PTK_KEY_MSG_LEN + 1;
1931 s32Error = send_config_pkt(SET_CFG, strWIDList, 2,
1932 get_id_from_handler(hif_drv));
1934 up(&hif_drv->hSemTestKeyBlock);
1936 if (pstrHostIFkeyAttr->action & ADDKEY) {
1939 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
1943 if (pu8keybuf == NULL) {
1944 PRINT_ER("No buffer to send PTK Key\n");
1946 goto _WPAPtk_end_case_;
1950 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1951 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1952 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->attr.wpa.key,
1953 pstrHostIFkeyAttr->attr.wpa.key_len);
1955 strWID.id = (u16)WID_ADD_PTK;
1956 strWID.type = WID_STR;
1957 strWID.val = (s8 *)pu8keybuf;
1958 strWID.size = PTK_KEY_MSG_LEN;
1960 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1961 get_id_from_handler(hif_drv));
1963 up(&hif_drv->hSemTestKeyBlock);
1967 kfree(pstrHostIFkeyAttr->attr.wpa.key);
1976 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
1978 pu8keybuf = kmalloc((pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
1979 if (pu8keybuf == NULL) {
1980 PRINT_ER("No buffer to send PMKSA Key\n");
1984 pu8keybuf[0] = pstrHostIFkeyAttr->attr.pmkid.numpmkid;
1986 for (i = 0; i < pstrHostIFkeyAttr->attr.pmkid.numpmkid; i++) {
1987 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
1988 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
1991 strWID.id = (u16)WID_PMKID_INFO;
1992 strWID.type = WID_STR;
1993 strWID.val = (s8 *)pu8keybuf;
1994 strWID.size = (pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
1996 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1997 get_id_from_handler(hif_drv));
2004 PRINT_ER("Failed to send key config packet\n");
2010 static void Handle_Disconnect(struct host_if_drv *hif_drv)
2015 u16 u16DummyReasonCode = 0;
2017 strWID.id = (u16)WID_DISCONNECT;
2018 strWID.type = WID_CHAR;
2019 strWID.val = (s8 *)&u16DummyReasonCode;
2020 strWID.size = sizeof(char);
2024 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2026 g_obtainingIP = false;
2027 host_int_set_power_mgmt(hif_drv, 0, 0);
2029 eth_zero_addr(u8ConnectedSSID);
2031 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2032 get_id_from_handler(hif_drv));
2035 PRINT_ER("Failed to send dissconect config packet\n");
2037 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2039 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
2041 strDisconnectNotifInfo.u16reason = 0;
2042 strDisconnectNotifInfo.ie = NULL;
2043 strDisconnectNotifInfo.ie_len = 0;
2045 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
2046 del_timer(&hif_drv->hScanTimer);
2047 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
2048 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2050 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
2053 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2054 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2055 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
2056 del_timer(&hif_drv->hConnectTimer);
2059 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
2060 0, &strDisconnectNotifInfo, hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
2062 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
2065 scan_while_connected = false;
2067 hif_drv->enuHostIFstate = HOST_IF_IDLE;
2069 eth_zero_addr(hif_drv->au8AssociatedBSSID);
2071 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
2072 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
2073 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
2074 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2075 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
2077 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
2078 kfree(gu8FlushedJoinReq);
2079 gu8FlushedJoinReq = NULL;
2081 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
2082 kfree(gu8FlushedInfoElemAsoc);
2083 gu8FlushedInfoElemAsoc = NULL;
2088 up(&hif_drv->hSemTestDisconnectBlock);
2092 void resolve_disconnect_aberration(struct host_if_drv *hif_drv)
2096 if ((hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (hif_drv->enuHostIFstate == HOST_IF_CONNECTING)) {
2097 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
2098 host_int_disconnect(hif_drv, 1);
2102 static s32 Handle_GetChnl(struct host_if_drv *hif_drv)
2108 strWID.id = (u16)WID_CURRENT_CHANNEL;
2109 strWID.type = WID_CHAR;
2110 strWID.val = (s8 *)&gu8Chnl;
2111 strWID.size = sizeof(char);
2113 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
2115 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2116 get_id_from_handler(hif_drv));
2119 PRINT_ER("Failed to get channel number\n");
2123 up(&hif_drv->hSemGetCHNL);
2131 static void Handle_GetRssi(struct host_if_drv *hif_drv)
2136 strWID.id = (u16)WID_RSSI;
2137 strWID.type = WID_CHAR;
2139 strWID.size = sizeof(char);
2141 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
2143 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2144 get_id_from_handler(hif_drv));
2146 PRINT_ER("Failed to get RSSI value\n");
2150 up(&hif_drv->hSemGetRSSI);
2156 static void Handle_GetLinkspeed(struct host_if_drv *hif_drv)
2163 strWID.id = (u16)WID_LINKSPEED;
2164 strWID.type = WID_CHAR;
2165 strWID.val = &link_speed;
2166 strWID.size = sizeof(char);
2168 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
2170 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2171 get_id_from_handler(hif_drv));
2173 PRINT_ER("Failed to get LINKSPEED value\n");
2177 up(&(hif_drv->hSemGetLINKSPEED));
2182 s32 Handle_GetStatistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
2184 struct wid strWIDList[5];
2185 u32 u32WidsCount = 0, s32Error = 0;
2187 strWIDList[u32WidsCount].id = WID_LINKSPEED;
2188 strWIDList[u32WidsCount].type = WID_CHAR;
2189 strWIDList[u32WidsCount].size = sizeof(char);
2190 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u8LinkSpeed));
2193 strWIDList[u32WidsCount].id = WID_RSSI;
2194 strWIDList[u32WidsCount].type = WID_CHAR;
2195 strWIDList[u32WidsCount].size = sizeof(char);
2196 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->s8RSSI));
2199 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
2200 strWIDList[u32WidsCount].type = WID_INT;
2201 strWIDList[u32WidsCount].size = sizeof(u32);
2202 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32TxCount));
2205 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
2206 strWIDList[u32WidsCount].type = WID_INT;
2207 strWIDList[u32WidsCount].size = sizeof(u32);
2208 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32RxCount));
2211 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
2212 strWIDList[u32WidsCount].type = WID_INT;
2213 strWIDList[u32WidsCount].size = sizeof(u32);
2214 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32TxFailureCount));
2217 s32Error = send_config_pkt(GET_CFG, strWIDList, u32WidsCount,
2218 get_id_from_handler(hif_drv));
2221 PRINT_ER("Failed to send scan paramters config packet\n");
2223 up(&hif_sema_wait_response);
2228 static s32 Handle_Get_InActiveTime(struct host_if_drv *hif_drv,
2229 struct sta_inactive_t *strHostIfStaInactiveT)
2236 strWID.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
2237 strWID.type = WID_STR;
2238 strWID.size = ETH_ALEN;
2239 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2242 stamac = strWID.val;
2243 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
2246 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
2249 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2250 get_id_from_handler(hif_drv));
2253 PRINT_ER("Failed to SET incative time\n");
2258 strWID.id = (u16)WID_GET_INACTIVE_TIME;
2259 strWID.type = WID_INT;
2260 strWID.val = (s8 *)&gu32InactiveTime;
2261 strWID.size = sizeof(u32);
2264 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2265 get_id_from_handler(hif_drv));
2268 PRINT_ER("Failed to get incative time\n");
2273 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
2275 up(&hif_drv->hSemInactiveTime);
2283 static void Handle_AddBeacon(struct host_if_drv *hif_drv,
2284 struct beacon_attr *pstrSetBeaconParam)
2290 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
2292 strWID.id = (u16)WID_ADD_BEACON;
2293 strWID.type = WID_BIN;
2294 strWID.size = pstrSetBeaconParam->head_len + pstrSetBeaconParam->tail_len + 16;
2295 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2296 if (strWID.val == NULL)
2299 pu8CurrByte = strWID.val;
2300 *pu8CurrByte++ = (pstrSetBeaconParam->interval & 0xFF);
2301 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 8) & 0xFF);
2302 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 16) & 0xFF);
2303 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 24) & 0xFF);
2305 *pu8CurrByte++ = (pstrSetBeaconParam->dtim_period & 0xFF);
2306 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 8) & 0xFF);
2307 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 16) & 0xFF);
2308 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 24) & 0xFF);
2310 *pu8CurrByte++ = (pstrSetBeaconParam->head_len & 0xFF);
2311 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 8) & 0xFF);
2312 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 16) & 0xFF);
2313 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 24) & 0xFF);
2315 memcpy(pu8CurrByte, pstrSetBeaconParam->head, pstrSetBeaconParam->head_len);
2316 pu8CurrByte += pstrSetBeaconParam->head_len;
2318 *pu8CurrByte++ = (pstrSetBeaconParam->tail_len & 0xFF);
2319 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 8) & 0xFF);
2320 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 16) & 0xFF);
2321 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 24) & 0xFF);
2323 if (pstrSetBeaconParam->tail > 0)
2324 memcpy(pu8CurrByte, pstrSetBeaconParam->tail, pstrSetBeaconParam->tail_len);
2325 pu8CurrByte += pstrSetBeaconParam->tail_len;
2327 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2328 get_id_from_handler(hif_drv));
2330 PRINT_ER("Failed to send add beacon config packet\n");
2334 kfree(pstrSetBeaconParam->head);
2335 kfree(pstrSetBeaconParam->tail);
2338 static void Handle_DelBeacon(struct host_if_drv *hif_drv)
2344 strWID.id = (u16)WID_DEL_BEACON;
2345 strWID.type = WID_CHAR;
2346 strWID.size = sizeof(char);
2347 strWID.val = &gu8DelBcn;
2349 if (strWID.val == NULL)
2352 pu8CurrByte = strWID.val;
2354 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
2356 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2357 get_id_from_handler(hif_drv));
2359 PRINT_ER("Failed to send delete beacon config packet\n");
2362 static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
2363 struct add_sta_param *pstrStationParam)
2367 pu8CurrByte = pu8Buffer;
2369 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
2370 memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
2371 pu8CurrByte += ETH_ALEN;
2373 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
2374 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
2376 *pu8CurrByte++ = pstrStationParam->u8NumRates;
2377 if (pstrStationParam->u8NumRates > 0)
2378 memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
2379 pu8CurrByte += pstrStationParam->u8NumRates;
2381 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
2382 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
2383 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
2385 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
2386 memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
2387 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
2389 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
2390 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
2392 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
2393 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
2394 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
2395 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
2397 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
2399 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
2400 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
2402 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
2403 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
2405 return pu8CurrByte - pu8Buffer;
2408 static void Handle_AddStation(struct host_if_drv *hif_drv,
2409 struct add_sta_param *pstrStationParam)
2415 PRINT_D(HOSTINF_DBG, "Handling add station\n");
2416 strWID.id = (u16)WID_ADD_STA;
2417 strWID.type = WID_BIN;
2418 strWID.size = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
2420 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2421 if (strWID.val == NULL)
2424 pu8CurrByte = strWID.val;
2425 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2427 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2428 get_id_from_handler(hif_drv));
2430 PRINT_ER("Failed to send add station config packet\n");
2433 kfree(pstrStationParam->pu8Rates);
2437 static void Handle_DelAllSta(struct host_if_drv *hif_drv,
2438 struct del_all_sta *pstrDelAllStaParam)
2445 u8 au8Zero_Buff[6] = {0};
2447 strWID.id = (u16)WID_DEL_ALL_STA;
2448 strWID.type = WID_STR;
2449 strWID.size = (pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1;
2451 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
2453 strWID.val = kmalloc((pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1, GFP_KERNEL);
2454 if (strWID.val == NULL)
2457 pu8CurrByte = strWID.val;
2459 *(pu8CurrByte++) = pstrDelAllStaParam->assoc_sta;
2461 for (i = 0; i < MAX_NUM_STA; i++) {
2462 if (memcmp(pstrDelAllStaParam->del_all_sta[i], au8Zero_Buff, ETH_ALEN))
2463 memcpy(pu8CurrByte, pstrDelAllStaParam->del_all_sta[i], ETH_ALEN);
2467 pu8CurrByte += ETH_ALEN;
2470 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2471 get_id_from_handler(hif_drv));
2473 PRINT_ER("Failed to send add station config packet\n");
2478 up(&hif_sema_wait_response);
2481 static void Handle_DelStation(struct host_if_drv *hif_drv,
2482 struct del_sta *pstrDelStaParam)
2488 strWID.id = (u16)WID_REMOVE_STA;
2489 strWID.type = WID_BIN;
2490 strWID.size = ETH_ALEN;
2492 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
2494 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2495 if (strWID.val == NULL)
2498 pu8CurrByte = strWID.val;
2500 memcpy(pu8CurrByte, pstrDelStaParam->mac_addr, ETH_ALEN);
2502 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2503 get_id_from_handler(hif_drv));
2505 PRINT_ER("Failed to send add station config packet\n");
2511 static void Handle_EditStation(struct host_if_drv *hif_drv,
2512 struct add_sta_param *pstrStationParam)
2518 strWID.id = (u16)WID_EDIT_STA;
2519 strWID.type = WID_BIN;
2520 strWID.size = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
2522 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
2523 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2524 if (strWID.val == NULL)
2527 pu8CurrByte = strWID.val;
2528 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2530 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2531 get_id_from_handler(hif_drv));
2533 PRINT_ER("Failed to send edit station config packet\n");
2536 kfree(pstrStationParam->pu8Rates);
2540 static int Handle_RemainOnChan(struct host_if_drv *hif_drv,
2541 struct remain_ch *pstrHostIfRemainOnChan)
2544 u8 u8remain_on_chan_flag;
2547 if (!hif_drv->u8RemainOnChan_pendingreq) {
2548 hif_drv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
2549 hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
2550 hif_drv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
2551 hif_drv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
2552 hif_drv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
2554 pstrHostIfRemainOnChan->u16Channel = hif_drv->strHostIfRemainOnChan.u16Channel;
2557 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
2558 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
2559 hif_drv->u8RemainOnChan_pendingreq = 1;
2563 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2564 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
2569 if (g_obtainingIP || connecting) {
2570 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
2575 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
2577 u8remain_on_chan_flag = true;
2578 strWID.id = (u16)WID_REMAIN_ON_CHAN;
2579 strWID.type = WID_STR;
2581 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2583 if (strWID.val == NULL) {
2588 strWID.val[0] = u8remain_on_chan_flag;
2589 strWID.val[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
2591 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2592 get_id_from_handler(hif_drv));
2594 PRINT_ER("Failed to set remain on channel\n");
2598 P2P_LISTEN_STATE = 1;
2599 hif_drv->hRemainOnChannel.data = (unsigned long)hif_drv;
2600 mod_timer(&hif_drv->hRemainOnChannel,
2602 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
2604 if (hif_drv->strHostIfRemainOnChan.pRemainOnChanReady)
2605 hif_drv->strHostIfRemainOnChan.pRemainOnChanReady(hif_drv->strHostIfRemainOnChan.pVoid);
2607 if (hif_drv->u8RemainOnChan_pendingreq)
2608 hif_drv->u8RemainOnChan_pendingreq = 0;
2613 static int Handle_RegisterFrame(struct host_if_drv *hif_drv,
2614 struct reg_frame *pstrHostIfRegisterFrame)
2620 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
2622 strWID.id = (u16)WID_REGISTER_FRAME;
2623 strWID.type = WID_STR;
2624 strWID.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
2625 if (strWID.val == NULL)
2628 pu8CurrByte = strWID.val;
2630 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
2631 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
2632 memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
2635 strWID.size = sizeof(u16) + 2;
2637 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2638 get_id_from_handler(hif_drv));
2640 PRINT_ER("Failed to frame register config packet\n");
2648 #define FALSE_FRMWR_CHANNEL 100
2649 static u32 Handle_ListenStateExpired(struct host_if_drv *hif_drv,
2650 struct remain_ch *pstrHostIfRemainOnChan)
2652 u8 u8remain_on_chan_flag;
2656 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
2658 if (P2P_LISTEN_STATE) {
2659 u8remain_on_chan_flag = false;
2660 strWID.id = (u16)WID_REMAIN_ON_CHAN;
2661 strWID.type = WID_STR;
2663 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2665 if (strWID.val == NULL)
2666 PRINT_ER("Failed to allocate memory\n");
2668 strWID.val[0] = u8remain_on_chan_flag;
2669 strWID.val[1] = FALSE_FRMWR_CHANNEL;
2671 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2672 get_id_from_handler(hif_drv));
2673 if (s32Error != 0) {
2674 PRINT_ER("Failed to set remain on channel\n");
2678 if (hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired) {
2679 hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired(hif_drv->strHostIfRemainOnChan.pVoid
2680 , pstrHostIfRemainOnChan->u32ListenSessionID);
2682 P2P_LISTEN_STATE = 0;
2684 PRINT_D(GENERIC_DBG, "Not in listen state\n");
2692 static void ListenTimerCB(unsigned long arg)
2695 struct host_if_msg msg;
2696 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
2698 del_timer(&hif_drv->hRemainOnChannel);
2700 memset(&msg, 0, sizeof(struct host_if_msg));
2701 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
2703 msg.body.remain_on_ch.u32ListenSessionID = hif_drv->strHostIfRemainOnChan.u32ListenSessionID;
2705 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2707 PRINT_ER("wilc_mq_send fail\n");
2710 static void Handle_PowerManagement(struct host_if_drv *hif_drv,
2711 struct power_mgmt_param *strPowerMgmtParam)
2717 strWID.id = (u16)WID_POWER_MANAGEMENT;
2719 if (strPowerMgmtParam->enabled == true)
2720 s8PowerMode = MIN_FAST_PS;
2722 s8PowerMode = NO_POWERSAVE;
2723 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
2724 strWID.val = &s8PowerMode;
2725 strWID.size = sizeof(char);
2727 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
2729 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2730 get_id_from_handler(hif_drv));
2732 PRINT_ER("Failed to send power management config packet\n");
2735 static void Handle_SetMulticastFilter(struct host_if_drv *hif_drv,
2736 struct set_multicast *strHostIfSetMulti)
2742 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
2744 strWID.id = (u16)WID_SETUP_MULTICAST_FILTER;
2745 strWID.type = WID_BIN;
2746 strWID.size = sizeof(struct set_multicast) + ((strHostIfSetMulti->cnt) * ETH_ALEN);
2747 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2748 if (strWID.val == NULL)
2751 pu8CurrByte = strWID.val;
2752 *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF);
2753 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 8) & 0xFF);
2754 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 16) & 0xFF);
2755 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 24) & 0xFF);
2757 *pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF);
2758 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF);
2759 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 16) & 0xFF);
2760 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 24) & 0xFF);
2762 if ((strHostIfSetMulti->cnt) > 0)
2763 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->cnt) * ETH_ALEN));
2765 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2766 get_id_from_handler(hif_drv));
2768 PRINT_ER("Failed to send setup multicast config packet\n");
2775 static s32 Handle_AddBASession(struct host_if_drv *hif_drv,
2776 struct ba_session_info *strHostIfBASessionInfo)
2780 int AddbaTimeout = 100;
2783 PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\nBufferSize == %d\nSessionTimeOut = %d\n",
2784 strHostIfBASessionInfo->au8Bssid[0],
2785 strHostIfBASessionInfo->au8Bssid[1],
2786 strHostIfBASessionInfo->au8Bssid[2],
2787 strHostIfBASessionInfo->u16BufferSize,
2788 strHostIfBASessionInfo->u16SessionTimeout,
2789 strHostIfBASessionInfo->u8Ted);
2791 strWID.id = (u16)WID_11E_P_ACTION_REQ;
2792 strWID.type = WID_STR;
2793 strWID.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2794 strWID.size = BLOCK_ACK_REQ_SIZE;
2799 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2801 *ptr++ = strHostIfBASessionInfo->u8Ted;
2803 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
2804 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
2805 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
2806 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
2807 *ptr++ = (AddbaTimeout & 0xFF);
2808 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
2812 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2813 get_id_from_handler(hif_drv));
2815 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
2818 strWID.id = (u16)WID_11E_P_ACTION_REQ;
2819 strWID.type = WID_STR;
2825 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2827 *ptr++ = strHostIfBASessionInfo->u8Ted;
2829 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
2830 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
2832 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2833 get_id_from_handler(hif_drv));
2841 static s32 Handle_DelAllRxBASessions(struct host_if_drv *hif_drv,
2842 struct ba_session_info *strHostIfBASessionInfo)
2848 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
2849 strHostIfBASessionInfo->au8Bssid[0],
2850 strHostIfBASessionInfo->au8Bssid[1],
2851 strHostIfBASessionInfo->au8Bssid[2],
2852 strHostIfBASessionInfo->u8Ted);
2854 strWID.id = (u16)WID_DEL_ALL_RX_BA;
2855 strWID.type = WID_STR;
2856 strWID.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2857 strWID.size = BLOCK_ACK_REQ_SIZE;
2862 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2864 *ptr++ = strHostIfBASessionInfo->u8Ted;
2868 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2869 get_id_from_handler(hif_drv));
2871 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
2876 up(&hif_sema_wait_response);
2882 static int hostIFthread(void *pvArg)
2885 struct host_if_msg msg;
2886 struct host_if_drv *hif_drv;
2888 memset(&msg, 0, sizeof(struct host_if_msg));
2891 wilc_mq_recv(&hif_msg_q, &msg, sizeof(struct host_if_msg), &u32Ret);
2892 hif_drv = (struct host_if_drv *)msg.drv;
2893 if (msg.id == HOST_IF_MSG_EXIT) {
2894 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
2898 if ((!g_wilc_initialized)) {
2899 PRINT_D(GENERIC_DBG, "--WAIT--");
2900 usleep_range(200 * 1000, 200 * 1000);
2901 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2905 if (msg.id == HOST_IF_MSG_CONNECT && hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
2906 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
2907 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2908 usleep_range(2 * 1000, 2 * 1000);
2913 case HOST_IF_MSG_Q_IDLE:
2914 Handle_wait_msg_q_empty();
2917 case HOST_IF_MSG_SCAN:
2918 Handle_Scan(msg.drv, &msg.body.scan_info);
2921 case HOST_IF_MSG_CONNECT:
2922 Handle_Connect(msg.drv, &msg.body.con_info);
2925 case HOST_IF_MSG_FLUSH_CONNECT:
2926 Handle_FlushConnect(msg.drv);
2929 case HOST_IF_MSG_RCVD_NTWRK_INFO:
2930 Handle_RcvdNtwrkInfo(msg.drv, &msg.body.net_info);
2933 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
2934 Handle_RcvdGnrlAsyncInfo(msg.drv, &msg.body.async_info);
2937 case HOST_IF_MSG_KEY:
2938 Handle_Key(msg.drv, &msg.body.key_info);
2941 case HOST_IF_MSG_CFG_PARAMS:
2943 Handle_CfgParam(msg.drv, &msg.body.cfg_info);
2946 case HOST_IF_MSG_SET_CHANNEL:
2947 Handle_SetChannel(msg.drv, &msg.body.channel_info);
2950 case HOST_IF_MSG_DISCONNECT:
2951 Handle_Disconnect(msg.drv);
2954 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
2955 del_timer(&hif_drv->hScanTimer);
2956 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
2958 if (!linux_wlan_get_num_conn_ifcs())
2959 chip_sleep_manually(INFINITE_SLEEP_TIME);
2961 Handle_ScanDone(msg.drv, SCAN_EVENT_DONE);
2963 if (hif_drv->u8RemainOnChan_pendingreq)
2964 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
2968 case HOST_IF_MSG_GET_RSSI:
2969 Handle_GetRssi(msg.drv);
2972 case HOST_IF_MSG_GET_LINKSPEED:
2973 Handle_GetLinkspeed(msg.drv);
2976 case HOST_IF_MSG_GET_STATISTICS:
2977 Handle_GetStatistics(msg.drv, (struct rf_info *)msg.body.data);
2980 case HOST_IF_MSG_GET_CHNL:
2981 Handle_GetChnl(msg.drv);
2984 case HOST_IF_MSG_ADD_BEACON:
2985 Handle_AddBeacon(msg.drv, &msg.body.beacon_info);
2988 case HOST_IF_MSG_DEL_BEACON:
2989 Handle_DelBeacon(msg.drv);
2992 case HOST_IF_MSG_ADD_STATION:
2993 Handle_AddStation(msg.drv, &msg.body.add_sta_info);
2996 case HOST_IF_MSG_DEL_STATION:
2997 Handle_DelStation(msg.drv, &msg.body.del_sta_info);
3000 case HOST_IF_MSG_EDIT_STATION:
3001 Handle_EditStation(msg.drv, &msg.body.edit_sta_info);
3004 case HOST_IF_MSG_GET_INACTIVETIME:
3005 Handle_Get_InActiveTime(msg.drv, &msg.body.mac_info);
3008 case HOST_IF_MSG_SCAN_TIMER_FIRED:
3009 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
3011 Handle_ScanDone(msg.drv, SCAN_EVENT_ABORTED);
3014 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
3015 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
3016 Handle_ConnectTimeout(msg.drv);
3019 case HOST_IF_MSG_POWER_MGMT:
3020 Handle_PowerManagement(msg.drv, &msg.body.pwr_mgmt_info);
3023 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
3024 Handle_SetWfiDrvHandler(msg.drv,
3028 case HOST_IF_MSG_SET_OPERATION_MODE:
3029 Handle_SetOperationMode(msg.drv, &msg.body.mode);
3032 case HOST_IF_MSG_SET_IPADDRESS:
3033 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
3034 Handle_set_IPAddress(msg.drv, msg.body.ip_info.ip_addr, msg.body.ip_info.idx);
3037 case HOST_IF_MSG_GET_IPADDRESS:
3038 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
3039 Handle_get_IPAddress(msg.drv, msg.body.ip_info.ip_addr, msg.body.ip_info.idx);
3042 case HOST_IF_MSG_SET_MAC_ADDRESS:
3043 Handle_SetMacAddress(msg.drv, &msg.body.set_mac_info);
3046 case HOST_IF_MSG_GET_MAC_ADDRESS:
3047 Handle_GetMacAddress(msg.drv, &msg.body.get_mac_info);
3050 case HOST_IF_MSG_REMAIN_ON_CHAN:
3051 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
3052 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
3055 case HOST_IF_MSG_REGISTER_FRAME:
3056 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
3057 Handle_RegisterFrame(msg.drv, &msg.body.reg_frame);
3060 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
3061 Handle_ListenStateExpired(msg.drv, &msg.body.remain_on_ch);
3064 case HOST_IF_MSG_SET_MULTICAST_FILTER:
3065 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
3066 Handle_SetMulticastFilter(msg.drv, &msg.body.multicast_info);
3069 case HOST_IF_MSG_ADD_BA_SESSION:
3070 Handle_AddBASession(msg.drv, &msg.body.session_info);
3073 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
3074 Handle_DelAllRxBASessions(msg.drv, &msg.body.session_info);
3077 case HOST_IF_MSG_DEL_ALL_STA:
3078 Handle_DelAllSta(msg.drv, &msg.body.del_all_sta_info);
3082 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
3087 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
3088 up(&hif_sema_thread);
3092 static void TimerCB_Scan(unsigned long arg)
3094 void *pvArg = (void *)arg;
3095 struct host_if_msg msg;
3097 memset(&msg, 0, sizeof(struct host_if_msg));
3099 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
3101 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3104 static void TimerCB_Connect(unsigned long arg)
3106 void *pvArg = (void *)arg;
3107 struct host_if_msg msg;
3109 memset(&msg, 0, sizeof(struct host_if_msg));
3111 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
3113 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3116 s32 host_int_remove_key(struct host_if_drv *hif_drv, const u8 *pu8StaAddress)
3120 strWID.id = (u16)WID_REMOVE_KEY;
3121 strWID.type = WID_STR;
3122 strWID.val = (s8 *)pu8StaAddress;
3128 int host_int_remove_wep_key(struct host_if_drv *hif_drv, u8 index)
3131 struct host_if_msg msg;
3135 PRINT_ER("Failed to send setup multicast config packet\n");
3139 memset(&msg, 0, sizeof(struct host_if_msg));
3141 msg.id = HOST_IF_MSG_KEY;
3142 msg.body.key_info.type = WEP;
3143 msg.body.key_info.action = REMOVEKEY;
3145 msg.body.key_info.attr.wep.index = index;
3147 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3149 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
3150 down(&hif_drv->hSemTestKeyBlock);
3155 s32 host_int_set_WEPDefaultKeyID(struct host_if_drv *hif_drv, u8 u8Index)
3158 struct host_if_msg msg;
3163 PRINT_ER("driver is null\n");
3167 memset(&msg, 0, sizeof(struct host_if_msg));
3170 msg.id = HOST_IF_MSG_KEY;
3171 msg.body.key_info.type = WEP;
3172 msg.body.key_info.action = DEFAULTKEY;
3174 msg.body.key_info.attr.wep.index = u8Index;
3176 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3178 PRINT_ER("Error in sending message queue : Default key index\n");
3179 down(&hif_drv->hSemTestKeyBlock);
3184 s32 host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv,
3185 const u8 *pu8WepKey,
3191 struct host_if_msg msg;
3195 PRINT_ER("driver is null\n");
3199 memset(&msg, 0, sizeof(struct host_if_msg));
3202 msg.id = HOST_IF_MSG_KEY;
3203 msg.body.key_info.type = WEP;
3204 msg.body.key_info.action = ADDKEY;
3206 msg.body.key_info.attr.wep.key = kmalloc(u8WepKeylen, GFP_KERNEL);
3207 memcpy(msg.body.key_info.attr.wep.key, pu8WepKey, u8WepKeylen);
3208 msg.body.key_info.attr.wep.key_len = (u8WepKeylen);
3209 msg.body.key_info.attr.wep.index = u8Keyidx;
3211 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3213 PRINT_ER("Error in sending message queue :WEP Key\n");
3214 down(&hif_drv->hSemTestKeyBlock);
3220 s32 host_int_add_wep_key_bss_ap(struct host_if_drv *hif_drv,
3221 const u8 *pu8WepKey,
3225 enum AUTHTYPE tenuAuth_type)
3229 struct host_if_msg msg;
3234 PRINT_ER("driver is null\n");
3238 memset(&msg, 0, sizeof(struct host_if_msg));
3241 for (i = 0; i < u8WepKeylen; i++)
3242 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
3244 msg.id = HOST_IF_MSG_KEY;
3245 msg.body.key_info.type = WEP;
3246 msg.body.key_info.action = ADDKEY_AP;
3248 msg.body.key_info.attr.wep.key = kmalloc(u8WepKeylen, GFP_KERNEL);
3249 memcpy(msg.body.key_info.attr.wep.key, pu8WepKey, (u8WepKeylen));
3250 msg.body.key_info.attr.wep.key_len = (u8WepKeylen);
3251 msg.body.key_info.attr.wep.index = u8Keyidx;
3252 msg.body.key_info.attr.wep.mode = u8mode;
3253 msg.body.key_info.attr.wep.auth_type = tenuAuth_type;
3255 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3258 PRINT_ER("Error in sending message queue :WEP Key\n");
3259 down(&hif_drv->hSemTestKeyBlock);
3265 s32 host_int_add_ptk(struct host_if_drv *hif_drv, const u8 *pu8Ptk,
3266 u8 u8PtkKeylen, const u8 *mac_addr,
3267 const u8 *pu8RxMic, const u8 *pu8TxMic,
3268 u8 mode, u8 u8Ciphermode, u8 u8Idx)
3271 struct host_if_msg msg;
3272 u8 u8KeyLen = u8PtkKeylen;
3277 PRINT_ER("driver is null\n");
3280 if (pu8RxMic != NULL)
3281 u8KeyLen += RX_MIC_KEY_LEN;
3282 if (pu8TxMic != NULL)
3283 u8KeyLen += TX_MIC_KEY_LEN;
3285 memset(&msg, 0, sizeof(struct host_if_msg));
3288 msg.id = HOST_IF_MSG_KEY;
3289 msg.body.key_info.type = WPAPtk;
3290 if (mode == AP_MODE) {
3291 msg.body.key_info.action = ADDKEY_AP;
3292 msg.body.key_info.attr.wpa.index = u8Idx;
3294 if (mode == STATION_MODE)
3295 msg.body.key_info.action = ADDKEY;
3297 msg.body.key_info.attr.wpa.key = kmalloc(u8PtkKeylen, GFP_KERNEL);
3298 memcpy(msg.body.key_info.attr.wpa.key, pu8Ptk, u8PtkKeylen);
3300 if (pu8RxMic != NULL) {
3301 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic, RX_MIC_KEY_LEN);
3303 for (i = 0; i < RX_MIC_KEY_LEN; i++)
3304 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
3307 if (pu8TxMic != NULL) {
3308 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic, TX_MIC_KEY_LEN);
3310 for (i = 0; i < TX_MIC_KEY_LEN; i++)
3311 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
3315 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
3316 msg.body.key_info.attr.wpa.mac_addr = mac_addr;
3317 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
3320 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3323 PRINT_ER("Error in sending message queue: PTK Key\n");
3325 down(&hif_drv->hSemTestKeyBlock);
3330 s32 host_int_add_rx_gtk(struct host_if_drv *hif_drv, const u8 *pu8RxGtk,
3331 u8 u8GtkKeylen, u8 u8KeyIdx,
3332 u32 u32KeyRSClen, const u8 *KeyRSC,
3333 const u8 *pu8RxMic, const u8 *pu8TxMic,
3334 u8 mode, u8 u8Ciphermode)
3337 struct host_if_msg msg;
3338 u8 u8KeyLen = u8GtkKeylen;
3342 PRINT_ER("driver is null\n");
3345 memset(&msg, 0, sizeof(struct host_if_msg));
3348 if (pu8RxMic != NULL)
3349 u8KeyLen += RX_MIC_KEY_LEN;
3350 if (pu8TxMic != NULL)
3351 u8KeyLen += TX_MIC_KEY_LEN;
3352 if (KeyRSC != NULL) {
3353 msg.body.key_info.attr.wpa.seq = kmalloc(u32KeyRSClen, GFP_KERNEL);
3354 memcpy(msg.body.key_info.attr.wpa.seq, KeyRSC, u32KeyRSClen);
3358 msg.id = HOST_IF_MSG_KEY;
3359 msg.body.key_info.type = WPARxGtk;
3362 if (mode == AP_MODE) {
3363 msg.body.key_info.action = ADDKEY_AP;
3364 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
3366 if (mode == STATION_MODE)
3367 msg.body.key_info.action = ADDKEY;
3369 msg.body.key_info.attr.wpa.key = kmalloc(u8KeyLen, GFP_KERNEL);
3370 memcpy(msg.body.key_info.attr.wpa.key, pu8RxGtk, u8GtkKeylen);
3372 if (pu8RxMic != NULL) {
3373 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic, RX_MIC_KEY_LEN);
3375 if (pu8TxMic != NULL) {
3376 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic, TX_MIC_KEY_LEN);
3379 msg.body.key_info.attr.wpa.index = u8KeyIdx;
3380 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
3381 msg.body.key_info.attr.wpa.seq_len = u32KeyRSClen;
3383 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3385 PRINT_ER("Error in sending message queue: RX GTK\n");
3387 down(&hif_drv->hSemTestKeyBlock);
3392 s32 host_int_set_pmkid_info(struct host_if_drv *hif_drv, struct host_if_pmkid_attr *pu8PmkidInfoArray)
3395 struct host_if_msg msg;
3401 PRINT_ER("driver is null\n");
3405 memset(&msg, 0, sizeof(struct host_if_msg));
3407 msg.id = HOST_IF_MSG_KEY;
3408 msg.body.key_info.type = PMKSA;
3409 msg.body.key_info.action = ADDKEY;
3412 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
3413 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
3415 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
3419 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3421 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
3426 s32 host_int_get_pmkid_info(struct host_if_drv *hif_drv,
3427 u8 *pu8PmkidInfoArray,
3428 u32 u32PmkidInfoLen)
3432 strWID.id = (u16)WID_PMKID_INFO;
3433 strWID.type = WID_STR;
3434 strWID.size = u32PmkidInfoLen;
3435 strWID.val = pu8PmkidInfoArray;
3440 s32 host_int_set_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3446 if ((u8Psklength > 7) && (u8Psklength < 65)) {
3447 strWID.id = (u16)WID_11I_PSK;
3448 strWID.type = WID_STR;
3449 strWID.val = pu8PassPhrase;
3450 strWID.size = u8Psklength;
3456 s32 host_int_get_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
3459 struct host_if_msg msg;
3461 memset(&msg, 0, sizeof(struct host_if_msg));
3463 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
3464 msg.body.get_mac_info.u8MacAddress = pu8MacAddress;
3467 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3469 PRINT_ER("Failed to send get mac address\n");
3473 down(&hif_sema_wait_response);
3477 s32 host_int_set_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
3480 struct host_if_msg msg;
3482 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
3484 memset(&msg, 0, sizeof(struct host_if_msg));
3485 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
3486 memcpy(msg.body.set_mac_info.u8MacAddress, pu8MacAddress, ETH_ALEN);
3489 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3491 PRINT_ER("Failed to send message queue: Set mac address\n");
3497 s32 host_int_get_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3498 u8 *pu8PassPhrase, u8 u8Psklength)
3502 strWID.id = (u16)WID_11I_PSK;
3503 strWID.type = WID_STR;
3504 strWID.size = u8Psklength;
3505 strWID.val = pu8PassPhrase;
3510 s32 host_int_set_start_scan_req(struct host_if_drv *hif_drv, u8 scanSource)
3514 strWID.id = (u16)WID_START_SCAN_REQ;
3515 strWID.type = WID_CHAR;
3516 strWID.val = (s8 *)&scanSource;
3517 strWID.size = sizeof(char);
3522 s32 host_int_get_start_scan_req(struct host_if_drv *hif_drv, u8 *pu8ScanSource)
3526 strWID.id = (u16)WID_START_SCAN_REQ;
3527 strWID.type = WID_CHAR;
3528 strWID.val = (s8 *)pu8ScanSource;
3529 strWID.size = sizeof(char);
3534 s32 host_int_set_join_req(struct host_if_drv *hif_drv, u8 *pu8bssid,
3535 const u8 *pu8ssid, size_t ssidLen,
3536 const u8 *pu8IEs, size_t IEsLen,
3537 wilc_connect_result pfConnectResult, void *pvUserArg,
3538 u8 u8security, enum AUTHTYPE tenuAuth_type,
3539 u8 u8channel, void *pJoinParams)
3542 struct host_if_msg msg;
3544 if (!hif_drv || pfConnectResult == NULL) {
3546 PRINT_ER("Driver is null\n");
3550 if (pJoinParams == NULL) {
3551 PRINT_ER("Unable to Join - JoinParams is NULL\n");
3555 memset(&msg, 0, sizeof(struct host_if_msg));
3557 msg.id = HOST_IF_MSG_CONNECT;
3559 msg.body.con_info.security = u8security;
3560 msg.body.con_info.auth_type = tenuAuth_type;
3561 msg.body.con_info.ch = u8channel;
3562 msg.body.con_info.result = pfConnectResult;
3563 msg.body.con_info.arg = pvUserArg;
3564 msg.body.con_info.params = pJoinParams;
3567 if (pu8bssid != NULL) {
3568 msg.body.con_info.bssid = kmalloc(6, GFP_KERNEL);
3569 memcpy(msg.body.con_info.bssid, pu8bssid, 6);
3572 if (pu8ssid != NULL) {
3573 msg.body.con_info.ssid_len = ssidLen;
3574 msg.body.con_info.ssid = kmalloc(ssidLen, GFP_KERNEL);
3575 memcpy(msg.body.con_info.ssid, pu8ssid, ssidLen);
3578 if (pu8IEs != NULL) {
3579 msg.body.con_info.ies_len = IEsLen;
3580 msg.body.con_info.ies = kmalloc(IEsLen, GFP_KERNEL);
3581 memcpy(msg.body.con_info.ies, pu8IEs, IEsLen);
3583 if (hif_drv->enuHostIFstate < HOST_IF_CONNECTING)
3584 hif_drv->enuHostIFstate = HOST_IF_CONNECTING;
3586 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", hif_drv->enuHostIFstate);
3588 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3590 PRINT_ER("Failed to send message queue: Set join request\n");
3594 hif_drv->hConnectTimer.data = (unsigned long)hif_drv;
3595 mod_timer(&hif_drv->hConnectTimer,
3596 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
3601 s32 host_int_flush_join_req(struct host_if_drv *hif_drv)
3604 struct host_if_msg msg;
3606 if (!gu8FlushedJoinReq) {
3614 PRINT_ER("Driver is null\n");
3618 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
3621 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3623 PRINT_ER("Failed to send message queue: Flush join request\n");
3630 s32 host_int_disconnect(struct host_if_drv *hif_drv, u16 u16ReasonCode)
3633 struct host_if_msg msg;
3636 PRINT_ER("Driver is null\n");
3640 memset(&msg, 0, sizeof(struct host_if_msg));
3642 msg.id = HOST_IF_MSG_DISCONNECT;
3645 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3647 PRINT_ER("Failed to send message queue: disconnect\n");
3649 down(&hif_drv->hSemTestDisconnectBlock);
3654 s32 host_int_disconnect_station(struct host_if_drv *hif_drv, u8 assoc_id)
3658 strWID.id = (u16)WID_DISCONNECT;
3659 strWID.type = WID_CHAR;
3660 strWID.val = (s8 *)&assoc_id;
3661 strWID.size = sizeof(char);
3666 s32 host_int_get_assoc_req_info(struct host_if_drv *hif_drv, u8 *pu8AssocReqInfo,
3667 u32 u32AssocReqInfoLen)
3671 strWID.id = (u16)WID_ASSOC_REQ_INFO;
3672 strWID.type = WID_STR;
3673 strWID.val = pu8AssocReqInfo;
3674 strWID.size = u32AssocReqInfoLen;
3679 s32 host_int_get_assoc_res_info(struct host_if_drv *hif_drv, u8 *pu8AssocRespInfo,
3680 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
3686 PRINT_ER("Driver is null\n");
3690 strWID.id = (u16)WID_ASSOC_RES_INFO;
3691 strWID.type = WID_STR;
3692 strWID.val = pu8AssocRespInfo;
3693 strWID.size = u32MaxAssocRespInfoLen;
3695 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
3696 get_id_from_handler(hif_drv));
3698 *pu32RcvdAssocRespInfoLen = 0;
3699 PRINT_ER("Failed to send association response config packet\n");
3702 *pu32RcvdAssocRespInfoLen = strWID.size;
3708 s32 host_int_get_rx_power_level(struct host_if_drv *hif_drv, u8 *pu8RxPowerLevel,
3709 u32 u32RxPowerLevelLen)
3713 strWID.id = (u16)WID_RX_POWER_LEVEL;
3714 strWID.type = WID_STR;
3715 strWID.val = pu8RxPowerLevel;
3716 strWID.size = u32RxPowerLevelLen;
3721 int host_int_set_mac_chnl_num(struct host_if_drv *hif_drv, u8 channel)
3724 struct host_if_msg msg;
3727 PRINT_ER("driver is null\n");
3731 memset(&msg, 0, sizeof(struct host_if_msg));
3732 msg.id = HOST_IF_MSG_SET_CHANNEL;
3733 msg.body.channel_info.set_ch = channel;
3736 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3738 PRINT_ER("wilc mq send fail\n");
3745 int host_int_wait_msg_queue_idle(void)
3749 struct host_if_msg msg;
3750 memset(&msg, 0, sizeof(struct host_if_msg));
3751 msg.id = HOST_IF_MSG_Q_IDLE;
3752 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3754 PRINT_ER("wilc mq send fail\n");
3758 down(&hif_sema_wait_response);
3763 int host_int_set_wfi_drv_handler(struct host_if_drv *hif_drv)
3767 struct host_if_msg msg;
3768 memset(&msg, 0, sizeof(struct host_if_msg));
3769 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
3770 msg.body.drv.u32Address = get_id_from_handler(hif_drv);
3773 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3775 PRINT_ER("wilc mq send fail\n");
3782 int host_int_set_operation_mode(struct host_if_drv *hif_drv, u32 mode)
3786 struct host_if_msg msg;
3787 memset(&msg, 0, sizeof(struct host_if_msg));
3788 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
3789 msg.body.mode.u32Mode = mode;
3792 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3794 PRINT_ER("wilc mq send fail\n");
3801 s32 host_int_get_host_chnl_num(struct host_if_drv *hif_drv, u8 *pu8ChNo)
3804 struct host_if_msg msg;
3807 PRINT_ER("driver is null\n");
3811 memset(&msg, 0, sizeof(struct host_if_msg));
3813 msg.id = HOST_IF_MSG_GET_CHNL;
3816 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3818 PRINT_ER("wilc mq send fail\n");
3819 down(&hif_drv->hSemGetCHNL);
3828 s32 host_int_get_inactive_time(struct host_if_drv *hif_drv,
3829 const u8 *mac, u32 *pu32InactiveTime)
3832 struct host_if_msg msg;
3835 PRINT_ER("driver is null\n");
3839 memset(&msg, 0, sizeof(struct host_if_msg));
3842 memcpy(msg.body.mac_info.mac,
3845 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
3848 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3850 PRINT_ER("Failed to send get host channel param's message queue ");
3852 down(&hif_drv->hSemInactiveTime);
3854 *pu32InactiveTime = gu32InactiveTime;
3859 s32 host_int_test_get_int_wid(struct host_if_drv *hif_drv, u32 *pu32TestMemAddr)
3866 PRINT_ER("driver is null\n");
3870 strWID.id = (u16)WID_MEMORY_ADDRESS;
3871 strWID.type = WID_INT;
3872 strWID.val = (s8 *)pu32TestMemAddr;
3873 strWID.size = sizeof(u32);
3875 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
3876 get_id_from_handler(hif_drv));
3879 PRINT_ER("Failed to get wid value\n");
3882 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
3889 s32 host_int_get_rssi(struct host_if_drv *hif_drv, s8 *ps8Rssi)
3892 struct host_if_msg msg;
3893 memset(&msg, 0, sizeof(struct host_if_msg));
3895 msg.id = HOST_IF_MSG_GET_RSSI;
3898 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3900 PRINT_ER("Failed to send get host channel param's message queue ");
3904 down(&hif_drv->hSemGetRSSI);
3907 if (ps8Rssi == NULL) {
3908 PRINT_ER("RSS pointer value is null");
3917 s32 host_int_get_link_speed(struct host_if_drv *hif_drv, s8 *ps8lnkspd)
3919 struct host_if_msg msg;
3921 memset(&msg, 0, sizeof(struct host_if_msg));
3923 msg.id = HOST_IF_MSG_GET_LINKSPEED;
3926 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3928 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
3932 down(&hif_drv->hSemGetLINKSPEED);
3935 if (ps8lnkspd == NULL) {
3936 PRINT_ER("LINKSPEED pointer value is null");
3940 *ps8lnkspd = link_speed;
3945 s32 host_int_get_statistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
3948 struct host_if_msg msg;
3949 memset(&msg, 0, sizeof(struct host_if_msg));
3951 msg.id = HOST_IF_MSG_GET_STATISTICS;
3952 msg.body.data = (char *)pstrStatistics;
3955 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3957 PRINT_ER("Failed to send get host channel param's message queue ");
3961 down(&hif_sema_wait_response);
3965 s32 host_int_scan(struct host_if_drv *hif_drv, u8 u8ScanSource,
3966 u8 u8ScanType, u8 *pu8ChnlFreqList,
3967 u8 u8ChnlListLen, const u8 *pu8IEs,
3968 size_t IEsLen, wilc_scan_result ScanResult,
3969 void *pvUserArg, struct hidden_network *pstrHiddenNetwork)
3972 struct host_if_msg msg;
3974 if (!hif_drv || ScanResult == NULL) {
3975 PRINT_ER("hif_drv or ScanResult = NULL\n");
3979 memset(&msg, 0, sizeof(struct host_if_msg));
3981 msg.id = HOST_IF_MSG_SCAN;
3983 if (pstrHiddenNetwork != NULL) {
3984 msg.body.scan_info.hidden_network.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
3985 msg.body.scan_info.hidden_network.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
3988 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
3991 msg.body.scan_info.src = u8ScanSource;
3992 msg.body.scan_info.type = u8ScanType;
3993 msg.body.scan_info.result = ScanResult;
3994 msg.body.scan_info.arg = pvUserArg;
3996 msg.body.scan_info.ch_list_len = u8ChnlListLen;
3997 msg.body.scan_info.ch_freq_list = kmalloc(u8ChnlListLen, GFP_KERNEL);
3998 memcpy(msg.body.scan_info.ch_freq_list, pu8ChnlFreqList, u8ChnlListLen);
4000 msg.body.scan_info.ies_len = IEsLen;
4001 msg.body.scan_info.ies = kmalloc(IEsLen, GFP_KERNEL);
4002 memcpy(msg.body.scan_info.ies, pu8IEs, IEsLen);
4004 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4006 PRINT_ER("Error in sending message queue\n");
4010 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
4011 hif_drv->hScanTimer.data = (unsigned long)hif_drv;
4012 mod_timer(&hif_drv->hScanTimer,
4013 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
4019 s32 hif_set_cfg(struct host_if_drv *hif_drv,
4020 struct cfg_param_val *pstrCfgParamVal)
4024 struct host_if_msg msg;
4028 PRINT_ER("hif_drv NULL\n");
4032 memset(&msg, 0, sizeof(struct host_if_msg));
4033 msg.id = HOST_IF_MSG_CFG_PARAMS;
4034 msg.body.cfg_info.cfg_attr_info = *pstrCfgParamVal;
4037 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4043 s32 hif_get_cfg(struct host_if_drv *hif_drv, u16 u16WID, u16 *pu16WID_Value)
4047 down(&hif_drv->gtOsCfgValuesSem);
4050 PRINT_ER("hif_drv NULL\n");
4053 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
4057 *pu16WID_Value = (u16)hif_drv->strCfgValues.bss_type;
4061 *pu16WID_Value = (u16)hif_drv->strCfgValues.auth_type;
4064 case WID_AUTH_TIMEOUT:
4065 *pu16WID_Value = hif_drv->strCfgValues.auth_timeout;
4068 case WID_POWER_MANAGEMENT:
4069 *pu16WID_Value = (u16)hif_drv->strCfgValues.power_mgmt_mode;
4072 case WID_SHORT_RETRY_LIMIT:
4073 *pu16WID_Value = hif_drv->strCfgValues.short_retry_limit;
4076 case WID_LONG_RETRY_LIMIT:
4077 *pu16WID_Value = hif_drv->strCfgValues.long_retry_limit;
4080 case WID_FRAG_THRESHOLD:
4081 *pu16WID_Value = hif_drv->strCfgValues.frag_threshold;
4084 case WID_RTS_THRESHOLD:
4085 *pu16WID_Value = hif_drv->strCfgValues.rts_threshold;
4089 *pu16WID_Value = (u16)hif_drv->strCfgValues.preamble_type;
4092 case WID_SHORT_SLOT_ALLOWED:
4093 *pu16WID_Value = (u16) hif_drv->strCfgValues.short_slot_allowed;
4096 case WID_11N_TXOP_PROT_DISABLE:
4097 *pu16WID_Value = (u16)hif_drv->strCfgValues.txop_prot_disabled;
4100 case WID_BEACON_INTERVAL:
4101 *pu16WID_Value = hif_drv->strCfgValues.beacon_interval;
4104 case WID_DTIM_PERIOD:
4105 *pu16WID_Value = (u16)hif_drv->strCfgValues.dtim_period;
4108 case WID_SITE_SURVEY:
4109 *pu16WID_Value = (u16)hif_drv->strCfgValues.site_survey_enabled;
4112 case WID_SITE_SURVEY_SCAN_TIME:
4113 *pu16WID_Value = hif_drv->strCfgValues.site_survey_scan_time;
4116 case WID_ACTIVE_SCAN_TIME:
4117 *pu16WID_Value = hif_drv->strCfgValues.active_scan_time;
4120 case WID_PASSIVE_SCAN_TIME:
4121 *pu16WID_Value = hif_drv->strCfgValues.passive_scan_time;
4124 case WID_CURRENT_TX_RATE:
4125 *pu16WID_Value = hif_drv->strCfgValues.curr_tx_rate;
4132 up(&hif_drv->gtOsCfgValuesSem);
4138 void host_int_send_join_leave_info_to_host
4139 (u16 assocId, u8 *stationAddr, bool joining)
4143 static void GetPeriodicRSSI(unsigned long arg)
4145 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
4148 PRINT_ER("Driver handler is NULL\n");
4152 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED) {
4154 struct host_if_msg msg;
4156 memset(&msg, 0, sizeof(struct host_if_msg));
4158 msg.id = HOST_IF_MSG_GET_RSSI;
4161 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4163 PRINT_ER("Failed to send get host channel param's message queue ");
4167 periodic_rssi.data = (unsigned long)hif_drv;
4168 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
4172 void host_int_send_network_info_to_host
4173 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
4177 static u32 clients_count;
4179 s32 host_int_init(struct host_if_drv **hif_drv_handler)
4182 struct host_if_drv *hif_drv;
4185 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
4187 scan_while_connected = false;
4189 sema_init(&hif_sema_wait_response, 0);
4191 hif_drv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
4196 *hif_drv_handler = hif_drv;
4197 err = add_handler_in_list(hif_drv);
4203 g_obtainingIP = false;
4205 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", hif_drv);
4206 if (clients_count == 0) {
4207 sema_init(&hif_sema_thread, 0);
4208 sema_init(&hif_sema_driver, 0);
4209 sema_init(&hif_sema_deinit, 1);
4212 sema_init(&hif_drv->hSemTestKeyBlock, 0);
4213 sema_init(&hif_drv->hSemTestDisconnectBlock, 0);
4214 sema_init(&hif_drv->hSemGetRSSI, 0);
4215 sema_init(&hif_drv->hSemGetLINKSPEED, 0);
4216 sema_init(&hif_drv->hSemGetCHNL, 0);
4217 sema_init(&hif_drv->hSemInactiveTime, 0);
4219 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
4221 if (clients_count == 0) {
4222 result = wilc_mq_create(&hif_msg_q);
4225 PRINT_ER("Failed to creat MQ\n");
4229 hif_thread_handler = kthread_run(hostIFthread, NULL, "WILC_kthread");
4231 if (IS_ERR(hif_thread_handler)) {
4232 PRINT_ER("Failed to creat Thread\n");
4236 setup_timer(&periodic_rssi, GetPeriodicRSSI,
4237 (unsigned long)hif_drv);
4238 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
4241 setup_timer(&hif_drv->hScanTimer, TimerCB_Scan, 0);
4243 setup_timer(&hif_drv->hConnectTimer, TimerCB_Connect, 0);
4245 setup_timer(&hif_drv->hRemainOnChannel, ListenTimerCB, 0);
4247 sema_init(&(hif_drv->gtOsCfgValuesSem), 1);
4248 down(&hif_drv->gtOsCfgValuesSem);
4250 hif_drv->enuHostIFstate = HOST_IF_IDLE;
4251 hif_drv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
4252 hif_drv->strCfgValues.scan_source = DEFAULT_SCAN;
4253 hif_drv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
4254 hif_drv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
4255 hif_drv->strCfgValues.curr_tx_rate = AUTORATE;
4257 hif_drv->u64P2p_MgmtTimeout = 0;
4259 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",
4261 hif_drv->strCfgValues.site_survey_enabled, hif_drv->strCfgValues.scan_source,
4262 hif_drv->strCfgValues.active_scan_time, hif_drv->strCfgValues.passive_scan_time,
4263 hif_drv->strCfgValues.curr_tx_rate);
4265 up(&hif_drv->gtOsCfgValuesSem);
4272 up(&hif_drv->gtOsCfgValuesSem);
4273 del_timer_sync(&hif_drv->hConnectTimer);
4274 del_timer_sync(&hif_drv->hScanTimer);
4275 kthread_stop(hif_thread_handler);
4277 wilc_mq_destroy(&hif_msg_q);
4282 s32 host_int_deinit(struct host_if_drv *hif_drv)
4285 struct host_if_msg msg;
4289 PRINT_ER("hif_drv = NULL\n");
4293 down(&hif_sema_deinit);
4295 terminated_handle = hif_drv;
4296 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
4298 if (del_timer_sync(&hif_drv->hScanTimer)) {
4299 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
4302 if (del_timer_sync(&hif_drv->hConnectTimer)) {
4303 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4306 if (del_timer_sync(&periodic_rssi))
4307 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4309 del_timer_sync(&hif_drv->hRemainOnChannel);
4311 host_int_set_wfi_drv_handler(NULL);
4312 down(&hif_sema_driver);
4314 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
4315 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
4316 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
4318 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
4321 hif_drv->enuHostIFstate = HOST_IF_IDLE;
4323 scan_while_connected = false;
4325 memset(&msg, 0, sizeof(struct host_if_msg));
4327 if (clients_count == 1) {
4328 if (del_timer_sync(&periodic_rssi))
4329 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4331 msg.id = HOST_IF_MSG_EXIT;
4334 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4336 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
4338 down(&hif_sema_thread);
4340 wilc_mq_destroy(&hif_msg_q);
4343 down(&(hif_drv->gtOsCfgValuesSem));
4345 ret = remove_handler_in_list(hif_drv);
4352 terminated_handle = NULL;
4353 up(&hif_sema_deinit);
4357 void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
4360 struct host_if_msg msg;
4362 struct host_if_drv *hif_drv = NULL;
4364 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4365 hif_drv = get_handler_from_id(id);
4370 if (!hif_drv || hif_drv == terminated_handle) {
4371 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv);
4375 memset(&msg, 0, sizeof(struct host_if_msg));
4377 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
4380 msg.body.net_info.len = u32Length;
4381 msg.body.net_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4382 memcpy(msg.body.net_info.buffer, pu8Buffer, u32Length);
4384 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4386 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
4389 void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
4392 struct host_if_msg msg;
4394 struct host_if_drv *hif_drv = NULL;
4396 down(&hif_sema_deinit);
4398 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4399 hif_drv = get_handler_from_id(id);
4400 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
4403 if (!hif_drv || hif_drv == terminated_handle) {
4404 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
4405 up(&hif_sema_deinit);
4409 if (!hif_drv->strWILC_UsrConnReq.pfUserConnectResult) {
4410 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
4411 up(&hif_sema_deinit);
4415 memset(&msg, 0, sizeof(struct host_if_msg));
4418 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
4421 msg.body.async_info.len = u32Length;
4422 msg.body.async_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4423 memcpy(msg.body.async_info.buffer, pu8Buffer, u32Length);
4425 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4427 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
4429 up(&hif_sema_deinit);
4432 void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
4435 struct host_if_msg msg;
4437 struct host_if_drv *hif_drv = NULL;
4439 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4440 hif_drv = get_handler_from_id(id);
4443 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", hif_drv);
4445 if (!hif_drv || hif_drv == terminated_handle)
4448 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
4449 memset(&msg, 0, sizeof(struct host_if_msg));
4451 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
4454 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4456 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
4464 s32 host_int_remain_on_channel(struct host_if_drv *hif_drv, u32 u32SessionID,
4465 u32 u32duration, u16 chan,
4466 wilc_remain_on_chan_expired RemainOnChanExpired,
4467 wilc_remain_on_chan_ready RemainOnChanReady,
4471 struct host_if_msg msg;
4474 PRINT_ER("driver is null\n");
4478 memset(&msg, 0, sizeof(struct host_if_msg));
4480 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
4481 msg.body.remain_on_ch.u16Channel = chan;
4482 msg.body.remain_on_ch.pRemainOnChanExpired = RemainOnChanExpired;
4483 msg.body.remain_on_ch.pRemainOnChanReady = RemainOnChanReady;
4484 msg.body.remain_on_ch.pVoid = pvUserArg;
4485 msg.body.remain_on_ch.u32duration = u32duration;
4486 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
4489 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4491 PRINT_ER("wilc mq send fail\n");
4496 s32 host_int_ListenStateExpired(struct host_if_drv *hif_drv, u32 u32SessionID)
4499 struct host_if_msg msg;
4502 PRINT_ER("driver is null\n");
4506 del_timer(&hif_drv->hRemainOnChannel);
4508 memset(&msg, 0, sizeof(struct host_if_msg));
4509 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
4511 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
4513 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4515 PRINT_ER("wilc mq send fail\n");
4520 s32 host_int_frame_register(struct host_if_drv *hif_drv, u16 u16FrameType, bool bReg)
4523 struct host_if_msg msg;
4526 PRINT_ER("driver is null\n");
4530 memset(&msg, 0, sizeof(struct host_if_msg));
4532 msg.id = HOST_IF_MSG_REGISTER_FRAME;
4533 switch (u16FrameType) {
4535 PRINT_D(HOSTINF_DBG, "ACTION\n");
4536 msg.body.reg_frame.u8Regid = ACTION_FRM_IDX;
4540 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
4541 msg.body.reg_frame.u8Regid = PROBE_REQ_IDX;
4545 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
4548 msg.body.reg_frame.u16FrameType = u16FrameType;
4549 msg.body.reg_frame.bReg = bReg;
4552 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4554 PRINT_ER("wilc mq send fail\n");
4561 s32 host_int_add_beacon(struct host_if_drv *hif_drv, u32 u32Interval,
4562 u32 u32DTIMPeriod, u32 u32HeadLen, u8 *pu8Head,
4563 u32 u32TailLen, u8 *pu8Tail)
4566 struct host_if_msg msg;
4567 struct beacon_attr *pstrSetBeaconParam = &msg.body.beacon_info;
4570 PRINT_ER("driver is null\n");
4574 memset(&msg, 0, sizeof(struct host_if_msg));
4576 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
4578 msg.id = HOST_IF_MSG_ADD_BEACON;
4580 pstrSetBeaconParam->interval = u32Interval;
4581 pstrSetBeaconParam->dtim_period = u32DTIMPeriod;
4582 pstrSetBeaconParam->head_len = u32HeadLen;
4583 pstrSetBeaconParam->head = kmalloc(u32HeadLen, GFP_KERNEL);
4584 if (pstrSetBeaconParam->head == NULL) {
4588 memcpy(pstrSetBeaconParam->head, pu8Head, u32HeadLen);
4589 pstrSetBeaconParam->tail_len = u32TailLen;
4591 if (u32TailLen > 0) {
4592 pstrSetBeaconParam->tail = kmalloc(u32TailLen, GFP_KERNEL);
4593 if (pstrSetBeaconParam->tail == NULL) {
4597 memcpy(pstrSetBeaconParam->tail, pu8Tail, u32TailLen);
4599 pstrSetBeaconParam->tail = NULL;
4602 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4604 PRINT_ER("wilc mq send fail\n");
4608 kfree(pstrSetBeaconParam->head);
4610 kfree(pstrSetBeaconParam->tail);
4617 s32 host_int_del_beacon(struct host_if_drv *hif_drv)
4620 struct host_if_msg msg;
4623 PRINT_ER("driver is null\n");
4627 msg.id = HOST_IF_MSG_DEL_BEACON;
4629 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
4631 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4633 PRINT_ER("wilc_mq_send fail\n");
4638 s32 host_int_add_station(struct host_if_drv *hif_drv,
4639 struct add_sta_param *pstrStaParams)
4642 struct host_if_msg msg;
4643 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
4647 PRINT_ER("driver is null\n");
4651 memset(&msg, 0, sizeof(struct host_if_msg));
4653 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
4655 msg.id = HOST_IF_MSG_ADD_STATION;
4658 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
4659 if (pstrAddStationMsg->u8NumRates > 0) {
4660 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
4665 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
4666 pstrAddStationMsg->pu8Rates = rates;
4669 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4671 PRINT_ER("wilc_mq_send fail\n");
4675 s32 host_int_del_station(struct host_if_drv *hif_drv, const u8 *pu8MacAddr)
4678 struct host_if_msg msg;
4679 struct del_sta *pstrDelStationMsg = &msg.body.del_sta_info;
4682 PRINT_ER("driver is null\n");
4686 memset(&msg, 0, sizeof(struct host_if_msg));
4688 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
4690 msg.id = HOST_IF_MSG_DEL_STATION;
4693 if (pu8MacAddr == NULL)
4694 memset(pstrDelStationMsg->mac_addr, 255, ETH_ALEN);
4696 memcpy(pstrDelStationMsg->mac_addr, pu8MacAddr, ETH_ALEN);
4698 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4700 PRINT_ER("wilc_mq_send fail\n");
4704 s32 host_int_del_allstation(struct host_if_drv *hif_drv,
4705 u8 pu8MacAddr[][ETH_ALEN])
4708 struct host_if_msg msg;
4709 struct del_all_sta *pstrDelAllStationMsg = &msg.body.del_all_sta_info;
4710 u8 au8Zero_Buff[ETH_ALEN] = {0};
4716 PRINT_ER("driver is null\n");
4720 memset(&msg, 0, sizeof(struct host_if_msg));
4722 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
4724 msg.id = HOST_IF_MSG_DEL_ALL_STA;
4727 for (i = 0; i < MAX_NUM_STA; i++) {
4728 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
4729 memcpy(pstrDelAllStationMsg->del_all_sta[i], pu8MacAddr[i], ETH_ALEN);
4730 PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n",
4731 pstrDelAllStationMsg->del_all_sta[i][0],
4732 pstrDelAllStationMsg->del_all_sta[i][1],
4733 pstrDelAllStationMsg->del_all_sta[i][2],
4734 pstrDelAllStationMsg->del_all_sta[i][3],
4735 pstrDelAllStationMsg->del_all_sta[i][4],
4736 pstrDelAllStationMsg->del_all_sta[i][5]);
4741 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
4745 pstrDelAllStationMsg->assoc_sta = u8AssocNumb;
4746 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4749 PRINT_ER("wilc_mq_send fail\n");
4751 down(&hif_sema_wait_response);
4757 s32 host_int_edit_station(struct host_if_drv *hif_drv,
4758 struct add_sta_param *pstrStaParams)
4761 struct host_if_msg msg;
4762 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
4765 PRINT_ER("driver is null\n");
4769 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
4771 memset(&msg, 0, sizeof(struct host_if_msg));
4773 msg.id = HOST_IF_MSG_EDIT_STATION;
4776 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
4777 if (pstrAddStationMsg->u8NumRates > 0) {
4778 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
4783 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
4784 pstrAddStationMsg->pu8Rates = rates;
4787 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4789 PRINT_ER("wilc_mq_send fail\n");
4794 s32 host_int_set_power_mgmt(struct host_if_drv *hif_drv,
4799 struct host_if_msg msg;
4800 struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.pwr_mgmt_info;
4802 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
4805 PRINT_ER("driver is null\n");
4809 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
4811 memset(&msg, 0, sizeof(struct host_if_msg));
4813 msg.id = HOST_IF_MSG_POWER_MGMT;
4816 pstrPowerMgmtParam->enabled = bIsEnabled;
4817 pstrPowerMgmtParam->timeout = u32Timeout;
4819 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4821 PRINT_ER("wilc_mq_send fail\n");
4825 s32 host_int_setup_multicast_filter(struct host_if_drv *hif_drv,
4830 struct host_if_msg msg;
4831 struct set_multicast *pstrMulticastFilterParam = &msg.body.multicast_info;
4835 PRINT_ER("driver is null\n");
4839 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
4841 memset(&msg, 0, sizeof(struct host_if_msg));
4843 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
4846 pstrMulticastFilterParam->enabled = bIsEnabled;
4847 pstrMulticastFilterParam->cnt = u32count;
4849 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4851 PRINT_ER("wilc_mq_send fail\n");
4855 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
4857 struct join_bss_param *pNewJoinBssParam = NULL;
4866 u8 pcipherTotalCount = 0;
4867 u8 authTotalCount = 0;
4870 pu8IEs = ptstrNetworkInfo->pu8IEs;
4871 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
4873 pNewJoinBssParam = kzalloc(sizeof(struct join_bss_param), GFP_KERNEL);
4874 if (pNewJoinBssParam != NULL) {
4875 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
4876 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
4877 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
4878 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
4879 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
4880 pNewJoinBssParam->ssid_len = ptstrNetworkInfo->u8SsidLen;
4881 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
4882 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
4884 while (index < u16IEsLen) {
4885 if (pu8IEs[index] == SUPP_RATES_IE) {
4886 suppRatesNo = pu8IEs[index + 1];
4887 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
4890 for (i = 0; i < suppRatesNo; i++) {
4891 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
4893 index += suppRatesNo;
4895 } else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
4896 extSuppRatesNo = pu8IEs[index + 1];
4897 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
4898 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
4900 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
4902 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
4903 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
4905 index += extSuppRatesNo;
4907 } else if (pu8IEs[index] == HT_CAPABILITY_IE) {
4908 pNewJoinBssParam->ht_capable = true;
4909 index += pu8IEs[index + 1] + 2;
4911 } else if ((pu8IEs[index] == WMM_IE) &&
4912 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
4913 (pu8IEs[index + 4] == 0xF2) &&
4914 (pu8IEs[index + 5] == 0x02) &&
4915 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) &&
4916 (pu8IEs[index + 7] == 0x01)) {
4917 pNewJoinBssParam->wmm_cap = true;
4919 if (pu8IEs[index + 8] & BIT(7))
4920 pNewJoinBssParam->uapsd_cap = true;
4921 index += pu8IEs[index + 1] + 2;
4923 } else if ((pu8IEs[index] == P2P_IE) &&
4924 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
4925 (pu8IEs[index + 4] == 0x9a) &&
4926 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) {
4929 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
4930 pNewJoinBssParam->noa_enabled = 1;
4931 pNewJoinBssParam->idx = pu8IEs[index + 9];
4933 if (pu8IEs[index + 10] & BIT(7)) {
4934 pNewJoinBssParam->opp_enabled = 1;
4935 pNewJoinBssParam->ct_window = pu8IEs[index + 10];
4937 pNewJoinBssParam->opp_enabled = 0;
4940 PRINT_D(GENERIC_DBG, "P2P Dump\n");
4941 for (i = 0; i < pu8IEs[index + 7]; i++)
4942 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
4944 pNewJoinBssParam->cnt = pu8IEs[index + 11];
4945 u16P2P_count = index + 12;
4947 memcpy(pNewJoinBssParam->duration, pu8IEs + u16P2P_count, 4);
4950 memcpy(pNewJoinBssParam->interval, pu8IEs + u16P2P_count, 4);
4953 memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
4955 index += pu8IEs[index + 1] + 2;
4958 } else if ((pu8IEs[index] == RSN_IE) ||
4959 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
4960 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
4961 (pu8IEs[index + 5] == 0x01))) {
4962 u16 rsnIndex = index;
4964 if (pu8IEs[rsnIndex] == RSN_IE) {
4965 pNewJoinBssParam->mode_802_11i = 2;
4967 if (pNewJoinBssParam->mode_802_11i == 0)
4968 pNewJoinBssParam->mode_802_11i = 1;
4973 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
4975 jumpOffset = pu8IEs[rsnIndex] * 4;
4976 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
4979 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
4980 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
4982 pcipherTotalCount += pcipherCount;
4983 rsnIndex += jumpOffset;
4985 jumpOffset = pu8IEs[rsnIndex] * 4;
4987 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
4990 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
4991 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
4993 authTotalCount += authCount;
4994 rsnIndex += jumpOffset;
4996 if (pu8IEs[index] == RSN_IE) {
4997 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
4998 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
5001 pNewJoinBssParam->rsn_found = true;
5002 index += pu8IEs[index + 1] + 2;
5005 index += pu8IEs[index + 1] + 2;
5012 return (void *)pNewJoinBssParam;
5016 void host_int_freeJoinParams(void *pJoinParams)
5018 if ((struct bss_param *)pJoinParams != NULL)
5019 kfree((struct bss_param *)pJoinParams);
5021 PRINT_ER("Unable to FREE null pointer\n");
5024 s32 host_int_delBASession(struct host_if_drv *hif_drv, char *pBSSID, char TID)
5027 struct host_if_msg msg;
5028 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
5031 PRINT_ER("driver is null\n");
5035 memset(&msg, 0, sizeof(struct host_if_msg));
5037 msg.id = HOST_IF_MSG_DEL_BA_SESSION;
5039 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
5040 pBASessionInfo->u8Ted = TID;
5043 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
5045 PRINT_ER("wilc_mq_send fail\n");
5047 down(&hif_sema_wait_response);
5052 s32 host_int_del_All_Rx_BASession(struct host_if_drv *hif_drv,
5057 struct host_if_msg msg;
5058 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
5061 PRINT_ER("driver is null\n");
5065 memset(&msg, 0, sizeof(struct host_if_msg));
5067 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
5069 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
5070 pBASessionInfo->u8Ted = TID;
5073 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
5075 PRINT_ER("wilc_mq_send fail\n");
5077 down(&hif_sema_wait_response);
5082 s32 host_int_setup_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
5085 struct host_if_msg msg;
5090 PRINT_ER("driver is null\n");
5094 memset(&msg, 0, sizeof(struct host_if_msg));
5096 msg.id = HOST_IF_MSG_SET_IPADDRESS;
5098 msg.body.ip_info.ip_addr = u16ipadd;
5100 msg.body.ip_info.idx = idx;
5102 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
5104 PRINT_ER("wilc_mq_send fail\n");
5111 s32 host_int_get_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
5114 struct host_if_msg msg;
5117 PRINT_ER("driver is null\n");
5121 memset(&msg, 0, sizeof(struct host_if_msg));
5123 msg.id = HOST_IF_MSG_GET_IPADDRESS;
5125 msg.body.ip_info.ip_addr = u16ipadd;
5127 msg.body.ip_info.idx = idx;
5129 s32Error = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
5131 PRINT_ER("wilc_mq_send fail\n");