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 /* Message types of the Host IF Message Queue*/
18 #define HOST_IF_MSG_SCAN 0
19 #define HOST_IF_MSG_CONNECT 1
20 #define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
21 #define HOST_IF_MSG_KEY 3
22 #define HOST_IF_MSG_RCVD_NTWRK_INFO 4
23 #define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
24 #define HOST_IF_MSG_CFG_PARAMS 6
25 #define HOST_IF_MSG_SET_CHANNEL 7
26 #define HOST_IF_MSG_DISCONNECT 8
27 #define HOST_IF_MSG_GET_RSSI 9
28 #define HOST_IF_MSG_GET_CHNL 10
29 #define HOST_IF_MSG_ADD_BEACON 11
30 #define HOST_IF_MSG_DEL_BEACON 12
31 #define HOST_IF_MSG_ADD_STATION 13
32 #define HOST_IF_MSG_DEL_STATION 14
33 #define HOST_IF_MSG_EDIT_STATION 15
34 #define HOST_IF_MSG_SCAN_TIMER_FIRED 16
35 #define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
36 #define HOST_IF_MSG_POWER_MGMT 18
37 #define HOST_IF_MSG_GET_INACTIVETIME 19
38 #define HOST_IF_MSG_REMAIN_ON_CHAN 20
39 #define HOST_IF_MSG_REGISTER_FRAME 21
40 #define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
41 #define HOST_IF_MSG_GET_LINKSPEED 23
42 #define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
43 #define HOST_IF_MSG_SET_MAC_ADDRESS 25
44 #define HOST_IF_MSG_GET_MAC_ADDRESS 26
45 #define HOST_IF_MSG_SET_OPERATION_MODE 27
46 #define HOST_IF_MSG_SET_IPADDRESS 28
47 #define HOST_IF_MSG_GET_IPADDRESS 29
48 #define HOST_IF_MSG_FLUSH_CONNECT 30
49 #define HOST_IF_MSG_GET_STATISTICS 31
50 #define HOST_IF_MSG_SET_MULTICAST_FILTER 32
51 #define HOST_IF_MSG_ADD_BA_SESSION 33
52 #define HOST_IF_MSG_DEL_BA_SESSION 34
53 #define HOST_IF_MSG_Q_IDLE 35
54 #define HOST_IF_MSG_DEL_ALL_STA 36
55 #define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
56 #define HOST_IF_MSG_EXIT 100
58 #define HOST_IF_SCAN_TIMEOUT 4000
59 #define HOST_IF_CONNECT_TIMEOUT 9500
61 #define BA_SESSION_DEFAULT_BUFFER_SIZE 16
62 #define BA_SESSION_DEFAULT_TIMEOUT 1000
63 #define BLOCK_ACK_REQ_SIZE 0x14
66 * @struct cfg_param_attr
67 * @brief Structure to hold Host IF CFG Params Attributes
71 * @author Mai Daftedar
75 struct cfg_param_attr {
76 struct cfg_param_val pstrCfgParamVal;
80 * @struct host_if_wpa_attr
81 * @brief Structure to hold Host IF Scan Attributes
85 * @author Mai Daftedar
89 struct host_if_wpa_attr {
101 * @struct host_if_wep_attr
102 * @brief Structure to hold Host IF Scan Attributes
106 * @author Mai Daftedar
107 * @date 25 March 2012
110 struct host_if_wep_attr {
115 enum AUTHTYPE tenuAuth_type;
119 * @struct host_if_key_attr
120 * @brief Structure to hold Host IF Scan Attributes
124 * @author Mai Daftedar
125 * @date 25 March 2012
128 union host_if_key_attr {
129 struct host_if_wep_attr strHostIFwepAttr;
130 struct host_if_wpa_attr strHostIFwpaAttr;
131 struct host_if_pmkid_attr strHostIFpmkidAttr;
136 * @brief Structure to hold Host IF Scan Attributes
140 * @author Mai Daftedar
141 * @date 25 March 2012
145 enum KEY_TYPE enuKeyType;
147 union host_if_key_attr uniHostIFkeyAttr;
155 * @brief Structure to hold Host IF Scan Attributes
159 * @author Mostafa Abu Bakr
160 * @date 25 March 2012
170 wilc_scan_result pfScanResult;
172 struct hidden_network strHiddenNetwork;
176 * @struct connect_attr
177 * @brief Structure to hold Host IF Connect Attributes
181 * @author Mostafa Abu Bakr
182 * @date 25 March 2012
185 struct connect_attr {
192 wilc_connect_result pfConnectResult;
194 enum AUTHTYPE tenuAuth_type;
200 * @struct rcvd_async_info
201 * @brief Structure to hold Received General Asynchronous info
205 * @author Mostafa Abu Bakr
206 * @date 25 March 2012
209 struct rcvd_async_info {
215 * @struct channel_attr
216 * @brief Set Channel message body
220 * @author Mai Daftedar
221 * @date 25 March 2012
224 struct channel_attr {
229 * @struct tstrScanComplete
230 * @brief hold received Async. Scan Complete message body
235 * @date 25 March 2012
238 /*typedef struct _tstrScanComplete
242 * } tstrScanComplete;*/
245 * @struct beacon_attr
246 * @brief Set Beacon message body
250 * @author Adham Abozaeid
255 u32 u32Interval; /*!< Beacon Interval. Period between two successive beacons on air */
256 u32 u32DTIMPeriod; /*!< DTIM Period. Indicates how many Beacon frames
257 * (including the current frame) appear before the next DTIM */
258 u32 u32HeadLen; /*!< Length of the head buffer in bytes */
259 u8 *pu8Head; /*!< Pointer to the beacon's head buffer. Beacon's head is the part
260 * from the beacon's start till the TIM element, NOT including the TIM */
261 u32 u32TailLen; /*!< Length of the tail buffer in bytes */
262 u8 *pu8Tail; /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just
263 * after the TIM inormation element */
267 * @struct set_multicast
268 * @brief set Multicast filter Address
272 * @author Abdelrahman Sobhy
273 * @date 30 August 2013
274 * @version 1.0 Description
277 struct set_multicast {
283 * @struct del_all_sta
284 * @brief Deauth station message body
288 * @author Mai Daftedar
289 * @date 09 April 2014
290 * @version 1.0 Description
293 u8 au8Sta_DelAllSta[MAX_NUM_STA][ETH_ALEN];
299 * @brief Delete station message body
303 * @author Adham Abozaeid
305 * @version 1.0 Description
308 u8 au8MacAddr[ETH_ALEN];
312 * @struct power_mgmt_param
313 * @brief Power management message body
317 * @author Adham Abozaeid
318 * @date 24 November 2012
321 struct power_mgmt_param {
328 * @struct set_ip_addr
329 * @brief set IP Address message body
333 * @author Abdelrahman Sobhy
334 * @date 30 August 2013
335 * @version 1.0 Description
343 * @struct sta_inactive_t
344 * @brief Get station message body
348 * @author Mai Daftedar
349 * @date 16 April 2013
352 struct sta_inactive_t {
357 * @union message_body
358 * @brief Message body for the Host Interface message_q
362 * @author Mostafa Abu Bakr
363 * @date 25 March 2012
367 struct scan_attr scan_info;
368 struct connect_attr con_info;
369 struct rcvd_net_info net_info;
370 struct rcvd_async_info async_info;
371 struct key_attr key_info;
372 struct cfg_param_attr cfg_info;
373 struct channel_attr channel_info;
374 struct beacon_attr beacon_info;
375 struct add_sta_param add_sta_info;
376 struct del_sta del_sta_info;
377 struct add_sta_param edit_sta_info;
378 struct power_mgmt_param pwr_mgmt_info;
379 struct sta_inactive_t mac_info;
380 struct set_ip_addr ip_info;
381 struct drv_handler drv;
382 struct set_multicast multicast_info;
384 struct set_mac_addr set_mac_info;
385 struct get_mac_addr get_mac_info;
386 struct ba_session_info session_info;
387 struct remain_ch remain_on_ch;
388 struct reg_frame reg_frame;
390 struct del_all_sta del_all_sta_info;
394 * @struct struct host_if_msg
395 * @brief Host Interface message
399 * @author Mostafa Abu Bakr
400 * @date 25 March 2012
404 u16 id; /*!< Message ID */
405 union message_body body; /*!< Message body */
406 struct host_if_drv *drv;
409 typedef struct _tstrWidJoinReqExt {
410 char SSID[MAX_SSID_LEN];
415 /*Struct containg joinParam of each AP*/
416 typedef struct _tstrJoinBssParam {
422 char ssid[MAX_SSID_LEN];
424 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
431 u8 rsn_pcip_policy[3];
432 u8 rsn_auth_policy[3];
434 struct _tstrJoinParam *nextJoinBss;
445 /*a linked list table containing needed join parameters entries for each AP found in most recent scan*/
446 typedef struct _tstrBssTable {
448 tstrJoinBssParam *head;
449 tstrJoinBssParam *tail;
455 SCAN_CONNECT_TIMER_FORCE_32BIT = 0xFFFFFFFF
458 /*****************************************************************************/
460 /* Global Variabls */
462 /*****************************************************************************/
463 /* Zero is not used, because a zero ID means termination */
464 static struct host_if_drv *wfidrv_list[NUM_CONCURRENT_IFC + 1];
465 struct host_if_drv *terminated_handle;
466 struct host_if_drv *gWFiDrvHandle;
467 bool g_obtainingIP = false;
469 static struct task_struct *HostIFthreadHandler;
470 static WILC_MsgQueueHandle gMsgQHostIF;
471 static struct semaphore hSemHostIFthrdEnd;
473 struct semaphore hSemDeinitDrvHandle;
474 static struct semaphore hWaitResponse;
475 struct semaphore hSemHostIntDeinit;
476 struct timer_list g_hPeriodicRSSI;
480 u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
482 static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE];
484 bool gbScanWhileConnected = false;
489 static u8 gs8SetIP[2][4];
490 static u8 gs8GetIP[2][4];
491 static u32 gu32InactiveTime;
493 static u32 gu32WidConnRstHack;
495 u8 *gu8FlushedJoinReq;
496 u8 *gu8FlushedInfoElemAsoc;
497 u8 gu8Flushed11iMode;
498 u8 gu8FlushedAuthType;
499 u32 gu32FlushedJoinReqSize;
500 u32 gu32FlushedInfoElemAsocSize;
501 struct host_if_drv *gu8FlushedJoinReqDrvHandler;
502 #define REAL_JOIN_REQ 0
503 #define FLUSHED_JOIN_REQ 1
504 #define FLUSHED_BYTE_POS 79 /* Position the byte indicating flushing in the flushed request */
506 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
508 extern void chip_sleep_manually(u32 u32SleepTime);
509 extern int linux_wlan_get_num_conn_ifcs(void);
511 static int add_handler_in_list(struct host_if_drv *handler)
515 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
516 if (!wfidrv_list[i]) {
517 wfidrv_list[i] = handler;
525 static int remove_handler_in_list(struct host_if_drv *handler)
529 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
530 if (wfidrv_list[i] == handler) {
531 wfidrv_list[i] = NULL;
539 static int get_id_from_handler(struct host_if_drv *handler)
546 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
547 if (wfidrv_list[i] == handler)
554 static struct host_if_drv *get_handler_from_id(int id)
556 if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list))
558 return wfidrv_list[id];
562 * @brief Handle_SetChannel
563 * @details Sending config packet to firmware to set channel
564 * @param[in] struct channel_attr *pstrHostIFSetChan
565 * @return Error code.
570 static s32 Handle_SetChannel(struct host_if_drv *drvHandler,
571 struct channel_attr *pstrHostIFSetChan)
576 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
578 /*prepare configuration packet*/
579 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
580 strWID.enuWIDtype = WID_CHAR;
581 strWID.ps8WidVal = (char *)&(pstrHostIFSetChan->u8SetChan);
582 strWID.s32ValueSize = sizeof(char);
584 PRINT_D(HOSTINF_DBG, "Setting channel\n");
586 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
587 get_id_from_handler(pstrWFIDrv));
589 PRINT_ER("Failed to set channel\n");
596 * @brief Handle_SetWfiDrvHandler
597 * @details Sending config packet to firmware to set driver handler
598 * @param[in] void * drvHandler,
599 * struct drv_handler *pstrHostIfSetDrvHandler
600 * @return Error code.
605 static s32 Handle_SetWfiDrvHandler(struct host_if_drv *drvHandler,
606 struct drv_handler *pstrHostIfSetDrvHandler)
611 struct host_if_drv *pstrWFIDrv = drvHandler;
614 /*prepare configuration packet*/
615 strWID.u16WIDid = (u16)WID_SET_DRV_HANDLER;
616 strWID.enuWIDtype = WID_INT;
617 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetDrvHandler->u32Address);
618 strWID.s32ValueSize = sizeof(u32);
622 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
623 pstrHostIfSetDrvHandler->u32Address);
625 if (pstrWFIDrv == NULL)
626 up(&hSemDeinitDrvHandle);
630 PRINT_ER("Failed to set driver handler\n");
638 * @brief Handle_SetWfiAPDrvHandler
639 * @details Sending config packet to firmware to set driver handler
640 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
641 * @return Error code.
646 static s32 Handle_SetOperationMode(struct host_if_drv *drvHandler,
647 struct op_mode *pstrHostIfSetOperationMode)
652 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
655 /*prepare configuration packet*/
656 strWID.u16WIDid = (u16)WID_SET_OPERATION_MODE;
657 strWID.enuWIDtype = WID_INT;
658 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetOperationMode->u32Mode);
659 strWID.s32ValueSize = sizeof(u32);
662 PRINT_INFO(HOSTINF_DBG, "pstrWFIDrv= %p\n", pstrWFIDrv);
664 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
665 get_id_from_handler(pstrWFIDrv));
668 if ((pstrHostIfSetOperationMode->u32Mode) == IDLE_MODE)
669 up(&hSemDeinitDrvHandle);
673 PRINT_ER("Failed to set driver handler\n");
681 * @brief host_int_set_IPAddress
682 * @details Setting IP address params in message queue
683 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
684 * @return Error code.
689 s32 Handle_set_IPAddress(struct host_if_drv *drvHandler, u8 *pu8IPAddr, u8 idx)
694 char firmwareIPAddress[4] = {0};
695 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
697 if (pu8IPAddr[0] < 192)
700 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n", idx, pu8IPAddr);
702 memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN);
704 /*prepare configuration packet*/
705 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
706 strWID.enuWIDtype = WID_STR;
707 strWID.ps8WidVal = (u8 *)pu8IPAddr;
708 strWID.s32ValueSize = IP_ALEN;
710 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
711 get_id_from_handler(pstrWFIDrv));
714 host_int_get_ipaddress(drvHandler, firmwareIPAddress, idx);
717 PRINT_ER("Failed to set IP address\n");
721 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
728 * @brief Handle_get_IPAddress
729 * @details Setting IP address params in message queue
730 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
731 * @return Error code.
736 s32 Handle_get_IPAddress(struct host_if_drv *drvHandler, u8 *pu8IPAddr, u8 idx)
741 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
743 /*prepare configuration packet*/
744 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
745 strWID.enuWIDtype = WID_STR;
746 strWID.ps8WidVal = kmalloc(IP_ALEN, GFP_KERNEL);
747 strWID.s32ValueSize = IP_ALEN;
749 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
750 get_id_from_handler(pstrWFIDrv));
752 PRINT_INFO(HOSTINF_DBG, "%pI4\n", strWID.ps8WidVal);
754 memcpy(gs8GetIP[idx], strWID.ps8WidVal, IP_ALEN);
756 /*get the value by searching the local copy*/
757 kfree(strWID.ps8WidVal);
759 if (memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0)
760 host_int_setup_ipaddress(pstrWFIDrv, gs8SetIP[idx], idx);
763 PRINT_ER("Failed to get IP address\n");
767 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
768 PRINT_INFO(HOSTINF_DBG, "%pI4\n", gs8GetIP[idx]);
769 PRINT_INFO(HOSTINF_DBG, "\n");
776 * @brief Handle_SetMacAddress
777 * @details Setting mac address
778 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
779 * @return Error code.
780 * @author Amr Abdel-Moghny
781 * @date November 2013
784 static s32 Handle_SetMacAddress(struct host_if_drv *drvHandler,
785 struct set_mac_addr *pstrHostIfSetMacAddress)
790 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
791 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
793 if (mac_buf == NULL) {
794 PRINT_ER("No buffer to send mac address\n");
797 memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
799 /*prepare configuration packet*/
800 strWID.u16WIDid = (u16)WID_MAC_ADDR;
801 strWID.enuWIDtype = WID_STR;
802 strWID.ps8WidVal = mac_buf;
803 strWID.s32ValueSize = ETH_ALEN;
804 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", strWID.ps8WidVal);
806 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
807 get_id_from_handler(pstrWFIDrv));
809 PRINT_ER("Failed to set mac address\n");
819 * @brief Handle_GetMacAddress
820 * @details Getting mac address
821 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
822 * @return Error code.
823 * @author Amr Abdel-Moghny
827 static s32 Handle_GetMacAddress(struct host_if_drv *drvHandler,
828 struct get_mac_addr *pstrHostIfGetMacAddress)
834 /*prepare configuration packet*/
835 strWID.u16WIDid = (u16)WID_MAC_ADDR;
836 strWID.enuWIDtype = WID_STR;
837 strWID.ps8WidVal = pstrHostIfGetMacAddress->u8MacAddress;
838 strWID.s32ValueSize = ETH_ALEN;
841 s32Error = send_config_pkt(GET_CFG, &strWID, 1, false,
842 get_id_from_handler(drvHandler));
844 PRINT_ER("Failed to get mac address\n");
854 * @brief Handle_CfgParam
855 * @details Sending config packet to firmware to set CFG params
856 * @param[in] struct cfg_param_attr *strHostIFCfgParamAttr
857 * @return Error code.
862 static s32 Handle_CfgParam(struct host_if_drv *drvHandler,
863 struct cfg_param_attr *strHostIFCfgParamAttr)
866 tstrWID strWIDList[32];
868 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
871 down(&(pstrWFIDrv->gtOsCfgValuesSem));
874 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
876 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BSS_TYPE) {
877 /*----------------------------------------------------------*/
878 /*Input Value: INFRASTRUCTURE = 1, */
879 /* INDEPENDENT= 2, */
881 /*----------------------------------------------------------*/
882 /* validate input then copy>> need to check value 4 and 5 */
883 if (strHostIFCfgParamAttr->pstrCfgParamVal.bss_type < 6) {
884 strWIDList[u8WidCnt].u16WIDid = WID_BSS_TYPE;
885 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
886 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
887 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
888 pstrWFIDrv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
890 PRINT_ER("check value 6 over\n");
896 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTH_TYPE) {
897 /*------------------------------------------------------*/
898 /*Input Values: OPEN_SYSTEM = 0, */
899 /* SHARED_KEY = 1, */
901 /*------------------------------------------------------*/
902 /*validate Possible values*/
903 if ((strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 1 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 2 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 5) {
904 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TYPE;
905 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
906 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
907 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
908 pstrWFIDrv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
910 PRINT_ER("Impossible value \n");
916 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTHEN_TIMEOUT) {
917 /* range is 1 to 65535. */
918 if (strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout < 65536) {
919 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TIMEOUT;
920 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
921 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
922 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
923 pstrWFIDrv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
925 PRINT_ER("Range(1 ~ 65535) over\n");
931 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & POWER_MANAGEMENT) {
932 /*-----------------------------------------------------------*/
933 /*Input Values: NO_POWERSAVE = 0, */
934 /* MIN_FAST_PS = 1, */
935 /* MAX_FAST_PS = 2, */
936 /* MIN_PSPOLL_PS = 3, */
937 /* MAX_PSPOLL_PS = 4 */
938 /*----------------------------------------------------------*/
939 if (strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode < 5) {
940 strWIDList[u8WidCnt].u16WIDid = WID_POWER_MANAGEMENT;
941 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
942 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
943 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
944 pstrWFIDrv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
946 PRINT_ER("Invalide power mode\n");
952 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_SHORT) {
953 /* range from 1 to 256 */
954 if ((strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit < 256)) {
955 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_RETRY_LIMIT;
956 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
957 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
958 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
959 pstrWFIDrv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
961 PRINT_ER("Range(1~256) over\n");
967 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_LONG) {
968 /* range from 1 to 256 */
969 if ((strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit < 256)) {
970 strWIDList[u8WidCnt].u16WIDid = WID_LONG_RETRY_LIMIT;
971 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
973 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
974 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
975 pstrWFIDrv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
977 PRINT_ER("Range(1~256) over\n");
983 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & FRAG_THRESHOLD) {
985 if (strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold < 7937) {
986 strWIDList[u8WidCnt].u16WIDid = WID_FRAG_THRESHOLD;
987 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
988 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
989 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
990 pstrWFIDrv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
992 PRINT_ER("Threshold Range fail\n");
998 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RTS_THRESHOLD) {
999 /* range 256 to 65535 */
1000 if (strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold < 65536) {
1001 strWIDList[u8WidCnt].u16WIDid = WID_RTS_THRESHOLD;
1002 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
1003 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1004 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1005 pstrWFIDrv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
1007 PRINT_ER("Threshold Range fail\n");
1013 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PREAMBLE) {
1014 /*-----------------------------------------------------*/
1015 /*Input Values: Short= 0, */
1018 /*------------------------------------------------------*/
1019 if (strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type < 3) {
1020 strWIDList[u8WidCnt].u16WIDid = WID_PREAMBLE;
1021 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
1022 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1023 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1024 pstrWFIDrv->strCfgValues.preamble_type = strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
1026 PRINT_ER("Preamle Range(0~2) over\n");
1032 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SHORT_SLOT_ALLOWED) {
1033 if (strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed < 2) {
1034 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_SLOT_ALLOWED;
1035 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
1036 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1037 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1038 pstrWFIDrv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
1040 PRINT_ER("Short slot(2) over\n");
1046 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & TXOP_PROT_DISABLE) {
1047 /*Description: used to Disable RTS-CTS protection for TXOP burst*/
1048 /*transmission when the acknowledgement policy is No-Ack or Block-Ack */
1049 /* this information is useful for external supplicant */
1050 /*Input Values: 1 for enable and 0 for disable. */
1051 if (strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled < 2) {
1052 strWIDList[u8WidCnt].u16WIDid = WID_11N_TXOP_PROT_DISABLE;
1053 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
1054 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1055 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1056 pstrWFIDrv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
1058 PRINT_ER("TXOP prot disable\n");
1064 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BEACON_INTERVAL) {
1065 /* range is 1 to 65535. */
1066 if (strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval < 65536) {
1067 strWIDList[u8WidCnt].u16WIDid = WID_BEACON_INTERVAL;
1068 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
1069 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1070 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1071 pstrWFIDrv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
1073 PRINT_ER("Beacon interval(1~65535) fail\n");
1079 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & DTIM_PERIOD) {
1080 /* range is 1 to 255. */
1081 if (strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period < 256) {
1082 strWIDList[u8WidCnt].u16WIDid = WID_DTIM_PERIOD;
1083 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
1084 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1085 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1086 pstrWFIDrv->strCfgValues.dtim_period = strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
1088 PRINT_ER("DTIM range(1~255) fail\n");
1094 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY) {
1095 /*----------------------------------------------------------------------*/
1096 /*Input Values: SITE_SURVEY_1CH = 0, i.e.: currently set channel */
1097 /* SITE_SURVEY_ALL_CH = 1, */
1098 /* SITE_SURVEY_OFF = 2 */
1099 /*----------------------------------------------------------------------*/
1100 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled < 3) {
1101 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY;
1102 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
1103 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1104 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1105 pstrWFIDrv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
1107 PRINT_ER("Site survey disable\n");
1113 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY_SCAN_TIME) {
1114 /* range is 1 to 65535. */
1115 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time < 65536) {
1116 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY_SCAN_TIME;
1117 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
1118 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1119 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1120 pstrWFIDrv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
1122 PRINT_ER("Site survey scan time(1~65535) over\n");
1128 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & ACTIVE_SCANTIME) {
1129 /* range is 1 to 65535. */
1130 if (strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time < 65536) {
1131 strWIDList[u8WidCnt].u16WIDid = WID_ACTIVE_SCAN_TIME;
1132 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
1133 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1134 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1135 pstrWFIDrv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
1137 PRINT_ER("Active scan time(1~65535) over\n");
1143 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PASSIVE_SCANTIME) {
1144 /* range is 1 to 65535. */
1145 if (strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time < 65536) {
1146 strWIDList[u8WidCnt].u16WIDid = WID_PASSIVE_SCAN_TIME;
1147 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
1148 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1149 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1150 pstrWFIDrv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
1152 PRINT_ER("Passive scan time(1~65535) over\n");
1158 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & CURRENT_TX_RATE) {
1159 enum CURRENT_TXRATE curr_tx_rate = strHostIFCfgParamAttr->pstrCfgParamVal.curr_tx_rate;
1160 /*----------------------------------------------------------------------*/
1161 /*Rates: 1 2 5.5 11 6 9 12 18 24 36 48 54 Auto */
1162 /*InputValues: 1 2 3 4 5 6 7 8 9 10 11 12 0 */
1163 /*----------------------------------------------------------------------*/
1165 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
1166 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
1167 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
1168 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
1169 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
1170 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
1171 strWIDList[u8WidCnt].u16WIDid = WID_CURRENT_TX_RATE;
1172 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&curr_tx_rate;
1173 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1174 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1175 pstrWFIDrv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
1177 PRINT_ER("out of TX rate\n");
1183 s32Error = send_config_pkt(SET_CFG, strWIDList, u8WidCnt, false,
1184 get_id_from_handler(pstrWFIDrv));
1187 PRINT_ER("Error in setting CFG params\n");
1190 up(&(pstrWFIDrv->gtOsCfgValuesSem));
1196 * @brief Handle_wait_msg_q_empty
1197 * @details this should be the last msg and then the msg Q becomes idle
1198 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1199 * @return Error code.
1204 static s32 Handle_wait_msg_q_empty(void)
1208 g_wilc_initialized = 0;
1214 * @brief Handle_Scan
1215 * @details Sending config packet to firmware to set the scan params
1216 * @param[in] struct scan_attr *pstrHostIFscanAttr
1217 * @return Error code.
1222 static s32 Handle_Scan(struct host_if_drv *drvHandler,
1223 struct scan_attr *pstrHostIFscanAttr)
1226 tstrWID strWIDList[5];
1227 u32 u32WidsCount = 0;
1231 u8 *pu8HdnNtwrksWidVal = NULL;
1232 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *) drvHandler;
1234 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1235 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", pstrWFIDrv->enuHostIFstate);
1237 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->pfScanResult;
1238 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->pvUserArg;
1240 if ((pstrWFIDrv->enuHostIFstate >= HOST_IF_SCANNING) && (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTED)) {
1241 /* here we either in HOST_IF_SCANNING, HOST_IF_WAITING_CONN_REQ or HOST_IF_WAITING_CONN_RESP */
1242 PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", pstrWFIDrv->enuHostIFstate);
1243 PRINT_ER("Already scan\n");
1248 if (g_obtainingIP || connecting) {
1249 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
1250 PRINT_ER("Don't do obss scan\n");
1255 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1258 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount = 0;
1260 strWIDList[u32WidsCount].u16WIDid = (u16)WID_SSID_PROBE_REQ;
1261 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1263 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++)
1264 valuesize += ((pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
1265 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
1266 strWIDList[u32WidsCount].ps8WidVal = pu8HdnNtwrksWidVal;
1267 if (strWIDList[u32WidsCount].ps8WidVal != NULL) {
1268 pu8Buffer = strWIDList[u32WidsCount].ps8WidVal;
1270 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum;
1272 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum);
1274 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) {
1275 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1276 memcpy(pu8Buffer, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen);
1277 pu8Buffer += pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1282 strWIDList[u32WidsCount].s32ValueSize = (s32)(valuesize + 1);
1286 /*filling cfg param array*/
1288 /* if((pstrHostIFscanAttr->pu8IEs != NULL) && (pstrHostIFscanAttr->IEsLen != 0)) */
1290 /* IEs to be inserted in Probe Request */
1291 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_PROBE;
1292 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1293 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8IEs;
1294 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->IEsLen;
1299 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_TYPE;
1300 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1301 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1302 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanType));
1305 /*list of channels to be scanned*/
1306 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_CHANNEL_LIST;
1307 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1309 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL && pstrHostIFscanAttr->u8ChnlListLen > 0) {
1312 for (i = 0; i < pstrHostIFscanAttr->u8ChnlListLen; i++) {
1313 if (pstrHostIFscanAttr->pu8ChnlFreqList[i] > 0)
1314 pstrHostIFscanAttr->pu8ChnlFreqList[i] = pstrHostIFscanAttr->pu8ChnlFreqList[i] - 1;
1318 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8ChnlFreqList;
1319 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->u8ChnlListLen;
1323 strWIDList[u32WidsCount].u16WIDid = WID_START_SCAN_REQ;
1324 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1325 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1326 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanSource));
1329 /*keep the state as is , no need to change it*/
1330 /* gWFiDrvHandle->enuHostIFstate = HOST_IF_SCANNING; */
1332 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
1333 gbScanWhileConnected = true;
1334 else if (pstrWFIDrv->enuHostIFstate == HOST_IF_IDLE)
1335 gbScanWhileConnected = false;
1337 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount, false,
1338 get_id_from_handler(pstrWFIDrv));
1341 PRINT_ER("Failed to send scan paramters config packet\n");
1343 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
1347 del_timer(&pstrWFIDrv->hScanTimer);
1348 /*if there is an ongoing scan request*/
1349 Handle_ScanDone(drvHandler, SCAN_EVENT_ABORTED);
1352 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1353 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
1354 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
1355 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1358 /* Deallocate pstrHostIFscanAttr->pu8IEs which was previously allocated by the sending thread */
1359 if (pstrHostIFscanAttr->pu8IEs != NULL) {
1360 kfree(pstrHostIFscanAttr->pu8IEs);
1361 pstrHostIFscanAttr->pu8IEs = NULL;
1363 if (pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo != NULL) {
1364 kfree(pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo);
1365 pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo = NULL;
1368 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1369 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
1370 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
1371 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1374 if (pu8HdnNtwrksWidVal != NULL)
1375 kfree(pu8HdnNtwrksWidVal);
1381 * @brief Handle_ScanDone
1382 * @details Call scan notification callback function
1384 * @return Error code.
1389 static s32 Handle_ScanDone(struct host_if_drv *drvHandler, tenuScanEvent enuEvent)
1393 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
1396 u8 u8abort_running_scan;
1400 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
1402 /*Ask FW to abort the running scan, if any*/
1403 if (enuEvent == SCAN_EVENT_ABORTED) {
1404 PRINT_D(GENERIC_DBG, "Abort running scan\n");
1405 u8abort_running_scan = 1;
1406 strWID.u16WIDid = (u16)WID_ABORT_RUNNING_SCAN;
1407 strWID.enuWIDtype = WID_CHAR;
1408 strWID.ps8WidVal = (s8 *)&u8abort_running_scan;
1409 strWID.s32ValueSize = sizeof(char);
1412 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
1413 get_id_from_handler(pstrWFIDrv));
1415 PRINT_ER("Failed to set abort running scan\n");
1420 if (pstrWFIDrv == NULL) {
1421 PRINT_ER("Driver handler is NULL\n");
1425 /*if there is an ongoing scan request*/
1426 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
1427 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
1428 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
1429 /*delete current scan request*/
1430 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
1437 * @brief Handle_Connect
1438 * @details Sending config packet to firmware to starting connection
1439 * @param[in] struct connect_attr *pstrHostIFconnectAttr
1440 * @return Error code.
1445 u8 u8ConnectedSSID[6] = {0};
1446 static s32 Handle_Connect(struct host_if_drv *drvHandler,
1447 struct connect_attr *pstrHostIFconnectAttr)
1449 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *) drvHandler;
1451 tstrWID strWIDList[8];
1452 u32 u32WidsCount = 0, dummyval = 0;
1453 /* char passphrase[] = "12345678"; */
1454 u8 *pu8CurrByte = NULL;
1455 tstrJoinBssParam *ptstrJoinBssParam;
1457 PRINT_D(GENERIC_DBG, "Handling connect request\n");
1459 /* if we try to connect to an already connected AP then discard the request */
1461 if (memcmp(pstrHostIFconnectAttr->pu8bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
1464 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1468 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1470 ptstrJoinBssParam = (tstrJoinBssParam *)pstrHostIFconnectAttr->pJoinParams;
1471 if (ptstrJoinBssParam == NULL) {
1472 PRINT_ER("Required BSSID not found\n");
1477 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1478 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = kmalloc(6, GFP_KERNEL);
1479 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
1482 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1483 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1484 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssidLen + 1, GFP_KERNEL);
1485 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
1486 pstrHostIFconnectAttr->ssidLen);
1487 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1490 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1491 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1492 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
1493 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
1494 pstrHostIFconnectAttr->IEsLen);
1497 pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1498 pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1499 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1500 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1502 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
1503 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
1504 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
1505 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
1508 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
1509 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
1510 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
1511 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
1514 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
1515 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
1516 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
1517 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
1520 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1521 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1523 /* IEs to be inserted in Association Request */
1524 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1525 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1526 strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1527 strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1530 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1532 gu32FlushedInfoElemAsocSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1533 gu8FlushedInfoElemAsoc = kmalloc(gu32FlushedInfoElemAsocSize, GFP_KERNEL);
1534 memcpy(gu8FlushedInfoElemAsoc, pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
1535 gu32FlushedInfoElemAsocSize);
1538 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
1539 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1540 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1541 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
1544 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
1545 gu8Flushed11iMode = pstrWFIDrv->strWILC_UsrConnReq.u8security;
1547 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1550 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
1551 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1552 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1553 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1556 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
1557 gu8FlushedAuthType = (u8)pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type;
1559 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1561 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
1562 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1563 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
1564 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
1568 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
1569 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->u8channel);
1571 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
1572 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1574 /*Sending NoA attributes during connection*/
1575 strWIDList[u32WidsCount].s32ValueSize = 112; /* 79; */
1576 strWIDList[u32WidsCount].ps8WidVal = kmalloc(strWIDList[u32WidsCount].s32ValueSize, GFP_KERNEL);
1578 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1579 gu32FlushedJoinReqSize = strWIDList[u32WidsCount].s32ValueSize;
1580 gu8FlushedJoinReq = kmalloc(gu32FlushedJoinReqSize, GFP_KERNEL);
1582 if (strWIDList[u32WidsCount].ps8WidVal == NULL) {
1587 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1590 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1591 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
1592 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1594 pu8CurrByte += MAX_SSID_LEN;
1597 *(pu8CurrByte++) = INFRASTRUCTURE;
1599 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1600 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1602 PRINT_ER("Channel out of range\n");
1603 *(pu8CurrByte++) = 0xFF;
1606 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1607 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1608 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1611 if (pstrHostIFconnectAttr->pu8bssid != NULL)
1612 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
1616 if (pstrHostIFconnectAttr->pu8bssid != NULL)
1617 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
1621 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1622 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1623 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1625 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1626 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1627 /* Supported rates*/
1628 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
1629 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1632 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1633 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1635 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1638 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1639 /* copy this information to the user request */
1640 pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
1643 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1644 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1645 /* rsn group policy*/
1646 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1647 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1649 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1650 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1651 /* rsn pcip policy*/
1652 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
1653 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1655 /* rsn auth policy*/
1656 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
1657 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1659 /* rsn auth policy*/
1660 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
1661 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1663 *(pu8CurrByte++) = REAL_JOIN_REQ;
1665 *(pu8CurrByte++) = ptstrJoinBssParam->u8NoaEnbaled;
1666 if (ptstrJoinBssParam->u8NoaEnbaled) {
1667 PRINT_D(HOSTINF_DBG, "NOA present\n");
1669 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1670 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1671 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1672 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1674 *(pu8CurrByte++) = ptstrJoinBssParam->u8Index;
1676 *(pu8CurrByte++) = ptstrJoinBssParam->u8OppEnable;
1678 if (ptstrJoinBssParam->u8OppEnable)
1679 *(pu8CurrByte++) = ptstrJoinBssParam->u8CtWindow;
1681 *(pu8CurrByte++) = ptstrJoinBssParam->u8Count;
1683 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Duration, sizeof(ptstrJoinBssParam->au8Duration));
1685 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Duration);
1687 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Interval, sizeof(ptstrJoinBssParam->au8Interval));
1689 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Interval);
1691 memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
1693 pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1696 PRINT_D(HOSTINF_DBG, "NOA not present\n");
1698 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1699 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1702 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1703 * firmware at chip reset when processing the WIDs of the Connect Request.
1704 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1705 /* ////////////////////// */
1706 gu32WidConnRstHack = 0;
1707 /* ////////////////////// */
1709 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1710 memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
1711 gu8FlushedJoinReqDrvHandler = pstrWFIDrv;
1714 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1716 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1717 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->pu8bssid, ETH_ALEN);
1719 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n", pstrHostIFconnectAttr->pu8bssid);
1720 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", u8ConnectedSSID);
1723 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount, false,
1724 get_id_from_handler(pstrWFIDrv));
1726 PRINT_ER("failed to send config packet\n");
1730 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
1731 pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1736 tstrConnectInfo strConnectInfo;
1738 del_timer(&pstrWFIDrv->hConnectTimer);
1740 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
1742 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1744 if (pstrHostIFconnectAttr->pfConnectResult != NULL) {
1745 if (pstrHostIFconnectAttr->pu8bssid != NULL)
1746 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
1748 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1749 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1750 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
1751 memcpy(strConnectInfo.pu8ReqIEs,
1752 pstrHostIFconnectAttr->pu8IEs,
1753 pstrHostIFconnectAttr->IEsLen);
1756 pstrHostIFconnectAttr->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1760 pstrHostIFconnectAttr->pvUserArg);
1761 /*Change state to idle*/
1762 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
1764 if (strConnectInfo.pu8ReqIEs != NULL) {
1765 kfree(strConnectInfo.pu8ReqIEs);
1766 strConnectInfo.pu8ReqIEs = NULL;
1770 PRINT_ER("Connect callback function pointer is NULL\n");
1774 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
1775 /* Deallocate pstrHostIFconnectAttr->pu8bssid which was prevoisuly allocated by the sending thread */
1776 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1777 kfree(pstrHostIFconnectAttr->pu8bssid);
1778 pstrHostIFconnectAttr->pu8bssid = NULL;
1781 /* Deallocate pstrHostIFconnectAttr->pu8ssid which was prevoisuly allocated by the sending thread */
1782 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1783 kfree(pstrHostIFconnectAttr->pu8ssid);
1784 pstrHostIFconnectAttr->pu8ssid = NULL;
1787 /* Deallocate pstrHostIFconnectAttr->pu8IEs which was prevoisuly allocated by the sending thread */
1788 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1789 kfree(pstrHostIFconnectAttr->pu8IEs);
1790 pstrHostIFconnectAttr->pu8IEs = NULL;
1793 if (pu8CurrByte != NULL)
1799 * @brief Handle_FlushConnect
1800 * @details Sending config packet to firmware to flush an old connection
1801 * after switching FW from station one to hybrid one
1802 * @param[in] void * drvHandler
1803 * @return Error code.
1804 * @author Amr Abdel-Moghny
1809 static s32 Handle_FlushConnect(struct host_if_drv *drvHandler)
1812 tstrWID strWIDList[5];
1813 u32 u32WidsCount = 0;
1814 u8 *pu8CurrByte = NULL;
1817 /* IEs to be inserted in Association Request */
1818 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1819 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1820 strWIDList[u32WidsCount].ps8WidVal = gu8FlushedInfoElemAsoc;
1821 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedInfoElemAsocSize;
1824 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
1825 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1826 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1827 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(gu8Flushed11iMode));
1832 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
1833 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1834 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1835 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&gu8FlushedAuthType);
1838 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
1839 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1840 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedJoinReqSize;
1841 strWIDList[u32WidsCount].ps8WidVal = (s8 *)gu8FlushedJoinReq;
1842 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1844 pu8CurrByte += FLUSHED_BYTE_POS;
1845 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1849 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount, false,
1850 get_id_from_handler(gu8FlushedJoinReqDrvHandler));
1852 PRINT_ER("failed to send config packet\n");
1860 * @brief Handle_ConnectTimeout
1861 * @details Call connect notification callback function indicating connection failure
1863 * @return Error code.
1868 static s32 Handle_ConnectTimeout(struct host_if_drv *drvHandler)
1871 tstrConnectInfo strConnectInfo;
1873 u16 u16DummyReasonCode = 0;
1874 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *) drvHandler;
1876 if (pstrWFIDrv == NULL) {
1877 PRINT_ER("Driver handler is NULL\n");
1881 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
1883 gbScanWhileConnected = false;
1886 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1889 /* First, we will notify the upper layer with the Connection failure {through the Connect Callback function},
1890 * then we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
1891 * WID_DISCONNECT} */
1892 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
1893 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
1894 memcpy(strConnectInfo.au8bssid,
1895 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
1898 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1899 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1900 strConnectInfo.pu8ReqIEs = kmalloc(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
1901 memcpy(strConnectInfo.pu8ReqIEs,
1902 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
1903 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
1906 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1910 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
1912 /* Deallocation of strConnectInfo.pu8ReqIEs */
1913 if (strConnectInfo.pu8ReqIEs != NULL) {
1914 kfree(strConnectInfo.pu8ReqIEs);
1915 strConnectInfo.pu8ReqIEs = NULL;
1918 PRINT_ER("Connect callback function pointer is NULL\n");
1921 /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
1922 * WID_DISCONNECT} */
1923 strWID.u16WIDid = (u16)WID_DISCONNECT;
1924 strWID.enuWIDtype = WID_CHAR;
1925 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
1926 strWID.s32ValueSize = sizeof(char);
1928 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1930 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
1931 get_id_from_handler(pstrWFIDrv));
1933 PRINT_ER("Failed to send dissconect config packet\n");
1935 /* Deallocation of the Saved Connect Request in the global Handle */
1936 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
1937 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
1938 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
1939 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
1942 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
1943 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
1944 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
1947 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1948 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1949 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
1950 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
1953 eth_zero_addr(u8ConnectedSSID);
1954 /*Freeing flushed join request params on connect timeout*/
1955 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
1956 kfree(gu8FlushedJoinReq);
1957 gu8FlushedJoinReq = NULL;
1959 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
1960 kfree(gu8FlushedInfoElemAsoc);
1961 gu8FlushedInfoElemAsoc = NULL;
1968 * @brief Handle_RcvdNtwrkInfo
1969 * @details Handling received network information
1970 * @param[in] struct rcvd_net_info *pstrRcvdNetworkInfo
1971 * @return Error code.
1976 static s32 Handle_RcvdNtwrkInfo(struct host_if_drv *drvHandler,
1977 struct rcvd_net_info *pstrRcvdNetworkInfo)
1980 bool bNewNtwrkFound;
1985 tstrNetworkInfo *pstrNetworkInfo = NULL;
1986 void *pJoinParams = NULL;
1988 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
1992 bNewNtwrkFound = true;
1993 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
1995 /*if there is a an ongoing scan request*/
1996 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
1997 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
1998 parse_network_info(pstrRcvdNetworkInfo->pu8Buffer, &pstrNetworkInfo);
1999 if ((pstrNetworkInfo == NULL)
2000 || (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
2001 PRINT_ER("driver is null\n");
2006 /* check whether this network is discovered before */
2007 for (i = 0; i < pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
2009 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
2010 (pstrNetworkInfo->au8bssid != NULL)) {
2011 if (memcmp(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
2012 pstrNetworkInfo->au8bssid, 6) == 0) {
2013 if (pstrNetworkInfo->s8rssi <= pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
2014 /*we have already found this network with better rssi, so keep the old cached one and don't
2015 * send anything to the upper layer */
2016 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
2019 /* here the same already found network is found again but with a better rssi, so just update
2020 * the rssi for this cached network and send this updated network to the upper layer but
2021 * don't add a new record for it */
2022 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
2023 bNewNtwrkFound = false;
2030 if (bNewNtwrkFound == true) {
2031 /* here it is confirmed that it is a new discovered network,
2032 * so add its record then call the User CallBack function */
2034 PRINT_D(HOSTINF_DBG, "New network found\n");
2036 if (pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
2037 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
2039 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
2040 && (pstrNetworkInfo->au8bssid != NULL)) {
2041 memcpy(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
2042 pstrNetworkInfo->au8bssid, 6);
2044 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount++;
2046 pstrNetworkInfo->bNewNetwork = true;
2047 /* add new BSS to JoinBssTable */
2048 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
2050 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2051 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid,
2057 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
2060 pstrNetworkInfo->bNewNetwork = false;
2061 /* just call the User CallBack function to send the same discovered network with its updated RSSI */
2062 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2063 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2068 /* Deallocate pstrRcvdNetworkInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2069 if (pstrRcvdNetworkInfo->pu8Buffer != NULL) {
2070 kfree(pstrRcvdNetworkInfo->pu8Buffer);
2071 pstrRcvdNetworkInfo->pu8Buffer = NULL;
2074 /*free structure allocated*/
2075 if (pstrNetworkInfo != NULL) {
2076 DeallocateNetworkInfo(pstrNetworkInfo);
2077 pstrNetworkInfo = NULL;
2084 * @brief Handle_RcvdGnrlAsyncInfo
2085 * @details Handling received asynchrous general network information
2086 * @param[in] struct rcvd_async_info *pstrRcvdGnrlAsyncInfo
2087 * @return Error code.
2092 static s32 Handle_RcvdGnrlAsyncInfo(struct host_if_drv *drvHandler,
2093 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
2095 /* TODO: mostafa: till now, this function just handles only the received mac status msg, */
2096 /* which carries only 1 WID which have WID ID = WID_STATUS */
2101 u16 u16WidID = (u16)WID_NIL;
2104 u8 u8MacStatusReasonCode;
2105 u8 u8MacStatusAdditionalInfo;
2106 tstrConnectInfo strConnectInfo;
2107 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2109 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *) drvHandler;
2112 PRINT_ER("Driver handler is NULL\n");
2115 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", pstrWFIDrv->enuHostIFstate,
2116 pstrRcvdGnrlAsyncInfo->pu8Buffer[7]);
2118 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
2119 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) ||
2120 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2121 if ((pstrRcvdGnrlAsyncInfo->pu8Buffer == NULL) ||
2122 (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
2123 PRINT_ER("driver is null\n");
2127 u8MsgType = pstrRcvdGnrlAsyncInfo->pu8Buffer[0];
2129 /* Check whether the received message type is 'I' */
2130 if ('I' != u8MsgType) {
2131 PRINT_ER("Received Message format incorrect.\n");
2135 /* Extract message ID */
2136 u8MsgID = pstrRcvdGnrlAsyncInfo->pu8Buffer[1];
2138 /* Extract message Length */
2139 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[2], pstrRcvdGnrlAsyncInfo->pu8Buffer[3]);
2141 /* Extract WID ID [expected to be = WID_STATUS] */
2142 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[4], pstrRcvdGnrlAsyncInfo->pu8Buffer[5]);
2144 /* Extract WID Length [expected to be = 1] */
2145 u8WidLen = pstrRcvdGnrlAsyncInfo->pu8Buffer[6];
2147 /* get the WID value [expected to be one of two values: either MAC_CONNECTED = (1) or MAC_DISCONNECTED = (0)] */
2148 u8MacStatus = pstrRcvdGnrlAsyncInfo->pu8Buffer[7];
2149 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->pu8Buffer[8];
2150 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->pu8Buffer[9];
2151 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2152 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2153 /* our station had sent Association Request frame, so here it will get the Association Response frame then parse it */
2154 u32 u32RcvdAssocRespInfoLen;
2155 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
2157 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2159 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
2161 if (u8MacStatus == MAC_CONNECTED) {
2162 memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
2164 host_int_get_assoc_res_info(pstrWFIDrv,
2166 MAX_ASSOC_RESP_FRAME_SIZE,
2167 &u32RcvdAssocRespInfoLen);
2169 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
2171 if (u32RcvdAssocRespInfoLen != 0) {
2173 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
2174 s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
2175 &pstrConnectRespInfo);
2177 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
2179 /* use the necessary parsed Info from the Received Association Response */
2180 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
2182 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
2183 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
2184 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
2185 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
2188 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL);
2189 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
2190 pstrConnectRespInfo->u16RespIEsLen);
2194 /* deallocate the Assoc. Resp. parsed structure as it is not needed anymore */
2195 if (pstrConnectRespInfo != NULL) {
2196 DeallocateAssocRespInfo(pstrConnectRespInfo);
2197 pstrConnectRespInfo = NULL;
2203 /* The station has just received mac status and it also received assoc. response which
2204 * it was waiting for.
2205 * So check first the matching between the received mac status and the received status code in Asoc Resp */
2206 if ((u8MacStatus == MAC_CONNECTED) &&
2207 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
2208 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
2209 eth_zero_addr(u8ConnectedSSID);
2211 } else if (u8MacStatus == MAC_DISCONNECTED) {
2212 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
2213 eth_zero_addr(u8ConnectedSSID);
2216 /* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */
2217 /* through a structure of type tstrConnectRespInfo */
2218 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2219 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
2220 memcpy(strConnectInfo.au8bssid, pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
2222 if ((u8MacStatus == MAC_CONNECTED) &&
2223 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
2224 memcpy(pstrWFIDrv->au8AssociatedBSSID,
2225 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
2230 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2231 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
2232 strConnectInfo.pu8ReqIEs = kmalloc(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
2233 memcpy(strConnectInfo.pu8ReqIEs,
2234 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2235 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2239 del_timer(&pstrWFIDrv->hConnectTimer);
2240 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2244 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2247 /* if received mac status is MAC_CONNECTED and
2248 * received status code in Asoc Resp is SUCCESSFUL_STATUSCODE, change state to CONNECTED
2249 * else change state to IDLE */
2250 if ((u8MacStatus == MAC_CONNECTED) &&
2251 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
2252 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
2254 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
2255 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTED;
2257 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
2258 g_obtainingIP = true;
2259 mod_timer(&hDuringIpTimer,
2260 jiffies + msecs_to_jiffies(10000));
2262 /* open a BA session if possible */
2263 /* if(pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable) */
2264 /* BA_SESSION_DEFAULT_BUFFER_SIZE,BA_SESSION_DEFAULT_TIMEOUT); */
2266 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
2267 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2268 gbScanWhileConnected = false;
2272 if (strConnectInfo.pu8RespIEs != NULL) {
2273 kfree(strConnectInfo.pu8RespIEs);
2274 strConnectInfo.pu8RespIEs = NULL;
2277 if (strConnectInfo.pu8ReqIEs != NULL) {
2278 kfree(strConnectInfo.pu8ReqIEs);
2279 strConnectInfo.pu8ReqIEs = NULL;
2283 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2284 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
2285 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
2286 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2289 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2290 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
2291 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2294 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2295 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2296 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
2297 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2300 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2301 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)) {
2302 /* Disassociation or Deauthentication frame has been received */
2303 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
2305 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
2307 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2308 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
2309 del_timer(&pstrWFIDrv->hScanTimer);
2310 Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED);
2313 strDisconnectNotifInfo.u16reason = 0;
2314 strDisconnectNotifInfo.ie = NULL;
2315 strDisconnectNotifInfo.ie_len = 0;
2317 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2318 g_obtainingIP = false;
2319 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
2321 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
2324 &strDisconnectNotifInfo,
2325 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2328 PRINT_ER("Connect result callback function is NULL\n");
2331 eth_zero_addr(pstrWFIDrv->au8AssociatedBSSID);
2336 /* if Information Elements were retrieved from the Received deauth/disassoc frame, then they
2337 * should be deallocated here */
2339 * if(strDisconnectNotifInfo.ie != NULL)
2341 * kfree(strDisconnectNotifInfo.ie);
2342 * strDisconnectNotifInfo.ie = NULL;
2346 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2347 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
2348 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
2349 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2352 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2353 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
2354 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2357 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2358 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2359 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
2360 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2363 /*Freeing flushed join request params on receiving*/
2364 /*MAC_DISCONNECTED while connected*/
2365 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
2366 kfree(gu8FlushedJoinReq);
2367 gu8FlushedJoinReq = NULL;
2369 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
2370 kfree(gu8FlushedInfoElemAsoc);
2371 gu8FlushedInfoElemAsoc = NULL;
2374 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2375 gbScanWhileConnected = false;
2377 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2378 (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
2379 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
2380 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
2381 /*Abort the running scan*/
2382 del_timer(&pstrWFIDrv->hScanTimer);
2383 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult)
2384 Handle_ScanDone(pstrWFIDrv, SCAN_EVENT_ABORTED);
2390 /* Deallocate pstrRcvdGnrlAsyncInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2391 if (pstrRcvdGnrlAsyncInfo->pu8Buffer != NULL) {
2392 kfree(pstrRcvdGnrlAsyncInfo->pu8Buffer);
2393 pstrRcvdGnrlAsyncInfo->pu8Buffer = NULL;
2401 * @details Sending config packet to firmware to set key
2402 * @param[in] struct key_attr *pstrHostIFkeyAttr
2403 * @return Error code.
2408 static int Handle_Key(struct host_if_drv *drvHandler,
2409 struct key_attr *pstrHostIFkeyAttr)
2413 tstrWID strWIDList[5];
2418 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
2421 switch (pstrHostIFkeyAttr->enuKeyType) {
2426 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2428 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
2429 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
2430 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
2431 strWIDList[0].enuWIDtype = WID_CHAR;
2432 strWIDList[0].s32ValueSize = sizeof(char);
2433 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8mode));
2435 strWIDList[1].u16WIDid = WID_AUTH_TYPE;
2436 strWIDList[1].enuWIDtype = WID_CHAR;
2437 strWIDList[1].s32ValueSize = sizeof(char);
2438 strWIDList[1].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type));
2440 strWIDList[2].u16WIDid = (u16)WID_KEY_ID;
2441 strWIDList[2].enuWIDtype = WID_CHAR;
2443 strWIDList[2].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
2444 strWIDList[2].s32ValueSize = sizeof(char);
2447 pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, GFP_KERNEL);
2450 if (pu8keybuf == NULL) {
2451 PRINT_ER("No buffer to send Key\n");
2455 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
2456 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2459 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
2461 strWIDList[3].u16WIDid = (u16)WID_WEP_KEY_VALUE;
2462 strWIDList[3].enuWIDtype = WID_STR;
2463 strWIDList[3].s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen;
2464 strWIDList[3].ps8WidVal = (s8 *)pu8keybuf;
2467 s32Error = send_config_pkt(SET_CFG, strWIDList, 4, true,
2468 get_id_from_handler(pstrWFIDrv));
2474 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2475 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
2476 pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2, GFP_KERNEL);
2477 if (pu8keybuf == NULL) {
2478 PRINT_ER("No buffer to send Key\n");
2481 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2483 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, 1);
2485 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
2486 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2488 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
2490 strWID.u16WIDid = (u16)WID_ADD_WEP_KEY;
2491 strWID.enuWIDtype = WID_STR;
2492 strWID.ps8WidVal = (s8 *)pu8keybuf;
2493 strWID.s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2;
2495 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2496 get_id_from_handler(pstrWFIDrv));
2498 } else if (pstrHostIFkeyAttr->u8KeyAction & REMOVEKEY) {
2500 PRINT_D(HOSTINF_DBG, "Removing key\n");
2501 strWID.u16WIDid = (u16)WID_REMOVE_WEP_KEY;
2502 strWID.enuWIDtype = WID_STR;
2504 s8idxarray[0] = (s8)pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2505 strWID.ps8WidVal = s8idxarray;
2506 strWID.s32ValueSize = 1;
2508 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2509 get_id_from_handler(pstrWFIDrv));
2511 strWID.u16WIDid = (u16)WID_KEY_ID;
2512 strWID.enuWIDtype = WID_CHAR;
2513 strWID.ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
2514 strWID.s32ValueSize = sizeof(char);
2516 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
2518 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2519 get_id_from_handler(pstrWFIDrv));
2521 up(&(pstrWFIDrv->hSemTestKeyBlock));
2525 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2526 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
2527 if (pu8keybuf == NULL) {
2528 PRINT_ER("No buffer to send RxGTK Key\n");
2530 goto _WPARxGtk_end_case_;
2533 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
2536 /*|----------------------------------------------------------------------------|
2537 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2538 * |------------|---------|-------|------------|---------------|----------------|
2539 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2543 if (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq != NULL)
2544 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
2547 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2549 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2551 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2552 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2553 /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */
2554 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
2555 strWIDList[0].enuWIDtype = WID_CHAR;
2556 strWIDList[0].s32ValueSize = sizeof(char);
2557 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
2559 strWIDList[1].u16WIDid = (u16)WID_ADD_RX_GTK;
2560 strWIDList[1].enuWIDtype = WID_STR;
2561 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
2562 strWIDList[1].s32ValueSize = RX_MIC_KEY_MSG_LEN;
2564 s32Error = send_config_pkt(SET_CFG, strWIDList, 2, true,
2565 get_id_from_handler(pstrWFIDrv));
2569 /* ////////////////////////// */
2570 up(&(pstrWFIDrv->hSemTestKeyBlock));
2571 /* ///////////////////////// */
2574 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2575 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
2577 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
2578 if (pu8keybuf == NULL) {
2579 PRINT_ER("No buffer to send RxGTK Key\n");
2581 goto _WPARxGtk_end_case_;
2584 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
2587 /*|----------------------------------------------------------------------------|
2588 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2589 * |------------|---------|-------|------------|---------------|----------------|
2590 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2592 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
2593 memcpy(pu8keybuf, pstrWFIDrv->au8AssociatedBSSID, ETH_ALEN);
2595 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
2597 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
2599 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2601 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2602 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2603 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2605 strWID.u16WIDid = (u16)WID_ADD_RX_GTK;
2606 strWID.enuWIDtype = WID_STR;
2607 strWID.ps8WidVal = (s8 *)pu8keybuf;
2608 strWID.s32ValueSize = RX_MIC_KEY_MSG_LEN;
2610 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2611 get_id_from_handler(pstrWFIDrv));
2615 /* ////////////////////////// */
2616 up(&(pstrWFIDrv->hSemTestKeyBlock));
2617 /* ///////////////////////// */
2619 _WPARxGtk_end_case_:
2620 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
2621 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq);
2628 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2631 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
2635 if (pu8keybuf == NULL) {
2636 PRINT_ER("No buffer to send PTK Key\n");
2638 goto _WPAPtk_end_case_;
2642 /*|-----------------------------------------------------------------------------|
2643 * |Station address | keyidx |Key Length |Temporal Key | Rx Michael Key |Tx Michael Key |
2644 * |----------------|------------ |--------------|----------------|---------------|
2645 | 6 bytes | 1 byte | 1byte | 16 bytes | 8 bytes | 8 bytes |
2646 |-----------------------------------------------------------------------------|*/
2648 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
2650 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2651 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2653 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2654 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2657 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
2658 strWIDList[0].enuWIDtype = WID_CHAR;
2659 strWIDList[0].s32ValueSize = sizeof(char);
2660 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
2662 strWIDList[1].u16WIDid = (u16)WID_ADD_PTK;
2663 strWIDList[1].enuWIDtype = WID_STR;
2664 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
2665 strWIDList[1].s32ValueSize = PTK_KEY_MSG_LEN + 1;
2667 s32Error = send_config_pkt(SET_CFG, strWIDList, 2, true,
2668 get_id_from_handler(pstrWFIDrv));
2671 /* ////////////////////////// */
2672 up(&(pstrWFIDrv->hSemTestKeyBlock));
2673 /* ///////////////////////// */
2675 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2678 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
2682 if (pu8keybuf == NULL) {
2683 PRINT_ER("No buffer to send PTK Key\n");
2685 goto _WPAPtk_end_case_;
2689 /*|-----------------------------------------------------------------------------|
2690 * |Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
2691 * |----------------|------------|--------------|----------------|---------------|
2692 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
2693 |-----------------------------------------------------------------------------|*/
2695 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
2697 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2699 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2700 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2703 strWID.u16WIDid = (u16)WID_ADD_PTK;
2704 strWID.enuWIDtype = WID_STR;
2705 strWID.ps8WidVal = (s8 *)pu8keybuf;
2706 strWID.s32ValueSize = PTK_KEY_MSG_LEN;
2708 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2709 get_id_from_handler(pstrWFIDrv));
2712 /* ////////////////////////// */
2713 up(&(pstrWFIDrv->hSemTestKeyBlock));
2714 /* ///////////////////////// */
2718 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
2727 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
2729 pu8keybuf = kmalloc((pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
2730 if (pu8keybuf == NULL) {
2731 PRINT_ER("No buffer to send PMKSA Key\n");
2735 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid;
2737 for (i = 0; i < pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid; i++) {
2739 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, ETH_ALEN);
2740 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, PMKID_LEN);
2743 strWID.u16WIDid = (u16)WID_PMKID_INFO;
2744 strWID.enuWIDtype = WID_STR;
2745 strWID.ps8WidVal = (s8 *)pu8keybuf;
2746 strWID.s32ValueSize = (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1;
2748 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2749 get_id_from_handler(pstrWFIDrv));
2756 PRINT_ER("Failed to send key config packet\n");
2764 * @brief Handle_Disconnect
2765 * @details Sending config packet to firmware to disconnect
2772 static void Handle_Disconnect(struct host_if_drv *drvHandler)
2777 u16 u16DummyReasonCode = 0;
2778 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
2781 strWID.u16WIDid = (u16)WID_DISCONNECT;
2782 strWID.enuWIDtype = WID_CHAR;
2783 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
2784 strWID.s32ValueSize = sizeof(char);
2788 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2790 g_obtainingIP = false;
2791 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
2793 eth_zero_addr(u8ConnectedSSID);
2795 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
2796 get_id_from_handler(pstrWFIDrv));
2799 PRINT_ER("Failed to send dissconect config packet\n");
2801 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2803 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
2805 strDisconnectNotifInfo.u16reason = 0;
2806 strDisconnectNotifInfo.ie = NULL;
2807 strDisconnectNotifInfo.ie_len = 0;
2809 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2810 del_timer(&pstrWFIDrv->hScanTimer);
2811 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
2812 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2814 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
2817 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2819 /*Stop connect timer, if connection in progress*/
2820 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2821 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
2822 del_timer(&pstrWFIDrv->hConnectTimer);
2825 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
2826 0, &strDisconnectNotifInfo, pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2828 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
2831 gbScanWhileConnected = false;
2833 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2835 eth_zero_addr(pstrWFIDrv->au8AssociatedBSSID);
2839 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2840 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
2841 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
2842 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2845 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2846 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
2847 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2850 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2851 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2852 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
2853 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2857 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
2858 kfree(gu8FlushedJoinReq);
2859 gu8FlushedJoinReq = NULL;
2861 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
2862 kfree(gu8FlushedInfoElemAsoc);
2863 gu8FlushedInfoElemAsoc = NULL;
2868 /* ////////////////////////// */
2869 up(&(pstrWFIDrv->hSemTestDisconnectBlock));
2870 /* ///////////////////////// */
2875 void resolve_disconnect_aberration(struct host_if_drv *drvHandler)
2877 struct host_if_drv *pstrWFIDrv;
2879 pstrWFIDrv = (struct host_if_drv *)drvHandler;
2880 if (pstrWFIDrv == NULL)
2882 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTING)) {
2883 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
2884 host_int_disconnect(pstrWFIDrv, 1);
2889 * @brief Handle_GetChnl
2890 * @details Sending config packet to get channel
2898 static s32 Handle_GetChnl(struct host_if_drv *drvHandler)
2903 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
2905 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
2906 strWID.enuWIDtype = WID_CHAR;
2907 strWID.ps8WidVal = (s8 *)&gu8Chnl;
2908 strWID.s32ValueSize = sizeof(char);
2910 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
2912 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
2913 get_id_from_handler(pstrWFIDrv));
2914 /*get the value by searching the local copy*/
2916 PRINT_ER("Failed to get channel number\n");
2920 up(&(pstrWFIDrv->hSemGetCHNL));
2930 * @brief Handle_GetRssi
2931 * @details Sending config packet to get RSSI
2938 static void Handle_GetRssi(struct host_if_drv *drvHandler)
2942 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
2944 strWID.u16WIDid = (u16)WID_RSSI;
2945 strWID.enuWIDtype = WID_CHAR;
2946 strWID.ps8WidVal = &gs8Rssi;
2947 strWID.s32ValueSize = sizeof(char);
2950 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
2952 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
2953 get_id_from_handler(pstrWFIDrv));
2955 PRINT_ER("Failed to get RSSI value\n");
2959 up(&(pstrWFIDrv->hSemGetRSSI));
2965 static void Handle_GetLinkspeed(struct host_if_drv *drvHandler)
2969 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
2973 strWID.u16WIDid = (u16)WID_LINKSPEED;
2974 strWID.enuWIDtype = WID_CHAR;
2975 strWID.ps8WidVal = &gs8lnkspd;
2976 strWID.s32ValueSize = sizeof(char);
2978 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
2980 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
2981 get_id_from_handler(pstrWFIDrv));
2983 PRINT_ER("Failed to get LINKSPEED value\n");
2987 up(&(pstrWFIDrv->hSemGetLINKSPEED));
2992 s32 Handle_GetStatistics(struct host_if_drv *drvHandler, tstrStatistics *pstrStatistics)
2994 tstrWID strWIDList[5];
2995 u32 u32WidsCount = 0, s32Error = 0;
2997 strWIDList[u32WidsCount].u16WIDid = WID_LINKSPEED;
2998 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
2999 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
3000 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u8LinkSpeed));
3003 strWIDList[u32WidsCount].u16WIDid = WID_RSSI;
3004 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
3005 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
3006 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->s8RSSI));
3009 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
3010 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
3011 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
3012 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxCount));
3015 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
3016 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
3017 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
3018 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32RxCount));
3021 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
3022 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
3023 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
3024 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxFailureCount));
3027 s32Error = send_config_pkt(GET_CFG, strWIDList, u32WidsCount, false,
3028 get_id_from_handler(drvHandler));
3031 PRINT_ER("Failed to send scan paramters config packet\n");
3039 * @brief Handle_Get_InActiveTime
3040 * @details Sending config packet to set mac adddress for station and
3049 static s32 Handle_Get_InActiveTime(struct host_if_drv *drvHandler,
3050 struct sta_inactive_t *strHostIfStaInactiveT)
3056 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
3059 strWID.u16WIDid = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
3060 strWID.enuWIDtype = WID_STR;
3061 strWID.s32ValueSize = ETH_ALEN;
3062 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
3065 stamac = strWID.ps8WidVal;
3066 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
3069 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
3072 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3073 get_id_from_handler(pstrWFIDrv));
3074 /*get the value by searching the local copy*/
3076 PRINT_ER("Failed to SET incative time\n");
3081 strWID.u16WIDid = (u16)WID_GET_INACTIVE_TIME;
3082 strWID.enuWIDtype = WID_INT;
3083 strWID.ps8WidVal = (s8 *)&gu32InactiveTime;
3084 strWID.s32ValueSize = sizeof(u32);
3087 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
3088 get_id_from_handler(pstrWFIDrv));
3089 /*get the value by searching the local copy*/
3091 PRINT_ER("Failed to get incative time\n");
3096 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
3098 up(&(pstrWFIDrv->hSemInactiveTime));
3108 * @brief Handle_AddBeacon
3109 * @details Sending config packet to add beacon
3110 * @param[in] struct beacon_attr *pstrSetBeaconParam
3116 static void Handle_AddBeacon(struct host_if_drv *drvHandler,
3117 struct beacon_attr *pstrSetBeaconParam)
3122 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
3124 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
3126 strWID.u16WIDid = (u16)WID_ADD_BEACON;
3127 strWID.enuWIDtype = WID_BIN;
3128 strWID.s32ValueSize = pstrSetBeaconParam->u32HeadLen + pstrSetBeaconParam->u32TailLen + 16;
3129 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
3130 if (strWID.ps8WidVal == NULL)
3133 pu8CurrByte = strWID.ps8WidVal;
3134 *pu8CurrByte++ = (pstrSetBeaconParam->u32Interval & 0xFF);
3135 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 8) & 0xFF);
3136 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 16) & 0xFF);
3137 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 24) & 0xFF);
3139 *pu8CurrByte++ = (pstrSetBeaconParam->u32DTIMPeriod & 0xFF);
3140 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 8) & 0xFF);
3141 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 16) & 0xFF);
3142 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 24) & 0xFF);
3144 *pu8CurrByte++ = (pstrSetBeaconParam->u32HeadLen & 0xFF);
3145 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 8) & 0xFF);
3146 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 16) & 0xFF);
3147 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 24) & 0xFF);
3149 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Head, pstrSetBeaconParam->u32HeadLen);
3150 pu8CurrByte += pstrSetBeaconParam->u32HeadLen;
3152 *pu8CurrByte++ = (pstrSetBeaconParam->u32TailLen & 0xFF);
3153 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 8) & 0xFF);
3154 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 16) & 0xFF);
3155 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 24) & 0xFF);
3157 if (pstrSetBeaconParam->pu8Tail > 0)
3158 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Tail, pstrSetBeaconParam->u32TailLen);
3159 pu8CurrByte += pstrSetBeaconParam->u32TailLen;
3164 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3165 get_id_from_handler(pstrWFIDrv));
3167 PRINT_ER("Failed to send add beacon config packet\n");
3170 kfree(strWID.ps8WidVal);
3171 kfree(pstrSetBeaconParam->pu8Head);
3172 kfree(pstrSetBeaconParam->pu8Tail);
3177 * @brief Handle_AddBeacon
3178 * @details Sending config packet to delete beacon
3179 * @param[in] struct host_if_drv *drvHandler
3185 static void Handle_DelBeacon(struct host_if_drv *drvHandler)
3190 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
3192 strWID.u16WIDid = (u16)WID_DEL_BEACON;
3193 strWID.enuWIDtype = WID_CHAR;
3194 strWID.s32ValueSize = sizeof(char);
3195 strWID.ps8WidVal = &gu8DelBcn;
3197 if (strWID.ps8WidVal == NULL)
3200 pu8CurrByte = strWID.ps8WidVal;
3202 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
3203 /* TODO: build del beacon message*/
3206 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3207 get_id_from_handler(pstrWFIDrv));
3209 PRINT_ER("Failed to send delete beacon config packet\n");
3214 * @brief WILC_HostIf_PackStaParam
3215 * @details Handling packing of the station params in a buffer
3216 * @param[in] u8* pu8Buffer, struct add_sta_param *pstrStationParam
3222 static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
3223 struct add_sta_param *pstrStationParam)
3227 pu8CurrByte = pu8Buffer;
3229 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
3230 memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
3231 pu8CurrByte += ETH_ALEN;
3233 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
3234 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
3236 *pu8CurrByte++ = pstrStationParam->u8NumRates;
3237 if (pstrStationParam->u8NumRates > 0)
3238 memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
3239 pu8CurrByte += pstrStationParam->u8NumRates;
3241 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
3242 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
3243 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
3245 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
3246 memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
3247 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
3249 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
3250 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
3252 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
3253 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
3254 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
3255 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
3257 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
3259 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
3260 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
3262 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
3263 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
3265 return pu8CurrByte - pu8Buffer;
3269 * @brief Handle_AddStation
3270 * @details Sending config packet to add station
3271 * @param[in] struct add_sta_param *pstrStationParam
3277 static void Handle_AddStation(struct host_if_drv *drvHandler,
3278 struct add_sta_param *pstrStationParam)
3283 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
3285 PRINT_D(HOSTINF_DBG, "Handling add station\n");
3286 strWID.u16WIDid = (u16)WID_ADD_STA;
3287 strWID.enuWIDtype = WID_BIN;
3288 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3290 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
3291 if (strWID.ps8WidVal == NULL)
3294 pu8CurrByte = strWID.ps8WidVal;
3295 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3298 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3299 get_id_from_handler(pstrWFIDrv));
3301 PRINT_ER("Failed to send add station config packet\n");
3304 kfree(pstrStationParam->pu8Rates);
3305 kfree(strWID.ps8WidVal);
3309 * @brief Handle_DelAllSta
3310 * @details Sending config packet to delete station
3311 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3317 static void Handle_DelAllSta(struct host_if_drv *drvHandler,
3318 struct del_all_sta *pstrDelAllStaParam)
3324 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
3326 u8 au8Zero_Buff[6] = {0};
3328 strWID.u16WIDid = (u16)WID_DEL_ALL_STA;
3329 strWID.enuWIDtype = WID_STR;
3330 strWID.s32ValueSize = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1;
3332 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
3334 strWID.ps8WidVal = kmalloc((pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1, GFP_KERNEL);
3335 if (strWID.ps8WidVal == NULL)
3338 pu8CurrByte = strWID.ps8WidVal;
3340 *(pu8CurrByte++) = pstrDelAllStaParam->u8Num_AssocSta;
3342 for (i = 0; i < MAX_NUM_STA; i++) {
3343 if (memcmp(pstrDelAllStaParam->au8Sta_DelAllSta[i], au8Zero_Buff, ETH_ALEN))
3344 memcpy(pu8CurrByte, pstrDelAllStaParam->au8Sta_DelAllSta[i], ETH_ALEN);
3348 pu8CurrByte += ETH_ALEN;
3352 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3353 get_id_from_handler(pstrWFIDrv));
3355 PRINT_ER("Failed to send add station config packet\n");
3358 kfree(strWID.ps8WidVal);
3365 * @brief Handle_DelStation
3366 * @details Sending config packet to delete station
3367 * @param[in] struct del_sta *pstrDelStaParam
3373 static void Handle_DelStation(struct host_if_drv *drvHandler,
3374 struct del_sta *pstrDelStaParam)
3379 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
3381 strWID.u16WIDid = (u16)WID_REMOVE_STA;
3382 strWID.enuWIDtype = WID_BIN;
3383 strWID.s32ValueSize = ETH_ALEN;
3385 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
3387 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
3388 if (strWID.ps8WidVal == NULL)
3391 pu8CurrByte = strWID.ps8WidVal;
3393 memcpy(pu8CurrByte, pstrDelStaParam->au8MacAddr, ETH_ALEN);
3396 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3397 get_id_from_handler(pstrWFIDrv));
3399 PRINT_ER("Failed to send add station config packet\n");
3402 kfree(strWID.ps8WidVal);
3407 * @brief Handle_EditStation
3408 * @details Sending config packet to edit station
3409 * @param[in] struct add_sta_param *pstrStationParam
3415 static void Handle_EditStation(struct host_if_drv *drvHandler,
3416 struct add_sta_param *pstrStationParam)
3421 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
3423 strWID.u16WIDid = (u16)WID_EDIT_STA;
3424 strWID.enuWIDtype = WID_BIN;
3425 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3427 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
3428 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
3429 if (strWID.ps8WidVal == NULL)
3432 pu8CurrByte = strWID.ps8WidVal;
3433 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3436 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3437 get_id_from_handler(pstrWFIDrv));
3439 PRINT_ER("Failed to send edit station config packet\n");
3442 kfree(pstrStationParam->pu8Rates);
3443 kfree(strWID.ps8WidVal);
3447 * @brief Handle_RemainOnChan
3448 * @details Sending config packet to edit station
3449 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3455 static int Handle_RemainOnChan(struct host_if_drv *drvHandler,
3456 struct remain_ch *pstrHostIfRemainOnChan)
3459 u8 u8remain_on_chan_flag;
3461 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *) drvHandler;
3463 /*If it's a pendig remain-on-channel, don't overwrite gWFiDrvHandle values (since incoming msg is garbbage)*/
3464 if (!pstrWFIDrv->u8RemainOnChan_pendingreq) {
3465 pstrWFIDrv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
3466 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
3467 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
3468 pstrWFIDrv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
3469 pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
3471 /*Set the channel to use it as a wid val*/
3472 pstrHostIfRemainOnChan->u16Channel = pstrWFIDrv->strHostIfRemainOnChan.u16Channel;
3475 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
3476 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
3477 pstrWFIDrv->u8RemainOnChan_pendingreq = 1;
3481 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3482 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
3487 if (g_obtainingIP || connecting) {
3488 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
3493 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
3495 u8remain_on_chan_flag = true;
3496 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
3497 strWID.enuWIDtype = WID_STR;
3498 strWID.s32ValueSize = 2;
3499 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
3501 if (strWID.ps8WidVal == NULL) {
3506 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
3507 strWID.ps8WidVal[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
3510 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3511 get_id_from_handler(pstrWFIDrv));
3513 PRINT_ER("Failed to set remain on channel\n");
3517 P2P_LISTEN_STATE = 1;
3518 pstrWFIDrv->hRemainOnChannel.data = (unsigned long)pstrWFIDrv;
3519 mod_timer(&pstrWFIDrv->hRemainOnChannel,
3521 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
3523 /*Calling CFG ready_on_channel*/
3524 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady)
3525 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady(pstrWFIDrv->strHostIfRemainOnChan.pVoid);
3527 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
3528 pstrWFIDrv->u8RemainOnChan_pendingreq = 0;
3534 * @brief Handle_RegisterFrame
3542 static int Handle_RegisterFrame(struct host_if_drv *drvHandler,
3543 struct reg_frame *pstrHostIfRegisterFrame)
3548 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
3550 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
3552 /*prepare configuration packet*/
3553 strWID.u16WIDid = (u16)WID_REGISTER_FRAME;
3554 strWID.enuWIDtype = WID_STR;
3555 strWID.ps8WidVal = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
3556 if (strWID.ps8WidVal == NULL)
3559 pu8CurrByte = strWID.ps8WidVal;
3561 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
3562 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
3563 memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
3566 strWID.s32ValueSize = sizeof(u16) + 2;
3570 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3571 get_id_from_handler(pstrWFIDrv));
3573 PRINT_ER("Failed to frame register config packet\n");
3582 * @brief Handle_ListenStateExpired
3583 * @details Handle of listen state expiration
3585 * @return Error code.
3590 #define FALSE_FRMWR_CHANNEL 100
3591 static u32 Handle_ListenStateExpired(struct host_if_drv *drvHandler,
3592 struct remain_ch *pstrHostIfRemainOnChan)
3594 u8 u8remain_on_chan_flag;
3597 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *) drvHandler;
3599 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
3601 /*Make sure we are already in listen state*/
3602 /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/
3603 if (P2P_LISTEN_STATE) {
3604 u8remain_on_chan_flag = false;
3605 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
3606 strWID.enuWIDtype = WID_STR;
3607 strWID.s32ValueSize = 2;
3608 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
3610 if (strWID.ps8WidVal == NULL)
3611 PRINT_ER("Failed to allocate memory\n");
3613 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
3614 strWID.ps8WidVal[1] = FALSE_FRMWR_CHANNEL;
3617 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3618 get_id_from_handler(pstrWFIDrv));
3619 if (s32Error != 0) {
3620 PRINT_ER("Failed to set remain on channel\n");
3624 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired) {
3625 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired(pstrWFIDrv->strHostIfRemainOnChan.pVoid
3626 , pstrHostIfRemainOnChan->u32ListenSessionID);
3628 P2P_LISTEN_STATE = 0;
3630 PRINT_D(GENERIC_DBG, "Not in listen state\n");
3640 * @brief ListenTimerCB
3641 * @details Callback function of remain-on-channel timer
3643 * @return Error code.
3648 static void ListenTimerCB(unsigned long arg)
3651 struct host_if_msg msg;
3652 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)arg;
3653 /*Stopping remain-on-channel timer*/
3654 del_timer(&pstrWFIDrv->hRemainOnChannel);
3656 /* prepare the Timer Callback message */
3657 memset(&msg, 0, sizeof(struct host_if_msg));
3658 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
3659 msg.drv = pstrWFIDrv;
3660 msg.body.remain_on_ch.u32ListenSessionID = pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID;
3662 /* send the message */
3663 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3665 PRINT_ER("wilc_mq_send fail\n");
3669 * @brief Handle_EditStation
3670 * @details Sending config packet to edit station
3671 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3677 static void Handle_PowerManagement(struct host_if_drv *drvHandler,
3678 struct power_mgmt_param *strPowerMgmtParam)
3683 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
3685 strWID.u16WIDid = (u16)WID_POWER_MANAGEMENT;
3687 if (strPowerMgmtParam->bIsEnabled == true)
3688 s8PowerMode = MIN_FAST_PS;
3690 s8PowerMode = NO_POWERSAVE;
3691 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
3692 strWID.ps8WidVal = &s8PowerMode;
3693 strWID.s32ValueSize = sizeof(char);
3695 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
3698 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3699 get_id_from_handler(pstrWFIDrv));
3701 PRINT_ER("Failed to send power management config packet\n");
3705 * @brief Handle_SetMulticastFilter
3706 * @details Set Multicast filter in firmware
3707 * @param[in] struct set_multicast *strHostIfSetMulti
3713 static void Handle_SetMulticastFilter(struct host_if_drv *drvHandler,
3714 struct set_multicast *strHostIfSetMulti)
3720 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
3722 strWID.u16WIDid = (u16)WID_SETUP_MULTICAST_FILTER;
3723 strWID.enuWIDtype = WID_BIN;
3724 strWID.s32ValueSize = sizeof(struct set_multicast) + ((strHostIfSetMulti->u32count) * ETH_ALEN);
3725 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
3726 if (strWID.ps8WidVal == NULL)
3729 pu8CurrByte = strWID.ps8WidVal;
3730 *pu8CurrByte++ = (strHostIfSetMulti->bIsEnabled & 0xFF);
3731 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 8) & 0xFF);
3732 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 16) & 0xFF);
3733 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 24) & 0xFF);
3735 *pu8CurrByte++ = (strHostIfSetMulti->u32count & 0xFF);
3736 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 8) & 0xFF);
3737 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 16) & 0xFF);
3738 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 24) & 0xFF);
3740 if ((strHostIfSetMulti->u32count) > 0)
3741 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->u32count) * ETH_ALEN));
3744 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3745 get_id_from_handler(drvHandler));
3747 PRINT_ER("Failed to send setup multicast config packet\n");
3750 kfree(strWID.ps8WidVal);
3756 * @brief Handle_AddBASession
3757 * @details Add block ack session
3758 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
3760 * @author Amr Abdel-Moghny
3764 static s32 Handle_AddBASession(struct host_if_drv *drvHandler,
3765 struct ba_session_info *strHostIfBASessionInfo)
3769 int AddbaTimeout = 100;
3771 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
3773 PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\nBufferSize == %d\nSessionTimeOut = %d\n",
3774 strHostIfBASessionInfo->au8Bssid[0],
3775 strHostIfBASessionInfo->au8Bssid[1],
3776 strHostIfBASessionInfo->au8Bssid[2],
3777 strHostIfBASessionInfo->u16BufferSize,
3778 strHostIfBASessionInfo->u16SessionTimeout,
3779 strHostIfBASessionInfo->u8Ted);
3781 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
3782 strWID.enuWIDtype = WID_STR;
3783 strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
3784 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
3785 ptr = strWID.ps8WidVal;
3786 /* *ptr++ = 0x14; */
3790 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
3792 *ptr++ = strHostIfBASessionInfo->u8Ted;
3796 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
3797 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
3799 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
3800 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
3802 *ptr++ = (AddbaTimeout & 0xFF);
3803 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
3804 /* Group Buffer Max Frames*/
3806 /* Group Buffer Timeout */
3809 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3810 get_id_from_handler(pstrWFIDrv));
3812 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
3815 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
3816 strWID.enuWIDtype = WID_STR;
3817 strWID.s32ValueSize = 15;
3818 ptr = strWID.ps8WidVal;
3819 /* *ptr++ = 0x14; */
3823 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
3826 *ptr++ = strHostIfBASessionInfo->u8Ted;
3830 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
3831 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
3834 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3835 get_id_from_handler(pstrWFIDrv));
3837 if (strWID.ps8WidVal != NULL)
3838 kfree(strWID.ps8WidVal);
3845 * @brief Handle_DelAllRxBASessions
3846 * @details Delete all Rx BA sessions
3847 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
3849 * @author Abdelrahman Sobhy
3853 static s32 Handle_DelAllRxBASessions(struct host_if_drv *drvHandler,
3854 struct ba_session_info *strHostIfBASessionInfo)
3859 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
3861 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
3862 strHostIfBASessionInfo->au8Bssid[0],
3863 strHostIfBASessionInfo->au8Bssid[1],
3864 strHostIfBASessionInfo->au8Bssid[2],
3865 strHostIfBASessionInfo->u8Ted);
3867 strWID.u16WIDid = (u16)WID_DEL_ALL_RX_BA;
3868 strWID.enuWIDtype = WID_STR;
3869 strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
3870 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
3871 ptr = strWID.ps8WidVal;
3875 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
3877 *ptr++ = strHostIfBASessionInfo->u8Ted;
3878 /* BA direction = recipent*/
3881 *ptr++ = 32; /* Unspecific QOS reason */
3883 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3884 get_id_from_handler(pstrWFIDrv));
3886 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
3889 if (strWID.ps8WidVal != NULL)
3890 kfree(strWID.ps8WidVal);
3899 * @brief hostIFthread
3900 * @details Main thread to handle message queue requests
3901 * @param[in] void* pvArg
3907 static int hostIFthread(void *pvArg)
3910 struct host_if_msg msg;
3911 struct host_if_drv *pstrWFIDrv;
3913 memset(&msg, 0, sizeof(struct host_if_msg));
3916 wilc_mq_recv(&gMsgQHostIF, &msg, sizeof(struct host_if_msg), &u32Ret);
3917 pstrWFIDrv = (struct host_if_drv *)msg.drv;
3918 if (msg.id == HOST_IF_MSG_EXIT) {
3919 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
3924 /*Re-Queue HIF message*/
3925 if ((!g_wilc_initialized)) {
3926 PRINT_D(GENERIC_DBG, "--WAIT--");
3927 usleep_range(200 * 1000, 200 * 1000);
3928 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3932 if (msg.id == HOST_IF_MSG_CONNECT && pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
3933 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
3934 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3935 usleep_range(2 * 1000, 2 * 1000);
3940 case HOST_IF_MSG_Q_IDLE:
3941 Handle_wait_msg_q_empty();
3944 case HOST_IF_MSG_SCAN:
3945 Handle_Scan(msg.drv, &msg.body.scan_info);
3948 case HOST_IF_MSG_CONNECT:
3949 Handle_Connect(msg.drv, &msg.body.con_info);
3952 case HOST_IF_MSG_FLUSH_CONNECT:
3953 Handle_FlushConnect(msg.drv);
3956 case HOST_IF_MSG_RCVD_NTWRK_INFO:
3957 Handle_RcvdNtwrkInfo(msg.drv, &msg.body.net_info);
3960 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
3961 Handle_RcvdGnrlAsyncInfo(msg.drv, &msg.body.async_info);
3964 case HOST_IF_MSG_KEY:
3965 Handle_Key(msg.drv, &msg.body.key_info);
3968 case HOST_IF_MSG_CFG_PARAMS:
3970 Handle_CfgParam(msg.drv, &msg.body.cfg_info);
3973 case HOST_IF_MSG_SET_CHANNEL:
3974 Handle_SetChannel(msg.drv, &msg.body.channel_info);
3977 case HOST_IF_MSG_DISCONNECT:
3978 Handle_Disconnect(msg.drv);
3981 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
3982 del_timer(&pstrWFIDrv->hScanTimer);
3983 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
3985 /*Allow chip sleep, only if both interfaces are not connected*/
3986 if (!linux_wlan_get_num_conn_ifcs())
3987 chip_sleep_manually(INFINITE_SLEEP_TIME);
3989 Handle_ScanDone(msg.drv, SCAN_EVENT_DONE);
3991 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
3992 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
3996 case HOST_IF_MSG_GET_RSSI:
3997 Handle_GetRssi(msg.drv);
4000 case HOST_IF_MSG_GET_LINKSPEED:
4001 Handle_GetLinkspeed(msg.drv);
4004 case HOST_IF_MSG_GET_STATISTICS:
4005 Handle_GetStatistics(msg.drv, (tstrStatistics *)msg.body.data);
4008 case HOST_IF_MSG_GET_CHNL:
4009 Handle_GetChnl(msg.drv);
4012 case HOST_IF_MSG_ADD_BEACON:
4013 Handle_AddBeacon(msg.drv, &msg.body.beacon_info);
4016 case HOST_IF_MSG_DEL_BEACON:
4017 Handle_DelBeacon(msg.drv);
4020 case HOST_IF_MSG_ADD_STATION:
4021 Handle_AddStation(msg.drv, &msg.body.add_sta_info);
4024 case HOST_IF_MSG_DEL_STATION:
4025 Handle_DelStation(msg.drv, &msg.body.del_sta_info);
4028 case HOST_IF_MSG_EDIT_STATION:
4029 Handle_EditStation(msg.drv, &msg.body.edit_sta_info);
4032 case HOST_IF_MSG_GET_INACTIVETIME:
4033 Handle_Get_InActiveTime(msg.drv, &msg.body.mac_info);
4036 case HOST_IF_MSG_SCAN_TIMER_FIRED:
4037 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
4039 Handle_ScanDone(msg.drv, SCAN_EVENT_ABORTED);
4042 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
4043 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
4044 Handle_ConnectTimeout(msg.drv);
4047 case HOST_IF_MSG_POWER_MGMT:
4048 Handle_PowerManagement(msg.drv, &msg.body.pwr_mgmt_info);
4051 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
4052 Handle_SetWfiDrvHandler(msg.drv,
4056 case HOST_IF_MSG_SET_OPERATION_MODE:
4057 Handle_SetOperationMode(msg.drv, &msg.body.mode);
4060 case HOST_IF_MSG_SET_IPADDRESS:
4061 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
4062 Handle_set_IPAddress(msg.drv, msg.body.ip_info.au8IPAddr, msg.body.ip_info.idx);
4065 case HOST_IF_MSG_GET_IPADDRESS:
4066 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
4067 Handle_get_IPAddress(msg.drv, msg.body.ip_info.au8IPAddr, msg.body.ip_info.idx);
4070 case HOST_IF_MSG_SET_MAC_ADDRESS:
4071 Handle_SetMacAddress(msg.drv, &msg.body.set_mac_info);
4074 case HOST_IF_MSG_GET_MAC_ADDRESS:
4075 Handle_GetMacAddress(msg.drv, &msg.body.get_mac_info);
4078 case HOST_IF_MSG_REMAIN_ON_CHAN:
4079 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
4080 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
4083 case HOST_IF_MSG_REGISTER_FRAME:
4084 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
4085 Handle_RegisterFrame(msg.drv, &msg.body.reg_frame);
4088 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
4089 Handle_ListenStateExpired(msg.drv, &msg.body.remain_on_ch);
4092 case HOST_IF_MSG_SET_MULTICAST_FILTER:
4093 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
4094 Handle_SetMulticastFilter(msg.drv, &msg.body.multicast_info);
4097 case HOST_IF_MSG_ADD_BA_SESSION:
4098 Handle_AddBASession(msg.drv, &msg.body.session_info);
4101 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
4102 Handle_DelAllRxBASessions(msg.drv, &msg.body.session_info);
4105 case HOST_IF_MSG_DEL_ALL_STA:
4106 Handle_DelAllSta(msg.drv, &msg.body.del_all_sta_info);
4110 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
4115 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
4116 up(&hSemHostIFthrdEnd);
4120 static void TimerCB_Scan(unsigned long arg)
4122 void *pvArg = (void *)arg;
4123 struct host_if_msg msg;
4125 /* prepare the Timer Callback message */
4126 memset(&msg, 0, sizeof(struct host_if_msg));
4128 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
4130 /* send the message */
4131 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4134 static void TimerCB_Connect(unsigned long arg)
4136 void *pvArg = (void *)arg;
4137 struct host_if_msg msg;
4139 /* prepare the Timer Callback message */
4140 memset(&msg, 0, sizeof(struct host_if_msg));
4142 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
4144 /* send the message */
4145 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4150 * @brief removes wpa/wpa2 keys
4151 * @details only in BSS STA mode if External Supplicant support is enabled.
4152 * removes all WPA/WPA2 station key entries from MAC hardware.
4153 * @param[in,out] handle to the wifi driver
4154 * @param[in] 6 bytes of Station Adress in the station entry table
4155 * @return Error code indicating success/failure
4158 * @date 8 March 2012
4161 /* Check implementation in core adding 9 bytes to the input! */
4162 s32 host_int_remove_key(struct host_if_drv *hWFIDrv, const u8 *pu8StaAddress)
4167 strWID.u16WIDid = (u16)WID_REMOVE_KEY;
4168 strWID.enuWIDtype = WID_STR;
4169 strWID.ps8WidVal = (s8 *)pu8StaAddress;
4170 strWID.s32ValueSize = 6;
4177 * @brief removes WEP key
4178 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4179 * remove a WEP key entry from MAC HW.
4180 * The BSS Station automatically finds the index of the entry using its
4181 * BSS ID and removes that entry from the MAC hardware.
4182 * @param[in,out] handle to the wifi driver
4183 * @param[in] 6 bytes of Station Adress in the station entry table
4184 * @return Error code indicating success/failure
4185 * @note NO need for the STA add since it is not used for processing
4187 * @date 8 March 2012
4190 int host_int_remove_wep_key(struct host_if_drv *wfi_drv, u8 index)
4193 struct host_if_msg msg;
4197 PRINT_ER("Failed to send setup multicast config packet\n");
4201 /* prepare the Remove Wep Key Message */
4202 memset(&msg, 0, sizeof(struct host_if_msg));
4204 msg.id = HOST_IF_MSG_KEY;
4205 msg.body.key_info.enuKeyType = WEP;
4206 msg.body.key_info.u8KeyAction = REMOVEKEY;
4210 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = index;
4212 /* send the message */
4213 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4215 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
4216 down(&wfi_drv->hSemTestKeyBlock);
4222 * @brief sets WEP default key
4223 * @details Sets the index of the WEP encryption key in use,
4225 * @param[in,out] handle to the wifi driver
4226 * @param[in] key index ( 0, 1, 2, 3)
4227 * @return Error code indicating success/failure
4230 * @date 8 March 2012
4233 s32 host_int_set_WEPDefaultKeyID(struct host_if_drv *hWFIDrv, u8 u8Index)
4236 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
4237 struct host_if_msg msg;
4240 if (pstrWFIDrv == NULL) {
4242 PRINT_ER("driver is null\n");
4246 /* prepare the Key Message */
4247 memset(&msg, 0, sizeof(struct host_if_msg));
4250 msg.id = HOST_IF_MSG_KEY;
4251 msg.body.key_info.enuKeyType = WEP;
4252 msg.body.key_info.u8KeyAction = DEFAULTKEY;
4257 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Index;
4259 /* send the message */
4260 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4262 PRINT_ER("Error in sending message queue : Default key index\n");
4263 down(&(pstrWFIDrv->hSemTestKeyBlock));
4269 * @brief sets WEP deafault key
4270 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4271 * sets WEP key entry into MAC hardware when it receives the
4272 * corresponding request from NDIS.
4273 * @param[in,out] handle to the wifi driver
4274 * @param[in] message containing WEP Key in the following format
4275 *|---------------------------------------|
4276 *|Key ID Value | Key Length | Key |
4277 *|-------------|------------|------------|
4278 | 1byte | 1byte | Key Length |
4279 ||---------------------------------------|
4281 * @return Error code indicating success/failure
4284 * @date 8 March 2012
4287 s32 host_int_add_wep_key_bss_sta(struct host_if_drv *hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx)
4291 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
4292 struct host_if_msg msg;
4294 if (pstrWFIDrv == NULL) {
4296 PRINT_ER("driver is null\n");
4300 /* prepare the Key Message */
4301 memset(&msg, 0, sizeof(struct host_if_msg));
4304 msg.id = HOST_IF_MSG_KEY;
4305 msg.body.key_info.enuKeyType = WEP;
4306 msg.body.key_info.u8KeyAction = ADDKEY;
4311 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = kmalloc(u8WepKeylen, GFP_KERNEL);
4313 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
4314 pu8WepKey, u8WepKeylen);
4318 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4321 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4323 /* send the message */
4324 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4326 PRINT_ER("Error in sending message queue :WEP Key\n");
4327 down(&(pstrWFIDrv->hSemTestKeyBlock));
4335 * @brief host_int_add_wep_key_bss_ap
4336 * @details valid only in BSS AP mode if External Supplicant support is enabled.
4337 * sets WEP key entry into MAC hardware when it receives the
4339 * corresponding request from NDIS.
4340 * @param[in,out] handle to the wifi driver
4343 * @return Error code indicating success/failure
4349 s32 host_int_add_wep_key_bss_ap(struct host_if_drv *hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx, u8 u8mode, enum AUTHTYPE tenuAuth_type)
4353 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
4354 struct host_if_msg msg;
4357 if (pstrWFIDrv == NULL) {
4359 PRINT_ER("driver is null\n");
4363 /* prepare the Key Message */
4364 memset(&msg, 0, sizeof(struct host_if_msg));
4367 for (i = 0; i < u8WepKeylen; i++)
4368 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
4370 msg.id = HOST_IF_MSG_KEY;
4371 msg.body.key_info.enuKeyType = WEP;
4372 msg.body.key_info.u8KeyAction = ADDKEY_AP;
4377 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = kmalloc(u8WepKeylen, GFP_KERNEL);
4380 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
4381 pu8WepKey, (u8WepKeylen));
4385 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4388 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4391 uniHostIFkeyAttr.strHostIFwepAttr.u8mode = u8mode;
4394 uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type = tenuAuth_type;
4395 /* send the message */
4396 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4399 PRINT_ER("Error in sending message queue :WEP Key\n");
4400 down(&(pstrWFIDrv->hSemTestKeyBlock));
4407 * @brief adds ptk Key
4409 * @param[in,out] handle to the wifi driver
4410 * @param[in] message containing PTK Key in the following format
4411 *|-----------------------------------------------------------------------------|
4412 *|Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
4413 *|----------------|------------|--------------|----------------|---------------|
4414 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
4415 ||-----------------------------------------------------------------------------|
4416 * @return Error code indicating success/failure
4419 * @date 8 March 2012
4422 s32 host_int_add_ptk(struct host_if_drv *hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen,
4423 const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode, u8 u8Idx)
4426 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
4427 struct host_if_msg msg;
4428 u8 u8KeyLen = u8PtkKeylen;
4431 if (pstrWFIDrv == NULL) {
4433 PRINT_ER("driver is null\n");
4436 if (pu8RxMic != NULL)
4437 u8KeyLen += RX_MIC_KEY_LEN;
4438 if (pu8TxMic != NULL)
4439 u8KeyLen += TX_MIC_KEY_LEN;
4441 /* prepare the Key Message */
4442 memset(&msg, 0, sizeof(struct host_if_msg));
4445 msg.id = HOST_IF_MSG_KEY;
4446 msg.body.key_info.enuKeyType = WPAPtk;
4447 if (mode == AP_MODE) {
4448 msg.body.key_info.u8KeyAction = ADDKEY_AP;
4450 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8Idx;
4452 if (mode == STATION_MODE)
4453 msg.body.key_info.u8KeyAction = ADDKEY;
4457 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = kmalloc(u8PtkKeylen, GFP_KERNEL);
4460 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
4461 pu8Ptk, u8PtkKeylen);
4463 if (pu8RxMic != NULL) {
4465 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
4466 pu8RxMic, RX_MIC_KEY_LEN);
4468 for (i = 0; i < RX_MIC_KEY_LEN; i++)
4469 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
4472 if (pu8TxMic != NULL) {
4474 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
4475 pu8TxMic, TX_MIC_KEY_LEN);
4477 for (i = 0; i < TX_MIC_KEY_LEN; i++)
4478 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
4483 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
4486 uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
4488 uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr = mac_addr;
4491 /* send the message */
4492 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4495 PRINT_ER("Error in sending message queue: PTK Key\n");
4497 /* ////////////// */
4498 down(&(pstrWFIDrv->hSemTestKeyBlock));
4505 * @brief adds Rx GTk Key
4507 * @param[in,out] handle to the wifi driver
4508 * @param[in] pu8RxGtk : contains temporal key | Rx Mic | Tx Mic
4509 * u8GtkKeylen :The total key length
4511 * @return Error code indicating success/failure
4514 * @date 8 March 2012
4517 s32 host_int_add_rx_gtk(struct host_if_drv *hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen,
4518 u8 u8KeyIdx, u32 u32KeyRSClen, const u8 *KeyRSC,
4519 const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode)
4522 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
4523 struct host_if_msg msg;
4524 u8 u8KeyLen = u8GtkKeylen;
4526 if (pstrWFIDrv == NULL) {
4528 PRINT_ER("driver is null\n");
4531 /* prepare the Key Message */
4532 memset(&msg, 0, sizeof(struct host_if_msg));
4535 if (pu8RxMic != NULL)
4536 u8KeyLen += RX_MIC_KEY_LEN;
4537 if (pu8TxMic != NULL)
4538 u8KeyLen += TX_MIC_KEY_LEN;
4539 if (KeyRSC != NULL) {
4541 uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq = kmalloc(u32KeyRSClen, GFP_KERNEL);
4543 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq,
4544 KeyRSC, u32KeyRSClen);
4548 msg.id = HOST_IF_MSG_KEY;
4549 msg.body.key_info.enuKeyType = WPARxGtk;
4552 if (mode == AP_MODE) {
4553 msg.body.key_info.u8KeyAction = ADDKEY_AP;
4554 msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
4556 if (mode == STATION_MODE)
4557 msg.body.key_info.u8KeyAction = ADDKEY;
4561 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = kmalloc(u8KeyLen, GFP_KERNEL);
4563 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
4564 pu8RxGtk, u8GtkKeylen);
4566 if (pu8RxMic != NULL) {
4568 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
4569 pu8RxMic, RX_MIC_KEY_LEN);
4572 if (pu8TxMic != NULL) {
4574 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
4575 pu8TxMic, TX_MIC_KEY_LEN);
4580 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8KeyIdx;
4582 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
4585 uniHostIFkeyAttr.strHostIFwpaAttr.u8seqlen = u32KeyRSClen;
4589 /* send the message */
4590 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4592 PRINT_ER("Error in sending message queue: RX GTK\n");
4593 /* ////////////// */
4594 down(&(pstrWFIDrv->hSemTestKeyBlock));
4601 * @brief host_int_set_pmkid_info
4602 * @details caches the pmkid valid only in BSS STA mode if External Supplicant
4603 * support is enabled. This Function sets the PMKID in firmware
4604 * when host drivr receives the corresponding request from NDIS.
4605 * The firmware then includes theset PMKID in the appropriate
4607 * @param[in,out] handle to the wifi driver
4608 * @param[in] message containing PMKID Info in the following format
4609 *|-----------------------------------------------------------------|
4610 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
4611 *|-----------|------------|----------|-------|----------|----------|
4612 | 1 | 6 | 16 | ... | 6 | 16 |
4613 ||-----------------------------------------------------------------|
4614 * @return Error code indicating success/failure
4617 * @date 8 March 2012
4620 s32 host_int_set_pmkid_info(struct host_if_drv *hWFIDrv, struct host_if_pmkid_attr *pu8PmkidInfoArray)
4623 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
4624 struct host_if_msg msg;
4628 if (pstrWFIDrv == NULL) {
4630 PRINT_ER("driver is null\n");
4634 /* prepare the Key Message */
4635 memset(&msg, 0, sizeof(struct host_if_msg));
4637 msg.id = HOST_IF_MSG_KEY;
4638 msg.body.key_info.enuKeyType = PMKSA;
4639 msg.body.key_info.u8KeyAction = ADDKEY;
4642 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
4644 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
4647 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
4651 /* send the message */
4652 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4654 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
4660 * @brief gets the cached the pmkid info
4661 * @details valid only in BSS STA mode if External Supplicant
4662 * support is enabled. This Function sets the PMKID in firmware
4663 * when host drivr receives the corresponding request from NDIS.
4664 * The firmware then includes theset PMKID in the appropriate
4666 * @param[in,out] handle to the wifi driver,
4667 * message containing PMKID Info in the following format
4668 *|-----------------------------------------------------------------|
4669 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
4670 *|-----------|------------|----------|-------|----------|----------|
4671 | 1 | 6 | 16 | ... | 6 | 16 |
4672 ||-----------------------------------------------------------------|
4674 * @return Error code indicating success/failure
4677 * @date 8 March 2012
4680 s32 host_int_get_pmkid_info(struct host_if_drv *hWFIDrv, u8 *pu8PmkidInfoArray,
4681 u32 u32PmkidInfoLen)
4686 strWID.u16WIDid = (u16)WID_PMKID_INFO;
4687 strWID.enuWIDtype = WID_STR;
4688 strWID.s32ValueSize = u32PmkidInfoLen;
4689 strWID.ps8WidVal = pu8PmkidInfoArray;
4695 * @brief sets the pass phrase
4696 * @details AP/STA mode. This function gives the pass phrase used to
4697 * generate the Pre-Shared Key when WPA/WPA2 is enabled
4698 * The length of the field can vary from 8 to 64 bytes,
4699 * the lower layer should get the
4700 * @param[in,out] handle to the wifi driver,
4701 * @param[in] String containing PSK
4702 * @return Error code indicating success/failure
4705 * @date 8 March 2012
4708 s32 host_int_set_RSNAConfigPSKPassPhrase(struct host_if_drv *hWFIDrv, u8 *pu8PassPhrase,
4714 /*validating psk length*/
4715 if ((u8Psklength > 7) && (u8Psklength < 65)) {
4716 strWID.u16WIDid = (u16)WID_11I_PSK;
4717 strWID.enuWIDtype = WID_STR;
4718 strWID.ps8WidVal = pu8PassPhrase;
4719 strWID.s32ValueSize = u8Psklength;
4725 * @brief host_int_get_MacAddress
4726 * @details gets mac address
4727 * @param[in,out] handle to the wifi driver,
4729 * @return Error code indicating success/failure
4732 * @date 19 April 2012
4735 s32 host_int_get_MacAddress(struct host_if_drv *hWFIDrv, u8 *pu8MacAddress)
4738 struct host_if_msg msg;
4741 /* prepare the Message */
4742 memset(&msg, 0, sizeof(struct host_if_msg));
4744 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
4745 msg.body.get_mac_info.u8MacAddress = pu8MacAddress;
4747 /* send the message */
4748 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4750 PRINT_ER("Failed to send get mac address\n");
4754 down(&hWaitResponse);
4759 * @brief host_int_set_MacAddress
4760 * @details sets mac address
4761 * @param[in,out] handle to the wifi driver,
4763 * @return Error code indicating success/failure
4766 * @date 16 July 2012
4769 s32 host_int_set_MacAddress(struct host_if_drv *hWFIDrv, u8 *pu8MacAddress)
4772 struct host_if_msg msg;
4774 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
4776 /* prepare setting mac address message */
4777 memset(&msg, 0, sizeof(struct host_if_msg));
4778 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
4779 memcpy(msg.body.set_mac_info.u8MacAddress, pu8MacAddress, ETH_ALEN);
4782 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4784 PRINT_ER("Failed to send message queue: Set mac address\n");
4791 * @brief host_int_get_RSNAConfigPSKPassPhrase
4792 * @details gets the pass phrase:AP/STA mode. This function gets the pass phrase used to
4793 * generate the Pre-Shared Key when WPA/WPA2 is enabled
4794 * The length of the field can vary from 8 to 64 bytes,
4795 * the lower layer should get the
4796 * @param[in,out] handle to the wifi driver,
4797 * String containing PSK
4798 * @return Error code indicating success/failure
4801 * @date 8 March 2012
4804 s32 host_int_get_RSNAConfigPSKPassPhrase(struct host_if_drv *hWFIDrv,
4805 u8 *pu8PassPhrase, u8 u8Psklength)
4810 strWID.u16WIDid = (u16)WID_11I_PSK;
4811 strWID.enuWIDtype = WID_STR;
4812 strWID.s32ValueSize = u8Psklength;
4813 strWID.ps8WidVal = pu8PassPhrase;
4819 * @brief sets a start scan request
4821 * @param[in,out] handle to the wifi driver,
4822 * @param[in] Scan Source one of the following values
4825 * OBSS_PERIODIC_SCAN BIT1
4826 * OBSS_ONETIME_SCAN BIT2
4827 * @return Error code indicating success/failure
4830 * @date 8 March 2012
4833 s32 host_int_set_start_scan_req(struct host_if_drv *hWFIDrv, u8 scanSource)
4838 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
4839 strWID.enuWIDtype = WID_CHAR;
4840 strWID.ps8WidVal = (s8 *)&scanSource;
4841 strWID.s32ValueSize = sizeof(char);
4847 * @brief host_int_get_start_scan_req
4848 * @details gets a start scan request
4849 * @param[in,out] handle to the wifi driver,
4850 * @param[in] Scan Source one of the following values
4853 * OBSS_PERIODIC_SCAN BIT1
4854 * OBSS_ONETIME_SCAN BIT2
4855 * @return Error code indicating success/failure
4858 * @date 8 March 2012
4862 s32 host_int_get_start_scan_req(struct host_if_drv *hWFIDrv, u8 *pu8ScanSource)
4867 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
4868 strWID.enuWIDtype = WID_CHAR;
4869 strWID.ps8WidVal = (s8 *)pu8ScanSource;
4870 strWID.s32ValueSize = sizeof(char);
4876 * @brief host_int_set_join_req
4877 * @details sets a join request
4878 * @param[in,out] handle to the wifi driver,
4879 * @param[in] Index of the bss descriptor
4880 * @return Error code indicating success/failure
4883 * @date 8 March 2012
4886 s32 host_int_set_join_req(struct host_if_drv *hWFIDrv, u8 *pu8bssid,
4887 const u8 *pu8ssid, size_t ssidLen,
4888 const u8 *pu8IEs, size_t IEsLen,
4889 wilc_connect_result pfConnectResult, void *pvUserArg,
4890 u8 u8security, enum AUTHTYPE tenuAuth_type,
4895 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
4896 struct host_if_msg msg;
4897 tenuScanConnTimer enuScanConnTimer;
4899 if (pstrWFIDrv == NULL || pfConnectResult == NULL) {
4901 PRINT_ER("Driver is null\n");
4905 if (hWFIDrv == NULL) {
4906 PRINT_ER("Driver is null\n");
4910 if (pJoinParams == NULL) {
4911 PRINT_ER("Unable to Join - JoinParams is NULL\n");
4915 /* prepare the Connect Message */
4916 memset(&msg, 0, sizeof(struct host_if_msg));
4918 msg.id = HOST_IF_MSG_CONNECT;
4920 msg.body.con_info.u8security = u8security;
4921 msg.body.con_info.tenuAuth_type = tenuAuth_type;
4922 msg.body.con_info.u8channel = u8channel;
4923 msg.body.con_info.pfConnectResult = pfConnectResult;
4924 msg.body.con_info.pvUserArg = pvUserArg;
4925 msg.body.con_info.pJoinParams = pJoinParams;
4928 if (pu8bssid != NULL) {
4929 msg.body.con_info.pu8bssid = kmalloc(6, GFP_KERNEL); /* will be deallocated by the receiving thread */
4930 memcpy(msg.body.con_info.pu8bssid,
4934 if (pu8ssid != NULL) {
4935 msg.body.con_info.ssidLen = ssidLen;
4936 msg.body.con_info.pu8ssid = kmalloc(ssidLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
4937 memcpy(msg.body.con_info.pu8ssid,
4942 if (pu8IEs != NULL) {
4943 msg.body.con_info.IEsLen = IEsLen;
4944 msg.body.con_info.pu8IEs = kmalloc(IEsLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
4945 memcpy(msg.body.con_info.pu8IEs,
4948 if (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTING)
4949 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTING;
4951 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", pstrWFIDrv->enuHostIFstate);
4953 /* send the message */
4954 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4956 PRINT_ER("Failed to send message queue: Set join request\n");
4960 enuScanConnTimer = CONNECT_TIMER;
4961 pstrWFIDrv->hConnectTimer.data = (unsigned long)hWFIDrv;
4962 mod_timer(&pstrWFIDrv->hConnectTimer,
4963 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
4969 * @brief Flush a join request parameters to FW, but actual connection
4970 * @details The function is called in situation where WILC is connected to AP and
4971 * required to switch to hybrid FW for P2P connection
4972 * @param[in] handle to the wifi driver,
4973 * @return Error code indicating success/failure
4975 * @author Amr Abdel-Moghny
4980 s32 host_int_flush_join_req(struct host_if_drv *hWFIDrv)
4983 struct host_if_msg msg;
4985 if (!gu8FlushedJoinReq) {
4991 if (hWFIDrv == NULL) {
4993 PRINT_ER("Driver is null\n");
4997 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
5000 /* send the message */
5001 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5003 PRINT_ER("Failed to send message queue: Flush join request\n");
5011 * @brief host_int_disconnect
5012 * @details disconnects from the currently associated network
5013 * @param[in,out] handle to the wifi driver,
5014 * @param[in] Reason Code of the Disconnection
5015 * @return Error code indicating success/failure
5018 * @date 8 March 2012
5021 s32 host_int_disconnect(struct host_if_drv *hWFIDrv, u16 u16ReasonCode)
5024 struct host_if_msg msg;
5025 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
5027 if (pstrWFIDrv == NULL) {
5028 PRINT_ER("Driver is null\n");
5032 /* prepare the Disconnect Message */
5033 memset(&msg, 0, sizeof(struct host_if_msg));
5035 msg.id = HOST_IF_MSG_DISCONNECT;
5038 /* send the message */
5039 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5041 PRINT_ER("Failed to send message queue: disconnect\n");
5042 /* ////////////// */
5043 down(&(pstrWFIDrv->hSemTestDisconnectBlock));
5050 * @brief host_int_disconnect_station
5051 * @details disconnects a sta
5052 * @param[in,out] handle to the wifi driver,
5053 * @param[in] Association Id of the station to be disconnected
5054 * @return Error code indicating success/failure
5057 * @date 8 March 2012
5060 s32 host_int_disconnect_station(struct host_if_drv *hWFIDrv, u8 assoc_id)
5065 strWID.u16WIDid = (u16)WID_DISCONNECT;
5066 strWID.enuWIDtype = WID_CHAR;
5067 strWID.ps8WidVal = (s8 *)&assoc_id;
5068 strWID.s32ValueSize = sizeof(char);
5074 * @brief host_int_get_assoc_req_info
5075 * @details gets a Association request info
5076 * @param[in,out] handle to the wifi driver,
5077 * Message containg assoc. req info in the following format
5078 * ------------------------------------------------------------------------
5079 | Management Frame Format |
5080 ||-------------------------------------------------------------------|
5081 ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS |
5082 ||-------------|--------|--|--|-----|----------------|----------|----|
5083 | 2 |2 |6 |6 |6 | 2 |0 - 2312 | 4 |
5084 ||-------------------------------------------------------------------|
5086 | Association Request Frame - Frame Body |
5087 ||-------------------------------------------------------------------|
5088 | Capability Information | Listen Interval | SSID | Supported Rates |
5089 ||------------------------|-----------------|------|-----------------|
5090 | 2 | 2 | 2-34 | 3-10 |
5091 | ---------------------------------------------------------------------
5092 * @return Error code indicating success/failure
5095 * @date 8 March 2012
5099 s32 host_int_get_assoc_req_info(struct host_if_drv *hWFIDrv, u8 *pu8AssocReqInfo,
5100 u32 u32AssocReqInfoLen)
5105 strWID.u16WIDid = (u16)WID_ASSOC_REQ_INFO;
5106 strWID.enuWIDtype = WID_STR;
5107 strWID.ps8WidVal = pu8AssocReqInfo;
5108 strWID.s32ValueSize = u32AssocReqInfoLen;
5115 * @brief gets a Association Response info
5117 * @param[in,out] handle to the wifi driver,
5118 * Message containg assoc. resp info
5119 * @return Error code indicating success/failure
5122 * @date 8 March 2012
5125 s32 host_int_get_assoc_res_info(struct host_if_drv *hWFIDrv, u8 *pu8AssocRespInfo,
5126 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
5130 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
5132 if (pstrWFIDrv == NULL) {
5133 PRINT_ER("Driver is null\n");
5137 strWID.u16WIDid = (u16)WID_ASSOC_RES_INFO;
5138 strWID.enuWIDtype = WID_STR;
5139 strWID.ps8WidVal = pu8AssocRespInfo;
5140 strWID.s32ValueSize = u32MaxAssocRespInfoLen;
5143 /* Sending Configuration packet */
5144 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
5145 get_id_from_handler(pstrWFIDrv));
5147 *pu32RcvdAssocRespInfoLen = 0;
5148 PRINT_ER("Failed to send association response config packet\n");
5151 *pu32RcvdAssocRespInfoLen = strWID.s32ValueSize;
5158 * @brief gets a Association Response info
5159 * @details Valid only in STA mode. This function gives the RSSI
5160 * values observed in all the channels at the time of scanning.
5161 * The length of the field is 1 greater that the total number of
5162 * channels supported. Byte 0 contains the number of channels while
5163 * each of Byte N contains the observed RSSI value for the channel index N.
5164 * @param[in,out] handle to the wifi driver,
5165 * array of scanned channels' RSSI
5166 * @return Error code indicating success/failure
5169 * @date 8 March 2012
5172 s32 host_int_get_rx_power_level(struct host_if_drv *hWFIDrv, u8 *pu8RxPowerLevel,
5173 u32 u32RxPowerLevelLen)
5178 strWID.u16WIDid = (u16)WID_RX_POWER_LEVEL;
5179 strWID.enuWIDtype = WID_STR;
5180 strWID.ps8WidVal = pu8RxPowerLevel;
5181 strWID.s32ValueSize = u32RxPowerLevelLen;
5188 * @brief sets a channel
5190 * @param[in,out] handle to the wifi driver,
5191 * @param[in] Index of the channel to be set
5192 *|-------------------------------------------------------------------|
5193 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5195 ||-------------------------------------------------------------------|
5196 * @return Error code indicating success/failure
5199 * @date 8 March 2012
5202 int host_int_set_mac_chnl_num(struct host_if_drv *wfi_drv, u8 channel)
5205 struct host_if_msg msg;
5208 PRINT_ER("driver is null\n");
5212 /* prepare the set channel message */
5213 memset(&msg, 0, sizeof(struct host_if_msg));
5214 msg.id = HOST_IF_MSG_SET_CHANNEL;
5215 msg.body.channel_info.u8SetChan = channel;
5218 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5220 PRINT_ER("wilc mq send fail\n");
5227 int host_int_wait_msg_queue_idle(void)
5231 struct host_if_msg msg;
5233 /* prepare the set driver handler message */
5235 memset(&msg, 0, sizeof(struct host_if_msg));
5236 msg.id = HOST_IF_MSG_Q_IDLE;
5237 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5239 PRINT_ER("wilc mq send fail\n");
5243 /* wait untill MSG Q is empty */
5244 down(&hWaitResponse);
5249 int host_int_set_wfi_drv_handler(struct host_if_drv *address)
5253 struct host_if_msg msg;
5255 /* prepare the set driver handler message */
5257 memset(&msg, 0, sizeof(struct host_if_msg));
5258 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
5259 msg.body.drv.u32Address = get_id_from_handler(address);
5262 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5264 PRINT_ER("wilc mq send fail\n");
5271 int host_int_set_operation_mode(struct host_if_drv *wfi_drv, u32 mode)
5275 struct host_if_msg msg;
5277 /* prepare the set driver handler message */
5279 memset(&msg, 0, sizeof(struct host_if_msg));
5280 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
5281 msg.body.mode.u32Mode = mode;
5284 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5286 PRINT_ER("wilc mq send fail\n");
5294 * @brief gets the current channel index
5296 * @param[in,out] handle to the wifi driver,
5297 * current channel index
5298 *|-----------------------------------------------------------------------|
5299 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5301 ||-----------------------------------------------------------------------|
5302 * @return Error code indicating success/failure
5305 * @date 8 March 2012
5308 s32 host_int_get_host_chnl_num(struct host_if_drv *hWFIDrv, u8 *pu8ChNo)
5311 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
5312 struct host_if_msg msg;
5314 if (pstrWFIDrv == NULL) {
5315 PRINT_ER("driver is null\n");
5319 /* prepare the Get Channel Message */
5320 memset(&msg, 0, sizeof(struct host_if_msg));
5322 msg.id = HOST_IF_MSG_GET_CHNL;
5325 /* send the message */
5326 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5328 PRINT_ER("wilc mq send fail\n");
5329 down(&(pstrWFIDrv->hSemGetCHNL));
5340 * @brief host_int_get_inactive_time
5342 * @param[in,out] handle to the wifi driver,
5343 * current sta macaddress, inactive_time
5350 s32 host_int_get_inactive_time(struct host_if_drv *hWFIDrv, const u8 *mac, u32 *pu32InactiveTime)
5353 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
5354 struct host_if_msg msg;
5356 if (pstrWFIDrv == NULL) {
5357 PRINT_ER("driver is null\n");
5361 memset(&msg, 0, sizeof(struct host_if_msg));
5364 memcpy(msg.body.mac_info.mac,
5367 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
5370 /* send the message */
5371 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5373 PRINT_ER("Failed to send get host channel param's message queue ");
5375 down(&(pstrWFIDrv->hSemInactiveTime));
5377 *pu32InactiveTime = gu32InactiveTime;
5383 * @brief host_int_test_get_int_wid
5384 * @details Test function for getting wids
5385 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32* pu32TestMemAddr
5386 * @return Error code indicating success/failure
5389 * @date 8 March 2012
5392 s32 host_int_test_get_int_wid(struct host_if_drv *hWFIDrv, u32 *pu32TestMemAddr)
5397 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
5400 if (pstrWFIDrv == NULL) {
5401 PRINT_ER("driver is null\n");
5405 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
5406 strWID.enuWIDtype = WID_INT;
5407 strWID.ps8WidVal = (s8 *)pu32TestMemAddr;
5408 strWID.s32ValueSize = sizeof(u32);
5410 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
5411 get_id_from_handler(pstrWFIDrv));
5412 /*get the value by searching the local copy*/
5414 PRINT_ER("Failed to get wid value\n");
5417 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
5426 * @brief host_int_get_rssi
5427 * @details gets the currently maintained RSSI value for the station.
5428 * The received signal strength value in dB.
5429 * The range of valid values is -128 to 0.
5430 * @param[in,out] handle to the wifi driver,
5432 * @return Error code indicating success/failure
5435 * @date 8 March 2012
5438 s32 host_int_get_rssi(struct host_if_drv *hWFIDrv, s8 *ps8Rssi)
5441 struct host_if_msg msg;
5442 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
5445 /* prepare the Get RSSI Message */
5446 memset(&msg, 0, sizeof(struct host_if_msg));
5448 msg.id = HOST_IF_MSG_GET_RSSI;
5451 /* send the message */
5452 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5454 PRINT_ER("Failed to send get host channel param's message queue ");
5458 down(&(pstrWFIDrv->hSemGetRSSI));
5461 if (ps8Rssi == NULL) {
5462 PRINT_ER("RSS pointer value is null");
5473 s32 host_int_get_link_speed(struct host_if_drv *hWFIDrv, s8 *ps8lnkspd)
5475 struct host_if_msg msg;
5478 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
5482 /* prepare the Get LINKSPEED Message */
5483 memset(&msg, 0, sizeof(struct host_if_msg));
5485 msg.id = HOST_IF_MSG_GET_LINKSPEED;
5488 /* send the message */
5489 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5491 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
5495 down(&(pstrWFIDrv->hSemGetLINKSPEED));
5498 if (ps8lnkspd == NULL) {
5499 PRINT_ER("LINKSPEED pointer value is null");
5504 *ps8lnkspd = gs8lnkspd;
5510 s32 host_int_get_statistics(struct host_if_drv *hWFIDrv, tstrStatistics *pstrStatistics)
5513 struct host_if_msg msg;
5516 /* prepare the Get RSSI Message */
5517 memset(&msg, 0, sizeof(struct host_if_msg));
5519 msg.id = HOST_IF_MSG_GET_STATISTICS;
5520 msg.body.data = (char *)pstrStatistics;
5522 /* send the message */
5523 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5525 PRINT_ER("Failed to send get host channel param's message queue ");
5529 down(&hWaitResponse);
5535 * @brief host_int_scan
5536 * @details scans a set of channels
5537 * @param[in,out] handle to the wifi driver,
5538 * @param[in] Scan source
5539 * Scan Type PASSIVE_SCAN = 0,
5542 * Channels Array length
5543 * Scan Callback function
5544 * @return Error code indicating success/failure
5547 * @date 8 March 2012
5550 s32 host_int_scan(struct host_if_drv *hWFIDrv, u8 u8ScanSource,
5551 u8 u8ScanType, u8 *pu8ChnlFreqList,
5552 u8 u8ChnlListLen, const u8 *pu8IEs,
5553 size_t IEsLen, wilc_scan_result ScanResult,
5555 struct hidden_network *pstrHiddenNetwork)
5558 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
5559 struct host_if_msg msg;
5560 tenuScanConnTimer enuScanConnTimer;
5562 if (pstrWFIDrv == NULL || ScanResult == NULL) {
5563 PRINT_ER("pstrWFIDrv or ScanResult = NULL\n");
5567 /* prepare the Scan Message */
5568 memset(&msg, 0, sizeof(struct host_if_msg));
5570 msg.id = HOST_IF_MSG_SCAN;
5572 if (pstrHiddenNetwork != NULL) {
5573 msg.body.scan_info.strHiddenNetwork.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
5574 msg.body.scan_info.strHiddenNetwork.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
5577 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
5580 msg.body.scan_info.u8ScanSource = u8ScanSource;
5581 msg.body.scan_info.u8ScanType = u8ScanType;
5582 msg.body.scan_info.pfScanResult = ScanResult;
5583 msg.body.scan_info.pvUserArg = pvUserArg;
5585 msg.body.scan_info.u8ChnlListLen = u8ChnlListLen;
5586 msg.body.scan_info.pu8ChnlFreqList = kmalloc(u8ChnlListLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5587 memcpy(msg.body.scan_info.pu8ChnlFreqList,
5588 pu8ChnlFreqList, u8ChnlListLen);
5590 msg.body.scan_info.IEsLen = IEsLen;
5591 msg.body.scan_info.pu8IEs = kmalloc(IEsLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5592 memcpy(msg.body.scan_info.pu8IEs,
5595 /* send the message */
5596 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5598 PRINT_ER("Error in sending message queue\n");
5602 enuScanConnTimer = SCAN_TIMER;
5603 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
5604 pstrWFIDrv->hScanTimer.data = (unsigned long)hWFIDrv;
5605 mod_timer(&pstrWFIDrv->hScanTimer,
5606 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
5612 * @brief hif_set_cfg
5613 * @details sets configuration wids values
5614 * @param[in,out] handle to the wifi driver,
5615 * @param[in] WID, WID value
5616 * @return Error code indicating success/failure
5619 * @date 8 March 2012
5622 s32 hif_set_cfg(struct host_if_drv *hWFIDrv, struct cfg_param_val *pstrCfgParamVal)
5626 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
5628 struct host_if_msg msg;
5631 if (pstrWFIDrv == NULL) {
5632 PRINT_ER("pstrWFIDrv NULL\n");
5635 /* prepare the WiphyParams Message */
5636 memset(&msg, 0, sizeof(struct host_if_msg));
5637 msg.id = HOST_IF_MSG_CFG_PARAMS;
5638 msg.body.cfg_info.pstrCfgParamVal = *pstrCfgParamVal;
5641 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5649 * @brief hif_get_cfg
5650 * @details gets configuration wids values
5651 * @param[in,out] handle to the wifi driver,
5654 * @return Error code indicating success/failure
5658 * @date 8 March 2012
5661 s32 hif_get_cfg(struct host_if_drv *hWFIDrv, u16 u16WID, u16 *pu16WID_Value)
5664 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
5666 down(&(pstrWFIDrv->gtOsCfgValuesSem));
5668 if (pstrWFIDrv == NULL) {
5669 PRINT_ER("pstrWFIDrv NULL\n");
5672 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
5676 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.bss_type;
5680 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.auth_type;
5683 case WID_AUTH_TIMEOUT:
5684 *pu16WID_Value = pstrWFIDrv->strCfgValues.auth_timeout;
5687 case WID_POWER_MANAGEMENT:
5688 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.power_mgmt_mode;
5691 case WID_SHORT_RETRY_LIMIT:
5692 *pu16WID_Value = pstrWFIDrv->strCfgValues.short_retry_limit;
5695 case WID_LONG_RETRY_LIMIT:
5696 *pu16WID_Value = pstrWFIDrv->strCfgValues.long_retry_limit;
5699 case WID_FRAG_THRESHOLD:
5700 *pu16WID_Value = pstrWFIDrv->strCfgValues.frag_threshold;
5703 case WID_RTS_THRESHOLD:
5704 *pu16WID_Value = pstrWFIDrv->strCfgValues.rts_threshold;
5708 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.preamble_type;
5711 case WID_SHORT_SLOT_ALLOWED:
5712 *pu16WID_Value = (u16) pstrWFIDrv->strCfgValues.short_slot_allowed;
5715 case WID_11N_TXOP_PROT_DISABLE:
5716 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.txop_prot_disabled;
5719 case WID_BEACON_INTERVAL:
5720 *pu16WID_Value = pstrWFIDrv->strCfgValues.beacon_interval;
5723 case WID_DTIM_PERIOD:
5724 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.dtim_period;
5727 case WID_SITE_SURVEY:
5728 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.site_survey_enabled;
5731 case WID_SITE_SURVEY_SCAN_TIME:
5732 *pu16WID_Value = pstrWFIDrv->strCfgValues.site_survey_scan_time;
5735 case WID_ACTIVE_SCAN_TIME:
5736 *pu16WID_Value = pstrWFIDrv->strCfgValues.active_scan_time;
5739 case WID_PASSIVE_SCAN_TIME:
5740 *pu16WID_Value = pstrWFIDrv->strCfgValues.passive_scan_time;
5743 case WID_CURRENT_TX_RATE:
5744 *pu16WID_Value = pstrWFIDrv->strCfgValues.curr_tx_rate;
5751 up(&(pstrWFIDrv->gtOsCfgValuesSem));
5757 /*****************************************************************************/
5758 /* Notification Functions */
5759 /*****************************************************************************/
5761 * @brief notifies host with join and leave requests
5762 * @details This function prepares an Information frame having the
5763 * information about a joining/leaving station.
5764 * @param[in,out] handle to the wifi driver,
5765 * @param[in] 6 byte Sta Adress
5766 * Join or leave flag:
5769 * @return Error code indicating success/failure
5772 * @date 8 March 2012
5775 void host_int_send_join_leave_info_to_host
5776 (u16 assocId, u8 *stationAddr, bool joining)
5780 * @brief notifies host with stations found in scan
5781 * @details sends the beacon/probe response from scan
5782 * @param[in,out] handle to the wifi driver,
5783 * @param[in] Sta Address,
5785 * Rssi of the Station found
5786 * @return Error code indicating success/failure
5789 * @date 8 March 2012
5793 static void GetPeriodicRSSI(unsigned long arg)
5795 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)arg;
5797 if (pstrWFIDrv == NULL) {
5798 PRINT_ER("Driver handler is NULL\n");
5802 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
5804 struct host_if_msg msg;
5806 /* prepare the Get RSSI Message */
5807 memset(&msg, 0, sizeof(struct host_if_msg));
5809 msg.id = HOST_IF_MSG_GET_RSSI;
5810 msg.drv = pstrWFIDrv;
5812 /* send the message */
5813 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5815 PRINT_ER("Failed to send get host channel param's message queue ");
5819 g_hPeriodicRSSI.data = (unsigned long)pstrWFIDrv;
5820 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
5824 void host_int_send_network_info_to_host
5825 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
5829 * @brief host_int_init
5830 * @details host interface initialization function
5831 * @param[in,out] handle to the wifi driver,
5834 * @date 8 March 2012
5837 static u32 clients_count;
5839 s32 host_int_init(struct host_if_drv **phWFIDrv)
5842 struct host_if_drv *pstrWFIDrv;
5845 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
5847 gbScanWhileConnected = false;
5849 sema_init(&hWaitResponse, 0);
5851 /*Allocate host interface private structure*/
5852 pstrWFIDrv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
5857 *phWFIDrv = pstrWFIDrv;
5858 err = add_handler_in_list(pstrWFIDrv);
5864 g_obtainingIP = false;
5866 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", pstrWFIDrv);
5867 if (clients_count == 0) {
5868 sema_init(&hSemHostIFthrdEnd, 0);
5869 sema_init(&hSemDeinitDrvHandle, 0);
5870 sema_init(&hSemHostIntDeinit, 1);
5873 sema_init(&pstrWFIDrv->hSemTestKeyBlock, 0);
5874 sema_init(&pstrWFIDrv->hSemTestDisconnectBlock, 0);
5875 sema_init(&pstrWFIDrv->hSemGetRSSI, 0);
5876 sema_init(&pstrWFIDrv->hSemGetLINKSPEED, 0);
5877 sema_init(&pstrWFIDrv->hSemGetCHNL, 0);
5878 sema_init(&pstrWFIDrv->hSemInactiveTime, 0);
5880 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
5882 if (clients_count == 0) {
5883 result = wilc_mq_create(&gMsgQHostIF);
5886 PRINT_ER("Failed to creat MQ\n");
5889 HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread");
5890 if (IS_ERR(HostIFthreadHandler)) {
5891 PRINT_ER("Failed to creat Thread\n");
5895 setup_timer(&g_hPeriodicRSSI, GetPeriodicRSSI,
5896 (unsigned long)pstrWFIDrv);
5897 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
5900 setup_timer(&pstrWFIDrv->hScanTimer, TimerCB_Scan, 0);
5902 setup_timer(&pstrWFIDrv->hConnectTimer, TimerCB_Connect, 0);
5904 /*Remain on channel timer*/
5905 setup_timer(&pstrWFIDrv->hRemainOnChannel, ListenTimerCB, 0);
5907 sema_init(&(pstrWFIDrv->gtOsCfgValuesSem), 1);
5908 down(&pstrWFIDrv->gtOsCfgValuesSem);
5910 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
5912 /*Initialize CFG WIDS Defualt Values*/
5914 pstrWFIDrv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
5915 pstrWFIDrv->strCfgValues.scan_source = DEFAULT_SCAN;
5916 pstrWFIDrv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
5917 pstrWFIDrv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
5918 pstrWFIDrv->strCfgValues.curr_tx_rate = AUTORATE;
5920 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
5922 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",
5924 pstrWFIDrv->strCfgValues.site_survey_enabled, pstrWFIDrv->strCfgValues.scan_source,
5925 pstrWFIDrv->strCfgValues.active_scan_time, pstrWFIDrv->strCfgValues.passive_scan_time,
5926 pstrWFIDrv->strCfgValues.curr_tx_rate);
5928 up(&pstrWFIDrv->gtOsCfgValuesSem);
5930 clients_count++; /* increase number of created entities */
5935 up(&pstrWFIDrv->gtOsCfgValuesSem);
5936 del_timer_sync(&pstrWFIDrv->hConnectTimer);
5937 del_timer_sync(&pstrWFIDrv->hScanTimer);
5938 kthread_stop(HostIFthreadHandler);
5940 wilc_mq_destroy(&gMsgQHostIF);
5945 * @brief host_int_deinit
5946 * @details host interface initialization function
5947 * @param[in,out] handle to the wifi driver,
5950 * @date 8 March 2012
5954 s32 host_int_deinit(struct host_if_drv *hWFIDrv)
5957 struct host_if_msg msg;
5960 /*obtain driver handle*/
5961 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
5963 if (pstrWFIDrv == NULL) {
5964 PRINT_ER("pstrWFIDrv = NULL\n");
5968 down(&hSemHostIntDeinit);
5970 terminated_handle = pstrWFIDrv;
5971 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
5973 /*Destroy all timers before acquiring hSemDeinitDrvHandle*/
5974 /*to guarantee handling all messages befor proceeding*/
5975 if (del_timer_sync(&pstrWFIDrv->hScanTimer)) {
5976 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
5977 /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */
5980 if (del_timer_sync(&pstrWFIDrv->hConnectTimer)) {
5981 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
5982 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
5986 if (del_timer_sync(&g_hPeriodicRSSI)) {
5987 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
5988 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
5991 /*Destroy Remain-onchannel Timer*/
5992 del_timer_sync(&pstrWFIDrv->hRemainOnChannel);
5994 host_int_set_wfi_drv_handler(NULL);
5995 down(&hSemDeinitDrvHandle);
5998 /*Calling the CFG80211 scan done function with the abort flag set to true*/
5999 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
6000 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
6001 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
6003 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
6006 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
6008 gbScanWhileConnected = false;
6010 memset(&msg, 0, sizeof(struct host_if_msg));
6012 if (clients_count == 1) {
6013 if (del_timer_sync(&g_hPeriodicRSSI)) {
6014 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
6015 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6017 msg.id = HOST_IF_MSG_EXIT;
6021 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6023 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
6025 down(&hSemHostIFthrdEnd);
6027 wilc_mq_destroy(&gMsgQHostIF);
6030 down(&(pstrWFIDrv->gtOsCfgValuesSem));
6032 /*Setting the gloabl driver handler with NULL*/
6033 /* gWFiDrvHandle = NULL; */
6034 ret = remove_handler_in_list(pstrWFIDrv);
6038 if (pstrWFIDrv != NULL) {
6040 /* pstrWFIDrv=NULL; */
6044 clients_count--; /* Decrease number of created entities */
6045 terminated_handle = NULL;
6046 up(&hSemHostIntDeinit);
6052 * @brief NetworkInfoReceived
6053 * @details function to to be called when network info packet is received
6054 * @param[in] pu8Buffer the received packet
6055 * @param[in] u32Length length of the received packet
6062 void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
6065 struct host_if_msg msg;
6067 struct host_if_drv *pstrWFIDrv = NULL;
6069 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6070 pstrWFIDrv = get_handler_from_id(id);
6075 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
6076 PRINT_ER("NetworkInfo received but driver not init[%p]\n", pstrWFIDrv);
6080 /* prepare the Asynchronous Network Info message */
6081 memset(&msg, 0, sizeof(struct host_if_msg));
6083 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
6084 msg.drv = pstrWFIDrv;
6086 msg.body.net_info.u32Length = u32Length;
6087 msg.body.net_info.pu8Buffer = kmalloc(u32Length, GFP_KERNEL); /* will be deallocated by the receiving thread */
6088 memcpy(msg.body.net_info.pu8Buffer,
6089 pu8Buffer, u32Length);
6091 /* send the message */
6092 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6094 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
6098 * @brief GnrlAsyncInfoReceived
6099 * @details function to be called when general Asynchronous info packet is received
6100 * @param[in] pu8Buffer the received packet
6101 * @param[in] u32Length length of the received packet
6108 void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
6111 struct host_if_msg msg;
6113 struct host_if_drv *pstrWFIDrv = NULL;
6115 down(&hSemHostIntDeinit);
6117 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6118 pstrWFIDrv = get_handler_from_id(id);
6119 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
6122 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
6123 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
6124 up(&hSemHostIntDeinit);
6128 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL) {
6129 /* received mac status is not needed when there is no current Connect Request */
6130 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
6131 up(&hSemHostIntDeinit);
6135 /* prepare the General Asynchronous Info message */
6136 memset(&msg, 0, sizeof(struct host_if_msg));
6139 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
6140 msg.drv = pstrWFIDrv;
6143 msg.body.async_info.u32Length = u32Length;
6144 msg.body.async_info.pu8Buffer = kmalloc(u32Length, GFP_KERNEL); /* will be deallocated by the receiving thread */
6145 memcpy(msg.body.async_info.pu8Buffer,
6146 pu8Buffer, u32Length);
6148 /* send the message */
6149 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6151 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
6153 up(&hSemHostIntDeinit);
6157 * @brief host_int_ScanCompleteReceived
6158 * @details Setting scan complete received notifcation in message queue
6159 * @param[in] u8* pu8Buffer, u32 u32Length
6160 * @return Error code.
6165 void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
6168 struct host_if_msg msg;
6170 struct host_if_drv *pstrWFIDrv = NULL;
6172 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6173 pstrWFIDrv = get_handler_from_id(id);
6176 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", pstrWFIDrv);
6178 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle)
6181 /*if there is an ongoing scan request*/
6182 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
6183 /* prepare theScan Done message */
6184 memset(&msg, 0, sizeof(struct host_if_msg));
6186 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
6187 msg.drv = pstrWFIDrv;
6190 /* will be deallocated by the receiving thread */
6191 /*no need to send message body*/
6193 /*msg.body.strScanComplete.u32Length = u32Length;
6194 * msg.body.strScanComplete.pu8Buffer = (u8*)WILC_MALLOC(u32Length);
6195 * memcpy(msg.body.strScanComplete.pu8Buffer,
6196 * pu8Buffer, u32Length); */
6198 /* send the message */
6199 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6201 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
6210 * @brief host_int_remain_on_channel
6212 * @param[in] Handle to wifi driver
6213 * Duration to remain on channel
6214 * Channel to remain on
6215 * Pointer to fn to be called on receive frames in listen state
6216 * Pointer to remain-on-channel expired fn
6218 * @return Error code.
6223 s32 host_int_remain_on_channel(struct host_if_drv *hWFIDrv, u32 u32SessionID, u32 u32duration, u16 chan, wilc_remain_on_chan_expired RemainOnChanExpired, wilc_remain_on_chan_ready RemainOnChanReady, void *pvUserArg)
6226 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6227 struct host_if_msg msg;
6229 if (pstrWFIDrv == NULL) {
6230 PRINT_ER("driver is null\n");
6234 /* prepare the remainonchan Message */
6235 memset(&msg, 0, sizeof(struct host_if_msg));
6237 /* prepare the WiphyParams Message */
6238 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
6239 msg.body.remain_on_ch.u16Channel = chan;
6240 msg.body.remain_on_ch.pRemainOnChanExpired = RemainOnChanExpired;
6241 msg.body.remain_on_ch.pRemainOnChanReady = RemainOnChanReady;
6242 msg.body.remain_on_ch.pVoid = pvUserArg;
6243 msg.body.remain_on_ch.u32duration = u32duration;
6244 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
6247 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6249 PRINT_ER("wilc mq send fail\n");
6255 * @brief host_int_ListenStateExpired
6257 * @param[in] Handle to wifi driver
6258 * Duration to remain on channel
6259 * Channel to remain on
6260 * Pointer to fn to be called on receive frames in listen state
6261 * Pointer to remain-on-channel expired fn
6263 * @return Error code.
6268 s32 host_int_ListenStateExpired(struct host_if_drv *hWFIDrv, u32 u32SessionID)
6271 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6272 struct host_if_msg msg;
6274 if (pstrWFIDrv == NULL) {
6275 PRINT_ER("driver is null\n");
6279 /*Stopping remain-on-channel timer*/
6280 del_timer(&pstrWFIDrv->hRemainOnChannel);
6282 /* prepare the timer fire Message */
6283 memset(&msg, 0, sizeof(struct host_if_msg));
6284 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
6286 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
6288 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6290 PRINT_ER("wilc mq send fail\n");
6296 * @brief host_int_frame_register
6298 * @param[in] Handle to wifi driver
6299 * @return Error code.
6303 s32 host_int_frame_register(struct host_if_drv *hWFIDrv, u16 u16FrameType, bool bReg)
6306 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6307 struct host_if_msg msg;
6309 if (pstrWFIDrv == NULL) {
6310 PRINT_ER("driver is null\n");
6314 memset(&msg, 0, sizeof(struct host_if_msg));
6316 /* prepare the WiphyParams Message */
6317 msg.id = HOST_IF_MSG_REGISTER_FRAME;
6318 switch (u16FrameType) {
6320 PRINT_D(HOSTINF_DBG, "ACTION\n");
6321 msg.body.reg_frame.u8Regid = ACTION_FRM_IDX;
6325 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
6326 msg.body.reg_frame.u8Regid = PROBE_REQ_IDX;
6330 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
6333 msg.body.reg_frame.u16FrameType = u16FrameType;
6334 msg.body.reg_frame.bReg = bReg;
6337 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6339 PRINT_ER("wilc mq send fail\n");
6347 * @brief host_int_add_beacon
6348 * @details Setting add beacon params in message queue
6349 * @param[in] WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
6350 * u32 u32DTIMPeriod,u32 u32HeadLen, u8* pu8Head,
6351 * u32 u32TailLen, u8* pu8Tail
6352 * @return Error code.
6357 s32 host_int_add_beacon(struct host_if_drv *hWFIDrv, u32 u32Interval,
6359 u32 u32HeadLen, u8 *pu8Head,
6360 u32 u32TailLen, u8 *pu8Tail)
6363 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6364 struct host_if_msg msg;
6365 struct beacon_attr *pstrSetBeaconParam = &msg.body.beacon_info;
6367 if (pstrWFIDrv == NULL) {
6368 PRINT_ER("driver is null\n");
6372 memset(&msg, 0, sizeof(struct host_if_msg));
6374 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
6377 /* prepare the WiphyParams Message */
6378 msg.id = HOST_IF_MSG_ADD_BEACON;
6380 pstrSetBeaconParam->u32Interval = u32Interval;
6381 pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
6382 pstrSetBeaconParam->u32HeadLen = u32HeadLen;
6383 pstrSetBeaconParam->pu8Head = kmalloc(u32HeadLen, GFP_KERNEL);
6384 if (pstrSetBeaconParam->pu8Head == NULL) {
6388 memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
6389 pstrSetBeaconParam->u32TailLen = u32TailLen;
6391 if (u32TailLen > 0) {
6392 pstrSetBeaconParam->pu8Tail = kmalloc(u32TailLen, GFP_KERNEL);
6393 if (pstrSetBeaconParam->pu8Tail == NULL) {
6397 memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen);
6399 pstrSetBeaconParam->pu8Tail = NULL;
6402 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6404 PRINT_ER("wilc mq send fail\n");
6408 if (pstrSetBeaconParam->pu8Head != NULL)
6409 kfree(pstrSetBeaconParam->pu8Head);
6411 if (pstrSetBeaconParam->pu8Tail != NULL)
6412 kfree(pstrSetBeaconParam->pu8Tail);
6421 * @brief host_int_del_beacon
6422 * @details Setting add beacon params in message queue
6423 * @param[in] WILC_WFIDrvHandle hWFIDrv
6424 * @return Error code.
6429 s32 host_int_del_beacon(struct host_if_drv *hWFIDrv)
6432 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6433 struct host_if_msg msg;
6435 if (pstrWFIDrv == NULL) {
6436 PRINT_ER("driver is null\n");
6440 /* prepare the WiphyParams Message */
6441 msg.id = HOST_IF_MSG_DEL_BEACON;
6443 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
6445 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6447 PRINT_ER("wilc_mq_send fail\n");
6454 * @brief host_int_add_station
6455 * @details Setting add station params in message queue
6456 * @param[in] WILC_WFIDrvHandle hWFIDrv, struct add_sta_param *pstrStaParams
6457 * @return Error code.
6462 s32 host_int_add_station(struct host_if_drv *hWFIDrv,
6463 struct add_sta_param *pstrStaParams)
6466 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6467 struct host_if_msg msg;
6468 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
6471 if (pstrWFIDrv == NULL) {
6472 PRINT_ER("driver is null\n");
6476 memset(&msg, 0, sizeof(struct host_if_msg));
6478 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
6481 /* prepare the WiphyParams Message */
6482 msg.id = HOST_IF_MSG_ADD_STATION;
6485 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
6486 if (pstrAddStationMsg->u8NumRates > 0) {
6487 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
6492 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
6493 pstrAddStationMsg->pu8Rates = rates;
6497 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6499 PRINT_ER("wilc_mq_send fail\n");
6504 * @brief host_int_del_station
6505 * @details Setting delete station params in message queue
6506 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr
6507 * @return Error code.
6512 s32 host_int_del_station(struct host_if_drv *hWFIDrv, const u8 *pu8MacAddr)
6515 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6516 struct host_if_msg msg;
6517 struct del_sta *pstrDelStationMsg = &msg.body.del_sta_info;
6519 if (pstrWFIDrv == NULL) {
6520 PRINT_ER("driver is null\n");
6524 memset(&msg, 0, sizeof(struct host_if_msg));
6526 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
6530 /* prepare the WiphyParams Message */
6531 msg.id = HOST_IF_MSG_DEL_STATION;
6534 if (pu8MacAddr == NULL)
6535 memset(pstrDelStationMsg->au8MacAddr, 255, ETH_ALEN);
6537 memcpy(pstrDelStationMsg->au8MacAddr, pu8MacAddr, ETH_ALEN);
6539 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6541 PRINT_ER("wilc_mq_send fail\n");
6545 * @brief host_int_del_allstation
6546 * @details Setting del station params in message queue
6547 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]s
6548 * @return Error code.
6553 s32 host_int_del_allstation(struct host_if_drv *hWFIDrv,
6554 u8 pu8MacAddr[][ETH_ALEN])
6557 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6558 struct host_if_msg msg;
6559 struct del_all_sta *pstrDelAllStationMsg = &msg.body.del_all_sta_info;
6560 u8 au8Zero_Buff[ETH_ALEN] = {0};
6565 if (pstrWFIDrv == NULL) {
6566 PRINT_ER("driver is null\n");
6570 memset(&msg, 0, sizeof(struct host_if_msg));
6572 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
6574 /* prepare the WiphyParams Message */
6575 msg.id = HOST_IF_MSG_DEL_ALL_STA;
6578 /* Handling situation of deauthenticing all associated stations*/
6579 for (i = 0; i < MAX_NUM_STA; i++) {
6580 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
6581 memcpy(pstrDelAllStationMsg->au8Sta_DelAllSta[i], pu8MacAddr[i], ETH_ALEN);
6582 PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n", pstrDelAllStationMsg->au8Sta_DelAllSta[i][0], pstrDelAllStationMsg->au8Sta_DelAllSta[i][1], pstrDelAllStationMsg->au8Sta_DelAllSta[i][2], pstrDelAllStationMsg->au8Sta_DelAllSta[i][3], pstrDelAllStationMsg->au8Sta_DelAllSta[i][4],
6583 pstrDelAllStationMsg->au8Sta_DelAllSta[i][5]);
6588 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
6592 pstrDelAllStationMsg->u8Num_AssocSta = u8AssocNumb;
6593 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6597 PRINT_ER("wilc_mq_send fail\n");
6599 down(&hWaitResponse);
6606 * @brief host_int_edit_station
6607 * @details Setting edit station params in message queue
6608 * @param[in] WILC_WFIDrvHandle hWFIDrv, struct add_sta_param *pstrStaParams
6609 * @return Error code.
6614 s32 host_int_edit_station(struct host_if_drv *hWFIDrv,
6615 struct add_sta_param *pstrStaParams)
6618 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6619 struct host_if_msg msg;
6620 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
6622 if (pstrWFIDrv == NULL) {
6623 PRINT_ER("driver is null\n");
6627 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
6629 memset(&msg, 0, sizeof(struct host_if_msg));
6632 /* prepare the WiphyParams Message */
6633 msg.id = HOST_IF_MSG_EDIT_STATION;
6636 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
6637 if (pstrAddStationMsg->u8NumRates > 0) {
6638 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
6643 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
6644 pstrAddStationMsg->pu8Rates = rates;
6647 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6649 PRINT_ER("wilc_mq_send fail\n");
6654 s32 host_int_set_power_mgmt(struct host_if_drv *hWFIDrv, bool bIsEnabled, u32 u32Timeout)
6657 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6658 struct host_if_msg msg;
6659 struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.pwr_mgmt_info;
6661 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
6663 if (pstrWFIDrv == NULL) {
6664 PRINT_ER("driver is null\n");
6668 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
6670 memset(&msg, 0, sizeof(struct host_if_msg));
6673 /* prepare the WiphyParams Message */
6674 msg.id = HOST_IF_MSG_POWER_MGMT;
6677 pstrPowerMgmtParam->bIsEnabled = bIsEnabled;
6678 pstrPowerMgmtParam->u32Timeout = u32Timeout;
6681 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6683 PRINT_ER("wilc_mq_send fail\n");
6687 s32 host_int_setup_multicast_filter(struct host_if_drv *hWFIDrv, bool bIsEnabled, u32 u32count)
6691 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6692 struct host_if_msg msg;
6693 struct set_multicast *pstrMulticastFilterParam = &msg.body.multicast_info;
6696 if (pstrWFIDrv == NULL) {
6697 PRINT_ER("driver is null\n");
6701 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
6703 memset(&msg, 0, sizeof(struct host_if_msg));
6706 /* prepare the WiphyParams Message */
6707 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
6710 pstrMulticastFilterParam->bIsEnabled = bIsEnabled;
6711 pstrMulticastFilterParam->u32count = u32count;
6713 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6715 PRINT_ER("wilc_mq_send fail\n");
6720 * @brief host_int_ParseJoinBssParam
6721 * @details Parse Needed Join Parameters and save it in a new JoinBssParam entry
6722 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
6727 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
6729 tstrJoinBssParam *pNewJoinBssParam = NULL;
6738 u8 pcipherTotalCount = 0;
6739 u8 authTotalCount = 0;
6742 pu8IEs = ptstrNetworkInfo->pu8IEs;
6743 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
6745 pNewJoinBssParam = kmalloc(sizeof(tstrJoinBssParam), GFP_KERNEL);
6746 if (pNewJoinBssParam != NULL) {
6747 memset(pNewJoinBssParam, 0, sizeof(tstrJoinBssParam));
6748 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
6749 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
6750 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
6751 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
6753 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/
6754 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
6755 pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen;
6756 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
6757 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
6758 /*for(i=0; i<pNewJoinBssParam->ssidLen;i++)
6759 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/
6761 /* parse supported rates: */
6762 while (index < u16IEsLen) {
6763 /* supportedRates IE */
6764 if (pu8IEs[index] == SUPP_RATES_IE) {
6765 /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */
6766 suppRatesNo = pu8IEs[index + 1];
6767 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
6768 index += 2; /* skipping ID and length bytes; */
6770 for (i = 0; i < suppRatesNo; i++) {
6771 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
6772 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */
6774 index += suppRatesNo;
6777 /* Ext SupportedRates IE */
6778 else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
6779 /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */
6780 /* checking if no of ext. supp and supp rates < max limit */
6781 extSuppRatesNo = pu8IEs[index + 1];
6782 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
6783 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
6785 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
6787 /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */
6788 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
6789 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
6790 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */
6792 index += extSuppRatesNo;
6796 else if (pu8IEs[index] == HT_CAPABILITY_IE) {
6797 /* if IE found set the flag */
6798 pNewJoinBssParam->ht_capable = true;
6799 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
6800 /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */
6802 } else if ((pu8IEs[index] == WMM_IE) && /* WMM Element ID */
6803 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
6804 (pu8IEs[index + 4] == 0xF2) && /* OUI */
6805 (pu8IEs[index + 5] == 0x02) && /* OUI Type */
6806 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) && /* OUI Sub Type */
6807 (pu8IEs[index + 7] == 0x01)) {
6808 /* Presence of WMM Info/Param element indicates WMM capability */
6809 pNewJoinBssParam->wmm_cap = true;
6811 /* Check if Bit 7 is set indicating U-APSD capability */
6812 if (pu8IEs[index + 8] & BIT(7))
6813 pNewJoinBssParam->uapsd_cap = true;
6814 index += pu8IEs[index + 1] + 2;
6817 else if ((pu8IEs[index] == P2P_IE) && /* P2P Element ID */
6818 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
6819 (pu8IEs[index + 4] == 0x9a) && /* OUI */
6820 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) { /* OUI Type */
6823 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
6824 pNewJoinBssParam->u8NoaEnbaled = 1;
6825 pNewJoinBssParam->u8Index = pu8IEs[index + 9];
6827 /* Check if Bit 7 is set indicating Opss capability */
6828 if (pu8IEs[index + 10] & BIT(7)) {
6829 pNewJoinBssParam->u8OppEnable = 1;
6830 pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10];
6832 pNewJoinBssParam->u8OppEnable = 0;
6834 PRINT_D(GENERIC_DBG, "P2P Dump\n");
6835 for (i = 0; i < pu8IEs[index + 7]; i++)
6836 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
6838 pNewJoinBssParam->u8Count = pu8IEs[index + 11];
6839 u16P2P_count = index + 12;
6841 memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4);
6844 memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4);
6847 memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
6849 index += pu8IEs[index + 1] + 2;
6853 else if ((pu8IEs[index] == RSN_IE) ||
6854 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
6855 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
6856 (pu8IEs[index + 5] == 0x01))) {
6857 u16 rsnIndex = index;
6858 /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]);
6859 * for(i=0; i<pu8IEs[rsnIndex+1]; i++)
6861 * PRINT_D(HOSTINF_DBG,"%0x ",pu8IEs[rsnIndex+2+i]);
6863 if (pu8IEs[rsnIndex] == RSN_IE) {
6864 pNewJoinBssParam->mode_802_11i = 2;
6865 /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */
6866 } else { /* check if rsn was previously parsed */
6867 if (pNewJoinBssParam->mode_802_11i == 0)
6868 pNewJoinBssParam->mode_802_11i = 1;
6869 /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */
6872 rsnIndex += 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */
6873 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
6875 /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x\n",pNewJoinBssParam->rsn_grp_policy); */
6876 /* initialize policies with invalid values */
6878 jumpOffset = pu8IEs[rsnIndex] * 4; /* total no.of bytes of pcipher field (count*4) */
6880 /*parsing pairwise cipher*/
6882 /* saving 3 pcipher max. */
6883 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
6884 rsnIndex += 2; /* jump 2 bytes of pcipher count */
6886 /* PRINT_D(HOSTINF_DBG,"\npcipher:%d\n",pcipherCount); */
6887 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
6888 /* each count corresponds to 4 bytes, only last byte is saved */
6889 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
6890 /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */
6892 pcipherTotalCount += pcipherCount;
6893 rsnIndex += jumpOffset;
6895 jumpOffset = pu8IEs[rsnIndex] * 4;
6897 /*parsing AKM suite (auth_policy)*/
6898 /* saving 3 auth policies max. */
6899 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
6900 rsnIndex += 2; /* jump 2 bytes of pcipher count */
6902 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
6903 /* each count corresponds to 4 bytes, only last byte is saved */
6904 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
6906 authTotalCount += authCount;
6907 rsnIndex += jumpOffset;
6908 /*pasring rsn cap. only if rsn IE*/
6909 if (pu8IEs[index] == RSN_IE) {
6910 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
6911 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
6914 pNewJoinBssParam->rsn_found = true;
6915 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
6918 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
6925 return (void *)pNewJoinBssParam;
6929 void host_int_freeJoinParams(void *pJoinParams)
6931 if ((tstrJoinBssParam *)pJoinParams != NULL)
6932 kfree((tstrJoinBssParam *)pJoinParams);
6934 PRINT_ER("Unable to FREE null pointer\n");
6937 s32 host_int_delBASession(struct host_if_drv *hWFIDrv, char *pBSSID, char TID)
6940 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6941 struct host_if_msg msg;
6942 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
6944 if (pstrWFIDrv == NULL) {
6945 PRINT_ER("driver is null\n");
6949 memset(&msg, 0, sizeof(struct host_if_msg));
6951 /* prepare the WiphyParams Message */
6952 msg.id = HOST_IF_MSG_DEL_BA_SESSION;
6954 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
6955 pBASessionInfo->u8Ted = TID;
6958 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6960 PRINT_ER("wilc_mq_send fail\n");
6962 down(&hWaitResponse);
6967 s32 host_int_del_All_Rx_BASession(struct host_if_drv *hWFIDrv, char *pBSSID, char TID)
6970 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6971 struct host_if_msg msg;
6972 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
6974 if (pstrWFIDrv == NULL) {
6975 PRINT_ER("driver is null\n");
6979 memset(&msg, 0, sizeof(struct host_if_msg));
6981 /* prepare the WiphyParams Message */
6982 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
6984 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
6985 pBASessionInfo->u8Ted = TID;
6988 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6990 PRINT_ER("wilc_mq_send fail\n");
6992 down(&hWaitResponse);
6998 * @brief host_int_setup_ipaddress
6999 * @details setup IP in firmware
7000 * @param[in] Handle to wifi driver
7001 * @return Error code.
7002 * @author Abdelrahman Sobhy
7005 s32 host_int_setup_ipaddress(struct host_if_drv *hWFIDrv, u8 *u16ipadd, u8 idx)
7008 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
7009 struct host_if_msg msg;
7011 /* TODO: Enable This feature on softap firmware */
7014 if (pstrWFIDrv == NULL) {
7015 PRINT_ER("driver is null\n");
7019 memset(&msg, 0, sizeof(struct host_if_msg));
7021 /* prepare the WiphyParams Message */
7022 msg.id = HOST_IF_MSG_SET_IPADDRESS;
7024 msg.body.ip_info.au8IPAddr = u16ipadd;
7026 msg.body.ip_info.idx = idx;
7028 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
7030 PRINT_ER("wilc_mq_send fail\n");
7038 * @brief host_int_get_ipaddress
7039 * @details Get IP from firmware
7040 * @param[in] Handle to wifi driver
7041 * @return Error code.
7042 * @author Abdelrahman Sobhy
7045 s32 host_int_get_ipaddress(struct host_if_drv *hWFIDrv, u8 *u16ipadd, u8 idx)
7048 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
7049 struct host_if_msg msg;
7051 if (pstrWFIDrv == NULL) {
7052 PRINT_ER("driver is null\n");
7056 memset(&msg, 0, sizeof(struct host_if_msg));
7058 /* prepare the WiphyParams Message */
7059 msg.id = HOST_IF_MSG_GET_IPADDRESS;
7061 msg.body.ip_info.au8IPAddr = u16ipadd;
7063 msg.body.ip_info.idx = idx;
7065 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
7067 PRINT_ER("wilc_mq_send fail\n");