1 #include "host_interface.h"
2 #include "coreconfigurator.h"
4 extern s32 TransportInit(void);
5 extern s32 TransportDeInit(void);
8 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
9 extern WILC_TimerHandle hDuringIpTimer;
12 extern bool bEnablePS;
14 extern u8 g_wilc_initialized;
15 /*****************************************************************************/
17 /*****************************************************************************/
19 /* Message types of the Host IF Message Queue*/
20 #define HOST_IF_MSG_SCAN ((u16)0)
21 #define HOST_IF_MSG_CONNECT ((u16)1)
22 #define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO ((u16)2)
23 #define HOST_IF_MSG_KEY ((u16)3)
24 #define HOST_IF_MSG_RCVD_NTWRK_INFO ((u16)4)
25 #define HOST_IF_MSG_RCVD_SCAN_COMPLETE ((u16)5)
26 #define HOST_IF_MSG_CFG_PARAMS ((u16)6)
27 #define HOST_IF_MSG_SET_CHANNEL ((u16)7)
28 #define HOST_IF_MSG_DISCONNECT ((u16)8)
29 #define HOST_IF_MSG_GET_RSSI ((u16)9)
30 #define HOST_IF_MSG_GET_CHNL ((u16)10)
31 #define HOST_IF_MSG_ADD_BEACON ((u16)11)
32 #define HOST_IF_MSG_DEL_BEACON ((u16)12)
33 #define HOST_IF_MSG_ADD_STATION ((u16)13)
34 #define HOST_IF_MSG_DEL_STATION ((u16)14)
35 #define HOST_IF_MSG_EDIT_STATION ((u16)15)
36 #define HOST_IF_MSG_SCAN_TIMER_FIRED ((u16)16)
37 #define HOST_IF_MSG_CONNECT_TIMER_FIRED ((u16)17)
38 #define HOST_IF_MSG_POWER_MGMT ((u16)18)
39 #define HOST_IF_MSG_GET_INACTIVETIME ((u16)19)
40 #define HOST_IF_MSG_REMAIN_ON_CHAN ((u16)20)
41 #define HOST_IF_MSG_REGISTER_FRAME ((u16)21)
42 #define HOST_IF_MSG_LISTEN_TIMER_FIRED ((u16)22)
43 #define HOST_IF_MSG_GET_LINKSPEED ((u16)23)
44 #define HOST_IF_MSG_SET_WFIDRV_HANDLER ((u16)24)
45 #define HOST_IF_MSG_SET_MAC_ADDRESS ((u16)25)
46 #define HOST_IF_MSG_GET_MAC_ADDRESS ((u16)26)
47 #define HOST_IF_MSG_SET_OPERATION_MODE ((u16)27)
48 #define HOST_IF_MSG_SET_IPADDRESS ((u16)28)
49 #define HOST_IF_MSG_GET_IPADDRESS ((u16)29)
50 #define HOST_IF_MSG_FLUSH_CONNECT ((u16)30)
51 #define HOST_IF_MSG_GET_STATISTICS ((u16)31)
52 #define HOST_IF_MSG_SET_MULTICAST_FILTER ((u16)32)
53 #define HOST_IF_MSG_ADD_BA_SESSION ((u16)33)
54 #define HOST_IF_MSG_DEL_BA_SESSION ((u16)34)
55 #define HOST_IF_MSG_Q_IDLE ((u16)35)
56 #define HOST_IF_MSG_DEL_ALL_STA ((u16)36)
57 #define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS ((u16)34)
59 #define HOST_IF_MSG_EXIT ((u16)100)
61 #define HOST_IF_SCAN_TIMEOUT 4000
62 #define HOST_IF_CONNECT_TIMEOUT 9500
64 #define BA_SESSION_DEFAULT_BUFFER_SIZE 16
65 #define BA_SESSION_DEFAULT_TIMEOUT 1000
66 #define BLOCK_ACK_REQ_SIZE 0x14
67 /*****************************************************************************/
68 /* Type Definitions */
69 /*****************************************************************************/
72 * @struct tstrHostIFCfgParamAttr
73 * @brief Structure to hold Host IF CFG Params Attributes
77 * @author Mai Daftedar
81 typedef struct _tstrHostIFCfgParamAttr {
82 tstrCfgParamVal pstrCfgParamVal;
84 } tstrHostIFCfgParamAttr;
87 * @struct tstrHostIFwpaAttr
88 * @brief Structure to hold Host IF Scan Attributes
92 * @author Mai Daftedar
96 typedef struct _tstrHostIFwpaAttr {
108 * @struct tstrHostIFwepAttr
109 * @brief Structure to hold Host IF Scan Attributes
113 * @author Mai Daftedar
114 * @date 25 March 2012
117 typedef struct _tstrHostIFwepAttr {
122 AUTHTYPE_T tenuAuth_type;
127 * @struct tuniHostIFkeyAttr
128 * @brief Structure to hold Host IF Scan Attributes
132 * @author Mai Daftedar
133 * @date 25 March 2012
136 typedef union _tuniHostIFkeyAttr {
137 tstrHostIFwepAttr strHostIFwepAttr;
138 tstrHostIFwpaAttr strHostIFwpaAttr;
139 tstrHostIFpmkidAttr strHostIFpmkidAttr;
143 * @struct tstrHostIFkeyAttr
144 * @brief Structure to hold Host IF Scan Attributes
148 * @author Mai Daftedar
149 * @date 25 March 2012
152 typedef struct _tstrHostIFkeyAttr {
153 tenuKeyType enuKeyType;
155 tuniHostIFkeyAttr uniHostIFkeyAttr;
162 * @struct tstrHostIFscanAttr
163 * @brief Structure to hold Host IF Scan Attributes
167 * @author Mostafa Abu Bakr
168 * @date 25 March 2012
171 typedef struct _tstrHostIFscanAttr {
178 tWILCpfScanResult pfScanResult;
181 tstrHiddenNetwork strHiddenNetwork;
183 } tstrHostIFscanAttr;
186 * @struct tstrHostIFconnectAttr
187 * @brief Structure to hold Host IF Connect Attributes
191 * @author Mostafa Abu Bakr
192 * @date 25 March 2012
195 typedef struct _tstrHostIFconnectAttr {
202 tWILCpfConnectResult pfConnectResult;
204 AUTHTYPE_T tenuAuth_type;
207 } tstrHostIFconnectAttr;
210 * @struct tstrRcvdGnrlAsyncInfo
211 * @brief Structure to hold Received General Asynchronous info
215 * @author Mostafa Abu Bakr
216 * @date 25 March 2012
219 typedef struct _tstrRcvdGnrlAsyncInfo {
222 } tstrRcvdGnrlAsyncInfo;
225 * @struct tstrHostIFSetChan
226 * @brief Set Channel message body
230 * @author Mai Daftedar
231 * @date 25 March 2012
234 typedef struct _tstrHostIFSetChan {
239 * @struct tstrHostIFSetChan
240 * @brief Get Channel message body
244 * @author Mai Daftedar
248 typedef struct _tstrHostIFGetChan {
252 /*bug3819: Add Scan acomplete notification to host*/
254 * @struct tstrScanComplete
255 * @brief hold received Async. Scan Complete message body
260 * @date 25 March 2012
263 /*typedef struct _tstrScanComplete
267 * } tstrScanComplete;*/
270 * @struct tstrHostIFSetBeacon
271 * @brief Set Beacon message body
275 * @author Adham Abozaeid
279 typedef struct _tstrHostIFSetBeacon {
280 u32 u32Interval; /*!< Beacon Interval. Period between two successive beacons on air */
281 u32 u32DTIMPeriod; /*!< DTIM Period. Indicates how many Beacon frames
282 * (including the current frame) appear before the next DTIM */
283 u32 u32HeadLen; /*!< Length of the head buffer in bytes */
284 u8 *pu8Head; /*!< Pointer to the beacon's head buffer. Beacon's head is the part
285 * from the beacon's start till the TIM element, NOT including the TIM */
286 u32 u32TailLen; /*!< Length of the tail buffer in bytes */
287 u8 *pu8Tail; /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just
288 * after the TIM inormation element */
289 } tstrHostIFSetBeacon;
294 * @struct tstrHostIFDelBeacon
295 * @brief Del Beacon message body
299 * @author Adham Abozaeid
303 typedef struct _tstrHostIFDelBeacon {
305 } tstrHostIFDelBeacon;
308 * @struct tstrHostIFSetMulti
309 * @brief set Multicast filter Address
313 * @author Abdelrahman Sobhy
314 * @date 30 August 2013
315 * @version 1.0 Description
321 } tstrHostIFSetMulti;
324 * @struct tstrHostIFDelAllSta
325 * @brief Deauth station message body
329 * @author Mai Daftedar
330 * @date 09 April 2014
331 * @version 1.0 Description
335 u8 au8Sta_DelAllSta[MAX_NUM_STA][ETH_ALEN];
337 } tstrHostIFDelAllSta;
340 * @struct tstrHostIFDelSta
341 * @brief Delete station message body
345 * @author Adham Abozaeid
347 * @version 1.0 Description
351 u8 au8MacAddr[ETH_ALEN];
355 * @struct tstrTimerCb
356 * @brief Timer callback message body
360 * @author Mostafa Abu Bakr
361 * @date 25 March 2012
364 typedef struct _tstrTimerCb {
365 void *pvUsrArg; /*!< Private data passed at timer start */
369 * @struct tstrHostIfPowerMgmtParam
370 * @brief Power management message body
374 * @author Adham Abozaeid
375 * @date 24 November 2012
382 } tstrHostIfPowerMgmtParam;
385 * @struct tstrHostIFSetIPAddr
386 * @brief set IP Address message body
390 * @author Abdelrahman Sobhy
391 * @date 30 August 2013
392 * @version 1.0 Description
398 } tstrHostIFSetIPAddr;
401 * @struct tstrHostIfStaInactiveT
402 * @brief Get station message body
406 * @author Mai Daftedar
407 * @date 16 April 2013
413 } tstrHostIfStaInactiveT;
416 * @union tuniHostIFmsgBody
417 * @brief Message body for the Host Interface message_q
421 * @author Mostafa Abu Bakr
422 * @date 25 March 2012
425 typedef union _tuniHostIFmsgBody {
426 tstrHostIFscanAttr strHostIFscanAttr; /*!< Host IF Scan Request Attributes message body */
427 tstrHostIFconnectAttr strHostIFconnectAttr; /*!< Host IF Connect Request Attributes message body */
428 tstrRcvdNetworkInfo strRcvdNetworkInfo; /*!< Received Asynchronous Network Info message body */
429 tstrRcvdGnrlAsyncInfo strRcvdGnrlAsyncInfo; /*!< Received General Asynchronous Info message body */
430 tstrHostIFkeyAttr strHostIFkeyAttr; /*!<>*/
431 tstrHostIFCfgParamAttr strHostIFCfgParamAttr; /*! <CFG Parameter message Body> */
432 tstrHostIFSetChan strHostIFSetChan;
433 tstrHostIFGetChan strHostIFGetChan;
434 tstrHostIFSetBeacon strHostIFSetBeacon; /*!< Set beacon message body */
435 tstrHostIFDelBeacon strHostIFDelBeacon; /*!< Del beacon message body */
436 tstrWILC_AddStaParam strAddStaParam; /*!< Add station message body */
437 tstrHostIFDelSta strDelStaParam; /*!< Del Station message body */
438 tstrWILC_AddStaParam strEditStaParam; /*!< Edit station message body */
439 /* tstrScanComplete strScanComplete; / *Received Async. Scan Complete message body* / */
440 tstrTimerCb strTimerCb; /*!< Timer callback message body */
441 tstrHostIfPowerMgmtParam strPowerMgmtparam; /*!< Power Management message body */
442 tstrHostIfStaInactiveT strHostIfStaInactiveT;
443 tstrHostIFSetIPAddr strHostIfSetIP;
444 tstrHostIfSetDrvHandler strHostIfSetDrvHandler;
445 tstrHostIFSetMulti strHostIfSetMulti;
446 tstrHostIfSetOperationMode strHostIfSetOperationMode;
447 tstrHostIfSetMacAddress strHostIfSetMacAddress;
448 tstrHostIfGetMacAddress strHostIfGetMacAddress;
449 tstrHostIfBASessionInfo strHostIfBASessionInfo;
451 tstrHostIfRemainOnChan strHostIfRemainOnChan;
452 tstrHostIfRegisterFrame strHostIfRegisterFrame;
455 tstrHostIFDelAllSta strHostIFDelAllSta;
459 * @struct tstrHostIFmsg
460 * @brief Host Interface message
464 * @author Mostafa Abu Bakr
465 * @date 25 March 2012
468 typedef struct _tstrHostIFmsg {
469 u16 u16MsgId; /*!< Message ID */
470 tuniHostIFmsgBody uniHostIFmsgBody; /*!< Message body */
474 #ifdef CONNECT_DIRECT
475 typedef struct _tstrWidJoinReqExt {
476 char SSID[MAX_SSID_LEN];
482 /*Bug4218: Parsing Join Param*/
483 #ifdef WILC_PARSE_SCAN_IN_HOST
484 /*Struct containg joinParam of each AP*/
485 typedef struct _tstrJoinBssParam {
491 char ssid[MAX_SSID_LEN];
493 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
500 u8 rsn_pcip_policy[3];
501 u8 rsn_auth_policy[3];
503 struct _tstrJoinParam *nextJoinBss;
516 /*Bug4218: Parsing Join Param*/
517 /*a linked list table containing needed join parameters entries for each AP found in most recent scan*/
518 typedef struct _tstrBssTable {
520 tstrJoinBssParam *head;
521 tstrJoinBssParam *tail;
523 #endif /*WILC_PARSE_SCAN_IN_HOST*/
528 SCAN_CONNECT_TIMER_FORCE_32BIT = 0xFFFFFFFF
531 /*****************************************************************************/
533 /* Global Variabls */
535 /*****************************************************************************/
538 tstrWILC_WFIDrv *terminated_handle = NULL;
539 tstrWILC_WFIDrv *gWFiDrvHandle = NULL;
540 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
541 bool g_obtainingIP = false;
544 static struct task_struct *HostIFthreadHandler;
545 static WILC_MsgQueueHandle gMsgQHostIF;
546 static struct semaphore hSemHostIFthrdEnd;
548 struct semaphore hSemDeinitDrvHandle;
549 static struct semaphore hWaitResponse;
550 struct semaphore hSemHostIntDeinit;
551 WILC_TimerHandle g_hPeriodicRSSI;
555 u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
557 #ifndef CONNECT_DIRECT
558 static u8 gapu8RcvdSurveyResults[2][MAX_SURVEY_RESULT_FRAG_SIZE];
561 static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE];
563 bool gbScanWhileConnected = false;
568 static u8 gs8SetIP[2][4];
569 static u8 gs8GetIP[2][4];
570 #ifdef WILC_AP_EXTERNAL_MLME
571 static u32 gu32InactiveTime;
575 static u32 gu32WidConnRstHack;
579 u8 *gu8FlushedJoinReq;
580 u8 *gu8FlushedInfoElemAsoc;
581 u8 gu8Flushed11iMode;
582 u8 gu8FlushedAuthType;
583 u32 gu32FlushedJoinReqSize;
584 u32 gu32FlushedInfoElemAsocSize;
585 u32 gu8FlushedJoinReqDrvHandler;
586 #define REAL_JOIN_REQ 0
587 #define FLUSHED_JOIN_REQ 1
588 #define FLUSHED_BYTE_POS 79 /* Position the byte indicating flushing in the flushed request */
590 /*Bug4218: Parsing Join Param*/
591 #ifdef WILC_PARSE_SCAN_IN_HOST
592 /*Bug4218: Parsing Join Param*/
593 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
594 #endif /*WILC_PARSE_SCAN_IN_HOST*/
596 extern void chip_sleep_manually(u32 u32SleepTime);
597 extern int linux_wlan_get_num_conn_ifcs(void);
600 * @brief Handle_SetChannel
601 * @details Sending config packet to firmware to set channel
602 * @param[in] tstrHostIFSetChan* pstrHostIFSetChan
603 * @return Error code.
608 static s32 Handle_SetChannel(void *drvHandler, tstrHostIFSetChan *pstrHostIFSetChan)
611 s32 s32Error = WILC_SUCCESS;
613 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
615 /*prepare configuration packet*/
616 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
617 strWID.enuWIDtype = WID_CHAR;
618 strWID.ps8WidVal = (char *)&(pstrHostIFSetChan->u8SetChan);
619 strWID.s32ValueSize = sizeof(char);
621 PRINT_D(HOSTINF_DBG, "Setting channel\n");
623 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
625 PRINT_ER("Failed to set channel\n");
626 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
636 * @brief Handle_SetWfiDrvHandler
637 * @details Sending config packet to firmware to set driver handler
638 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
639 * @return Error code.
644 static s32 Handle_SetWfiDrvHandler(tstrHostIfSetDrvHandler *pstrHostIfSetDrvHandler)
647 s32 s32Error = WILC_SUCCESS;
649 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)((pstrHostIfSetDrvHandler->u32Address));
652 /*prepare configuration packet*/
653 strWID.u16WIDid = (u16)WID_SET_DRV_HANDLER;
654 strWID.enuWIDtype = WID_INT;
655 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetDrvHandler->u32Address);
656 strWID.s32ValueSize = sizeof(u32);
660 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
663 if ((pstrHostIfSetDrvHandler->u32Address) == (u32)NULL) {
664 up(&hSemDeinitDrvHandle);
669 PRINT_ER("Failed to set driver handler\n");
670 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
681 * @brief Handle_SetWfiAPDrvHandler
682 * @details Sending config packet to firmware to set driver handler
683 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
684 * @return Error code.
689 static s32 Handle_SetOperationMode(void *drvHandler, tstrHostIfSetOperationMode *pstrHostIfSetOperationMode)
692 s32 s32Error = WILC_SUCCESS;
694 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
697 /*prepare configuration packet*/
698 strWID.u16WIDid = (u16)WID_SET_OPERATION_MODE;
699 strWID.enuWIDtype = WID_INT;
700 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetOperationMode->u32Mode);
701 strWID.s32ValueSize = sizeof(u32);
704 PRINT_INFO(HOSTINF_DBG, "pstrWFIDrv= %p \n", pstrWFIDrv);
706 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
709 if ((pstrHostIfSetOperationMode->u32Mode) == (u32)NULL) {
710 up(&hSemDeinitDrvHandle);
715 PRINT_ER("Failed to set driver handler\n");
716 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
727 * @brief host_int_set_IPAddress
728 * @details Setting IP address params in message queue
729 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
730 * @return Error code.
735 s32 Handle_set_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx)
738 s32 s32Error = WILC_SUCCESS;
740 char firmwareIPAddress[4] = {0};
741 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
743 if (pu8IPAddr[0] < 192)
746 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %d.%d.%d.%d \n", idx, pu8IPAddr[0], pu8IPAddr[1], pu8IPAddr[2], pu8IPAddr[3]);
748 WILC_memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN);
750 /*prepare configuration packet*/
751 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
752 strWID.enuWIDtype = WID_STR;
753 strWID.ps8WidVal = (u8 *)pu8IPAddr;
754 strWID.s32ValueSize = IP_ALEN;
756 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
760 host_int_get_ipaddress((WILC_WFIDrvHandle)drvHandler, firmwareIPAddress, idx);
763 PRINT_D(HOSTINF_DBG, "Failed to set IP address\n");
764 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
766 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
779 * @brief Handle_get_IPAddress
780 * @details Setting IP address params in message queue
781 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
782 * @return Error code.
787 s32 Handle_get_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx)
790 s32 s32Error = WILC_SUCCESS;
792 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
794 /*prepare configuration packet*/
795 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
796 strWID.enuWIDtype = WID_STR;
797 strWID.ps8WidVal = (u8 *)WILC_MALLOC(IP_ALEN);
798 strWID.s32ValueSize = IP_ALEN;
800 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
802 PRINT_INFO(HOSTINF_DBG, "%d.%d.%d.%d\n", (u8)(strWID.ps8WidVal[0]), (u8)(strWID.ps8WidVal[1]), (u8)(strWID.ps8WidVal[2]), (u8)(strWID.ps8WidVal[3]));
804 WILC_memcpy(gs8GetIP[idx], strWID.ps8WidVal, IP_ALEN);
806 /*get the value by searching the local copy*/
807 WILC_FREE(strWID.ps8WidVal);
809 if (WILC_memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0)
810 host_int_setup_ipaddress((WILC_WFIDrvHandle)pstrWFIDrv, gs8SetIP[idx], idx);
812 if (s32Error != WILC_SUCCESS) {
813 PRINT_ER("Failed to get IP address\n");
814 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
816 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d \n", idx);
817 PRINT_INFO(HOSTINF_DBG, "%d.%d.%d.%d\n", gs8GetIP[idx][0], gs8GetIP[idx][1], gs8GetIP[idx][2], gs8GetIP[idx][3]);
818 PRINT_INFO(HOSTINF_DBG, "\n");
832 * @brief Handle_SetMacAddress
833 * @details Setting mac address
834 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
835 * @return Error code.
836 * @author Amr Abdel-Moghny
837 * @date November 2013
840 static s32 Handle_SetMacAddress(void *drvHandler, tstrHostIfSetMacAddress *pstrHostIfSetMacAddress)
843 s32 s32Error = WILC_SUCCESS;
845 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
846 u8 *mac_buf = (u8 *)WILC_MALLOC(ETH_ALEN);
847 if (mac_buf == NULL) {
848 PRINT_ER("No buffer to send mac address\n");
851 WILC_memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
853 /*prepare configuration packet*/
854 strWID.u16WIDid = (u16)WID_MAC_ADDR;
855 strWID.enuWIDtype = WID_STR;
856 strWID.ps8WidVal = mac_buf;
857 strWID.s32ValueSize = ETH_ALEN;
858 PRINT_D(GENERIC_DBG, "mac addr = :%x:%x:%x:%x:%x:%x\n", strWID.ps8WidVal[0], strWID.ps8WidVal[1], strWID.ps8WidVal[2], strWID.ps8WidVal[3], strWID.ps8WidVal[4], strWID.ps8WidVal[5]);
860 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
862 PRINT_ER("Failed to set mac address\n");
863 WILC_ERRORREPORT(s32Error, WILC_FAIL);
877 * @brief Handle_GetMacAddress
878 * @details Getting mac address
879 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
880 * @return Error code.
881 * @author Amr Abdel-Moghny
885 static s32 Handle_GetMacAddress(void *drvHandler, tstrHostIfGetMacAddress *pstrHostIfGetMacAddress)
888 s32 s32Error = WILC_SUCCESS;
891 /*prepare configuration packet*/
892 strWID.u16WIDid = (u16)WID_MAC_ADDR;
893 strWID.enuWIDtype = WID_STR;
894 strWID.ps8WidVal = pstrHostIfGetMacAddress->u8MacAddress;
895 strWID.s32ValueSize = ETH_ALEN;
898 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, false, (u32)drvHandler);
900 PRINT_ER("Failed to get mac address\n");
901 WILC_ERRORREPORT(s32Error, WILC_FAIL);
914 * @brief Handle_CfgParam
915 * @details Sending config packet to firmware to set CFG params
916 * @param[in] tstrHostIFCfgParamAttr* strHostIFCfgParamAttr
917 * @return Error code.
922 static s32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *strHostIFCfgParamAttr)
924 s32 s32Error = WILC_SUCCESS;
925 tstrWID strWIDList[32];
927 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
930 down(&(pstrWFIDrv->gtOsCfgValuesSem));
933 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
935 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BSS_TYPE) {
936 /*----------------------------------------------------------*/
937 /*Input Value: INFRASTRUCTURE = 1, */
938 /* INDEPENDENT= 2, */
940 /*----------------------------------------------------------*/
941 /* validate input then copy>> need to check value 4 and 5 */
942 if (strHostIFCfgParamAttr->pstrCfgParamVal.bss_type < 6) {
943 strWIDList[u8WidCnt].u16WIDid = WID_BSS_TYPE;
944 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
945 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
946 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
947 pstrWFIDrv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
949 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
953 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTH_TYPE) {
954 /*------------------------------------------------------*/
955 /*Input Values: OPEN_SYSTEM = 0, */
956 /* SHARED_KEY = 1, */
958 /*------------------------------------------------------*/
959 /*validate Possible values*/
960 if ((strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 1 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 2 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 5) {
961 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TYPE;
962 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
963 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
964 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
965 pstrWFIDrv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
967 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
971 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTHEN_TIMEOUT) {
972 /* range is 1 to 65535. */
973 if (strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout < 65536) {
974 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TIMEOUT;
975 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
976 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
977 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
978 pstrWFIDrv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
980 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
984 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & POWER_MANAGEMENT) {
985 /*-----------------------------------------------------------*/
986 /*Input Values: NO_POWERSAVE = 0, */
987 /* MIN_FAST_PS = 1, */
988 /* MAX_FAST_PS = 2, */
989 /* MIN_PSPOLL_PS = 3, */
990 /* MAX_PSPOLL_PS = 4 */
991 /*----------------------------------------------------------*/
992 if (strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode < 5) {
993 strWIDList[u8WidCnt].u16WIDid = WID_POWER_MANAGEMENT;
994 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
995 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
996 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
997 pstrWFIDrv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
999 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1003 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_SHORT) {
1004 /* range from 1 to 256 */
1005 if ((strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit < 256)) {
1006 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_RETRY_LIMIT;
1007 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
1008 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1009 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1010 pstrWFIDrv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
1012 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1016 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_LONG) {
1017 /* range from 1 to 256 */
1018 if ((strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit < 256)) {
1019 strWIDList[u8WidCnt].u16WIDid = WID_LONG_RETRY_LIMIT;
1020 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
1022 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1023 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1024 pstrWFIDrv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
1026 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1030 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & FRAG_THRESHOLD) {
1032 if (strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold < 7937) {
1033 strWIDList[u8WidCnt].u16WIDid = WID_FRAG_THRESHOLD;
1034 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
1035 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1036 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1037 pstrWFIDrv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
1039 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1043 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RTS_THRESHOLD) {
1044 /* range 256 to 65535 */
1045 if (strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold < 65536) {
1046 strWIDList[u8WidCnt].u16WIDid = WID_RTS_THRESHOLD;
1047 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
1048 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1049 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1050 pstrWFIDrv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
1052 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1056 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PREAMBLE) {
1057 /*-----------------------------------------------------*/
1058 /*Input Values: Short= 0, */
1061 /*------------------------------------------------------*/
1062 if (strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type < 3) {
1063 strWIDList[u8WidCnt].u16WIDid = WID_PREAMBLE;
1064 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
1065 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1066 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1067 pstrWFIDrv->strCfgValues.preamble_type = strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
1069 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1073 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SHORT_SLOT_ALLOWED) {
1074 if (strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed < 2) {
1075 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_SLOT_ALLOWED;
1076 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
1077 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1078 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1079 pstrWFIDrv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
1081 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1085 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & TXOP_PROT_DISABLE) {
1086 /*Description: used to Disable RTS-CTS protection for TXOP burst*/
1087 /*transmission when the acknowledgement policy is No-Ack or Block-Ack */
1088 /* this information is useful for external supplicant */
1089 /*Input Values: 1 for enable and 0 for disable. */
1090 if (strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled < 2) {
1091 strWIDList[u8WidCnt].u16WIDid = WID_11N_TXOP_PROT_DISABLE;
1092 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
1093 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1094 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1095 pstrWFIDrv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
1097 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1101 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BEACON_INTERVAL) {
1102 /* range is 1 to 65535. */
1103 if (strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval < 65536) {
1104 strWIDList[u8WidCnt].u16WIDid = WID_BEACON_INTERVAL;
1105 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
1106 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1107 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1108 pstrWFIDrv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
1110 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1114 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & DTIM_PERIOD) {
1115 /* range is 1 to 255. */
1116 if (strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period < 256) {
1117 strWIDList[u8WidCnt].u16WIDid = WID_DTIM_PERIOD;
1118 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
1119 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1120 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1121 pstrWFIDrv->strCfgValues.dtim_period = strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
1123 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1127 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY) {
1128 /*----------------------------------------------------------------------*/
1129 /*Input Values: SITE_SURVEY_1CH = 0, i.e.: currently set channel */
1130 /* SITE_SURVEY_ALL_CH = 1, */
1131 /* SITE_SURVEY_OFF = 2 */
1132 /*----------------------------------------------------------------------*/
1133 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled < 3) {
1134 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY;
1135 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
1136 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1137 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1138 pstrWFIDrv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
1140 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1144 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY_SCAN_TIME) {
1145 /* range is 1 to 65535. */
1146 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time < 65536) {
1147 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY_SCAN_TIME;
1148 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
1149 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1150 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1151 pstrWFIDrv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
1153 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1157 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & ACTIVE_SCANTIME) {
1158 /* range is 1 to 65535. */
1159 if (strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time < 65536) {
1160 strWIDList[u8WidCnt].u16WIDid = WID_ACTIVE_SCAN_TIME;
1161 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
1162 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1163 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1164 pstrWFIDrv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
1166 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1170 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PASSIVE_SCANTIME) {
1171 /* range is 1 to 65535. */
1172 if (strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time < 65536) {
1173 strWIDList[u8WidCnt].u16WIDid = WID_PASSIVE_SCAN_TIME;
1174 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
1175 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1176 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1177 pstrWFIDrv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
1179 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1183 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & CURRENT_TX_RATE) {
1184 CURRENT_TX_RATE_T curr_tx_rate = strHostIFCfgParamAttr->pstrCfgParamVal.curr_tx_rate;
1185 /*----------------------------------------------------------------------*/
1186 /*Rates: 1 2 5.5 11 6 9 12 18 24 36 48 54 Auto */
1187 /*InputValues: 1 2 3 4 5 6 7 8 9 10 11 12 0 */
1188 /*----------------------------------------------------------------------*/
1190 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
1191 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
1192 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
1193 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
1194 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
1195 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
1196 strWIDList[u8WidCnt].u16WIDid = WID_CURRENT_TX_RATE;
1197 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&curr_tx_rate;
1198 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1199 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1200 pstrWFIDrv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
1202 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1206 s32Error = SendConfigPkt(SET_CFG, strWIDList, u8WidCnt, false, (u32)pstrWFIDrv);
1209 PRINT_ER("Error in setting CFG params\n");
1212 WILC_CATCH(s32Error)
1215 up(&(pstrWFIDrv->gtOsCfgValuesSem));
1221 * @brief Handle_wait_msg_q_empty
1222 * @details this should be the last msg and then the msg Q becomes idle
1223 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1224 * @return Error code.
1229 static s32 Handle_wait_msg_q_empty(void)
1231 s32 s32Error = WILC_SUCCESS;
1232 g_wilc_initialized = 0;
1238 * @brief Handle_Scan
1239 * @details Sending config packet to firmware to set the scan params
1240 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1241 * @return Error code.
1246 static s32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr *pstrHostIFscanAttr)
1248 s32 s32Error = WILC_SUCCESS;
1249 tstrWID strWIDList[5];
1250 u32 u32WidsCount = 0;
1254 u8 *pu8HdnNtwrksWidVal = NULL;
1255 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
1257 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1258 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state \n", pstrWFIDrv->enuHostIFstate);
1260 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->pfScanResult;
1261 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->pvUserArg;
1265 if (pstrWFIDrv->enuHostIFstate == HOST_IF_P2P_LISTEN || (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED && pstrWFIDrv->u8P2PConnect)) {
1266 PRINT_INFO(GENERIC_DBG, "Busy: State: %d\n", pstrWFIDrv->enuHostIFstate);
1267 PRINT_INFO(GENERIC_DBG, "Current Jiffies: %lu Timeout:%llu\n", jiffies, pstrWFIDrv->u64P2p_MgmtTimeout);
1268 WILC_ERRORREPORT(s32Error, WILC_BUSY);
1273 if ((pstrWFIDrv->enuHostIFstate >= HOST_IF_SCANNING) && (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTED)) {
1274 /* here we either in HOST_IF_SCANNING, HOST_IF_WAITING_CONN_REQ or HOST_IF_WAITING_CONN_RESP */
1275 PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", pstrWFIDrv->enuHostIFstate);
1276 WILC_ERRORREPORT(s32Error, WILC_BUSY);
1279 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
1280 if (g_obtainingIP || connecting) {
1281 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
1282 WILC_ERRORREPORT(s32Error, WILC_BUSY);
1286 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1289 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount = 0;
1292 strWIDList[u32WidsCount].u16WIDid = (u16)WID_SSID_PROBE_REQ;
1293 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1295 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) {
1296 valuesize += ((pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
1298 pu8HdnNtwrksWidVal = WILC_MALLOC(valuesize + 1);
1299 strWIDList[u32WidsCount].ps8WidVal = pu8HdnNtwrksWidVal;
1300 if (strWIDList[u32WidsCount].ps8WidVal != NULL) {
1301 pu8Buffer = strWIDList[u32WidsCount].ps8WidVal;
1303 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum;
1305 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum);
1307 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) {
1308 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1309 WILC_memcpy(pu8Buffer, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen);
1310 pu8Buffer += pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1315 strWIDList[u32WidsCount].s32ValueSize = (s32)(valuesize + 1);
1319 /*filling cfg param array*/
1321 /* if((pstrHostIFscanAttr->pu8IEs != NULL) && (pstrHostIFscanAttr->IEsLen != 0)) */
1323 /* IEs to be inserted in Probe Request */
1324 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_PROBE;
1325 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1326 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8IEs;
1327 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->IEsLen;
1332 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_TYPE;
1333 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1334 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1335 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanType));
1338 /*list of channels to be scanned*/
1339 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_CHANNEL_LIST;
1340 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1342 /* Bug 4648: Convert channel numbers to start from 0 not 1. */
1343 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL && pstrHostIFscanAttr->u8ChnlListLen > 0) {
1346 for (i = 0; i < pstrHostIFscanAttr->u8ChnlListLen; i++) {
1347 if (pstrHostIFscanAttr->pu8ChnlFreqList[i] > 0) {
1348 pstrHostIFscanAttr->pu8ChnlFreqList[i] = pstrHostIFscanAttr->pu8ChnlFreqList[i] - 1;
1353 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8ChnlFreqList;
1354 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->u8ChnlListLen;
1358 strWIDList[u32WidsCount].u16WIDid = WID_START_SCAN_REQ;
1359 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1360 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1361 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanSource));
1364 /*keep the state as is , no need to change it*/
1365 /* gWFiDrvHandle->enuHostIFstate = HOST_IF_SCANNING; */
1367 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
1368 gbScanWhileConnected = true;
1369 } else if (pstrWFIDrv->enuHostIFstate == HOST_IF_IDLE) {
1370 gbScanWhileConnected = false;
1373 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, (u32)pstrWFIDrv);
1376 PRINT_ER("Failed to send scan paramters config packet\n");
1377 WILC_ERRORREPORT(s32Error, s32Error);
1379 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
1382 WILC_CATCH(s32Error)
1384 WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL);
1385 /*if there is an ongoing scan request*/
1386 Handle_ScanDone(drvHandler, SCAN_EVENT_ABORTED);
1389 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1390 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
1391 WILC_FREE(pstrHostIFscanAttr->pu8ChnlFreqList);
1392 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1395 /* Deallocate pstrHostIFscanAttr->pu8IEs which was previously allocated by the sending thread */
1396 if (pstrHostIFscanAttr->pu8IEs != NULL) {
1397 WILC_FREE(pstrHostIFscanAttr->pu8IEs);
1398 pstrHostIFscanAttr->pu8IEs = NULL;
1400 if (pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo != NULL) {
1401 WILC_FREE(pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo);
1402 pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo = NULL;
1405 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1406 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
1407 WILC_FREE(pstrHostIFscanAttr->pu8ChnlFreqList);
1408 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1411 if (pu8HdnNtwrksWidVal != NULL) {
1412 WILC_FREE(pu8HdnNtwrksWidVal);
1419 * @brief Handle_ScanDone
1420 * @details Call scan notification callback function
1422 * @return Error code.
1427 static s32 Handle_ScanDone(void *drvHandler, tenuScanEvent enuEvent)
1429 s32 s32Error = WILC_SUCCESS;
1431 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
1434 u8 u8abort_running_scan;
1438 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
1441 /*Ask FW to abort the running scan, if any*/
1442 if (enuEvent == SCAN_EVENT_ABORTED) {
1443 PRINT_D(GENERIC_DBG, "Abort running scan\n");
1444 u8abort_running_scan = 1;
1445 strWID.u16WIDid = (u16)WID_ABORT_RUNNING_SCAN;
1446 strWID.enuWIDtype = WID_CHAR;
1447 strWID.ps8WidVal = (s8 *)&u8abort_running_scan;
1448 strWID.s32ValueSize = sizeof(char);
1451 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
1452 if (s32Error != WILC_SUCCESS) {
1453 PRINT_ER("Failed to set abort running scan\n");
1454 WILC_ERRORREPORT(s32Error, WILC_FAIL);
1456 WILC_CATCH(s32Error)
1461 if (pstrWFIDrv == NULL) {
1462 PRINT_ER("Driver handler is NULL\n");
1466 /*if there is an ongoing scan request*/
1467 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
1468 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
1469 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
1470 /*delete current scan request*/
1471 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
1478 * @brief Handle_Connect
1479 * @details Sending config packet to firmware to starting connection
1480 * @param[in] tstrHostIFconnectAttr* pstrHostIFconnectAttr
1481 * @return Error code.
1486 u8 u8ConnectedSSID[6] = {0};
1487 static s32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrHostIFconnectAttr)
1489 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
1490 s32 s32Error = WILC_SUCCESS;
1491 tstrWID strWIDList[8];
1492 u32 u32WidsCount = 0, dummyval = 0;
1493 /* char passphrase[] = "12345678"; */
1494 #ifndef CONNECT_DIRECT
1495 s32 s32Err = WILC_SUCCESS;
1497 u8 u8bssDscListIndex;
1498 wid_site_survey_reslts_s *pstrSurveyResults = NULL;
1500 u8 *pu8CurrByte = NULL;
1501 /*Bug4218: Parsing Join Param*/
1502 #ifdef WILC_PARSE_SCAN_IN_HOST
1503 tstrJoinBssParam *ptstrJoinBssParam;
1504 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1508 PRINT_D(GENERIC_DBG, "Handling connect request\n");
1510 #ifndef CONNECT_DIRECT
1511 WILC_memset(gapu8RcvdSurveyResults[0], 0, MAX_SURVEY_RESULT_FRAG_SIZE);
1512 WILC_memset(gapu8RcvdSurveyResults[1], 0, MAX_SURVEY_RESULT_FRAG_SIZE);
1515 PRINT_D(HOSTINF_DBG, "Getting site survey results\n");
1516 s32Err = host_int_get_site_survey_results((WILC_WFIDrvHandle)pstrWFIDrv,
1517 gapu8RcvdSurveyResults,
1518 MAX_SURVEY_RESULT_FRAG_SIZE);
1520 PRINT_ER("Failed to get site survey results\n");
1521 WILC_ERRORREPORT(s32Error, WILC_FAIL);
1524 s32Err = ParseSurveyResults(gapu8RcvdSurveyResults, &pstrSurveyResults,
1525 &pstrWFIDrv->u32SurveyResultsCount);
1528 if (s32Err == WILC_SUCCESS) {
1529 /* use the parsed info in pstrSurveyResults, then deallocate it */
1530 PRINT_D(HOSTINF_DBG, "Copying site survey results in global structure, then deallocate\n");
1531 for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) {
1532 WILC_memcpy(&pstrWFIDrv->astrSurveyResults[i], &pstrSurveyResults[i],
1533 sizeof(wid_site_survey_reslts_s));
1536 DeallocateSurveyResults(pstrSurveyResults);
1538 WILC_ERRORREPORT(s32Error, WILC_FAIL);
1539 PRINT_ER("ParseSurveyResults() Error(%d) \n", s32Err);
1543 for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) {
1544 if (WILC_memcmp(pstrWFIDrv->astrSurveyResults[i].SSID,
1545 pstrHostIFconnectAttr->pu8ssid,
1546 pstrHostIFconnectAttr->ssidLen) == 0) {
1547 PRINT_INFO(HOSTINF_DBG, "Network with required SSID is found %s\n", pstrHostIFconnectAttr->pu8ssid);
1548 if (pstrHostIFconnectAttr->pu8bssid == NULL) {
1549 /* BSSID is not passed from the user, so decision of matching
1550 * is done by SSID only */
1551 PRINT_INFO(HOSTINF_DBG, "BSSID is not passed from the user\n");
1554 /* BSSID is also passed from the user, so decision of matching
1555 * should consider also this passed BSSID */
1557 if (WILC_memcmp(pstrWFIDrv->astrSurveyResults[i].BSSID,
1558 pstrHostIFconnectAttr->pu8bssid,
1560 PRINT_INFO(HOSTINF_DBG, "BSSID is passed from the user and matched\n");
1567 if (i < pstrWFIDrv->u32SurveyResultsCount) {
1568 u8bssDscListIndex = i;
1570 PRINT_INFO(HOSTINF_DBG, "Connecting to network of Bss Idx %d and SSID %s and channel %d \n",
1571 u8bssDscListIndex, pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].SSID,
1572 pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].Channel);
1574 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1576 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1577 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = (u8 *)WILC_MALLOC(6);
1578 WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
1581 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1582 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1583 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->ssidLen + 1);
1584 WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
1585 pstrHostIFconnectAttr->ssidLen);
1586 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1589 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1590 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1591 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->IEsLen);
1592 WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
1593 pstrHostIFconnectAttr->IEsLen);
1596 pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1597 pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1598 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1599 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1602 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1603 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1605 /* IEs to be inserted in Association Request */
1606 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1607 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1608 strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1609 strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1612 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
1613 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1614 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1615 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
1618 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1620 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
1621 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1622 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1623 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1626 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1628 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
1629 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1630 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
1631 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
1635 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ;
1636 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1637 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1638 strWIDList[u32WidsCount].ps8WidVal = (s8 *)&u8bssDscListIndex;
1642 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1643 * firmware at chip reset when processing the WIDs of the Connect Request.
1644 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1645 /* ////////////////////// */
1646 gu32WidConnRstHack = 0;
1647 /* ////////////////////// */
1650 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, (u32)pstrWFIDrv);
1652 PRINT_ER("Handle_Connect()] failed to send config packet\n");
1653 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
1655 pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1659 PRINT_ER("Required BSSID not found\n");
1660 WILC_ERRORREPORT(s32Error, WILC_NOT_FOUND);
1665 /* if we try to connect to an already connected AP then discard the request */
1667 if (WILC_memcmp(pstrHostIFconnectAttr->pu8bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
1669 s32Error = WILC_SUCCESS;
1670 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1674 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1676 /*Bug4218: Parsing Join Param*/
1677 #ifdef WILC_PARSE_SCAN_IN_HOST
1678 ptstrJoinBssParam = (tstrJoinBssParam *)pstrHostIFconnectAttr->pJoinParams;
1679 if (ptstrJoinBssParam == NULL) {
1680 PRINT_ER("Required BSSID not found\n");
1681 WILC_ERRORREPORT(s32Error, WILC_NOT_FOUND);
1683 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1686 /* if we try to connect to an already connected AP then discard the request */
1687 PRINT_D(GENERIC_DBG, "Bssid = %x:%x:%x:%x:%x:%x\n", (pstrHostIFconnectAttr->pu8bssid[0]), (pstrHostIFconnectAttr->pu8bssid[1]), (pstrHostIFconnectAttr->pu8bssid[2]), (pstrHostIFconnectAttr->pu8bssid[3]), (pstrHostIFconnectAttr->pu8bssid[4]), (pstrHostIFconnectAttr->pu8bssid[5]));
1688 PRINT_D(GENERIC_DBG, "bssid = %x:%x:%x:%x:%x:%x\n", (u8ConnectedSSID[0]), (u8ConnectedSSID[1]), (u8ConnectedSSID[2]), (u8ConnectedSSID[3]), (u8ConnectedSSID[4]), (u8ConnectedSSID[5]));
1689 if (WILC_memcmp(pstrHostIFconnectAttr->pu8bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
1690 PRINT_ER("Discard connect request\n");
1691 s32Error = WILC_FAIL;
1696 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1697 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = (u8 *)WILC_MALLOC(6);
1698 WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
1701 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1702 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1703 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->ssidLen + 1);
1704 WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
1705 pstrHostIFconnectAttr->ssidLen);
1706 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1709 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1710 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1711 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->IEsLen);
1712 WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
1713 pstrHostIFconnectAttr->IEsLen);
1716 pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1717 pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1718 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1719 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1721 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
1722 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
1723 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
1724 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
1727 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
1728 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
1729 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
1730 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
1733 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
1734 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
1735 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
1736 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
1739 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1740 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1742 /* IEs to be inserted in Association Request */
1743 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1744 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1745 strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1746 strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1750 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1752 gu32FlushedInfoElemAsocSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1753 gu8FlushedInfoElemAsoc = WILC_MALLOC(gu32FlushedInfoElemAsocSize);
1754 memcpy(gu8FlushedInfoElemAsoc, pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
1755 gu32FlushedInfoElemAsocSize);
1758 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
1759 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1760 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1761 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
1765 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
1766 gu8Flushed11iMode = pstrWFIDrv->strWILC_UsrConnReq.u8security;
1768 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1771 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
1772 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1773 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1774 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1778 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
1779 gu8FlushedAuthType = (u8)pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type;
1781 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1783 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
1784 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1785 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
1786 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
1790 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
1791 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->u8channel);
1794 #ifndef WILC_PARSE_SCAN_IN_HOST
1795 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
1796 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1797 strWIDList[u32WidsCount].s32ValueSize = MAX_SSID_LEN + 7;
1798 strWIDList[u32WidsCount].ps8WidVal = WILC_MALLOC(strWIDList[u32WidsCount].s32ValueSize);
1800 if (strWIDList[u32WidsCount].ps8WidVal == NULL) {
1801 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
1804 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1806 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1807 WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
1808 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1810 pu8CurrByte += MAX_SSID_LEN;
1811 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1812 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1814 PRINT_ER("Channel out of range\n");
1815 *(pu8CurrByte++) = 0xFF;
1817 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1818 WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
1822 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1823 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1827 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
1828 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1830 /*Sending NoA attributes during connection*/
1831 strWIDList[u32WidsCount].s32ValueSize = 112; /* 79; */
1832 strWIDList[u32WidsCount].ps8WidVal = WILC_MALLOC(strWIDList[u32WidsCount].s32ValueSize);
1835 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1836 gu32FlushedJoinReqSize = strWIDList[u32WidsCount].s32ValueSize;
1837 gu8FlushedJoinReq = WILC_MALLOC(gu32FlushedJoinReqSize);
1839 if (strWIDList[u32WidsCount].ps8WidVal == NULL) {
1840 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
1843 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1846 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1847 WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
1848 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1850 pu8CurrByte += MAX_SSID_LEN;
1853 *(pu8CurrByte++) = INFRASTRUCTURE;
1855 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1856 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1858 PRINT_ER("Channel out of range\n");
1859 *(pu8CurrByte++) = 0xFF;
1862 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1863 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1864 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1867 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1868 WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
1873 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1874 WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
1879 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1880 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1881 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1883 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1884 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1885 /* Supported rates*/
1886 WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
1887 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1890 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1891 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1893 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1896 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1897 /* copy this information to the user request */
1898 pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
1901 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1902 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1903 /* rsn group policy*/
1904 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1905 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1907 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1908 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1909 /* rsn pcip policy*/
1910 WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
1911 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1913 /* rsn auth policy*/
1914 WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
1915 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1917 /* rsn auth policy*/
1918 WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
1919 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1922 *(pu8CurrByte++) = REAL_JOIN_REQ;
1925 *(pu8CurrByte++) = ptstrJoinBssParam->u8NoaEnbaled;
1926 if (ptstrJoinBssParam->u8NoaEnbaled) {
1927 PRINT_D(HOSTINF_DBG, "NOA present\n");
1929 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1930 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1931 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1932 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1934 *(pu8CurrByte++) = ptstrJoinBssParam->u8Index;
1936 *(pu8CurrByte++) = ptstrJoinBssParam->u8OppEnable;
1938 if (ptstrJoinBssParam->u8OppEnable)
1939 *(pu8CurrByte++) = ptstrJoinBssParam->u8CtWindow;
1941 *(pu8CurrByte++) = ptstrJoinBssParam->u8Count;
1943 WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->au8Duration, sizeof(ptstrJoinBssParam->au8Duration));
1945 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Duration);
1947 WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->au8Interval, sizeof(ptstrJoinBssParam->au8Interval));
1949 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Interval);
1951 WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
1953 pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1956 PRINT_D(HOSTINF_DBG, "NOA not present\n");
1960 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1961 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1964 #endif /* #ifdef WILC_PARSE_SCAN_IN_HOST*/
1968 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1969 * firmware at chip reset when processing the WIDs of the Connect Request.
1970 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1971 /* ////////////////////// */
1972 gu32WidConnRstHack = 0;
1973 /* ////////////////////// */
1977 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1978 memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
1979 gu8FlushedJoinReqDrvHandler = (u32)pstrWFIDrv;
1982 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1984 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1985 WILC_memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->pu8bssid, ETH_ALEN);
1987 PRINT_D(GENERIC_DBG, "save Bssid = %x:%x:%x:%x:%x:%x\n", (pstrHostIFconnectAttr->pu8bssid[0]), (pstrHostIFconnectAttr->pu8bssid[1]), (pstrHostIFconnectAttr->pu8bssid[2]), (pstrHostIFconnectAttr->pu8bssid[3]), (pstrHostIFconnectAttr->pu8bssid[4]), (pstrHostIFconnectAttr->pu8bssid[5]));
1988 PRINT_D(GENERIC_DBG, "save bssid = %x:%x:%x:%x:%x:%x\n", (u8ConnectedSSID[0]), (u8ConnectedSSID[1]), (u8ConnectedSSID[2]), (u8ConnectedSSID[3]), (u8ConnectedSSID[4]), (u8ConnectedSSID[5]));
1991 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, (u32)pstrWFIDrv);
1993 PRINT_ER("Handle_Connect()] failed to send config packet\n");
1994 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
1996 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
1997 pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
2001 WILC_CATCH(s32Error)
2003 tstrConnectInfo strConnectInfo;
2005 WILC_TimerStop(&(pstrWFIDrv->hConnectTimer), NULL);
2007 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
2009 WILC_memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
2011 if (pstrHostIFconnectAttr->pfConnectResult != NULL) {
2012 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
2013 WILC_memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
2016 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
2017 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->IEsLen;
2018 strConnectInfo.pu8ReqIEs = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->IEsLen);
2019 WILC_memcpy(strConnectInfo.pu8ReqIEs,
2020 pstrHostIFconnectAttr->pu8IEs,
2021 pstrHostIFconnectAttr->IEsLen);
2024 pstrHostIFconnectAttr->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2028 pstrHostIFconnectAttr->pvUserArg);
2029 /*Change state to idle*/
2030 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2032 if (strConnectInfo.pu8ReqIEs != NULL) {
2033 WILC_FREE(strConnectInfo.pu8ReqIEs);
2034 strConnectInfo.pu8ReqIEs = NULL;
2038 PRINT_ER("Connect callback function pointer is NULL \n");
2042 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
2043 /* Deallocate pstrHostIFconnectAttr->pu8bssid which was prevoisuly allocated by the sending thread */
2044 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
2045 WILC_FREE(pstrHostIFconnectAttr->pu8bssid);
2046 pstrHostIFconnectAttr->pu8bssid = NULL;
2049 /* Deallocate pstrHostIFconnectAttr->pu8ssid which was prevoisuly allocated by the sending thread */
2050 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
2051 WILC_FREE(pstrHostIFconnectAttr->pu8ssid);
2052 pstrHostIFconnectAttr->pu8ssid = NULL;
2055 /* Deallocate pstrHostIFconnectAttr->pu8IEs which was prevoisuly allocated by the sending thread */
2056 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
2057 WILC_FREE(pstrHostIFconnectAttr->pu8IEs);
2058 pstrHostIFconnectAttr->pu8IEs = NULL;
2061 if (pu8CurrByte != NULL) {
2062 WILC_FREE(pu8CurrByte);
2068 * @brief Handle_FlushConnect
2069 * @details Sending config packet to firmware to flush an old connection
2070 * after switching FW from station one to hybrid one
2071 * @param[in] void * drvHandler
2072 * @return Error code.
2073 * @author Amr Abdel-Moghny
2078 static s32 Handle_FlushConnect(void *drvHandler)
2080 s32 s32Error = WILC_SUCCESS;
2081 tstrWID strWIDList[5];
2082 u32 u32WidsCount = 0;
2083 u8 *pu8CurrByte = NULL;
2086 /* IEs to be inserted in Association Request */
2087 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
2088 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
2089 strWIDList[u32WidsCount].ps8WidVal = gu8FlushedInfoElemAsoc;
2090 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedInfoElemAsocSize;
2093 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
2094 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
2095 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
2096 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(gu8Flushed11iMode));
2101 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
2102 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
2103 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
2104 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&gu8FlushedAuthType);
2108 #ifdef WILC_PARSE_SCAN_IN_HOST
2109 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
2110 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
2111 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedJoinReqSize;
2112 strWIDList[u32WidsCount].ps8WidVal = (s8 *)gu8FlushedJoinReq;
2113 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
2115 pu8CurrByte += FLUSHED_BYTE_POS;
2116 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
2122 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, gu8FlushedJoinReqDrvHandler);
2124 PRINT_ER("Handle_Flush_Connect()] failed to send config packet\n");
2125 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
2128 WILC_CATCH(s32Error)
2137 * @brief Handle_ConnectTimeout
2138 * @details Call connect notification callback function indicating connection failure
2140 * @return Error code.
2145 static s32 Handle_ConnectTimeout(void *drvHandler)
2147 s32 s32Error = WILC_SUCCESS;
2148 tstrConnectInfo strConnectInfo;
2150 u16 u16DummyReasonCode = 0;
2151 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
2153 if (pstrWFIDrv == NULL) {
2154 PRINT_ER("Driver handler is NULL\n");
2158 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2160 gbScanWhileConnected = false;
2163 WILC_memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
2166 /* First, we will notify the upper layer with the Connection failure {through the Connect Callback function},
2167 * then we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2168 * WID_DISCONNECT} */
2169 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2170 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2171 WILC_memcpy(strConnectInfo.au8bssid,
2172 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
2175 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2176 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
2177 strConnectInfo.pu8ReqIEs = (u8 *)WILC_MALLOC(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2178 WILC_memcpy(strConnectInfo.pu8ReqIEs,
2179 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2180 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2183 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2187 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2189 /* Deallocation of strConnectInfo.pu8ReqIEs */
2190 if (strConnectInfo.pu8ReqIEs != NULL) {
2191 WILC_FREE(strConnectInfo.pu8ReqIEs);
2192 strConnectInfo.pu8ReqIEs = NULL;
2195 PRINT_ER("Connect callback function pointer is NULL \n");
2198 /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2199 * WID_DISCONNECT} */
2200 strWID.u16WIDid = (u16)WID_DISCONNECT;
2201 strWID.enuWIDtype = WID_CHAR;
2202 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
2203 strWID.s32ValueSize = sizeof(char);
2205 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2207 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
2209 PRINT_ER("Failed to send dissconect config packet\n");
2212 /* Deallocation of the Saved Connect Request in the global Handle */
2213 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2214 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
2215 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
2216 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2219 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2220 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
2221 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2224 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2225 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2226 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
2227 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2230 WILC_memset(u8ConnectedSSID, 0, ETH_ALEN);
2232 /*Freeing flushed join request params on connect timeout*/
2233 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
2234 WILC_FREE(gu8FlushedJoinReq);
2235 gu8FlushedJoinReq = NULL;
2237 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
2238 WILC_FREE(gu8FlushedInfoElemAsoc);
2239 gu8FlushedInfoElemAsoc = NULL;
2246 * @brief Handle_RcvdNtwrkInfo
2247 * @details Handling received network information
2248 * @param[in] tstrRcvdNetworkInfo* pstrRcvdNetworkInfo
2249 * @return Error code.
2254 static s32 Handle_RcvdNtwrkInfo(void *drvHandler, tstrRcvdNetworkInfo *pstrRcvdNetworkInfo)
2257 bool bNewNtwrkFound;
2261 s32 s32Error = WILC_SUCCESS;
2262 tstrNetworkInfo *pstrNetworkInfo = NULL;
2263 void *pJoinParams = NULL;
2265 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2269 bNewNtwrkFound = true;
2270 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
2272 /*if there is a an ongoing scan request*/
2273 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2274 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
2275 ParseNetworkInfo(pstrRcvdNetworkInfo->pu8Buffer, &pstrNetworkInfo);
2276 if ((pstrNetworkInfo == NULL)
2277 || (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
2278 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
2281 /* check whether this network is discovered before */
2282 for (i = 0; i < pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
2284 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
2285 (pstrNetworkInfo->au8bssid != NULL)) {
2286 if (WILC_memcmp(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
2287 pstrNetworkInfo->au8bssid, 6) == 0) {
2288 if (pstrNetworkInfo->s8rssi <= pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
2289 /*we have already found this network with better rssi, so keep the old cached one and don't
2290 * send anything to the upper layer */
2291 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
2294 /* here the same already found network is found again but with a better rssi, so just update
2295 * the rssi for this cached network and send this updated network to the upper layer but
2296 * don't add a new record for it */
2297 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
2298 bNewNtwrkFound = false;
2305 if (bNewNtwrkFound == true) {
2306 /* here it is confirmed that it is a new discovered network,
2307 * so add its record then call the User CallBack function */
2309 PRINT_D(HOSTINF_DBG, "New network found\n");
2311 if (pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
2312 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
2314 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
2315 && (pstrNetworkInfo->au8bssid != NULL)) {
2316 WILC_memcpy(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
2317 pstrNetworkInfo->au8bssid, 6);
2319 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount++;
2321 pstrNetworkInfo->bNewNetwork = true;
2322 /*Bug4218: Parsing Join Param*/
2323 /* add new BSS to JoinBssTable */
2324 #ifdef WILC_PARSE_SCAN_IN_HOST
2325 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
2326 #endif /*WILC_PARSE_SCAN_IN_HOST*/
2328 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2329 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid,
2335 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit \n");
2338 pstrNetworkInfo->bNewNetwork = false;
2339 /* just call the User CallBack function to send the same discovered network with its updated RSSI */
2340 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2341 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2346 WILC_CATCH(s32Error)
2352 /* Deallocate pstrRcvdNetworkInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2353 if (pstrRcvdNetworkInfo->pu8Buffer != NULL) {
2354 WILC_FREE(pstrRcvdNetworkInfo->pu8Buffer);
2355 pstrRcvdNetworkInfo->pu8Buffer = NULL;
2358 /*free structure allocated*/
2359 if (pstrNetworkInfo != NULL) {
2360 DeallocateNetworkInfo(pstrNetworkInfo);
2361 pstrNetworkInfo = NULL;
2368 * @brief Handle_RcvdGnrlAsyncInfo
2369 * @details Handling received asynchrous general network information
2370 * @param[in] tstrRcvdGnrlAsyncInfo* pstrRcvdGnrlAsyncInfo
2371 * @return Error code.
2376 static s32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncInfo *pstrRcvdGnrlAsyncInfo)
2378 /* TODO: mostafa: till now, this function just handles only the received mac status msg, */
2379 /* which carries only 1 WID which have WID ID = WID_STATUS */
2380 s32 s32Error = WILC_SUCCESS;
2384 u16 u16WidID = (u16)WID_NIL;
2387 u8 u8MacStatusReasonCode;
2388 u8 u8MacStatusAdditionalInfo;
2389 tstrConnectInfo strConnectInfo;
2390 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2391 s32 s32Err = WILC_SUCCESS;
2392 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
2393 if (pstrWFIDrv == NULL) {
2394 PRINT_ER("Driver handler is NULL\n");
2396 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", pstrWFIDrv->enuHostIFstate,
2397 pstrRcvdGnrlAsyncInfo->pu8Buffer[7]);
2399 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
2400 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) ||
2401 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2402 if ((pstrRcvdGnrlAsyncInfo->pu8Buffer == NULL) ||
2403 (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
2404 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
2407 u8MsgType = pstrRcvdGnrlAsyncInfo->pu8Buffer[0];
2409 /* Check whether the received message type is 'I' */
2410 if ('I' != u8MsgType) {
2411 PRINT_ER("Received Message format incorrect.\n");
2412 WILC_ERRORREPORT(s32Error, WILC_FAIL);
2415 /* Extract message ID */
2416 u8MsgID = pstrRcvdGnrlAsyncInfo->pu8Buffer[1];
2418 /* Extract message Length */
2419 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[2], pstrRcvdGnrlAsyncInfo->pu8Buffer[3]);
2421 /* Extract WID ID [expected to be = WID_STATUS] */
2422 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[4], pstrRcvdGnrlAsyncInfo->pu8Buffer[5]);
2424 /* Extract WID Length [expected to be = 1] */
2425 u8WidLen = pstrRcvdGnrlAsyncInfo->pu8Buffer[6];
2427 /* get the WID value [expected to be one of two values: either MAC_CONNECTED = (1) or MAC_DISCONNECTED = (0)] */
2428 u8MacStatus = pstrRcvdGnrlAsyncInfo->pu8Buffer[7];
2429 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->pu8Buffer[8];
2430 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->pu8Buffer[9];
2431 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2432 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2433 /* our station had sent Association Request frame, so here it will get the Association Response frame then parse it */
2434 u32 u32RcvdAssocRespInfoLen;
2435 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
2437 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2439 WILC_memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
2441 if (u8MacStatus == MAC_CONNECTED) {
2442 WILC_memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
2444 host_int_get_assoc_res_info((WILC_WFIDrvHandle)pstrWFIDrv,
2446 MAX_ASSOC_RESP_FRAME_SIZE,
2447 &u32RcvdAssocRespInfoLen);
2449 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
2451 if (u32RcvdAssocRespInfoLen != 0) {
2453 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
2454 s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
2455 &pstrConnectRespInfo);
2457 PRINT_ER("ParseAssocRespInfo() returned error %d \n", s32Err);
2459 /* use the necessary parsed Info from the Received Association Response */
2460 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
2462 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
2463 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
2464 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
2465 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
2468 strConnectInfo.pu8RespIEs = (u8 *)WILC_MALLOC(pstrConnectRespInfo->u16RespIEsLen);
2469 WILC_memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
2470 pstrConnectRespInfo->u16RespIEsLen);
2474 /* deallocate the Assoc. Resp. parsed structure as it is not needed anymore */
2475 if (pstrConnectRespInfo != NULL) {
2476 DeallocateAssocRespInfo(pstrConnectRespInfo);
2477 pstrConnectRespInfo = NULL;
2483 /* The station has just received mac status and it also received assoc. response which
2484 * it was waiting for.
2485 * So check first the matching between the received mac status and the received status code in Asoc Resp */
2486 if ((u8MacStatus == MAC_CONNECTED) &&
2487 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
2488 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE \n");
2489 WILC_memset(u8ConnectedSSID, 0, ETH_ALEN);
2491 } else if (u8MacStatus == MAC_DISCONNECTED) {
2492 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
2493 WILC_memset(u8ConnectedSSID, 0, ETH_ALEN);
2496 /* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */
2497 /* through a structure of type tstrConnectRespInfo */
2498 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2499 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
2500 WILC_memcpy(strConnectInfo.au8bssid, pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
2502 if ((u8MacStatus == MAC_CONNECTED) &&
2503 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
2504 WILC_memcpy(pstrWFIDrv->au8AssociatedBSSID,
2505 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
2510 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2511 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
2512 strConnectInfo.pu8ReqIEs = (u8 *)WILC_MALLOC(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2513 WILC_memcpy(strConnectInfo.pu8ReqIEs,
2514 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2515 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2519 WILC_TimerStop(&(pstrWFIDrv->hConnectTimer), NULL);
2520 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2524 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2527 /* if received mac status is MAC_CONNECTED and
2528 * received status code in Asoc Resp is SUCCESSFUL_STATUSCODE, change state to CONNECTED
2529 * else change state to IDLE */
2530 if ((u8MacStatus == MAC_CONNECTED) &&
2531 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
2532 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2534 host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 0, 0);
2537 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
2538 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTED;
2540 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2541 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
2542 g_obtainingIP = true;
2543 WILC_TimerStart(&hDuringIpTimer, 10000, NULL, NULL);
2546 #ifdef WILC_PARSE_SCAN_IN_HOST
2547 /* open a BA session if possible */
2548 /* if(pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable) */
2552 /* host_int_addBASession(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid,0, */
2553 /* BA_SESSION_DEFAULT_BUFFER_SIZE,BA_SESSION_DEFAULT_TIMEOUT); */
2555 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
2556 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2557 gbScanWhileConnected = false;
2561 if (strConnectInfo.pu8RespIEs != NULL) {
2562 WILC_FREE(strConnectInfo.pu8RespIEs);
2563 strConnectInfo.pu8RespIEs = NULL;
2566 if (strConnectInfo.pu8ReqIEs != NULL) {
2567 WILC_FREE(strConnectInfo.pu8ReqIEs);
2568 strConnectInfo.pu8ReqIEs = NULL;
2572 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2573 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
2574 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
2575 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2578 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2579 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
2580 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2583 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2584 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2585 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
2586 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2589 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2590 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)) {
2591 /* Disassociation or Deauthentication frame has been received */
2592 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
2594 WILC_memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
2596 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2597 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >> \n\n");
2598 WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL);
2599 Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED);
2602 strDisconnectNotifInfo.u16reason = 0;
2603 strDisconnectNotifInfo.ie = NULL;
2604 strDisconnectNotifInfo.ie_len = 0;
2606 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2607 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2609 g_obtainingIP = false;
2610 host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 0, 0);
2613 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
2616 &strDisconnectNotifInfo,
2617 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2620 PRINT_ER("Connect result callback function is NULL \n");
2623 WILC_memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
2628 /* if Information Elements were retrieved from the Received deauth/disassoc frame, then they
2629 * should be deallocated here */
2631 * if(strDisconnectNotifInfo.ie != NULL)
2633 * WILC_FREE(strDisconnectNotifInfo.ie);
2634 * strDisconnectNotifInfo.ie = NULL;
2638 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2639 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
2640 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
2641 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2644 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2645 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
2646 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2649 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2650 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2651 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
2652 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2656 /*Freeing flushed join request params on receiving*/
2657 /*MAC_DISCONNECTED while connected*/
2658 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
2659 WILC_FREE(gu8FlushedJoinReq);
2660 gu8FlushedJoinReq = NULL;
2662 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
2663 WILC_FREE(gu8FlushedInfoElemAsoc);
2664 gu8FlushedInfoElemAsoc = NULL;
2667 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2668 gbScanWhileConnected = false;
2670 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2671 (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
2672 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
2673 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >> \n\n");
2674 /*Abort the running scan*/
2675 WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL);
2676 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2677 Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED);
2684 WILC_CATCH(s32Error)
2689 /* Deallocate pstrRcvdGnrlAsyncInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2690 if (pstrRcvdGnrlAsyncInfo->pu8Buffer != NULL) {
2691 WILC_FREE(pstrRcvdGnrlAsyncInfo->pu8Buffer);
2692 pstrRcvdGnrlAsyncInfo->pu8Buffer = NULL;
2700 * @details Sending config packet to firmware to set key
2701 * @param[in] tstrHostIFkeyAttr* pstrHostIFkeyAttr
2702 * @return Error code.
2707 static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr)
2709 s32 s32Error = WILC_SUCCESS;
2711 #ifdef WILC_AP_EXTERNAL_MLME
2712 tstrWID strWIDList[5];
2718 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2721 switch (pstrHostIFkeyAttr->enuKeyType) {
2726 #ifdef WILC_AP_EXTERNAL_MLME
2727 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2729 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
2730 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
2731 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
2732 strWIDList[0].enuWIDtype = WID_CHAR;
2733 strWIDList[0].s32ValueSize = sizeof(char);
2734 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8mode));
2736 strWIDList[1].u16WIDid = WID_AUTH_TYPE;
2737 strWIDList[1].enuWIDtype = WID_CHAR;
2738 strWIDList[1].s32ValueSize = sizeof(char);
2739 strWIDList[1].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type));
2741 strWIDList[2].u16WIDid = (u16)WID_KEY_ID;
2742 strWIDList[2].enuWIDtype = WID_CHAR;
2744 strWIDList[2].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
2745 strWIDList[2].s32ValueSize = sizeof(char);
2748 pu8keybuf = (u8 *)WILC_MALLOC(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2751 if (pu8keybuf == NULL) {
2752 PRINT_ER("No buffer to send Key\n");
2756 WILC_memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
2757 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2760 WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
2762 strWIDList[3].u16WIDid = (u16)WID_WEP_KEY_VALUE;
2763 strWIDList[3].enuWIDtype = WID_STR;
2764 strWIDList[3].s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen;
2765 strWIDList[3].ps8WidVal = (s8 *)pu8keybuf;
2768 s32Error = SendConfigPkt(SET_CFG, strWIDList, 4, true, (u32)pstrWFIDrv);
2769 WILC_FREE(pu8keybuf);
2775 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2776 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
2777 pu8keybuf = (u8 *)WILC_MALLOC(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2);
2778 if (pu8keybuf == NULL) {
2779 PRINT_ER("No buffer to send Key\n");
2782 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2784 WILC_memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, 1);
2786 WILC_memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
2787 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2789 WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
2791 strWID.u16WIDid = (u16)WID_ADD_WEP_KEY;
2792 strWID.enuWIDtype = WID_STR;
2793 strWID.ps8WidVal = (s8 *)pu8keybuf;
2794 strWID.s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2;
2796 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2797 WILC_FREE(pu8keybuf);
2798 } else if (pstrHostIFkeyAttr->u8KeyAction & REMOVEKEY) {
2800 PRINT_D(HOSTINF_DBG, "Removing key\n");
2801 strWID.u16WIDid = (u16)WID_REMOVE_WEP_KEY;
2802 strWID.enuWIDtype = WID_STR;
2804 s8idxarray[0] = (s8)pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2805 strWID.ps8WidVal = s8idxarray;
2806 strWID.s32ValueSize = 1;
2808 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2810 strWID.u16WIDid = (u16)WID_KEY_ID;
2811 strWID.enuWIDtype = WID_CHAR;
2812 strWID.ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
2813 strWID.s32ValueSize = sizeof(char);
2815 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
2817 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2819 up(&(pstrWFIDrv->hSemTestKeyBlock));
2823 #ifdef WILC_AP_EXTERNAL_MLME
2824 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2825 pu8keybuf = (u8 *)WILC_MALLOC(RX_MIC_KEY_MSG_LEN);
2826 if (pu8keybuf == NULL) {
2827 PRINT_ER("No buffer to send RxGTK Key\n");
2829 goto _WPARxGtk_end_case_;
2832 WILC_memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
2835 /*|----------------------------------------------------------------------------|
2836 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2837 * |------------|---------|-------|------------|---------------|----------------|
2838 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2842 if (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq != NULL)
2843 WILC_memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
2846 WILC_memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2848 WILC_memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2850 WILC_memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2851 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2852 /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */
2853 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
2854 strWIDList[0].enuWIDtype = WID_CHAR;
2855 strWIDList[0].s32ValueSize = sizeof(char);
2856 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
2858 strWIDList[1].u16WIDid = (u16)WID_ADD_RX_GTK;
2859 strWIDList[1].enuWIDtype = WID_STR;
2860 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
2861 strWIDList[1].s32ValueSize = RX_MIC_KEY_MSG_LEN;
2863 s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, true, (u32)pstrWFIDrv);
2865 WILC_FREE(pu8keybuf);
2867 /* ////////////////////////// */
2868 up(&(pstrWFIDrv->hSemTestKeyBlock));
2869 /* ///////////////////////// */
2873 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2874 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
2876 pu8keybuf = (u8 *)WILC_MALLOC(RX_MIC_KEY_MSG_LEN);
2877 if (pu8keybuf == NULL) {
2878 PRINT_ER("No buffer to send RxGTK Key\n");
2880 goto _WPARxGtk_end_case_;
2883 WILC_memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
2886 /*|----------------------------------------------------------------------------|
2887 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2888 * |------------|---------|-------|------------|---------------|----------------|
2889 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2891 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
2892 WILC_memcpy(pu8keybuf, pstrWFIDrv->au8AssociatedBSSID, ETH_ALEN);
2894 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED \n");
2897 WILC_memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
2899 WILC_memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2901 WILC_memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2902 WILC_memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2903 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2905 strWID.u16WIDid = (u16)WID_ADD_RX_GTK;
2906 strWID.enuWIDtype = WID_STR;
2907 strWID.ps8WidVal = (s8 *)pu8keybuf;
2908 strWID.s32ValueSize = RX_MIC_KEY_MSG_LEN;
2910 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2912 WILC_FREE(pu8keybuf);
2914 /* ////////////////////////// */
2915 up(&(pstrWFIDrv->hSemTestKeyBlock));
2916 /* ///////////////////////// */
2918 _WPARxGtk_end_case_:
2919 WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
2920 WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq);
2927 #ifdef WILC_AP_EXTERNAL_MLME
2928 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2931 pu8keybuf = (u8 *)WILC_MALLOC(PTK_KEY_MSG_LEN + 1);
2935 if (pu8keybuf == NULL) {
2936 PRINT_ER("No buffer to send PTK Key\n");
2938 goto _WPAPtk_end_case_;
2942 /*|-----------------------------------------------------------------------------|
2943 * |Station address | keyidx |Key Length |Temporal Key | Rx Michael Key |Tx Michael Key |
2944 * |----------------|------------ |--------------|----------------|---------------|
2945 | 6 bytes | 1 byte | 1byte | 16 bytes | 8 bytes | 8 bytes |
2946 |-----------------------------------------------------------------------------|*/
2948 WILC_memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
2950 WILC_memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2951 WILC_memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2953 WILC_memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2954 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2957 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
2958 strWIDList[0].enuWIDtype = WID_CHAR;
2959 strWIDList[0].s32ValueSize = sizeof(char);
2960 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
2962 strWIDList[1].u16WIDid = (u16)WID_ADD_PTK;
2963 strWIDList[1].enuWIDtype = WID_STR;
2964 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
2965 strWIDList[1].s32ValueSize = PTK_KEY_MSG_LEN + 1;
2967 s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, true, (u32)pstrWFIDrv);
2968 WILC_FREE(pu8keybuf);
2970 /* ////////////////////////// */
2971 up(&(pstrWFIDrv->hSemTestKeyBlock));
2972 /* ///////////////////////// */
2975 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2978 pu8keybuf = (u8 *)WILC_MALLOC(PTK_KEY_MSG_LEN);
2982 if (pu8keybuf == NULL) {
2983 PRINT_ER("No buffer to send PTK Key\n");
2985 goto _WPAPtk_end_case_;
2989 /*|-----------------------------------------------------------------------------|
2990 * |Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
2991 * |----------------|------------|--------------|----------------|---------------|
2992 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
2993 |-----------------------------------------------------------------------------|*/
2995 WILC_memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
2997 WILC_memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2999 WILC_memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
3000 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
3003 strWID.u16WIDid = (u16)WID_ADD_PTK;
3004 strWID.enuWIDtype = WID_STR;
3005 strWID.ps8WidVal = (s8 *)pu8keybuf;
3006 strWID.s32ValueSize = PTK_KEY_MSG_LEN;
3008 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3009 WILC_FREE(pu8keybuf);
3011 /* ////////////////////////// */
3012 up(&(pstrWFIDrv->hSemTestKeyBlock));
3013 /* ///////////////////////// */
3017 WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
3026 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
3028 pu8keybuf = (u8 *)WILC_MALLOC((pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1);
3029 if (pu8keybuf == NULL) {
3030 PRINT_ER("No buffer to send PMKSA Key\n");
3034 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid;
3036 for (i = 0; i < pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid; i++) {
3038 WILC_memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, ETH_ALEN);
3039 WILC_memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, PMKID_LEN);
3042 strWID.u16WIDid = (u16)WID_PMKID_INFO;
3043 strWID.enuWIDtype = WID_STR;
3044 strWID.ps8WidVal = (s8 *)pu8keybuf;
3045 strWID.s32ValueSize = (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1;
3047 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3049 WILC_FREE(pu8keybuf);
3054 PRINT_ER("Failed to send key config packet\n");
3062 * @brief Handle_Disconnect
3063 * @details Sending config packet to firmware to disconnect
3070 static void Handle_Disconnect(void *drvHandler)
3074 s32 s32Error = WILC_SUCCESS;
3075 u16 u16DummyReasonCode = 0;
3076 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3079 strWID.u16WIDid = (u16)WID_DISCONNECT;
3080 strWID.enuWIDtype = WID_CHAR;
3081 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
3082 strWID.s32ValueSize = sizeof(char);
3086 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
3088 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3090 g_obtainingIP = false;
3091 host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 0, 0);
3094 WILC_memset(u8ConnectedSSID, 0, ETH_ALEN);
3096 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3099 PRINT_ER("Failed to send dissconect config packet\n");
3100 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3102 tstrDisconnectNotifInfo strDisconnectNotifInfo;
3104 WILC_memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
3106 strDisconnectNotifInfo.u16reason = 0;
3107 strDisconnectNotifInfo.ie = NULL;
3108 strDisconnectNotifInfo.ie_len = 0;
3110 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
3111 WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL);
3112 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
3113 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
3115 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
3118 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
3121 /*Stop connect timer, if connection in progress*/
3122 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3123 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
3124 WILC_TimerStop(&(pstrWFIDrv->hConnectTimer), NULL);
3127 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
3128 0, &strDisconnectNotifInfo, pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
3130 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL \n");
3133 gbScanWhileConnected = false;
3135 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
3137 WILC_memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
3141 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
3142 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
3143 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
3144 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
3147 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
3148 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
3149 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
3152 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
3153 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
3154 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
3155 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
3160 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
3161 WILC_FREE(gu8FlushedJoinReq);
3162 gu8FlushedJoinReq = NULL;
3164 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
3165 WILC_FREE(gu8FlushedInfoElemAsoc);
3166 gu8FlushedInfoElemAsoc = NULL;
3171 WILC_CATCH(s32Error)
3176 /* ////////////////////////// */
3177 up(&(pstrWFIDrv->hSemTestDisconnectBlock));
3178 /* ///////////////////////// */
3183 void resolve_disconnect_aberration(void *drvHandler)
3185 tstrWILC_WFIDrv *pstrWFIDrv;
3187 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3188 if (pstrWFIDrv == NULL)
3190 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTING)) {
3191 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
3192 host_int_disconnect((WILC_WFIDrvHandle)pstrWFIDrv, 1);
3195 static s32 Switch_Log_Terminal(void *drvHandler)
3199 s32 s32Error = WILC_SUCCESS;
3201 static char dummy = 9;
3202 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3204 strWID.u16WIDid = (u16)WID_LOGTerminal_Switch;
3205 strWID.enuWIDtype = WID_CHAR;
3206 strWID.ps8WidVal = &dummy;
3207 strWID.s32ValueSize = sizeof(char);
3209 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3213 PRINT_D(HOSTINF_DBG, "Failed to switch log terminal\n");
3214 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
3216 PRINT_INFO(HOSTINF_DBG, "MAC address set :: \n");
3221 WILC_CATCH(s32Error)
3230 * @brief Handle_GetChnl
3231 * @details Sending config packet to get channel
3239 static s32 Handle_GetChnl(void *drvHandler)
3242 s32 s32Error = WILC_SUCCESS;
3244 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
3245 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3246 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
3247 strWID.enuWIDtype = WID_CHAR;
3248 strWID.ps8WidVal = (s8 *)&gu8Chnl;
3249 strWID.s32ValueSize = sizeof(char);
3251 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
3253 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3254 /*get the value by searching the local copy*/
3256 PRINT_ER("Failed to get channel number\n");
3257 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3261 WILC_CATCH(s32Error)
3265 up(&(pstrWFIDrv->hSemGetCHNL));
3275 * @brief Handle_GetRssi
3276 * @details Sending config packet to get RSSI
3283 static void Handle_GetRssi(void *drvHandler)
3285 s32 s32Error = WILC_SUCCESS;
3287 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3289 strWID.u16WIDid = (u16)WID_RSSI;
3290 strWID.enuWIDtype = WID_CHAR;
3291 strWID.ps8WidVal = &gs8Rssi;
3292 strWID.s32ValueSize = sizeof(char);
3295 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
3297 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3299 PRINT_ER("Failed to get RSSI value\n");
3300 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3303 WILC_CATCH(s32Error)
3307 up(&(pstrWFIDrv->hSemGetRSSI));
3313 static void Handle_GetLinkspeed(void *drvHandler)
3315 s32 s32Error = WILC_SUCCESS;
3317 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3321 strWID.u16WIDid = (u16)WID_LINKSPEED;
3322 strWID.enuWIDtype = WID_CHAR;
3323 strWID.ps8WidVal = &gs8lnkspd;
3324 strWID.s32ValueSize = sizeof(char);
3326 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
3328 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3330 PRINT_ER("Failed to get LINKSPEED value\n");
3331 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3334 WILC_CATCH(s32Error)
3338 up(&(pstrWFIDrv->hSemGetLINKSPEED));
3343 s32 Handle_GetStatistics(void *drvHandler, tstrStatistics *pstrStatistics)
3345 tstrWID strWIDList[5];
3346 uint32_t u32WidsCount = 0, s32Error = 0;
3348 strWIDList[u32WidsCount].u16WIDid = WID_LINKSPEED;
3349 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
3350 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
3351 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u8LinkSpeed));
3354 strWIDList[u32WidsCount].u16WIDid = WID_RSSI;
3355 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
3356 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
3357 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->s8RSSI));
3360 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
3361 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
3362 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
3363 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxCount));
3366 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
3367 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
3368 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
3369 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32RxCount));
3372 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
3373 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
3374 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
3375 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxFailureCount));
3378 s32Error = SendConfigPkt(GET_CFG, strWIDList, u32WidsCount, false, (u32)drvHandler);
3381 PRINT_ER("Failed to send scan paramters config packet\n");
3382 /* WILC_ERRORREPORT(s32Error, s32Error); */
3390 #ifdef WILC_AP_EXTERNAL_MLME
3394 * @brief Handle_Get_InActiveTime
3395 * @details Sending config packet to set mac adddress for station and
3404 static s32 Handle_Get_InActiveTime(void *drvHandler, tstrHostIfStaInactiveT *strHostIfStaInactiveT)
3407 s32 s32Error = WILC_SUCCESS;
3410 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3413 strWID.u16WIDid = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
3414 strWID.enuWIDtype = WID_STR;
3415 strWID.s32ValueSize = ETH_ALEN;
3416 strWID.ps8WidVal = (u8 *)WILC_MALLOC(strWID.s32ValueSize);
3419 stamac = strWID.ps8WidVal;
3420 WILC_memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
3423 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
3426 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3427 /*get the value by searching the local copy*/
3429 PRINT_ER("Failed to SET incative time\n");
3430 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3434 strWID.u16WIDid = (u16)WID_GET_INACTIVE_TIME;
3435 strWID.enuWIDtype = WID_INT;
3436 strWID.ps8WidVal = (s8 *)&gu32InactiveTime;
3437 strWID.s32ValueSize = sizeof(u32);
3440 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3441 /*get the value by searching the local copy*/
3443 PRINT_ER("Failed to get incative time\n");
3444 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3448 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
3450 up(&(pstrWFIDrv->hSemInactiveTime));
3451 WILC_CATCH(s32Error)
3465 * @brief Handle_AddBeacon
3466 * @details Sending config packet to add beacon
3467 * @param[in] tstrHostIFSetBeacon* pstrSetBeaconParam
3473 static void Handle_AddBeacon(void *drvHandler, tstrHostIFSetBeacon *pstrSetBeaconParam)
3475 s32 s32Error = WILC_SUCCESS;
3478 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3479 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
3481 strWID.u16WIDid = (u16)WID_ADD_BEACON;
3482 strWID.enuWIDtype = WID_BIN;
3483 strWID.s32ValueSize = pstrSetBeaconParam->u32HeadLen + pstrSetBeaconParam->u32TailLen + 16;
3484 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3485 if (strWID.ps8WidVal == NULL) {
3486 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3489 pu8CurrByte = strWID.ps8WidVal;
3490 *pu8CurrByte++ = (pstrSetBeaconParam->u32Interval & 0xFF);
3491 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 8) & 0xFF);
3492 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 16) & 0xFF);
3493 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 24) & 0xFF);
3495 *pu8CurrByte++ = (pstrSetBeaconParam->u32DTIMPeriod & 0xFF);
3496 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 8) & 0xFF);
3497 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 16) & 0xFF);
3498 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 24) & 0xFF);
3500 *pu8CurrByte++ = (pstrSetBeaconParam->u32HeadLen & 0xFF);
3501 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 8) & 0xFF);
3502 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 16) & 0xFF);
3503 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 24) & 0xFF);
3505 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Head, pstrSetBeaconParam->u32HeadLen);
3506 pu8CurrByte += pstrSetBeaconParam->u32HeadLen;
3508 *pu8CurrByte++ = (pstrSetBeaconParam->u32TailLen & 0xFF);
3509 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 8) & 0xFF);
3510 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 16) & 0xFF);
3511 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 24) & 0xFF);
3513 /* Bug 4599 : if tail length = 0 skip copying */
3514 if (pstrSetBeaconParam->pu8Tail > 0)
3515 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Tail, pstrSetBeaconParam->u32TailLen);
3516 pu8CurrByte += pstrSetBeaconParam->u32TailLen;
3521 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3523 PRINT_ER("Failed to send add beacon config packet\n");
3524 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3527 WILC_CATCH(s32Error)
3530 WILC_FREE_IF_TRUE(strWID.ps8WidVal);
3531 WILC_FREE_IF_TRUE(pstrSetBeaconParam->pu8Head);
3532 WILC_FREE_IF_TRUE(pstrSetBeaconParam->pu8Tail);
3537 * @brief Handle_AddBeacon
3538 * @details Sending config packet to delete beacon
3539 * @param[in] tstrHostIFDelBeacon* pstrDelBeacon
3545 static void Handle_DelBeacon(void *drvHandler, tstrHostIFDelBeacon *pstrDelBeacon)
3547 s32 s32Error = WILC_SUCCESS;
3550 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3551 strWID.u16WIDid = (u16)WID_DEL_BEACON;
3552 strWID.enuWIDtype = WID_CHAR;
3553 strWID.s32ValueSize = sizeof(char);
3554 strWID.ps8WidVal = &gu8DelBcn;
3556 if (strWID.ps8WidVal == NULL) {
3557 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3560 pu8CurrByte = strWID.ps8WidVal;
3562 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
3563 /* TODO: build del beacon message*/
3566 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3569 PRINT_ER("Failed to send delete beacon config packet\n");
3570 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3573 WILC_CATCH(s32Error)
3580 * @brief WILC_HostIf_PackStaParam
3581 * @details Handling packing of the station params in a buffer
3582 * @param[in] u8* pu8Buffer, tstrWILC_AddStaParam* pstrStationParam
3588 static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer, tstrWILC_AddStaParam *pstrStationParam)
3592 pu8CurrByte = pu8Buffer;
3594 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
3595 WILC_memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
3596 pu8CurrByte += ETH_ALEN;
3598 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
3599 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
3601 *pu8CurrByte++ = pstrStationParam->u8NumRates;
3602 if (pstrStationParam->u8NumRates > 0) {
3603 WILC_memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
3605 pu8CurrByte += pstrStationParam->u8NumRates;
3607 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
3608 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
3609 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
3611 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
3612 WILC_memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
3613 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
3615 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
3616 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
3618 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
3619 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
3620 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
3621 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
3623 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
3625 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
3626 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
3628 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
3629 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
3631 return pu8CurrByte - pu8Buffer;
3635 * @brief Handle_AddStation
3636 * @details Sending config packet to add station
3637 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3643 static void Handle_AddStation(void *drvHandler, tstrWILC_AddStaParam *pstrStationParam)
3645 s32 s32Error = WILC_SUCCESS;
3648 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3649 PRINT_D(HOSTINF_DBG, "Handling add station\n");
3650 strWID.u16WIDid = (u16)WID_ADD_STA;
3651 strWID.enuWIDtype = WID_BIN;
3652 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3654 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3655 if (strWID.ps8WidVal == NULL) {
3656 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3659 pu8CurrByte = strWID.ps8WidVal;
3660 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3663 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3664 if (s32Error != WILC_SUCCESS) {
3666 PRINT_ER("Failed to send add station config packet\n");
3667 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3670 WILC_CATCH(s32Error)
3673 WILC_FREE_IF_TRUE(pstrStationParam->pu8Rates);
3674 WILC_FREE_IF_TRUE(strWID.ps8WidVal);
3678 * @brief Handle_DelAllSta
3679 * @details Sending config packet to delete station
3680 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3686 static void Handle_DelAllSta(void *drvHandler, tstrHostIFDelAllSta *pstrDelAllStaParam)
3688 s32 s32Error = WILC_SUCCESS;
3691 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3693 u8 au8Zero_Buff[6] = {0};
3694 strWID.u16WIDid = (u16)WID_DEL_ALL_STA;
3695 strWID.enuWIDtype = WID_STR;
3696 strWID.s32ValueSize = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1;
3698 PRINT_D(HOSTINF_DBG, "Handling delete station \n");
3700 strWID.ps8WidVal = WILC_MALLOC((pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1);
3701 if (strWID.ps8WidVal == NULL) {
3702 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3705 pu8CurrByte = strWID.ps8WidVal;
3707 *(pu8CurrByte++) = pstrDelAllStaParam->u8Num_AssocSta;
3709 for (i = 0; i < MAX_NUM_STA; i++) {
3710 if (memcmp(pstrDelAllStaParam->au8Sta_DelAllSta[i], au8Zero_Buff, ETH_ALEN))
3711 WILC_memcpy(pu8CurrByte, pstrDelAllStaParam->au8Sta_DelAllSta[i], ETH_ALEN);
3715 pu8CurrByte += ETH_ALEN;
3719 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3722 PRINT_ER("Failed to send add station config packe\n");
3723 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3726 WILC_CATCH(s32Error)
3729 WILC_FREE_IF_TRUE(strWID.ps8WidVal);
3736 * @brief Handle_DelStation
3737 * @details Sending config packet to delete station
3738 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3744 static void Handle_DelStation(void *drvHandler, tstrHostIFDelSta *pstrDelStaParam)
3746 s32 s32Error = WILC_SUCCESS;
3749 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3751 strWID.u16WIDid = (u16)WID_REMOVE_STA;
3752 strWID.enuWIDtype = WID_BIN;
3753 strWID.s32ValueSize = ETH_ALEN;
3755 PRINT_D(HOSTINF_DBG, "Handling delete station \n");
3757 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3758 if (strWID.ps8WidVal == NULL) {
3759 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3762 pu8CurrByte = strWID.ps8WidVal;
3764 WILC_memcpy(pu8CurrByte, pstrDelStaParam->au8MacAddr, ETH_ALEN);
3767 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3770 PRINT_ER("Failed to send add station config packe\n");
3771 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3774 WILC_CATCH(s32Error)
3777 WILC_FREE_IF_TRUE(strWID.ps8WidVal);
3782 * @brief Handle_EditStation
3783 * @details Sending config packet to edit station
3784 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3790 static void Handle_EditStation(void *drvHandler, tstrWILC_AddStaParam *pstrStationParam)
3792 s32 s32Error = WILC_SUCCESS;
3795 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3797 strWID.u16WIDid = (u16)WID_EDIT_STA;
3798 strWID.enuWIDtype = WID_BIN;
3799 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3801 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
3802 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3803 if (strWID.ps8WidVal == NULL) {
3804 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3807 pu8CurrByte = strWID.ps8WidVal;
3808 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3811 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3814 PRINT_ER("Failed to send edit station config packet\n");
3815 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3818 WILC_CATCH(s32Error)
3821 WILC_FREE_IF_TRUE(pstrStationParam->pu8Rates);
3822 WILC_FREE_IF_TRUE(strWID.ps8WidVal);
3824 #endif /*WILC_AP_EXTERNAL_MLME*/
3828 * @brief Handle_RemainOnChan
3829 * @details Sending config packet to edit station
3830 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3836 static int Handle_RemainOnChan(void *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan)
3838 s32 s32Error = WILC_SUCCESS;
3839 u8 u8remain_on_chan_flag;
3841 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3843 /*If it's a pendig remain-on-channel, don't overwrite gWFiDrvHandle values (since incoming msg is garbbage)*/
3844 if (!pstrWFIDrv->u8RemainOnChan_pendingreq) {
3845 pstrWFIDrv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
3846 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
3847 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
3848 pstrWFIDrv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
3849 pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
3851 /*Set the channel to use it as a wid val*/
3852 pstrHostIfRemainOnChan->u16Channel = pstrWFIDrv->strHostIfRemainOnChan.u16Channel;
3855 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
3856 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
3857 pstrWFIDrv->u8RemainOnChan_pendingreq = 1;
3858 WILC_ERRORREPORT(s32Error, WILC_BUSY);
3860 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3861 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
3862 WILC_ERRORREPORT(s32Error, WILC_BUSY);
3865 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3866 if (g_obtainingIP || connecting) {
3867 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
3868 WILC_ERRORREPORT(s32Error, WILC_BUSY);
3872 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
3874 u8remain_on_chan_flag = true;
3875 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
3876 strWID.enuWIDtype = WID_STR;
3877 strWID.s32ValueSize = 2;
3878 strWID.ps8WidVal = (s8 *)WILC_MALLOC(strWID.s32ValueSize);
3880 if (strWID.ps8WidVal == NULL) {
3881 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3884 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
3885 strWID.ps8WidVal[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
3888 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3889 if (s32Error != WILC_SUCCESS) {
3890 PRINT_ER("Failed to set remain on channel\n");
3895 P2P_LISTEN_STATE = 1;
3896 WILC_TimerStart(&(pstrWFIDrv->hRemainOnChannel), pstrHostIfRemainOnChan->u32duration, (void *)pstrWFIDrv, NULL);
3898 /*Calling CFG ready_on_channel*/
3899 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady) {
3900 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady(pstrWFIDrv->strHostIfRemainOnChan.pVoid);
3903 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
3904 pstrWFIDrv->u8RemainOnChan_pendingreq = 0;
3910 * @brief Handle_RegisterFrame
3918 static int Handle_RegisterFrame(void *drvHandler, tstrHostIfRegisterFrame *pstrHostIfRegisterFrame)
3920 s32 s32Error = WILC_SUCCESS;
3923 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3925 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
3927 /*prepare configuration packet*/
3928 strWID.u16WIDid = (u16)WID_REGISTER_FRAME;
3929 strWID.enuWIDtype = WID_STR;
3930 strWID.ps8WidVal = WILC_MALLOC(sizeof(u16) + 2);
3931 if (strWID.ps8WidVal == NULL) {
3932 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3935 pu8CurrByte = strWID.ps8WidVal;
3937 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
3938 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
3939 WILC_memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
3942 strWID.s32ValueSize = sizeof(u16) + 2;
3946 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3948 PRINT_ER("Failed to frame register config packet\n");
3949 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
3953 WILC_CATCH(s32Error)
3962 * @brief Handle_ListenStateExpired
3963 * @details Handle of listen state expiration
3965 * @return Error code.
3970 #define FALSE_FRMWR_CHANNEL 100
3971 static u32 Handle_ListenStateExpired(void *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan)
3973 u8 u8remain_on_chan_flag;
3975 s32 s32Error = WILC_SUCCESS;
3976 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3978 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
3981 /*Make sure we are already in listen state*/
3982 /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/
3983 if (P2P_LISTEN_STATE) {
3984 u8remain_on_chan_flag = false;
3985 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
3986 strWID.enuWIDtype = WID_STR;
3987 strWID.s32ValueSize = 2;
3988 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3990 if (strWID.ps8WidVal == NULL) {
3991 PRINT_ER("Failed to allocate memory\n");
3994 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
3995 strWID.ps8WidVal[1] = FALSE_FRMWR_CHANNEL;
3998 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3999 if (s32Error != WILC_SUCCESS) {
4000 PRINT_ER("Failed to set remain on channel\n");
4004 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired) {
4005 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired(pstrWFIDrv->strHostIfRemainOnChan.pVoid
4006 , pstrHostIfRemainOnChan->u32ListenSessionID);
4008 P2P_LISTEN_STATE = 0;
4010 PRINT_D(GENERIC_DBG, "Not in listen state\n");
4011 s32Error = WILC_FAIL;
4020 * @brief ListenTimerCB
4021 * @details Callback function of remain-on-channel timer
4023 * @return Error code.
4028 static void ListenTimerCB(void *pvArg)
4030 s32 s32Error = WILC_SUCCESS;
4031 tstrHostIFmsg strHostIFmsg;
4032 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)pvArg;
4033 /*Stopping remain-on-channel timer*/
4034 WILC_TimerStop(&(pstrWFIDrv->hRemainOnChannel), NULL);
4036 /* prepare the Timer Callback message */
4037 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4038 strHostIFmsg.u16MsgId = HOST_IF_MSG_LISTEN_TIMER_FIRED;
4039 strHostIFmsg.drvHandler = pstrWFIDrv;
4040 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID;
4042 /* send the message */
4043 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4045 WILC_ERRORREPORT(s32Error, s32Error);
4047 WILC_CATCH(s32Error)
4056 * @brief Handle_EditStation
4057 * @details Sending config packet to edit station
4058 * @param[in] tstrWILC_AddStaParam* pstrStationParam
4064 static void Handle_PowerManagement(void *drvHandler, tstrHostIfPowerMgmtParam *strPowerMgmtParam)
4066 s32 s32Error = WILC_SUCCESS;
4069 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4070 strWID.u16WIDid = (u16)WID_POWER_MANAGEMENT;
4072 if (strPowerMgmtParam->bIsEnabled == true) {
4073 s8PowerMode = MIN_FAST_PS;
4075 s8PowerMode = NO_POWERSAVE;
4077 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
4078 strWID.ps8WidVal = &s8PowerMode;
4079 strWID.s32ValueSize = sizeof(char);
4081 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
4084 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4086 PRINT_ER("Failed to send power management config packet\n");
4087 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
4090 WILC_CATCH(s32Error)
4097 * @brief Handle_SetMulticastFilter
4098 * @details Set Multicast filter in firmware
4099 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4105 static void Handle_SetMulticastFilter(void *drvHandler, tstrHostIFSetMulti *strHostIfSetMulti)
4107 s32 s32Error = WILC_SUCCESS;
4111 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
4113 strWID.u16WIDid = (u16)WID_SETUP_MULTICAST_FILTER;
4114 strWID.enuWIDtype = WID_BIN;
4115 strWID.s32ValueSize = sizeof(tstrHostIFSetMulti) + ((strHostIfSetMulti->u32count) * ETH_ALEN);
4116 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
4117 if (strWID.ps8WidVal == NULL) {
4118 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
4121 pu8CurrByte = strWID.ps8WidVal;
4122 *pu8CurrByte++ = (strHostIfSetMulti->bIsEnabled & 0xFF);
4123 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 8) & 0xFF);
4124 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 16) & 0xFF);
4125 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 24) & 0xFF);
4127 *pu8CurrByte++ = (strHostIfSetMulti->u32count & 0xFF);
4128 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 8) & 0xFF);
4129 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 16) & 0xFF);
4130 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 24) & 0xFF);
4132 if ((strHostIfSetMulti->u32count) > 0)
4133 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->u32count) * ETH_ALEN));
4136 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)drvHandler);
4138 PRINT_ER("Failed to send setup multicast config packet\n");
4139 WILC_ERRORREPORT(s32Error, WILC_FAIL);
4142 WILC_CATCH(s32Error)
4145 WILC_FREE_IF_TRUE(strWID.ps8WidVal);
4152 * @brief Handle_AddBASession
4153 * @details Add block ack session
4154 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4156 * @author Amr Abdel-Moghny
4160 static s32 Handle_AddBASession(void *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
4162 s32 s32Error = WILC_SUCCESS;
4164 int AddbaTimeout = 100;
4166 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4168 PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x \nTID=%d \nBufferSize == %d \nSessionTimeOut = %d\n",
4169 strHostIfBASessionInfo->au8Bssid[0],
4170 strHostIfBASessionInfo->au8Bssid[1],
4171 strHostIfBASessionInfo->au8Bssid[2],
4172 strHostIfBASessionInfo->u16BufferSize,
4173 strHostIfBASessionInfo->u16SessionTimeout,
4174 strHostIfBASessionInfo->u8Ted);
4176 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
4177 strWID.enuWIDtype = WID_STR;
4178 strWID.ps8WidVal = (u8 *)WILC_MALLOC(BLOCK_ACK_REQ_SIZE);
4179 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4180 ptr = strWID.ps8WidVal;
4181 /* *ptr++ = 0x14; */
4185 WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4187 *ptr++ = strHostIfBASessionInfo->u8Ted;
4191 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
4192 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
4194 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
4195 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
4197 *ptr++ = (AddbaTimeout & 0xFF);
4198 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
4199 /* Group Buffer Max Frames*/
4201 /* Group Buffer Timeout */
4204 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4206 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
4209 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
4210 strWID.enuWIDtype = WID_STR;
4211 strWID.s32ValueSize = 15;
4212 ptr = strWID.ps8WidVal;
4213 /* *ptr++ = 0x14; */
4217 WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4220 *ptr++ = strHostIfBASessionInfo->u8Ted;
4224 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
4225 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
4228 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4230 if (strWID.ps8WidVal != NULL)
4231 WILC_FREE(strWID.ps8WidVal);
4240 * @brief Handle_DelBASession
4241 * @details Delete block ack session
4242 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4244 * @author Amr Abdel-Moghny
4248 static s32 Handle_DelBASession(void *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
4250 s32 s32Error = WILC_SUCCESS;
4253 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4255 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x \nTID=%d\n",
4256 strHostIfBASessionInfo->au8Bssid[0],
4257 strHostIfBASessionInfo->au8Bssid[1],
4258 strHostIfBASessionInfo->au8Bssid[2],
4259 strHostIfBASessionInfo->u8Ted);
4261 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
4262 strWID.enuWIDtype = WID_STR;
4263 strWID.ps8WidVal = (u8 *)WILC_MALLOC(BLOCK_ACK_REQ_SIZE);
4264 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4265 ptr = strWID.ps8WidVal;
4266 /* *ptr++ = 0x14; */
4270 WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4272 *ptr++ = strHostIfBASessionInfo->u8Ted;
4273 /* BA direction = recipent*/
4276 *ptr++ = 32; /* Unspecific QOS reason */
4278 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4280 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
4283 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
4284 strWID.enuWIDtype = WID_STR;
4285 strWID.s32ValueSize = 15;
4286 ptr = strWID.ps8WidVal;
4287 /* *ptr++ = 0x14; */
4291 WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4294 *ptr++ = strHostIfBASessionInfo->u8Ted;
4296 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4298 if (strWID.ps8WidVal != NULL)
4299 WILC_FREE(strWID.ps8WidVal);
4310 * @brief Handle_DelAllRxBASessions
4311 * @details Delete all Rx BA sessions
4312 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4314 * @author Abdelrahman Sobhy
4318 static s32 Handle_DelAllRxBASessions(void *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
4320 s32 s32Error = WILC_SUCCESS;
4323 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4325 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x \nTID=%d\n",
4326 strHostIfBASessionInfo->au8Bssid[0],
4327 strHostIfBASessionInfo->au8Bssid[1],
4328 strHostIfBASessionInfo->au8Bssid[2],
4329 strHostIfBASessionInfo->u8Ted);
4331 strWID.u16WIDid = (u16)WID_DEL_ALL_RX_BA;
4332 strWID.enuWIDtype = WID_STR;
4333 strWID.ps8WidVal = (u8 *)WILC_MALLOC(BLOCK_ACK_REQ_SIZE);
4334 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4335 ptr = strWID.ps8WidVal;
4339 WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4341 *ptr++ = strHostIfBASessionInfo->u8Ted;
4342 /* BA direction = recipent*/
4345 *ptr++ = 32; /* Unspecific QOS reason */
4347 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4349 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
4352 if (strWID.ps8WidVal != NULL)
4353 WILC_FREE(strWID.ps8WidVal);
4363 * @brief hostIFthread
4364 * @details Main thread to handle message queue requests
4365 * @param[in] void* pvArg
4371 static int hostIFthread(void *pvArg)
4374 tstrHostIFmsg strHostIFmsg;
4375 tstrWILC_WFIDrv *pstrWFIDrv;
4377 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4380 WILC_MsgQueueRecv(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), &u32Ret, NULL);
4381 pstrWFIDrv = (tstrWILC_WFIDrv *)strHostIFmsg.drvHandler;
4382 if (strHostIFmsg.u16MsgId == HOST_IF_MSG_EXIT) {
4383 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
4388 /*Re-Queue HIF message*/
4389 if ((!g_wilc_initialized)) {
4390 PRINT_D(GENERIC_DBG, "--WAIT--");
4392 WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4396 if (strHostIFmsg.u16MsgId == HOST_IF_MSG_CONNECT && pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
4397 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
4398 WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4403 switch (strHostIFmsg.u16MsgId) {
4404 case HOST_IF_MSG_Q_IDLE:
4405 Handle_wait_msg_q_empty();
4408 case HOST_IF_MSG_SCAN:
4409 Handle_Scan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr);
4412 case HOST_IF_MSG_CONNECT:
4413 Handle_Connect(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr);
4417 case HOST_IF_MSG_FLUSH_CONNECT:
4418 Handle_FlushConnect(strHostIFmsg.drvHandler);
4421 case HOST_IF_MSG_RCVD_NTWRK_INFO:
4422 Handle_RcvdNtwrkInfo(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo);
4425 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
4426 Handle_RcvdGnrlAsyncInfo(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo);
4429 case HOST_IF_MSG_KEY:
4430 Handle_Key(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr);
4433 case HOST_IF_MSG_CFG_PARAMS:
4435 Handle_CfgParam(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFCfgParamAttr);
4438 case HOST_IF_MSG_SET_CHANNEL:
4439 Handle_SetChannel(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFSetChan);
4442 case HOST_IF_MSG_DISCONNECT:
4443 Handle_Disconnect(strHostIFmsg.drvHandler);
4446 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
4447 WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL);
4448 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
4451 /*Allow chip sleep, only if both interfaces are not connected*/
4452 if (!linux_wlan_get_num_conn_ifcs()) {
4453 chip_sleep_manually(INFINITE_SLEEP_TIME);
4456 Handle_ScanDone(strHostIFmsg.drvHandler, SCAN_EVENT_DONE);
4459 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
4460 Handle_RemainOnChan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
4465 case HOST_IF_MSG_GET_RSSI:
4466 Handle_GetRssi(strHostIFmsg.drvHandler);
4469 case HOST_IF_MSG_GET_LINKSPEED:
4470 Handle_GetLinkspeed(strHostIFmsg.drvHandler);
4473 case HOST_IF_MSG_GET_STATISTICS:
4474 Handle_GetStatistics(strHostIFmsg.drvHandler, (tstrStatistics *)strHostIFmsg.uniHostIFmsgBody.pUserData);
4477 case HOST_IF_MSG_GET_CHNL:
4478 Handle_GetChnl(strHostIFmsg.drvHandler);
4481 #ifdef WILC_AP_EXTERNAL_MLME
4482 case HOST_IF_MSG_ADD_BEACON:
4483 Handle_AddBeacon(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFSetBeacon);
4486 case HOST_IF_MSG_DEL_BEACON:
4487 Handle_DelBeacon(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFDelBeacon);
4490 case HOST_IF_MSG_ADD_STATION:
4491 Handle_AddStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strAddStaParam);
4494 case HOST_IF_MSG_DEL_STATION:
4495 Handle_DelStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strDelStaParam);
4498 case HOST_IF_MSG_EDIT_STATION:
4499 Handle_EditStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strEditStaParam);
4502 case HOST_IF_MSG_GET_INACTIVETIME:
4503 Handle_Get_InActiveTime(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfStaInactiveT);
4506 #endif /*WILC_AP_EXTERNAL_MLME*/
4507 case HOST_IF_MSG_SCAN_TIMER_FIRED:
4508 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
4510 Handle_ScanDone(strHostIFmsg.drvHandler, SCAN_EVENT_ABORTED);
4513 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
4514 PRINT_D(HOSTINF_DBG, "Connect Timeout \n");
4515 Handle_ConnectTimeout(strHostIFmsg.drvHandler);
4518 case HOST_IF_MSG_POWER_MGMT:
4519 Handle_PowerManagement(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strPowerMgmtparam);
4522 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
4523 Handle_SetWfiDrvHandler(&strHostIFmsg.uniHostIFmsgBody.strHostIfSetDrvHandler);
4526 case HOST_IF_MSG_SET_OPERATION_MODE:
4527 Handle_SetOperationMode(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetOperationMode);
4530 case HOST_IF_MSG_SET_IPADDRESS:
4531 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
4532 Handle_set_IPAddress(strHostIFmsg.drvHandler, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx);
4535 case HOST_IF_MSG_GET_IPADDRESS:
4536 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
4537 Handle_get_IPAddress(strHostIFmsg.drvHandler, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx);
4541 case HOST_IF_MSG_SET_MAC_ADDRESS:
4542 Handle_SetMacAddress(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMacAddress);
4546 case HOST_IF_MSG_GET_MAC_ADDRESS:
4547 Handle_GetMacAddress(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfGetMacAddress);
4551 case HOST_IF_MSG_REMAIN_ON_CHAN:
4552 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
4553 Handle_RemainOnChan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
4556 case HOST_IF_MSG_REGISTER_FRAME:
4557 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
4558 Handle_RegisterFrame(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame);
4561 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
4562 Handle_ListenStateExpired(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
4566 case HOST_IF_MSG_SET_MULTICAST_FILTER:
4567 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
4568 Handle_SetMulticastFilter(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMulti);
4572 case HOST_IF_MSG_ADD_BA_SESSION:
4573 Handle_AddBASession(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo);
4576 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
4577 Handle_DelAllRxBASessions(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo);
4580 case HOST_IF_MSG_DEL_ALL_STA:
4581 Handle_DelAllSta(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFDelAllSta);
4585 PRINT_ER("[Host Interface] undefined Received Msg ID \n");
4590 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
4591 up(&hSemHostIFthrdEnd);
4595 static void TimerCB_Scan(void *pvArg)
4597 tstrHostIFmsg strHostIFmsg;
4599 /* prepare the Timer Callback message */
4600 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4601 strHostIFmsg.drvHandler = pvArg;
4602 strHostIFmsg.u16MsgId = HOST_IF_MSG_SCAN_TIMER_FIRED;
4604 /* send the message */
4605 WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4608 static void TimerCB_Connect(void *pvArg)
4610 tstrHostIFmsg strHostIFmsg;
4612 /* prepare the Timer Callback message */
4613 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4614 strHostIFmsg.drvHandler = pvArg;
4615 strHostIFmsg.u16MsgId = HOST_IF_MSG_CONNECT_TIMER_FIRED;
4617 /* send the message */
4618 WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4623 * @brief removes wpa/wpa2 keys
4624 * @details only in BSS STA mode if External Supplicant support is enabled.
4625 * removes all WPA/WPA2 station key entries from MAC hardware.
4626 * @param[in,out] handle to the wifi driver
4627 * @param[in] 6 bytes of Station Adress in the station entry table
4628 * @return Error code indicating success/failure
4631 * @date 8 March 2012
4634 /* Check implementation in core adding 9 bytes to the input! */
4635 s32 host_int_remove_key(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8StaAddress)
4637 s32 s32Error = WILC_SUCCESS;
4639 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4641 strWID.u16WIDid = (u16)WID_REMOVE_KEY;
4642 strWID.enuWIDtype = WID_STR;
4643 strWID.ps8WidVal = (s8 *)pu8StaAddress;
4644 strWID.s32ValueSize = 6;
4651 * @brief removes WEP key
4652 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4653 * remove a WEP key entry from MAC HW.
4654 * The BSS Station automatically finds the index of the entry using its
4655 * BSS ID and removes that entry from the MAC hardware.
4656 * @param[in,out] handle to the wifi driver
4657 * @param[in] 6 bytes of Station Adress in the station entry table
4658 * @return Error code indicating success/failure
4659 * @note NO need for the STA add since it is not used for processing
4661 * @date 8 March 2012
4664 s32 host_int_remove_wep_key(WILC_WFIDrvHandle hWFIDrv, u8 u8keyIdx)
4666 s32 s32Error = WILC_SUCCESS;
4667 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4668 tstrHostIFmsg strHostIFmsg;
4671 if (pstrWFIDrv == NULL) {
4672 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4675 /* prepare the Remove Wep Key Message */
4676 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4679 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4680 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4681 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = REMOVEKEY;
4682 strHostIFmsg.drvHandler = hWFIDrv;
4686 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4687 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8keyIdx;
4689 /* send the message */
4690 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4692 PRINT_ER("Error in sending message queue : Request to remove WEP key \n");
4693 down(&(pstrWFIDrv->hSemTestKeyBlock));
4695 WILC_CATCH(s32Error)
4703 * @brief sets WEP default key
4704 * @details Sets the index of the WEP encryption key in use,
4706 * @param[in,out] handle to the wifi driver
4707 * @param[in] key index ( 0, 1, 2, 3)
4708 * @return Error code indicating success/failure
4711 * @date 8 March 2012
4714 s32 host_int_set_WEPDefaultKeyID(WILC_WFIDrvHandle hWFIDrv, u8 u8Index)
4716 s32 s32Error = WILC_SUCCESS;
4717 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4718 tstrHostIFmsg strHostIFmsg;
4721 if (pstrWFIDrv == NULL) {
4722 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4725 /* prepare the Key Message */
4726 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4729 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4730 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4731 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = DEFAULTKEY;
4732 strHostIFmsg.drvHandler = hWFIDrv;
4735 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4736 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Index;
4738 /* send the message */
4739 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4741 PRINT_ER("Error in sending message queue : Default key index\n");
4742 down(&(pstrWFIDrv->hSemTestKeyBlock));
4744 WILC_CATCH(s32Error)
4753 * @brief sets WEP deafault key
4754 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4755 * sets WEP key entry into MAC hardware when it receives the
4756 * corresponding request from NDIS.
4757 * @param[in,out] handle to the wifi driver
4758 * @param[in] message containing WEP Key in the following format
4759 *|---------------------------------------|
4760 *|Key ID Value | Key Length | Key |
4761 *|-------------|------------|------------|
4762 | 1byte | 1byte | Key Length |
4763 ||---------------------------------------|
4765 * @return Error code indicating success/failure
4768 * @date 8 March 2012
4771 s32 host_int_add_wep_key_bss_sta(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx)
4774 s32 s32Error = WILC_SUCCESS;
4775 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4776 tstrHostIFmsg strHostIFmsg;
4778 if (pstrWFIDrv == NULL) {
4779 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4783 /* prepare the Key Message */
4784 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4787 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4788 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4789 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
4790 strHostIFmsg.drvHandler = hWFIDrv;
4793 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4794 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = (u8 *)WILC_MALLOC(u8WepKeylen);
4796 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
4797 pu8WepKey, u8WepKeylen);
4800 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4801 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4803 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4804 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4806 /* send the message */
4807 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4809 PRINT_ER("Error in sending message queue :WEP Key\n");
4810 down(&(pstrWFIDrv->hSemTestKeyBlock));
4812 WILC_CATCH(s32Error)
4820 #ifdef WILC_AP_EXTERNAL_MLME
4823 * @brief host_int_add_wep_key_bss_ap
4824 * @details valid only in BSS AP mode if External Supplicant support is enabled.
4825 * sets WEP key entry into MAC hardware when it receives the
4827 * corresponding request from NDIS.
4828 * @param[in,out] handle to the wifi driver
4831 * @return Error code indicating success/failure
4837 s32 host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx, u8 u8mode, AUTHTYPE_T tenuAuth_type)
4840 s32 s32Error = WILC_SUCCESS;
4841 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4842 tstrHostIFmsg strHostIFmsg;
4845 if (pstrWFIDrv == NULL) {
4846 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4850 /* prepare the Key Message */
4851 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4854 for (i = 0; i < u8WepKeylen; i++)
4855 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
4857 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4858 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4859 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
4860 strHostIFmsg.drvHandler = hWFIDrv;
4863 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4864 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = (u8 *)WILC_MALLOC((u8WepKeylen));
4867 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
4868 pu8WepKey, (u8WepKeylen));
4871 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4872 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4874 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4875 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4877 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4878 uniHostIFkeyAttr.strHostIFwepAttr.u8mode = u8mode;
4880 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4881 uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type = tenuAuth_type;
4882 /* send the message */
4883 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4886 PRINT_ER("Error in sending message queue :WEP Key\n");
4887 down(&(pstrWFIDrv->hSemTestKeyBlock));
4889 WILC_CATCH(s32Error)
4898 * @brief adds ptk Key
4900 * @param[in,out] handle to the wifi driver
4901 * @param[in] message containing PTK Key in the following format
4902 *|-----------------------------------------------------------------------------|
4903 *|Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
4904 *|----------------|------------|--------------|----------------|---------------|
4905 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
4906 ||-----------------------------------------------------------------------------|
4907 * @return Error code indicating success/failure
4910 * @date 8 March 2012
4913 s32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen,
4914 const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode, u8 u8Idx)
4916 s32 s32Error = WILC_SUCCESS;
4917 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4918 tstrHostIFmsg strHostIFmsg;
4919 u8 u8KeyLen = u8PtkKeylen;
4921 if (pstrWFIDrv == NULL) {
4922 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4924 if (pu8RxMic != NULL) {
4925 u8KeyLen += RX_MIC_KEY_LEN;
4927 if (pu8TxMic != NULL) {
4928 u8KeyLen += TX_MIC_KEY_LEN;
4931 /* prepare the Key Message */
4932 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4935 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4936 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WPAPtk;
4937 #ifdef WILC_AP_EXTERNAL_MLME
4938 if (mode == AP_MODE) {
4939 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
4940 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4941 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8Idx;
4944 if (mode == STATION_MODE)
4945 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
4948 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4949 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = (u8 *)WILC_MALLOC(u8PtkKeylen);
4952 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
4953 pu8Ptk, u8PtkKeylen);
4955 if (pu8RxMic != NULL) {
4957 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
4958 pu8RxMic, RX_MIC_KEY_LEN);
4960 for (i = 0; i < RX_MIC_KEY_LEN; i++)
4961 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
4964 if (pu8TxMic != NULL) {
4966 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
4967 pu8TxMic, TX_MIC_KEY_LEN);
4969 for (i = 0; i < TX_MIC_KEY_LEN; i++)
4970 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
4974 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4975 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
4977 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4978 uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
4979 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4980 uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr = mac_addr;
4981 strHostIFmsg.drvHandler = hWFIDrv;
4983 /* send the message */
4984 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4987 PRINT_ER("Error in sending message queue: PTK Key\n");
4989 /* ////////////// */
4990 down(&(pstrWFIDrv->hSemTestKeyBlock));
4991 /* WILC_Sleep(100); */
4994 WILC_CATCH(s32Error)
5003 * @brief adds Rx GTk Key
5005 * @param[in,out] handle to the wifi driver
5006 * @param[in] pu8RxGtk : contains temporal key | Rx Mic | Tx Mic
5007 * u8GtkKeylen :The total key length
5009 * @return Error code indicating success/failure
5012 * @date 8 March 2012
5015 s32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen,
5016 u8 u8KeyIdx, u32 u32KeyRSClen, const u8 *KeyRSC,
5017 const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode)
5019 s32 s32Error = WILC_SUCCESS;
5020 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5021 tstrHostIFmsg strHostIFmsg;
5022 u8 u8KeyLen = u8GtkKeylen;
5024 if (pstrWFIDrv == NULL) {
5025 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5027 /* prepare the Key Message */
5028 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5031 if (pu8RxMic != NULL) {
5032 u8KeyLen += RX_MIC_KEY_LEN;
5034 if (pu8TxMic != NULL) {
5035 u8KeyLen += TX_MIC_KEY_LEN;
5037 if (KeyRSC != NULL) {
5038 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5039 uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq = (u8 *)WILC_MALLOC(u32KeyRSClen);
5041 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq,
5042 KeyRSC, u32KeyRSClen);
5046 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
5047 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WPARxGtk;
5048 strHostIFmsg.drvHandler = hWFIDrv;
5050 #ifdef WILC_AP_EXTERNAL_MLME
5051 if (mode == AP_MODE) {
5052 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
5053 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
5056 if (mode == STATION_MODE)
5057 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
5060 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5061 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = (u8 *)WILC_MALLOC(u8KeyLen);
5063 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
5064 pu8RxGtk, u8GtkKeylen);
5066 if (pu8RxMic != NULL) {
5068 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
5069 pu8RxMic, RX_MIC_KEY_LEN);
5072 if (pu8TxMic != NULL) {
5074 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
5075 pu8TxMic, TX_MIC_KEY_LEN);
5079 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5080 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8KeyIdx;
5081 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5082 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
5084 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5085 uniHostIFkeyAttr.strHostIFwpaAttr.u8seqlen = u32KeyRSClen;
5089 /* send the message */
5090 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5092 PRINT_ER("Error in sending message queue: RX GTK\n");
5093 /* ////////////// */
5094 down(&(pstrWFIDrv->hSemTestKeyBlock));
5095 /* WILC_Sleep(100); */
5098 WILC_CATCH(s32Error)
5106 * @brief host_int_add_tx_gtk
5107 * @details adds Tx GTk Key
5108 * @param[in,out] handle to the wifi driver
5109 * @param[in] message containing Tx GTK Key in the following format
5110 *|----------------------------------------------------|
5111 | KeyID | Key Length | Temporal Key | Tx Michael Key |
5112 ||-------|------------|--------------|----------------|
5113 ||1 byte | 1 byte | 16 bytes | 8 bytes |
5114 ||----------------------------------------------------|
5115 * @return Error code indicating success/failure
5118 * @date 8 March 2012
5121 s32 host_int_add_tx_gtk(WILC_WFIDrvHandle hWFIDrv, u8 u8KeyLen, u8 *pu8TxGtk, u8 u8KeyIdx)
5123 s32 s32Error = WILC_SUCCESS;
5124 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5125 tstrHostIFmsg strHostIFmsg;
5127 if (pstrWFIDrv == NULL) {
5128 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5131 /* prepare the Key Message */
5132 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5134 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
5135 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WPATxGtk;
5136 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
5138 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5139 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = (u8 *)WILC_MALLOC(u8KeyLen);
5141 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
5142 pu8TxGtk, u8KeyLen);
5144 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
5146 /* send the message */
5147 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5149 PRINT_ER("Error in sending message queue: TX GTK\n");
5151 /* ////////////// */
5152 down(&hSemTestKeyBlock);
5156 WILC_CATCH(s32Error)
5164 * @brief host_int_set_pmkid_info
5165 * @details caches the pmkid valid only in BSS STA mode if External Supplicant
5166 * support is enabled. This Function sets the PMKID in firmware
5167 * when host drivr receives the corresponding request from NDIS.
5168 * The firmware then includes theset PMKID in the appropriate
5170 * @param[in,out] handle to the wifi driver
5171 * @param[in] message containing PMKID Info in the following format
5172 *|-----------------------------------------------------------------|
5173 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
5174 *|-----------|------------|----------|-------|----------|----------|
5175 | 1 | 6 | 16 | ... | 6 | 16 |
5176 ||-----------------------------------------------------------------|
5177 * @return Error code indicating success/failure
5180 * @date 8 March 2012
5183 s32 host_int_set_pmkid_info(WILC_WFIDrvHandle hWFIDrv, tstrHostIFpmkidAttr *pu8PmkidInfoArray)
5185 s32 s32Error = WILC_SUCCESS;
5186 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5187 tstrHostIFmsg strHostIFmsg;
5191 if (pstrWFIDrv == NULL) {
5192 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5195 /* prepare the Key Message */
5196 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5198 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
5199 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = PMKSA;
5200 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
5201 strHostIFmsg.drvHandler = hWFIDrv;
5203 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
5205 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
5208 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
5212 /* send the message */
5213 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5215 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
5217 WILC_CATCH(s32Error)
5226 * @brief gets the cached the pmkid info
5227 * @details valid only in BSS STA mode if External Supplicant
5228 * support is enabled. This Function sets the PMKID in firmware
5229 * when host drivr receives the corresponding request from NDIS.
5230 * The firmware then includes theset PMKID in the appropriate
5232 * @param[in,out] handle to the wifi driver,
5233 * message containing PMKID Info in the following format
5234 *|-----------------------------------------------------------------|
5235 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
5236 *|-----------|------------|----------|-------|----------|----------|
5237 | 1 | 6 | 16 | ... | 6 | 16 |
5238 ||-----------------------------------------------------------------|
5240 * @return Error code indicating success/failure
5243 * @date 8 March 2012
5246 s32 host_int_get_pmkid_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PmkidInfoArray,
5247 u32 u32PmkidInfoLen)
5249 s32 s32Error = WILC_SUCCESS;
5251 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5253 strWID.u16WIDid = (u16)WID_PMKID_INFO;
5254 strWID.enuWIDtype = WID_STR;
5255 strWID.s32ValueSize = u32PmkidInfoLen;
5256 strWID.ps8WidVal = pu8PmkidInfoArray;
5262 * @brief sets the pass phrase
5263 * @details AP/STA mode. This function gives the pass phrase used to
5264 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5265 * The length of the field can vary from 8 to 64 bytes,
5266 * the lower layer should get the
5267 * @param[in,out] handle to the wifi driver,
5268 * @param[in] String containing PSK
5269 * @return Error code indicating success/failure
5272 * @date 8 March 2012
5275 s32 host_int_set_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PassPhrase,
5278 s32 s32Error = WILC_SUCCESS;
5280 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5282 /* u8 u8Psklength = WILC_strlen(pu8PassPhrase); */
5283 /*validating psk length*/
5284 if ((u8Psklength > 7) && (u8Psklength < 65)) {
5285 strWID.u16WIDid = (u16)WID_11I_PSK;
5286 strWID.enuWIDtype = WID_STR;
5287 strWID.ps8WidVal = pu8PassPhrase;
5288 strWID.s32ValueSize = u8Psklength;
5294 * @brief host_int_get_MacAddress
5295 * @details gets mac address
5296 * @param[in,out] handle to the wifi driver,
5298 * @return Error code indicating success/failure
5301 * @date 19 April 2012
5304 s32 host_int_get_MacAddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8MacAddress)
5306 s32 s32Error = WILC_SUCCESS;
5307 tstrHostIFmsg strHostIFmsg;
5310 /* prepare the Message */
5311 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5313 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_MAC_ADDRESS;
5314 strHostIFmsg.uniHostIFmsgBody.strHostIfGetMacAddress.u8MacAddress = pu8MacAddress;
5315 strHostIFmsg.drvHandler = hWFIDrv;
5316 /* send the message */
5317 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5319 PRINT_ER("Failed to send get mac address\n");
5323 down(&hWaitResponse);
5328 * @brief host_int_set_MacAddress
5329 * @details sets mac address
5330 * @param[in,out] handle to the wifi driver,
5332 * @return Error code indicating success/failure
5335 * @date 16 July 2012
5338 s32 host_int_set_MacAddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8MacAddress)
5340 s32 s32Error = WILC_SUCCESS;
5341 tstrHostIFmsg strHostIFmsg;
5343 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
5345 /* prepare setting mac address message */
5346 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5347 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_MAC_ADDRESS;
5348 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIfSetMacAddress.u8MacAddress, pu8MacAddress, ETH_ALEN);
5349 strHostIFmsg.drvHandler = hWFIDrv;
5351 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5353 PRINT_ER("Failed to send message queue: Set mac address\n");
5354 WILC_ERRORREPORT(s32Error, s32Error);
5356 WILC_CATCH(s32Error)
5366 * @brief host_int_get_RSNAConfigPSKPassPhrase
5367 * @details gets the pass phrase:AP/STA mode. This function gets the pass phrase used to
5368 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5369 * The length of the field can vary from 8 to 64 bytes,
5370 * the lower layer should get the
5371 * @param[in,out] handle to the wifi driver,
5372 * String containing PSK
5373 * @return Error code indicating success/failure
5376 * @date 8 March 2012
5379 s32 host_int_get_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv,
5380 u8 *pu8PassPhrase, u8 u8Psklength)
5382 s32 s32Error = WILC_SUCCESS;
5384 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5386 strWID.u16WIDid = (u16)WID_11I_PSK;
5387 strWID.enuWIDtype = WID_STR;
5388 strWID.s32ValueSize = u8Psklength;
5389 strWID.ps8WidVal = pu8PassPhrase;
5395 * @brief host_int_get_site_survey_results
5396 * @details gets the site survey results
5397 * @param[in,out] handle to the wifi driver,
5398 * Message containing site survey results in the
5400 *|---------------------------------------------------|
5401 | MsgLength | fragNo. | MsgBodyLength | MsgBody |
5402 ||-----------|-----------|---------------|-----------|
5404 | ----------------------------------------- | ----------------
5406 ||---------------------------------------|
5407 | Network1 | Netweork2 | ... | Network5 |
5408 ||---------------------------------------|
5409 | 44 | 44 | ... | 44 |
5410 | -------------------------- | ---------------------------------------
5412 ||---------------------------------------------------------------------|
5413 | SSID | BSS Type | Channel | Security Status| BSSID | RSSI |Reserved |
5416 ||------|----------|---------|----------------|-------|------|---------|
5417 | 33 | 1 | 1 | 1 | 6 | 1 | 1 |
5418 ||---------------------------------------------------------------------|
5419 * @return Error code indicating success/failure
5422 * @date 8 March 2012
5425 #ifndef CONNECT_DIRECT
5426 s32 host_int_get_site_survey_results(WILC_WFIDrvHandle hWFIDrv,
5427 u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE],
5428 u32 u32MaxSiteSrvyFragLen)
5430 s32 s32Error = WILC_SUCCESS;
5431 tstrWID astrWIDList[2];
5432 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5434 astrWIDList[0].u16WIDid = (u16)WID_SITE_SURVEY_RESULTS;
5435 astrWIDList[0].enuWIDtype = WID_STR;
5436 astrWIDList[0].ps8WidVal = ppu8RcvdSiteSurveyResults[0];
5437 astrWIDList[0].s32ValueSize = u32MaxSiteSrvyFragLen;
5439 astrWIDList[1].u16WIDid = (u16)WID_SITE_SURVEY_RESULTS;
5440 astrWIDList[1].enuWIDtype = WID_STR;
5441 astrWIDList[1].ps8WidVal = ppu8RcvdSiteSurveyResults[1];
5442 astrWIDList[1].s32ValueSize = u32MaxSiteSrvyFragLen;
5444 s32Error = SendConfigPkt(GET_CFG, astrWIDList, 2, true, (u32)pstrWFIDrv);
5446 /*get the value by searching the local copy*/
5448 PRINT_ER("Failed to send config packet to get survey results\n");
5449 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
5452 WILC_CATCH(s32Error)
5462 * @brief sets a start scan request
5464 * @param[in,out] handle to the wifi driver,
5465 * @param[in] Scan Source one of the following values
5468 * OBSS_PERIODIC_SCAN BIT1
5469 * OBSS_ONETIME_SCAN BIT2
5470 * @return Error code indicating success/failure
5473 * @date 8 March 2012
5476 s32 host_int_set_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 scanSource)
5478 s32 s32Error = WILC_SUCCESS;
5480 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5482 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
5483 strWID.enuWIDtype = WID_CHAR;
5484 strWID.ps8WidVal = (s8 *)&scanSource;
5485 strWID.s32ValueSize = sizeof(char);
5491 * @brief host_int_get_start_scan_req
5492 * @details gets a start scan request
5493 * @param[in,out] handle to the wifi driver,
5494 * @param[in] Scan Source one of the following values
5497 * OBSS_PERIODIC_SCAN BIT1
5498 * OBSS_ONETIME_SCAN BIT2
5499 * @return Error code indicating success/failure
5502 * @date 8 March 2012
5506 s32 host_int_get_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ScanSource)
5508 s32 s32Error = WILC_SUCCESS;
5510 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5512 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
5513 strWID.enuWIDtype = WID_CHAR;
5514 strWID.ps8WidVal = (s8 *)pu8ScanSource;
5515 strWID.s32ValueSize = sizeof(char);
5521 * @brief host_int_set_join_req
5522 * @details sets a join request
5523 * @param[in,out] handle to the wifi driver,
5524 * @param[in] Index of the bss descriptor
5525 * @return Error code indicating success/failure
5528 * @date 8 March 2012
5531 s32 host_int_set_join_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8bssid,
5532 const u8 *pu8ssid, size_t ssidLen,
5533 const u8 *pu8IEs, size_t IEsLen,
5534 tWILCpfConnectResult pfConnectResult, void *pvUserArg,
5535 u8 u8security, AUTHTYPE_T tenuAuth_type,
5539 s32 s32Error = WILC_SUCCESS;
5540 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5541 tstrHostIFmsg strHostIFmsg;
5542 tenuScanConnTimer enuScanConnTimer;
5544 if (pstrWFIDrv == NULL || pfConnectResult == NULL) {
5545 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5548 if (hWFIDrv == NULL) {
5549 PRINT_ER("Driver not initialized: gWFiDrvHandle = NULL\n");
5550 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5553 if (pJoinParams == NULL) {
5554 PRINT_ER("Unable to Join - JoinParams is NULL\n");
5555 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5559 * if(gWFiDrvHandle->strWILC_UsrScanReq.u32RcvdChCount == 0)
5561 * PRINT_ER("No scan results exist: Scanning should be done\n");
5562 * WILC_ERRORREPORT(s32Error, WILC_FAIL);
5565 /* prepare the Connect Message */
5566 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5568 strHostIFmsg.u16MsgId = HOST_IF_MSG_CONNECT;
5570 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.u8security = u8security;
5571 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.tenuAuth_type = tenuAuth_type;
5572 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.u8channel = u8channel;
5573 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pfConnectResult = pfConnectResult;
5574 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pvUserArg = pvUserArg;
5575 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pJoinParams = pJoinParams;
5576 strHostIFmsg.drvHandler = hWFIDrv;
5578 if (pu8bssid != NULL) {
5579 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8bssid = (u8 *)WILC_MALLOC(6); /* will be deallocated by the receiving thread */
5580 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8bssid,
5584 if (pu8ssid != NULL) {
5585 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.ssidLen = ssidLen;
5586 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8ssid = (u8 *)WILC_MALLOC(ssidLen); /* will be deallocated by the receiving thread */
5587 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8ssid,
5592 if (pu8IEs != NULL) {
5593 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.IEsLen = IEsLen;
5594 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8IEs = (u8 *)WILC_MALLOC(IEsLen); /* will be deallocated by the receiving thread */
5595 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8IEs,
5598 if (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTING) {
5599 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTING;
5601 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", pstrWFIDrv->enuHostIFstate);
5603 /* send the message */
5604 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5606 PRINT_ER("Failed to send message queue: Set join request\n");
5607 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5610 enuScanConnTimer = CONNECT_TIMER;
5611 WILC_TimerStart(&(pstrWFIDrv->hConnectTimer), HOST_IF_CONNECT_TIMEOUT, (void *) hWFIDrv, NULL);
5613 WILC_CATCH(s32Error)
5622 * @brief Flush a join request parameters to FW, but actual connection
5623 * @details The function is called in situation where WILC is connected to AP and
5624 * required to switch to hybrid FW for P2P connection
5625 * @param[in] handle to the wifi driver,
5626 * @return Error code indicating success/failure
5628 * @author Amr Abdel-Moghny
5633 s32 host_int_flush_join_req(WILC_WFIDrvHandle hWFIDrv)
5635 s32 s32Error = WILC_SUCCESS;
5636 tstrHostIFmsg strHostIFmsg;
5638 if (!gu8FlushedJoinReq) {
5639 s32Error = WILC_FAIL;
5644 if (hWFIDrv == NULL) {
5645 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5649 strHostIFmsg.u16MsgId = HOST_IF_MSG_FLUSH_CONNECT;
5650 strHostIFmsg.drvHandler = hWFIDrv;
5652 /* send the message */
5653 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5655 PRINT_ER("Failed to send message queue: Flush join request\n");
5656 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5659 WILC_CATCH(s32Error)
5667 * @brief host_int_disconnect
5668 * @details disconnects from the currently associated network
5669 * @param[in,out] handle to the wifi driver,
5670 * @param[in] Reason Code of the Disconnection
5671 * @return Error code indicating success/failure
5674 * @date 8 March 2012
5677 s32 host_int_disconnect(WILC_WFIDrvHandle hWFIDrv, u16 u16ReasonCode)
5679 s32 s32Error = WILC_SUCCESS;
5680 tstrHostIFmsg strHostIFmsg;
5681 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5683 if (pstrWFIDrv == NULL) {
5684 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
5685 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5688 if (pstrWFIDrv == NULL) {
5689 PRINT_ER("gWFiDrvHandle = NULL\n");
5690 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5693 /* prepare the Disconnect Message */
5694 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5696 strHostIFmsg.u16MsgId = HOST_IF_MSG_DISCONNECT;
5697 strHostIFmsg.drvHandler = hWFIDrv;
5699 /* send the message */
5700 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5702 PRINT_ER("Failed to send message queue: disconnect\n");
5703 /* ////////////// */
5704 down(&(pstrWFIDrv->hSemTestDisconnectBlock));
5707 WILC_CATCH(s32Error)
5716 * @brief host_int_disconnect_station
5717 * @details disconnects a sta
5718 * @param[in,out] handle to the wifi driver,
5719 * @param[in] Association Id of the station to be disconnected
5720 * @return Error code indicating success/failure
5723 * @date 8 March 2012
5726 s32 host_int_disconnect_station(WILC_WFIDrvHandle hWFIDrv, u8 assoc_id)
5728 s32 s32Error = WILC_SUCCESS;
5730 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5732 strWID.u16WIDid = (u16)WID_DISCONNECT;
5733 strWID.enuWIDtype = WID_CHAR;
5734 strWID.ps8WidVal = (s8 *)&assoc_id;
5735 strWID.s32ValueSize = sizeof(char);
5741 * @brief host_int_get_assoc_req_info
5742 * @details gets a Association request info
5743 * @param[in,out] handle to the wifi driver,
5744 * Message containg assoc. req info in the following format
5745 * ------------------------------------------------------------------------
5746 | Management Frame Format |
5747 ||-------------------------------------------------------------------|
5748 ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS |
5749 ||-------------|--------|--|--|-----|----------------|----------|----|
5750 | 2 |2 |6 |6 |6 | 2 |0 - 2312 | 4 |
5751 ||-------------------------------------------------------------------|
5753 | Association Request Frame - Frame Body |
5754 ||-------------------------------------------------------------------|
5755 | Capability Information | Listen Interval | SSID | Supported Rates |
5756 ||------------------------|-----------------|------|-----------------|
5757 | 2 | 2 | 2-34 | 3-10 |
5758 | ---------------------------------------------------------------------
5759 * @return Error code indicating success/failure
5762 * @date 8 March 2012
5766 s32 host_int_get_assoc_req_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocReqInfo,
5767 u32 u32AssocReqInfoLen)
5769 s32 s32Error = WILC_SUCCESS;
5771 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5773 strWID.u16WIDid = (u16)WID_ASSOC_REQ_INFO;
5774 strWID.enuWIDtype = WID_STR;
5775 strWID.ps8WidVal = pu8AssocReqInfo;
5776 strWID.s32ValueSize = u32AssocReqInfoLen;
5783 * @brief gets a Association Response info
5785 * @param[in,out] handle to the wifi driver,
5786 * Message containg assoc. resp info
5787 * @return Error code indicating success/failure
5790 * @date 8 March 2012
5793 s32 host_int_get_assoc_res_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocRespInfo,
5794 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
5796 s32 s32Error = WILC_SUCCESS;
5798 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5800 if (pstrWFIDrv == NULL) {
5801 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
5802 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5805 strWID.u16WIDid = (u16)WID_ASSOC_RES_INFO;
5806 strWID.enuWIDtype = WID_STR;
5807 strWID.ps8WidVal = pu8AssocRespInfo;
5808 strWID.s32ValueSize = u32MaxAssocRespInfoLen;
5811 /* Sending Configuration packet */
5812 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
5814 PRINT_ER("Failed to send association response config packet\n");
5815 *pu32RcvdAssocRespInfoLen = 0;
5816 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
5818 *pu32RcvdAssocRespInfoLen = strWID.s32ValueSize;
5821 WILC_CATCH(s32Error)
5829 * @brief gets a Association Response info
5830 * @details Valid only in STA mode. This function gives the RSSI
5831 * values observed in all the channels at the time of scanning.
5832 * The length of the field is 1 greater that the total number of
5833 * channels supported. Byte 0 contains the number of channels while
5834 * each of Byte N contains the observed RSSI value for the channel index N.
5835 * @param[in,out] handle to the wifi driver,
5836 * array of scanned channels' RSSI
5837 * @return Error code indicating success/failure
5840 * @date 8 March 2012
5843 s32 host_int_get_rx_power_level(WILC_WFIDrvHandle hWFIDrv, u8 *pu8RxPowerLevel,
5844 u32 u32RxPowerLevelLen)
5846 s32 s32Error = WILC_SUCCESS;
5848 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5850 strWID.u16WIDid = (u16)WID_RX_POWER_LEVEL;
5851 strWID.enuWIDtype = WID_STR;
5852 strWID.ps8WidVal = pu8RxPowerLevel;
5853 strWID.s32ValueSize = u32RxPowerLevelLen;
5860 * @brief sets a channel
5862 * @param[in,out] handle to the wifi driver,
5863 * @param[in] Index of the channel to be set
5864 *|-------------------------------------------------------------------|
5865 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5867 ||-------------------------------------------------------------------|
5868 * @return Error code indicating success/failure
5871 * @date 8 March 2012
5874 s32 host_int_set_mac_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 u8ChNum)
5876 s32 s32Error = WILC_SUCCESS;
5877 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5878 tstrHostIFmsg strHostIFmsg;
5880 if (pstrWFIDrv == NULL) {
5881 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5884 /* prepare the set channel message */
5885 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5886 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_CHANNEL;
5887 strHostIFmsg.uniHostIFmsgBody.strHostIFSetChan.u8SetChan = u8ChNum;
5888 strHostIFmsg.drvHandler = hWFIDrv;
5890 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5892 WILC_ERRORREPORT(s32Error, s32Error);
5894 WILC_CATCH(s32Error)
5903 s32 host_int_wait_msg_queue_idle(void)
5905 s32 s32Error = WILC_SUCCESS;
5907 tstrHostIFmsg strHostIFmsg;
5909 /* prepare the set driver handler message */
5911 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5912 strHostIFmsg.u16MsgId = HOST_IF_MSG_Q_IDLE;
5913 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5915 WILC_ERRORREPORT(s32Error, s32Error);
5917 WILC_CATCH(s32Error)
5922 /* wait untill MSG Q is empty */
5923 down(&hWaitResponse);
5929 s32 host_int_set_wfi_drv_handler(u32 u32address)
5931 s32 s32Error = WILC_SUCCESS;
5933 tstrHostIFmsg strHostIFmsg;
5936 /* prepare the set driver handler message */
5938 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5939 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_WFIDRV_HANDLER;
5940 strHostIFmsg.uniHostIFmsgBody.strHostIfSetDrvHandler.u32Address = u32address;
5941 /* strHostIFmsg.drvHandler=hWFIDrv; */
5943 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5945 WILC_ERRORREPORT(s32Error, s32Error);
5947 WILC_CATCH(s32Error)
5957 s32 host_int_set_operation_mode(WILC_WFIDrvHandle hWFIDrv, u32 u32mode)
5959 s32 s32Error = WILC_SUCCESS;
5961 tstrHostIFmsg strHostIFmsg;
5964 /* prepare the set driver handler message */
5966 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5967 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_OPERATION_MODE;
5968 strHostIFmsg.uniHostIFmsgBody.strHostIfSetOperationMode.u32Mode = u32mode;
5969 strHostIFmsg.drvHandler = hWFIDrv;
5971 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5973 WILC_ERRORREPORT(s32Error, s32Error);
5975 WILC_CATCH(s32Error)
5984 * @brief gets the current channel index
5986 * @param[in,out] handle to the wifi driver,
5987 * current channel index
5988 *|-----------------------------------------------------------------------|
5989 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5991 ||-----------------------------------------------------------------------|
5992 * @return Error code indicating success/failure
5995 * @date 8 March 2012
5998 s32 host_int_get_host_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ChNo)
6000 s32 s32Error = WILC_SUCCESS;
6001 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6002 tstrHostIFmsg strHostIFmsg;
6004 if (pstrWFIDrv == NULL) {
6005 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
6006 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6009 /* prepare the Get Channel Message */
6010 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6012 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_CHNL;
6013 strHostIFmsg.drvHandler = hWFIDrv;
6015 /* send the message */
6016 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6018 PRINT_ER("Failed to send get host channel param's message queue ");
6019 down(&(pstrWFIDrv->hSemGetCHNL));
6024 WILC_CATCH(s32Error)
6035 * @brief host_int_test_set_int_wid
6036 * @details Test function for setting wids
6037 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr
6038 * @return Error code indicating success/failure
6041 * @date 8 March 2012
6044 s32 host_int_test_set_int_wid(WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr)
6046 s32 s32Error = WILC_SUCCESS;
6048 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6051 if (pstrWFIDrv == NULL) {
6052 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
6053 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6056 /*prepare configuration packet*/
6057 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
6058 strWID.enuWIDtype = WID_INT;
6059 strWID.ps8WidVal = (char *)&u32TestMemAddr;
6060 strWID.s32ValueSize = sizeof(u32);
6063 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
6065 PRINT_ER("Test Function: Failed to set wid value\n");
6066 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
6068 PRINT_D(HOSTINF_DBG, "Successfully set wid value\n");
6072 WILC_CATCH(s32Error)
6079 #ifdef WILC_AP_EXTERNAL_MLME
6081 * @brief host_int_get_inactive_time
6083 * @param[in,out] handle to the wifi driver,
6084 * current sta macaddress, inactive_time
6091 s32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, const u8 *mac, u32 *pu32InactiveTime)
6093 s32 s32Error = WILC_SUCCESS;
6094 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6095 tstrHostIFmsg strHostIFmsg;
6097 if (pstrWFIDrv == NULL) {
6098 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
6099 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6102 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6105 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIfStaInactiveT.mac,
6108 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_INACTIVETIME;
6109 strHostIFmsg.drvHandler = hWFIDrv;
6111 /* send the message */
6112 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6114 PRINT_ER("Failed to send get host channel param's message queue ");
6116 down(&(pstrWFIDrv->hSemInactiveTime));
6118 *pu32InactiveTime = gu32InactiveTime;
6120 WILC_CATCH(s32Error)
6128 * @brief host_int_test_get_int_wid
6129 * @details Test function for getting wids
6130 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32* pu32TestMemAddr
6131 * @return Error code indicating success/failure
6134 * @date 8 March 2012
6137 s32 host_int_test_get_int_wid(WILC_WFIDrvHandle hWFIDrv, u32 *pu32TestMemAddr)
6140 s32 s32Error = WILC_SUCCESS;
6142 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6145 if (pstrWFIDrv == NULL) {
6146 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
6147 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6150 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
6151 strWID.enuWIDtype = WID_INT;
6152 strWID.ps8WidVal = (s8 *)pu32TestMemAddr;
6153 strWID.s32ValueSize = sizeof(u32);
6155 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
6156 /*get the value by searching the local copy*/
6158 PRINT_ER("Test Function: Failed to get wid value\n");
6159 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
6161 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
6165 WILC_CATCH(s32Error)
6174 * @brief host_int_get_rssi
6175 * @details gets the currently maintained RSSI value for the station.
6176 * The received signal strength value in dB.
6177 * The range of valid values is -128 to 0.
6178 * @param[in,out] handle to the wifi driver,
6180 * @return Error code indicating success/failure
6183 * @date 8 March 2012
6186 s32 host_int_get_rssi(WILC_WFIDrvHandle hWFIDrv, s8 *ps8Rssi)
6188 s32 s32Error = WILC_SUCCESS;
6189 tstrHostIFmsg strHostIFmsg;
6190 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6193 /* prepare the Get RSSI Message */
6194 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6196 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_RSSI;
6197 strHostIFmsg.drvHandler = hWFIDrv;
6199 /* send the message */
6200 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6202 PRINT_ER("Failed to send get host channel param's message queue ");
6206 down(&(pstrWFIDrv->hSemGetRSSI));
6209 if (ps8Rssi == NULL) {
6210 PRINT_ER("RSS pointer value is null");
6221 s32 host_int_get_link_speed(WILC_WFIDrvHandle hWFIDrv, s8 *ps8lnkspd)
6223 tstrHostIFmsg strHostIFmsg;
6224 s32 s32Error = WILC_SUCCESS;
6226 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6230 /* prepare the Get LINKSPEED Message */
6231 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6233 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_LINKSPEED;
6234 strHostIFmsg.drvHandler = hWFIDrv;
6236 /* send the message */
6237 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6239 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
6243 down(&(pstrWFIDrv->hSemGetLINKSPEED));
6246 if (ps8lnkspd == NULL) {
6247 PRINT_ER("LINKSPEED pointer value is null");
6252 *ps8lnkspd = gs8lnkspd;
6258 s32 host_int_get_statistics(WILC_WFIDrvHandle hWFIDrv, tstrStatistics *pstrStatistics)
6260 s32 s32Error = WILC_SUCCESS;
6261 tstrHostIFmsg strHostIFmsg;
6264 /* prepare the Get RSSI Message */
6265 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6267 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_STATISTICS;
6268 strHostIFmsg.uniHostIFmsgBody.pUserData = (char *)pstrStatistics;
6269 strHostIFmsg.drvHandler = hWFIDrv;
6270 /* send the message */
6271 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6273 PRINT_ER("Failed to send get host channel param's message queue ");
6277 down(&hWaitResponse);
6283 * @brief host_int_scan
6284 * @details scans a set of channels
6285 * @param[in,out] handle to the wifi driver,
6286 * @param[in] Scan source
6287 * Scan Type PASSIVE_SCAN = 0,
6290 * Channels Array length
6291 * Scan Callback function
6292 * @return Error code indicating success/failure
6295 * @date 8 March 2012
6298 s32 host_int_scan(WILC_WFIDrvHandle hWFIDrv, u8 u8ScanSource,
6299 u8 u8ScanType, u8 *pu8ChnlFreqList,
6300 u8 u8ChnlListLen, const u8 *pu8IEs,
6301 size_t IEsLen, tWILCpfScanResult ScanResult,
6302 void *pvUserArg, tstrHiddenNetwork *pstrHiddenNetwork)
6304 s32 s32Error = WILC_SUCCESS;
6305 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6306 tstrHostIFmsg strHostIFmsg;
6307 tenuScanConnTimer enuScanConnTimer;
6309 if (pstrWFIDrv == NULL || ScanResult == NULL) {
6310 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6314 /* prepare the Scan Message */
6315 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6317 strHostIFmsg.u16MsgId = HOST_IF_MSG_SCAN;
6319 if (pstrHiddenNetwork != NULL) {
6320 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.strHiddenNetwork.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
6321 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.strHiddenNetwork.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
6324 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
6326 strHostIFmsg.drvHandler = hWFIDrv;
6327 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ScanSource = u8ScanSource;
6328 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ScanType = u8ScanType;
6329 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pfScanResult = ScanResult;
6330 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pvUserArg = pvUserArg;
6332 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ChnlListLen = u8ChnlListLen;
6333 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8ChnlFreqList = (u8 *)WILC_MALLOC(u8ChnlListLen); /* will be deallocated by the receiving thread */
6334 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8ChnlFreqList,
6335 pu8ChnlFreqList, u8ChnlListLen);
6337 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.IEsLen = IEsLen;
6338 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8IEs = (u8 *)WILC_MALLOC(IEsLen); /* will be deallocated by the receiving thread */
6339 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8IEs,
6342 /* send the message */
6343 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6345 PRINT_ER("Error in sending message queue scanning parameters: Error(%d)\n", s32Error);
6346 WILC_ERRORREPORT(s32Error, WILC_FAIL);
6349 enuScanConnTimer = SCAN_TIMER;
6350 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
6351 WILC_TimerStart(&(pstrWFIDrv->hScanTimer), HOST_IF_SCAN_TIMEOUT, (void *) hWFIDrv, NULL);
6354 WILC_CATCH(s32Error)
6362 * @brief hif_set_cfg
6363 * @details sets configuration wids values
6364 * @param[in,out] handle to the wifi driver,
6365 * @param[in] WID, WID value
6366 * @return Error code indicating success/failure
6369 * @date 8 March 2012
6372 s32 hif_set_cfg(WILC_WFIDrvHandle hWFIDrv, tstrCfgParamVal *pstrCfgParamVal)
6375 s32 s32Error = WILC_SUCCESS;
6376 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6378 tstrHostIFmsg strHostIFmsg;
6381 if (pstrWFIDrv == NULL) {
6382 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6384 /* prepare the WiphyParams Message */
6385 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6386 strHostIFmsg.u16MsgId = HOST_IF_MSG_CFG_PARAMS;
6387 strHostIFmsg.uniHostIFmsgBody.strHostIFCfgParamAttr.pstrCfgParamVal = *pstrCfgParamVal;
6388 strHostIFmsg.drvHandler = hWFIDrv;
6390 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6392 WILC_CATCH(s32Error)
6402 * @brief hif_get_cfg
6403 * @details gets configuration wids values
6404 * @param[in,out] handle to the wifi driver,
6407 * @return Error code indicating success/failure
6411 * @date 8 March 2012
6414 s32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, u16 u16WID, u16 *pu16WID_Value)
6416 s32 s32Error = WILC_SUCCESS;
6417 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6419 down(&(pstrWFIDrv->gtOsCfgValuesSem));
6421 if (pstrWFIDrv == NULL) {
6422 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
6423 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6425 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
6429 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.bss_type;
6433 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.auth_type;
6436 case WID_AUTH_TIMEOUT:
6437 *pu16WID_Value = pstrWFIDrv->strCfgValues.auth_timeout;
6440 case WID_POWER_MANAGEMENT:
6441 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.power_mgmt_mode;
6444 case WID_SHORT_RETRY_LIMIT:
6445 *pu16WID_Value = pstrWFIDrv->strCfgValues.short_retry_limit;
6448 case WID_LONG_RETRY_LIMIT:
6449 *pu16WID_Value = pstrWFIDrv->strCfgValues.long_retry_limit;
6452 case WID_FRAG_THRESHOLD:
6453 *pu16WID_Value = pstrWFIDrv->strCfgValues.frag_threshold;
6456 case WID_RTS_THRESHOLD:
6457 *pu16WID_Value = pstrWFIDrv->strCfgValues.rts_threshold;
6461 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.preamble_type;
6464 case WID_SHORT_SLOT_ALLOWED:
6465 *pu16WID_Value = (u16) pstrWFIDrv->strCfgValues.short_slot_allowed;
6468 case WID_11N_TXOP_PROT_DISABLE:
6469 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.txop_prot_disabled;
6472 case WID_BEACON_INTERVAL:
6473 *pu16WID_Value = pstrWFIDrv->strCfgValues.beacon_interval;
6476 case WID_DTIM_PERIOD:
6477 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.dtim_period;
6480 case WID_SITE_SURVEY:
6481 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.site_survey_enabled;
6484 case WID_SITE_SURVEY_SCAN_TIME:
6485 *pu16WID_Value = pstrWFIDrv->strCfgValues.site_survey_scan_time;
6488 case WID_ACTIVE_SCAN_TIME:
6489 *pu16WID_Value = pstrWFIDrv->strCfgValues.active_scan_time;
6492 case WID_PASSIVE_SCAN_TIME:
6493 *pu16WID_Value = pstrWFIDrv->strCfgValues.passive_scan_time;
6496 case WID_CURRENT_TX_RATE:
6497 *pu16WID_Value = pstrWFIDrv->strCfgValues.curr_tx_rate;
6504 up(&(pstrWFIDrv->gtOsCfgValuesSem));
6506 WILC_CATCH(s32Error)
6513 /*****************************************************************************/
6514 /* Notification Functions */
6515 /*****************************************************************************/
6517 * @brief notifies host with join and leave requests
6518 * @details This function prepares an Information frame having the
6519 * information about a joining/leaving station.
6520 * @param[in,out] handle to the wifi driver,
6521 * @param[in] 6 byte Sta Adress
6522 * Join or leave flag:
6525 * @return Error code indicating success/failure
6528 * @date 8 March 2012
6531 void host_int_send_join_leave_info_to_host
6532 (u16 assocId, u8 *stationAddr, bool joining)
6536 * @brief notifies host with stations found in scan
6537 * @details sends the beacon/probe response from scan
6538 * @param[in,out] handle to the wifi driver,
6539 * @param[in] Sta Address,
6541 * Rssi of the Station found
6542 * @return Error code indicating success/failure
6545 * @date 8 March 2012
6549 void GetPeriodicRSSI(void *pvArg)
6551 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)pvArg;
6552 if (pstrWFIDrv == NULL) {
6553 PRINT_ER("Driver handler is NULL\n");
6557 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
6558 s32 s32Error = WILC_SUCCESS;
6559 tstrHostIFmsg strHostIFmsg;
6561 /* prepare the Get RSSI Message */
6562 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6564 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_RSSI;
6565 strHostIFmsg.drvHandler = pstrWFIDrv;
6567 /* send the message */
6568 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6570 PRINT_ER("Failed to send get host channel param's message queue ");
6574 WILC_TimerStart(&(g_hPeriodicRSSI), 5000, (void *)pstrWFIDrv, NULL);
6578 void host_int_send_network_info_to_host
6579 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
6583 * @brief host_int_init
6584 * @details host interface initialization function
6585 * @param[in,out] handle to the wifi driver,
6588 * @date 8 March 2012
6591 static u32 u32Intialized;
6592 static u32 msgQ_created;
6593 static u32 clients_count;
6595 s32 host_int_init(WILC_WFIDrvHandle *phWFIDrv)
6597 s32 s32Error = WILC_SUCCESS;
6598 tstrWILC_WFIDrv *pstrWFIDrv;
6600 /*if(u32Intialized == 1)
6602 * PRINT_D(HOSTINF_DBG,"Host interface is previously initialized\n");
6603 * *phWFIDrv = (WILC_WFIDrvHandle)gWFiDrvHandle; //Will be adjusted later for P2P
6606 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
6608 gbScanWhileConnected = false;
6610 sema_init(&hWaitResponse, 0);
6614 /*Allocate host interface private structure*/
6615 pstrWFIDrv = (tstrWILC_WFIDrv *)WILC_MALLOC(sizeof(tstrWILC_WFIDrv));
6616 if (pstrWFIDrv == NULL) {
6617 /* WILC_ERRORREPORT(s32Error,WILC_NO_MEM); */
6618 s32Error = WILC_NO_MEM;
6619 PRINT_ER("Failed to allocate memory\n");
6622 WILC_memset(pstrWFIDrv, 0, sizeof(tstrWILC_WFIDrv));
6623 /*return driver handle to user*/
6624 *phWFIDrv = (WILC_WFIDrvHandle)pstrWFIDrv;
6625 /*save into globl handle*/
6627 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
6629 g_obtainingIP = false;
6632 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", pstrWFIDrv);
6633 /* /////////////////////////////////////// */
6634 if (clients_count == 0) {
6635 sema_init(&hSemHostIFthrdEnd, 0);
6636 sema_init(&hSemDeinitDrvHandle, 0);
6638 sema_init(&hSemHostIntDeinit, 1);
6641 sema_init(&(pstrWFIDrv->hSemTestKeyBlock), 0);
6642 sema_init(&(pstrWFIDrv->hSemTestDisconnectBlock), 0);
6643 sema_init(&(pstrWFIDrv->hSemGetRSSI), 0);
6644 sema_init(&(pstrWFIDrv->hSemGetLINKSPEED), 0);
6645 sema_init(&(pstrWFIDrv->hSemGetCHNL), 0);
6646 sema_init(&(pstrWFIDrv->hSemInactiveTime), 0);
6648 /* /////////////////////////////////////// */
6652 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
6654 if (clients_count == 0) {
6656 s32Error = WILC_MsgQueueCreate(&gMsgQHostIF, NULL);
6660 PRINT_ER("Failed to creat MQ\n");
6664 HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread");
6665 if (IS_ERR(HostIFthreadHandler)) {
6666 PRINT_ER("Failed to creat Thread\n");
6667 s32Error = WILC_FAIL;
6670 s32Error = WILC_TimerCreate(&(g_hPeriodicRSSI), GetPeriodicRSSI, NULL);
6672 PRINT_ER("Failed to creat Timer\n");
6675 WILC_TimerStart(&(g_hPeriodicRSSI), 5000, (void *)pstrWFIDrv, NULL);
6680 s32Error = WILC_TimerCreate(&(pstrWFIDrv->hScanTimer), TimerCB_Scan, NULL);
6682 PRINT_ER("Failed to creat Timer\n");
6686 s32Error = WILC_TimerCreate(&(pstrWFIDrv->hConnectTimer), TimerCB_Connect, NULL);
6688 PRINT_ER("Failed to creat Timer\n");
6694 /*Remain on channel timer*/
6695 s32Error = WILC_TimerCreate(&(pstrWFIDrv->hRemainOnChannel), ListenTimerCB, NULL);
6697 PRINT_ER("Failed to creat Remain-on-channel Timer\n");
6702 sema_init(&(pstrWFIDrv->gtOsCfgValuesSem), 1);
6703 down(&(pstrWFIDrv->gtOsCfgValuesSem));
6711 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
6712 /* gWFiDrvHandle->bPendingConnRequest = false; */
6714 /*Initialize CFG WIDS Defualt Values*/
6716 pstrWFIDrv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
6717 pstrWFIDrv->strCfgValues.scan_source = DEFAULT_SCAN;
6718 pstrWFIDrv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
6719 pstrWFIDrv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
6720 pstrWFIDrv->strCfgValues.curr_tx_rate = AUTORATE;
6725 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
6729 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",
6731 pstrWFIDrv->strCfgValues.site_survey_enabled, pstrWFIDrv->strCfgValues.scan_source,
6732 pstrWFIDrv->strCfgValues.active_scan_time, pstrWFIDrv->strCfgValues.passive_scan_time,
6733 pstrWFIDrv->strCfgValues.curr_tx_rate);
6736 up(&(pstrWFIDrv->gtOsCfgValuesSem));
6738 /*TODO Code to setup simulation to be removed later*/
6739 /*Intialize configurator module*/
6740 s32Error = CoreConfiguratorInit();
6742 PRINT_ER("Failed to initialize core configurator\n");
6747 /*Initialize Simulaor*/
6748 CoreConfigSimulatorInit();
6752 clients_count++; /* increase number of created entities */
6758 if (pstrWFIDrv != NULL)
6759 WILC_FREE(pstrWFIDrv);
6762 WILC_TimerDestroy(&(pstrWFIDrv->hRemainOnChannel), NULL);
6765 up(&(pstrWFIDrv->gtOsCfgValuesSem));
6766 WILC_TimerDestroy(&(pstrWFIDrv->hConnectTimer), NULL);
6768 WILC_TimerDestroy(&(pstrWFIDrv->hScanTimer), NULL);
6770 kthread_stop(HostIFthreadHandler);
6772 WILC_MsgQueueDestroy(&gMsgQHostIF, NULL);
6779 * @brief host_int_deinit
6780 * @details host interface initialization function
6781 * @param[in,out] handle to the wifi driver,
6784 * @date 8 March 2012
6788 s32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv)
6790 s32 s32Error = WILC_SUCCESS;
6791 tstrHostIFmsg strHostIFmsg;
6794 /*obtain driver handle*/
6795 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6796 /*if(u32Intialized == 0)
6798 * PRINT_ER("Host Interface is not initialized\n");
6804 if (pstrWFIDrv == NULL) {
6805 PRINT_ER("pstrWFIDrv = NULL\n");
6809 down(&hSemHostIntDeinit);
6811 terminated_handle = pstrWFIDrv;
6812 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
6815 /*Destroy all timers before acquiring hSemDeinitDrvHandle*/
6816 /*to guarantee handling all messages befor proceeding*/
6817 if (WILC_TimerDestroy(&(pstrWFIDrv->hScanTimer), NULL)) {
6818 PRINT_D(HOSTINF_DBG, ">> Scan timer is active \n");
6819 /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */
6822 if (WILC_TimerDestroy(&(pstrWFIDrv->hConnectTimer), NULL)) {
6823 PRINT_D(HOSTINF_DBG, ">> Connect timer is active \n");
6824 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6828 if (WILC_TimerDestroy(&(g_hPeriodicRSSI), NULL)) {
6829 PRINT_D(HOSTINF_DBG, ">> Connect timer is active \n");
6830 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6834 /*Destroy Remain-onchannel Timer*/
6835 WILC_TimerDestroy(&(pstrWFIDrv->hRemainOnChannel), NULL);
6838 host_int_set_wfi_drv_handler((u32)NULL);
6839 down(&hSemDeinitDrvHandle);
6842 /*Calling the CFG80211 scan done function with the abort flag set to true*/
6843 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
6844 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
6845 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
6847 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
6849 /*deinit configurator and simulator*/
6851 CoreConfigSimulatorDeInit();
6853 CoreConfiguratorDeInit();
6858 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
6860 gbScanWhileConnected = false;
6862 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6864 if (clients_count == 1) {
6865 if (WILC_TimerDestroy(&g_hPeriodicRSSI, NULL)) {
6866 PRINT_D(HOSTINF_DBG, ">> Connect timer is active \n");
6867 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6869 strHostIFmsg.u16MsgId = HOST_IF_MSG_EXIT;
6870 strHostIFmsg.drvHandler = hWFIDrv;
6873 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6874 if (s32Error != WILC_SUCCESS) {
6875 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
6878 down(&hSemHostIFthrdEnd);
6882 WILC_MsgQueueDestroy(&gMsgQHostIF, NULL);
6886 down(&(pstrWFIDrv->gtOsCfgValuesSem));
6888 /*Setting the gloabl driver handler with NULL*/
6890 /* gWFiDrvHandle = NULL; */
6891 if (pstrWFIDrv != NULL) {
6892 WILC_FREE(pstrWFIDrv);
6893 /* pstrWFIDrv=NULL; */
6897 clients_count--; /* Decrease number of created entities */
6898 terminated_handle = NULL;
6899 up(&hSemHostIntDeinit);
6905 * @brief NetworkInfoReceived
6906 * @details function to to be called when network info packet is received
6907 * @param[in] pu8Buffer the received packet
6908 * @param[in] u32Length length of the received packet
6915 void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
6917 s32 s32Error = WILC_SUCCESS;
6918 tstrHostIFmsg strHostIFmsg;
6920 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
6922 drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6923 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
6928 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
6929 PRINT_ER("NetworkInfo received but driver not init[%p]\n", pstrWFIDrv);
6933 /* prepare the Asynchronous Network Info message */
6934 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6936 strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_NTWRK_INFO;
6937 strHostIFmsg.drvHandler = pstrWFIDrv;
6939 strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.u32Length = u32Length;
6940 strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.pu8Buffer = (u8 *)WILC_MALLOC(u32Length); /* will be deallocated by the receiving thread */
6941 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.pu8Buffer,
6942 pu8Buffer, u32Length);
6944 /* send the message */
6945 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6947 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
6955 * @brief GnrlAsyncInfoReceived
6956 * @details function to be called when general Asynchronous info packet is received
6957 * @param[in] pu8Buffer the received packet
6958 * @param[in] u32Length length of the received packet
6965 void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
6967 s32 s32Error = WILC_SUCCESS;
6968 tstrHostIFmsg strHostIFmsg;
6970 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
6973 down(&hSemHostIntDeinit);
6975 drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6976 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
6977 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received \n");
6980 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
6981 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
6983 up(&hSemHostIntDeinit);
6987 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL) {
6988 /* received mac status is not needed when there is no current Connect Request */
6989 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
6991 up(&hSemHostIntDeinit);
6995 /* prepare the General Asynchronous Info message */
6996 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6999 strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
7000 strHostIFmsg.drvHandler = pstrWFIDrv;
7003 strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.u32Length = u32Length;
7004 strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.pu8Buffer = (u8 *)WILC_MALLOC(u32Length); /* will be deallocated by the receiving thread */
7005 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.pu8Buffer,
7006 pu8Buffer, u32Length);
7008 /* send the message */
7009 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7011 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
7015 up(&hSemHostIntDeinit);
7020 * @brief host_int_ScanCompleteReceived
7021 * @details Setting scan complete received notifcation in message queue
7022 * @param[in] u8* pu8Buffer, u32 u32Length
7023 * @return Error code.
7028 void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
7030 s32 s32Error = WILC_SUCCESS;
7031 tstrHostIFmsg strHostIFmsg;
7033 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
7034 drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
7035 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
7038 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", pstrWFIDrv);
7040 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
7044 /*if there is an ongoing scan request*/
7045 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
7046 /* prepare theScan Done message */
7047 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7049 strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
7050 strHostIFmsg.drvHandler = pstrWFIDrv;
7053 /* will be deallocated by the receiving thread */
7054 /*no need to send message body*/
7056 /*strHostIFmsg.uniHostIFmsgBody.strScanComplete.u32Length = u32Length;
7057 * strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer = (u8*)WILC_MALLOC(u32Length);
7058 * WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer,
7059 * pu8Buffer, u32Length); */
7061 /* send the message */
7062 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7064 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
7075 * @brief host_int_remain_on_channel
7077 * @param[in] Handle to wifi driver
7078 * Duration to remain on channel
7079 * Channel to remain on
7080 * Pointer to fn to be called on receive frames in listen state
7081 * Pointer to remain-on-channel expired fn
7083 * @return Error code.
7088 s32 host_int_remain_on_channel(WILC_WFIDrvHandle hWFIDrv, u32 u32SessionID, u32 u32duration, u16 chan, tWILCpfRemainOnChanExpired RemainOnChanExpired, tWILCpfRemainOnChanReady RemainOnChanReady, void *pvUserArg)
7090 s32 s32Error = WILC_SUCCESS;
7091 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7092 tstrHostIFmsg strHostIFmsg;
7094 if (pstrWFIDrv == NULL) {
7095 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7098 /* prepare the remainonchan Message */
7099 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7101 /* prepare the WiphyParams Message */
7102 strHostIFmsg.u16MsgId = HOST_IF_MSG_REMAIN_ON_CHAN;
7103 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u16Channel = chan;
7104 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pRemainOnChanExpired = RemainOnChanExpired;
7105 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pRemainOnChanReady = RemainOnChanReady;
7106 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pVoid = pvUserArg;
7107 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32duration = u32duration;
7108 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
7109 strHostIFmsg.drvHandler = hWFIDrv;
7111 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7113 WILC_ERRORREPORT(s32Error, s32Error);
7115 WILC_CATCH(s32Error)
7124 * @brief host_int_ListenStateExpired
7126 * @param[in] Handle to wifi driver
7127 * Duration to remain on channel
7128 * Channel to remain on
7129 * Pointer to fn to be called on receive frames in listen state
7130 * Pointer to remain-on-channel expired fn
7132 * @return Error code.
7137 s32 host_int_ListenStateExpired(WILC_WFIDrvHandle hWFIDrv, u32 u32SessionID)
7139 s32 s32Error = WILC_SUCCESS;
7140 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7141 tstrHostIFmsg strHostIFmsg;
7143 if (pstrWFIDrv == NULL) {
7144 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7147 /*Stopping remain-on-channel timer*/
7148 WILC_TimerStop(&(pstrWFIDrv->hRemainOnChannel), NULL);
7150 /* prepare the timer fire Message */
7151 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7152 strHostIFmsg.u16MsgId = HOST_IF_MSG_LISTEN_TIMER_FIRED;
7153 strHostIFmsg.drvHandler = hWFIDrv;
7154 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
7156 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7158 WILC_ERRORREPORT(s32Error, s32Error);
7160 WILC_CATCH(s32Error)
7168 * @brief host_int_frame_register
7170 * @param[in] Handle to wifi driver
7171 * @return Error code.
7175 s32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, u16 u16FrameType, bool bReg)
7177 s32 s32Error = WILC_SUCCESS;
7178 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7179 tstrHostIFmsg strHostIFmsg;
7181 if (pstrWFIDrv == NULL) {
7182 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7185 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7187 /* prepare the WiphyParams Message */
7188 strHostIFmsg.u16MsgId = HOST_IF_MSG_REGISTER_FRAME;
7189 switch (u16FrameType) {
7191 PRINT_D(HOSTINF_DBG, "ACTION\n");
7192 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u8Regid = ACTION_FRM_IDX;
7196 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
7197 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u8Regid = PROBE_REQ_IDX;
7201 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
7204 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u16FrameType = u16FrameType;
7205 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.bReg = bReg;
7206 strHostIFmsg.drvHandler = hWFIDrv;
7208 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7210 WILC_ERRORREPORT(s32Error, s32Error);
7212 WILC_CATCH(s32Error)
7223 #ifdef WILC_AP_EXTERNAL_MLME
7225 * @brief host_int_add_beacon
7226 * @details Setting add beacon params in message queue
7227 * @param[in] WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
7228 * u32 u32DTIMPeriod,u32 u32HeadLen, u8* pu8Head,
7229 * u32 u32TailLen, u8* pu8Tail
7230 * @return Error code.
7235 s32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
7237 u32 u32HeadLen, u8 *pu8Head,
7238 u32 u32TailLen, u8 *pu8Tail)
7240 s32 s32Error = WILC_SUCCESS;
7241 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7242 tstrHostIFmsg strHostIFmsg;
7243 tstrHostIFSetBeacon *pstrSetBeaconParam = &strHostIFmsg.uniHostIFmsgBody.strHostIFSetBeacon;
7245 if (pstrWFIDrv == NULL) {
7246 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7249 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7251 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
7254 /* prepare the WiphyParams Message */
7255 strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_BEACON;
7256 strHostIFmsg.drvHandler = hWFIDrv;
7257 pstrSetBeaconParam->u32Interval = u32Interval;
7258 pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
7259 pstrSetBeaconParam->u32HeadLen = u32HeadLen;
7260 pstrSetBeaconParam->pu8Head = (u8 *)WILC_MALLOC(u32HeadLen);
7261 if (pstrSetBeaconParam->pu8Head == NULL) {
7262 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
7264 WILC_memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
7265 pstrSetBeaconParam->u32TailLen = u32TailLen;
7267 /* Bug 4599 : if tail length = 0 skip allocating & copying */
7268 if (u32TailLen > 0) {
7269 pstrSetBeaconParam->pu8Tail = (u8 *)WILC_MALLOC(u32TailLen);
7270 if (pstrSetBeaconParam->pu8Tail == NULL) {
7271 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
7273 WILC_memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen);
7275 pstrSetBeaconParam->pu8Tail = NULL;
7278 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7280 WILC_ERRORREPORT(s32Error, s32Error);
7283 WILC_CATCH(s32Error)
7285 if (pstrSetBeaconParam->pu8Head != NULL) {
7286 WILC_FREE(pstrSetBeaconParam->pu8Head);
7289 if (pstrSetBeaconParam->pu8Tail != NULL) {
7290 WILC_FREE(pstrSetBeaconParam->pu8Tail);
7300 * @brief host_int_del_beacon
7301 * @details Setting add beacon params in message queue
7302 * @param[in] WILC_WFIDrvHandle hWFIDrv
7303 * @return Error code.
7308 s32 host_int_del_beacon(WILC_WFIDrvHandle hWFIDrv)
7310 s32 s32Error = WILC_SUCCESS;
7311 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7312 tstrHostIFmsg strHostIFmsg;
7314 if (pstrWFIDrv == NULL) {
7315 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7318 /* prepare the WiphyParams Message */
7319 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_BEACON;
7320 strHostIFmsg.drvHandler = hWFIDrv;
7321 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
7323 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7324 WILC_ERRORCHECK(s32Error);
7326 WILC_CATCH(s32Error)
7334 * @brief host_int_add_station
7335 * @details Setting add station params in message queue
7336 * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7337 * @return Error code.
7342 s32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrStaParams)
7344 s32 s32Error = WILC_SUCCESS;
7345 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7346 tstrHostIFmsg strHostIFmsg;
7347 tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam;
7350 if (pstrWFIDrv == NULL) {
7351 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7354 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7356 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
7359 /* prepare the WiphyParams Message */
7360 strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_STATION;
7361 strHostIFmsg.drvHandler = hWFIDrv;
7363 WILC_memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam));
7364 if (pstrAddStationMsg->u8NumRates > 0) {
7365 u8 *rates = WILC_MALLOC(pstrAddStationMsg->u8NumRates);
7366 WILC_NULLCHECK(s32Error, rates);
7368 WILC_memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
7369 pstrAddStationMsg->pu8Rates = rates;
7373 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7375 WILC_ERRORREPORT(s32Error, s32Error);
7378 WILC_CATCH(s32Error)
7385 * @brief host_int_del_station
7386 * @details Setting delete station params in message queue
7387 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr
7388 * @return Error code.
7393 s32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8MacAddr)
7395 s32 s32Error = WILC_SUCCESS;
7396 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7397 tstrHostIFmsg strHostIFmsg;
7398 tstrHostIFDelSta *pstrDelStationMsg = &strHostIFmsg.uniHostIFmsgBody.strDelStaParam;
7400 if (pstrWFIDrv == NULL) {
7401 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7404 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7406 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
7410 /* prepare the WiphyParams Message */
7411 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_STATION;
7412 strHostIFmsg.drvHandler = hWFIDrv;
7414 /*BugID_4795: Handling situation of deleting all stations*/
7415 if (pu8MacAddr == NULL)
7416 WILC_memset(pstrDelStationMsg->au8MacAddr, 255, ETH_ALEN);
7418 WILC_memcpy(pstrDelStationMsg->au8MacAddr, pu8MacAddr, ETH_ALEN);
7420 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7422 WILC_ERRORREPORT(s32Error, s32Error);
7425 WILC_CATCH(s32Error)
7431 * @brief host_int_del_allstation
7432 * @details Setting del station params in message queue
7433 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]s
7434 * @return Error code.
7439 s32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN])
7441 s32 s32Error = WILC_SUCCESS;
7442 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7443 tstrHostIFmsg strHostIFmsg;
7444 tstrHostIFDelAllSta *pstrDelAllStationMsg = &strHostIFmsg.uniHostIFmsgBody.strHostIFDelAllSta;
7445 u8 au8Zero_Buff[ETH_ALEN] = {0};
7450 if (pstrWFIDrv == NULL) {
7451 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7454 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7456 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
7458 /* prepare the WiphyParams Message */
7459 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_ALL_STA;
7460 strHostIFmsg.drvHandler = hWFIDrv;
7462 /* Handling situation of deauthenticing all associated stations*/
7463 for (i = 0; i < MAX_NUM_STA; i++) {
7464 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
7465 WILC_memcpy(pstrDelAllStationMsg->au8Sta_DelAllSta[i], pu8MacAddr[i], ETH_ALEN);
7466 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],
7467 pstrDelAllStationMsg->au8Sta_DelAllSta[i][5]);
7472 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
7476 pstrDelAllStationMsg->u8Num_AssocSta = u8AssocNumb;
7477 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7481 WILC_ERRORREPORT(s32Error, s32Error);
7484 WILC_CATCH(s32Error)
7488 down(&hWaitResponse);
7495 * @brief host_int_edit_station
7496 * @details Setting edit station params in message queue
7497 * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7498 * @return Error code.
7503 s32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrStaParams)
7505 s32 s32Error = WILC_SUCCESS;
7506 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7507 tstrHostIFmsg strHostIFmsg;
7508 tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam;
7510 if (pstrWFIDrv == NULL) {
7511 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7514 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
7516 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7519 /* prepare the WiphyParams Message */
7520 strHostIFmsg.u16MsgId = HOST_IF_MSG_EDIT_STATION;
7521 strHostIFmsg.drvHandler = hWFIDrv;
7523 WILC_memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam));
7524 if (pstrAddStationMsg->u8NumRates > 0) {
7525 u8 *rates = WILC_MALLOC(pstrAddStationMsg->u8NumRates);
7526 WILC_NULLCHECK(s32Error, rates);
7527 WILC_memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
7528 pstrAddStationMsg->pu8Rates = rates;
7531 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7533 WILC_ERRORREPORT(s32Error, s32Error);
7535 WILC_CATCH(s32Error)
7540 #endif /*WILC_AP_EXTERNAL_MLME*/
7541 uint32_t wilc_get_chipid(uint8_t);
7543 s32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, bool bIsEnabled, u32 u32Timeout)
7545 s32 s32Error = WILC_SUCCESS;
7546 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7547 tstrHostIFmsg strHostIFmsg;
7548 tstrHostIfPowerMgmtParam *pstrPowerMgmtParam = &strHostIFmsg.uniHostIFmsgBody.strPowerMgmtparam;
7550 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d << \n\n", bIsEnabled);
7552 if (pstrWFIDrv == NULL) {
7553 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7556 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
7558 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7561 /* prepare the WiphyParams Message */
7562 strHostIFmsg.u16MsgId = HOST_IF_MSG_POWER_MGMT;
7563 strHostIFmsg.drvHandler = hWFIDrv;
7565 pstrPowerMgmtParam->bIsEnabled = bIsEnabled;
7566 pstrPowerMgmtParam->u32Timeout = u32Timeout;
7569 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7571 WILC_ERRORREPORT(s32Error, s32Error);
7573 WILC_CATCH(s32Error)
7579 s32 host_int_setup_multicast_filter(WILC_WFIDrvHandle hWFIDrv, bool bIsEnabled, u32 u32count)
7581 s32 s32Error = WILC_SUCCESS;
7583 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7584 tstrHostIFmsg strHostIFmsg;
7585 tstrHostIFSetMulti *pstrMulticastFilterParam = &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMulti;
7588 if (pstrWFIDrv == NULL) {
7589 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7592 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
7594 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7597 /* prepare the WiphyParams Message */
7598 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_MULTICAST_FILTER;
7599 strHostIFmsg.drvHandler = hWFIDrv;
7601 pstrMulticastFilterParam->bIsEnabled = bIsEnabled;
7602 pstrMulticastFilterParam->u32count = u32count;
7604 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7606 WILC_ERRORREPORT(s32Error, s32Error);
7608 WILC_CATCH(s32Error)
7616 /*Bug4218: Parsing Join Param*/
7617 #ifdef WILC_PARSE_SCAN_IN_HOST
7619 /*Bug4218: Parsing Join Param*/
7621 * @brief host_int_ParseJoinBssParam
7622 * @details Parse Needed Join Parameters and save it in a new JoinBssParam entry
7623 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7628 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
7630 tstrJoinBssParam *pNewJoinBssParam = NULL;
7639 u8 pcipherTotalCount = 0;
7640 u8 authTotalCount = 0;
7643 pu8IEs = ptstrNetworkInfo->pu8IEs;
7644 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
7646 pNewJoinBssParam = WILC_MALLOC(sizeof(tstrJoinBssParam));
7647 if (pNewJoinBssParam != NULL) {
7648 WILC_memset(pNewJoinBssParam, 0, sizeof(tstrJoinBssParam));
7649 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
7650 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
7651 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
7652 WILC_memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
7654 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/
7655 WILC_memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
7656 pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen;
7657 WILC_memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
7658 WILC_memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
7659 /*for(i=0; i<pNewJoinBssParam->ssidLen;i++)
7660 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/
7662 /* parse supported rates: */
7663 while (index < u16IEsLen) {
7664 /* supportedRates IE */
7665 if (pu8IEs[index] == SUPP_RATES_IE) {
7666 /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */
7667 suppRatesNo = pu8IEs[index + 1];
7668 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
7669 index += 2; /* skipping ID and length bytes; */
7671 for (i = 0; i < suppRatesNo; i++) {
7672 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
7673 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */
7675 index += suppRatesNo;
7678 /* Ext SupportedRates IE */
7679 else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
7680 /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */
7681 /* checking if no of ext. supp and supp rates < max limit */
7682 extSuppRatesNo = pu8IEs[index + 1];
7683 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
7684 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
7686 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
7688 /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */
7689 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
7690 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
7691 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */
7693 index += extSuppRatesNo;
7697 else if (pu8IEs[index] == HT_CAPABILITY_IE) {
7698 /* if IE found set the flag */
7699 pNewJoinBssParam->ht_capable = true;
7700 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7701 /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */
7703 } else if ((pu8IEs[index] == WMM_IE) && /* WMM Element ID */
7704 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
7705 (pu8IEs[index + 4] == 0xF2) && /* OUI */
7706 (pu8IEs[index + 5] == 0x02) && /* OUI Type */
7707 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) && /* OUI Sub Type */
7708 (pu8IEs[index + 7] == 0x01)) {
7709 /* Presence of WMM Info/Param element indicates WMM capability */
7710 pNewJoinBssParam->wmm_cap = true;
7712 /* Check if Bit 7 is set indicating U-APSD capability */
7713 if (pu8IEs[index + 8] & (1 << 7)) {
7714 pNewJoinBssParam->uapsd_cap = true;
7716 index += pu8IEs[index + 1] + 2;
7720 else if ((pu8IEs[index] == P2P_IE) && /* P2P Element ID */
7721 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
7722 (pu8IEs[index + 4] == 0x9a) && /* OUI */
7723 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) { /* OUI Type */
7725 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
7726 pNewJoinBssParam->u8NoaEnbaled = 1;
7727 pNewJoinBssParam->u8Index = pu8IEs[index + 9];
7729 /* Check if Bit 7 is set indicating Opss capability */
7730 if (pu8IEs[index + 10] & (1 << 7)) {
7731 pNewJoinBssParam->u8OppEnable = 1;
7732 pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10];
7734 pNewJoinBssParam->u8OppEnable = 0;
7736 PRINT_D(GENERIC_DBG, "P2P Dump \n");
7737 for (i = 0; i < pu8IEs[index + 7]; i++)
7738 PRINT_D(GENERIC_DBG, " %x \n", pu8IEs[index + 9 + i]);
7740 pNewJoinBssParam->u8Count = pu8IEs[index + 11];
7741 u16P2P_count = index + 12;
7743 WILC_memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4);
7746 WILC_memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4);
7749 WILC_memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
7751 index += pu8IEs[index + 1] + 2;
7756 else if ((pu8IEs[index] == RSN_IE) ||
7757 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
7758 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
7759 (pu8IEs[index + 5] == 0x01))) {
7760 u16 rsnIndex = index;
7761 /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]);
7762 * for(i=0; i<pu8IEs[rsnIndex+1]; i++)
7764 * PRINT_D(HOSTINF_DBG,"%0x ",pu8IEs[rsnIndex+2+i]);
7766 if (pu8IEs[rsnIndex] == RSN_IE) {
7767 pNewJoinBssParam->mode_802_11i = 2;
7768 /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */
7769 } else { /* check if rsn was previously parsed */
7770 if (pNewJoinBssParam->mode_802_11i == 0)
7771 pNewJoinBssParam->mode_802_11i = 1;
7772 /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */
7775 rsnIndex += 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */
7776 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
7778 /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x \n",pNewJoinBssParam->rsn_grp_policy); */
7779 /* initialize policies with invalid values */
7781 jumpOffset = pu8IEs[rsnIndex] * 4; /* total no.of bytes of pcipher field (count*4) */
7783 /*parsing pairwise cipher*/
7785 /* saving 3 pcipher max. */
7786 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7787 rsnIndex += 2; /* jump 2 bytes of pcipher count */
7789 /* PRINT_D(HOSTINF_DBG,"\npcipher:%d \n",pcipherCount); */
7790 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
7791 /* each count corresponds to 4 bytes, only last byte is saved */
7792 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7793 /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */
7795 pcipherTotalCount += pcipherCount;
7796 rsnIndex += jumpOffset;
7798 jumpOffset = pu8IEs[rsnIndex] * 4;
7800 /*parsing AKM suite (auth_policy)*/
7801 /* saving 3 auth policies max. */
7802 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7803 rsnIndex += 2; /* jump 2 bytes of pcipher count */
7805 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
7806 /* each count corresponds to 4 bytes, only last byte is saved */
7807 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7809 authTotalCount += authCount;
7810 rsnIndex += jumpOffset;
7811 /*pasring rsn cap. only if rsn IE*/
7812 if (pu8IEs[index] == RSN_IE) {
7813 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
7814 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
7817 pNewJoinBssParam->rsn_found = true;
7818 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7821 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7828 return (void *)pNewJoinBssParam;
7832 void host_int_freeJoinParams(void *pJoinParams)
7834 if ((tstrJoinBssParam *)pJoinParams != NULL)
7835 WILC_FREE((tstrJoinBssParam *)pJoinParams);
7837 PRINT_ER("Unable to FREE null pointer\n");
7839 #endif /*WILC_PARSE_SCAN_IN_HOST*/
7843 * @brief host_int_addBASession
7844 * @details Open a block Ack session with the given parameters
7845 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7847 * @author anoureldin
7851 static int host_int_addBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID, short int BufferSize,
7852 short int SessionTimeout, void *drvHandler)
7854 s32 s32Error = WILC_SUCCESS;
7855 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7856 tstrHostIFmsg strHostIFmsg;
7857 tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
7859 if (pstrWFIDrv == NULL) {
7860 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7863 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7865 /* prepare the WiphyParams Message */
7866 strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_BA_SESSION;
7868 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7869 pBASessionInfo->u8Ted = TID;
7870 pBASessionInfo->u16BufferSize = BufferSize;
7871 pBASessionInfo->u16SessionTimeout = SessionTimeout;
7872 strHostIFmsg.drvHandler = hWFIDrv;
7874 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7876 WILC_ERRORREPORT(s32Error, s32Error);
7878 WILC_CATCH(s32Error)
7887 s32 host_int_delBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID)
7889 s32 s32Error = WILC_SUCCESS;
7890 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7891 tstrHostIFmsg strHostIFmsg;
7892 tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
7894 if (pstrWFIDrv == NULL) {
7895 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7898 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7900 /* prepare the WiphyParams Message */
7901 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_BA_SESSION;
7903 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7904 pBASessionInfo->u8Ted = TID;
7905 strHostIFmsg.drvHandler = hWFIDrv;
7907 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7909 WILC_ERRORREPORT(s32Error, s32Error);
7911 WILC_CATCH(s32Error)
7917 down(&hWaitResponse);
7922 s32 host_int_del_All_Rx_BASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID)
7924 s32 s32Error = WILC_SUCCESS;
7925 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7926 tstrHostIFmsg strHostIFmsg;
7927 tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
7929 if (pstrWFIDrv == NULL) {
7930 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7933 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7935 /* prepare the WiphyParams Message */
7936 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
7938 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7939 pBASessionInfo->u8Ted = TID;
7940 strHostIFmsg.drvHandler = hWFIDrv;
7942 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7944 WILC_ERRORREPORT(s32Error, s32Error);
7946 WILC_CATCH(s32Error)
7952 down(&hWaitResponse);
7958 * @brief host_int_setup_ipaddress
7959 * @details setup IP in firmware
7960 * @param[in] Handle to wifi driver
7961 * @return Error code.
7962 * @author Abdelrahman Sobhy
7965 s32 host_int_setup_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *u16ipadd, u8 idx)
7967 s32 s32Error = WILC_SUCCESS;
7968 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7969 tstrHostIFmsg strHostIFmsg;
7971 /* TODO: Enable This feature on softap firmware */
7974 if (pstrWFIDrv == NULL) {
7975 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7978 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7980 /* prepare the WiphyParams Message */
7981 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_IPADDRESS;
7983 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr = u16ipadd;
7984 strHostIFmsg.drvHandler = hWFIDrv;
7985 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx = idx;
7987 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7989 WILC_ERRORREPORT(s32Error, s32Error);
7991 WILC_CATCH(s32Error)
8002 * @brief host_int_get_ipaddress
8003 * @details Get IP from firmware
8004 * @param[in] Handle to wifi driver
8005 * @return Error code.
8006 * @author Abdelrahman Sobhy
8009 s32 host_int_get_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *u16ipadd, u8 idx)
8011 s32 s32Error = WILC_SUCCESS;
8012 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
8013 tstrHostIFmsg strHostIFmsg;
8015 if (pstrWFIDrv == NULL) {
8016 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
8019 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
8021 /* prepare the WiphyParams Message */
8022 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_IPADDRESS;
8024 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr = u16ipadd;
8025 strHostIFmsg.drvHandler=hWFIDrv;
8026 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx= idx;
8028 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
8030 WILC_ERRORREPORT(s32Error, s32Error);
8032 WILC_CATCH(s32Error)