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 0
21 #define HOST_IF_MSG_CONNECT 1
22 #define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
23 #define HOST_IF_MSG_KEY 3
24 #define HOST_IF_MSG_RCVD_NTWRK_INFO 4
25 #define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
26 #define HOST_IF_MSG_CFG_PARAMS 6
27 #define HOST_IF_MSG_SET_CHANNEL 7
28 #define HOST_IF_MSG_DISCONNECT 8
29 #define HOST_IF_MSG_GET_RSSI 9
30 #define HOST_IF_MSG_GET_CHNL 10
31 #define HOST_IF_MSG_ADD_BEACON 11
32 #define HOST_IF_MSG_DEL_BEACON 12
33 #define HOST_IF_MSG_ADD_STATION 13
34 #define HOST_IF_MSG_DEL_STATION 14
35 #define HOST_IF_MSG_EDIT_STATION 15
36 #define HOST_IF_MSG_SCAN_TIMER_FIRED 16
37 #define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
38 #define HOST_IF_MSG_POWER_MGMT 18
39 #define HOST_IF_MSG_GET_INACTIVETIME 19
40 #define HOST_IF_MSG_REMAIN_ON_CHAN 20
41 #define HOST_IF_MSG_REGISTER_FRAME 21
42 #define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
43 #define HOST_IF_MSG_GET_LINKSPEED 23
44 #define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
45 #define HOST_IF_MSG_SET_MAC_ADDRESS 25
46 #define HOST_IF_MSG_GET_MAC_ADDRESS 26
47 #define HOST_IF_MSG_SET_OPERATION_MODE 27
48 #define HOST_IF_MSG_SET_IPADDRESS 28
49 #define HOST_IF_MSG_GET_IPADDRESS 29
50 #define HOST_IF_MSG_FLUSH_CONNECT 30
51 #define HOST_IF_MSG_GET_STATISTICS 31
52 #define HOST_IF_MSG_SET_MULTICAST_FILTER 32
53 #define HOST_IF_MSG_ADD_BA_SESSION 33
54 #define HOST_IF_MSG_DEL_BA_SESSION 34
55 #define HOST_IF_MSG_Q_IDLE 35
56 #define HOST_IF_MSG_DEL_ALL_STA 36
57 #define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
58 #define HOST_IF_MSG_EXIT 100
60 #define HOST_IF_SCAN_TIMEOUT 4000
61 #define HOST_IF_CONNECT_TIMEOUT 9500
63 #define BA_SESSION_DEFAULT_BUFFER_SIZE 16
64 #define BA_SESSION_DEFAULT_TIMEOUT 1000
65 #define BLOCK_ACK_REQ_SIZE 0x14
66 /*****************************************************************************/
67 /* Type Definitions */
68 /*****************************************************************************/
71 * @struct tstrHostIFCfgParamAttr
72 * @brief Structure to hold Host IF CFG Params Attributes
76 * @author Mai Daftedar
80 typedef struct _tstrHostIFCfgParamAttr {
81 tstrCfgParamVal pstrCfgParamVal;
83 } tstrHostIFCfgParamAttr;
86 * @struct tstrHostIFwpaAttr
87 * @brief Structure to hold Host IF Scan Attributes
91 * @author Mai Daftedar
95 typedef struct _tstrHostIFwpaAttr {
107 * @struct tstrHostIFwepAttr
108 * @brief Structure to hold Host IF Scan Attributes
112 * @author Mai Daftedar
113 * @date 25 March 2012
116 typedef struct _tstrHostIFwepAttr {
121 AUTHTYPE_T tenuAuth_type;
126 * @struct tuniHostIFkeyAttr
127 * @brief Structure to hold Host IF Scan Attributes
131 * @author Mai Daftedar
132 * @date 25 March 2012
135 typedef union _tuniHostIFkeyAttr {
136 tstrHostIFwepAttr strHostIFwepAttr;
137 tstrHostIFwpaAttr strHostIFwpaAttr;
138 tstrHostIFpmkidAttr strHostIFpmkidAttr;
142 * @struct tstrHostIFkeyAttr
143 * @brief Structure to hold Host IF Scan Attributes
147 * @author Mai Daftedar
148 * @date 25 March 2012
151 typedef struct _tstrHostIFkeyAttr {
152 tenuKeyType enuKeyType;
154 tuniHostIFkeyAttr uniHostIFkeyAttr;
161 * @struct tstrHostIFscanAttr
162 * @brief Structure to hold Host IF Scan Attributes
166 * @author Mostafa Abu Bakr
167 * @date 25 March 2012
170 typedef struct _tstrHostIFscanAttr {
177 tWILCpfScanResult pfScanResult;
180 tstrHiddenNetwork strHiddenNetwork;
182 } tstrHostIFscanAttr;
185 * @struct tstrHostIFconnectAttr
186 * @brief Structure to hold Host IF Connect Attributes
190 * @author Mostafa Abu Bakr
191 * @date 25 March 2012
194 typedef struct _tstrHostIFconnectAttr {
201 tWILCpfConnectResult pfConnectResult;
203 AUTHTYPE_T tenuAuth_type;
206 } tstrHostIFconnectAttr;
209 * @struct tstrRcvdGnrlAsyncInfo
210 * @brief Structure to hold Received General Asynchronous info
214 * @author Mostafa Abu Bakr
215 * @date 25 March 2012
218 typedef struct _tstrRcvdGnrlAsyncInfo {
221 } tstrRcvdGnrlAsyncInfo;
224 * @struct tstrHostIFSetChan
225 * @brief Set Channel message body
229 * @author Mai Daftedar
230 * @date 25 March 2012
233 typedef struct _tstrHostIFSetChan {
238 * @struct tstrHostIFSetChan
239 * @brief Get Channel message body
243 * @author Mai Daftedar
247 typedef struct _tstrHostIFGetChan {
251 /*bug3819: Add Scan acomplete notification to host*/
253 * @struct tstrScanComplete
254 * @brief hold received Async. Scan Complete message body
259 * @date 25 March 2012
262 /*typedef struct _tstrScanComplete
266 * } tstrScanComplete;*/
269 * @struct tstrHostIFSetBeacon
270 * @brief Set Beacon message body
274 * @author Adham Abozaeid
278 typedef struct _tstrHostIFSetBeacon {
279 u32 u32Interval; /*!< Beacon Interval. Period between two successive beacons on air */
280 u32 u32DTIMPeriod; /*!< DTIM Period. Indicates how many Beacon frames
281 * (including the current frame) appear before the next DTIM */
282 u32 u32HeadLen; /*!< Length of the head buffer in bytes */
283 u8 *pu8Head; /*!< Pointer to the beacon's head buffer. Beacon's head is the part
284 * from the beacon's start till the TIM element, NOT including the TIM */
285 u32 u32TailLen; /*!< Length of the tail buffer in bytes */
286 u8 *pu8Tail; /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just
287 * after the TIM inormation element */
288 } tstrHostIFSetBeacon;
293 * @struct tstrHostIFDelBeacon
294 * @brief Del Beacon message body
298 * @author Adham Abozaeid
302 typedef struct _tstrHostIFDelBeacon {
304 } tstrHostIFDelBeacon;
307 * @struct tstrHostIFSetMulti
308 * @brief set Multicast filter Address
312 * @author Abdelrahman Sobhy
313 * @date 30 August 2013
314 * @version 1.0 Description
320 } tstrHostIFSetMulti;
323 * @struct tstrHostIFDelAllSta
324 * @brief Deauth station message body
328 * @author Mai Daftedar
329 * @date 09 April 2014
330 * @version 1.0 Description
334 u8 au8Sta_DelAllSta[MAX_NUM_STA][ETH_ALEN];
336 } tstrHostIFDelAllSta;
339 * @struct tstrHostIFDelSta
340 * @brief Delete station message body
344 * @author Adham Abozaeid
346 * @version 1.0 Description
350 u8 au8MacAddr[ETH_ALEN];
354 * @struct tstrTimerCb
355 * @brief Timer callback message body
359 * @author Mostafa Abu Bakr
360 * @date 25 March 2012
363 typedef struct _tstrTimerCb {
364 void *pvUsrArg; /*!< Private data passed at timer start */
368 * @struct tstrHostIfPowerMgmtParam
369 * @brief Power management message body
373 * @author Adham Abozaeid
374 * @date 24 November 2012
381 } tstrHostIfPowerMgmtParam;
384 * @struct tstrHostIFSetIPAddr
385 * @brief set IP Address message body
389 * @author Abdelrahman Sobhy
390 * @date 30 August 2013
391 * @version 1.0 Description
397 } tstrHostIFSetIPAddr;
400 * @struct tstrHostIfStaInactiveT
401 * @brief Get station message body
405 * @author Mai Daftedar
406 * @date 16 April 2013
412 } tstrHostIfStaInactiveT;
415 * @union tuniHostIFmsgBody
416 * @brief Message body for the Host Interface message_q
420 * @author Mostafa Abu Bakr
421 * @date 25 March 2012
424 typedef union _tuniHostIFmsgBody {
425 tstrHostIFscanAttr strHostIFscanAttr; /*!< Host IF Scan Request Attributes message body */
426 tstrHostIFconnectAttr strHostIFconnectAttr; /*!< Host IF Connect Request Attributes message body */
427 tstrRcvdNetworkInfo strRcvdNetworkInfo; /*!< Received Asynchronous Network Info message body */
428 tstrRcvdGnrlAsyncInfo strRcvdGnrlAsyncInfo; /*!< Received General Asynchronous Info message body */
429 tstrHostIFkeyAttr strHostIFkeyAttr; /*!<>*/
430 tstrHostIFCfgParamAttr strHostIFCfgParamAttr; /*! <CFG Parameter message Body> */
431 tstrHostIFSetChan strHostIFSetChan;
432 tstrHostIFGetChan strHostIFGetChan;
433 tstrHostIFSetBeacon strHostIFSetBeacon; /*!< Set beacon message body */
434 tstrHostIFDelBeacon strHostIFDelBeacon; /*!< Del beacon message body */
435 tstrWILC_AddStaParam strAddStaParam; /*!< Add station message body */
436 tstrHostIFDelSta strDelStaParam; /*!< Del Station message body */
437 tstrWILC_AddStaParam strEditStaParam; /*!< Edit station message body */
438 /* tstrScanComplete strScanComplete; / *Received Async. Scan Complete message body* / */
439 tstrTimerCb strTimerCb; /*!< Timer callback message body */
440 tstrHostIfPowerMgmtParam strPowerMgmtparam; /*!< Power Management message body */
441 tstrHostIfStaInactiveT strHostIfStaInactiveT;
442 tstrHostIFSetIPAddr strHostIfSetIP;
443 tstrHostIfSetDrvHandler strHostIfSetDrvHandler;
444 tstrHostIFSetMulti strHostIfSetMulti;
445 tstrHostIfSetOperationMode strHostIfSetOperationMode;
446 tstrHostIfSetMacAddress strHostIfSetMacAddress;
447 tstrHostIfGetMacAddress strHostIfGetMacAddress;
448 tstrHostIfBASessionInfo strHostIfBASessionInfo;
450 tstrHostIfRemainOnChan strHostIfRemainOnChan;
451 tstrHostIfRegisterFrame strHostIfRegisterFrame;
454 tstrHostIFDelAllSta strHostIFDelAllSta;
458 * @struct tstrHostIFmsg
459 * @brief Host Interface message
463 * @author Mostafa Abu Bakr
464 * @date 25 March 2012
467 typedef struct _tstrHostIFmsg {
468 u16 u16MsgId; /*!< Message ID */
469 tuniHostIFmsgBody uniHostIFmsgBody; /*!< Message body */
473 #ifdef CONNECT_DIRECT
474 typedef struct _tstrWidJoinReqExt {
475 char SSID[MAX_SSID_LEN];
481 /*Bug4218: Parsing Join Param*/
482 #ifdef WILC_PARSE_SCAN_IN_HOST
483 /*Struct containg joinParam of each AP*/
484 typedef struct _tstrJoinBssParam {
490 char ssid[MAX_SSID_LEN];
492 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
499 u8 rsn_pcip_policy[3];
500 u8 rsn_auth_policy[3];
502 struct _tstrJoinParam *nextJoinBss;
515 /*Bug4218: Parsing Join Param*/
516 /*a linked list table containing needed join parameters entries for each AP found in most recent scan*/
517 typedef struct _tstrBssTable {
519 tstrJoinBssParam *head;
520 tstrJoinBssParam *tail;
522 #endif /*WILC_PARSE_SCAN_IN_HOST*/
527 SCAN_CONNECT_TIMER_FORCE_32BIT = 0xFFFFFFFF
530 /*****************************************************************************/
532 /* Global Variabls */
534 /*****************************************************************************/
537 tstrWILC_WFIDrv *terminated_handle = NULL;
538 tstrWILC_WFIDrv *gWFiDrvHandle = NULL;
539 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
540 bool g_obtainingIP = false;
543 static struct task_struct *HostIFthreadHandler;
544 static WILC_MsgQueueHandle gMsgQHostIF;
545 static struct semaphore hSemHostIFthrdEnd;
547 struct semaphore hSemDeinitDrvHandle;
548 static struct semaphore hWaitResponse;
549 struct semaphore hSemHostIntDeinit;
550 WILC_TimerHandle g_hPeriodicRSSI;
554 u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
556 #ifndef CONNECT_DIRECT
557 static u8 gapu8RcvdSurveyResults[2][MAX_SURVEY_RESULT_FRAG_SIZE];
560 static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE];
562 bool gbScanWhileConnected = false;
567 static u8 gs8SetIP[2][4];
568 static u8 gs8GetIP[2][4];
569 #ifdef WILC_AP_EXTERNAL_MLME
570 static u32 gu32InactiveTime;
574 static u32 gu32WidConnRstHack;
578 u8 *gu8FlushedJoinReq;
579 u8 *gu8FlushedInfoElemAsoc;
580 u8 gu8Flushed11iMode;
581 u8 gu8FlushedAuthType;
582 u32 gu32FlushedJoinReqSize;
583 u32 gu32FlushedInfoElemAsocSize;
584 u32 gu8FlushedJoinReqDrvHandler;
585 #define REAL_JOIN_REQ 0
586 #define FLUSHED_JOIN_REQ 1
587 #define FLUSHED_BYTE_POS 79 /* Position the byte indicating flushing in the flushed request */
589 /*Bug4218: Parsing Join Param*/
590 #ifdef WILC_PARSE_SCAN_IN_HOST
591 /*Bug4218: Parsing Join Param*/
592 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
593 #endif /*WILC_PARSE_SCAN_IN_HOST*/
595 extern void chip_sleep_manually(u32 u32SleepTime);
596 extern int linux_wlan_get_num_conn_ifcs(void);
599 * @brief Handle_SetChannel
600 * @details Sending config packet to firmware to set channel
601 * @param[in] tstrHostIFSetChan* pstrHostIFSetChan
602 * @return Error code.
607 static s32 Handle_SetChannel(void *drvHandler, tstrHostIFSetChan *pstrHostIFSetChan)
610 s32 s32Error = WILC_SUCCESS;
612 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
614 /*prepare configuration packet*/
615 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
616 strWID.enuWIDtype = WID_CHAR;
617 strWID.ps8WidVal = (char *)&(pstrHostIFSetChan->u8SetChan);
618 strWID.s32ValueSize = sizeof(char);
620 PRINT_D(HOSTINF_DBG, "Setting channel\n");
622 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
624 PRINT_ER("Failed to set channel\n");
625 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
635 * @brief Handle_SetWfiDrvHandler
636 * @details Sending config packet to firmware to set driver handler
637 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
638 * @return Error code.
643 static s32 Handle_SetWfiDrvHandler(tstrHostIfSetDrvHandler *pstrHostIfSetDrvHandler)
646 s32 s32Error = WILC_SUCCESS;
648 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)((pstrHostIfSetDrvHandler->u32Address));
651 /*prepare configuration packet*/
652 strWID.u16WIDid = (u16)WID_SET_DRV_HANDLER;
653 strWID.enuWIDtype = WID_INT;
654 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetDrvHandler->u32Address);
655 strWID.s32ValueSize = sizeof(u32);
659 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
662 if ((pstrHostIfSetDrvHandler->u32Address) == (u32)NULL)
663 up(&hSemDeinitDrvHandle);
667 PRINT_ER("Failed to set driver handler\n");
668 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
679 * @brief Handle_SetWfiAPDrvHandler
680 * @details Sending config packet to firmware to set driver handler
681 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
682 * @return Error code.
687 static s32 Handle_SetOperationMode(void *drvHandler, tstrHostIfSetOperationMode *pstrHostIfSetOperationMode)
690 s32 s32Error = WILC_SUCCESS;
692 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
695 /*prepare configuration packet*/
696 strWID.u16WIDid = (u16)WID_SET_OPERATION_MODE;
697 strWID.enuWIDtype = WID_INT;
698 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetOperationMode->u32Mode);
699 strWID.s32ValueSize = sizeof(u32);
702 PRINT_INFO(HOSTINF_DBG, "pstrWFIDrv= %p\n", pstrWFIDrv);
704 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
707 if ((pstrHostIfSetOperationMode->u32Mode) == (u32)NULL)
708 up(&hSemDeinitDrvHandle);
712 PRINT_ER("Failed to set driver handler\n");
713 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
724 * @brief host_int_set_IPAddress
725 * @details Setting IP address params in message queue
726 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
727 * @return Error code.
732 s32 Handle_set_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx)
735 s32 s32Error = WILC_SUCCESS;
737 char firmwareIPAddress[4] = {0};
738 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
740 if (pu8IPAddr[0] < 192)
743 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %d.%d.%d.%d\n", idx, pu8IPAddr[0], pu8IPAddr[1], pu8IPAddr[2], pu8IPAddr[3]);
745 WILC_memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN);
747 /*prepare configuration packet*/
748 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
749 strWID.enuWIDtype = WID_STR;
750 strWID.ps8WidVal = (u8 *)pu8IPAddr;
751 strWID.s32ValueSize = IP_ALEN;
753 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
757 host_int_get_ipaddress((WILC_WFIDrvHandle)drvHandler, firmwareIPAddress, idx);
760 PRINT_D(HOSTINF_DBG, "Failed to set IP address\n");
761 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
763 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
776 * @brief Handle_get_IPAddress
777 * @details Setting IP address params in message queue
778 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
779 * @return Error code.
784 s32 Handle_get_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx)
787 s32 s32Error = WILC_SUCCESS;
789 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
791 /*prepare configuration packet*/
792 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
793 strWID.enuWIDtype = WID_STR;
794 strWID.ps8WidVal = (u8 *)WILC_MALLOC(IP_ALEN);
795 strWID.s32ValueSize = IP_ALEN;
797 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
799 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]));
801 WILC_memcpy(gs8GetIP[idx], strWID.ps8WidVal, IP_ALEN);
803 /*get the value by searching the local copy*/
804 WILC_FREE(strWID.ps8WidVal);
806 if (WILC_memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0)
807 host_int_setup_ipaddress((WILC_WFIDrvHandle)pstrWFIDrv, gs8SetIP[idx], idx);
809 if (s32Error != WILC_SUCCESS) {
810 PRINT_ER("Failed to get IP address\n");
811 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
813 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
814 PRINT_INFO(HOSTINF_DBG, "%d.%d.%d.%d\n", gs8GetIP[idx][0], gs8GetIP[idx][1], gs8GetIP[idx][2], gs8GetIP[idx][3]);
815 PRINT_INFO(HOSTINF_DBG, "\n");
829 * @brief Handle_SetMacAddress
830 * @details Setting mac address
831 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
832 * @return Error code.
833 * @author Amr Abdel-Moghny
834 * @date November 2013
837 static s32 Handle_SetMacAddress(void *drvHandler, tstrHostIfSetMacAddress *pstrHostIfSetMacAddress)
840 s32 s32Error = WILC_SUCCESS;
842 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
843 u8 *mac_buf = (u8 *)WILC_MALLOC(ETH_ALEN);
845 if (mac_buf == NULL) {
846 PRINT_ER("No buffer to send mac address\n");
849 WILC_memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
851 /*prepare configuration packet*/
852 strWID.u16WIDid = (u16)WID_MAC_ADDR;
853 strWID.enuWIDtype = WID_STR;
854 strWID.ps8WidVal = mac_buf;
855 strWID.s32ValueSize = ETH_ALEN;
856 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]);
858 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
860 PRINT_ER("Failed to set mac address\n");
861 WILC_ERRORREPORT(s32Error, WILC_FAIL);
875 * @brief Handle_GetMacAddress
876 * @details Getting mac address
877 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
878 * @return Error code.
879 * @author Amr Abdel-Moghny
883 static s32 Handle_GetMacAddress(void *drvHandler, tstrHostIfGetMacAddress *pstrHostIfGetMacAddress)
886 s32 s32Error = WILC_SUCCESS;
889 /*prepare configuration packet*/
890 strWID.u16WIDid = (u16)WID_MAC_ADDR;
891 strWID.enuWIDtype = WID_STR;
892 strWID.ps8WidVal = pstrHostIfGetMacAddress->u8MacAddress;
893 strWID.s32ValueSize = ETH_ALEN;
896 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, false, (u32)drvHandler);
898 PRINT_ER("Failed to get mac address\n");
899 WILC_ERRORREPORT(s32Error, WILC_FAIL);
912 * @brief Handle_CfgParam
913 * @details Sending config packet to firmware to set CFG params
914 * @param[in] tstrHostIFCfgParamAttr* strHostIFCfgParamAttr
915 * @return Error code.
920 static s32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *strHostIFCfgParamAttr)
922 s32 s32Error = WILC_SUCCESS;
923 tstrWID strWIDList[32];
925 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
928 down(&(pstrWFIDrv->gtOsCfgValuesSem));
931 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
933 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BSS_TYPE) {
934 /*----------------------------------------------------------*/
935 /*Input Value: INFRASTRUCTURE = 1, */
936 /* INDEPENDENT= 2, */
938 /*----------------------------------------------------------*/
939 /* validate input then copy>> need to check value 4 and 5 */
940 if (strHostIFCfgParamAttr->pstrCfgParamVal.bss_type < 6) {
941 strWIDList[u8WidCnt].u16WIDid = WID_BSS_TYPE;
942 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
943 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
944 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
945 pstrWFIDrv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
947 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
951 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTH_TYPE) {
952 /*------------------------------------------------------*/
953 /*Input Values: OPEN_SYSTEM = 0, */
954 /* SHARED_KEY = 1, */
956 /*------------------------------------------------------*/
957 /*validate Possible values*/
958 if ((strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 1 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 2 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 5) {
959 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TYPE;
960 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
961 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
962 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
963 pstrWFIDrv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
965 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
969 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTHEN_TIMEOUT) {
970 /* range is 1 to 65535. */
971 if (strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout < 65536) {
972 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TIMEOUT;
973 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
974 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
975 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
976 pstrWFIDrv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
978 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
982 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & POWER_MANAGEMENT) {
983 /*-----------------------------------------------------------*/
984 /*Input Values: NO_POWERSAVE = 0, */
985 /* MIN_FAST_PS = 1, */
986 /* MAX_FAST_PS = 2, */
987 /* MIN_PSPOLL_PS = 3, */
988 /* MAX_PSPOLL_PS = 4 */
989 /*----------------------------------------------------------*/
990 if (strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode < 5) {
991 strWIDList[u8WidCnt].u16WIDid = WID_POWER_MANAGEMENT;
992 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
993 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
994 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
995 pstrWFIDrv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
997 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1001 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_SHORT) {
1002 /* range from 1 to 256 */
1003 if ((strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit < 256)) {
1004 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_RETRY_LIMIT;
1005 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
1006 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1007 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1008 pstrWFIDrv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
1010 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1014 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_LONG) {
1015 /* range from 1 to 256 */
1016 if ((strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit < 256)) {
1017 strWIDList[u8WidCnt].u16WIDid = WID_LONG_RETRY_LIMIT;
1018 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
1020 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1021 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1022 pstrWFIDrv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
1024 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1028 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & FRAG_THRESHOLD) {
1030 if (strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold < 7937) {
1031 strWIDList[u8WidCnt].u16WIDid = WID_FRAG_THRESHOLD;
1032 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
1033 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1034 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1035 pstrWFIDrv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
1037 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1041 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RTS_THRESHOLD) {
1042 /* range 256 to 65535 */
1043 if (strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold < 65536) {
1044 strWIDList[u8WidCnt].u16WIDid = WID_RTS_THRESHOLD;
1045 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
1046 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1047 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1048 pstrWFIDrv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
1050 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1054 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PREAMBLE) {
1055 /*-----------------------------------------------------*/
1056 /*Input Values: Short= 0, */
1059 /*------------------------------------------------------*/
1060 if (strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type < 3) {
1061 strWIDList[u8WidCnt].u16WIDid = WID_PREAMBLE;
1062 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
1063 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1064 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1065 pstrWFIDrv->strCfgValues.preamble_type = strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
1067 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1071 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SHORT_SLOT_ALLOWED) {
1072 if (strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed < 2) {
1073 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_SLOT_ALLOWED;
1074 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
1075 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1076 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1077 pstrWFIDrv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
1079 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1083 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & TXOP_PROT_DISABLE) {
1084 /*Description: used to Disable RTS-CTS protection for TXOP burst*/
1085 /*transmission when the acknowledgement policy is No-Ack or Block-Ack */
1086 /* this information is useful for external supplicant */
1087 /*Input Values: 1 for enable and 0 for disable. */
1088 if (strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled < 2) {
1089 strWIDList[u8WidCnt].u16WIDid = WID_11N_TXOP_PROT_DISABLE;
1090 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
1091 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1092 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1093 pstrWFIDrv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
1095 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1099 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BEACON_INTERVAL) {
1100 /* range is 1 to 65535. */
1101 if (strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval < 65536) {
1102 strWIDList[u8WidCnt].u16WIDid = WID_BEACON_INTERVAL;
1103 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
1104 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1105 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1106 pstrWFIDrv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
1108 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1112 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & DTIM_PERIOD) {
1113 /* range is 1 to 255. */
1114 if (strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period < 256) {
1115 strWIDList[u8WidCnt].u16WIDid = WID_DTIM_PERIOD;
1116 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
1117 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1118 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1119 pstrWFIDrv->strCfgValues.dtim_period = strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
1121 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1125 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY) {
1126 /*----------------------------------------------------------------------*/
1127 /*Input Values: SITE_SURVEY_1CH = 0, i.e.: currently set channel */
1128 /* SITE_SURVEY_ALL_CH = 1, */
1129 /* SITE_SURVEY_OFF = 2 */
1130 /*----------------------------------------------------------------------*/
1131 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled < 3) {
1132 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY;
1133 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
1134 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1135 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1136 pstrWFIDrv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
1138 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1142 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY_SCAN_TIME) {
1143 /* range is 1 to 65535. */
1144 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time < 65536) {
1145 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY_SCAN_TIME;
1146 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
1147 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1148 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1149 pstrWFIDrv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
1151 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1155 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & ACTIVE_SCANTIME) {
1156 /* range is 1 to 65535. */
1157 if (strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time < 65536) {
1158 strWIDList[u8WidCnt].u16WIDid = WID_ACTIVE_SCAN_TIME;
1159 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
1160 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1161 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1162 pstrWFIDrv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
1164 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1168 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PASSIVE_SCANTIME) {
1169 /* range is 1 to 65535. */
1170 if (strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time < 65536) {
1171 strWIDList[u8WidCnt].u16WIDid = WID_PASSIVE_SCAN_TIME;
1172 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
1173 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1174 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1175 pstrWFIDrv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
1177 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1181 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & CURRENT_TX_RATE) {
1182 CURRENT_TX_RATE_T curr_tx_rate = strHostIFCfgParamAttr->pstrCfgParamVal.curr_tx_rate;
1183 /*----------------------------------------------------------------------*/
1184 /*Rates: 1 2 5.5 11 6 9 12 18 24 36 48 54 Auto */
1185 /*InputValues: 1 2 3 4 5 6 7 8 9 10 11 12 0 */
1186 /*----------------------------------------------------------------------*/
1188 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
1189 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
1190 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
1191 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
1192 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
1193 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
1194 strWIDList[u8WidCnt].u16WIDid = WID_CURRENT_TX_RATE;
1195 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&curr_tx_rate;
1196 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1197 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1198 pstrWFIDrv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
1200 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1204 s32Error = SendConfigPkt(SET_CFG, strWIDList, u8WidCnt, false, (u32)pstrWFIDrv);
1207 PRINT_ER("Error in setting CFG params\n");
1209 WILC_CATCH(s32Error)
1212 up(&(pstrWFIDrv->gtOsCfgValuesSem));
1218 * @brief Handle_wait_msg_q_empty
1219 * @details this should be the last msg and then the msg Q becomes idle
1220 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1221 * @return Error code.
1226 static s32 Handle_wait_msg_q_empty(void)
1228 s32 s32Error = WILC_SUCCESS;
1230 g_wilc_initialized = 0;
1236 * @brief Handle_Scan
1237 * @details Sending config packet to firmware to set the scan params
1238 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1239 * @return Error code.
1244 static s32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr *pstrHostIFscanAttr)
1246 s32 s32Error = WILC_SUCCESS;
1247 tstrWID strWIDList[5];
1248 u32 u32WidsCount = 0;
1252 u8 *pu8HdnNtwrksWidVal = NULL;
1253 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
1255 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1256 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", pstrWFIDrv->enuHostIFstate);
1258 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->pfScanResult;
1259 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->pvUserArg;
1264 if ((pstrWFIDrv->enuHostIFstate >= HOST_IF_SCANNING) && (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTED)) {
1265 /* here we either in HOST_IF_SCANNING, HOST_IF_WAITING_CONN_REQ or HOST_IF_WAITING_CONN_RESP */
1266 PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", pstrWFIDrv->enuHostIFstate);
1267 WILC_ERRORREPORT(s32Error, WILC_BUSY);
1270 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
1271 if (g_obtainingIP || connecting) {
1272 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
1273 WILC_ERRORREPORT(s32Error, WILC_BUSY);
1277 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1280 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount = 0;
1283 strWIDList[u32WidsCount].u16WIDid = (u16)WID_SSID_PROBE_REQ;
1284 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1286 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++)
1287 valuesize += ((pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
1288 pu8HdnNtwrksWidVal = WILC_MALLOC(valuesize + 1);
1289 strWIDList[u32WidsCount].ps8WidVal = pu8HdnNtwrksWidVal;
1290 if (strWIDList[u32WidsCount].ps8WidVal != NULL) {
1291 pu8Buffer = strWIDList[u32WidsCount].ps8WidVal;
1293 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum;
1295 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum);
1297 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) {
1298 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1299 WILC_memcpy(pu8Buffer, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen);
1300 pu8Buffer += pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1305 strWIDList[u32WidsCount].s32ValueSize = (s32)(valuesize + 1);
1309 /*filling cfg param array*/
1311 /* if((pstrHostIFscanAttr->pu8IEs != NULL) && (pstrHostIFscanAttr->IEsLen != 0)) */
1313 /* IEs to be inserted in Probe Request */
1314 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_PROBE;
1315 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1316 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8IEs;
1317 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->IEsLen;
1322 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_TYPE;
1323 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1324 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1325 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanType));
1328 /*list of channels to be scanned*/
1329 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_CHANNEL_LIST;
1330 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1332 /* Bug 4648: Convert channel numbers to start from 0 not 1. */
1333 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL && pstrHostIFscanAttr->u8ChnlListLen > 0) {
1336 for (i = 0; i < pstrHostIFscanAttr->u8ChnlListLen; i++) {
1337 if (pstrHostIFscanAttr->pu8ChnlFreqList[i] > 0)
1338 pstrHostIFscanAttr->pu8ChnlFreqList[i] = pstrHostIFscanAttr->pu8ChnlFreqList[i] - 1;
1342 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8ChnlFreqList;
1343 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->u8ChnlListLen;
1347 strWIDList[u32WidsCount].u16WIDid = WID_START_SCAN_REQ;
1348 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1349 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1350 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanSource));
1353 /*keep the state as is , no need to change it*/
1354 /* gWFiDrvHandle->enuHostIFstate = HOST_IF_SCANNING; */
1356 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
1357 gbScanWhileConnected = true;
1358 } else if (pstrWFIDrv->enuHostIFstate == HOST_IF_IDLE) {
1359 gbScanWhileConnected = false;
1362 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, (u32)pstrWFIDrv);
1365 PRINT_ER("Failed to send scan paramters config packet\n");
1366 WILC_ERRORREPORT(s32Error, s32Error);
1368 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
1371 WILC_CATCH(s32Error)
1373 WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL);
1374 /*if there is an ongoing scan request*/
1375 Handle_ScanDone(drvHandler, SCAN_EVENT_ABORTED);
1378 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1379 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
1380 WILC_FREE(pstrHostIFscanAttr->pu8ChnlFreqList);
1381 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1384 /* Deallocate pstrHostIFscanAttr->pu8IEs which was previously allocated by the sending thread */
1385 if (pstrHostIFscanAttr->pu8IEs != NULL) {
1386 WILC_FREE(pstrHostIFscanAttr->pu8IEs);
1387 pstrHostIFscanAttr->pu8IEs = NULL;
1389 if (pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo != NULL) {
1390 WILC_FREE(pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo);
1391 pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo = NULL;
1394 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1395 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
1396 WILC_FREE(pstrHostIFscanAttr->pu8ChnlFreqList);
1397 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1400 if (pu8HdnNtwrksWidVal != NULL)
1401 WILC_FREE(pu8HdnNtwrksWidVal);
1407 * @brief Handle_ScanDone
1408 * @details Call scan notification callback function
1410 * @return Error code.
1415 static s32 Handle_ScanDone(void *drvHandler, tenuScanEvent enuEvent)
1417 s32 s32Error = WILC_SUCCESS;
1419 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
1422 u8 u8abort_running_scan;
1426 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
1429 /*Ask FW to abort the running scan, if any*/
1430 if (enuEvent == SCAN_EVENT_ABORTED) {
1431 PRINT_D(GENERIC_DBG, "Abort running scan\n");
1432 u8abort_running_scan = 1;
1433 strWID.u16WIDid = (u16)WID_ABORT_RUNNING_SCAN;
1434 strWID.enuWIDtype = WID_CHAR;
1435 strWID.ps8WidVal = (s8 *)&u8abort_running_scan;
1436 strWID.s32ValueSize = sizeof(char);
1439 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
1440 if (s32Error != WILC_SUCCESS) {
1441 PRINT_ER("Failed to set abort running scan\n");
1442 WILC_ERRORREPORT(s32Error, WILC_FAIL);
1444 WILC_CATCH(s32Error)
1449 if (pstrWFIDrv == NULL) {
1450 PRINT_ER("Driver handler is NULL\n");
1454 /*if there is an ongoing scan request*/
1455 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
1456 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
1457 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
1458 /*delete current scan request*/
1459 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
1466 * @brief Handle_Connect
1467 * @details Sending config packet to firmware to starting connection
1468 * @param[in] tstrHostIFconnectAttr* pstrHostIFconnectAttr
1469 * @return Error code.
1474 u8 u8ConnectedSSID[6] = {0};
1475 static s32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrHostIFconnectAttr)
1477 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
1478 s32 s32Error = WILC_SUCCESS;
1479 tstrWID strWIDList[8];
1480 u32 u32WidsCount = 0, dummyval = 0;
1481 /* char passphrase[] = "12345678"; */
1482 #ifndef CONNECT_DIRECT
1483 s32 s32Err = WILC_SUCCESS;
1485 u8 u8bssDscListIndex;
1486 wid_site_survey_reslts_s *pstrSurveyResults = NULL;
1488 u8 *pu8CurrByte = NULL;
1489 /*Bug4218: Parsing Join Param*/
1490 #ifdef WILC_PARSE_SCAN_IN_HOST
1491 tstrJoinBssParam *ptstrJoinBssParam;
1492 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1496 PRINT_D(GENERIC_DBG, "Handling connect request\n");
1498 #ifndef CONNECT_DIRECT
1499 WILC_memset(gapu8RcvdSurveyResults[0], 0, MAX_SURVEY_RESULT_FRAG_SIZE);
1500 WILC_memset(gapu8RcvdSurveyResults[1], 0, MAX_SURVEY_RESULT_FRAG_SIZE);
1503 PRINT_D(HOSTINF_DBG, "Getting site survey results\n");
1504 s32Err = host_int_get_site_survey_results((WILC_WFIDrvHandle)pstrWFIDrv,
1505 gapu8RcvdSurveyResults,
1506 MAX_SURVEY_RESULT_FRAG_SIZE);
1508 PRINT_ER("Failed to get site survey results\n");
1509 WILC_ERRORREPORT(s32Error, WILC_FAIL);
1512 s32Err = ParseSurveyResults(gapu8RcvdSurveyResults, &pstrSurveyResults,
1513 &pstrWFIDrv->u32SurveyResultsCount);
1516 if (s32Err == WILC_SUCCESS) {
1517 /* use the parsed info in pstrSurveyResults, then deallocate it */
1518 PRINT_D(HOSTINF_DBG, "Copying site survey results in global structure, then deallocate\n");
1519 for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) {
1520 WILC_memcpy(&pstrWFIDrv->astrSurveyResults[i], &pstrSurveyResults[i],
1521 sizeof(wid_site_survey_reslts_s));
1524 DeallocateSurveyResults(pstrSurveyResults);
1526 WILC_ERRORREPORT(s32Error, WILC_FAIL);
1527 PRINT_ER("ParseSurveyResults() Error(%d)\n", s32Err);
1531 for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) {
1532 if (WILC_memcmp(pstrWFIDrv->astrSurveyResults[i].SSID,
1533 pstrHostIFconnectAttr->pu8ssid,
1534 pstrHostIFconnectAttr->ssidLen) == 0) {
1535 PRINT_INFO(HOSTINF_DBG, "Network with required SSID is found %s\n", pstrHostIFconnectAttr->pu8ssid);
1536 if (pstrHostIFconnectAttr->pu8bssid == NULL) {
1537 /* BSSID is not passed from the user, so decision of matching
1538 * is done by SSID only */
1539 PRINT_INFO(HOSTINF_DBG, "BSSID is not passed from the user\n");
1542 /* BSSID is also passed from the user, so decision of matching
1543 * should consider also this passed BSSID */
1545 if (WILC_memcmp(pstrWFIDrv->astrSurveyResults[i].BSSID,
1546 pstrHostIFconnectAttr->pu8bssid,
1548 PRINT_INFO(HOSTINF_DBG, "BSSID is passed from the user and matched\n");
1555 if (i < pstrWFIDrv->u32SurveyResultsCount) {
1556 u8bssDscListIndex = i;
1558 PRINT_INFO(HOSTINF_DBG, "Connecting to network of Bss Idx%d and SSID %s and channel%d\n",
1559 u8bssDscListIndex, pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].SSID,
1560 pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].Channel);
1562 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1564 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1565 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = (u8 *)WILC_MALLOC(6);
1566 WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
1569 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1570 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1571 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->ssidLen + 1);
1572 WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
1573 pstrHostIFconnectAttr->ssidLen);
1574 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1577 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1578 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1579 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->IEsLen);
1580 WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
1581 pstrHostIFconnectAttr->IEsLen);
1584 pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1585 pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1586 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1587 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1590 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1591 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1593 /* IEs to be inserted in Association Request */
1594 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1595 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1596 strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1597 strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1600 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
1601 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1602 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1603 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
1606 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1608 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
1609 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1610 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1611 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1614 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1616 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
1617 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1618 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
1619 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
1623 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ;
1624 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1625 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1626 strWIDList[u32WidsCount].ps8WidVal = (s8 *)&u8bssDscListIndex;
1630 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1631 * firmware at chip reset when processing the WIDs of the Connect Request.
1632 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1633 /* ////////////////////// */
1634 gu32WidConnRstHack = 0;
1635 /* ////////////////////// */
1638 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, (u32)pstrWFIDrv);
1640 PRINT_ER("Handle_Connect()] failed to send config packet\n");
1641 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
1643 pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1647 PRINT_ER("Required BSSID not found\n");
1648 WILC_ERRORREPORT(s32Error, WILC_NOT_FOUND);
1653 /* if we try to connect to an already connected AP then discard the request */
1655 if (WILC_memcmp(pstrHostIFconnectAttr->pu8bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
1657 s32Error = WILC_SUCCESS;
1658 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1662 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1664 /*Bug4218: Parsing Join Param*/
1665 #ifdef WILC_PARSE_SCAN_IN_HOST
1666 ptstrJoinBssParam = (tstrJoinBssParam *)pstrHostIFconnectAttr->pJoinParams;
1667 if (ptstrJoinBssParam == NULL) {
1668 PRINT_ER("Required BSSID not found\n");
1669 WILC_ERRORREPORT(s32Error, WILC_NOT_FOUND);
1671 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1673 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1674 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = (u8 *)WILC_MALLOC(6);
1675 WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
1678 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1679 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1680 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->ssidLen + 1);
1681 WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
1682 pstrHostIFconnectAttr->ssidLen);
1683 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1686 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1687 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1688 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->IEsLen);
1689 WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
1690 pstrHostIFconnectAttr->IEsLen);
1693 pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1694 pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1695 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1696 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1698 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
1699 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
1700 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
1701 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
1704 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
1705 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
1706 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
1707 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
1710 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
1711 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
1712 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
1713 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
1716 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1717 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1719 /* IEs to be inserted in Association Request */
1720 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1721 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1722 strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1723 strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1727 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1729 gu32FlushedInfoElemAsocSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1730 gu8FlushedInfoElemAsoc = WILC_MALLOC(gu32FlushedInfoElemAsocSize);
1731 memcpy(gu8FlushedInfoElemAsoc, pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
1732 gu32FlushedInfoElemAsocSize);
1735 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
1736 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1737 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1738 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
1742 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
1743 gu8Flushed11iMode = pstrWFIDrv->strWILC_UsrConnReq.u8security;
1745 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1748 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
1749 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1750 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1751 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1755 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
1756 gu8FlushedAuthType = (u8)pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type;
1758 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1760 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
1761 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1762 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
1763 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
1767 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
1768 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->u8channel);
1771 #ifndef WILC_PARSE_SCAN_IN_HOST
1772 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
1773 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1774 strWIDList[u32WidsCount].s32ValueSize = MAX_SSID_LEN + 7;
1775 strWIDList[u32WidsCount].ps8WidVal = WILC_MALLOC(strWIDList[u32WidsCount].s32ValueSize);
1777 if (strWIDList[u32WidsCount].ps8WidVal == NULL)
1778 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
1780 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1782 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1783 WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
1784 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1786 pu8CurrByte += MAX_SSID_LEN;
1787 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1788 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1790 PRINT_ER("Channel out of range\n");
1791 *(pu8CurrByte++) = 0xFF;
1793 if (pstrHostIFconnectAttr->pu8bssid != NULL)
1794 WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
1797 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1798 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1802 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
1803 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1805 /*Sending NoA attributes during connection*/
1806 strWIDList[u32WidsCount].s32ValueSize = 112; /* 79; */
1807 strWIDList[u32WidsCount].ps8WidVal = WILC_MALLOC(strWIDList[u32WidsCount].s32ValueSize);
1810 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1811 gu32FlushedJoinReqSize = strWIDList[u32WidsCount].s32ValueSize;
1812 gu8FlushedJoinReq = WILC_MALLOC(gu32FlushedJoinReqSize);
1814 if (strWIDList[u32WidsCount].ps8WidVal == NULL)
1815 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
1817 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1820 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1821 WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
1822 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1824 pu8CurrByte += MAX_SSID_LEN;
1827 *(pu8CurrByte++) = INFRASTRUCTURE;
1829 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1830 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1832 PRINT_ER("Channel out of range\n");
1833 *(pu8CurrByte++) = 0xFF;
1836 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1837 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1838 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1841 if (pstrHostIFconnectAttr->pu8bssid != NULL)
1842 WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
1846 if (pstrHostIFconnectAttr->pu8bssid != NULL)
1847 WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
1851 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1852 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1853 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1855 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1856 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1857 /* Supported rates*/
1858 WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
1859 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1862 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1863 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1865 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1868 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1869 /* copy this information to the user request */
1870 pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
1873 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1874 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1875 /* rsn group policy*/
1876 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1877 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1879 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1880 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1881 /* rsn pcip policy*/
1882 WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
1883 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1885 /* rsn auth policy*/
1886 WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
1887 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1889 /* rsn auth policy*/
1890 WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
1891 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1894 *(pu8CurrByte++) = REAL_JOIN_REQ;
1897 *(pu8CurrByte++) = ptstrJoinBssParam->u8NoaEnbaled;
1898 if (ptstrJoinBssParam->u8NoaEnbaled) {
1899 PRINT_D(HOSTINF_DBG, "NOA present\n");
1901 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1902 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1903 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1904 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1906 *(pu8CurrByte++) = ptstrJoinBssParam->u8Index;
1908 *(pu8CurrByte++) = ptstrJoinBssParam->u8OppEnable;
1910 if (ptstrJoinBssParam->u8OppEnable)
1911 *(pu8CurrByte++) = ptstrJoinBssParam->u8CtWindow;
1913 *(pu8CurrByte++) = ptstrJoinBssParam->u8Count;
1915 WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->au8Duration, sizeof(ptstrJoinBssParam->au8Duration));
1917 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Duration);
1919 WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->au8Interval, sizeof(ptstrJoinBssParam->au8Interval));
1921 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Interval);
1923 WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
1925 pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1928 PRINT_D(HOSTINF_DBG, "NOA not present\n");
1932 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1933 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1936 #endif /* #ifdef WILC_PARSE_SCAN_IN_HOST*/
1940 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1941 * firmware at chip reset when processing the WIDs of the Connect Request.
1942 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1943 /* ////////////////////// */
1944 gu32WidConnRstHack = 0;
1945 /* ////////////////////// */
1949 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1950 memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
1951 gu8FlushedJoinReqDrvHandler = (u32)pstrWFIDrv;
1954 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1956 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1957 WILC_memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->pu8bssid, ETH_ALEN);
1959 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]));
1960 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]));
1963 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, (u32)pstrWFIDrv);
1965 PRINT_ER("Handle_Connect()] failed to send config packet\n");
1966 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
1968 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
1969 pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1973 WILC_CATCH(s32Error)
1975 tstrConnectInfo strConnectInfo;
1977 WILC_TimerStop(&(pstrWFIDrv->hConnectTimer), NULL);
1979 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
1981 WILC_memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1983 if (pstrHostIFconnectAttr->pfConnectResult != NULL) {
1984 if (pstrHostIFconnectAttr->pu8bssid != NULL)
1985 WILC_memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
1987 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1988 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1989 strConnectInfo.pu8ReqIEs = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->IEsLen);
1990 WILC_memcpy(strConnectInfo.pu8ReqIEs,
1991 pstrHostIFconnectAttr->pu8IEs,
1992 pstrHostIFconnectAttr->IEsLen);
1995 pstrHostIFconnectAttr->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1999 pstrHostIFconnectAttr->pvUserArg);
2000 /*Change state to idle*/
2001 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2003 if (strConnectInfo.pu8ReqIEs != NULL) {
2004 WILC_FREE(strConnectInfo.pu8ReqIEs);
2005 strConnectInfo.pu8ReqIEs = NULL;
2009 PRINT_ER("Connect callback function pointer is NULL\n");
2013 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
2014 /* Deallocate pstrHostIFconnectAttr->pu8bssid which was prevoisuly allocated by the sending thread */
2015 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
2016 WILC_FREE(pstrHostIFconnectAttr->pu8bssid);
2017 pstrHostIFconnectAttr->pu8bssid = NULL;
2020 /* Deallocate pstrHostIFconnectAttr->pu8ssid which was prevoisuly allocated by the sending thread */
2021 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
2022 WILC_FREE(pstrHostIFconnectAttr->pu8ssid);
2023 pstrHostIFconnectAttr->pu8ssid = NULL;
2026 /* Deallocate pstrHostIFconnectAttr->pu8IEs which was prevoisuly allocated by the sending thread */
2027 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
2028 WILC_FREE(pstrHostIFconnectAttr->pu8IEs);
2029 pstrHostIFconnectAttr->pu8IEs = NULL;
2032 if (pu8CurrByte != NULL)
2033 WILC_FREE(pu8CurrByte);
2038 * @brief Handle_FlushConnect
2039 * @details Sending config packet to firmware to flush an old connection
2040 * after switching FW from station one to hybrid one
2041 * @param[in] void * drvHandler
2042 * @return Error code.
2043 * @author Amr Abdel-Moghny
2048 static s32 Handle_FlushConnect(void *drvHandler)
2050 s32 s32Error = WILC_SUCCESS;
2051 tstrWID strWIDList[5];
2052 u32 u32WidsCount = 0;
2053 u8 *pu8CurrByte = NULL;
2056 /* IEs to be inserted in Association Request */
2057 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
2058 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
2059 strWIDList[u32WidsCount].ps8WidVal = gu8FlushedInfoElemAsoc;
2060 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedInfoElemAsocSize;
2063 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
2064 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
2065 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
2066 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(gu8Flushed11iMode));
2071 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
2072 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
2073 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
2074 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&gu8FlushedAuthType);
2078 #ifdef WILC_PARSE_SCAN_IN_HOST
2079 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
2080 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
2081 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedJoinReqSize;
2082 strWIDList[u32WidsCount].ps8WidVal = (s8 *)gu8FlushedJoinReq;
2083 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
2085 pu8CurrByte += FLUSHED_BYTE_POS;
2086 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
2092 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, gu8FlushedJoinReqDrvHandler);
2094 PRINT_ER("Handle_Flush_Connect()] failed to send config packet\n");
2095 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
2098 WILC_CATCH(s32Error)
2107 * @brief Handle_ConnectTimeout
2108 * @details Call connect notification callback function indicating connection failure
2110 * @return Error code.
2115 static s32 Handle_ConnectTimeout(void *drvHandler)
2117 s32 s32Error = WILC_SUCCESS;
2118 tstrConnectInfo strConnectInfo;
2120 u16 u16DummyReasonCode = 0;
2121 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
2123 if (pstrWFIDrv == NULL) {
2124 PRINT_ER("Driver handler is NULL\n");
2128 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2130 gbScanWhileConnected = false;
2133 WILC_memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
2136 /* First, we will notify the upper layer with the Connection failure {through the Connect Callback function},
2137 * then we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2138 * WID_DISCONNECT} */
2139 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2140 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2141 WILC_memcpy(strConnectInfo.au8bssid,
2142 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
2145 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2146 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
2147 strConnectInfo.pu8ReqIEs = (u8 *)WILC_MALLOC(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2148 WILC_memcpy(strConnectInfo.pu8ReqIEs,
2149 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2150 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2153 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2157 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2159 /* Deallocation of strConnectInfo.pu8ReqIEs */
2160 if (strConnectInfo.pu8ReqIEs != NULL) {
2161 WILC_FREE(strConnectInfo.pu8ReqIEs);
2162 strConnectInfo.pu8ReqIEs = NULL;
2165 PRINT_ER("Connect callback function pointer is NULL\n");
2168 /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2169 * WID_DISCONNECT} */
2170 strWID.u16WIDid = (u16)WID_DISCONNECT;
2171 strWID.enuWIDtype = WID_CHAR;
2172 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
2173 strWID.s32ValueSize = sizeof(char);
2175 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2177 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
2179 PRINT_ER("Failed to send dissconect config packet\n");
2181 /* Deallocation of the Saved Connect Request in the global Handle */
2182 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2183 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
2184 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
2185 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2188 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2189 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
2190 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2193 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2194 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2195 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
2196 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2199 WILC_memset(u8ConnectedSSID, 0, ETH_ALEN);
2201 /*Freeing flushed join request params on connect timeout*/
2202 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
2203 WILC_FREE(gu8FlushedJoinReq);
2204 gu8FlushedJoinReq = NULL;
2206 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
2207 WILC_FREE(gu8FlushedInfoElemAsoc);
2208 gu8FlushedInfoElemAsoc = NULL;
2215 * @brief Handle_RcvdNtwrkInfo
2216 * @details Handling received network information
2217 * @param[in] tstrRcvdNetworkInfo* pstrRcvdNetworkInfo
2218 * @return Error code.
2223 static s32 Handle_RcvdNtwrkInfo(void *drvHandler, tstrRcvdNetworkInfo *pstrRcvdNetworkInfo)
2226 bool bNewNtwrkFound;
2230 s32 s32Error = WILC_SUCCESS;
2231 tstrNetworkInfo *pstrNetworkInfo = NULL;
2232 void *pJoinParams = NULL;
2234 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2238 bNewNtwrkFound = true;
2239 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
2241 /*if there is a an ongoing scan request*/
2242 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2243 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
2244 ParseNetworkInfo(pstrRcvdNetworkInfo->pu8Buffer, &pstrNetworkInfo);
2245 if ((pstrNetworkInfo == NULL)
2246 || (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
2247 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
2250 /* check whether this network is discovered before */
2251 for (i = 0; i < pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
2253 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
2254 (pstrNetworkInfo->au8bssid != NULL)) {
2255 if (WILC_memcmp(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
2256 pstrNetworkInfo->au8bssid, 6) == 0) {
2257 if (pstrNetworkInfo->s8rssi <= pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
2258 /*we have already found this network with better rssi, so keep the old cached one and don't
2259 * send anything to the upper layer */
2260 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
2263 /* here the same already found network is found again but with a better rssi, so just update
2264 * the rssi for this cached network and send this updated network to the upper layer but
2265 * don't add a new record for it */
2266 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
2267 bNewNtwrkFound = false;
2274 if (bNewNtwrkFound == true) {
2275 /* here it is confirmed that it is a new discovered network,
2276 * so add its record then call the User CallBack function */
2278 PRINT_D(HOSTINF_DBG, "New network found\n");
2280 if (pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
2281 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
2283 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
2284 && (pstrNetworkInfo->au8bssid != NULL)) {
2285 WILC_memcpy(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
2286 pstrNetworkInfo->au8bssid, 6);
2288 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount++;
2290 pstrNetworkInfo->bNewNetwork = true;
2291 /*Bug4218: Parsing Join Param*/
2292 /* add new BSS to JoinBssTable */
2293 #ifdef WILC_PARSE_SCAN_IN_HOST
2294 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
2295 #endif /*WILC_PARSE_SCAN_IN_HOST*/
2297 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2298 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid,
2304 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
2307 pstrNetworkInfo->bNewNetwork = false;
2308 /* just call the User CallBack function to send the same discovered network with its updated RSSI */
2309 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2310 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2315 WILC_CATCH(s32Error)
2321 /* Deallocate pstrRcvdNetworkInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2322 if (pstrRcvdNetworkInfo->pu8Buffer != NULL) {
2323 WILC_FREE(pstrRcvdNetworkInfo->pu8Buffer);
2324 pstrRcvdNetworkInfo->pu8Buffer = NULL;
2327 /*free structure allocated*/
2328 if (pstrNetworkInfo != NULL) {
2329 DeallocateNetworkInfo(pstrNetworkInfo);
2330 pstrNetworkInfo = NULL;
2337 * @brief Handle_RcvdGnrlAsyncInfo
2338 * @details Handling received asynchrous general network information
2339 * @param[in] tstrRcvdGnrlAsyncInfo* pstrRcvdGnrlAsyncInfo
2340 * @return Error code.
2345 static s32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncInfo *pstrRcvdGnrlAsyncInfo)
2347 /* TODO: mostafa: till now, this function just handles only the received mac status msg, */
2348 /* which carries only 1 WID which have WID ID = WID_STATUS */
2349 s32 s32Error = WILC_SUCCESS;
2353 u16 u16WidID = (u16)WID_NIL;
2356 u8 u8MacStatusReasonCode;
2357 u8 u8MacStatusAdditionalInfo;
2358 tstrConnectInfo strConnectInfo;
2359 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2360 s32 s32Err = WILC_SUCCESS;
2361 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
2363 if (pstrWFIDrv == NULL)
2364 PRINT_ER("Driver handler is NULL\n");
2365 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", pstrWFIDrv->enuHostIFstate,
2366 pstrRcvdGnrlAsyncInfo->pu8Buffer[7]);
2368 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
2369 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) ||
2370 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2371 if ((pstrRcvdGnrlAsyncInfo->pu8Buffer == NULL) ||
2372 (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
2373 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
2376 u8MsgType = pstrRcvdGnrlAsyncInfo->pu8Buffer[0];
2378 /* Check whether the received message type is 'I' */
2379 if ('I' != u8MsgType) {
2380 PRINT_ER("Received Message format incorrect.\n");
2381 WILC_ERRORREPORT(s32Error, WILC_FAIL);
2384 /* Extract message ID */
2385 u8MsgID = pstrRcvdGnrlAsyncInfo->pu8Buffer[1];
2387 /* Extract message Length */
2388 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[2], pstrRcvdGnrlAsyncInfo->pu8Buffer[3]);
2390 /* Extract WID ID [expected to be = WID_STATUS] */
2391 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[4], pstrRcvdGnrlAsyncInfo->pu8Buffer[5]);
2393 /* Extract WID Length [expected to be = 1] */
2394 u8WidLen = pstrRcvdGnrlAsyncInfo->pu8Buffer[6];
2396 /* get the WID value [expected to be one of two values: either MAC_CONNECTED = (1) or MAC_DISCONNECTED = (0)] */
2397 u8MacStatus = pstrRcvdGnrlAsyncInfo->pu8Buffer[7];
2398 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->pu8Buffer[8];
2399 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->pu8Buffer[9];
2400 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2401 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2402 /* our station had sent Association Request frame, so here it will get the Association Response frame then parse it */
2403 u32 u32RcvdAssocRespInfoLen;
2404 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
2406 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2408 WILC_memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
2410 if (u8MacStatus == MAC_CONNECTED) {
2411 WILC_memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
2413 host_int_get_assoc_res_info((WILC_WFIDrvHandle)pstrWFIDrv,
2415 MAX_ASSOC_RESP_FRAME_SIZE,
2416 &u32RcvdAssocRespInfoLen);
2418 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
2420 if (u32RcvdAssocRespInfoLen != 0) {
2422 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
2423 s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
2424 &pstrConnectRespInfo);
2426 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
2428 /* use the necessary parsed Info from the Received Association Response */
2429 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
2431 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
2432 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
2433 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
2434 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
2437 strConnectInfo.pu8RespIEs = (u8 *)WILC_MALLOC(pstrConnectRespInfo->u16RespIEsLen);
2438 WILC_memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
2439 pstrConnectRespInfo->u16RespIEsLen);
2443 /* deallocate the Assoc. Resp. parsed structure as it is not needed anymore */
2444 if (pstrConnectRespInfo != NULL) {
2445 DeallocateAssocRespInfo(pstrConnectRespInfo);
2446 pstrConnectRespInfo = NULL;
2452 /* The station has just received mac status and it also received assoc. response which
2453 * it was waiting for.
2454 * So check first the matching between the received mac status and the received status code in Asoc Resp */
2455 if ((u8MacStatus == MAC_CONNECTED) &&
2456 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
2457 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
2458 WILC_memset(u8ConnectedSSID, 0, ETH_ALEN);
2460 } else if (u8MacStatus == MAC_DISCONNECTED) {
2461 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
2462 WILC_memset(u8ConnectedSSID, 0, ETH_ALEN);
2465 /* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */
2466 /* through a structure of type tstrConnectRespInfo */
2467 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2468 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
2469 WILC_memcpy(strConnectInfo.au8bssid, pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
2471 if ((u8MacStatus == MAC_CONNECTED) &&
2472 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
2473 WILC_memcpy(pstrWFIDrv->au8AssociatedBSSID,
2474 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
2479 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2480 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
2481 strConnectInfo.pu8ReqIEs = (u8 *)WILC_MALLOC(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2482 WILC_memcpy(strConnectInfo.pu8ReqIEs,
2483 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2484 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2488 WILC_TimerStop(&(pstrWFIDrv->hConnectTimer), NULL);
2489 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2493 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2496 /* if received mac status is MAC_CONNECTED and
2497 * received status code in Asoc Resp is SUCCESSFUL_STATUSCODE, change state to CONNECTED
2498 * else change state to IDLE */
2499 if ((u8MacStatus == MAC_CONNECTED) &&
2500 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
2501 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2503 host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 0, 0);
2506 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
2507 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTED;
2509 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2510 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
2511 g_obtainingIP = true;
2512 WILC_TimerStart(&hDuringIpTimer, 10000, NULL, NULL);
2515 #ifdef WILC_PARSE_SCAN_IN_HOST
2516 /* open a BA session if possible */
2517 /* if(pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable) */
2521 /* host_int_addBASession(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid,0, */
2522 /* BA_SESSION_DEFAULT_BUFFER_SIZE,BA_SESSION_DEFAULT_TIMEOUT); */
2524 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
2525 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2526 gbScanWhileConnected = false;
2530 if (strConnectInfo.pu8RespIEs != NULL) {
2531 WILC_FREE(strConnectInfo.pu8RespIEs);
2532 strConnectInfo.pu8RespIEs = NULL;
2535 if (strConnectInfo.pu8ReqIEs != NULL) {
2536 WILC_FREE(strConnectInfo.pu8ReqIEs);
2537 strConnectInfo.pu8ReqIEs = NULL;
2541 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2542 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
2543 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
2544 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2547 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2548 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
2549 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2552 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2553 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2554 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
2555 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2558 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2559 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)) {
2560 /* Disassociation or Deauthentication frame has been received */
2561 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
2563 WILC_memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
2565 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2566 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
2567 WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL);
2568 Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED);
2571 strDisconnectNotifInfo.u16reason = 0;
2572 strDisconnectNotifInfo.ie = NULL;
2573 strDisconnectNotifInfo.ie_len = 0;
2575 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2576 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2578 g_obtainingIP = false;
2579 host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 0, 0);
2582 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
2585 &strDisconnectNotifInfo,
2586 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2589 PRINT_ER("Connect result callback function is NULL\n");
2592 WILC_memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
2597 /* if Information Elements were retrieved from the Received deauth/disassoc frame, then they
2598 * should be deallocated here */
2600 * if(strDisconnectNotifInfo.ie != NULL)
2602 * WILC_FREE(strDisconnectNotifInfo.ie);
2603 * strDisconnectNotifInfo.ie = NULL;
2607 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2608 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
2609 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
2610 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2613 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2614 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
2615 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2618 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2619 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2620 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
2621 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2625 /*Freeing flushed join request params on receiving*/
2626 /*MAC_DISCONNECTED while connected*/
2627 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
2628 WILC_FREE(gu8FlushedJoinReq);
2629 gu8FlushedJoinReq = NULL;
2631 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
2632 WILC_FREE(gu8FlushedInfoElemAsoc);
2633 gu8FlushedInfoElemAsoc = NULL;
2636 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2637 gbScanWhileConnected = false;
2639 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2640 (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
2641 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
2642 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
2643 /*Abort the running scan*/
2644 WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL);
2645 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult)
2646 Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED);
2652 WILC_CATCH(s32Error)
2657 /* Deallocate pstrRcvdGnrlAsyncInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2658 if (pstrRcvdGnrlAsyncInfo->pu8Buffer != NULL) {
2659 WILC_FREE(pstrRcvdGnrlAsyncInfo->pu8Buffer);
2660 pstrRcvdGnrlAsyncInfo->pu8Buffer = NULL;
2668 * @details Sending config packet to firmware to set key
2669 * @param[in] tstrHostIFkeyAttr* pstrHostIFkeyAttr
2670 * @return Error code.
2675 static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr)
2677 s32 s32Error = WILC_SUCCESS;
2679 #ifdef WILC_AP_EXTERNAL_MLME
2680 tstrWID strWIDList[5];
2686 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2689 switch (pstrHostIFkeyAttr->enuKeyType) {
2694 #ifdef WILC_AP_EXTERNAL_MLME
2695 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2697 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
2698 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
2699 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
2700 strWIDList[0].enuWIDtype = WID_CHAR;
2701 strWIDList[0].s32ValueSize = sizeof(char);
2702 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8mode));
2704 strWIDList[1].u16WIDid = WID_AUTH_TYPE;
2705 strWIDList[1].enuWIDtype = WID_CHAR;
2706 strWIDList[1].s32ValueSize = sizeof(char);
2707 strWIDList[1].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type));
2709 strWIDList[2].u16WIDid = (u16)WID_KEY_ID;
2710 strWIDList[2].enuWIDtype = WID_CHAR;
2712 strWIDList[2].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
2713 strWIDList[2].s32ValueSize = sizeof(char);
2716 pu8keybuf = (u8 *)WILC_MALLOC(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2719 if (pu8keybuf == NULL) {
2720 PRINT_ER("No buffer to send Key\n");
2724 WILC_memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
2725 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2728 WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
2730 strWIDList[3].u16WIDid = (u16)WID_WEP_KEY_VALUE;
2731 strWIDList[3].enuWIDtype = WID_STR;
2732 strWIDList[3].s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen;
2733 strWIDList[3].ps8WidVal = (s8 *)pu8keybuf;
2736 s32Error = SendConfigPkt(SET_CFG, strWIDList, 4, true, (u32)pstrWFIDrv);
2737 WILC_FREE(pu8keybuf);
2743 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2744 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
2745 pu8keybuf = (u8 *)WILC_MALLOC(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2);
2746 if (pu8keybuf == NULL) {
2747 PRINT_ER("No buffer to send Key\n");
2750 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2752 WILC_memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, 1);
2754 WILC_memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
2755 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2757 WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
2759 strWID.u16WIDid = (u16)WID_ADD_WEP_KEY;
2760 strWID.enuWIDtype = WID_STR;
2761 strWID.ps8WidVal = (s8 *)pu8keybuf;
2762 strWID.s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2;
2764 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2765 WILC_FREE(pu8keybuf);
2766 } else if (pstrHostIFkeyAttr->u8KeyAction & REMOVEKEY) {
2768 PRINT_D(HOSTINF_DBG, "Removing key\n");
2769 strWID.u16WIDid = (u16)WID_REMOVE_WEP_KEY;
2770 strWID.enuWIDtype = WID_STR;
2772 s8idxarray[0] = (s8)pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2773 strWID.ps8WidVal = s8idxarray;
2774 strWID.s32ValueSize = 1;
2776 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2778 strWID.u16WIDid = (u16)WID_KEY_ID;
2779 strWID.enuWIDtype = WID_CHAR;
2780 strWID.ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
2781 strWID.s32ValueSize = sizeof(char);
2783 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
2785 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2787 up(&(pstrWFIDrv->hSemTestKeyBlock));
2791 #ifdef WILC_AP_EXTERNAL_MLME
2792 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2793 pu8keybuf = (u8 *)WILC_MALLOC(RX_MIC_KEY_MSG_LEN);
2794 if (pu8keybuf == NULL) {
2795 PRINT_ER("No buffer to send RxGTK Key\n");
2797 goto _WPARxGtk_end_case_;
2800 WILC_memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
2803 /*|----------------------------------------------------------------------------|
2804 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2805 * |------------|---------|-------|------------|---------------|----------------|
2806 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2810 if (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq != NULL)
2811 WILC_memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
2814 WILC_memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2816 WILC_memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2818 WILC_memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2819 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2820 /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */
2821 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
2822 strWIDList[0].enuWIDtype = WID_CHAR;
2823 strWIDList[0].s32ValueSize = sizeof(char);
2824 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
2826 strWIDList[1].u16WIDid = (u16)WID_ADD_RX_GTK;
2827 strWIDList[1].enuWIDtype = WID_STR;
2828 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
2829 strWIDList[1].s32ValueSize = RX_MIC_KEY_MSG_LEN;
2831 s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, true, (u32)pstrWFIDrv);
2833 WILC_FREE(pu8keybuf);
2835 /* ////////////////////////// */
2836 up(&(pstrWFIDrv->hSemTestKeyBlock));
2837 /* ///////////////////////// */
2841 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2842 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
2844 pu8keybuf = (u8 *)WILC_MALLOC(RX_MIC_KEY_MSG_LEN);
2845 if (pu8keybuf == NULL) {
2846 PRINT_ER("No buffer to send RxGTK Key\n");
2848 goto _WPARxGtk_end_case_;
2851 WILC_memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
2854 /*|----------------------------------------------------------------------------|
2855 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2856 * |------------|---------|-------|------------|---------------|----------------|
2857 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2859 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
2860 WILC_memcpy(pu8keybuf, pstrWFIDrv->au8AssociatedBSSID, ETH_ALEN);
2862 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
2865 WILC_memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
2867 WILC_memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2869 WILC_memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2870 WILC_memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2871 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2873 strWID.u16WIDid = (u16)WID_ADD_RX_GTK;
2874 strWID.enuWIDtype = WID_STR;
2875 strWID.ps8WidVal = (s8 *)pu8keybuf;
2876 strWID.s32ValueSize = RX_MIC_KEY_MSG_LEN;
2878 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2880 WILC_FREE(pu8keybuf);
2882 /* ////////////////////////// */
2883 up(&(pstrWFIDrv->hSemTestKeyBlock));
2884 /* ///////////////////////// */
2886 _WPARxGtk_end_case_:
2887 WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
2888 WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq);
2895 #ifdef WILC_AP_EXTERNAL_MLME
2896 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2899 pu8keybuf = (u8 *)WILC_MALLOC(PTK_KEY_MSG_LEN + 1);
2903 if (pu8keybuf == NULL) {
2904 PRINT_ER("No buffer to send PTK Key\n");
2906 goto _WPAPtk_end_case_;
2910 /*|-----------------------------------------------------------------------------|
2911 * |Station address | keyidx |Key Length |Temporal Key | Rx Michael Key |Tx Michael Key |
2912 * |----------------|------------ |--------------|----------------|---------------|
2913 | 6 bytes | 1 byte | 1byte | 16 bytes | 8 bytes | 8 bytes |
2914 |-----------------------------------------------------------------------------|*/
2916 WILC_memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
2918 WILC_memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2919 WILC_memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2921 WILC_memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2922 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2925 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
2926 strWIDList[0].enuWIDtype = WID_CHAR;
2927 strWIDList[0].s32ValueSize = sizeof(char);
2928 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
2930 strWIDList[1].u16WIDid = (u16)WID_ADD_PTK;
2931 strWIDList[1].enuWIDtype = WID_STR;
2932 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
2933 strWIDList[1].s32ValueSize = PTK_KEY_MSG_LEN + 1;
2935 s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, true, (u32)pstrWFIDrv);
2936 WILC_FREE(pu8keybuf);
2938 /* ////////////////////////// */
2939 up(&(pstrWFIDrv->hSemTestKeyBlock));
2940 /* ///////////////////////// */
2943 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2946 pu8keybuf = (u8 *)WILC_MALLOC(PTK_KEY_MSG_LEN);
2950 if (pu8keybuf == NULL) {
2951 PRINT_ER("No buffer to send PTK Key\n");
2953 goto _WPAPtk_end_case_;
2957 /*|-----------------------------------------------------------------------------|
2958 * |Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
2959 * |----------------|------------|--------------|----------------|---------------|
2960 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
2961 |-----------------------------------------------------------------------------|*/
2963 WILC_memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
2965 WILC_memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2967 WILC_memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2968 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2971 strWID.u16WIDid = (u16)WID_ADD_PTK;
2972 strWID.enuWIDtype = WID_STR;
2973 strWID.ps8WidVal = (s8 *)pu8keybuf;
2974 strWID.s32ValueSize = PTK_KEY_MSG_LEN;
2976 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2977 WILC_FREE(pu8keybuf);
2979 /* ////////////////////////// */
2980 up(&(pstrWFIDrv->hSemTestKeyBlock));
2981 /* ///////////////////////// */
2985 WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
2994 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
2996 pu8keybuf = (u8 *)WILC_MALLOC((pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1);
2997 if (pu8keybuf == NULL) {
2998 PRINT_ER("No buffer to send PMKSA Key\n");
3002 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid;
3004 for (i = 0; i < pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid; i++) {
3006 WILC_memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, ETH_ALEN);
3007 WILC_memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, PMKID_LEN);
3010 strWID.u16WIDid = (u16)WID_PMKID_INFO;
3011 strWID.enuWIDtype = WID_STR;
3012 strWID.ps8WidVal = (s8 *)pu8keybuf;
3013 strWID.s32ValueSize = (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1;
3015 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3017 WILC_FREE(pu8keybuf);
3022 PRINT_ER("Failed to send key config packet\n");
3030 * @brief Handle_Disconnect
3031 * @details Sending config packet to firmware to disconnect
3038 static void Handle_Disconnect(void *drvHandler)
3042 s32 s32Error = WILC_SUCCESS;
3043 u16 u16DummyReasonCode = 0;
3044 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3047 strWID.u16WIDid = (u16)WID_DISCONNECT;
3048 strWID.enuWIDtype = WID_CHAR;
3049 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
3050 strWID.s32ValueSize = sizeof(char);
3054 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
3056 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3058 g_obtainingIP = false;
3059 host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 0, 0);
3062 WILC_memset(u8ConnectedSSID, 0, ETH_ALEN);
3064 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3067 PRINT_ER("Failed to send dissconect config packet\n");
3068 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3070 tstrDisconnectNotifInfo strDisconnectNotifInfo;
3072 WILC_memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
3074 strDisconnectNotifInfo.u16reason = 0;
3075 strDisconnectNotifInfo.ie = NULL;
3076 strDisconnectNotifInfo.ie_len = 0;
3078 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
3079 WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL);
3080 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
3081 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
3083 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
3086 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
3089 /*Stop connect timer, if connection in progress*/
3090 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3091 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
3092 WILC_TimerStop(&(pstrWFIDrv->hConnectTimer), NULL);
3095 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
3096 0, &strDisconnectNotifInfo, pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
3098 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
3101 gbScanWhileConnected = false;
3103 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
3105 WILC_memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
3109 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
3110 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
3111 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
3112 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
3115 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
3116 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
3117 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
3120 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
3121 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
3122 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
3123 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
3128 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
3129 WILC_FREE(gu8FlushedJoinReq);
3130 gu8FlushedJoinReq = NULL;
3132 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
3133 WILC_FREE(gu8FlushedInfoElemAsoc);
3134 gu8FlushedInfoElemAsoc = NULL;
3139 WILC_CATCH(s32Error)
3144 /* ////////////////////////// */
3145 up(&(pstrWFIDrv->hSemTestDisconnectBlock));
3146 /* ///////////////////////// */
3151 void resolve_disconnect_aberration(void *drvHandler)
3153 tstrWILC_WFIDrv *pstrWFIDrv;
3155 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3156 if (pstrWFIDrv == NULL)
3158 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTING)) {
3159 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
3160 host_int_disconnect((WILC_WFIDrvHandle)pstrWFIDrv, 1);
3163 static s32 Switch_Log_Terminal(void *drvHandler)
3167 s32 s32Error = WILC_SUCCESS;
3169 static char dummy = 9;
3170 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3172 strWID.u16WIDid = (u16)WID_LOGTerminal_Switch;
3173 strWID.enuWIDtype = WID_CHAR;
3174 strWID.ps8WidVal = &dummy;
3175 strWID.s32ValueSize = sizeof(char);
3177 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3181 PRINT_D(HOSTINF_DBG, "Failed to switch log terminal\n");
3182 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
3184 PRINT_INFO(HOSTINF_DBG, "MAC address set ::\n");
3189 WILC_CATCH(s32Error)
3198 * @brief Handle_GetChnl
3199 * @details Sending config packet to get channel
3207 static s32 Handle_GetChnl(void *drvHandler)
3210 s32 s32Error = WILC_SUCCESS;
3212 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
3213 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3215 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
3216 strWID.enuWIDtype = WID_CHAR;
3217 strWID.ps8WidVal = (s8 *)&gu8Chnl;
3218 strWID.s32ValueSize = sizeof(char);
3220 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
3222 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3223 /*get the value by searching the local copy*/
3225 PRINT_ER("Failed to get channel number\n");
3226 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3230 WILC_CATCH(s32Error)
3234 up(&(pstrWFIDrv->hSemGetCHNL));
3244 * @brief Handle_GetRssi
3245 * @details Sending config packet to get RSSI
3252 static void Handle_GetRssi(void *drvHandler)
3254 s32 s32Error = WILC_SUCCESS;
3256 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3258 strWID.u16WIDid = (u16)WID_RSSI;
3259 strWID.enuWIDtype = WID_CHAR;
3260 strWID.ps8WidVal = &gs8Rssi;
3261 strWID.s32ValueSize = sizeof(char);
3264 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
3266 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3268 PRINT_ER("Failed to get RSSI value\n");
3269 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3272 WILC_CATCH(s32Error)
3276 up(&(pstrWFIDrv->hSemGetRSSI));
3282 static void Handle_GetLinkspeed(void *drvHandler)
3284 s32 s32Error = WILC_SUCCESS;
3286 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3290 strWID.u16WIDid = (u16)WID_LINKSPEED;
3291 strWID.enuWIDtype = WID_CHAR;
3292 strWID.ps8WidVal = &gs8lnkspd;
3293 strWID.s32ValueSize = sizeof(char);
3295 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
3297 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3299 PRINT_ER("Failed to get LINKSPEED value\n");
3300 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3303 WILC_CATCH(s32Error)
3307 up(&(pstrWFIDrv->hSemGetLINKSPEED));
3312 s32 Handle_GetStatistics(void *drvHandler, tstrStatistics *pstrStatistics)
3314 tstrWID strWIDList[5];
3315 uint32_t u32WidsCount = 0, s32Error = 0;
3317 strWIDList[u32WidsCount].u16WIDid = WID_LINKSPEED;
3318 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
3319 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
3320 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u8LinkSpeed));
3323 strWIDList[u32WidsCount].u16WIDid = WID_RSSI;
3324 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
3325 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
3326 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->s8RSSI));
3329 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
3330 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
3331 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
3332 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxCount));
3335 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
3336 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
3337 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
3338 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32RxCount));
3341 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
3342 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
3343 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
3344 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxFailureCount));
3347 s32Error = SendConfigPkt(GET_CFG, strWIDList, u32WidsCount, false, (u32)drvHandler);
3350 PRINT_ER("Failed to send scan paramters config packet\n");
3351 /* WILC_ERRORREPORT(s32Error, s32Error); */
3359 #ifdef WILC_AP_EXTERNAL_MLME
3363 * @brief Handle_Get_InActiveTime
3364 * @details Sending config packet to set mac adddress for station and
3373 static s32 Handle_Get_InActiveTime(void *drvHandler, tstrHostIfStaInactiveT *strHostIfStaInactiveT)
3376 s32 s32Error = WILC_SUCCESS;
3379 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3382 strWID.u16WIDid = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
3383 strWID.enuWIDtype = WID_STR;
3384 strWID.s32ValueSize = ETH_ALEN;
3385 strWID.ps8WidVal = (u8 *)WILC_MALLOC(strWID.s32ValueSize);
3388 stamac = strWID.ps8WidVal;
3389 WILC_memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
3392 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
3395 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3396 /*get the value by searching the local copy*/
3398 PRINT_ER("Failed to SET incative time\n");
3399 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3403 strWID.u16WIDid = (u16)WID_GET_INACTIVE_TIME;
3404 strWID.enuWIDtype = WID_INT;
3405 strWID.ps8WidVal = (s8 *)&gu32InactiveTime;
3406 strWID.s32ValueSize = sizeof(u32);
3409 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3410 /*get the value by searching the local copy*/
3412 PRINT_ER("Failed to get incative time\n");
3413 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3417 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
3419 up(&(pstrWFIDrv->hSemInactiveTime));
3420 WILC_CATCH(s32Error)
3434 * @brief Handle_AddBeacon
3435 * @details Sending config packet to add beacon
3436 * @param[in] tstrHostIFSetBeacon* pstrSetBeaconParam
3442 static void Handle_AddBeacon(void *drvHandler, tstrHostIFSetBeacon *pstrSetBeaconParam)
3444 s32 s32Error = WILC_SUCCESS;
3447 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3449 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
3451 strWID.u16WIDid = (u16)WID_ADD_BEACON;
3452 strWID.enuWIDtype = WID_BIN;
3453 strWID.s32ValueSize = pstrSetBeaconParam->u32HeadLen + pstrSetBeaconParam->u32TailLen + 16;
3454 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3455 if (strWID.ps8WidVal == NULL)
3456 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3458 pu8CurrByte = strWID.ps8WidVal;
3459 *pu8CurrByte++ = (pstrSetBeaconParam->u32Interval & 0xFF);
3460 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 8) & 0xFF);
3461 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 16) & 0xFF);
3462 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 24) & 0xFF);
3464 *pu8CurrByte++ = (pstrSetBeaconParam->u32DTIMPeriod & 0xFF);
3465 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 8) & 0xFF);
3466 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 16) & 0xFF);
3467 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 24) & 0xFF);
3469 *pu8CurrByte++ = (pstrSetBeaconParam->u32HeadLen & 0xFF);
3470 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 8) & 0xFF);
3471 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 16) & 0xFF);
3472 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 24) & 0xFF);
3474 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Head, pstrSetBeaconParam->u32HeadLen);
3475 pu8CurrByte += pstrSetBeaconParam->u32HeadLen;
3477 *pu8CurrByte++ = (pstrSetBeaconParam->u32TailLen & 0xFF);
3478 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 8) & 0xFF);
3479 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 16) & 0xFF);
3480 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 24) & 0xFF);
3482 /* Bug 4599 : if tail length = 0 skip copying */
3483 if (pstrSetBeaconParam->pu8Tail > 0)
3484 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Tail, pstrSetBeaconParam->u32TailLen);
3485 pu8CurrByte += pstrSetBeaconParam->u32TailLen;
3490 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3492 PRINT_ER("Failed to send add beacon config packet\n");
3493 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3496 WILC_CATCH(s32Error)
3499 WILC_FREE_IF_TRUE(strWID.ps8WidVal);
3500 WILC_FREE_IF_TRUE(pstrSetBeaconParam->pu8Head);
3501 WILC_FREE_IF_TRUE(pstrSetBeaconParam->pu8Tail);
3506 * @brief Handle_AddBeacon
3507 * @details Sending config packet to delete beacon
3508 * @param[in] tstrHostIFDelBeacon* pstrDelBeacon
3514 static void Handle_DelBeacon(void *drvHandler, tstrHostIFDelBeacon *pstrDelBeacon)
3516 s32 s32Error = WILC_SUCCESS;
3519 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3521 strWID.u16WIDid = (u16)WID_DEL_BEACON;
3522 strWID.enuWIDtype = WID_CHAR;
3523 strWID.s32ValueSize = sizeof(char);
3524 strWID.ps8WidVal = &gu8DelBcn;
3526 if (strWID.ps8WidVal == NULL)
3527 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3529 pu8CurrByte = strWID.ps8WidVal;
3531 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
3532 /* TODO: build del beacon message*/
3535 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3538 PRINT_ER("Failed to send delete beacon config packet\n");
3539 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3542 WILC_CATCH(s32Error)
3549 * @brief WILC_HostIf_PackStaParam
3550 * @details Handling packing of the station params in a buffer
3551 * @param[in] u8* pu8Buffer, tstrWILC_AddStaParam* pstrStationParam
3557 static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer, tstrWILC_AddStaParam *pstrStationParam)
3561 pu8CurrByte = pu8Buffer;
3563 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
3564 WILC_memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
3565 pu8CurrByte += ETH_ALEN;
3567 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
3568 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
3570 *pu8CurrByte++ = pstrStationParam->u8NumRates;
3571 if (pstrStationParam->u8NumRates > 0)
3572 WILC_memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
3573 pu8CurrByte += pstrStationParam->u8NumRates;
3575 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
3576 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
3577 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
3579 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
3580 WILC_memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
3581 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
3583 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
3584 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
3586 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
3587 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
3588 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
3589 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
3591 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
3593 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
3594 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
3596 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
3597 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
3599 return pu8CurrByte - pu8Buffer;
3603 * @brief Handle_AddStation
3604 * @details Sending config packet to add station
3605 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3611 static void Handle_AddStation(void *drvHandler, tstrWILC_AddStaParam *pstrStationParam)
3613 s32 s32Error = WILC_SUCCESS;
3616 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3618 PRINT_D(HOSTINF_DBG, "Handling add station\n");
3619 strWID.u16WIDid = (u16)WID_ADD_STA;
3620 strWID.enuWIDtype = WID_BIN;
3621 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3623 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3624 if (strWID.ps8WidVal == NULL)
3625 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3627 pu8CurrByte = strWID.ps8WidVal;
3628 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3631 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3632 if (s32Error != WILC_SUCCESS) {
3634 PRINT_ER("Failed to send add station config packet\n");
3635 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3638 WILC_CATCH(s32Error)
3641 WILC_FREE_IF_TRUE(pstrStationParam->pu8Rates);
3642 WILC_FREE_IF_TRUE(strWID.ps8WidVal);
3646 * @brief Handle_DelAllSta
3647 * @details Sending config packet to delete station
3648 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3654 static void Handle_DelAllSta(void *drvHandler, tstrHostIFDelAllSta *pstrDelAllStaParam)
3656 s32 s32Error = WILC_SUCCESS;
3660 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3662 u8 au8Zero_Buff[6] = {0};
3664 strWID.u16WIDid = (u16)WID_DEL_ALL_STA;
3665 strWID.enuWIDtype = WID_STR;
3666 strWID.s32ValueSize = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1;
3668 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
3670 strWID.ps8WidVal = WILC_MALLOC((pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1);
3671 if (strWID.ps8WidVal == NULL)
3672 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3674 pu8CurrByte = strWID.ps8WidVal;
3676 *(pu8CurrByte++) = pstrDelAllStaParam->u8Num_AssocSta;
3678 for (i = 0; i < MAX_NUM_STA; i++) {
3679 if (memcmp(pstrDelAllStaParam->au8Sta_DelAllSta[i], au8Zero_Buff, ETH_ALEN))
3680 WILC_memcpy(pu8CurrByte, pstrDelAllStaParam->au8Sta_DelAllSta[i], ETH_ALEN);
3684 pu8CurrByte += ETH_ALEN;
3688 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3691 PRINT_ER("Failed to send add station config packet\n");
3692 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3695 WILC_CATCH(s32Error)
3698 WILC_FREE_IF_TRUE(strWID.ps8WidVal);
3705 * @brief Handle_DelStation
3706 * @details Sending config packet to delete station
3707 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3713 static void Handle_DelStation(void *drvHandler, tstrHostIFDelSta *pstrDelStaParam)
3715 s32 s32Error = WILC_SUCCESS;
3718 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3720 strWID.u16WIDid = (u16)WID_REMOVE_STA;
3721 strWID.enuWIDtype = WID_BIN;
3722 strWID.s32ValueSize = ETH_ALEN;
3724 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
3726 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3727 if (strWID.ps8WidVal == NULL)
3728 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3730 pu8CurrByte = strWID.ps8WidVal;
3732 WILC_memcpy(pu8CurrByte, pstrDelStaParam->au8MacAddr, ETH_ALEN);
3735 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3738 PRINT_ER("Failed to send add station config packet\n");
3739 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3742 WILC_CATCH(s32Error)
3745 WILC_FREE_IF_TRUE(strWID.ps8WidVal);
3750 * @brief Handle_EditStation
3751 * @details Sending config packet to edit station
3752 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3758 static void Handle_EditStation(void *drvHandler, tstrWILC_AddStaParam *pstrStationParam)
3760 s32 s32Error = WILC_SUCCESS;
3763 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3765 strWID.u16WIDid = (u16)WID_EDIT_STA;
3766 strWID.enuWIDtype = WID_BIN;
3767 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3769 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
3770 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3771 if (strWID.ps8WidVal == NULL)
3772 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3774 pu8CurrByte = strWID.ps8WidVal;
3775 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3778 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3781 PRINT_ER("Failed to send edit station config packet\n");
3782 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3785 WILC_CATCH(s32Error)
3788 WILC_FREE_IF_TRUE(pstrStationParam->pu8Rates);
3789 WILC_FREE_IF_TRUE(strWID.ps8WidVal);
3791 #endif /*WILC_AP_EXTERNAL_MLME*/
3795 * @brief Handle_RemainOnChan
3796 * @details Sending config packet to edit station
3797 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3803 static int Handle_RemainOnChan(void *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan)
3805 s32 s32Error = WILC_SUCCESS;
3806 u8 u8remain_on_chan_flag;
3808 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3810 /*If it's a pendig remain-on-channel, don't overwrite gWFiDrvHandle values (since incoming msg is garbbage)*/
3811 if (!pstrWFIDrv->u8RemainOnChan_pendingreq) {
3812 pstrWFIDrv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
3813 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
3814 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
3815 pstrWFIDrv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
3816 pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
3818 /*Set the channel to use it as a wid val*/
3819 pstrHostIfRemainOnChan->u16Channel = pstrWFIDrv->strHostIfRemainOnChan.u16Channel;
3822 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
3823 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
3824 pstrWFIDrv->u8RemainOnChan_pendingreq = 1;
3825 WILC_ERRORREPORT(s32Error, WILC_BUSY);
3827 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3828 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
3829 WILC_ERRORREPORT(s32Error, WILC_BUSY);
3832 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3833 if (g_obtainingIP || connecting) {
3834 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
3835 WILC_ERRORREPORT(s32Error, WILC_BUSY);
3839 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
3841 u8remain_on_chan_flag = true;
3842 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
3843 strWID.enuWIDtype = WID_STR;
3844 strWID.s32ValueSize = 2;
3845 strWID.ps8WidVal = (s8 *)WILC_MALLOC(strWID.s32ValueSize);
3847 if (strWID.ps8WidVal == NULL)
3848 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3850 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
3851 strWID.ps8WidVal[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
3854 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3855 if (s32Error != WILC_SUCCESS)
3856 PRINT_ER("Failed to set remain on channel\n");
3860 P2P_LISTEN_STATE = 1;
3861 WILC_TimerStart(&(pstrWFIDrv->hRemainOnChannel), pstrHostIfRemainOnChan->u32duration, (void *)pstrWFIDrv, NULL);
3863 /*Calling CFG ready_on_channel*/
3864 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady)
3865 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady(pstrWFIDrv->strHostIfRemainOnChan.pVoid);
3867 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
3868 pstrWFIDrv->u8RemainOnChan_pendingreq = 0;
3874 * @brief Handle_RegisterFrame
3882 static int Handle_RegisterFrame(void *drvHandler, tstrHostIfRegisterFrame *pstrHostIfRegisterFrame)
3884 s32 s32Error = WILC_SUCCESS;
3887 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3889 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
3891 /*prepare configuration packet*/
3892 strWID.u16WIDid = (u16)WID_REGISTER_FRAME;
3893 strWID.enuWIDtype = WID_STR;
3894 strWID.ps8WidVal = WILC_MALLOC(sizeof(u16) + 2);
3895 if (strWID.ps8WidVal == NULL)
3896 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3898 pu8CurrByte = strWID.ps8WidVal;
3900 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
3901 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
3902 WILC_memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
3905 strWID.s32ValueSize = sizeof(u16) + 2;
3909 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3911 PRINT_ER("Failed to frame register config packet\n");
3912 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
3916 WILC_CATCH(s32Error)
3925 * @brief Handle_ListenStateExpired
3926 * @details Handle of listen state expiration
3928 * @return Error code.
3933 #define FALSE_FRMWR_CHANNEL 100
3934 static u32 Handle_ListenStateExpired(void *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan)
3936 u8 u8remain_on_chan_flag;
3938 s32 s32Error = WILC_SUCCESS;
3939 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3941 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
3944 /*Make sure we are already in listen state*/
3945 /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/
3946 if (P2P_LISTEN_STATE) {
3947 u8remain_on_chan_flag = false;
3948 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
3949 strWID.enuWIDtype = WID_STR;
3950 strWID.s32ValueSize = 2;
3951 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3953 if (strWID.ps8WidVal == NULL)
3954 PRINT_ER("Failed to allocate memory\n");
3956 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
3957 strWID.ps8WidVal[1] = FALSE_FRMWR_CHANNEL;
3960 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3961 if (s32Error != WILC_SUCCESS) {
3962 PRINT_ER("Failed to set remain on channel\n");
3966 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired) {
3967 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired(pstrWFIDrv->strHostIfRemainOnChan.pVoid
3968 , pstrHostIfRemainOnChan->u32ListenSessionID);
3970 P2P_LISTEN_STATE = 0;
3972 PRINT_D(GENERIC_DBG, "Not in listen state\n");
3973 s32Error = WILC_FAIL;
3982 * @brief ListenTimerCB
3983 * @details Callback function of remain-on-channel timer
3985 * @return Error code.
3990 static void ListenTimerCB(void *pvArg)
3992 s32 s32Error = WILC_SUCCESS;
3993 tstrHostIFmsg strHostIFmsg;
3994 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)pvArg;
3995 /*Stopping remain-on-channel timer*/
3996 WILC_TimerStop(&(pstrWFIDrv->hRemainOnChannel), NULL);
3998 /* prepare the Timer Callback message */
3999 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4000 strHostIFmsg.u16MsgId = HOST_IF_MSG_LISTEN_TIMER_FIRED;
4001 strHostIFmsg.drvHandler = pstrWFIDrv;
4002 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID;
4004 /* send the message */
4005 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4007 WILC_ERRORREPORT(s32Error, s32Error);
4008 WILC_CATCH(s32Error)
4017 * @brief Handle_EditStation
4018 * @details Sending config packet to edit station
4019 * @param[in] tstrWILC_AddStaParam* pstrStationParam
4025 static void Handle_PowerManagement(void *drvHandler, tstrHostIfPowerMgmtParam *strPowerMgmtParam)
4027 s32 s32Error = WILC_SUCCESS;
4030 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4032 strWID.u16WIDid = (u16)WID_POWER_MANAGEMENT;
4034 if (strPowerMgmtParam->bIsEnabled == true) {
4035 s8PowerMode = MIN_FAST_PS;
4037 s8PowerMode = NO_POWERSAVE;
4039 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
4040 strWID.ps8WidVal = &s8PowerMode;
4041 strWID.s32ValueSize = sizeof(char);
4043 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
4046 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4048 PRINT_ER("Failed to send power management config packet\n");
4049 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
4052 WILC_CATCH(s32Error)
4059 * @brief Handle_SetMulticastFilter
4060 * @details Set Multicast filter in firmware
4061 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4067 static void Handle_SetMulticastFilter(void *drvHandler, tstrHostIFSetMulti *strHostIfSetMulti)
4069 s32 s32Error = WILC_SUCCESS;
4073 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
4075 strWID.u16WIDid = (u16)WID_SETUP_MULTICAST_FILTER;
4076 strWID.enuWIDtype = WID_BIN;
4077 strWID.s32ValueSize = sizeof(tstrHostIFSetMulti) + ((strHostIfSetMulti->u32count) * ETH_ALEN);
4078 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
4079 if (strWID.ps8WidVal == NULL)
4080 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
4082 pu8CurrByte = strWID.ps8WidVal;
4083 *pu8CurrByte++ = (strHostIfSetMulti->bIsEnabled & 0xFF);
4084 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 8) & 0xFF);
4085 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 16) & 0xFF);
4086 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 24) & 0xFF);
4088 *pu8CurrByte++ = (strHostIfSetMulti->u32count & 0xFF);
4089 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 8) & 0xFF);
4090 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 16) & 0xFF);
4091 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 24) & 0xFF);
4093 if ((strHostIfSetMulti->u32count) > 0)
4094 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->u32count) * ETH_ALEN));
4097 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)drvHandler);
4099 PRINT_ER("Failed to send setup multicast config packet\n");
4100 WILC_ERRORREPORT(s32Error, WILC_FAIL);
4103 WILC_CATCH(s32Error)
4106 WILC_FREE_IF_TRUE(strWID.ps8WidVal);
4113 * @brief Handle_AddBASession
4114 * @details Add block ack session
4115 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4117 * @author Amr Abdel-Moghny
4121 static s32 Handle_AddBASession(void *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
4123 s32 s32Error = WILC_SUCCESS;
4125 int AddbaTimeout = 100;
4127 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4129 PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\nBufferSize == %d\nSessionTimeOut = %d\n",
4130 strHostIfBASessionInfo->au8Bssid[0],
4131 strHostIfBASessionInfo->au8Bssid[1],
4132 strHostIfBASessionInfo->au8Bssid[2],
4133 strHostIfBASessionInfo->u16BufferSize,
4134 strHostIfBASessionInfo->u16SessionTimeout,
4135 strHostIfBASessionInfo->u8Ted);
4137 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
4138 strWID.enuWIDtype = WID_STR;
4139 strWID.ps8WidVal = (u8 *)WILC_MALLOC(BLOCK_ACK_REQ_SIZE);
4140 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4141 ptr = strWID.ps8WidVal;
4142 /* *ptr++ = 0x14; */
4146 WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4148 *ptr++ = strHostIfBASessionInfo->u8Ted;
4152 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
4153 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
4155 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
4156 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
4158 *ptr++ = (AddbaTimeout & 0xFF);
4159 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
4160 /* Group Buffer Max Frames*/
4162 /* Group Buffer Timeout */
4165 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4167 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
4170 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
4171 strWID.enuWIDtype = WID_STR;
4172 strWID.s32ValueSize = 15;
4173 ptr = strWID.ps8WidVal;
4174 /* *ptr++ = 0x14; */
4178 WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4181 *ptr++ = strHostIfBASessionInfo->u8Ted;
4185 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
4186 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
4189 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4191 if (strWID.ps8WidVal != NULL)
4192 WILC_FREE(strWID.ps8WidVal);
4201 * @brief Handle_DelBASession
4202 * @details Delete block ack session
4203 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4205 * @author Amr Abdel-Moghny
4209 static s32 Handle_DelBASession(void *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
4211 s32 s32Error = WILC_SUCCESS;
4214 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4216 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
4217 strHostIfBASessionInfo->au8Bssid[0],
4218 strHostIfBASessionInfo->au8Bssid[1],
4219 strHostIfBASessionInfo->au8Bssid[2],
4220 strHostIfBASessionInfo->u8Ted);
4222 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
4223 strWID.enuWIDtype = WID_STR;
4224 strWID.ps8WidVal = (u8 *)WILC_MALLOC(BLOCK_ACK_REQ_SIZE);
4225 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4226 ptr = strWID.ps8WidVal;
4227 /* *ptr++ = 0x14; */
4231 WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4233 *ptr++ = strHostIfBASessionInfo->u8Ted;
4234 /* BA direction = recipent*/
4237 *ptr++ = 32; /* Unspecific QOS reason */
4239 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4241 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
4244 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
4245 strWID.enuWIDtype = WID_STR;
4246 strWID.s32ValueSize = 15;
4247 ptr = strWID.ps8WidVal;
4248 /* *ptr++ = 0x14; */
4252 WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4255 *ptr++ = strHostIfBASessionInfo->u8Ted;
4257 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4259 if (strWID.ps8WidVal != NULL)
4260 WILC_FREE(strWID.ps8WidVal);
4271 * @brief Handle_DelAllRxBASessions
4272 * @details Delete all Rx BA sessions
4273 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4275 * @author Abdelrahman Sobhy
4279 static s32 Handle_DelAllRxBASessions(void *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
4281 s32 s32Error = WILC_SUCCESS;
4284 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4286 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
4287 strHostIfBASessionInfo->au8Bssid[0],
4288 strHostIfBASessionInfo->au8Bssid[1],
4289 strHostIfBASessionInfo->au8Bssid[2],
4290 strHostIfBASessionInfo->u8Ted);
4292 strWID.u16WIDid = (u16)WID_DEL_ALL_RX_BA;
4293 strWID.enuWIDtype = WID_STR;
4294 strWID.ps8WidVal = (u8 *)WILC_MALLOC(BLOCK_ACK_REQ_SIZE);
4295 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4296 ptr = strWID.ps8WidVal;
4300 WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4302 *ptr++ = strHostIfBASessionInfo->u8Ted;
4303 /* BA direction = recipent*/
4306 *ptr++ = 32; /* Unspecific QOS reason */
4308 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4310 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
4313 if (strWID.ps8WidVal != NULL)
4314 WILC_FREE(strWID.ps8WidVal);
4324 * @brief hostIFthread
4325 * @details Main thread to handle message queue requests
4326 * @param[in] void* pvArg
4332 static int hostIFthread(void *pvArg)
4335 tstrHostIFmsg strHostIFmsg;
4336 tstrWILC_WFIDrv *pstrWFIDrv;
4338 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4341 WILC_MsgQueueRecv(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), &u32Ret, NULL);
4342 pstrWFIDrv = (tstrWILC_WFIDrv *)strHostIFmsg.drvHandler;
4343 if (strHostIFmsg.u16MsgId == HOST_IF_MSG_EXIT) {
4344 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
4349 /*Re-Queue HIF message*/
4350 if ((!g_wilc_initialized)) {
4351 PRINT_D(GENERIC_DBG, "--WAIT--");
4353 WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4357 if (strHostIFmsg.u16MsgId == HOST_IF_MSG_CONNECT && pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
4358 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
4359 WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4364 switch (strHostIFmsg.u16MsgId) {
4365 case HOST_IF_MSG_Q_IDLE:
4366 Handle_wait_msg_q_empty();
4369 case HOST_IF_MSG_SCAN:
4370 Handle_Scan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr);
4373 case HOST_IF_MSG_CONNECT:
4374 Handle_Connect(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr);
4378 case HOST_IF_MSG_FLUSH_CONNECT:
4379 Handle_FlushConnect(strHostIFmsg.drvHandler);
4382 case HOST_IF_MSG_RCVD_NTWRK_INFO:
4383 Handle_RcvdNtwrkInfo(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo);
4386 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
4387 Handle_RcvdGnrlAsyncInfo(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo);
4390 case HOST_IF_MSG_KEY:
4391 Handle_Key(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr);
4394 case HOST_IF_MSG_CFG_PARAMS:
4396 Handle_CfgParam(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFCfgParamAttr);
4399 case HOST_IF_MSG_SET_CHANNEL:
4400 Handle_SetChannel(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFSetChan);
4403 case HOST_IF_MSG_DISCONNECT:
4404 Handle_Disconnect(strHostIFmsg.drvHandler);
4407 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
4408 WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL);
4409 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
4412 /*Allow chip sleep, only if both interfaces are not connected*/
4413 if (!linux_wlan_get_num_conn_ifcs())
4414 chip_sleep_manually(INFINITE_SLEEP_TIME);
4416 Handle_ScanDone(strHostIFmsg.drvHandler, SCAN_EVENT_DONE);
4419 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
4420 Handle_RemainOnChan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
4425 case HOST_IF_MSG_GET_RSSI:
4426 Handle_GetRssi(strHostIFmsg.drvHandler);
4429 case HOST_IF_MSG_GET_LINKSPEED:
4430 Handle_GetLinkspeed(strHostIFmsg.drvHandler);
4433 case HOST_IF_MSG_GET_STATISTICS:
4434 Handle_GetStatistics(strHostIFmsg.drvHandler, (tstrStatistics *)strHostIFmsg.uniHostIFmsgBody.pUserData);
4437 case HOST_IF_MSG_GET_CHNL:
4438 Handle_GetChnl(strHostIFmsg.drvHandler);
4441 #ifdef WILC_AP_EXTERNAL_MLME
4442 case HOST_IF_MSG_ADD_BEACON:
4443 Handle_AddBeacon(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFSetBeacon);
4446 case HOST_IF_MSG_DEL_BEACON:
4447 Handle_DelBeacon(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFDelBeacon);
4450 case HOST_IF_MSG_ADD_STATION:
4451 Handle_AddStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strAddStaParam);
4454 case HOST_IF_MSG_DEL_STATION:
4455 Handle_DelStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strDelStaParam);
4458 case HOST_IF_MSG_EDIT_STATION:
4459 Handle_EditStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strEditStaParam);
4462 case HOST_IF_MSG_GET_INACTIVETIME:
4463 Handle_Get_InActiveTime(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfStaInactiveT);
4466 #endif /*WILC_AP_EXTERNAL_MLME*/
4467 case HOST_IF_MSG_SCAN_TIMER_FIRED:
4468 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
4470 Handle_ScanDone(strHostIFmsg.drvHandler, SCAN_EVENT_ABORTED);
4473 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
4474 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
4475 Handle_ConnectTimeout(strHostIFmsg.drvHandler);
4478 case HOST_IF_MSG_POWER_MGMT:
4479 Handle_PowerManagement(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strPowerMgmtparam);
4482 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
4483 Handle_SetWfiDrvHandler(&strHostIFmsg.uniHostIFmsgBody.strHostIfSetDrvHandler);
4486 case HOST_IF_MSG_SET_OPERATION_MODE:
4487 Handle_SetOperationMode(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetOperationMode);
4490 case HOST_IF_MSG_SET_IPADDRESS:
4491 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
4492 Handle_set_IPAddress(strHostIFmsg.drvHandler, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx);
4495 case HOST_IF_MSG_GET_IPADDRESS:
4496 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
4497 Handle_get_IPAddress(strHostIFmsg.drvHandler, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx);
4501 case HOST_IF_MSG_SET_MAC_ADDRESS:
4502 Handle_SetMacAddress(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMacAddress);
4506 case HOST_IF_MSG_GET_MAC_ADDRESS:
4507 Handle_GetMacAddress(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfGetMacAddress);
4511 case HOST_IF_MSG_REMAIN_ON_CHAN:
4512 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
4513 Handle_RemainOnChan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
4516 case HOST_IF_MSG_REGISTER_FRAME:
4517 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
4518 Handle_RegisterFrame(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame);
4521 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
4522 Handle_ListenStateExpired(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
4526 case HOST_IF_MSG_SET_MULTICAST_FILTER:
4527 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
4528 Handle_SetMulticastFilter(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMulti);
4532 case HOST_IF_MSG_ADD_BA_SESSION:
4533 Handle_AddBASession(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo);
4536 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
4537 Handle_DelAllRxBASessions(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo);
4540 case HOST_IF_MSG_DEL_ALL_STA:
4541 Handle_DelAllSta(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFDelAllSta);
4545 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
4550 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
4551 up(&hSemHostIFthrdEnd);
4555 static void TimerCB_Scan(void *pvArg)
4557 tstrHostIFmsg strHostIFmsg;
4559 /* prepare the Timer Callback message */
4560 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4561 strHostIFmsg.drvHandler = pvArg;
4562 strHostIFmsg.u16MsgId = HOST_IF_MSG_SCAN_TIMER_FIRED;
4564 /* send the message */
4565 WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4568 static void TimerCB_Connect(void *pvArg)
4570 tstrHostIFmsg strHostIFmsg;
4572 /* prepare the Timer Callback message */
4573 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4574 strHostIFmsg.drvHandler = pvArg;
4575 strHostIFmsg.u16MsgId = HOST_IF_MSG_CONNECT_TIMER_FIRED;
4577 /* send the message */
4578 WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4583 * @brief removes wpa/wpa2 keys
4584 * @details only in BSS STA mode if External Supplicant support is enabled.
4585 * removes all WPA/WPA2 station key entries from MAC hardware.
4586 * @param[in,out] handle to the wifi driver
4587 * @param[in] 6 bytes of Station Adress in the station entry table
4588 * @return Error code indicating success/failure
4591 * @date 8 March 2012
4594 /* Check implementation in core adding 9 bytes to the input! */
4595 s32 host_int_remove_key(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8StaAddress)
4597 s32 s32Error = WILC_SUCCESS;
4599 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4601 strWID.u16WIDid = (u16)WID_REMOVE_KEY;
4602 strWID.enuWIDtype = WID_STR;
4603 strWID.ps8WidVal = (s8 *)pu8StaAddress;
4604 strWID.s32ValueSize = 6;
4611 * @brief removes WEP key
4612 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4613 * remove a WEP key entry from MAC HW.
4614 * The BSS Station automatically finds the index of the entry using its
4615 * BSS ID and removes that entry from the MAC hardware.
4616 * @param[in,out] handle to the wifi driver
4617 * @param[in] 6 bytes of Station Adress in the station entry table
4618 * @return Error code indicating success/failure
4619 * @note NO need for the STA add since it is not used for processing
4621 * @date 8 March 2012
4624 s32 host_int_remove_wep_key(WILC_WFIDrvHandle hWFIDrv, u8 u8keyIdx)
4626 s32 s32Error = WILC_SUCCESS;
4627 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4628 tstrHostIFmsg strHostIFmsg;
4631 if (pstrWFIDrv == NULL)
4632 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4634 /* prepare the Remove Wep Key Message */
4635 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4638 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4639 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4640 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = REMOVEKEY;
4641 strHostIFmsg.drvHandler = hWFIDrv;
4645 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4646 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8keyIdx;
4648 /* send the message */
4649 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4651 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
4652 down(&(pstrWFIDrv->hSemTestKeyBlock));
4654 WILC_CATCH(s32Error)
4662 * @brief sets WEP default key
4663 * @details Sets the index of the WEP encryption key in use,
4665 * @param[in,out] handle to the wifi driver
4666 * @param[in] key index ( 0, 1, 2, 3)
4667 * @return Error code indicating success/failure
4670 * @date 8 March 2012
4673 s32 host_int_set_WEPDefaultKeyID(WILC_WFIDrvHandle hWFIDrv, u8 u8Index)
4675 s32 s32Error = WILC_SUCCESS;
4676 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4677 tstrHostIFmsg strHostIFmsg;
4680 if (pstrWFIDrv == NULL)
4681 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4683 /* prepare the Key Message */
4684 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4687 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4688 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4689 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = DEFAULTKEY;
4690 strHostIFmsg.drvHandler = hWFIDrv;
4693 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4694 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Index;
4696 /* send the message */
4697 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4699 PRINT_ER("Error in sending message queue : Default key index\n");
4700 down(&(pstrWFIDrv->hSemTestKeyBlock));
4702 WILC_CATCH(s32Error)
4711 * @brief sets WEP deafault key
4712 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4713 * sets WEP key entry into MAC hardware when it receives the
4714 * corresponding request from NDIS.
4715 * @param[in,out] handle to the wifi driver
4716 * @param[in] message containing WEP Key in the following format
4717 *|---------------------------------------|
4718 *|Key ID Value | Key Length | Key |
4719 *|-------------|------------|------------|
4720 | 1byte | 1byte | Key Length |
4721 ||---------------------------------------|
4723 * @return Error code indicating success/failure
4726 * @date 8 March 2012
4729 s32 host_int_add_wep_key_bss_sta(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx)
4732 s32 s32Error = WILC_SUCCESS;
4733 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4734 tstrHostIFmsg strHostIFmsg;
4736 if (pstrWFIDrv == NULL)
4737 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4740 /* prepare the Key Message */
4741 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4744 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4745 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4746 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
4747 strHostIFmsg.drvHandler = hWFIDrv;
4750 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4751 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = (u8 *)WILC_MALLOC(u8WepKeylen);
4753 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
4754 pu8WepKey, u8WepKeylen);
4757 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4758 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4760 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4761 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4763 /* send the message */
4764 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4766 PRINT_ER("Error in sending message queue :WEP Key\n");
4767 down(&(pstrWFIDrv->hSemTestKeyBlock));
4769 WILC_CATCH(s32Error)
4777 #ifdef WILC_AP_EXTERNAL_MLME
4780 * @brief host_int_add_wep_key_bss_ap
4781 * @details valid only in BSS AP mode if External Supplicant support is enabled.
4782 * sets WEP key entry into MAC hardware when it receives the
4784 * corresponding request from NDIS.
4785 * @param[in,out] handle to the wifi driver
4788 * @return Error code indicating success/failure
4794 s32 host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx, u8 u8mode, AUTHTYPE_T tenuAuth_type)
4797 s32 s32Error = WILC_SUCCESS;
4798 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4799 tstrHostIFmsg strHostIFmsg;
4802 if (pstrWFIDrv == NULL)
4803 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4806 /* prepare the Key Message */
4807 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4810 for (i = 0; i < u8WepKeylen; i++)
4811 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
4813 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4814 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4815 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
4816 strHostIFmsg.drvHandler = hWFIDrv;
4819 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4820 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = (u8 *)WILC_MALLOC((u8WepKeylen));
4823 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
4824 pu8WepKey, (u8WepKeylen));
4827 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4828 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4830 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4831 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4833 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4834 uniHostIFkeyAttr.strHostIFwepAttr.u8mode = u8mode;
4836 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4837 uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type = tenuAuth_type;
4838 /* send the message */
4839 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4842 PRINT_ER("Error in sending message queue :WEP Key\n");
4843 down(&(pstrWFIDrv->hSemTestKeyBlock));
4845 WILC_CATCH(s32Error)
4854 * @brief adds ptk Key
4856 * @param[in,out] handle to the wifi driver
4857 * @param[in] message containing PTK Key in the following format
4858 *|-----------------------------------------------------------------------------|
4859 *|Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
4860 *|----------------|------------|--------------|----------------|---------------|
4861 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
4862 ||-----------------------------------------------------------------------------|
4863 * @return Error code indicating success/failure
4866 * @date 8 March 2012
4869 s32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen,
4870 const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode, u8 u8Idx)
4872 s32 s32Error = WILC_SUCCESS;
4873 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4874 tstrHostIFmsg strHostIFmsg;
4875 u8 u8KeyLen = u8PtkKeylen;
4878 if (pstrWFIDrv == NULL)
4879 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4880 if (pu8RxMic != NULL)
4881 u8KeyLen += RX_MIC_KEY_LEN;
4882 if (pu8TxMic != NULL)
4883 u8KeyLen += TX_MIC_KEY_LEN;
4885 /* prepare the Key Message */
4886 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4889 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4890 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WPAPtk;
4891 #ifdef WILC_AP_EXTERNAL_MLME
4892 if (mode == AP_MODE) {
4893 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
4894 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4895 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8Idx;
4898 if (mode == STATION_MODE)
4899 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
4902 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4903 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = (u8 *)WILC_MALLOC(u8PtkKeylen);
4906 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
4907 pu8Ptk, u8PtkKeylen);
4909 if (pu8RxMic != NULL) {
4911 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
4912 pu8RxMic, RX_MIC_KEY_LEN);
4914 for (i = 0; i < RX_MIC_KEY_LEN; i++)
4915 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
4918 if (pu8TxMic != NULL) {
4920 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
4921 pu8TxMic, TX_MIC_KEY_LEN);
4923 for (i = 0; i < TX_MIC_KEY_LEN; i++)
4924 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
4928 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4929 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
4931 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4932 uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
4933 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4934 uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr = mac_addr;
4935 strHostIFmsg.drvHandler = hWFIDrv;
4937 /* send the message */
4938 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4941 PRINT_ER("Error in sending message queue: PTK Key\n");
4943 /* ////////////// */
4944 down(&(pstrWFIDrv->hSemTestKeyBlock));
4945 /* WILC_Sleep(100); */
4948 WILC_CATCH(s32Error)
4957 * @brief adds Rx GTk Key
4959 * @param[in,out] handle to the wifi driver
4960 * @param[in] pu8RxGtk : contains temporal key | Rx Mic | Tx Mic
4961 * u8GtkKeylen :The total key length
4963 * @return Error code indicating success/failure
4966 * @date 8 March 2012
4969 s32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen,
4970 u8 u8KeyIdx, u32 u32KeyRSClen, const u8 *KeyRSC,
4971 const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode)
4973 s32 s32Error = WILC_SUCCESS;
4974 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4975 tstrHostIFmsg strHostIFmsg;
4976 u8 u8KeyLen = u8GtkKeylen;
4978 if (pstrWFIDrv == NULL)
4979 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4980 /* prepare the Key Message */
4981 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4984 if (pu8RxMic != NULL)
4985 u8KeyLen += RX_MIC_KEY_LEN;
4986 if (pu8TxMic != NULL)
4987 u8KeyLen += TX_MIC_KEY_LEN;
4988 if (KeyRSC != NULL) {
4989 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4990 uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq = (u8 *)WILC_MALLOC(u32KeyRSClen);
4992 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq,
4993 KeyRSC, u32KeyRSClen);
4997 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4998 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WPARxGtk;
4999 strHostIFmsg.drvHandler = hWFIDrv;
5001 #ifdef WILC_AP_EXTERNAL_MLME
5002 if (mode == AP_MODE) {
5003 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
5004 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
5007 if (mode == STATION_MODE)
5008 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
5011 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5012 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = (u8 *)WILC_MALLOC(u8KeyLen);
5014 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
5015 pu8RxGtk, u8GtkKeylen);
5017 if (pu8RxMic != NULL) {
5019 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
5020 pu8RxMic, RX_MIC_KEY_LEN);
5023 if (pu8TxMic != NULL) {
5025 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
5026 pu8TxMic, TX_MIC_KEY_LEN);
5030 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5031 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8KeyIdx;
5032 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5033 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
5035 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5036 uniHostIFkeyAttr.strHostIFwpaAttr.u8seqlen = u32KeyRSClen;
5040 /* send the message */
5041 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5043 PRINT_ER("Error in sending message queue: RX GTK\n");
5044 /* ////////////// */
5045 down(&(pstrWFIDrv->hSemTestKeyBlock));
5046 /* WILC_Sleep(100); */
5049 WILC_CATCH(s32Error)
5057 * @brief host_int_set_pmkid_info
5058 * @details caches the pmkid valid only in BSS STA mode if External Supplicant
5059 * support is enabled. This Function sets the PMKID in firmware
5060 * when host drivr receives the corresponding request from NDIS.
5061 * The firmware then includes theset PMKID in the appropriate
5063 * @param[in,out] handle to the wifi driver
5064 * @param[in] message containing PMKID Info in the following format
5065 *|-----------------------------------------------------------------|
5066 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
5067 *|-----------|------------|----------|-------|----------|----------|
5068 | 1 | 6 | 16 | ... | 6 | 16 |
5069 ||-----------------------------------------------------------------|
5070 * @return Error code indicating success/failure
5073 * @date 8 March 2012
5076 s32 host_int_set_pmkid_info(WILC_WFIDrvHandle hWFIDrv, tstrHostIFpmkidAttr *pu8PmkidInfoArray)
5078 s32 s32Error = WILC_SUCCESS;
5079 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5080 tstrHostIFmsg strHostIFmsg;
5084 if (pstrWFIDrv == NULL)
5085 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5087 /* prepare the Key Message */
5088 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5090 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
5091 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = PMKSA;
5092 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
5093 strHostIFmsg.drvHandler = hWFIDrv;
5095 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
5097 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
5100 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
5104 /* send the message */
5105 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5107 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
5109 WILC_CATCH(s32Error)
5118 * @brief gets the cached the pmkid info
5119 * @details valid only in BSS STA mode if External Supplicant
5120 * support is enabled. This Function sets the PMKID in firmware
5121 * when host drivr receives the corresponding request from NDIS.
5122 * The firmware then includes theset PMKID in the appropriate
5124 * @param[in,out] handle to the wifi driver,
5125 * message containing PMKID Info in the following format
5126 *|-----------------------------------------------------------------|
5127 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
5128 *|-----------|------------|----------|-------|----------|----------|
5129 | 1 | 6 | 16 | ... | 6 | 16 |
5130 ||-----------------------------------------------------------------|
5132 * @return Error code indicating success/failure
5135 * @date 8 March 2012
5138 s32 host_int_get_pmkid_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PmkidInfoArray,
5139 u32 u32PmkidInfoLen)
5141 s32 s32Error = WILC_SUCCESS;
5143 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5145 strWID.u16WIDid = (u16)WID_PMKID_INFO;
5146 strWID.enuWIDtype = WID_STR;
5147 strWID.s32ValueSize = u32PmkidInfoLen;
5148 strWID.ps8WidVal = pu8PmkidInfoArray;
5154 * @brief sets the pass phrase
5155 * @details AP/STA mode. This function gives the pass phrase used to
5156 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5157 * The length of the field can vary from 8 to 64 bytes,
5158 * the lower layer should get the
5159 * @param[in,out] handle to the wifi driver,
5160 * @param[in] String containing PSK
5161 * @return Error code indicating success/failure
5164 * @date 8 March 2012
5167 s32 host_int_set_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PassPhrase,
5170 s32 s32Error = WILC_SUCCESS;
5172 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5174 /* u8 u8Psklength = WILC_strlen(pu8PassPhrase); */
5175 /*validating psk length*/
5176 if ((u8Psklength > 7) && (u8Psklength < 65)) {
5177 strWID.u16WIDid = (u16)WID_11I_PSK;
5178 strWID.enuWIDtype = WID_STR;
5179 strWID.ps8WidVal = pu8PassPhrase;
5180 strWID.s32ValueSize = u8Psklength;
5186 * @brief host_int_get_MacAddress
5187 * @details gets mac address
5188 * @param[in,out] handle to the wifi driver,
5190 * @return Error code indicating success/failure
5193 * @date 19 April 2012
5196 s32 host_int_get_MacAddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8MacAddress)
5198 s32 s32Error = WILC_SUCCESS;
5199 tstrHostIFmsg strHostIFmsg;
5202 /* prepare the Message */
5203 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5205 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_MAC_ADDRESS;
5206 strHostIFmsg.uniHostIFmsgBody.strHostIfGetMacAddress.u8MacAddress = pu8MacAddress;
5207 strHostIFmsg.drvHandler = hWFIDrv;
5208 /* send the message */
5209 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5211 PRINT_ER("Failed to send get mac address\n");
5215 down(&hWaitResponse);
5220 * @brief host_int_set_MacAddress
5221 * @details sets mac address
5222 * @param[in,out] handle to the wifi driver,
5224 * @return Error code indicating success/failure
5227 * @date 16 July 2012
5230 s32 host_int_set_MacAddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8MacAddress)
5232 s32 s32Error = WILC_SUCCESS;
5233 tstrHostIFmsg strHostIFmsg;
5235 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
5237 /* prepare setting mac address message */
5238 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5239 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_MAC_ADDRESS;
5240 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIfSetMacAddress.u8MacAddress, pu8MacAddress, ETH_ALEN);
5241 strHostIFmsg.drvHandler = hWFIDrv;
5243 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5245 PRINT_ER("Failed to send message queue: Set mac address\n");
5246 WILC_ERRORREPORT(s32Error, s32Error);
5248 WILC_CATCH(s32Error)
5258 * @brief host_int_get_RSNAConfigPSKPassPhrase
5259 * @details gets the pass phrase:AP/STA mode. This function gets the pass phrase used to
5260 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5261 * The length of the field can vary from 8 to 64 bytes,
5262 * the lower layer should get the
5263 * @param[in,out] handle to the wifi driver,
5264 * String containing PSK
5265 * @return Error code indicating success/failure
5268 * @date 8 March 2012
5271 s32 host_int_get_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv,
5272 u8 *pu8PassPhrase, u8 u8Psklength)
5274 s32 s32Error = WILC_SUCCESS;
5276 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5278 strWID.u16WIDid = (u16)WID_11I_PSK;
5279 strWID.enuWIDtype = WID_STR;
5280 strWID.s32ValueSize = u8Psklength;
5281 strWID.ps8WidVal = pu8PassPhrase;
5287 * @brief host_int_get_site_survey_results
5288 * @details gets the site survey results
5289 * @param[in,out] handle to the wifi driver,
5290 * Message containing site survey results in the
5292 *|---------------------------------------------------|
5293 | MsgLength | fragNo. | MsgBodyLength | MsgBody |
5294 ||-----------|-----------|---------------|-----------|
5296 | ----------------------------------------- | ----------------
5298 ||---------------------------------------|
5299 | Network1 | Netweork2 | ... | Network5 |
5300 ||---------------------------------------|
5301 | 44 | 44 | ... | 44 |
5302 | -------------------------- | ---------------------------------------
5304 ||---------------------------------------------------------------------|
5305 | SSID | BSS Type | Channel | Security Status| BSSID | RSSI |Reserved |
5308 ||------|----------|---------|----------------|-------|------|---------|
5309 | 33 | 1 | 1 | 1 | 6 | 1 | 1 |
5310 ||---------------------------------------------------------------------|
5311 * @return Error code indicating success/failure
5314 * @date 8 March 2012
5317 #ifndef CONNECT_DIRECT
5318 s32 host_int_get_site_survey_results(WILC_WFIDrvHandle hWFIDrv,
5319 u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE],
5320 u32 u32MaxSiteSrvyFragLen)
5322 s32 s32Error = WILC_SUCCESS;
5323 tstrWID astrWIDList[2];
5324 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5326 astrWIDList[0].u16WIDid = (u16)WID_SITE_SURVEY_RESULTS;
5327 astrWIDList[0].enuWIDtype = WID_STR;
5328 astrWIDList[0].ps8WidVal = ppu8RcvdSiteSurveyResults[0];
5329 astrWIDList[0].s32ValueSize = u32MaxSiteSrvyFragLen;
5331 astrWIDList[1].u16WIDid = (u16)WID_SITE_SURVEY_RESULTS;
5332 astrWIDList[1].enuWIDtype = WID_STR;
5333 astrWIDList[1].ps8WidVal = ppu8RcvdSiteSurveyResults[1];
5334 astrWIDList[1].s32ValueSize = u32MaxSiteSrvyFragLen;
5336 s32Error = SendConfigPkt(GET_CFG, astrWIDList, 2, true, (u32)pstrWFIDrv);
5338 /*get the value by searching the local copy*/
5340 PRINT_ER("Failed to send config packet to get survey results\n");
5341 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
5344 WILC_CATCH(s32Error)
5354 * @brief sets a start scan request
5356 * @param[in,out] handle to the wifi driver,
5357 * @param[in] Scan Source one of the following values
5360 * OBSS_PERIODIC_SCAN BIT1
5361 * OBSS_ONETIME_SCAN BIT2
5362 * @return Error code indicating success/failure
5365 * @date 8 March 2012
5368 s32 host_int_set_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 scanSource)
5370 s32 s32Error = WILC_SUCCESS;
5372 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5374 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
5375 strWID.enuWIDtype = WID_CHAR;
5376 strWID.ps8WidVal = (s8 *)&scanSource;
5377 strWID.s32ValueSize = sizeof(char);
5383 * @brief host_int_get_start_scan_req
5384 * @details gets a start scan request
5385 * @param[in,out] handle to the wifi driver,
5386 * @param[in] Scan Source one of the following values
5389 * OBSS_PERIODIC_SCAN BIT1
5390 * OBSS_ONETIME_SCAN BIT2
5391 * @return Error code indicating success/failure
5394 * @date 8 March 2012
5398 s32 host_int_get_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ScanSource)
5400 s32 s32Error = WILC_SUCCESS;
5402 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5404 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
5405 strWID.enuWIDtype = WID_CHAR;
5406 strWID.ps8WidVal = (s8 *)pu8ScanSource;
5407 strWID.s32ValueSize = sizeof(char);
5413 * @brief host_int_set_join_req
5414 * @details sets a join request
5415 * @param[in,out] handle to the wifi driver,
5416 * @param[in] Index of the bss descriptor
5417 * @return Error code indicating success/failure
5420 * @date 8 March 2012
5423 s32 host_int_set_join_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8bssid,
5424 const u8 *pu8ssid, size_t ssidLen,
5425 const u8 *pu8IEs, size_t IEsLen,
5426 tWILCpfConnectResult pfConnectResult, void *pvUserArg,
5427 u8 u8security, AUTHTYPE_T tenuAuth_type,
5431 s32 s32Error = WILC_SUCCESS;
5432 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5433 tstrHostIFmsg strHostIFmsg;
5434 tenuScanConnTimer enuScanConnTimer;
5436 if (pstrWFIDrv == NULL || pfConnectResult == NULL)
5437 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5439 if (hWFIDrv == NULL) {
5440 PRINT_ER("Driver not initialized: gWFiDrvHandle = NULL\n");
5441 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5444 if (pJoinParams == NULL) {
5445 PRINT_ER("Unable to Join - JoinParams is NULL\n");
5446 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5450 * if(gWFiDrvHandle->strWILC_UsrScanReq.u32RcvdChCount == 0)
5452 * PRINT_ER("No scan results exist: Scanning should be done\n");
5453 * WILC_ERRORREPORT(s32Error, WILC_FAIL);
5456 /* prepare the Connect Message */
5457 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5459 strHostIFmsg.u16MsgId = HOST_IF_MSG_CONNECT;
5461 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.u8security = u8security;
5462 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.tenuAuth_type = tenuAuth_type;
5463 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.u8channel = u8channel;
5464 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pfConnectResult = pfConnectResult;
5465 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pvUserArg = pvUserArg;
5466 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pJoinParams = pJoinParams;
5467 strHostIFmsg.drvHandler = hWFIDrv;
5469 if (pu8bssid != NULL) {
5470 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8bssid = (u8 *)WILC_MALLOC(6); /* will be deallocated by the receiving thread */
5471 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8bssid,
5475 if (pu8ssid != NULL) {
5476 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.ssidLen = ssidLen;
5477 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8ssid = (u8 *)WILC_MALLOC(ssidLen); /* will be deallocated by the receiving thread */
5478 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8ssid,
5483 if (pu8IEs != NULL) {
5484 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.IEsLen = IEsLen;
5485 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8IEs = (u8 *)WILC_MALLOC(IEsLen); /* will be deallocated by the receiving thread */
5486 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8IEs,
5489 if (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTING) {
5490 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTING;
5492 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", pstrWFIDrv->enuHostIFstate);
5494 /* send the message */
5495 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5497 PRINT_ER("Failed to send message queue: Set join request\n");
5498 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5501 enuScanConnTimer = CONNECT_TIMER;
5502 WILC_TimerStart(&(pstrWFIDrv->hConnectTimer), HOST_IF_CONNECT_TIMEOUT, (void *) hWFIDrv, NULL);
5504 WILC_CATCH(s32Error)
5513 * @brief Flush a join request parameters to FW, but actual connection
5514 * @details The function is called in situation where WILC is connected to AP and
5515 * required to switch to hybrid FW for P2P connection
5516 * @param[in] handle to the wifi driver,
5517 * @return Error code indicating success/failure
5519 * @author Amr Abdel-Moghny
5524 s32 host_int_flush_join_req(WILC_WFIDrvHandle hWFIDrv)
5526 s32 s32Error = WILC_SUCCESS;
5527 tstrHostIFmsg strHostIFmsg;
5529 if (!gu8FlushedJoinReq) {
5530 s32Error = WILC_FAIL;
5535 if (hWFIDrv == NULL)
5536 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5539 strHostIFmsg.u16MsgId = HOST_IF_MSG_FLUSH_CONNECT;
5540 strHostIFmsg.drvHandler = hWFIDrv;
5542 /* send the message */
5543 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5545 PRINT_ER("Failed to send message queue: Flush join request\n");
5546 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5549 WILC_CATCH(s32Error)
5557 * @brief host_int_disconnect
5558 * @details disconnects from the currently associated network
5559 * @param[in,out] handle to the wifi driver,
5560 * @param[in] Reason Code of the Disconnection
5561 * @return Error code indicating success/failure
5564 * @date 8 March 2012
5567 s32 host_int_disconnect(WILC_WFIDrvHandle hWFIDrv, u16 u16ReasonCode)
5569 s32 s32Error = WILC_SUCCESS;
5570 tstrHostIFmsg strHostIFmsg;
5571 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5573 if (pstrWFIDrv == NULL) {
5574 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
5575 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5578 if (pstrWFIDrv == NULL) {
5579 PRINT_ER("gWFiDrvHandle = NULL\n");
5580 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5583 /* prepare the Disconnect Message */
5584 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5586 strHostIFmsg.u16MsgId = HOST_IF_MSG_DISCONNECT;
5587 strHostIFmsg.drvHandler = hWFIDrv;
5589 /* send the message */
5590 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5592 PRINT_ER("Failed to send message queue: disconnect\n");
5593 /* ////////////// */
5594 down(&(pstrWFIDrv->hSemTestDisconnectBlock));
5597 WILC_CATCH(s32Error)
5606 * @brief host_int_disconnect_station
5607 * @details disconnects a sta
5608 * @param[in,out] handle to the wifi driver,
5609 * @param[in] Association Id of the station to be disconnected
5610 * @return Error code indicating success/failure
5613 * @date 8 March 2012
5616 s32 host_int_disconnect_station(WILC_WFIDrvHandle hWFIDrv, u8 assoc_id)
5618 s32 s32Error = WILC_SUCCESS;
5620 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5622 strWID.u16WIDid = (u16)WID_DISCONNECT;
5623 strWID.enuWIDtype = WID_CHAR;
5624 strWID.ps8WidVal = (s8 *)&assoc_id;
5625 strWID.s32ValueSize = sizeof(char);
5631 * @brief host_int_get_assoc_req_info
5632 * @details gets a Association request info
5633 * @param[in,out] handle to the wifi driver,
5634 * Message containg assoc. req info in the following format
5635 * ------------------------------------------------------------------------
5636 | Management Frame Format |
5637 ||-------------------------------------------------------------------|
5638 ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS |
5639 ||-------------|--------|--|--|-----|----------------|----------|----|
5640 | 2 |2 |6 |6 |6 | 2 |0 - 2312 | 4 |
5641 ||-------------------------------------------------------------------|
5643 | Association Request Frame - Frame Body |
5644 ||-------------------------------------------------------------------|
5645 | Capability Information | Listen Interval | SSID | Supported Rates |
5646 ||------------------------|-----------------|------|-----------------|
5647 | 2 | 2 | 2-34 | 3-10 |
5648 | ---------------------------------------------------------------------
5649 * @return Error code indicating success/failure
5652 * @date 8 March 2012
5656 s32 host_int_get_assoc_req_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocReqInfo,
5657 u32 u32AssocReqInfoLen)
5659 s32 s32Error = WILC_SUCCESS;
5661 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5663 strWID.u16WIDid = (u16)WID_ASSOC_REQ_INFO;
5664 strWID.enuWIDtype = WID_STR;
5665 strWID.ps8WidVal = pu8AssocReqInfo;
5666 strWID.s32ValueSize = u32AssocReqInfoLen;
5673 * @brief gets a Association Response info
5675 * @param[in,out] handle to the wifi driver,
5676 * Message containg assoc. resp info
5677 * @return Error code indicating success/failure
5680 * @date 8 March 2012
5683 s32 host_int_get_assoc_res_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocRespInfo,
5684 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
5686 s32 s32Error = WILC_SUCCESS;
5688 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5690 if (pstrWFIDrv == NULL) {
5691 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
5692 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5695 strWID.u16WIDid = (u16)WID_ASSOC_RES_INFO;
5696 strWID.enuWIDtype = WID_STR;
5697 strWID.ps8WidVal = pu8AssocRespInfo;
5698 strWID.s32ValueSize = u32MaxAssocRespInfoLen;
5701 /* Sending Configuration packet */
5702 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
5704 PRINT_ER("Failed to send association response config packet\n");
5705 *pu32RcvdAssocRespInfoLen = 0;
5706 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
5708 *pu32RcvdAssocRespInfoLen = strWID.s32ValueSize;
5711 WILC_CATCH(s32Error)
5719 * @brief gets a Association Response info
5720 * @details Valid only in STA mode. This function gives the RSSI
5721 * values observed in all the channels at the time of scanning.
5722 * The length of the field is 1 greater that the total number of
5723 * channels supported. Byte 0 contains the number of channels while
5724 * each of Byte N contains the observed RSSI value for the channel index N.
5725 * @param[in,out] handle to the wifi driver,
5726 * array of scanned channels' RSSI
5727 * @return Error code indicating success/failure
5730 * @date 8 March 2012
5733 s32 host_int_get_rx_power_level(WILC_WFIDrvHandle hWFIDrv, u8 *pu8RxPowerLevel,
5734 u32 u32RxPowerLevelLen)
5736 s32 s32Error = WILC_SUCCESS;
5738 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5740 strWID.u16WIDid = (u16)WID_RX_POWER_LEVEL;
5741 strWID.enuWIDtype = WID_STR;
5742 strWID.ps8WidVal = pu8RxPowerLevel;
5743 strWID.s32ValueSize = u32RxPowerLevelLen;
5750 * @brief sets a channel
5752 * @param[in,out] handle to the wifi driver,
5753 * @param[in] Index of the channel to be set
5754 *|-------------------------------------------------------------------|
5755 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5757 ||-------------------------------------------------------------------|
5758 * @return Error code indicating success/failure
5761 * @date 8 March 2012
5764 s32 host_int_set_mac_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 u8ChNum)
5766 s32 s32Error = WILC_SUCCESS;
5767 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5768 tstrHostIFmsg strHostIFmsg;
5770 if (pstrWFIDrv == NULL)
5771 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5773 /* prepare the set channel message */
5774 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5775 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_CHANNEL;
5776 strHostIFmsg.uniHostIFmsgBody.strHostIFSetChan.u8SetChan = u8ChNum;
5777 strHostIFmsg.drvHandler = hWFIDrv;
5779 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5781 WILC_ERRORREPORT(s32Error, s32Error);
5782 WILC_CATCH(s32Error)
5791 s32 host_int_wait_msg_queue_idle(void)
5793 s32 s32Error = WILC_SUCCESS;
5795 tstrHostIFmsg strHostIFmsg;
5797 /* prepare the set driver handler message */
5799 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5800 strHostIFmsg.u16MsgId = HOST_IF_MSG_Q_IDLE;
5801 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5803 WILC_ERRORREPORT(s32Error, s32Error);
5804 WILC_CATCH(s32Error)
5809 /* wait untill MSG Q is empty */
5810 down(&hWaitResponse);
5816 s32 host_int_set_wfi_drv_handler(u32 u32address)
5818 s32 s32Error = WILC_SUCCESS;
5820 tstrHostIFmsg strHostIFmsg;
5823 /* prepare the set driver handler message */
5825 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5826 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_WFIDRV_HANDLER;
5827 strHostIFmsg.uniHostIFmsgBody.strHostIfSetDrvHandler.u32Address = u32address;
5828 /* strHostIFmsg.drvHandler=hWFIDrv; */
5830 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5832 WILC_ERRORREPORT(s32Error, s32Error);
5833 WILC_CATCH(s32Error)
5843 s32 host_int_set_operation_mode(WILC_WFIDrvHandle hWFIDrv, u32 u32mode)
5845 s32 s32Error = WILC_SUCCESS;
5847 tstrHostIFmsg strHostIFmsg;
5850 /* prepare the set driver handler message */
5852 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5853 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_OPERATION_MODE;
5854 strHostIFmsg.uniHostIFmsgBody.strHostIfSetOperationMode.u32Mode = u32mode;
5855 strHostIFmsg.drvHandler = hWFIDrv;
5857 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5859 WILC_ERRORREPORT(s32Error, s32Error);
5860 WILC_CATCH(s32Error)
5869 * @brief gets the current channel index
5871 * @param[in,out] handle to the wifi driver,
5872 * current channel index
5873 *|-----------------------------------------------------------------------|
5874 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5876 ||-----------------------------------------------------------------------|
5877 * @return Error code indicating success/failure
5880 * @date 8 March 2012
5883 s32 host_int_get_host_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ChNo)
5885 s32 s32Error = WILC_SUCCESS;
5886 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5887 tstrHostIFmsg strHostIFmsg;
5889 if (pstrWFIDrv == NULL) {
5890 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
5891 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5894 /* prepare the Get Channel Message */
5895 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5897 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_CHNL;
5898 strHostIFmsg.drvHandler = hWFIDrv;
5900 /* send the message */
5901 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5903 PRINT_ER("Failed to send get host channel param's message queue ");
5904 down(&(pstrWFIDrv->hSemGetCHNL));
5909 WILC_CATCH(s32Error)
5920 * @brief host_int_test_set_int_wid
5921 * @details Test function for setting wids
5922 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr
5923 * @return Error code indicating success/failure
5926 * @date 8 March 2012
5929 s32 host_int_test_set_int_wid(WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr)
5931 s32 s32Error = WILC_SUCCESS;
5933 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5936 if (pstrWFIDrv == NULL) {
5937 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
5938 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5941 /*prepare configuration packet*/
5942 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
5943 strWID.enuWIDtype = WID_INT;
5944 strWID.ps8WidVal = (char *)&u32TestMemAddr;
5945 strWID.s32ValueSize = sizeof(u32);
5948 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
5950 PRINT_ER("Test Function: Failed to set wid value\n");
5951 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
5953 PRINT_D(HOSTINF_DBG, "Successfully set wid value\n");
5957 WILC_CATCH(s32Error)
5964 #ifdef WILC_AP_EXTERNAL_MLME
5966 * @brief host_int_get_inactive_time
5968 * @param[in,out] handle to the wifi driver,
5969 * current sta macaddress, inactive_time
5976 s32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, const u8 *mac, u32 *pu32InactiveTime)
5978 s32 s32Error = WILC_SUCCESS;
5979 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5980 tstrHostIFmsg strHostIFmsg;
5982 if (pstrWFIDrv == NULL) {
5983 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
5984 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5987 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5990 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIfStaInactiveT.mac,
5993 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_INACTIVETIME;
5994 strHostIFmsg.drvHandler = hWFIDrv;
5996 /* send the message */
5997 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5999 PRINT_ER("Failed to send get host channel param's message queue ");
6001 down(&(pstrWFIDrv->hSemInactiveTime));
6003 *pu32InactiveTime = gu32InactiveTime;
6005 WILC_CATCH(s32Error)
6013 * @brief host_int_test_get_int_wid
6014 * @details Test function for getting wids
6015 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32* pu32TestMemAddr
6016 * @return Error code indicating success/failure
6019 * @date 8 March 2012
6022 s32 host_int_test_get_int_wid(WILC_WFIDrvHandle hWFIDrv, u32 *pu32TestMemAddr)
6025 s32 s32Error = WILC_SUCCESS;
6027 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6030 if (pstrWFIDrv == NULL) {
6031 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
6032 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6035 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
6036 strWID.enuWIDtype = WID_INT;
6037 strWID.ps8WidVal = (s8 *)pu32TestMemAddr;
6038 strWID.s32ValueSize = sizeof(u32);
6040 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
6041 /*get the value by searching the local copy*/
6043 PRINT_ER("Test Function: Failed to get wid value\n");
6044 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
6046 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
6050 WILC_CATCH(s32Error)
6059 * @brief host_int_get_rssi
6060 * @details gets the currently maintained RSSI value for the station.
6061 * The received signal strength value in dB.
6062 * The range of valid values is -128 to 0.
6063 * @param[in,out] handle to the wifi driver,
6065 * @return Error code indicating success/failure
6068 * @date 8 March 2012
6071 s32 host_int_get_rssi(WILC_WFIDrvHandle hWFIDrv, s8 *ps8Rssi)
6073 s32 s32Error = WILC_SUCCESS;
6074 tstrHostIFmsg strHostIFmsg;
6075 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6078 /* prepare the Get RSSI Message */
6079 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6081 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_RSSI;
6082 strHostIFmsg.drvHandler = hWFIDrv;
6084 /* send the message */
6085 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6087 PRINT_ER("Failed to send get host channel param's message queue ");
6091 down(&(pstrWFIDrv->hSemGetRSSI));
6094 if (ps8Rssi == NULL) {
6095 PRINT_ER("RSS pointer value is null");
6106 s32 host_int_get_link_speed(WILC_WFIDrvHandle hWFIDrv, s8 *ps8lnkspd)
6108 tstrHostIFmsg strHostIFmsg;
6109 s32 s32Error = WILC_SUCCESS;
6111 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6115 /* prepare the Get LINKSPEED Message */
6116 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6118 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_LINKSPEED;
6119 strHostIFmsg.drvHandler = hWFIDrv;
6121 /* send the message */
6122 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6124 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
6128 down(&(pstrWFIDrv->hSemGetLINKSPEED));
6131 if (ps8lnkspd == NULL) {
6132 PRINT_ER("LINKSPEED pointer value is null");
6137 *ps8lnkspd = gs8lnkspd;
6143 s32 host_int_get_statistics(WILC_WFIDrvHandle hWFIDrv, tstrStatistics *pstrStatistics)
6145 s32 s32Error = WILC_SUCCESS;
6146 tstrHostIFmsg strHostIFmsg;
6149 /* prepare the Get RSSI Message */
6150 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6152 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_STATISTICS;
6153 strHostIFmsg.uniHostIFmsgBody.pUserData = (char *)pstrStatistics;
6154 strHostIFmsg.drvHandler = hWFIDrv;
6155 /* send the message */
6156 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6158 PRINT_ER("Failed to send get host channel param's message queue ");
6162 down(&hWaitResponse);
6168 * @brief host_int_scan
6169 * @details scans a set of channels
6170 * @param[in,out] handle to the wifi driver,
6171 * @param[in] Scan source
6172 * Scan Type PASSIVE_SCAN = 0,
6175 * Channels Array length
6176 * Scan Callback function
6177 * @return Error code indicating success/failure
6180 * @date 8 March 2012
6183 s32 host_int_scan(WILC_WFIDrvHandle hWFIDrv, u8 u8ScanSource,
6184 u8 u8ScanType, u8 *pu8ChnlFreqList,
6185 u8 u8ChnlListLen, const u8 *pu8IEs,
6186 size_t IEsLen, tWILCpfScanResult ScanResult,
6187 void *pvUserArg, tstrHiddenNetwork *pstrHiddenNetwork)
6189 s32 s32Error = WILC_SUCCESS;
6190 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6191 tstrHostIFmsg strHostIFmsg;
6192 tenuScanConnTimer enuScanConnTimer;
6194 if (pstrWFIDrv == NULL || ScanResult == NULL)
6195 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6198 /* prepare the Scan Message */
6199 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6201 strHostIFmsg.u16MsgId = HOST_IF_MSG_SCAN;
6203 if (pstrHiddenNetwork != NULL) {
6204 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.strHiddenNetwork.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
6205 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.strHiddenNetwork.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
6208 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
6210 strHostIFmsg.drvHandler = hWFIDrv;
6211 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ScanSource = u8ScanSource;
6212 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ScanType = u8ScanType;
6213 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pfScanResult = ScanResult;
6214 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pvUserArg = pvUserArg;
6216 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ChnlListLen = u8ChnlListLen;
6217 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8ChnlFreqList = (u8 *)WILC_MALLOC(u8ChnlListLen); /* will be deallocated by the receiving thread */
6218 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8ChnlFreqList,
6219 pu8ChnlFreqList, u8ChnlListLen);
6221 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.IEsLen = IEsLen;
6222 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8IEs = (u8 *)WILC_MALLOC(IEsLen); /* will be deallocated by the receiving thread */
6223 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8IEs,
6226 /* send the message */
6227 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6229 PRINT_ER("Error in sending message queue scanning parameters: Error(%d)\n", s32Error);
6230 WILC_ERRORREPORT(s32Error, WILC_FAIL);
6233 enuScanConnTimer = SCAN_TIMER;
6234 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
6235 WILC_TimerStart(&(pstrWFIDrv->hScanTimer), HOST_IF_SCAN_TIMEOUT, (void *) hWFIDrv, NULL);
6238 WILC_CATCH(s32Error)
6246 * @brief hif_set_cfg
6247 * @details sets configuration wids values
6248 * @param[in,out] handle to the wifi driver,
6249 * @param[in] WID, WID value
6250 * @return Error code indicating success/failure
6253 * @date 8 March 2012
6256 s32 hif_set_cfg(WILC_WFIDrvHandle hWFIDrv, tstrCfgParamVal *pstrCfgParamVal)
6259 s32 s32Error = WILC_SUCCESS;
6260 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6262 tstrHostIFmsg strHostIFmsg;
6265 if (pstrWFIDrv == NULL)
6266 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6267 /* prepare the WiphyParams Message */
6268 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6269 strHostIFmsg.u16MsgId = HOST_IF_MSG_CFG_PARAMS;
6270 strHostIFmsg.uniHostIFmsgBody.strHostIFCfgParamAttr.pstrCfgParamVal = *pstrCfgParamVal;
6271 strHostIFmsg.drvHandler = hWFIDrv;
6273 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6275 WILC_CATCH(s32Error)
6285 * @brief hif_get_cfg
6286 * @details gets configuration wids values
6287 * @param[in,out] handle to the wifi driver,
6290 * @return Error code indicating success/failure
6294 * @date 8 March 2012
6297 s32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, u16 u16WID, u16 *pu16WID_Value)
6299 s32 s32Error = WILC_SUCCESS;
6300 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6302 down(&(pstrWFIDrv->gtOsCfgValuesSem));
6304 if (pstrWFIDrv == NULL) {
6305 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
6306 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6308 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
6312 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.bss_type;
6316 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.auth_type;
6319 case WID_AUTH_TIMEOUT:
6320 *pu16WID_Value = pstrWFIDrv->strCfgValues.auth_timeout;
6323 case WID_POWER_MANAGEMENT:
6324 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.power_mgmt_mode;
6327 case WID_SHORT_RETRY_LIMIT:
6328 *pu16WID_Value = pstrWFIDrv->strCfgValues.short_retry_limit;
6331 case WID_LONG_RETRY_LIMIT:
6332 *pu16WID_Value = pstrWFIDrv->strCfgValues.long_retry_limit;
6335 case WID_FRAG_THRESHOLD:
6336 *pu16WID_Value = pstrWFIDrv->strCfgValues.frag_threshold;
6339 case WID_RTS_THRESHOLD:
6340 *pu16WID_Value = pstrWFIDrv->strCfgValues.rts_threshold;
6344 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.preamble_type;
6347 case WID_SHORT_SLOT_ALLOWED:
6348 *pu16WID_Value = (u16) pstrWFIDrv->strCfgValues.short_slot_allowed;
6351 case WID_11N_TXOP_PROT_DISABLE:
6352 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.txop_prot_disabled;
6355 case WID_BEACON_INTERVAL:
6356 *pu16WID_Value = pstrWFIDrv->strCfgValues.beacon_interval;
6359 case WID_DTIM_PERIOD:
6360 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.dtim_period;
6363 case WID_SITE_SURVEY:
6364 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.site_survey_enabled;
6367 case WID_SITE_SURVEY_SCAN_TIME:
6368 *pu16WID_Value = pstrWFIDrv->strCfgValues.site_survey_scan_time;
6371 case WID_ACTIVE_SCAN_TIME:
6372 *pu16WID_Value = pstrWFIDrv->strCfgValues.active_scan_time;
6375 case WID_PASSIVE_SCAN_TIME:
6376 *pu16WID_Value = pstrWFIDrv->strCfgValues.passive_scan_time;
6379 case WID_CURRENT_TX_RATE:
6380 *pu16WID_Value = pstrWFIDrv->strCfgValues.curr_tx_rate;
6387 up(&(pstrWFIDrv->gtOsCfgValuesSem));
6389 WILC_CATCH(s32Error)
6396 /*****************************************************************************/
6397 /* Notification Functions */
6398 /*****************************************************************************/
6400 * @brief notifies host with join and leave requests
6401 * @details This function prepares an Information frame having the
6402 * information about a joining/leaving station.
6403 * @param[in,out] handle to the wifi driver,
6404 * @param[in] 6 byte Sta Adress
6405 * Join or leave flag:
6408 * @return Error code indicating success/failure
6411 * @date 8 March 2012
6414 void host_int_send_join_leave_info_to_host
6415 (u16 assocId, u8 *stationAddr, bool joining)
6419 * @brief notifies host with stations found in scan
6420 * @details sends the beacon/probe response from scan
6421 * @param[in,out] handle to the wifi driver,
6422 * @param[in] Sta Address,
6424 * Rssi of the Station found
6425 * @return Error code indicating success/failure
6428 * @date 8 March 2012
6432 void GetPeriodicRSSI(void *pvArg)
6434 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)pvArg;
6436 if (pstrWFIDrv == NULL) {
6437 PRINT_ER("Driver handler is NULL\n");
6441 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
6442 s32 s32Error = WILC_SUCCESS;
6443 tstrHostIFmsg strHostIFmsg;
6445 /* prepare the Get RSSI Message */
6446 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6448 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_RSSI;
6449 strHostIFmsg.drvHandler = pstrWFIDrv;
6451 /* send the message */
6452 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6454 PRINT_ER("Failed to send get host channel param's message queue ");
6458 WILC_TimerStart(&(g_hPeriodicRSSI), 5000, (void *)pstrWFIDrv, NULL);
6462 void host_int_send_network_info_to_host
6463 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
6467 * @brief host_int_init
6468 * @details host interface initialization function
6469 * @param[in,out] handle to the wifi driver,
6472 * @date 8 March 2012
6475 static u32 u32Intialized;
6476 static u32 msgQ_created;
6477 static u32 clients_count;
6479 s32 host_int_init(WILC_WFIDrvHandle *phWFIDrv)
6481 s32 s32Error = WILC_SUCCESS;
6482 tstrWILC_WFIDrv *pstrWFIDrv;
6484 /*if(u32Intialized == 1)
6486 * PRINT_D(HOSTINF_DBG,"Host interface is previously initialized\n");
6487 * *phWFIDrv = (WILC_WFIDrvHandle)gWFiDrvHandle; //Will be adjusted later for P2P
6490 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
6492 gbScanWhileConnected = false;
6494 sema_init(&hWaitResponse, 0);
6498 /*Allocate host interface private structure*/
6499 pstrWFIDrv = (tstrWILC_WFIDrv *)WILC_MALLOC(sizeof(tstrWILC_WFIDrv));
6500 if (pstrWFIDrv == NULL) {
6501 /* WILC_ERRORREPORT(s32Error,WILC_NO_MEM); */
6502 s32Error = WILC_NO_MEM;
6503 PRINT_ER("Failed to allocate memory\n");
6506 WILC_memset(pstrWFIDrv, 0, sizeof(tstrWILC_WFIDrv));
6507 /*return driver handle to user*/
6508 *phWFIDrv = (WILC_WFIDrvHandle)pstrWFIDrv;
6509 /*save into globl handle*/
6511 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
6513 g_obtainingIP = false;
6516 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", pstrWFIDrv);
6517 /* /////////////////////////////////////// */
6518 if (clients_count == 0) {
6519 sema_init(&hSemHostIFthrdEnd, 0);
6520 sema_init(&hSemDeinitDrvHandle, 0);
6522 sema_init(&hSemHostIntDeinit, 1);
6525 sema_init(&(pstrWFIDrv->hSemTestKeyBlock), 0);
6526 sema_init(&(pstrWFIDrv->hSemTestDisconnectBlock), 0);
6527 sema_init(&(pstrWFIDrv->hSemGetRSSI), 0);
6528 sema_init(&(pstrWFIDrv->hSemGetLINKSPEED), 0);
6529 sema_init(&(pstrWFIDrv->hSemGetCHNL), 0);
6530 sema_init(&(pstrWFIDrv->hSemInactiveTime), 0);
6532 /* /////////////////////////////////////// */
6536 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
6538 if (clients_count == 0) {
6540 s32Error = WILC_MsgQueueCreate(&gMsgQHostIF, NULL);
6544 PRINT_ER("Failed to creat MQ\n");
6548 HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread");
6549 if (IS_ERR(HostIFthreadHandler)) {
6550 PRINT_ER("Failed to creat Thread\n");
6551 s32Error = WILC_FAIL;
6554 s32Error = WILC_TimerCreate(&(g_hPeriodicRSSI), GetPeriodicRSSI, NULL);
6556 PRINT_ER("Failed to creat Timer\n");
6559 WILC_TimerStart(&(g_hPeriodicRSSI), 5000, (void *)pstrWFIDrv, NULL);
6564 s32Error = WILC_TimerCreate(&(pstrWFIDrv->hScanTimer), TimerCB_Scan, NULL);
6566 PRINT_ER("Failed to creat Timer\n");
6570 s32Error = WILC_TimerCreate(&(pstrWFIDrv->hConnectTimer), TimerCB_Connect, NULL);
6572 PRINT_ER("Failed to creat Timer\n");
6578 /*Remain on channel timer*/
6579 s32Error = WILC_TimerCreate(&(pstrWFIDrv->hRemainOnChannel), ListenTimerCB, NULL);
6581 PRINT_ER("Failed to creat Remain-on-channel Timer\n");
6586 sema_init(&(pstrWFIDrv->gtOsCfgValuesSem), 1);
6587 down(&(pstrWFIDrv->gtOsCfgValuesSem));
6595 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
6596 /* gWFiDrvHandle->bPendingConnRequest = false; */
6598 /*Initialize CFG WIDS Defualt Values*/
6600 pstrWFIDrv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
6601 pstrWFIDrv->strCfgValues.scan_source = DEFAULT_SCAN;
6602 pstrWFIDrv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
6603 pstrWFIDrv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
6604 pstrWFIDrv->strCfgValues.curr_tx_rate = AUTORATE;
6609 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
6613 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",
6615 pstrWFIDrv->strCfgValues.site_survey_enabled, pstrWFIDrv->strCfgValues.scan_source,
6616 pstrWFIDrv->strCfgValues.active_scan_time, pstrWFIDrv->strCfgValues.passive_scan_time,
6617 pstrWFIDrv->strCfgValues.curr_tx_rate);
6620 up(&(pstrWFIDrv->gtOsCfgValuesSem));
6622 /*TODO Code to setup simulation to be removed later*/
6623 /*Intialize configurator module*/
6624 s32Error = CoreConfiguratorInit();
6626 PRINT_ER("Failed to initialize core configurator\n");
6631 /*Initialize Simulaor*/
6632 CoreConfigSimulatorInit();
6636 clients_count++; /* increase number of created entities */
6642 if (pstrWFIDrv != NULL)
6643 WILC_FREE(pstrWFIDrv);
6646 WILC_TimerDestroy(&(pstrWFIDrv->hRemainOnChannel), NULL);
6649 up(&(pstrWFIDrv->gtOsCfgValuesSem));
6650 WILC_TimerDestroy(&(pstrWFIDrv->hConnectTimer), NULL);
6652 WILC_TimerDestroy(&(pstrWFIDrv->hScanTimer), NULL);
6654 kthread_stop(HostIFthreadHandler);
6656 WILC_MsgQueueDestroy(&gMsgQHostIF, NULL);
6663 * @brief host_int_deinit
6664 * @details host interface initialization function
6665 * @param[in,out] handle to the wifi driver,
6668 * @date 8 March 2012
6672 s32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv)
6674 s32 s32Error = WILC_SUCCESS;
6675 tstrHostIFmsg strHostIFmsg;
6678 /*obtain driver handle*/
6679 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6680 /*if(u32Intialized == 0)
6682 * PRINT_ER("Host Interface is not initialized\n");
6688 if (pstrWFIDrv == NULL) {
6689 PRINT_ER("pstrWFIDrv = NULL\n");
6693 down(&hSemHostIntDeinit);
6695 terminated_handle = pstrWFIDrv;
6696 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
6699 /*Destroy all timers before acquiring hSemDeinitDrvHandle*/
6700 /*to guarantee handling all messages befor proceeding*/
6701 if (WILC_TimerDestroy(&(pstrWFIDrv->hScanTimer), NULL)) {
6702 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
6703 /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */
6706 if (WILC_TimerDestroy(&(pstrWFIDrv->hConnectTimer), NULL)) {
6707 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
6708 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6712 if (WILC_TimerDestroy(&(g_hPeriodicRSSI), NULL)) {
6713 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
6714 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6718 /*Destroy Remain-onchannel Timer*/
6719 WILC_TimerDestroy(&(pstrWFIDrv->hRemainOnChannel), NULL);
6722 host_int_set_wfi_drv_handler((u32)NULL);
6723 down(&hSemDeinitDrvHandle);
6726 /*Calling the CFG80211 scan done function with the abort flag set to true*/
6727 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
6728 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
6729 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
6731 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
6733 /*deinit configurator and simulator*/
6735 CoreConfigSimulatorDeInit();
6737 CoreConfiguratorDeInit();
6742 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
6744 gbScanWhileConnected = false;
6746 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6748 if (clients_count == 1) {
6749 if (WILC_TimerDestroy(&g_hPeriodicRSSI, NULL)) {
6750 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
6751 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6753 strHostIFmsg.u16MsgId = HOST_IF_MSG_EXIT;
6754 strHostIFmsg.drvHandler = hWFIDrv;
6757 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6758 if (s32Error != WILC_SUCCESS)
6759 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
6761 down(&hSemHostIFthrdEnd);
6765 WILC_MsgQueueDestroy(&gMsgQHostIF, NULL);
6769 down(&(pstrWFIDrv->gtOsCfgValuesSem));
6771 /*Setting the gloabl driver handler with NULL*/
6773 /* gWFiDrvHandle = NULL; */
6774 if (pstrWFIDrv != NULL) {
6775 WILC_FREE(pstrWFIDrv);
6776 /* pstrWFIDrv=NULL; */
6780 clients_count--; /* Decrease number of created entities */
6781 terminated_handle = NULL;
6782 up(&hSemHostIntDeinit);
6788 * @brief NetworkInfoReceived
6789 * @details function to to be called when network info packet is received
6790 * @param[in] pu8Buffer the received packet
6791 * @param[in] u32Length length of the received packet
6798 void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
6800 s32 s32Error = WILC_SUCCESS;
6801 tstrHostIFmsg strHostIFmsg;
6803 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
6805 drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6806 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
6811 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
6812 PRINT_ER("NetworkInfo received but driver not init[%p]\n", pstrWFIDrv);
6816 /* prepare the Asynchronous Network Info message */
6817 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6819 strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_NTWRK_INFO;
6820 strHostIFmsg.drvHandler = pstrWFIDrv;
6822 strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.u32Length = u32Length;
6823 strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.pu8Buffer = (u8 *)WILC_MALLOC(u32Length); /* will be deallocated by the receiving thread */
6824 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.pu8Buffer,
6825 pu8Buffer, u32Length);
6827 /* send the message */
6828 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6830 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
6837 * @brief GnrlAsyncInfoReceived
6838 * @details function to be called when general Asynchronous info packet is received
6839 * @param[in] pu8Buffer the received packet
6840 * @param[in] u32Length length of the received packet
6847 void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
6849 s32 s32Error = WILC_SUCCESS;
6850 tstrHostIFmsg strHostIFmsg;
6852 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
6855 down(&hSemHostIntDeinit);
6857 drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6858 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
6859 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
6862 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
6863 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
6865 up(&hSemHostIntDeinit);
6869 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL) {
6870 /* received mac status is not needed when there is no current Connect Request */
6871 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
6873 up(&hSemHostIntDeinit);
6877 /* prepare the General Asynchronous Info message */
6878 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6881 strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
6882 strHostIFmsg.drvHandler = pstrWFIDrv;
6885 strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.u32Length = u32Length;
6886 strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.pu8Buffer = (u8 *)WILC_MALLOC(u32Length); /* will be deallocated by the receiving thread */
6887 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.pu8Buffer,
6888 pu8Buffer, u32Length);
6890 /* send the message */
6891 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6893 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
6896 up(&hSemHostIntDeinit);
6901 * @brief host_int_ScanCompleteReceived
6902 * @details Setting scan complete received notifcation in message queue
6903 * @param[in] u8* pu8Buffer, u32 u32Length
6904 * @return Error code.
6909 void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
6911 s32 s32Error = WILC_SUCCESS;
6912 tstrHostIFmsg strHostIFmsg;
6914 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
6916 drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6917 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
6920 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", pstrWFIDrv);
6922 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle)
6925 /*if there is an ongoing scan request*/
6926 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
6927 /* prepare theScan Done message */
6928 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6930 strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
6931 strHostIFmsg.drvHandler = pstrWFIDrv;
6934 /* will be deallocated by the receiving thread */
6935 /*no need to send message body*/
6937 /*strHostIFmsg.uniHostIFmsgBody.strScanComplete.u32Length = u32Length;
6938 * strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer = (u8*)WILC_MALLOC(u32Length);
6939 * WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer,
6940 * pu8Buffer, u32Length); */
6942 /* send the message */
6943 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6945 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
6955 * @brief host_int_remain_on_channel
6957 * @param[in] Handle to wifi driver
6958 * Duration to remain on channel
6959 * Channel to remain on
6960 * Pointer to fn to be called on receive frames in listen state
6961 * Pointer to remain-on-channel expired fn
6963 * @return Error code.
6968 s32 host_int_remain_on_channel(WILC_WFIDrvHandle hWFIDrv, u32 u32SessionID, u32 u32duration, u16 chan, tWILCpfRemainOnChanExpired RemainOnChanExpired, tWILCpfRemainOnChanReady RemainOnChanReady, void *pvUserArg)
6970 s32 s32Error = WILC_SUCCESS;
6971 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6972 tstrHostIFmsg strHostIFmsg;
6974 if (pstrWFIDrv == NULL)
6975 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6977 /* prepare the remainonchan Message */
6978 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6980 /* prepare the WiphyParams Message */
6981 strHostIFmsg.u16MsgId = HOST_IF_MSG_REMAIN_ON_CHAN;
6982 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u16Channel = chan;
6983 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pRemainOnChanExpired = RemainOnChanExpired;
6984 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pRemainOnChanReady = RemainOnChanReady;
6985 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pVoid = pvUserArg;
6986 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32duration = u32duration;
6987 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
6988 strHostIFmsg.drvHandler = hWFIDrv;
6990 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6992 WILC_ERRORREPORT(s32Error, s32Error);
6993 WILC_CATCH(s32Error)
7002 * @brief host_int_ListenStateExpired
7004 * @param[in] Handle to wifi driver
7005 * Duration to remain on channel
7006 * Channel to remain on
7007 * Pointer to fn to be called on receive frames in listen state
7008 * Pointer to remain-on-channel expired fn
7010 * @return Error code.
7015 s32 host_int_ListenStateExpired(WILC_WFIDrvHandle hWFIDrv, u32 u32SessionID)
7017 s32 s32Error = WILC_SUCCESS;
7018 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7019 tstrHostIFmsg strHostIFmsg;
7021 if (pstrWFIDrv == NULL)
7022 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7024 /*Stopping remain-on-channel timer*/
7025 WILC_TimerStop(&(pstrWFIDrv->hRemainOnChannel), NULL);
7027 /* prepare the timer fire Message */
7028 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7029 strHostIFmsg.u16MsgId = HOST_IF_MSG_LISTEN_TIMER_FIRED;
7030 strHostIFmsg.drvHandler = hWFIDrv;
7031 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
7033 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7035 WILC_ERRORREPORT(s32Error, s32Error);
7036 WILC_CATCH(s32Error)
7044 * @brief host_int_frame_register
7046 * @param[in] Handle to wifi driver
7047 * @return Error code.
7051 s32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, u16 u16FrameType, bool bReg)
7053 s32 s32Error = WILC_SUCCESS;
7054 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7055 tstrHostIFmsg strHostIFmsg;
7057 if (pstrWFIDrv == NULL)
7058 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7060 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7062 /* prepare the WiphyParams Message */
7063 strHostIFmsg.u16MsgId = HOST_IF_MSG_REGISTER_FRAME;
7064 switch (u16FrameType) {
7066 PRINT_D(HOSTINF_DBG, "ACTION\n");
7067 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u8Regid = ACTION_FRM_IDX;
7071 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
7072 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u8Regid = PROBE_REQ_IDX;
7076 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
7079 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u16FrameType = u16FrameType;
7080 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.bReg = bReg;
7081 strHostIFmsg.drvHandler = hWFIDrv;
7083 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7085 WILC_ERRORREPORT(s32Error, s32Error);
7086 WILC_CATCH(s32Error)
7097 #ifdef WILC_AP_EXTERNAL_MLME
7099 * @brief host_int_add_beacon
7100 * @details Setting add beacon params in message queue
7101 * @param[in] WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
7102 * u32 u32DTIMPeriod,u32 u32HeadLen, u8* pu8Head,
7103 * u32 u32TailLen, u8* pu8Tail
7104 * @return Error code.
7109 s32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
7111 u32 u32HeadLen, u8 *pu8Head,
7112 u32 u32TailLen, u8 *pu8Tail)
7114 s32 s32Error = WILC_SUCCESS;
7115 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7116 tstrHostIFmsg strHostIFmsg;
7117 tstrHostIFSetBeacon *pstrSetBeaconParam = &strHostIFmsg.uniHostIFmsgBody.strHostIFSetBeacon;
7119 if (pstrWFIDrv == NULL)
7120 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7122 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7124 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
7127 /* prepare the WiphyParams Message */
7128 strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_BEACON;
7129 strHostIFmsg.drvHandler = hWFIDrv;
7130 pstrSetBeaconParam->u32Interval = u32Interval;
7131 pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
7132 pstrSetBeaconParam->u32HeadLen = u32HeadLen;
7133 pstrSetBeaconParam->pu8Head = (u8 *)WILC_MALLOC(u32HeadLen);
7134 if (pstrSetBeaconParam->pu8Head == NULL)
7135 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
7136 WILC_memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
7137 pstrSetBeaconParam->u32TailLen = u32TailLen;
7139 /* Bug 4599 : if tail length = 0 skip allocating & copying */
7140 if (u32TailLen > 0) {
7141 pstrSetBeaconParam->pu8Tail = (u8 *)WILC_MALLOC(u32TailLen);
7142 if (pstrSetBeaconParam->pu8Tail == NULL)
7143 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
7144 WILC_memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen);
7146 pstrSetBeaconParam->pu8Tail = NULL;
7149 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7151 WILC_ERRORREPORT(s32Error, s32Error);
7153 WILC_CATCH(s32Error)
7155 if (pstrSetBeaconParam->pu8Head != NULL)
7156 WILC_FREE(pstrSetBeaconParam->pu8Head);
7158 if (pstrSetBeaconParam->pu8Tail != NULL)
7159 WILC_FREE(pstrSetBeaconParam->pu8Tail);
7168 * @brief host_int_del_beacon
7169 * @details Setting add beacon params in message queue
7170 * @param[in] WILC_WFIDrvHandle hWFIDrv
7171 * @return Error code.
7176 s32 host_int_del_beacon(WILC_WFIDrvHandle hWFIDrv)
7178 s32 s32Error = WILC_SUCCESS;
7179 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7180 tstrHostIFmsg strHostIFmsg;
7182 if (pstrWFIDrv == NULL)
7183 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7185 /* prepare the WiphyParams Message */
7186 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_BEACON;
7187 strHostIFmsg.drvHandler = hWFIDrv;
7188 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
7190 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7191 WILC_ERRORCHECK(s32Error);
7193 WILC_CATCH(s32Error)
7201 * @brief host_int_add_station
7202 * @details Setting add station params in message queue
7203 * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7204 * @return Error code.
7209 s32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrStaParams)
7211 s32 s32Error = WILC_SUCCESS;
7212 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7213 tstrHostIFmsg strHostIFmsg;
7214 tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam;
7217 if (pstrWFIDrv == NULL)
7218 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7220 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7222 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
7225 /* prepare the WiphyParams Message */
7226 strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_STATION;
7227 strHostIFmsg.drvHandler = hWFIDrv;
7229 WILC_memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam));
7230 if (pstrAddStationMsg->u8NumRates > 0) {
7231 u8 *rates = WILC_MALLOC(pstrAddStationMsg->u8NumRates);
7233 WILC_NULLCHECK(s32Error, rates);
7235 WILC_memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
7236 pstrAddStationMsg->pu8Rates = rates;
7240 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7242 WILC_ERRORREPORT(s32Error, s32Error);
7244 WILC_CATCH(s32Error)
7251 * @brief host_int_del_station
7252 * @details Setting delete station params in message queue
7253 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr
7254 * @return Error code.
7259 s32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8MacAddr)
7261 s32 s32Error = WILC_SUCCESS;
7262 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7263 tstrHostIFmsg strHostIFmsg;
7264 tstrHostIFDelSta *pstrDelStationMsg = &strHostIFmsg.uniHostIFmsgBody.strDelStaParam;
7266 if (pstrWFIDrv == NULL)
7267 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7269 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7271 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
7275 /* prepare the WiphyParams Message */
7276 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_STATION;
7277 strHostIFmsg.drvHandler = hWFIDrv;
7279 /*BugID_4795: Handling situation of deleting all stations*/
7280 if (pu8MacAddr == NULL)
7281 WILC_memset(pstrDelStationMsg->au8MacAddr, 255, ETH_ALEN);
7283 WILC_memcpy(pstrDelStationMsg->au8MacAddr, pu8MacAddr, ETH_ALEN);
7285 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7287 WILC_ERRORREPORT(s32Error, s32Error);
7289 WILC_CATCH(s32Error)
7295 * @brief host_int_del_allstation
7296 * @details Setting del station params in message queue
7297 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]s
7298 * @return Error code.
7303 s32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN])
7305 s32 s32Error = WILC_SUCCESS;
7306 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7307 tstrHostIFmsg strHostIFmsg;
7308 tstrHostIFDelAllSta *pstrDelAllStationMsg = &strHostIFmsg.uniHostIFmsgBody.strHostIFDelAllSta;
7309 u8 au8Zero_Buff[ETH_ALEN] = {0};
7314 if (pstrWFIDrv == NULL)
7315 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7317 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7319 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
7321 /* prepare the WiphyParams Message */
7322 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_ALL_STA;
7323 strHostIFmsg.drvHandler = hWFIDrv;
7325 /* Handling situation of deauthenticing all associated stations*/
7326 for (i = 0; i < MAX_NUM_STA; i++) {
7327 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
7328 WILC_memcpy(pstrDelAllStationMsg->au8Sta_DelAllSta[i], pu8MacAddr[i], ETH_ALEN);
7329 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],
7330 pstrDelAllStationMsg->au8Sta_DelAllSta[i][5]);
7335 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
7339 pstrDelAllStationMsg->u8Num_AssocSta = u8AssocNumb;
7340 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7344 WILC_ERRORREPORT(s32Error, s32Error);
7346 WILC_CATCH(s32Error)
7350 down(&hWaitResponse);
7357 * @brief host_int_edit_station
7358 * @details Setting edit station params in message queue
7359 * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7360 * @return Error code.
7365 s32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrStaParams)
7367 s32 s32Error = WILC_SUCCESS;
7368 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7369 tstrHostIFmsg strHostIFmsg;
7370 tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam;
7372 if (pstrWFIDrv == NULL)
7373 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7375 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
7377 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7380 /* prepare the WiphyParams Message */
7381 strHostIFmsg.u16MsgId = HOST_IF_MSG_EDIT_STATION;
7382 strHostIFmsg.drvHandler = hWFIDrv;
7384 WILC_memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam));
7385 if (pstrAddStationMsg->u8NumRates > 0) {
7386 u8 *rates = WILC_MALLOC(pstrAddStationMsg->u8NumRates);
7388 WILC_NULLCHECK(s32Error, rates);
7389 WILC_memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
7390 pstrAddStationMsg->pu8Rates = rates;
7393 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7395 WILC_ERRORREPORT(s32Error, s32Error);
7396 WILC_CATCH(s32Error)
7401 #endif /*WILC_AP_EXTERNAL_MLME*/
7402 uint32_t wilc_get_chipid(uint8_t);
7404 s32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, bool bIsEnabled, u32 u32Timeout)
7406 s32 s32Error = WILC_SUCCESS;
7407 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7408 tstrHostIFmsg strHostIFmsg;
7409 tstrHostIfPowerMgmtParam *pstrPowerMgmtParam = &strHostIFmsg.uniHostIFmsgBody.strPowerMgmtparam;
7411 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
7413 if (pstrWFIDrv == NULL)
7414 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7416 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
7418 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7421 /* prepare the WiphyParams Message */
7422 strHostIFmsg.u16MsgId = HOST_IF_MSG_POWER_MGMT;
7423 strHostIFmsg.drvHandler = hWFIDrv;
7425 pstrPowerMgmtParam->bIsEnabled = bIsEnabled;
7426 pstrPowerMgmtParam->u32Timeout = u32Timeout;
7429 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7431 WILC_ERRORREPORT(s32Error, s32Error);
7432 WILC_CATCH(s32Error)
7438 s32 host_int_setup_multicast_filter(WILC_WFIDrvHandle hWFIDrv, bool bIsEnabled, u32 u32count)
7440 s32 s32Error = WILC_SUCCESS;
7442 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7443 tstrHostIFmsg strHostIFmsg;
7444 tstrHostIFSetMulti *pstrMulticastFilterParam = &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMulti;
7447 if (pstrWFIDrv == NULL)
7448 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7450 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
7452 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7455 /* prepare the WiphyParams Message */
7456 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_MULTICAST_FILTER;
7457 strHostIFmsg.drvHandler = hWFIDrv;
7459 pstrMulticastFilterParam->bIsEnabled = bIsEnabled;
7460 pstrMulticastFilterParam->u32count = u32count;
7462 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7464 WILC_ERRORREPORT(s32Error, s32Error);
7465 WILC_CATCH(s32Error)
7473 /*Bug4218: Parsing Join Param*/
7474 #ifdef WILC_PARSE_SCAN_IN_HOST
7476 /*Bug4218: Parsing Join Param*/
7478 * @brief host_int_ParseJoinBssParam
7479 * @details Parse Needed Join Parameters and save it in a new JoinBssParam entry
7480 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7485 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
7487 tstrJoinBssParam *pNewJoinBssParam = NULL;
7496 u8 pcipherTotalCount = 0;
7497 u8 authTotalCount = 0;
7500 pu8IEs = ptstrNetworkInfo->pu8IEs;
7501 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
7503 pNewJoinBssParam = WILC_MALLOC(sizeof(tstrJoinBssParam));
7504 if (pNewJoinBssParam != NULL) {
7505 WILC_memset(pNewJoinBssParam, 0, sizeof(tstrJoinBssParam));
7506 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
7507 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
7508 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
7509 WILC_memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
7511 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/
7512 WILC_memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
7513 pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen;
7514 WILC_memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
7515 WILC_memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
7516 /*for(i=0; i<pNewJoinBssParam->ssidLen;i++)
7517 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/
7519 /* parse supported rates: */
7520 while (index < u16IEsLen) {
7521 /* supportedRates IE */
7522 if (pu8IEs[index] == SUPP_RATES_IE) {
7523 /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */
7524 suppRatesNo = pu8IEs[index + 1];
7525 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
7526 index += 2; /* skipping ID and length bytes; */
7528 for (i = 0; i < suppRatesNo; i++) {
7529 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
7530 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */
7532 index += suppRatesNo;
7535 /* Ext SupportedRates IE */
7536 else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
7537 /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */
7538 /* checking if no of ext. supp and supp rates < max limit */
7539 extSuppRatesNo = pu8IEs[index + 1];
7540 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
7541 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
7543 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
7545 /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */
7546 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
7547 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
7548 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */
7550 index += extSuppRatesNo;
7554 else if (pu8IEs[index] == HT_CAPABILITY_IE) {
7555 /* if IE found set the flag */
7556 pNewJoinBssParam->ht_capable = true;
7557 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7558 /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */
7560 } else if ((pu8IEs[index] == WMM_IE) && /* WMM Element ID */
7561 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
7562 (pu8IEs[index + 4] == 0xF2) && /* OUI */
7563 (pu8IEs[index + 5] == 0x02) && /* OUI Type */
7564 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) && /* OUI Sub Type */
7565 (pu8IEs[index + 7] == 0x01)) {
7566 /* Presence of WMM Info/Param element indicates WMM capability */
7567 pNewJoinBssParam->wmm_cap = true;
7569 /* Check if Bit 7 is set indicating U-APSD capability */
7570 if (pu8IEs[index + 8] & (1 << 7))
7571 pNewJoinBssParam->uapsd_cap = true;
7572 index += pu8IEs[index + 1] + 2;
7576 else if ((pu8IEs[index] == P2P_IE) && /* P2P Element ID */
7577 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
7578 (pu8IEs[index + 4] == 0x9a) && /* OUI */
7579 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) { /* OUI Type */
7582 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
7583 pNewJoinBssParam->u8NoaEnbaled = 1;
7584 pNewJoinBssParam->u8Index = pu8IEs[index + 9];
7586 /* Check if Bit 7 is set indicating Opss capability */
7587 if (pu8IEs[index + 10] & (1 << 7)) {
7588 pNewJoinBssParam->u8OppEnable = 1;
7589 pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10];
7591 pNewJoinBssParam->u8OppEnable = 0;
7593 PRINT_D(GENERIC_DBG, "P2P Dump\n");
7594 for (i = 0; i < pu8IEs[index + 7]; i++)
7595 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
7597 pNewJoinBssParam->u8Count = pu8IEs[index + 11];
7598 u16P2P_count = index + 12;
7600 WILC_memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4);
7603 WILC_memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4);
7606 WILC_memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
7608 index += pu8IEs[index + 1] + 2;
7613 else if ((pu8IEs[index] == RSN_IE) ||
7614 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
7615 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
7616 (pu8IEs[index + 5] == 0x01))) {
7617 u16 rsnIndex = index;
7618 /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]);
7619 * for(i=0; i<pu8IEs[rsnIndex+1]; i++)
7621 * PRINT_D(HOSTINF_DBG,"%0x ",pu8IEs[rsnIndex+2+i]);
7623 if (pu8IEs[rsnIndex] == RSN_IE) {
7624 pNewJoinBssParam->mode_802_11i = 2;
7625 /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */
7626 } else { /* check if rsn was previously parsed */
7627 if (pNewJoinBssParam->mode_802_11i == 0)
7628 pNewJoinBssParam->mode_802_11i = 1;
7629 /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */
7632 rsnIndex += 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */
7633 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
7635 /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x\n",pNewJoinBssParam->rsn_grp_policy); */
7636 /* initialize policies with invalid values */
7638 jumpOffset = pu8IEs[rsnIndex] * 4; /* total no.of bytes of pcipher field (count*4) */
7640 /*parsing pairwise cipher*/
7642 /* saving 3 pcipher max. */
7643 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7644 rsnIndex += 2; /* jump 2 bytes of pcipher count */
7646 /* PRINT_D(HOSTINF_DBG,"\npcipher:%d\n",pcipherCount); */
7647 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
7648 /* each count corresponds to 4 bytes, only last byte is saved */
7649 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7650 /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */
7652 pcipherTotalCount += pcipherCount;
7653 rsnIndex += jumpOffset;
7655 jumpOffset = pu8IEs[rsnIndex] * 4;
7657 /*parsing AKM suite (auth_policy)*/
7658 /* saving 3 auth policies max. */
7659 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7660 rsnIndex += 2; /* jump 2 bytes of pcipher count */
7662 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
7663 /* each count corresponds to 4 bytes, only last byte is saved */
7664 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7666 authTotalCount += authCount;
7667 rsnIndex += jumpOffset;
7668 /*pasring rsn cap. only if rsn IE*/
7669 if (pu8IEs[index] == RSN_IE) {
7670 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
7671 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
7674 pNewJoinBssParam->rsn_found = true;
7675 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7678 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7685 return (void *)pNewJoinBssParam;
7689 void host_int_freeJoinParams(void *pJoinParams)
7691 if ((tstrJoinBssParam *)pJoinParams != NULL)
7692 WILC_FREE((tstrJoinBssParam *)pJoinParams);
7694 PRINT_ER("Unable to FREE null pointer\n");
7696 #endif /*WILC_PARSE_SCAN_IN_HOST*/
7700 * @brief host_int_addBASession
7701 * @details Open a block Ack session with the given parameters
7702 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7704 * @author anoureldin
7708 static int host_int_addBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID, short int BufferSize,
7709 short int SessionTimeout, void *drvHandler)
7711 s32 s32Error = WILC_SUCCESS;
7712 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7713 tstrHostIFmsg strHostIFmsg;
7714 tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
7716 if (pstrWFIDrv == NULL)
7717 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7719 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7721 /* prepare the WiphyParams Message */
7722 strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_BA_SESSION;
7724 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7725 pBASessionInfo->u8Ted = TID;
7726 pBASessionInfo->u16BufferSize = BufferSize;
7727 pBASessionInfo->u16SessionTimeout = SessionTimeout;
7728 strHostIFmsg.drvHandler = hWFIDrv;
7730 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7732 WILC_ERRORREPORT(s32Error, s32Error);
7733 WILC_CATCH(s32Error)
7742 s32 host_int_delBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID)
7744 s32 s32Error = WILC_SUCCESS;
7745 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7746 tstrHostIFmsg strHostIFmsg;
7747 tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
7749 if (pstrWFIDrv == NULL)
7750 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7752 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7754 /* prepare the WiphyParams Message */
7755 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_BA_SESSION;
7757 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7758 pBASessionInfo->u8Ted = TID;
7759 strHostIFmsg.drvHandler = hWFIDrv;
7761 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7763 WILC_ERRORREPORT(s32Error, s32Error);
7764 WILC_CATCH(s32Error)
7770 down(&hWaitResponse);
7775 s32 host_int_del_All_Rx_BASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID)
7777 s32 s32Error = WILC_SUCCESS;
7778 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7779 tstrHostIFmsg strHostIFmsg;
7780 tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
7782 if (pstrWFIDrv == NULL)
7783 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7785 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7787 /* prepare the WiphyParams Message */
7788 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
7790 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7791 pBASessionInfo->u8Ted = TID;
7792 strHostIFmsg.drvHandler = hWFIDrv;
7794 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7796 WILC_ERRORREPORT(s32Error, s32Error);
7797 WILC_CATCH(s32Error)
7803 down(&hWaitResponse);
7809 * @brief host_int_setup_ipaddress
7810 * @details setup IP in firmware
7811 * @param[in] Handle to wifi driver
7812 * @return Error code.
7813 * @author Abdelrahman Sobhy
7816 s32 host_int_setup_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *u16ipadd, u8 idx)
7818 s32 s32Error = WILC_SUCCESS;
7819 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7820 tstrHostIFmsg strHostIFmsg;
7822 /* TODO: Enable This feature on softap firmware */
7825 if (pstrWFIDrv == NULL)
7826 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7828 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7830 /* prepare the WiphyParams Message */
7831 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_IPADDRESS;
7833 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr = u16ipadd;
7834 strHostIFmsg.drvHandler = hWFIDrv;
7835 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx = idx;
7837 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7839 WILC_ERRORREPORT(s32Error, s32Error);
7840 WILC_CATCH(s32Error)
7851 * @brief host_int_get_ipaddress
7852 * @details Get IP from firmware
7853 * @param[in] Handle to wifi driver
7854 * @return Error code.
7855 * @author Abdelrahman Sobhy
7858 s32 host_int_get_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *u16ipadd, u8 idx)
7860 s32 s32Error = WILC_SUCCESS;
7861 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7862 tstrHostIFmsg strHostIFmsg;
7864 if (pstrWFIDrv == NULL)
7865 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7867 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7869 /* prepare the WiphyParams Message */
7870 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_IPADDRESS;
7872 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr = u16ipadd;
7873 strHostIFmsg.drvHandler = hWFIDrv;
7874 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx = idx;
7876 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7878 WILC_ERRORREPORT(s32Error, s32Error);
7879 WILC_CATCH(s32Error)