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
63 #define FALSE_FRMWR_CHANNEL 100
65 struct cfg_param_attr {
66 struct cfg_param_val cfg_attr_info;
69 struct host_if_wpa_attr {
79 struct host_if_wep_attr {
84 enum AUTHTYPE auth_type;
87 union host_if_key_attr {
88 struct host_if_wep_attr wep;
89 struct host_if_wpa_attr wpa;
90 struct host_if_pmkid_attr pmkid;
96 union host_if_key_attr attr;
106 wilc_scan_result result;
108 struct hidden_network hidden_network;
111 struct connect_attr {
118 wilc_connect_result result;
120 enum AUTHTYPE auth_type;
125 struct rcvd_async_info {
130 struct channel_attr {
143 struct set_multicast {
149 u8 del_all_sta[MAX_NUM_STA][ETH_ALEN];
154 u8 mac_addr[ETH_ALEN];
157 struct power_mgmt_param {
167 struct sta_inactive_t {
172 struct scan_attr scan_info;
173 struct connect_attr con_info;
174 struct rcvd_net_info net_info;
175 struct rcvd_async_info async_info;
176 struct key_attr key_info;
177 struct cfg_param_attr cfg_info;
178 struct channel_attr channel_info;
179 struct beacon_attr beacon_info;
180 struct add_sta_param add_sta_info;
181 struct del_sta del_sta_info;
182 struct add_sta_param edit_sta_info;
183 struct power_mgmt_param pwr_mgmt_info;
184 struct sta_inactive_t mac_info;
185 struct set_ip_addr ip_info;
186 struct drv_handler drv;
187 struct set_multicast multicast_info;
189 struct set_mac_addr set_mac_info;
190 struct get_mac_addr get_mac_info;
191 struct ba_session_info session_info;
192 struct remain_ch remain_on_ch;
193 struct reg_frame reg_frame;
195 struct del_all_sta del_all_sta_info;
200 union message_body body;
201 struct host_if_drv *drv;
204 struct join_bss_param {
210 char ssid[MAX_SSID_LEN];
212 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
219 u8 rsn_pcip_policy[3];
220 u8 rsn_auth_policy[3];
233 static struct host_if_drv *wfidrv_list[NUM_CONCURRENT_IFC + 1];
234 struct host_if_drv *terminated_handle;
237 static struct task_struct *hif_thread_handler;
238 static WILC_MsgQueueHandle hif_msg_q;
239 static struct semaphore hif_sema_thread;
240 static struct semaphore hif_sema_driver;
241 static struct semaphore hif_sema_wait_response;
242 static struct semaphore hif_sema_deinit;
243 static struct timer_list periodic_rssi;
245 u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
247 static u8 rcv_assoc_resp[MAX_ASSOC_RESP_FRAME_SIZE];
249 static bool scan_while_connected;
252 static s8 link_speed;
254 static u8 set_ip[2][4];
255 static u8 get_ip[2][4];
256 static u32 inactive_time;
257 static u8 del_beacon;
258 static u32 clients_count;
265 static u32 info_element_size;
266 static struct host_if_drv *join_req_drv;
267 #define REAL_JOIN_REQ 0
268 #define FLUSHED_JOIN_REQ 1
269 #define FLUSHED_BYTE_POS 79
271 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
273 extern void chip_sleep_manually(u32 u32SleepTime);
274 extern int linux_wlan_get_num_conn_ifcs(void);
276 static int add_handler_in_list(struct host_if_drv *handler)
280 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
281 if (!wfidrv_list[i]) {
282 wfidrv_list[i] = handler;
290 static int remove_handler_in_list(struct host_if_drv *handler)
294 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
295 if (wfidrv_list[i] == handler) {
296 wfidrv_list[i] = NULL;
304 static int get_id_from_handler(struct host_if_drv *handler)
311 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
312 if (wfidrv_list[i] == handler)
319 static struct host_if_drv *get_handler_from_id(int id)
321 if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list))
323 return wfidrv_list[id];
326 static s32 Handle_SetChannel(struct host_if_drv *hif_drv,
327 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 result = send_config_pkt(SET_CFG, &strWID, 1,
340 get_id_from_handler(hif_drv));
343 PRINT_ER("Failed to set channel\n");
350 static s32 Handle_SetWfiDrvHandler(struct host_if_drv *hif_drv,
351 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 result = 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)
381 strWID.id = (u16)WID_SET_OPERATION_MODE;
382 strWID.type = WID_INT;
383 strWID.val = (s8 *)&(pstrHostIfSetOperationMode->u32Mode);
384 strWID.size = sizeof(u32);
386 result = send_config_pkt(SET_CFG, &strWID, 1,
387 get_id_from_handler(hif_drv));
389 if ((pstrHostIfSetOperationMode->u32Mode) == IDLE_MODE)
390 up(&hif_sema_driver);
393 PRINT_ER("Failed to set driver handler\n");
400 s32 Handle_set_IPAddress(struct host_if_drv *hif_drv, u8 *pu8IPAddr, u8 idx)
404 char firmwareIPAddress[4] = {0};
406 if (pu8IPAddr[0] < 192)
409 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n", idx, pu8IPAddr);
411 memcpy(set_ip[idx], pu8IPAddr, IP_ALEN);
413 strWID.id = (u16)WID_IP_ADDRESS;
414 strWID.type = WID_STR;
415 strWID.val = (u8 *)pu8IPAddr;
416 strWID.size = IP_ALEN;
418 result = send_config_pkt(SET_CFG, &strWID, 1,
419 get_id_from_handler(hif_drv));
421 host_int_get_ipaddress(hif_drv, firmwareIPAddress, idx);
424 PRINT_ER("Failed to set IP address\n");
428 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
433 s32 Handle_get_IPAddress(struct host_if_drv *hif_drv, u8 *pu8IPAddr, u8 idx)
438 strWID.id = (u16)WID_IP_ADDRESS;
439 strWID.type = WID_STR;
440 strWID.val = kmalloc(IP_ALEN, GFP_KERNEL);
441 strWID.size = IP_ALEN;
443 result = send_config_pkt(GET_CFG, &strWID, 1,
444 get_id_from_handler(hif_drv));
446 PRINT_INFO(HOSTINF_DBG, "%pI4\n", strWID.val);
448 memcpy(get_ip[idx], strWID.val, IP_ALEN);
452 if (memcmp(get_ip[idx], set_ip[idx], IP_ALEN) != 0)
453 host_int_setup_ipaddress(hif_drv, set_ip[idx], idx);
456 PRINT_ER("Failed to get IP address\n");
460 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
461 PRINT_INFO(HOSTINF_DBG, "%pI4\n", get_ip[idx]);
462 PRINT_INFO(HOSTINF_DBG, "\n");
467 static s32 Handle_SetMacAddress(struct host_if_drv *hif_drv,
468 struct set_mac_addr *pstrHostIfSetMacAddress)
472 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
474 if (mac_buf == NULL) {
475 PRINT_ER("No buffer to send mac address\n");
478 memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
480 strWID.id = (u16)WID_MAC_ADDR;
481 strWID.type = WID_STR;
482 strWID.val = mac_buf;
483 strWID.size = ETH_ALEN;
484 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", strWID.val);
486 result = send_config_pkt(SET_CFG, &strWID, 1,
487 get_id_from_handler(hif_drv));
489 PRINT_ER("Failed to set mac address\n");
497 static s32 Handle_GetMacAddress(struct host_if_drv *hif_drv,
498 struct get_mac_addr *pstrHostIfGetMacAddress)
503 strWID.id = (u16)WID_MAC_ADDR;
504 strWID.type = WID_STR;
505 strWID.val = pstrHostIfGetMacAddress->u8MacAddress;
506 strWID.size = ETH_ALEN;
508 result = send_config_pkt(GET_CFG, &strWID, 1,
509 get_id_from_handler(hif_drv));
512 PRINT_ER("Failed to get mac address\n");
515 up(&hif_sema_wait_response);
520 static s32 Handle_CfgParam(struct host_if_drv *hif_drv,
521 struct cfg_param_attr *strHostIFCfgParamAttr)
524 struct wid strWIDList[32];
527 down(&hif_drv->gtOsCfgValuesSem);
530 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
532 if (strHostIFCfgParamAttr->cfg_attr_info.flag & BSS_TYPE) {
533 if (strHostIFCfgParamAttr->cfg_attr_info.bss_type < 6) {
534 strWIDList[u8WidCnt].id = WID_BSS_TYPE;
535 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.bss_type;
536 strWIDList[u8WidCnt].type = WID_CHAR;
537 strWIDList[u8WidCnt].size = sizeof(char);
538 hif_drv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->cfg_attr_info.bss_type;
540 PRINT_ER("check value 6 over\n");
546 if (strHostIFCfgParamAttr->cfg_attr_info.flag & AUTH_TYPE) {
547 if ((strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 1 || (strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 2 || (strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 5) {
548 strWIDList[u8WidCnt].id = WID_AUTH_TYPE;
549 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.auth_type;
550 strWIDList[u8WidCnt].type = WID_CHAR;
551 strWIDList[u8WidCnt].size = sizeof(char);
552 hif_drv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->cfg_attr_info.auth_type;
554 PRINT_ER("Impossible value \n");
560 if (strHostIFCfgParamAttr->cfg_attr_info.flag & AUTHEN_TIMEOUT) {
561 if (strHostIFCfgParamAttr->cfg_attr_info.auth_timeout > 0 && strHostIFCfgParamAttr->cfg_attr_info.auth_timeout < 65536) {
562 strWIDList[u8WidCnt].id = WID_AUTH_TIMEOUT;
563 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.auth_timeout;
564 strWIDList[u8WidCnt].type = WID_SHORT;
565 strWIDList[u8WidCnt].size = sizeof(u16);
566 hif_drv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->cfg_attr_info.auth_timeout;
568 PRINT_ER("Range(1 ~ 65535) over\n");
574 if (strHostIFCfgParamAttr->cfg_attr_info.flag & POWER_MANAGEMENT) {
575 if (strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode < 5) {
576 strWIDList[u8WidCnt].id = WID_POWER_MANAGEMENT;
577 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode;
578 strWIDList[u8WidCnt].type = WID_CHAR;
579 strWIDList[u8WidCnt].size = sizeof(char);
580 hif_drv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode;
582 PRINT_ER("Invalide power mode\n");
588 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RETRY_SHORT) {
589 if ((strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit > 0) && (strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit < 256)) {
590 strWIDList[u8WidCnt].id = WID_SHORT_RETRY_LIMIT;
591 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit;
592 strWIDList[u8WidCnt].type = WID_SHORT;
593 strWIDList[u8WidCnt].size = sizeof(u16);
594 hif_drv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit;
596 PRINT_ER("Range(1~256) over\n");
602 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RETRY_LONG) {
603 if ((strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit > 0) && (strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit < 256)) {
604 strWIDList[u8WidCnt].id = WID_LONG_RETRY_LIMIT;
605 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit;
607 strWIDList[u8WidCnt].type = WID_SHORT;
608 strWIDList[u8WidCnt].size = sizeof(u16);
609 hif_drv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit;
611 PRINT_ER("Range(1~256) over\n");
617 if (strHostIFCfgParamAttr->cfg_attr_info.flag & FRAG_THRESHOLD) {
619 if (strHostIFCfgParamAttr->cfg_attr_info.frag_threshold > 255 && strHostIFCfgParamAttr->cfg_attr_info.frag_threshold < 7937) {
620 strWIDList[u8WidCnt].id = WID_FRAG_THRESHOLD;
621 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.frag_threshold;
622 strWIDList[u8WidCnt].type = WID_SHORT;
623 strWIDList[u8WidCnt].size = sizeof(u16);
624 hif_drv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->cfg_attr_info.frag_threshold;
626 PRINT_ER("Threshold Range fail\n");
632 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RTS_THRESHOLD) {
633 if (strHostIFCfgParamAttr->cfg_attr_info.rts_threshold > 255 && strHostIFCfgParamAttr->cfg_attr_info.rts_threshold < 65536) {
634 strWIDList[u8WidCnt].id = WID_RTS_THRESHOLD;
635 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.rts_threshold;
636 strWIDList[u8WidCnt].type = WID_SHORT;
637 strWIDList[u8WidCnt].size = sizeof(u16);
638 hif_drv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->cfg_attr_info.rts_threshold;
640 PRINT_ER("Threshold Range fail\n");
646 if (strHostIFCfgParamAttr->cfg_attr_info.flag & PREAMBLE) {
647 if (strHostIFCfgParamAttr->cfg_attr_info.preamble_type < 3) {
648 strWIDList[u8WidCnt].id = WID_PREAMBLE;
649 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.preamble_type;
650 strWIDList[u8WidCnt].type = WID_CHAR;
651 strWIDList[u8WidCnt].size = sizeof(char);
652 hif_drv->strCfgValues.preamble_type = strHostIFCfgParamAttr->cfg_attr_info.preamble_type;
654 PRINT_ER("Preamle Range(0~2) over\n");
660 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SHORT_SLOT_ALLOWED) {
661 if (strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed < 2) {
662 strWIDList[u8WidCnt].id = WID_SHORT_SLOT_ALLOWED;
663 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed;
664 strWIDList[u8WidCnt].type = WID_CHAR;
665 strWIDList[u8WidCnt].size = sizeof(char);
666 hif_drv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed;
668 PRINT_ER("Short slot(2) over\n");
674 if (strHostIFCfgParamAttr->cfg_attr_info.flag & TXOP_PROT_DISABLE) {
675 if (strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled < 2) {
676 strWIDList[u8WidCnt].id = WID_11N_TXOP_PROT_DISABLE;
677 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled;
678 strWIDList[u8WidCnt].type = WID_CHAR;
679 strWIDList[u8WidCnt].size = sizeof(char);
680 hif_drv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled;
682 PRINT_ER("TXOP prot disable\n");
688 if (strHostIFCfgParamAttr->cfg_attr_info.flag & BEACON_INTERVAL) {
689 if (strHostIFCfgParamAttr->cfg_attr_info.beacon_interval > 0 && strHostIFCfgParamAttr->cfg_attr_info.beacon_interval < 65536) {
690 strWIDList[u8WidCnt].id = WID_BEACON_INTERVAL;
691 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.beacon_interval;
692 strWIDList[u8WidCnt].type = WID_SHORT;
693 strWIDList[u8WidCnt].size = sizeof(u16);
694 hif_drv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->cfg_attr_info.beacon_interval;
696 PRINT_ER("Beacon interval(1~65535) fail\n");
702 if (strHostIFCfgParamAttr->cfg_attr_info.flag & DTIM_PERIOD) {
703 if (strHostIFCfgParamAttr->cfg_attr_info.dtim_period > 0 && strHostIFCfgParamAttr->cfg_attr_info.dtim_period < 256) {
704 strWIDList[u8WidCnt].id = WID_DTIM_PERIOD;
705 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.dtim_period;
706 strWIDList[u8WidCnt].type = WID_CHAR;
707 strWIDList[u8WidCnt].size = sizeof(char);
708 hif_drv->strCfgValues.dtim_period = strHostIFCfgParamAttr->cfg_attr_info.dtim_period;
710 PRINT_ER("DTIM range(1~255) fail\n");
716 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SITE_SURVEY) {
717 if (strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled < 3) {
718 strWIDList[u8WidCnt].id = WID_SITE_SURVEY;
719 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled;
720 strWIDList[u8WidCnt].type = WID_CHAR;
721 strWIDList[u8WidCnt].size = sizeof(char);
722 hif_drv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled;
724 PRINT_ER("Site survey disable\n");
730 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SITE_SURVEY_SCAN_TIME) {
731 if (strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time < 65536) {
732 strWIDList[u8WidCnt].id = WID_SITE_SURVEY_SCAN_TIME;
733 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time;
734 strWIDList[u8WidCnt].type = WID_SHORT;
735 strWIDList[u8WidCnt].size = sizeof(u16);
736 hif_drv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time;
738 PRINT_ER("Site survey scan time(1~65535) over\n");
744 if (strHostIFCfgParamAttr->cfg_attr_info.flag & ACTIVE_SCANTIME) {
745 if (strHostIFCfgParamAttr->cfg_attr_info.active_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.active_scan_time < 65536) {
746 strWIDList[u8WidCnt].id = WID_ACTIVE_SCAN_TIME;
747 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.active_scan_time;
748 strWIDList[u8WidCnt].type = WID_SHORT;
749 strWIDList[u8WidCnt].size = sizeof(u16);
750 hif_drv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->cfg_attr_info.active_scan_time;
752 PRINT_ER("Active scan time(1~65535) over\n");
758 if (strHostIFCfgParamAttr->cfg_attr_info.flag & PASSIVE_SCANTIME) {
759 if (strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time < 65536) {
760 strWIDList[u8WidCnt].id = WID_PASSIVE_SCAN_TIME;
761 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time;
762 strWIDList[u8WidCnt].type = WID_SHORT;
763 strWIDList[u8WidCnt].size = sizeof(u16);
764 hif_drv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time;
766 PRINT_ER("Passive scan time(1~65535) over\n");
772 if (strHostIFCfgParamAttr->cfg_attr_info.flag & CURRENT_TX_RATE) {
773 enum CURRENT_TXRATE curr_tx_rate = strHostIFCfgParamAttr->cfg_attr_info.curr_tx_rate;
774 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
775 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
776 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
777 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
778 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
779 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
780 strWIDList[u8WidCnt].id = WID_CURRENT_TX_RATE;
781 strWIDList[u8WidCnt].val = (s8 *)&curr_tx_rate;
782 strWIDList[u8WidCnt].type = WID_SHORT;
783 strWIDList[u8WidCnt].size = sizeof(u16);
784 hif_drv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
786 PRINT_ER("out of TX rate\n");
793 result = send_config_pkt(SET_CFG, strWIDList, u8WidCnt,
794 get_id_from_handler(hif_drv));
797 PRINT_ER("Error in setting CFG params\n");
800 up(&hif_drv->gtOsCfgValuesSem);
804 static s32 Handle_wait_msg_q_empty(void)
806 g_wilc_initialized = 0;
807 up(&hif_sema_wait_response);
811 static s32 Handle_Scan(struct host_if_drv *hif_drv,
812 struct scan_attr *pstrHostIFscanAttr)
815 struct wid strWIDList[5];
816 u32 u32WidsCount = 0;
820 u8 *pu8HdnNtwrksWidVal = NULL;
822 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
823 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", hif_drv->enuHostIFstate);
825 hif_drv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->result;
826 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->arg;
828 if ((hif_drv->enuHostIFstate >= HOST_IF_SCANNING) && (hif_drv->enuHostIFstate < HOST_IF_CONNECTED)) {
829 PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", hif_drv->enuHostIFstate);
830 PRINT_ER("Already scan\n");
835 if (g_obtainingIP || connecting) {
836 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
837 PRINT_ER("Don't do obss scan\n");
842 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
845 hif_drv->strWILC_UsrScanReq.u32RcvdChCount = 0;
847 strWIDList[u32WidsCount].id = (u16)WID_SSID_PROBE_REQ;
848 strWIDList[u32WidsCount].type = WID_STR;
850 for (i = 0; i < pstrHostIFscanAttr->hidden_network.u8ssidnum; i++)
851 valuesize += ((pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
852 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
853 strWIDList[u32WidsCount].val = pu8HdnNtwrksWidVal;
854 if (strWIDList[u32WidsCount].val != NULL) {
855 pu8Buffer = strWIDList[u32WidsCount].val;
857 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.u8ssidnum;
859 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->hidden_network.u8ssidnum);
861 for (i = 0; i < pstrHostIFscanAttr->hidden_network.u8ssidnum; i++) {
862 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen;
863 memcpy(pu8Buffer, pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen);
864 pu8Buffer += pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen;
869 strWIDList[u32WidsCount].size = (s32)(valuesize + 1);
874 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_PROBE;
875 strWIDList[u32WidsCount].type = WID_BIN_DATA;
876 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ies;
877 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ies_len;
881 strWIDList[u32WidsCount].id = WID_SCAN_TYPE;
882 strWIDList[u32WidsCount].type = WID_CHAR;
883 strWIDList[u32WidsCount].size = sizeof(char);
884 strWIDList[u32WidsCount].val = (s8 *)(&(pstrHostIFscanAttr->type));
887 strWIDList[u32WidsCount].id = WID_SCAN_CHANNEL_LIST;
888 strWIDList[u32WidsCount].type = WID_BIN_DATA;
890 if (pstrHostIFscanAttr->ch_freq_list != NULL && pstrHostIFscanAttr->ch_list_len > 0) {
893 for (i = 0; i < pstrHostIFscanAttr->ch_list_len; i++) {
894 if (pstrHostIFscanAttr->ch_freq_list[i] > 0)
895 pstrHostIFscanAttr->ch_freq_list[i] = pstrHostIFscanAttr->ch_freq_list[i] - 1;
899 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ch_freq_list;
900 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ch_list_len;
903 strWIDList[u32WidsCount].id = WID_START_SCAN_REQ;
904 strWIDList[u32WidsCount].type = WID_CHAR;
905 strWIDList[u32WidsCount].size = sizeof(char);
906 strWIDList[u32WidsCount].val = (s8 *)(&(pstrHostIFscanAttr->src));
909 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)
910 scan_while_connected = true;
911 else if (hif_drv->enuHostIFstate == HOST_IF_IDLE)
912 scan_while_connected = false;
914 result = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
915 get_id_from_handler(hif_drv));
918 PRINT_ER("Failed to send scan paramters config packet\n");
920 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
924 del_timer(&hif_drv->hScanTimer);
925 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
928 kfree(pstrHostIFscanAttr->ch_freq_list);
929 pstrHostIFscanAttr->ch_freq_list = NULL;
931 kfree(pstrHostIFscanAttr->ies);
932 pstrHostIFscanAttr->ies = NULL;
933 kfree(pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo);
934 pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo = NULL;
936 kfree(pu8HdnNtwrksWidVal);
941 static s32 Handle_ScanDone(struct host_if_drv *hif_drv,
942 enum scan_event enuEvent)
945 u8 u8abort_running_scan;
949 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
951 if (enuEvent == SCAN_EVENT_ABORTED) {
952 PRINT_D(GENERIC_DBG, "Abort running scan\n");
953 u8abort_running_scan = 1;
954 strWID.id = (u16)WID_ABORT_RUNNING_SCAN;
955 strWID.type = WID_CHAR;
956 strWID.val = (s8 *)&u8abort_running_scan;
957 strWID.size = sizeof(char);
959 result = send_config_pkt(SET_CFG, &strWID, 1,
960 get_id_from_handler(hif_drv));
963 PRINT_ER("Failed to set abort running scan\n");
969 PRINT_ER("Driver handler is NULL\n");
973 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
974 hif_drv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
975 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
976 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
982 u8 u8ConnectedSSID[6] = {0};
983 static s32 Handle_Connect(struct host_if_drv *hif_drv,
984 struct connect_attr *pstrHostIFconnectAttr)
987 struct wid strWIDList[8];
988 u32 u32WidsCount = 0, dummyval = 0;
989 u8 *pu8CurrByte = NULL;
990 struct join_bss_param *ptstrJoinBssParam;
992 PRINT_D(GENERIC_DBG, "Handling connect request\n");
994 if (memcmp(pstrHostIFconnectAttr->bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
996 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1000 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1002 ptstrJoinBssParam = (struct join_bss_param *)pstrHostIFconnectAttr->params;
1003 if (ptstrJoinBssParam == NULL) {
1004 PRINT_ER("Required BSSID not found\n");
1009 if (pstrHostIFconnectAttr->bssid != NULL) {
1010 hif_drv->strWILC_UsrConnReq.pu8bssid = kmalloc(6, GFP_KERNEL);
1011 memcpy(hif_drv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->bssid, 6);
1014 hif_drv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssid_len;
1015 if (pstrHostIFconnectAttr->ssid != NULL) {
1016 hif_drv->strWILC_UsrConnReq.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssid_len + 1, GFP_KERNEL);
1017 memcpy(hif_drv->strWILC_UsrConnReq.pu8ssid,
1018 pstrHostIFconnectAttr->ssid,
1019 pstrHostIFconnectAttr->ssid_len);
1020 hif_drv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssid_len] = '\0';
1023 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->ies_len;
1024 if (pstrHostIFconnectAttr->ies != NULL) {
1025 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
1026 memcpy(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
1027 pstrHostIFconnectAttr->ies,
1028 pstrHostIFconnectAttr->ies_len);
1031 hif_drv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->security;
1032 hif_drv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->auth_type;
1033 hif_drv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->result;
1034 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->arg;
1036 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
1037 strWIDList[u32WidsCount].type = WID_INT;
1038 strWIDList[u32WidsCount].size = sizeof(u32);
1039 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1042 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
1043 strWIDList[u32WidsCount].type = WID_INT;
1044 strWIDList[u32WidsCount].size = sizeof(u32);
1045 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1048 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
1049 strWIDList[u32WidsCount].type = WID_INT;
1050 strWIDList[u32WidsCount].size = sizeof(u32);
1051 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1055 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
1056 strWIDList[u32WidsCount].type = WID_BIN_DATA;
1057 strWIDList[u32WidsCount].val = hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs;
1058 strWIDList[u32WidsCount].size = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1061 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1062 info_element_size = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1063 info_element = kmalloc(info_element_size, GFP_KERNEL);
1064 memcpy(info_element, hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
1068 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
1069 strWIDList[u32WidsCount].type = WID_CHAR;
1070 strWIDList[u32WidsCount].size = sizeof(char);
1071 strWIDList[u32WidsCount].val = (s8 *)(&(hif_drv->strWILC_UsrConnReq.u8security));
1074 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
1075 mode_11i = hif_drv->strWILC_UsrConnReq.u8security;
1077 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", hif_drv->strWILC_UsrConnReq.u8security);
1080 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
1081 strWIDList[u32WidsCount].type = WID_CHAR;
1082 strWIDList[u32WidsCount].size = sizeof(char);
1083 strWIDList[u32WidsCount].val = (s8 *)(&hif_drv->strWILC_UsrConnReq.tenuAuth_type);
1086 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
1087 auth_type = (u8)hif_drv->strWILC_UsrConnReq.tenuAuth_type;
1089 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", hif_drv->strWILC_UsrConnReq.tenuAuth_type);
1090 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
1091 hif_drv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->ch);
1093 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
1094 strWIDList[u32WidsCount].type = WID_STR;
1095 strWIDList[u32WidsCount].size = 112;
1096 strWIDList[u32WidsCount].val = kmalloc(strWIDList[u32WidsCount].size, GFP_KERNEL);
1098 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1099 join_req_size = strWIDList[u32WidsCount].size;
1100 join_req = kmalloc(join_req_size, GFP_KERNEL);
1102 if (strWIDList[u32WidsCount].val == NULL) {
1107 pu8CurrByte = strWIDList[u32WidsCount].val;
1110 if (pstrHostIFconnectAttr->ssid != NULL) {
1111 memcpy(pu8CurrByte, pstrHostIFconnectAttr->ssid, pstrHostIFconnectAttr->ssid_len);
1112 pu8CurrByte[pstrHostIFconnectAttr->ssid_len] = '\0';
1114 pu8CurrByte += MAX_SSID_LEN;
1115 *(pu8CurrByte++) = INFRASTRUCTURE;
1117 if ((pstrHostIFconnectAttr->ch >= 1) && (pstrHostIFconnectAttr->ch <= 14)) {
1118 *(pu8CurrByte++) = pstrHostIFconnectAttr->ch;
1120 PRINT_ER("Channel out of range\n");
1121 *(pu8CurrByte++) = 0xFF;
1123 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1124 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1125 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1127 if (pstrHostIFconnectAttr->bssid != NULL)
1128 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
1131 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1132 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1133 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1134 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1135 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1137 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
1138 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1140 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1141 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1142 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1144 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1145 hif_drv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
1147 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1148 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1149 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1150 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1151 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1152 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1154 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
1155 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1157 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
1158 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1160 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
1161 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1163 *(pu8CurrByte++) = REAL_JOIN_REQ;
1164 *(pu8CurrByte++) = ptstrJoinBssParam->noa_enabled;
1166 if (ptstrJoinBssParam->noa_enabled) {
1167 PRINT_D(HOSTINF_DBG, "NOA present\n");
1169 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1170 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1171 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1172 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1174 *(pu8CurrByte++) = ptstrJoinBssParam->opp_enabled;
1175 *(pu8CurrByte++) = ptstrJoinBssParam->idx;
1177 if (ptstrJoinBssParam->opp_enabled)
1178 *(pu8CurrByte++) = ptstrJoinBssParam->ct_window;
1180 *(pu8CurrByte++) = ptstrJoinBssParam->cnt;
1182 memcpy(pu8CurrByte, ptstrJoinBssParam->duration, sizeof(ptstrJoinBssParam->duration));
1183 pu8CurrByte += sizeof(ptstrJoinBssParam->duration);
1185 memcpy(pu8CurrByte, ptstrJoinBssParam->interval, sizeof(ptstrJoinBssParam->interval));
1186 pu8CurrByte += sizeof(ptstrJoinBssParam->interval);
1188 memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
1190 pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1193 PRINT_D(HOSTINF_DBG, "NOA not present\n");
1195 pu8CurrByte = strWIDList[u32WidsCount].val;
1198 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1199 memcpy(join_req, pu8CurrByte, join_req_size);
1200 join_req_drv = hif_drv;
1203 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1205 if (pstrHostIFconnectAttr->bssid != NULL) {
1206 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->bssid, ETH_ALEN);
1208 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n", pstrHostIFconnectAttr->bssid);
1209 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", u8ConnectedSSID);
1212 result = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
1213 get_id_from_handler(hif_drv));
1215 PRINT_ER("failed to send config packet\n");
1219 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
1220 hif_drv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1225 tstrConnectInfo strConnectInfo;
1227 del_timer(&hif_drv->hConnectTimer);
1229 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
1231 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1233 if (pstrHostIFconnectAttr->result != NULL) {
1234 if (pstrHostIFconnectAttr->bssid != NULL)
1235 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->bssid, 6);
1237 if (pstrHostIFconnectAttr->ies != NULL) {
1238 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->ies_len;
1239 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
1240 memcpy(strConnectInfo.pu8ReqIEs,
1241 pstrHostIFconnectAttr->ies,
1242 pstrHostIFconnectAttr->ies_len);
1245 pstrHostIFconnectAttr->result(CONN_DISCONN_EVENT_CONN_RESP,
1249 pstrHostIFconnectAttr->arg);
1250 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1251 kfree(strConnectInfo.pu8ReqIEs);
1252 strConnectInfo.pu8ReqIEs = NULL;
1255 PRINT_ER("Connect callback function pointer is NULL\n");
1259 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
1260 kfree(pstrHostIFconnectAttr->bssid);
1261 pstrHostIFconnectAttr->bssid = NULL;
1263 kfree(pstrHostIFconnectAttr->ssid);
1264 pstrHostIFconnectAttr->ssid = NULL;
1266 kfree(pstrHostIFconnectAttr->ies);
1267 pstrHostIFconnectAttr->ies = NULL;
1273 static s32 Handle_FlushConnect(struct host_if_drv *hif_drv)
1276 struct wid strWIDList[5];
1277 u32 u32WidsCount = 0;
1278 u8 *pu8CurrByte = NULL;
1280 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
1281 strWIDList[u32WidsCount].type = WID_BIN_DATA;
1282 strWIDList[u32WidsCount].val = info_element;
1283 strWIDList[u32WidsCount].size = info_element_size;
1286 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
1287 strWIDList[u32WidsCount].type = WID_CHAR;
1288 strWIDList[u32WidsCount].size = sizeof(char);
1289 strWIDList[u32WidsCount].val = (s8 *)(&(mode_11i));
1294 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
1295 strWIDList[u32WidsCount].type = WID_CHAR;
1296 strWIDList[u32WidsCount].size = sizeof(char);
1297 strWIDList[u32WidsCount].val = (s8 *)(&auth_type);
1300 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
1301 strWIDList[u32WidsCount].type = WID_STR;
1302 strWIDList[u32WidsCount].size = join_req_size;
1303 strWIDList[u32WidsCount].val = (s8 *)join_req;
1304 pu8CurrByte = strWIDList[u32WidsCount].val;
1306 pu8CurrByte += FLUSHED_BYTE_POS;
1307 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1311 result = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
1312 get_id_from_handler(join_req_drv));
1314 PRINT_ER("failed to send config packet\n");
1321 static s32 Handle_ConnectTimeout(struct host_if_drv *hif_drv)
1324 tstrConnectInfo strConnectInfo;
1326 u16 u16DummyReasonCode = 0;
1329 PRINT_ER("Driver handler is NULL\n");
1333 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1335 scan_while_connected = false;
1337 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1339 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
1340 if (hif_drv->strWILC_UsrConnReq.pu8bssid != NULL) {
1341 memcpy(strConnectInfo.au8bssid,
1342 hif_drv->strWILC_UsrConnReq.pu8bssid, 6);
1345 if (hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1346 strConnectInfo.ReqIEsLen = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1347 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
1348 memcpy(strConnectInfo.pu8ReqIEs,
1349 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
1350 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen);
1353 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1357 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
1359 kfree(strConnectInfo.pu8ReqIEs);
1360 strConnectInfo.pu8ReqIEs = NULL;
1362 PRINT_ER("Connect callback function pointer is NULL\n");
1365 strWID.id = (u16)WID_DISCONNECT;
1366 strWID.type = WID_CHAR;
1367 strWID.val = (s8 *)&u16DummyReasonCode;
1368 strWID.size = sizeof(char);
1370 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1372 result = send_config_pkt(SET_CFG, &strWID, 1,
1373 get_id_from_handler(hif_drv));
1375 PRINT_ER("Failed to send dissconect config packet\n");
1377 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
1378 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
1379 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
1380 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1381 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
1383 eth_zero_addr(u8ConnectedSSID);
1385 if (join_req != NULL && join_req_drv == hif_drv) {
1390 if (info_element != NULL && join_req_drv == hif_drv) {
1391 kfree(info_element);
1392 info_element = NULL;
1398 static s32 Handle_RcvdNtwrkInfo(struct host_if_drv *hif_drv,
1399 struct rcvd_net_info *pstrRcvdNetworkInfo)
1402 bool bNewNtwrkFound;
1404 tstrNetworkInfo *pstrNetworkInfo = NULL;
1405 void *pJoinParams = NULL;
1407 bNewNtwrkFound = true;
1408 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
1410 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
1411 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
1412 parse_network_info(pstrRcvdNetworkInfo->buffer, &pstrNetworkInfo);
1413 if ((pstrNetworkInfo == NULL)
1414 || (hif_drv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
1415 PRINT_ER("driver is null\n");
1420 for (i = 0; i < hif_drv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
1422 if ((hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
1423 (pstrNetworkInfo->au8bssid != NULL)) {
1424 if (memcmp(hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
1425 pstrNetworkInfo->au8bssid, 6) == 0) {
1426 if (pstrNetworkInfo->s8rssi <= hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
1427 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
1430 hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
1431 bNewNtwrkFound = false;
1438 if (bNewNtwrkFound == true) {
1439 PRINT_D(HOSTINF_DBG, "New network found\n");
1441 if (hif_drv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
1442 hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
1444 if ((hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
1445 && (pstrNetworkInfo->au8bssid != NULL)) {
1446 memcpy(hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
1447 pstrNetworkInfo->au8bssid, 6);
1449 hif_drv->strWILC_UsrScanReq.u32RcvdChCount++;
1451 pstrNetworkInfo->bNewNetwork = true;
1452 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
1454 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1455 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid,
1461 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
1464 pstrNetworkInfo->bNewNetwork = false;
1465 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1466 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
1471 kfree(pstrRcvdNetworkInfo->buffer);
1472 pstrRcvdNetworkInfo->buffer = NULL;
1474 if (pstrNetworkInfo != NULL) {
1475 DeallocateNetworkInfo(pstrNetworkInfo);
1476 pstrNetworkInfo = NULL;
1482 static s32 Handle_RcvdGnrlAsyncInfo(struct host_if_drv *hif_drv,
1483 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
1489 u16 u16WidID = (u16)WID_NIL;
1492 u8 u8MacStatusReasonCode;
1493 u8 u8MacStatusAdditionalInfo;
1494 tstrConnectInfo strConnectInfo;
1495 tstrDisconnectNotifInfo strDisconnectNotifInfo;
1499 PRINT_ER("Driver handler is NULL\n");
1502 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", hif_drv->enuHostIFstate,
1503 pstrRcvdGnrlAsyncInfo->buffer[7]);
1505 if ((hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
1506 (hif_drv->enuHostIFstate == HOST_IF_CONNECTED) ||
1507 hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
1508 if ((pstrRcvdGnrlAsyncInfo->buffer == NULL) ||
1509 (hif_drv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
1510 PRINT_ER("driver is null\n");
1514 u8MsgType = pstrRcvdGnrlAsyncInfo->buffer[0];
1516 if ('I' != u8MsgType) {
1517 PRINT_ER("Received Message format incorrect.\n");
1521 u8MsgID = pstrRcvdGnrlAsyncInfo->buffer[1];
1522 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[2], pstrRcvdGnrlAsyncInfo->buffer[3]);
1523 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[4], pstrRcvdGnrlAsyncInfo->buffer[5]);
1524 u8WidLen = pstrRcvdGnrlAsyncInfo->buffer[6];
1525 u8MacStatus = pstrRcvdGnrlAsyncInfo->buffer[7];
1526 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->buffer[8];
1527 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->buffer[9];
1528 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
1529 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
1530 u32 u32RcvdAssocRespInfoLen;
1531 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
1533 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
1535 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1537 if (u8MacStatus == MAC_CONNECTED) {
1538 memset(rcv_assoc_resp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
1540 host_int_get_assoc_res_info(hif_drv,
1542 MAX_ASSOC_RESP_FRAME_SIZE,
1543 &u32RcvdAssocRespInfoLen);
1545 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
1547 if (u32RcvdAssocRespInfoLen != 0) {
1549 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
1550 s32Err = ParseAssocRespInfo(rcv_assoc_resp, u32RcvdAssocRespInfoLen,
1551 &pstrConnectRespInfo);
1553 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
1555 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
1557 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
1558 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
1559 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
1560 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
1563 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL);
1564 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
1565 pstrConnectRespInfo->u16RespIEsLen);
1569 if (pstrConnectRespInfo != NULL) {
1570 DeallocateAssocRespInfo(pstrConnectRespInfo);
1571 pstrConnectRespInfo = NULL;
1577 if ((u8MacStatus == MAC_CONNECTED) &&
1578 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
1579 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
1580 eth_zero_addr(u8ConnectedSSID);
1582 } else if (u8MacStatus == MAC_DISCONNECTED) {
1583 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
1584 eth_zero_addr(u8ConnectedSSID);
1587 if (hif_drv->strWILC_UsrConnReq.pu8bssid != NULL) {
1588 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
1589 memcpy(strConnectInfo.au8bssid, hif_drv->strWILC_UsrConnReq.pu8bssid, 6);
1591 if ((u8MacStatus == MAC_CONNECTED) &&
1592 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
1593 memcpy(hif_drv->au8AssociatedBSSID,
1594 hif_drv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
1599 if (hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1600 strConnectInfo.ReqIEsLen = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1601 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
1602 memcpy(strConnectInfo.pu8ReqIEs,
1603 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
1604 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen);
1608 del_timer(&hif_drv->hConnectTimer);
1609 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1613 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
1615 if ((u8MacStatus == MAC_CONNECTED) &&
1616 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
1617 host_int_set_power_mgmt(hif_drv, 0, 0);
1619 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
1620 hif_drv->enuHostIFstate = HOST_IF_CONNECTED;
1622 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
1623 g_obtainingIP = true;
1624 mod_timer(&hDuringIpTimer,
1625 jiffies + msecs_to_jiffies(10000));
1627 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
1628 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1629 scan_while_connected = false;
1632 kfree(strConnectInfo.pu8RespIEs);
1633 strConnectInfo.pu8RespIEs = NULL;
1635 kfree(strConnectInfo.pu8ReqIEs);
1636 strConnectInfo.pu8ReqIEs = NULL;
1637 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
1638 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
1639 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
1640 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1641 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
1642 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
1643 (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)) {
1644 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
1646 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
1648 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
1649 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
1650 del_timer(&hif_drv->hScanTimer);
1651 Handle_ScanDone((void *)hif_drv, SCAN_EVENT_ABORTED);
1654 strDisconnectNotifInfo.u16reason = 0;
1655 strDisconnectNotifInfo.ie = NULL;
1656 strDisconnectNotifInfo.ie_len = 0;
1658 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
1659 g_obtainingIP = false;
1660 host_int_set_power_mgmt(hif_drv, 0, 0);
1662 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1665 &strDisconnectNotifInfo,
1666 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
1669 PRINT_ER("Connect result callback function is NULL\n");
1672 eth_zero_addr(hif_drv->au8AssociatedBSSID);
1674 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
1675 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
1676 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
1677 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1678 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
1680 if (join_req != NULL && join_req_drv == hif_drv) {
1685 if (info_element != NULL && join_req_drv == hif_drv) {
1686 kfree(info_element);
1687 info_element = NULL;
1690 hif_drv->enuHostIFstate = HOST_IF_IDLE;
1691 scan_while_connected = false;
1693 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
1694 (hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
1695 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
1696 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
1698 del_timer(&hif_drv->hScanTimer);
1699 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult)
1700 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
1706 kfree(pstrRcvdGnrlAsyncInfo->buffer);
1707 pstrRcvdGnrlAsyncInfo->buffer = NULL;
1712 static int Handle_Key(struct host_if_drv *hif_drv,
1713 struct key_attr *pstrHostIFkeyAttr)
1717 struct wid strWIDList[5];
1723 switch (pstrHostIFkeyAttr->type) {
1728 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1730 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
1731 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->attr.wep.index));
1732 strWIDList[0].id = (u16)WID_11I_MODE;
1733 strWIDList[0].type = WID_CHAR;
1734 strWIDList[0].size = sizeof(char);
1735 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.mode));
1737 strWIDList[1].id = WID_AUTH_TYPE;
1738 strWIDList[1].type = WID_CHAR;
1739 strWIDList[1].size = sizeof(char);
1740 strWIDList[1].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.auth_type));
1742 strWIDList[2].id = (u16)WID_KEY_ID;
1743 strWIDList[2].type = WID_CHAR;
1745 strWIDList[2].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.index));
1746 strWIDList[2].size = sizeof(char);
1748 pu8keybuf = kmemdup(pstrHostIFkeyAttr->attr.wep.key,
1749 pstrHostIFkeyAttr->attr.wep.key_len,
1752 if (pu8keybuf == NULL) {
1753 PRINT_ER("No buffer to send Key\n");
1757 kfree(pstrHostIFkeyAttr->attr.wep.key);
1759 strWIDList[3].id = (u16)WID_WEP_KEY_VALUE;
1760 strWIDList[3].type = WID_STR;
1761 strWIDList[3].size = pstrHostIFkeyAttr->attr.wep.key_len;
1762 strWIDList[3].val = (s8 *)pu8keybuf;
1764 result = send_config_pkt(SET_CFG, strWIDList, 4,
1765 get_id_from_handler(hif_drv));
1771 if (pstrHostIFkeyAttr->action & ADDKEY) {
1772 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
1773 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2, GFP_KERNEL);
1774 if (pu8keybuf == NULL) {
1775 PRINT_ER("No buffer to send Key\n");
1778 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1779 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->attr.wep.key_len, 1);
1780 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->attr.wep.key,
1781 pstrHostIFkeyAttr->attr.wep.key_len);
1782 kfree(pstrHostIFkeyAttr->attr.wep.key);
1784 strWID.id = (u16)WID_ADD_WEP_KEY;
1785 strWID.type = WID_STR;
1786 strWID.val = (s8 *)pu8keybuf;
1787 strWID.size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
1789 result = send_config_pkt(SET_CFG, &strWID, 1,
1790 get_id_from_handler(hif_drv));
1792 } else if (pstrHostIFkeyAttr->action & REMOVEKEY) {
1794 PRINT_D(HOSTINF_DBG, "Removing key\n");
1795 strWID.id = (u16)WID_REMOVE_WEP_KEY;
1796 strWID.type = WID_STR;
1798 s8idxarray[0] = (s8)pstrHostIFkeyAttr->attr.wep.index;
1799 strWID.val = s8idxarray;
1802 result = send_config_pkt(SET_CFG, &strWID, 1,
1803 get_id_from_handler(hif_drv));
1805 strWID.id = (u16)WID_KEY_ID;
1806 strWID.type = WID_CHAR;
1807 strWID.val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.index));
1808 strWID.size = sizeof(char);
1810 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
1812 result = send_config_pkt(SET_CFG, &strWID, 1,
1813 get_id_from_handler(hif_drv));
1815 up(&hif_drv->hSemTestKeyBlock);
1819 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1820 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1821 if (pu8keybuf == NULL) {
1822 PRINT_ER("No buffer to send RxGTK Key\n");
1824 goto _WPARxGtk_end_case_;
1827 if (pstrHostIFkeyAttr->attr.wpa.seq != NULL)
1828 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1830 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1831 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1832 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1833 pstrHostIFkeyAttr->attr.wpa.key_len);
1835 strWIDList[0].id = (u16)WID_11I_MODE;
1836 strWIDList[0].type = WID_CHAR;
1837 strWIDList[0].size = sizeof(char);
1838 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wpa.mode));
1840 strWIDList[1].id = (u16)WID_ADD_RX_GTK;
1841 strWIDList[1].type = WID_STR;
1842 strWIDList[1].val = (s8 *)pu8keybuf;
1843 strWIDList[1].size = RX_MIC_KEY_MSG_LEN;
1845 result = send_config_pkt(SET_CFG, strWIDList, 2,
1846 get_id_from_handler(hif_drv));
1849 up(&hif_drv->hSemTestKeyBlock);
1852 if (pstrHostIFkeyAttr->action & ADDKEY) {
1853 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
1855 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1856 if (pu8keybuf == NULL) {
1857 PRINT_ER("No buffer to send RxGTK Key\n");
1859 goto _WPARxGtk_end_case_;
1862 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)
1863 memcpy(pu8keybuf, hif_drv->au8AssociatedBSSID, ETH_ALEN);
1865 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
1867 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1868 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1869 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1870 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1871 pstrHostIFkeyAttr->attr.wpa.key_len);
1873 strWID.id = (u16)WID_ADD_RX_GTK;
1874 strWID.type = WID_STR;
1875 strWID.val = (s8 *)pu8keybuf;
1876 strWID.size = RX_MIC_KEY_MSG_LEN;
1878 result = send_config_pkt(SET_CFG, &strWID, 1,
1879 get_id_from_handler(hif_drv));
1882 up(&hif_drv->hSemTestKeyBlock);
1884 _WPARxGtk_end_case_:
1885 kfree(pstrHostIFkeyAttr->attr.wpa.key);
1886 kfree(pstrHostIFkeyAttr->attr.wpa.seq);
1893 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1896 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
1900 if (pu8keybuf == NULL) {
1901 PRINT_ER("No buffer to send PTK Key\n");
1903 goto _WPAPtk_end_case_;
1907 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1908 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1909 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1910 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->attr.wpa.key,
1911 pstrHostIFkeyAttr->attr.wpa.key_len);
1913 strWIDList[0].id = (u16)WID_11I_MODE;
1914 strWIDList[0].type = WID_CHAR;
1915 strWIDList[0].size = sizeof(char);
1916 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wpa.mode));
1918 strWIDList[1].id = (u16)WID_ADD_PTK;
1919 strWIDList[1].type = WID_STR;
1920 strWIDList[1].val = (s8 *)pu8keybuf;
1921 strWIDList[1].size = PTK_KEY_MSG_LEN + 1;
1923 result = send_config_pkt(SET_CFG, strWIDList, 2,
1924 get_id_from_handler(hif_drv));
1926 up(&hif_drv->hSemTestKeyBlock);
1928 if (pstrHostIFkeyAttr->action & ADDKEY) {
1931 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
1935 if (pu8keybuf == NULL) {
1936 PRINT_ER("No buffer to send PTK Key\n");
1938 goto _WPAPtk_end_case_;
1942 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1943 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1944 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->attr.wpa.key,
1945 pstrHostIFkeyAttr->attr.wpa.key_len);
1947 strWID.id = (u16)WID_ADD_PTK;
1948 strWID.type = WID_STR;
1949 strWID.val = (s8 *)pu8keybuf;
1950 strWID.size = PTK_KEY_MSG_LEN;
1952 result = send_config_pkt(SET_CFG, &strWID, 1,
1953 get_id_from_handler(hif_drv));
1955 up(&hif_drv->hSemTestKeyBlock);
1959 kfree(pstrHostIFkeyAttr->attr.wpa.key);
1968 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
1970 pu8keybuf = kmalloc((pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
1971 if (pu8keybuf == NULL) {
1972 PRINT_ER("No buffer to send PMKSA Key\n");
1976 pu8keybuf[0] = pstrHostIFkeyAttr->attr.pmkid.numpmkid;
1978 for (i = 0; i < pstrHostIFkeyAttr->attr.pmkid.numpmkid; i++) {
1979 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
1980 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
1983 strWID.id = (u16)WID_PMKID_INFO;
1984 strWID.type = WID_STR;
1985 strWID.val = (s8 *)pu8keybuf;
1986 strWID.size = (pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
1988 result = send_config_pkt(SET_CFG, &strWID, 1,
1989 get_id_from_handler(hif_drv));
1996 PRINT_ER("Failed to send key config packet\n");
2001 static void Handle_Disconnect(struct host_if_drv *hif_drv)
2006 u16 u16DummyReasonCode = 0;
2008 strWID.id = (u16)WID_DISCONNECT;
2009 strWID.type = WID_CHAR;
2010 strWID.val = (s8 *)&u16DummyReasonCode;
2011 strWID.size = sizeof(char);
2015 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2017 g_obtainingIP = false;
2018 host_int_set_power_mgmt(hif_drv, 0, 0);
2020 eth_zero_addr(u8ConnectedSSID);
2022 result = send_config_pkt(SET_CFG, &strWID, 1,
2023 get_id_from_handler(hif_drv));
2026 PRINT_ER("Failed to send dissconect config packet\n");
2028 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2030 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
2032 strDisconnectNotifInfo.u16reason = 0;
2033 strDisconnectNotifInfo.ie = NULL;
2034 strDisconnectNotifInfo.ie_len = 0;
2036 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
2037 del_timer(&hif_drv->hScanTimer);
2038 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
2039 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2041 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
2044 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2045 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2046 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
2047 del_timer(&hif_drv->hConnectTimer);
2050 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
2051 0, &strDisconnectNotifInfo, hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
2053 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
2056 scan_while_connected = false;
2058 hif_drv->enuHostIFstate = HOST_IF_IDLE;
2060 eth_zero_addr(hif_drv->au8AssociatedBSSID);
2062 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
2063 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
2064 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
2065 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2066 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
2068 if (join_req != NULL && join_req_drv == hif_drv) {
2073 if (info_element != NULL && join_req_drv == hif_drv) {
2074 kfree(info_element);
2075 info_element = NULL;
2080 up(&hif_drv->hSemTestDisconnectBlock);
2084 void resolve_disconnect_aberration(struct host_if_drv *hif_drv)
2088 if ((hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (hif_drv->enuHostIFstate == HOST_IF_CONNECTING)) {
2089 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
2090 host_int_disconnect(hif_drv, 1);
2094 static s32 Handle_GetChnl(struct host_if_drv *hif_drv)
2099 strWID.id = (u16)WID_CURRENT_CHANNEL;
2100 strWID.type = WID_CHAR;
2101 strWID.val = (s8 *)&ch_no;
2102 strWID.size = sizeof(char);
2104 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
2106 result = send_config_pkt(GET_CFG, &strWID, 1,
2107 get_id_from_handler(hif_drv));
2110 PRINT_ER("Failed to get channel number\n");
2114 up(&hif_drv->hSemGetCHNL);
2119 static void Handle_GetRssi(struct host_if_drv *hif_drv)
2124 strWID.id = (u16)WID_RSSI;
2125 strWID.type = WID_CHAR;
2127 strWID.size = sizeof(char);
2129 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
2131 result = send_config_pkt(GET_CFG, &strWID, 1,
2132 get_id_from_handler(hif_drv));
2134 PRINT_ER("Failed to get RSSI value\n");
2138 up(&hif_drv->hSemGetRSSI);
2144 static void Handle_GetLinkspeed(struct host_if_drv *hif_drv)
2151 strWID.id = (u16)WID_LINKSPEED;
2152 strWID.type = WID_CHAR;
2153 strWID.val = &link_speed;
2154 strWID.size = sizeof(char);
2156 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
2158 result = send_config_pkt(GET_CFG, &strWID, 1,
2159 get_id_from_handler(hif_drv));
2161 PRINT_ER("Failed to get LINKSPEED value\n");
2165 up(&(hif_drv->hSemGetLINKSPEED));
2170 s32 Handle_GetStatistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
2172 struct wid strWIDList[5];
2173 u32 u32WidsCount = 0, result = 0;
2175 strWIDList[u32WidsCount].id = WID_LINKSPEED;
2176 strWIDList[u32WidsCount].type = WID_CHAR;
2177 strWIDList[u32WidsCount].size = sizeof(char);
2178 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u8LinkSpeed));
2181 strWIDList[u32WidsCount].id = WID_RSSI;
2182 strWIDList[u32WidsCount].type = WID_CHAR;
2183 strWIDList[u32WidsCount].size = sizeof(char);
2184 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->s8RSSI));
2187 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
2188 strWIDList[u32WidsCount].type = WID_INT;
2189 strWIDList[u32WidsCount].size = sizeof(u32);
2190 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32TxCount));
2193 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
2194 strWIDList[u32WidsCount].type = WID_INT;
2195 strWIDList[u32WidsCount].size = sizeof(u32);
2196 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32RxCount));
2199 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
2200 strWIDList[u32WidsCount].type = WID_INT;
2201 strWIDList[u32WidsCount].size = sizeof(u32);
2202 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32TxFailureCount));
2205 result = send_config_pkt(GET_CFG, strWIDList, u32WidsCount,
2206 get_id_from_handler(hif_drv));
2209 PRINT_ER("Failed to send scan paramters config packet\n");
2211 up(&hif_sema_wait_response);
2216 static s32 Handle_Get_InActiveTime(struct host_if_drv *hif_drv,
2217 struct sta_inactive_t *strHostIfStaInactiveT)
2223 strWID.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
2224 strWID.type = WID_STR;
2225 strWID.size = ETH_ALEN;
2226 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2229 stamac = strWID.val;
2230 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
2233 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
2235 result = send_config_pkt(SET_CFG, &strWID, 1,
2236 get_id_from_handler(hif_drv));
2239 PRINT_ER("Failed to SET incative time\n");
2244 strWID.id = (u16)WID_GET_INACTIVE_TIME;
2245 strWID.type = WID_INT;
2246 strWID.val = (s8 *)&inactive_time;
2247 strWID.size = sizeof(u32);
2249 result = send_config_pkt(GET_CFG, &strWID, 1,
2250 get_id_from_handler(hif_drv));
2253 PRINT_ER("Failed to get incative time\n");
2257 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", inactive_time);
2259 up(&hif_drv->hSemInactiveTime);
2264 static void Handle_AddBeacon(struct host_if_drv *hif_drv,
2265 struct beacon_attr *pstrSetBeaconParam)
2271 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
2273 strWID.id = (u16)WID_ADD_BEACON;
2274 strWID.type = WID_BIN;
2275 strWID.size = pstrSetBeaconParam->head_len + pstrSetBeaconParam->tail_len + 16;
2276 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2277 if (strWID.val == NULL)
2280 pu8CurrByte = strWID.val;
2281 *pu8CurrByte++ = (pstrSetBeaconParam->interval & 0xFF);
2282 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 8) & 0xFF);
2283 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 16) & 0xFF);
2284 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 24) & 0xFF);
2286 *pu8CurrByte++ = (pstrSetBeaconParam->dtim_period & 0xFF);
2287 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 8) & 0xFF);
2288 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 16) & 0xFF);
2289 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 24) & 0xFF);
2291 *pu8CurrByte++ = (pstrSetBeaconParam->head_len & 0xFF);
2292 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 8) & 0xFF);
2293 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 16) & 0xFF);
2294 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 24) & 0xFF);
2296 memcpy(pu8CurrByte, pstrSetBeaconParam->head, pstrSetBeaconParam->head_len);
2297 pu8CurrByte += pstrSetBeaconParam->head_len;
2299 *pu8CurrByte++ = (pstrSetBeaconParam->tail_len & 0xFF);
2300 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 8) & 0xFF);
2301 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 16) & 0xFF);
2302 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 24) & 0xFF);
2304 if (pstrSetBeaconParam->tail > 0)
2305 memcpy(pu8CurrByte, pstrSetBeaconParam->tail, pstrSetBeaconParam->tail_len);
2306 pu8CurrByte += pstrSetBeaconParam->tail_len;
2308 result = send_config_pkt(SET_CFG, &strWID, 1,
2309 get_id_from_handler(hif_drv));
2311 PRINT_ER("Failed to send add beacon config packet\n");
2315 kfree(pstrSetBeaconParam->head);
2316 kfree(pstrSetBeaconParam->tail);
2319 static void Handle_DelBeacon(struct host_if_drv *hif_drv)
2325 strWID.id = (u16)WID_DEL_BEACON;
2326 strWID.type = WID_CHAR;
2327 strWID.size = sizeof(char);
2328 strWID.val = &del_beacon;
2330 if (strWID.val == NULL)
2333 pu8CurrByte = strWID.val;
2335 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
2337 result = send_config_pkt(SET_CFG, &strWID, 1,
2338 get_id_from_handler(hif_drv));
2340 PRINT_ER("Failed to send delete beacon config packet\n");
2343 static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
2344 struct add_sta_param *pstrStationParam)
2348 pu8CurrByte = pu8Buffer;
2350 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
2351 memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
2352 pu8CurrByte += ETH_ALEN;
2354 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
2355 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
2357 *pu8CurrByte++ = pstrStationParam->u8NumRates;
2358 if (pstrStationParam->u8NumRates > 0)
2359 memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
2360 pu8CurrByte += pstrStationParam->u8NumRates;
2362 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
2363 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
2364 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
2366 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
2367 memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
2368 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
2370 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
2371 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
2373 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
2374 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
2375 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
2376 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
2378 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
2380 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
2381 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
2383 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
2384 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
2386 return pu8CurrByte - pu8Buffer;
2389 static void Handle_AddStation(struct host_if_drv *hif_drv,
2390 struct add_sta_param *pstrStationParam)
2396 PRINT_D(HOSTINF_DBG, "Handling add station\n");
2397 strWID.id = (u16)WID_ADD_STA;
2398 strWID.type = WID_BIN;
2399 strWID.size = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
2401 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2402 if (strWID.val == NULL)
2405 pu8CurrByte = strWID.val;
2406 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2408 result = send_config_pkt(SET_CFG, &strWID, 1,
2409 get_id_from_handler(hif_drv));
2411 PRINT_ER("Failed to send add station config packet\n");
2414 kfree(pstrStationParam->pu8Rates);
2418 static void Handle_DelAllSta(struct host_if_drv *hif_drv,
2419 struct del_all_sta *pstrDelAllStaParam)
2426 u8 au8Zero_Buff[6] = {0};
2428 strWID.id = (u16)WID_DEL_ALL_STA;
2429 strWID.type = WID_STR;
2430 strWID.size = (pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1;
2432 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
2434 strWID.val = kmalloc((pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1, GFP_KERNEL);
2435 if (strWID.val == NULL)
2438 pu8CurrByte = strWID.val;
2440 *(pu8CurrByte++) = pstrDelAllStaParam->assoc_sta;
2442 for (i = 0; i < MAX_NUM_STA; i++) {
2443 if (memcmp(pstrDelAllStaParam->del_all_sta[i], au8Zero_Buff, ETH_ALEN))
2444 memcpy(pu8CurrByte, pstrDelAllStaParam->del_all_sta[i], ETH_ALEN);
2448 pu8CurrByte += ETH_ALEN;
2451 result = send_config_pkt(SET_CFG, &strWID, 1,
2452 get_id_from_handler(hif_drv));
2454 PRINT_ER("Failed to send add station config packet\n");
2459 up(&hif_sema_wait_response);
2462 static void Handle_DelStation(struct host_if_drv *hif_drv,
2463 struct del_sta *pstrDelStaParam)
2469 strWID.id = (u16)WID_REMOVE_STA;
2470 strWID.type = WID_BIN;
2471 strWID.size = ETH_ALEN;
2473 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
2475 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2476 if (strWID.val == NULL)
2479 pu8CurrByte = strWID.val;
2481 memcpy(pu8CurrByte, pstrDelStaParam->mac_addr, ETH_ALEN);
2483 result = send_config_pkt(SET_CFG, &strWID, 1,
2484 get_id_from_handler(hif_drv));
2486 PRINT_ER("Failed to send add station config packet\n");
2492 static void Handle_EditStation(struct host_if_drv *hif_drv,
2493 struct add_sta_param *pstrStationParam)
2499 strWID.id = (u16)WID_EDIT_STA;
2500 strWID.type = WID_BIN;
2501 strWID.size = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
2503 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
2504 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2505 if (strWID.val == NULL)
2508 pu8CurrByte = strWID.val;
2509 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2511 result = send_config_pkt(SET_CFG, &strWID, 1,
2512 get_id_from_handler(hif_drv));
2514 PRINT_ER("Failed to send edit station config packet\n");
2517 kfree(pstrStationParam->pu8Rates);
2521 static int Handle_RemainOnChan(struct host_if_drv *hif_drv,
2522 struct remain_ch *pstrHostIfRemainOnChan)
2525 u8 u8remain_on_chan_flag;
2528 if (!hif_drv->u8RemainOnChan_pendingreq) {
2529 hif_drv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
2530 hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
2531 hif_drv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
2532 hif_drv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
2533 hif_drv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
2535 pstrHostIfRemainOnChan->u16Channel = hif_drv->strHostIfRemainOnChan.u16Channel;
2538 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
2539 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
2540 hif_drv->u8RemainOnChan_pendingreq = 1;
2544 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2545 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
2550 if (g_obtainingIP || connecting) {
2551 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
2556 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
2558 u8remain_on_chan_flag = true;
2559 strWID.id = (u16)WID_REMAIN_ON_CHAN;
2560 strWID.type = WID_STR;
2562 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2564 if (strWID.val == NULL) {
2569 strWID.val[0] = u8remain_on_chan_flag;
2570 strWID.val[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
2572 result = send_config_pkt(SET_CFG, &strWID, 1,
2573 get_id_from_handler(hif_drv));
2575 PRINT_ER("Failed to set remain on channel\n");
2579 P2P_LISTEN_STATE = 1;
2580 hif_drv->hRemainOnChannel.data = (unsigned long)hif_drv;
2581 mod_timer(&hif_drv->hRemainOnChannel,
2583 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
2585 if (hif_drv->strHostIfRemainOnChan.pRemainOnChanReady)
2586 hif_drv->strHostIfRemainOnChan.pRemainOnChanReady(hif_drv->strHostIfRemainOnChan.pVoid);
2588 if (hif_drv->u8RemainOnChan_pendingreq)
2589 hif_drv->u8RemainOnChan_pendingreq = 0;
2595 static int Handle_RegisterFrame(struct host_if_drv *hif_drv,
2596 struct reg_frame *pstrHostIfRegisterFrame)
2602 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
2604 strWID.id = (u16)WID_REGISTER_FRAME;
2605 strWID.type = WID_STR;
2606 strWID.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
2607 if (strWID.val == NULL)
2610 pu8CurrByte = strWID.val;
2612 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
2613 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
2614 memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
2617 strWID.size = sizeof(u16) + 2;
2619 result = send_config_pkt(SET_CFG, &strWID, 1,
2620 get_id_from_handler(hif_drv));
2622 PRINT_ER("Failed to frame register config packet\n");
2629 static u32 Handle_ListenStateExpired(struct host_if_drv *hif_drv,
2630 struct remain_ch *pstrHostIfRemainOnChan)
2632 u8 u8remain_on_chan_flag;
2636 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
2638 if (P2P_LISTEN_STATE) {
2639 u8remain_on_chan_flag = false;
2640 strWID.id = (u16)WID_REMAIN_ON_CHAN;
2641 strWID.type = WID_STR;
2643 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2645 if (strWID.val == NULL)
2646 PRINT_ER("Failed to allocate memory\n");
2648 strWID.val[0] = u8remain_on_chan_flag;
2649 strWID.val[1] = FALSE_FRMWR_CHANNEL;
2651 result = send_config_pkt(SET_CFG, &strWID, 1,
2652 get_id_from_handler(hif_drv));
2654 PRINT_ER("Failed to set remain on channel\n");
2658 if (hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired) {
2659 hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired(hif_drv->strHostIfRemainOnChan.pVoid
2660 , pstrHostIfRemainOnChan->u32ListenSessionID);
2662 P2P_LISTEN_STATE = 0;
2664 PRINT_D(GENERIC_DBG, "Not in listen state\n");
2672 static void ListenTimerCB(unsigned long arg)
2675 struct host_if_msg msg;
2676 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
2678 del_timer(&hif_drv->hRemainOnChannel);
2680 memset(&msg, 0, sizeof(struct host_if_msg));
2681 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
2683 msg.body.remain_on_ch.u32ListenSessionID = hif_drv->strHostIfRemainOnChan.u32ListenSessionID;
2685 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2687 PRINT_ER("wilc_mq_send fail\n");
2690 static void Handle_PowerManagement(struct host_if_drv *hif_drv,
2691 struct power_mgmt_param *strPowerMgmtParam)
2697 strWID.id = (u16)WID_POWER_MANAGEMENT;
2699 if (strPowerMgmtParam->enabled == true)
2700 s8PowerMode = MIN_FAST_PS;
2702 s8PowerMode = NO_POWERSAVE;
2703 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
2704 strWID.val = &s8PowerMode;
2705 strWID.size = sizeof(char);
2707 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
2709 result = send_config_pkt(SET_CFG, &strWID, 1,
2710 get_id_from_handler(hif_drv));
2712 PRINT_ER("Failed to send power management config packet\n");
2715 static void Handle_SetMulticastFilter(struct host_if_drv *hif_drv,
2716 struct set_multicast *strHostIfSetMulti)
2722 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
2724 strWID.id = (u16)WID_SETUP_MULTICAST_FILTER;
2725 strWID.type = WID_BIN;
2726 strWID.size = sizeof(struct set_multicast) + ((strHostIfSetMulti->cnt) * ETH_ALEN);
2727 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2728 if (strWID.val == NULL)
2731 pu8CurrByte = strWID.val;
2732 *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF);
2733 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 8) & 0xFF);
2734 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 16) & 0xFF);
2735 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 24) & 0xFF);
2737 *pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF);
2738 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF);
2739 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 16) & 0xFF);
2740 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 24) & 0xFF);
2742 if ((strHostIfSetMulti->cnt) > 0)
2743 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->cnt) * ETH_ALEN));
2745 result = send_config_pkt(SET_CFG, &strWID, 1,
2746 get_id_from_handler(hif_drv));
2748 PRINT_ER("Failed to send setup multicast config packet\n");
2755 static s32 Handle_AddBASession(struct host_if_drv *hif_drv,
2756 struct ba_session_info *strHostIfBASessionInfo)
2760 int AddbaTimeout = 100;
2763 PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\nBufferSize == %d\nSessionTimeOut = %d\n",
2764 strHostIfBASessionInfo->au8Bssid[0],
2765 strHostIfBASessionInfo->au8Bssid[1],
2766 strHostIfBASessionInfo->au8Bssid[2],
2767 strHostIfBASessionInfo->u16BufferSize,
2768 strHostIfBASessionInfo->u16SessionTimeout,
2769 strHostIfBASessionInfo->u8Ted);
2771 strWID.id = (u16)WID_11E_P_ACTION_REQ;
2772 strWID.type = WID_STR;
2773 strWID.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2774 strWID.size = BLOCK_ACK_REQ_SIZE;
2779 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2781 *ptr++ = strHostIfBASessionInfo->u8Ted;
2783 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
2784 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
2785 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
2786 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
2787 *ptr++ = (AddbaTimeout & 0xFF);
2788 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
2792 result = send_config_pkt(SET_CFG, &strWID, 1,
2793 get_id_from_handler(hif_drv));
2795 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
2798 strWID.id = (u16)WID_11E_P_ACTION_REQ;
2799 strWID.type = WID_STR;
2805 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2807 *ptr++ = strHostIfBASessionInfo->u8Ted;
2809 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
2810 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
2812 result = send_config_pkt(SET_CFG, &strWID, 1,
2813 get_id_from_handler(hif_drv));
2821 static s32 Handle_DelAllRxBASessions(struct host_if_drv *hif_drv,
2822 struct ba_session_info *strHostIfBASessionInfo)
2828 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
2829 strHostIfBASessionInfo->au8Bssid[0],
2830 strHostIfBASessionInfo->au8Bssid[1],
2831 strHostIfBASessionInfo->au8Bssid[2],
2832 strHostIfBASessionInfo->u8Ted);
2834 strWID.id = (u16)WID_DEL_ALL_RX_BA;
2835 strWID.type = WID_STR;
2836 strWID.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2837 strWID.size = BLOCK_ACK_REQ_SIZE;
2842 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
2844 *ptr++ = strHostIfBASessionInfo->u8Ted;
2848 result = send_config_pkt(SET_CFG, &strWID, 1,
2849 get_id_from_handler(hif_drv));
2851 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
2856 up(&hif_sema_wait_response);
2861 static int hostIFthread(void *pvArg)
2864 struct host_if_msg msg;
2865 struct host_if_drv *hif_drv;
2867 memset(&msg, 0, sizeof(struct host_if_msg));
2870 wilc_mq_recv(&hif_msg_q, &msg, sizeof(struct host_if_msg), &u32Ret);
2871 hif_drv = (struct host_if_drv *)msg.drv;
2872 if (msg.id == HOST_IF_MSG_EXIT) {
2873 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
2877 if ((!g_wilc_initialized)) {
2878 PRINT_D(GENERIC_DBG, "--WAIT--");
2879 usleep_range(200 * 1000, 200 * 1000);
2880 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2884 if (msg.id == HOST_IF_MSG_CONNECT && hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
2885 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
2886 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2887 usleep_range(2 * 1000, 2 * 1000);
2892 case HOST_IF_MSG_Q_IDLE:
2893 Handle_wait_msg_q_empty();
2896 case HOST_IF_MSG_SCAN:
2897 Handle_Scan(msg.drv, &msg.body.scan_info);
2900 case HOST_IF_MSG_CONNECT:
2901 Handle_Connect(msg.drv, &msg.body.con_info);
2904 case HOST_IF_MSG_FLUSH_CONNECT:
2905 Handle_FlushConnect(msg.drv);
2908 case HOST_IF_MSG_RCVD_NTWRK_INFO:
2909 Handle_RcvdNtwrkInfo(msg.drv, &msg.body.net_info);
2912 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
2913 Handle_RcvdGnrlAsyncInfo(msg.drv, &msg.body.async_info);
2916 case HOST_IF_MSG_KEY:
2917 Handle_Key(msg.drv, &msg.body.key_info);
2920 case HOST_IF_MSG_CFG_PARAMS:
2922 Handle_CfgParam(msg.drv, &msg.body.cfg_info);
2925 case HOST_IF_MSG_SET_CHANNEL:
2926 Handle_SetChannel(msg.drv, &msg.body.channel_info);
2929 case HOST_IF_MSG_DISCONNECT:
2930 Handle_Disconnect(msg.drv);
2933 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
2934 del_timer(&hif_drv->hScanTimer);
2935 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
2937 if (!linux_wlan_get_num_conn_ifcs())
2938 chip_sleep_manually(INFINITE_SLEEP_TIME);
2940 Handle_ScanDone(msg.drv, SCAN_EVENT_DONE);
2942 if (hif_drv->u8RemainOnChan_pendingreq)
2943 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
2947 case HOST_IF_MSG_GET_RSSI:
2948 Handle_GetRssi(msg.drv);
2951 case HOST_IF_MSG_GET_LINKSPEED:
2952 Handle_GetLinkspeed(msg.drv);
2955 case HOST_IF_MSG_GET_STATISTICS:
2956 Handle_GetStatistics(msg.drv, (struct rf_info *)msg.body.data);
2959 case HOST_IF_MSG_GET_CHNL:
2960 Handle_GetChnl(msg.drv);
2963 case HOST_IF_MSG_ADD_BEACON:
2964 Handle_AddBeacon(msg.drv, &msg.body.beacon_info);
2967 case HOST_IF_MSG_DEL_BEACON:
2968 Handle_DelBeacon(msg.drv);
2971 case HOST_IF_MSG_ADD_STATION:
2972 Handle_AddStation(msg.drv, &msg.body.add_sta_info);
2975 case HOST_IF_MSG_DEL_STATION:
2976 Handle_DelStation(msg.drv, &msg.body.del_sta_info);
2979 case HOST_IF_MSG_EDIT_STATION:
2980 Handle_EditStation(msg.drv, &msg.body.edit_sta_info);
2983 case HOST_IF_MSG_GET_INACTIVETIME:
2984 Handle_Get_InActiveTime(msg.drv, &msg.body.mac_info);
2987 case HOST_IF_MSG_SCAN_TIMER_FIRED:
2988 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
2990 Handle_ScanDone(msg.drv, SCAN_EVENT_ABORTED);
2993 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
2994 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
2995 Handle_ConnectTimeout(msg.drv);
2998 case HOST_IF_MSG_POWER_MGMT:
2999 Handle_PowerManagement(msg.drv, &msg.body.pwr_mgmt_info);
3002 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
3003 Handle_SetWfiDrvHandler(msg.drv,
3007 case HOST_IF_MSG_SET_OPERATION_MODE:
3008 Handle_SetOperationMode(msg.drv, &msg.body.mode);
3011 case HOST_IF_MSG_SET_IPADDRESS:
3012 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
3013 Handle_set_IPAddress(msg.drv, msg.body.ip_info.ip_addr, msg.body.ip_info.idx);
3016 case HOST_IF_MSG_GET_IPADDRESS:
3017 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
3018 Handle_get_IPAddress(msg.drv, msg.body.ip_info.ip_addr, msg.body.ip_info.idx);
3021 case HOST_IF_MSG_SET_MAC_ADDRESS:
3022 Handle_SetMacAddress(msg.drv, &msg.body.set_mac_info);
3025 case HOST_IF_MSG_GET_MAC_ADDRESS:
3026 Handle_GetMacAddress(msg.drv, &msg.body.get_mac_info);
3029 case HOST_IF_MSG_REMAIN_ON_CHAN:
3030 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
3031 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
3034 case HOST_IF_MSG_REGISTER_FRAME:
3035 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
3036 Handle_RegisterFrame(msg.drv, &msg.body.reg_frame);
3039 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
3040 Handle_ListenStateExpired(msg.drv, &msg.body.remain_on_ch);
3043 case HOST_IF_MSG_SET_MULTICAST_FILTER:
3044 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
3045 Handle_SetMulticastFilter(msg.drv, &msg.body.multicast_info);
3048 case HOST_IF_MSG_ADD_BA_SESSION:
3049 Handle_AddBASession(msg.drv, &msg.body.session_info);
3052 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
3053 Handle_DelAllRxBASessions(msg.drv, &msg.body.session_info);
3056 case HOST_IF_MSG_DEL_ALL_STA:
3057 Handle_DelAllSta(msg.drv, &msg.body.del_all_sta_info);
3061 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
3066 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
3067 up(&hif_sema_thread);
3071 static void TimerCB_Scan(unsigned long arg)
3073 void *pvArg = (void *)arg;
3074 struct host_if_msg msg;
3076 memset(&msg, 0, sizeof(struct host_if_msg));
3078 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
3080 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3083 static void TimerCB_Connect(unsigned long arg)
3085 void *pvArg = (void *)arg;
3086 struct host_if_msg msg;
3088 memset(&msg, 0, sizeof(struct host_if_msg));
3090 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
3092 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3095 s32 host_int_remove_key(struct host_if_drv *hif_drv, const u8 *pu8StaAddress)
3099 strWID.id = (u16)WID_REMOVE_KEY;
3100 strWID.type = WID_STR;
3101 strWID.val = (s8 *)pu8StaAddress;
3107 int host_int_remove_wep_key(struct host_if_drv *hif_drv, u8 index)
3110 struct host_if_msg msg;
3114 PRINT_ER("Failed to send setup multicast config packet\n");
3118 memset(&msg, 0, sizeof(struct host_if_msg));
3120 msg.id = HOST_IF_MSG_KEY;
3121 msg.body.key_info.type = WEP;
3122 msg.body.key_info.action = REMOVEKEY;
3124 msg.body.key_info.attr.wep.index = index;
3126 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3128 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
3129 down(&hif_drv->hSemTestKeyBlock);
3134 s32 host_int_set_WEPDefaultKeyID(struct host_if_drv *hif_drv, u8 u8Index)
3137 struct host_if_msg msg;
3142 PRINT_ER("driver is null\n");
3146 memset(&msg, 0, sizeof(struct host_if_msg));
3149 msg.id = HOST_IF_MSG_KEY;
3150 msg.body.key_info.type = WEP;
3151 msg.body.key_info.action = DEFAULTKEY;
3153 msg.body.key_info.attr.wep.index = u8Index;
3155 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3157 PRINT_ER("Error in sending message queue : Default key index\n");
3158 down(&hif_drv->hSemTestKeyBlock);
3163 s32 host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv,
3164 const u8 *pu8WepKey,
3169 struct host_if_msg msg;
3172 PRINT_ER("driver is null\n");
3176 memset(&msg, 0, sizeof(struct host_if_msg));
3179 msg.id = HOST_IF_MSG_KEY;
3180 msg.body.key_info.type = WEP;
3181 msg.body.key_info.action = ADDKEY;
3183 msg.body.key_info.attr.wep.key = kmalloc(u8WepKeylen, GFP_KERNEL);
3184 memcpy(msg.body.key_info.attr.wep.key, pu8WepKey, u8WepKeylen);
3185 msg.body.key_info.attr.wep.key_len = (u8WepKeylen);
3186 msg.body.key_info.attr.wep.index = u8Keyidx;
3188 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3190 PRINT_ER("Error in sending message queue :WEP Key\n");
3191 down(&hif_drv->hSemTestKeyBlock);
3196 s32 host_int_add_wep_key_bss_ap(struct host_if_drv *hif_drv,
3197 const u8 *pu8WepKey,
3201 enum AUTHTYPE tenuAuth_type)
3204 struct host_if_msg msg;
3208 PRINT_ER("driver is null\n");
3212 memset(&msg, 0, sizeof(struct host_if_msg));
3215 for (i = 0; i < u8WepKeylen; i++)
3216 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
3218 msg.id = HOST_IF_MSG_KEY;
3219 msg.body.key_info.type = WEP;
3220 msg.body.key_info.action = ADDKEY_AP;
3222 msg.body.key_info.attr.wep.key = kmalloc(u8WepKeylen, GFP_KERNEL);
3223 memcpy(msg.body.key_info.attr.wep.key, pu8WepKey, (u8WepKeylen));
3224 msg.body.key_info.attr.wep.key_len = (u8WepKeylen);
3225 msg.body.key_info.attr.wep.index = u8Keyidx;
3226 msg.body.key_info.attr.wep.mode = u8mode;
3227 msg.body.key_info.attr.wep.auth_type = tenuAuth_type;
3229 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3232 PRINT_ER("Error in sending message queue :WEP Key\n");
3233 down(&hif_drv->hSemTestKeyBlock);
3238 s32 host_int_add_ptk(struct host_if_drv *hif_drv, const u8 *pu8Ptk,
3239 u8 u8PtkKeylen, const u8 *mac_addr,
3240 const u8 *pu8RxMic, const u8 *pu8TxMic,
3241 u8 mode, u8 u8Ciphermode, u8 u8Idx)
3244 struct host_if_msg msg;
3245 u8 u8KeyLen = u8PtkKeylen;
3249 PRINT_ER("driver is null\n");
3252 if (pu8RxMic != NULL)
3253 u8KeyLen += RX_MIC_KEY_LEN;
3254 if (pu8TxMic != NULL)
3255 u8KeyLen += TX_MIC_KEY_LEN;
3257 memset(&msg, 0, sizeof(struct host_if_msg));
3260 msg.id = HOST_IF_MSG_KEY;
3261 msg.body.key_info.type = WPAPtk;
3262 if (mode == AP_MODE) {
3263 msg.body.key_info.action = ADDKEY_AP;
3264 msg.body.key_info.attr.wpa.index = u8Idx;
3266 if (mode == STATION_MODE)
3267 msg.body.key_info.action = ADDKEY;
3269 msg.body.key_info.attr.wpa.key = kmalloc(u8PtkKeylen, GFP_KERNEL);
3270 memcpy(msg.body.key_info.attr.wpa.key, pu8Ptk, u8PtkKeylen);
3272 if (pu8RxMic != NULL) {
3273 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic, RX_MIC_KEY_LEN);
3275 for (i = 0; i < RX_MIC_KEY_LEN; i++)
3276 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
3279 if (pu8TxMic != NULL) {
3280 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic, TX_MIC_KEY_LEN);
3282 for (i = 0; i < TX_MIC_KEY_LEN; i++)
3283 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
3287 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
3288 msg.body.key_info.attr.wpa.mac_addr = mac_addr;
3289 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
3292 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3295 PRINT_ER("Error in sending message queue: PTK Key\n");
3297 down(&hif_drv->hSemTestKeyBlock);
3302 s32 host_int_add_rx_gtk(struct host_if_drv *hif_drv, const u8 *pu8RxGtk,
3303 u8 u8GtkKeylen, u8 u8KeyIdx,
3304 u32 u32KeyRSClen, const u8 *KeyRSC,
3305 const u8 *pu8RxMic, const u8 *pu8TxMic,
3306 u8 mode, u8 u8Ciphermode)
3309 struct host_if_msg msg;
3310 u8 u8KeyLen = u8GtkKeylen;
3313 PRINT_ER("driver is null\n");
3316 memset(&msg, 0, sizeof(struct host_if_msg));
3319 if (pu8RxMic != NULL)
3320 u8KeyLen += RX_MIC_KEY_LEN;
3321 if (pu8TxMic != NULL)
3322 u8KeyLen += TX_MIC_KEY_LEN;
3323 if (KeyRSC != NULL) {
3324 msg.body.key_info.attr.wpa.seq = kmalloc(u32KeyRSClen, GFP_KERNEL);
3325 memcpy(msg.body.key_info.attr.wpa.seq, KeyRSC, u32KeyRSClen);
3329 msg.id = HOST_IF_MSG_KEY;
3330 msg.body.key_info.type = WPARxGtk;
3333 if (mode == AP_MODE) {
3334 msg.body.key_info.action = ADDKEY_AP;
3335 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
3337 if (mode == STATION_MODE)
3338 msg.body.key_info.action = ADDKEY;
3340 msg.body.key_info.attr.wpa.key = kmalloc(u8KeyLen, GFP_KERNEL);
3341 memcpy(msg.body.key_info.attr.wpa.key, pu8RxGtk, u8GtkKeylen);
3343 if (pu8RxMic != NULL) {
3344 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic, RX_MIC_KEY_LEN);
3346 if (pu8TxMic != NULL) {
3347 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic, TX_MIC_KEY_LEN);
3350 msg.body.key_info.attr.wpa.index = u8KeyIdx;
3351 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
3352 msg.body.key_info.attr.wpa.seq_len = u32KeyRSClen;
3354 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3356 PRINT_ER("Error in sending message queue: RX GTK\n");
3358 down(&hif_drv->hSemTestKeyBlock);
3363 s32 host_int_set_pmkid_info(struct host_if_drv *hif_drv, struct host_if_pmkid_attr *pu8PmkidInfoArray)
3366 struct host_if_msg msg;
3371 PRINT_ER("driver is null\n");
3375 memset(&msg, 0, sizeof(struct host_if_msg));
3377 msg.id = HOST_IF_MSG_KEY;
3378 msg.body.key_info.type = PMKSA;
3379 msg.body.key_info.action = ADDKEY;
3382 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
3383 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].bssid,
3384 &pu8PmkidInfoArray->pmkidlist[i].bssid, ETH_ALEN);
3385 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].pmkid,
3386 &pu8PmkidInfoArray->pmkidlist[i].pmkid, PMKID_LEN);
3389 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3391 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
3396 s32 host_int_get_pmkid_info(struct host_if_drv *hif_drv,
3397 u8 *pu8PmkidInfoArray,
3398 u32 u32PmkidInfoLen)
3402 strWID.id = (u16)WID_PMKID_INFO;
3403 strWID.type = WID_STR;
3404 strWID.size = u32PmkidInfoLen;
3405 strWID.val = pu8PmkidInfoArray;
3410 s32 host_int_set_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3416 if ((u8Psklength > 7) && (u8Psklength < 65)) {
3417 strWID.id = (u16)WID_11I_PSK;
3418 strWID.type = WID_STR;
3419 strWID.val = pu8PassPhrase;
3420 strWID.size = u8Psklength;
3426 s32 host_int_get_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
3429 struct host_if_msg msg;
3431 memset(&msg, 0, sizeof(struct host_if_msg));
3433 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
3434 msg.body.get_mac_info.u8MacAddress = pu8MacAddress;
3437 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3439 PRINT_ER("Failed to send get mac address\n");
3443 down(&hif_sema_wait_response);
3447 s32 host_int_set_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
3450 struct host_if_msg msg;
3452 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
3454 memset(&msg, 0, sizeof(struct host_if_msg));
3455 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
3456 memcpy(msg.body.set_mac_info.u8MacAddress, pu8MacAddress, ETH_ALEN);
3459 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3461 PRINT_ER("Failed to send message queue: Set mac address\n");
3466 s32 host_int_get_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3467 u8 *pu8PassPhrase, u8 u8Psklength)
3471 strWID.id = (u16)WID_11I_PSK;
3472 strWID.type = WID_STR;
3473 strWID.size = u8Psklength;
3474 strWID.val = pu8PassPhrase;
3479 s32 host_int_set_start_scan_req(struct host_if_drv *hif_drv, u8 scanSource)
3483 strWID.id = (u16)WID_START_SCAN_REQ;
3484 strWID.type = WID_CHAR;
3485 strWID.val = (s8 *)&scanSource;
3486 strWID.size = sizeof(char);
3491 s32 host_int_get_start_scan_req(struct host_if_drv *hif_drv, u8 *pu8ScanSource)
3495 strWID.id = (u16)WID_START_SCAN_REQ;
3496 strWID.type = WID_CHAR;
3497 strWID.val = (s8 *)pu8ScanSource;
3498 strWID.size = sizeof(char);
3503 s32 host_int_set_join_req(struct host_if_drv *hif_drv, u8 *pu8bssid,
3504 const u8 *pu8ssid, size_t ssidLen,
3505 const u8 *pu8IEs, size_t IEsLen,
3506 wilc_connect_result pfConnectResult, void *pvUserArg,
3507 u8 u8security, enum AUTHTYPE tenuAuth_type,
3508 u8 u8channel, void *pJoinParams)
3511 struct host_if_msg msg;
3513 if (!hif_drv || pfConnectResult == NULL) {
3514 PRINT_ER("Driver is null\n");
3518 if (pJoinParams == NULL) {
3519 PRINT_ER("Unable to Join - JoinParams is NULL\n");
3523 memset(&msg, 0, sizeof(struct host_if_msg));
3525 msg.id = HOST_IF_MSG_CONNECT;
3527 msg.body.con_info.security = u8security;
3528 msg.body.con_info.auth_type = tenuAuth_type;
3529 msg.body.con_info.ch = u8channel;
3530 msg.body.con_info.result = pfConnectResult;
3531 msg.body.con_info.arg = pvUserArg;
3532 msg.body.con_info.params = pJoinParams;
3535 if (pu8bssid != NULL) {
3536 msg.body.con_info.bssid = kmalloc(6, GFP_KERNEL);
3537 memcpy(msg.body.con_info.bssid, pu8bssid, 6);
3540 if (pu8ssid != NULL) {
3541 msg.body.con_info.ssid_len = ssidLen;
3542 msg.body.con_info.ssid = kmalloc(ssidLen, GFP_KERNEL);
3543 memcpy(msg.body.con_info.ssid, pu8ssid, ssidLen);
3546 if (pu8IEs != NULL) {
3547 msg.body.con_info.ies_len = IEsLen;
3548 msg.body.con_info.ies = kmalloc(IEsLen, GFP_KERNEL);
3549 memcpy(msg.body.con_info.ies, pu8IEs, IEsLen);
3551 if (hif_drv->enuHostIFstate < HOST_IF_CONNECTING)
3552 hif_drv->enuHostIFstate = HOST_IF_CONNECTING;
3554 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", hif_drv->enuHostIFstate);
3556 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3558 PRINT_ER("Failed to send message queue: Set join request\n");
3562 hif_drv->hConnectTimer.data = (unsigned long)hif_drv;
3563 mod_timer(&hif_drv->hConnectTimer,
3564 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
3569 s32 host_int_flush_join_req(struct host_if_drv *hif_drv)
3572 struct host_if_msg msg;
3578 PRINT_ER("Driver is null\n");
3582 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
3585 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3587 PRINT_ER("Failed to send message queue: Flush join request\n");
3594 s32 host_int_disconnect(struct host_if_drv *hif_drv, u16 u16ReasonCode)
3597 struct host_if_msg msg;
3600 PRINT_ER("Driver is null\n");
3604 memset(&msg, 0, sizeof(struct host_if_msg));
3606 msg.id = HOST_IF_MSG_DISCONNECT;
3609 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3611 PRINT_ER("Failed to send message queue: disconnect\n");
3613 down(&hif_drv->hSemTestDisconnectBlock);
3618 s32 host_int_disconnect_station(struct host_if_drv *hif_drv, u8 assoc_id)
3622 strWID.id = (u16)WID_DISCONNECT;
3623 strWID.type = WID_CHAR;
3624 strWID.val = (s8 *)&assoc_id;
3625 strWID.size = sizeof(char);
3630 s32 host_int_get_assoc_req_info(struct host_if_drv *hif_drv,
3631 u8 *pu8AssocReqInfo,
3632 u32 u32AssocReqInfoLen)
3636 strWID.id = (u16)WID_ASSOC_REQ_INFO;
3637 strWID.type = WID_STR;
3638 strWID.val = pu8AssocReqInfo;
3639 strWID.size = u32AssocReqInfoLen;
3644 s32 host_int_get_assoc_res_info(struct host_if_drv *hif_drv,
3645 u8 *pu8AssocRespInfo,
3646 u32 u32MaxAssocRespInfoLen,
3647 u32 *pu32RcvdAssocRespInfoLen)
3653 PRINT_ER("Driver is null\n");
3657 strWID.id = (u16)WID_ASSOC_RES_INFO;
3658 strWID.type = WID_STR;
3659 strWID.val = pu8AssocRespInfo;
3660 strWID.size = u32MaxAssocRespInfoLen;
3662 result = send_config_pkt(GET_CFG, &strWID, 1,
3663 get_id_from_handler(hif_drv));
3665 *pu32RcvdAssocRespInfoLen = 0;
3666 PRINT_ER("Failed to send association response config packet\n");
3669 *pu32RcvdAssocRespInfoLen = strWID.size;
3675 s32 host_int_get_rx_power_level(struct host_if_drv *hif_drv,
3676 u8 *pu8RxPowerLevel,
3677 u32 u32RxPowerLevelLen)
3681 strWID.id = (u16)WID_RX_POWER_LEVEL;
3682 strWID.type = WID_STR;
3683 strWID.val = pu8RxPowerLevel;
3684 strWID.size = u32RxPowerLevelLen;
3689 int host_int_set_mac_chnl_num(struct host_if_drv *hif_drv, u8 channel)
3692 struct host_if_msg msg;
3695 PRINT_ER("driver is null\n");
3699 memset(&msg, 0, sizeof(struct host_if_msg));
3700 msg.id = HOST_IF_MSG_SET_CHANNEL;
3701 msg.body.channel_info.set_ch = channel;
3704 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3706 PRINT_ER("wilc mq send fail\n");
3713 int host_int_wait_msg_queue_idle(void)
3717 struct host_if_msg msg;
3718 memset(&msg, 0, sizeof(struct host_if_msg));
3719 msg.id = HOST_IF_MSG_Q_IDLE;
3720 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3722 PRINT_ER("wilc mq send fail\n");
3726 down(&hif_sema_wait_response);
3731 int host_int_set_wfi_drv_handler(struct host_if_drv *hif_drv)
3735 struct host_if_msg msg;
3736 memset(&msg, 0, sizeof(struct host_if_msg));
3737 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
3738 msg.body.drv.u32Address = get_id_from_handler(hif_drv);
3741 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3743 PRINT_ER("wilc mq send fail\n");
3750 int host_int_set_operation_mode(struct host_if_drv *hif_drv, u32 mode)
3754 struct host_if_msg msg;
3755 memset(&msg, 0, sizeof(struct host_if_msg));
3756 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
3757 msg.body.mode.u32Mode = mode;
3760 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3762 PRINT_ER("wilc mq send fail\n");
3769 s32 host_int_get_host_chnl_num(struct host_if_drv *hif_drv, u8 *pu8ChNo)
3772 struct host_if_msg msg;
3775 PRINT_ER("driver is null\n");
3779 memset(&msg, 0, sizeof(struct host_if_msg));
3781 msg.id = HOST_IF_MSG_GET_CHNL;
3784 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3786 PRINT_ER("wilc mq send fail\n");
3787 down(&hif_drv->hSemGetCHNL);
3794 s32 host_int_get_inactive_time(struct host_if_drv *hif_drv,
3795 const u8 *mac, u32 *pu32InactiveTime)
3798 struct host_if_msg msg;
3801 PRINT_ER("driver is null\n");
3805 memset(&msg, 0, sizeof(struct host_if_msg));
3806 memcpy(msg.body.mac_info.mac, mac, ETH_ALEN);
3808 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
3811 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3813 PRINT_ER("Failed to send get host channel param's message queue ");
3815 down(&hif_drv->hSemInactiveTime);
3817 *pu32InactiveTime = inactive_time;
3822 s32 host_int_test_get_int_wid(struct host_if_drv *hif_drv, u32 *pu32TestMemAddr)
3828 PRINT_ER("driver is null\n");
3832 strWID.id = (u16)WID_MEMORY_ADDRESS;
3833 strWID.type = WID_INT;
3834 strWID.val = (s8 *)pu32TestMemAddr;
3835 strWID.size = sizeof(u32);
3837 result = send_config_pkt(GET_CFG, &strWID, 1,
3838 get_id_from_handler(hif_drv));
3841 PRINT_ER("Failed to get wid value\n");
3844 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
3851 s32 host_int_get_rssi(struct host_if_drv *hif_drv, s8 *ps8Rssi)
3854 struct host_if_msg msg;
3855 memset(&msg, 0, sizeof(struct host_if_msg));
3857 msg.id = HOST_IF_MSG_GET_RSSI;
3860 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3862 PRINT_ER("Failed to send get host channel param's message queue ");
3866 down(&hif_drv->hSemGetRSSI);
3869 if (ps8Rssi == NULL) {
3870 PRINT_ER("RSS pointer value is null");
3879 s32 host_int_get_link_speed(struct host_if_drv *hif_drv, s8 *ps8lnkspd)
3881 struct host_if_msg msg;
3883 memset(&msg, 0, sizeof(struct host_if_msg));
3885 msg.id = HOST_IF_MSG_GET_LINKSPEED;
3888 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3890 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
3894 down(&hif_drv->hSemGetLINKSPEED);
3897 if (ps8lnkspd == NULL) {
3898 PRINT_ER("LINKSPEED pointer value is null");
3902 *ps8lnkspd = link_speed;
3907 s32 host_int_get_statistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
3910 struct host_if_msg msg;
3911 memset(&msg, 0, sizeof(struct host_if_msg));
3913 msg.id = HOST_IF_MSG_GET_STATISTICS;
3914 msg.body.data = (char *)pstrStatistics;
3917 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3919 PRINT_ER("Failed to send get host channel param's message queue ");
3923 down(&hif_sema_wait_response);
3927 s32 host_int_scan(struct host_if_drv *hif_drv, u8 u8ScanSource,
3928 u8 u8ScanType, u8 *pu8ChnlFreqList,
3929 u8 u8ChnlListLen, const u8 *pu8IEs,
3930 size_t IEsLen, wilc_scan_result ScanResult,
3931 void *pvUserArg, struct hidden_network *pstrHiddenNetwork)
3934 struct host_if_msg msg;
3936 if (!hif_drv || ScanResult == NULL) {
3937 PRINT_ER("hif_drv or ScanResult = NULL\n");
3941 memset(&msg, 0, sizeof(struct host_if_msg));
3943 msg.id = HOST_IF_MSG_SCAN;
3945 if (pstrHiddenNetwork != NULL) {
3946 msg.body.scan_info.hidden_network.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
3947 msg.body.scan_info.hidden_network.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
3950 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
3953 msg.body.scan_info.src = u8ScanSource;
3954 msg.body.scan_info.type = u8ScanType;
3955 msg.body.scan_info.result = ScanResult;
3956 msg.body.scan_info.arg = pvUserArg;
3958 msg.body.scan_info.ch_list_len = u8ChnlListLen;
3959 msg.body.scan_info.ch_freq_list = kmalloc(u8ChnlListLen, GFP_KERNEL);
3960 memcpy(msg.body.scan_info.ch_freq_list, pu8ChnlFreqList, u8ChnlListLen);
3962 msg.body.scan_info.ies_len = IEsLen;
3963 msg.body.scan_info.ies = kmalloc(IEsLen, GFP_KERNEL);
3964 memcpy(msg.body.scan_info.ies, pu8IEs, IEsLen);
3966 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3968 PRINT_ER("Error in sending message queue\n");
3972 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
3973 hif_drv->hScanTimer.data = (unsigned long)hif_drv;
3974 mod_timer(&hif_drv->hScanTimer,
3975 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
3980 s32 hif_set_cfg(struct host_if_drv *hif_drv,
3981 struct cfg_param_val *pstrCfgParamVal)
3984 struct host_if_msg msg;
3988 PRINT_ER("hif_drv NULL\n");
3992 memset(&msg, 0, sizeof(struct host_if_msg));
3993 msg.id = HOST_IF_MSG_CFG_PARAMS;
3994 msg.body.cfg_info.cfg_attr_info = *pstrCfgParamVal;
3997 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4002 s32 hif_get_cfg(struct host_if_drv *hif_drv, u16 u16WID, u16 *pu16WID_Value)
4006 down(&hif_drv->gtOsCfgValuesSem);
4009 PRINT_ER("hif_drv NULL\n");
4012 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
4016 *pu16WID_Value = (u16)hif_drv->strCfgValues.bss_type;
4020 *pu16WID_Value = (u16)hif_drv->strCfgValues.auth_type;
4023 case WID_AUTH_TIMEOUT:
4024 *pu16WID_Value = hif_drv->strCfgValues.auth_timeout;
4027 case WID_POWER_MANAGEMENT:
4028 *pu16WID_Value = (u16)hif_drv->strCfgValues.power_mgmt_mode;
4031 case WID_SHORT_RETRY_LIMIT:
4032 *pu16WID_Value = hif_drv->strCfgValues.short_retry_limit;
4035 case WID_LONG_RETRY_LIMIT:
4036 *pu16WID_Value = hif_drv->strCfgValues.long_retry_limit;
4039 case WID_FRAG_THRESHOLD:
4040 *pu16WID_Value = hif_drv->strCfgValues.frag_threshold;
4043 case WID_RTS_THRESHOLD:
4044 *pu16WID_Value = hif_drv->strCfgValues.rts_threshold;
4048 *pu16WID_Value = (u16)hif_drv->strCfgValues.preamble_type;
4051 case WID_SHORT_SLOT_ALLOWED:
4052 *pu16WID_Value = (u16) hif_drv->strCfgValues.short_slot_allowed;
4055 case WID_11N_TXOP_PROT_DISABLE:
4056 *pu16WID_Value = (u16)hif_drv->strCfgValues.txop_prot_disabled;
4059 case WID_BEACON_INTERVAL:
4060 *pu16WID_Value = hif_drv->strCfgValues.beacon_interval;
4063 case WID_DTIM_PERIOD:
4064 *pu16WID_Value = (u16)hif_drv->strCfgValues.dtim_period;
4067 case WID_SITE_SURVEY:
4068 *pu16WID_Value = (u16)hif_drv->strCfgValues.site_survey_enabled;
4071 case WID_SITE_SURVEY_SCAN_TIME:
4072 *pu16WID_Value = hif_drv->strCfgValues.site_survey_scan_time;
4075 case WID_ACTIVE_SCAN_TIME:
4076 *pu16WID_Value = hif_drv->strCfgValues.active_scan_time;
4079 case WID_PASSIVE_SCAN_TIME:
4080 *pu16WID_Value = hif_drv->strCfgValues.passive_scan_time;
4083 case WID_CURRENT_TX_RATE:
4084 *pu16WID_Value = hif_drv->strCfgValues.curr_tx_rate;
4091 up(&hif_drv->gtOsCfgValuesSem);
4096 void host_int_send_join_leave_info_to_host
4097 (u16 assocId, u8 *stationAddr, bool joining)
4101 static void GetPeriodicRSSI(unsigned long arg)
4103 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
4106 PRINT_ER("Driver handler is NULL\n");
4110 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED) {
4112 struct host_if_msg msg;
4114 memset(&msg, 0, sizeof(struct host_if_msg));
4116 msg.id = HOST_IF_MSG_GET_RSSI;
4119 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4121 PRINT_ER("Failed to send get host channel param's message queue ");
4125 periodic_rssi.data = (unsigned long)hif_drv;
4126 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
4130 void host_int_send_network_info_to_host
4131 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
4135 s32 host_int_init(struct host_if_drv **hif_drv_handler)
4138 struct host_if_drv *hif_drv;
4141 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
4143 scan_while_connected = false;
4145 sema_init(&hif_sema_wait_response, 0);
4147 hif_drv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
4152 *hif_drv_handler = hif_drv;
4153 err = add_handler_in_list(hif_drv);
4159 g_obtainingIP = false;
4161 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", hif_drv);
4162 if (clients_count == 0) {
4163 sema_init(&hif_sema_thread, 0);
4164 sema_init(&hif_sema_driver, 0);
4165 sema_init(&hif_sema_deinit, 1);
4168 sema_init(&hif_drv->hSemTestKeyBlock, 0);
4169 sema_init(&hif_drv->hSemTestDisconnectBlock, 0);
4170 sema_init(&hif_drv->hSemGetRSSI, 0);
4171 sema_init(&hif_drv->hSemGetLINKSPEED, 0);
4172 sema_init(&hif_drv->hSemGetCHNL, 0);
4173 sema_init(&hif_drv->hSemInactiveTime, 0);
4175 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
4177 if (clients_count == 0) {
4178 result = wilc_mq_create(&hif_msg_q);
4181 PRINT_ER("Failed to creat MQ\n");
4185 hif_thread_handler = kthread_run(hostIFthread, NULL, "WILC_kthread");
4187 if (IS_ERR(hif_thread_handler)) {
4188 PRINT_ER("Failed to creat Thread\n");
4192 setup_timer(&periodic_rssi, GetPeriodicRSSI,
4193 (unsigned long)hif_drv);
4194 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
4197 setup_timer(&hif_drv->hScanTimer, TimerCB_Scan, 0);
4199 setup_timer(&hif_drv->hConnectTimer, TimerCB_Connect, 0);
4201 setup_timer(&hif_drv->hRemainOnChannel, ListenTimerCB, 0);
4203 sema_init(&(hif_drv->gtOsCfgValuesSem), 1);
4204 down(&hif_drv->gtOsCfgValuesSem);
4206 hif_drv->enuHostIFstate = HOST_IF_IDLE;
4207 hif_drv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
4208 hif_drv->strCfgValues.scan_source = DEFAULT_SCAN;
4209 hif_drv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
4210 hif_drv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
4211 hif_drv->strCfgValues.curr_tx_rate = AUTORATE;
4213 hif_drv->u64P2p_MgmtTimeout = 0;
4215 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",
4217 hif_drv->strCfgValues.site_survey_enabled, hif_drv->strCfgValues.scan_source,
4218 hif_drv->strCfgValues.active_scan_time, hif_drv->strCfgValues.passive_scan_time,
4219 hif_drv->strCfgValues.curr_tx_rate);
4221 up(&hif_drv->gtOsCfgValuesSem);
4228 up(&hif_drv->gtOsCfgValuesSem);
4229 del_timer_sync(&hif_drv->hConnectTimer);
4230 del_timer_sync(&hif_drv->hScanTimer);
4231 kthread_stop(hif_thread_handler);
4233 wilc_mq_destroy(&hif_msg_q);
4238 s32 host_int_deinit(struct host_if_drv *hif_drv)
4241 struct host_if_msg msg;
4245 PRINT_ER("hif_drv = NULL\n");
4249 down(&hif_sema_deinit);
4251 terminated_handle = hif_drv;
4252 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
4254 if (del_timer_sync(&hif_drv->hScanTimer)) {
4255 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
4258 if (del_timer_sync(&hif_drv->hConnectTimer)) {
4259 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4262 if (del_timer_sync(&periodic_rssi))
4263 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4265 del_timer_sync(&hif_drv->hRemainOnChannel);
4267 host_int_set_wfi_drv_handler(NULL);
4268 down(&hif_sema_driver);
4270 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
4271 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
4272 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
4274 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
4277 hif_drv->enuHostIFstate = HOST_IF_IDLE;
4279 scan_while_connected = false;
4281 memset(&msg, 0, sizeof(struct host_if_msg));
4283 if (clients_count == 1) {
4284 if (del_timer_sync(&periodic_rssi))
4285 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
4287 msg.id = HOST_IF_MSG_EXIT;
4290 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4292 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", result);
4294 down(&hif_sema_thread);
4296 wilc_mq_destroy(&hif_msg_q);
4299 down(&(hif_drv->gtOsCfgValuesSem));
4301 ret = remove_handler_in_list(hif_drv);
4308 terminated_handle = NULL;
4309 up(&hif_sema_deinit);
4313 void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
4316 struct host_if_msg msg;
4318 struct host_if_drv *hif_drv = NULL;
4320 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4321 hif_drv = get_handler_from_id(id);
4326 if (!hif_drv || hif_drv == terminated_handle) {
4327 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv);
4331 memset(&msg, 0, sizeof(struct host_if_msg));
4333 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
4336 msg.body.net_info.len = u32Length;
4337 msg.body.net_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4338 memcpy(msg.body.net_info.buffer, pu8Buffer, u32Length);
4340 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4342 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", result);
4345 void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
4348 struct host_if_msg msg;
4350 struct host_if_drv *hif_drv = NULL;
4352 down(&hif_sema_deinit);
4354 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4355 hif_drv = get_handler_from_id(id);
4356 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
4359 if (!hif_drv || hif_drv == terminated_handle) {
4360 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
4361 up(&hif_sema_deinit);
4365 if (!hif_drv->strWILC_UsrConnReq.pfUserConnectResult) {
4366 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
4367 up(&hif_sema_deinit);
4371 memset(&msg, 0, sizeof(struct host_if_msg));
4374 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
4377 msg.body.async_info.len = u32Length;
4378 msg.body.async_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4379 memcpy(msg.body.async_info.buffer, pu8Buffer, u32Length);
4381 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4383 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", result);
4385 up(&hif_sema_deinit);
4388 void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
4391 struct host_if_msg msg;
4393 struct host_if_drv *hif_drv = NULL;
4395 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
4396 hif_drv = get_handler_from_id(id);
4399 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", hif_drv);
4401 if (!hif_drv || hif_drv == terminated_handle)
4404 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
4405 memset(&msg, 0, sizeof(struct host_if_msg));
4407 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
4410 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4412 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", result);
4420 s32 host_int_remain_on_channel(struct host_if_drv *hif_drv, u32 u32SessionID,
4421 u32 u32duration, u16 chan,
4422 wilc_remain_on_chan_expired RemainOnChanExpired,
4423 wilc_remain_on_chan_ready RemainOnChanReady,
4427 struct host_if_msg msg;
4430 PRINT_ER("driver is null\n");
4434 memset(&msg, 0, sizeof(struct host_if_msg));
4436 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
4437 msg.body.remain_on_ch.u16Channel = chan;
4438 msg.body.remain_on_ch.pRemainOnChanExpired = RemainOnChanExpired;
4439 msg.body.remain_on_ch.pRemainOnChanReady = RemainOnChanReady;
4440 msg.body.remain_on_ch.pVoid = pvUserArg;
4441 msg.body.remain_on_ch.u32duration = u32duration;
4442 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
4445 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4447 PRINT_ER("wilc mq send fail\n");
4452 s32 host_int_ListenStateExpired(struct host_if_drv *hif_drv, u32 u32SessionID)
4455 struct host_if_msg msg;
4458 PRINT_ER("driver is null\n");
4462 del_timer(&hif_drv->hRemainOnChannel);
4464 memset(&msg, 0, sizeof(struct host_if_msg));
4465 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
4467 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
4469 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4471 PRINT_ER("wilc mq send fail\n");
4476 s32 host_int_frame_register(struct host_if_drv *hif_drv, u16 u16FrameType, bool bReg)
4479 struct host_if_msg msg;
4482 PRINT_ER("driver is null\n");
4486 memset(&msg, 0, sizeof(struct host_if_msg));
4488 msg.id = HOST_IF_MSG_REGISTER_FRAME;
4489 switch (u16FrameType) {
4491 PRINT_D(HOSTINF_DBG, "ACTION\n");
4492 msg.body.reg_frame.u8Regid = ACTION_FRM_IDX;
4496 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
4497 msg.body.reg_frame.u8Regid = PROBE_REQ_IDX;
4501 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
4504 msg.body.reg_frame.u16FrameType = u16FrameType;
4505 msg.body.reg_frame.bReg = bReg;
4508 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4510 PRINT_ER("wilc mq send fail\n");
4515 s32 host_int_add_beacon(struct host_if_drv *hif_drv, u32 u32Interval,
4516 u32 u32DTIMPeriod, u32 u32HeadLen, u8 *pu8Head,
4517 u32 u32TailLen, u8 *pu8Tail)
4520 struct host_if_msg msg;
4521 struct beacon_attr *pstrSetBeaconParam = &msg.body.beacon_info;
4524 PRINT_ER("driver is null\n");
4528 memset(&msg, 0, sizeof(struct host_if_msg));
4530 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
4532 msg.id = HOST_IF_MSG_ADD_BEACON;
4534 pstrSetBeaconParam->interval = u32Interval;
4535 pstrSetBeaconParam->dtim_period = u32DTIMPeriod;
4536 pstrSetBeaconParam->head_len = u32HeadLen;
4537 pstrSetBeaconParam->head = kmemdup(pu8Head, u32HeadLen, GFP_KERNEL);
4538 if (pstrSetBeaconParam->head == NULL) {
4542 pstrSetBeaconParam->tail_len = u32TailLen;
4544 if (u32TailLen > 0) {
4545 pstrSetBeaconParam->tail = kmemdup(pu8Tail, u32TailLen,
4547 if (pstrSetBeaconParam->tail == NULL) {
4552 pstrSetBeaconParam->tail = NULL;
4555 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4557 PRINT_ER("wilc mq send fail\n");
4561 kfree(pstrSetBeaconParam->head);
4563 kfree(pstrSetBeaconParam->tail);
4570 s32 host_int_del_beacon(struct host_if_drv *hif_drv)
4573 struct host_if_msg msg;
4576 PRINT_ER("driver is null\n");
4580 msg.id = HOST_IF_MSG_DEL_BEACON;
4582 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
4584 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4586 PRINT_ER("wilc_mq_send fail\n");
4591 s32 host_int_add_station(struct host_if_drv *hif_drv,
4592 struct add_sta_param *pstrStaParams)
4595 struct host_if_msg msg;
4596 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
4600 PRINT_ER("driver is null\n");
4604 memset(&msg, 0, sizeof(struct host_if_msg));
4606 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
4608 msg.id = HOST_IF_MSG_ADD_STATION;
4611 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
4612 if (pstrAddStationMsg->u8NumRates > 0) {
4613 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
4618 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
4619 pstrAddStationMsg->pu8Rates = rates;
4622 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4624 PRINT_ER("wilc_mq_send fail\n");
4628 s32 host_int_del_station(struct host_if_drv *hif_drv, const u8 *pu8MacAddr)
4631 struct host_if_msg msg;
4632 struct del_sta *pstrDelStationMsg = &msg.body.del_sta_info;
4635 PRINT_ER("driver is null\n");
4639 memset(&msg, 0, sizeof(struct host_if_msg));
4641 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
4643 msg.id = HOST_IF_MSG_DEL_STATION;
4646 if (pu8MacAddr == NULL)
4647 memset(pstrDelStationMsg->mac_addr, 255, ETH_ALEN);
4649 memcpy(pstrDelStationMsg->mac_addr, pu8MacAddr, ETH_ALEN);
4651 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4653 PRINT_ER("wilc_mq_send fail\n");
4657 s32 host_int_del_allstation(struct host_if_drv *hif_drv,
4658 u8 pu8MacAddr[][ETH_ALEN])
4661 struct host_if_msg msg;
4662 struct del_all_sta *pstrDelAllStationMsg = &msg.body.del_all_sta_info;
4663 u8 au8Zero_Buff[ETH_ALEN] = {0};
4669 PRINT_ER("driver is null\n");
4673 memset(&msg, 0, sizeof(struct host_if_msg));
4675 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
4677 msg.id = HOST_IF_MSG_DEL_ALL_STA;
4680 for (i = 0; i < MAX_NUM_STA; i++) {
4681 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
4682 memcpy(pstrDelAllStationMsg->del_all_sta[i], pu8MacAddr[i], ETH_ALEN);
4683 PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n",
4684 pstrDelAllStationMsg->del_all_sta[i][0],
4685 pstrDelAllStationMsg->del_all_sta[i][1],
4686 pstrDelAllStationMsg->del_all_sta[i][2],
4687 pstrDelAllStationMsg->del_all_sta[i][3],
4688 pstrDelAllStationMsg->del_all_sta[i][4],
4689 pstrDelAllStationMsg->del_all_sta[i][5]);
4694 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
4698 pstrDelAllStationMsg->assoc_sta = u8AssocNumb;
4699 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4702 PRINT_ER("wilc_mq_send fail\n");
4704 down(&hif_sema_wait_response);
4709 s32 host_int_edit_station(struct host_if_drv *hif_drv,
4710 struct add_sta_param *pstrStaParams)
4713 struct host_if_msg msg;
4714 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
4717 PRINT_ER("driver is null\n");
4721 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
4723 memset(&msg, 0, sizeof(struct host_if_msg));
4725 msg.id = HOST_IF_MSG_EDIT_STATION;
4728 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
4729 if (pstrAddStationMsg->u8NumRates > 0) {
4730 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
4735 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
4736 pstrAddStationMsg->pu8Rates = rates;
4739 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4741 PRINT_ER("wilc_mq_send fail\n");
4746 s32 host_int_set_power_mgmt(struct host_if_drv *hif_drv,
4751 struct host_if_msg msg;
4752 struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.pwr_mgmt_info;
4754 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
4757 PRINT_ER("driver is null\n");
4761 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
4763 memset(&msg, 0, sizeof(struct host_if_msg));
4765 msg.id = HOST_IF_MSG_POWER_MGMT;
4768 pstrPowerMgmtParam->enabled = bIsEnabled;
4769 pstrPowerMgmtParam->timeout = u32Timeout;
4771 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4773 PRINT_ER("wilc_mq_send fail\n");
4777 s32 host_int_setup_multicast_filter(struct host_if_drv *hif_drv,
4782 struct host_if_msg msg;
4783 struct set_multicast *pstrMulticastFilterParam = &msg.body.multicast_info;
4787 PRINT_ER("driver is null\n");
4791 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
4793 memset(&msg, 0, sizeof(struct host_if_msg));
4795 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
4798 pstrMulticastFilterParam->enabled = bIsEnabled;
4799 pstrMulticastFilterParam->cnt = u32count;
4801 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4803 PRINT_ER("wilc_mq_send fail\n");
4807 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
4809 struct join_bss_param *pNewJoinBssParam = NULL;
4818 u8 pcipherTotalCount = 0;
4819 u8 authTotalCount = 0;
4822 pu8IEs = ptstrNetworkInfo->pu8IEs;
4823 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
4825 pNewJoinBssParam = kzalloc(sizeof(struct join_bss_param), GFP_KERNEL);
4826 if (pNewJoinBssParam != NULL) {
4827 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
4828 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
4829 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
4830 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
4831 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
4832 pNewJoinBssParam->ssid_len = ptstrNetworkInfo->u8SsidLen;
4833 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
4834 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
4836 while (index < u16IEsLen) {
4837 if (pu8IEs[index] == SUPP_RATES_IE) {
4838 suppRatesNo = pu8IEs[index + 1];
4839 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
4842 for (i = 0; i < suppRatesNo; i++) {
4843 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
4845 index += suppRatesNo;
4847 } else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
4848 extSuppRatesNo = pu8IEs[index + 1];
4849 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
4850 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
4852 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
4854 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
4855 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
4857 index += extSuppRatesNo;
4859 } else if (pu8IEs[index] == HT_CAPABILITY_IE) {
4860 pNewJoinBssParam->ht_capable = true;
4861 index += pu8IEs[index + 1] + 2;
4863 } else if ((pu8IEs[index] == WMM_IE) &&
4864 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
4865 (pu8IEs[index + 4] == 0xF2) &&
4866 (pu8IEs[index + 5] == 0x02) &&
4867 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) &&
4868 (pu8IEs[index + 7] == 0x01)) {
4869 pNewJoinBssParam->wmm_cap = true;
4871 if (pu8IEs[index + 8] & BIT(7))
4872 pNewJoinBssParam->uapsd_cap = true;
4873 index += pu8IEs[index + 1] + 2;
4875 } else if ((pu8IEs[index] == P2P_IE) &&
4876 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
4877 (pu8IEs[index + 4] == 0x9a) &&
4878 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) {
4881 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
4882 pNewJoinBssParam->noa_enabled = 1;
4883 pNewJoinBssParam->idx = pu8IEs[index + 9];
4885 if (pu8IEs[index + 10] & BIT(7)) {
4886 pNewJoinBssParam->opp_enabled = 1;
4887 pNewJoinBssParam->ct_window = pu8IEs[index + 10];
4889 pNewJoinBssParam->opp_enabled = 0;
4892 PRINT_D(GENERIC_DBG, "P2P Dump\n");
4893 for (i = 0; i < pu8IEs[index + 7]; i++)
4894 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
4896 pNewJoinBssParam->cnt = pu8IEs[index + 11];
4897 u16P2P_count = index + 12;
4899 memcpy(pNewJoinBssParam->duration, pu8IEs + u16P2P_count, 4);
4902 memcpy(pNewJoinBssParam->interval, pu8IEs + u16P2P_count, 4);
4905 memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
4907 index += pu8IEs[index + 1] + 2;
4910 } else if ((pu8IEs[index] == RSN_IE) ||
4911 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
4912 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
4913 (pu8IEs[index + 5] == 0x01))) {
4914 u16 rsnIndex = index;
4916 if (pu8IEs[rsnIndex] == RSN_IE) {
4917 pNewJoinBssParam->mode_802_11i = 2;
4919 if (pNewJoinBssParam->mode_802_11i == 0)
4920 pNewJoinBssParam->mode_802_11i = 1;
4925 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
4927 jumpOffset = pu8IEs[rsnIndex] * 4;
4928 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
4931 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
4932 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
4934 pcipherTotalCount += pcipherCount;
4935 rsnIndex += jumpOffset;
4937 jumpOffset = pu8IEs[rsnIndex] * 4;
4939 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
4942 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
4943 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
4945 authTotalCount += authCount;
4946 rsnIndex += jumpOffset;
4948 if (pu8IEs[index] == RSN_IE) {
4949 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
4950 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
4953 pNewJoinBssParam->rsn_found = true;
4954 index += pu8IEs[index + 1] + 2;
4957 index += pu8IEs[index + 1] + 2;
4964 return (void *)pNewJoinBssParam;
4968 void host_int_freeJoinParams(void *pJoinParams)
4970 if ((struct bss_param *)pJoinParams != NULL)
4971 kfree((struct bss_param *)pJoinParams);
4973 PRINT_ER("Unable to FREE null pointer\n");
4976 s32 host_int_delBASession(struct host_if_drv *hif_drv, char *pBSSID, char TID)
4979 struct host_if_msg msg;
4980 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
4983 PRINT_ER("driver is null\n");
4987 memset(&msg, 0, sizeof(struct host_if_msg));
4989 msg.id = HOST_IF_MSG_DEL_BA_SESSION;
4991 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
4992 pBASessionInfo->u8Ted = TID;
4995 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4997 PRINT_ER("wilc_mq_send fail\n");
4999 down(&hif_sema_wait_response);
5004 s32 host_int_del_All_Rx_BASession(struct host_if_drv *hif_drv,
5009 struct host_if_msg msg;
5010 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
5013 PRINT_ER("driver is null\n");
5017 memset(&msg, 0, sizeof(struct host_if_msg));
5019 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
5021 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
5022 pBASessionInfo->u8Ted = TID;
5025 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
5027 PRINT_ER("wilc_mq_send fail\n");
5029 down(&hif_sema_wait_response);
5034 s32 host_int_setup_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
5037 struct host_if_msg msg;
5042 PRINT_ER("driver is null\n");
5046 memset(&msg, 0, sizeof(struct host_if_msg));
5048 msg.id = HOST_IF_MSG_SET_IPADDRESS;
5050 msg.body.ip_info.ip_addr = u16ipadd;
5052 msg.body.ip_info.idx = idx;
5054 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
5056 PRINT_ER("wilc_mq_send fail\n");
5061 s32 host_int_get_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
5064 struct host_if_msg msg;
5067 PRINT_ER("driver is null\n");
5071 memset(&msg, 0, sizeof(struct host_if_msg));
5073 msg.id = HOST_IF_MSG_GET_IPADDRESS;
5075 msg.body.ip_info.ip_addr = u16ipadd;
5077 msg.body.ip_info.idx = idx;
5079 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
5081 PRINT_ER("wilc_mq_send fail\n");