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);
668 PRINT_ER("Failed to set driver handler\n");
669 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
680 * @brief Handle_SetWfiAPDrvHandler
681 * @details Sending config packet to firmware to set driver handler
682 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
683 * @return Error code.
688 static s32 Handle_SetOperationMode(void *drvHandler, tstrHostIfSetOperationMode *pstrHostIfSetOperationMode)
691 s32 s32Error = WILC_SUCCESS;
693 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
696 /*prepare configuration packet*/
697 strWID.u16WIDid = (u16)WID_SET_OPERATION_MODE;
698 strWID.enuWIDtype = WID_INT;
699 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetOperationMode->u32Mode);
700 strWID.s32ValueSize = sizeof(u32);
703 PRINT_INFO(HOSTINF_DBG, "pstrWFIDrv= %p \n", pstrWFIDrv);
705 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
708 if ((pstrHostIfSetOperationMode->u32Mode) == (u32)NULL) {
709 up(&hSemDeinitDrvHandle);
714 PRINT_ER("Failed to set driver handler\n");
715 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
726 * @brief host_int_set_IPAddress
727 * @details Setting IP address params in message queue
728 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
729 * @return Error code.
734 s32 Handle_set_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx)
737 s32 s32Error = WILC_SUCCESS;
739 char firmwareIPAddress[4] = {0};
740 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
742 if (pu8IPAddr[0] < 192)
745 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %d.%d.%d.%d \n", idx, pu8IPAddr[0], pu8IPAddr[1], pu8IPAddr[2], pu8IPAddr[3]);
747 WILC_memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN);
749 /*prepare configuration packet*/
750 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
751 strWID.enuWIDtype = WID_STR;
752 strWID.ps8WidVal = (u8 *)pu8IPAddr;
753 strWID.s32ValueSize = IP_ALEN;
755 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
759 host_int_get_ipaddress((WILC_WFIDrvHandle)drvHandler, firmwareIPAddress, idx);
762 PRINT_D(HOSTINF_DBG, "Failed to set IP address\n");
763 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
765 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
778 * @brief Handle_get_IPAddress
779 * @details Setting IP address params in message queue
780 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
781 * @return Error code.
786 s32 Handle_get_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx)
789 s32 s32Error = WILC_SUCCESS;
791 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
793 /*prepare configuration packet*/
794 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
795 strWID.enuWIDtype = WID_STR;
796 strWID.ps8WidVal = (u8 *)WILC_MALLOC(IP_ALEN);
797 strWID.s32ValueSize = IP_ALEN;
799 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
801 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]));
803 WILC_memcpy(gs8GetIP[idx], strWID.ps8WidVal, IP_ALEN);
805 /*get the value by searching the local copy*/
806 WILC_FREE(strWID.ps8WidVal);
808 if (WILC_memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0)
809 host_int_setup_ipaddress((WILC_WFIDrvHandle)pstrWFIDrv, gs8SetIP[idx], idx);
811 if (s32Error != WILC_SUCCESS) {
812 PRINT_ER("Failed to get IP address\n");
813 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
815 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d \n", idx);
816 PRINT_INFO(HOSTINF_DBG, "%d.%d.%d.%d\n", gs8GetIP[idx][0], gs8GetIP[idx][1], gs8GetIP[idx][2], gs8GetIP[idx][3]);
817 PRINT_INFO(HOSTINF_DBG, "\n");
831 * @brief Handle_SetMacAddress
832 * @details Setting mac address
833 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
834 * @return Error code.
835 * @author Amr Abdel-Moghny
836 * @date November 2013
839 static s32 Handle_SetMacAddress(void *drvHandler, tstrHostIfSetMacAddress *pstrHostIfSetMacAddress)
842 s32 s32Error = WILC_SUCCESS;
844 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
845 u8 *mac_buf = (u8 *)WILC_MALLOC(ETH_ALEN);
846 if (mac_buf == NULL) {
847 PRINT_ER("No buffer to send mac address\n");
850 WILC_memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
852 /*prepare configuration packet*/
853 strWID.u16WIDid = (u16)WID_MAC_ADDR;
854 strWID.enuWIDtype = WID_STR;
855 strWID.ps8WidVal = mac_buf;
856 strWID.s32ValueSize = ETH_ALEN;
857 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]);
859 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
861 PRINT_ER("Failed to set mac address\n");
862 WILC_ERRORREPORT(s32Error, WILC_FAIL);
876 * @brief Handle_GetMacAddress
877 * @details Getting mac address
878 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
879 * @return Error code.
880 * @author Amr Abdel-Moghny
884 static s32 Handle_GetMacAddress(void *drvHandler, tstrHostIfGetMacAddress *pstrHostIfGetMacAddress)
887 s32 s32Error = WILC_SUCCESS;
890 /*prepare configuration packet*/
891 strWID.u16WIDid = (u16)WID_MAC_ADDR;
892 strWID.enuWIDtype = WID_STR;
893 strWID.ps8WidVal = pstrHostIfGetMacAddress->u8MacAddress;
894 strWID.s32ValueSize = ETH_ALEN;
897 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, false, (u32)drvHandler);
899 PRINT_ER("Failed to get mac address\n");
900 WILC_ERRORREPORT(s32Error, WILC_FAIL);
913 * @brief Handle_CfgParam
914 * @details Sending config packet to firmware to set CFG params
915 * @param[in] tstrHostIFCfgParamAttr* strHostIFCfgParamAttr
916 * @return Error code.
921 static s32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *strHostIFCfgParamAttr)
923 s32 s32Error = WILC_SUCCESS;
924 tstrWID strWIDList[32];
926 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
929 down(&(pstrWFIDrv->gtOsCfgValuesSem));
932 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
934 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BSS_TYPE) {
935 /*----------------------------------------------------------*/
936 /*Input Value: INFRASTRUCTURE = 1, */
937 /* INDEPENDENT= 2, */
939 /*----------------------------------------------------------*/
940 /* validate input then copy>> need to check value 4 and 5 */
941 if (strHostIFCfgParamAttr->pstrCfgParamVal.bss_type < 6) {
942 strWIDList[u8WidCnt].u16WIDid = WID_BSS_TYPE;
943 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
944 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
945 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
946 pstrWFIDrv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
948 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
952 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTH_TYPE) {
953 /*------------------------------------------------------*/
954 /*Input Values: OPEN_SYSTEM = 0, */
955 /* SHARED_KEY = 1, */
957 /*------------------------------------------------------*/
958 /*validate Possible values*/
959 if ((strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 1 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 2 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 5) {
960 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TYPE;
961 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
962 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
963 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
964 pstrWFIDrv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
966 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
970 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTHEN_TIMEOUT) {
971 /* range is 1 to 65535. */
972 if (strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout < 65536) {
973 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TIMEOUT;
974 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
975 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
976 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
977 pstrWFIDrv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
979 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
983 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & POWER_MANAGEMENT) {
984 /*-----------------------------------------------------------*/
985 /*Input Values: NO_POWERSAVE = 0, */
986 /* MIN_FAST_PS = 1, */
987 /* MAX_FAST_PS = 2, */
988 /* MIN_PSPOLL_PS = 3, */
989 /* MAX_PSPOLL_PS = 4 */
990 /*----------------------------------------------------------*/
991 if (strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode < 5) {
992 strWIDList[u8WidCnt].u16WIDid = WID_POWER_MANAGEMENT;
993 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
994 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
995 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
996 pstrWFIDrv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
998 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1002 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_SHORT) {
1003 /* range from 1 to 256 */
1004 if ((strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit < 256)) {
1005 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_RETRY_LIMIT;
1006 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
1007 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1008 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1009 pstrWFIDrv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
1011 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1015 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_LONG) {
1016 /* range from 1 to 256 */
1017 if ((strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit < 256)) {
1018 strWIDList[u8WidCnt].u16WIDid = WID_LONG_RETRY_LIMIT;
1019 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
1021 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1022 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1023 pstrWFIDrv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
1025 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1029 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & FRAG_THRESHOLD) {
1031 if (strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold < 7937) {
1032 strWIDList[u8WidCnt].u16WIDid = WID_FRAG_THRESHOLD;
1033 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
1034 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1035 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1036 pstrWFIDrv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
1038 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1042 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RTS_THRESHOLD) {
1043 /* range 256 to 65535 */
1044 if (strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold < 65536) {
1045 strWIDList[u8WidCnt].u16WIDid = WID_RTS_THRESHOLD;
1046 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
1047 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1048 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1049 pstrWFIDrv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
1051 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1055 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PREAMBLE) {
1056 /*-----------------------------------------------------*/
1057 /*Input Values: Short= 0, */
1060 /*------------------------------------------------------*/
1061 if (strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type < 3) {
1062 strWIDList[u8WidCnt].u16WIDid = WID_PREAMBLE;
1063 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
1064 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1065 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1066 pstrWFIDrv->strCfgValues.preamble_type = strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
1068 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1072 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SHORT_SLOT_ALLOWED) {
1073 if (strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed < 2) {
1074 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_SLOT_ALLOWED;
1075 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
1076 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1077 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1078 pstrWFIDrv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
1080 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1084 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & TXOP_PROT_DISABLE) {
1085 /*Description: used to Disable RTS-CTS protection for TXOP burst*/
1086 /*transmission when the acknowledgement policy is No-Ack or Block-Ack */
1087 /* this information is useful for external supplicant */
1088 /*Input Values: 1 for enable and 0 for disable. */
1089 if (strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled < 2) {
1090 strWIDList[u8WidCnt].u16WIDid = WID_11N_TXOP_PROT_DISABLE;
1091 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
1092 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1093 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1094 pstrWFIDrv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
1096 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1100 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BEACON_INTERVAL) {
1101 /* range is 1 to 65535. */
1102 if (strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval < 65536) {
1103 strWIDList[u8WidCnt].u16WIDid = WID_BEACON_INTERVAL;
1104 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
1105 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1106 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1107 pstrWFIDrv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
1109 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1113 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & DTIM_PERIOD) {
1114 /* range is 1 to 255. */
1115 if (strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period < 256) {
1116 strWIDList[u8WidCnt].u16WIDid = WID_DTIM_PERIOD;
1117 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
1118 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1119 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1120 pstrWFIDrv->strCfgValues.dtim_period = strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
1122 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1126 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY) {
1127 /*----------------------------------------------------------------------*/
1128 /*Input Values: SITE_SURVEY_1CH = 0, i.e.: currently set channel */
1129 /* SITE_SURVEY_ALL_CH = 1, */
1130 /* SITE_SURVEY_OFF = 2 */
1131 /*----------------------------------------------------------------------*/
1132 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled < 3) {
1133 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY;
1134 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
1135 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1136 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1137 pstrWFIDrv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
1139 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1143 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY_SCAN_TIME) {
1144 /* range is 1 to 65535. */
1145 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time < 65536) {
1146 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY_SCAN_TIME;
1147 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
1148 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1149 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1150 pstrWFIDrv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
1152 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1156 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & ACTIVE_SCANTIME) {
1157 /* range is 1 to 65535. */
1158 if (strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time < 65536) {
1159 strWIDList[u8WidCnt].u16WIDid = WID_ACTIVE_SCAN_TIME;
1160 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
1161 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1162 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1163 pstrWFIDrv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
1165 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1169 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PASSIVE_SCANTIME) {
1170 /* range is 1 to 65535. */
1171 if (strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time < 65536) {
1172 strWIDList[u8WidCnt].u16WIDid = WID_PASSIVE_SCAN_TIME;
1173 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
1174 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1175 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1176 pstrWFIDrv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
1178 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1182 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & CURRENT_TX_RATE) {
1183 CURRENT_TX_RATE_T curr_tx_rate = strHostIFCfgParamAttr->pstrCfgParamVal.curr_tx_rate;
1184 /*----------------------------------------------------------------------*/
1185 /*Rates: 1 2 5.5 11 6 9 12 18 24 36 48 54 Auto */
1186 /*InputValues: 1 2 3 4 5 6 7 8 9 10 11 12 0 */
1187 /*----------------------------------------------------------------------*/
1189 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
1190 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
1191 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
1192 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
1193 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
1194 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
1195 strWIDList[u8WidCnt].u16WIDid = WID_CURRENT_TX_RATE;
1196 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&curr_tx_rate;
1197 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1198 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1199 pstrWFIDrv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
1201 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1205 s32Error = SendConfigPkt(SET_CFG, strWIDList, u8WidCnt, false, (u32)pstrWFIDrv);
1208 PRINT_ER("Error in setting CFG params\n");
1211 WILC_CATCH(s32Error)
1214 up(&(pstrWFIDrv->gtOsCfgValuesSem));
1220 * @brief Handle_wait_msg_q_empty
1221 * @details this should be the last msg and then the msg Q becomes idle
1222 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1223 * @return Error code.
1228 static s32 Handle_wait_msg_q_empty(void)
1230 s32 s32Error = WILC_SUCCESS;
1231 g_wilc_initialized = 0;
1237 * @brief Handle_Scan
1238 * @details Sending config packet to firmware to set the scan params
1239 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1240 * @return Error code.
1245 static s32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr *pstrHostIFscanAttr)
1247 s32 s32Error = WILC_SUCCESS;
1248 tstrWID strWIDList[5];
1249 u32 u32WidsCount = 0;
1253 u8 *pu8HdnNtwrksWidVal = NULL;
1254 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
1256 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1257 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state \n", pstrWFIDrv->enuHostIFstate);
1259 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->pfScanResult;
1260 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->pvUserArg;
1265 if ((pstrWFIDrv->enuHostIFstate >= HOST_IF_SCANNING) && (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTED)) {
1266 /* here we either in HOST_IF_SCANNING, HOST_IF_WAITING_CONN_REQ or HOST_IF_WAITING_CONN_RESP */
1267 PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", pstrWFIDrv->enuHostIFstate);
1268 WILC_ERRORREPORT(s32Error, WILC_BUSY);
1271 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
1272 if (g_obtainingIP || connecting) {
1273 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
1274 WILC_ERRORREPORT(s32Error, WILC_BUSY);
1278 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1281 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount = 0;
1284 strWIDList[u32WidsCount].u16WIDid = (u16)WID_SSID_PROBE_REQ;
1285 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1287 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) {
1288 valuesize += ((pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
1290 pu8HdnNtwrksWidVal = WILC_MALLOC(valuesize + 1);
1291 strWIDList[u32WidsCount].ps8WidVal = pu8HdnNtwrksWidVal;
1292 if (strWIDList[u32WidsCount].ps8WidVal != NULL) {
1293 pu8Buffer = strWIDList[u32WidsCount].ps8WidVal;
1295 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum;
1297 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum);
1299 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) {
1300 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1301 WILC_memcpy(pu8Buffer, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen);
1302 pu8Buffer += pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1307 strWIDList[u32WidsCount].s32ValueSize = (s32)(valuesize + 1);
1311 /*filling cfg param array*/
1313 /* if((pstrHostIFscanAttr->pu8IEs != NULL) && (pstrHostIFscanAttr->IEsLen != 0)) */
1315 /* IEs to be inserted in Probe Request */
1316 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_PROBE;
1317 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1318 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8IEs;
1319 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->IEsLen;
1324 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_TYPE;
1325 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1326 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1327 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanType));
1330 /*list of channels to be scanned*/
1331 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_CHANNEL_LIST;
1332 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1334 /* Bug 4648: Convert channel numbers to start from 0 not 1. */
1335 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL && pstrHostIFscanAttr->u8ChnlListLen > 0) {
1338 for (i = 0; i < pstrHostIFscanAttr->u8ChnlListLen; i++) {
1339 if (pstrHostIFscanAttr->pu8ChnlFreqList[i] > 0) {
1340 pstrHostIFscanAttr->pu8ChnlFreqList[i] = pstrHostIFscanAttr->pu8ChnlFreqList[i] - 1;
1345 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8ChnlFreqList;
1346 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->u8ChnlListLen;
1350 strWIDList[u32WidsCount].u16WIDid = WID_START_SCAN_REQ;
1351 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1352 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1353 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanSource));
1356 /*keep the state as is , no need to change it*/
1357 /* gWFiDrvHandle->enuHostIFstate = HOST_IF_SCANNING; */
1359 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
1360 gbScanWhileConnected = true;
1361 } else if (pstrWFIDrv->enuHostIFstate == HOST_IF_IDLE) {
1362 gbScanWhileConnected = false;
1365 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, (u32)pstrWFIDrv);
1368 PRINT_ER("Failed to send scan paramters config packet\n");
1369 WILC_ERRORREPORT(s32Error, s32Error);
1371 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
1374 WILC_CATCH(s32Error)
1376 WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL);
1377 /*if there is an ongoing scan request*/
1378 Handle_ScanDone(drvHandler, SCAN_EVENT_ABORTED);
1381 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1382 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
1383 WILC_FREE(pstrHostIFscanAttr->pu8ChnlFreqList);
1384 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1387 /* Deallocate pstrHostIFscanAttr->pu8IEs which was previously allocated by the sending thread */
1388 if (pstrHostIFscanAttr->pu8IEs != NULL) {
1389 WILC_FREE(pstrHostIFscanAttr->pu8IEs);
1390 pstrHostIFscanAttr->pu8IEs = NULL;
1392 if (pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo != NULL) {
1393 WILC_FREE(pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo);
1394 pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo = NULL;
1397 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1398 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
1399 WILC_FREE(pstrHostIFscanAttr->pu8ChnlFreqList);
1400 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1403 if (pu8HdnNtwrksWidVal != NULL) {
1404 WILC_FREE(pu8HdnNtwrksWidVal);
1411 * @brief Handle_ScanDone
1412 * @details Call scan notification callback function
1414 * @return Error code.
1419 static s32 Handle_ScanDone(void *drvHandler, tenuScanEvent enuEvent)
1421 s32 s32Error = WILC_SUCCESS;
1423 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
1426 u8 u8abort_running_scan;
1430 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
1433 /*Ask FW to abort the running scan, if any*/
1434 if (enuEvent == SCAN_EVENT_ABORTED) {
1435 PRINT_D(GENERIC_DBG, "Abort running scan\n");
1436 u8abort_running_scan = 1;
1437 strWID.u16WIDid = (u16)WID_ABORT_RUNNING_SCAN;
1438 strWID.enuWIDtype = WID_CHAR;
1439 strWID.ps8WidVal = (s8 *)&u8abort_running_scan;
1440 strWID.s32ValueSize = sizeof(char);
1443 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
1444 if (s32Error != WILC_SUCCESS) {
1445 PRINT_ER("Failed to set abort running scan\n");
1446 WILC_ERRORREPORT(s32Error, WILC_FAIL);
1448 WILC_CATCH(s32Error)
1453 if (pstrWFIDrv == NULL) {
1454 PRINT_ER("Driver handler is NULL\n");
1458 /*if there is an ongoing scan request*/
1459 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
1460 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
1461 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
1462 /*delete current scan request*/
1463 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
1470 * @brief Handle_Connect
1471 * @details Sending config packet to firmware to starting connection
1472 * @param[in] tstrHostIFconnectAttr* pstrHostIFconnectAttr
1473 * @return Error code.
1478 u8 u8ConnectedSSID[6] = {0};
1479 static s32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrHostIFconnectAttr)
1481 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
1482 s32 s32Error = WILC_SUCCESS;
1483 tstrWID strWIDList[8];
1484 u32 u32WidsCount = 0, dummyval = 0;
1485 /* char passphrase[] = "12345678"; */
1486 #ifndef CONNECT_DIRECT
1487 s32 s32Err = WILC_SUCCESS;
1489 u8 u8bssDscListIndex;
1490 wid_site_survey_reslts_s *pstrSurveyResults = NULL;
1492 u8 *pu8CurrByte = NULL;
1493 /*Bug4218: Parsing Join Param*/
1494 #ifdef WILC_PARSE_SCAN_IN_HOST
1495 tstrJoinBssParam *ptstrJoinBssParam;
1496 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1500 PRINT_D(GENERIC_DBG, "Handling connect request\n");
1502 #ifndef CONNECT_DIRECT
1503 WILC_memset(gapu8RcvdSurveyResults[0], 0, MAX_SURVEY_RESULT_FRAG_SIZE);
1504 WILC_memset(gapu8RcvdSurveyResults[1], 0, MAX_SURVEY_RESULT_FRAG_SIZE);
1507 PRINT_D(HOSTINF_DBG, "Getting site survey results\n");
1508 s32Err = host_int_get_site_survey_results((WILC_WFIDrvHandle)pstrWFIDrv,
1509 gapu8RcvdSurveyResults,
1510 MAX_SURVEY_RESULT_FRAG_SIZE);
1512 PRINT_ER("Failed to get site survey results\n");
1513 WILC_ERRORREPORT(s32Error, WILC_FAIL);
1516 s32Err = ParseSurveyResults(gapu8RcvdSurveyResults, &pstrSurveyResults,
1517 &pstrWFIDrv->u32SurveyResultsCount);
1520 if (s32Err == WILC_SUCCESS) {
1521 /* use the parsed info in pstrSurveyResults, then deallocate it */
1522 PRINT_D(HOSTINF_DBG, "Copying site survey results in global structure, then deallocate\n");
1523 for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) {
1524 WILC_memcpy(&pstrWFIDrv->astrSurveyResults[i], &pstrSurveyResults[i],
1525 sizeof(wid_site_survey_reslts_s));
1528 DeallocateSurveyResults(pstrSurveyResults);
1530 WILC_ERRORREPORT(s32Error, WILC_FAIL);
1531 PRINT_ER("ParseSurveyResults() Error(%d) \n", s32Err);
1535 for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) {
1536 if (WILC_memcmp(pstrWFIDrv->astrSurveyResults[i].SSID,
1537 pstrHostIFconnectAttr->pu8ssid,
1538 pstrHostIFconnectAttr->ssidLen) == 0) {
1539 PRINT_INFO(HOSTINF_DBG, "Network with required SSID is found %s\n", pstrHostIFconnectAttr->pu8ssid);
1540 if (pstrHostIFconnectAttr->pu8bssid == NULL) {
1541 /* BSSID is not passed from the user, so decision of matching
1542 * is done by SSID only */
1543 PRINT_INFO(HOSTINF_DBG, "BSSID is not passed from the user\n");
1546 /* BSSID is also passed from the user, so decision of matching
1547 * should consider also this passed BSSID */
1549 if (WILC_memcmp(pstrWFIDrv->astrSurveyResults[i].BSSID,
1550 pstrHostIFconnectAttr->pu8bssid,
1552 PRINT_INFO(HOSTINF_DBG, "BSSID is passed from the user and matched\n");
1559 if (i < pstrWFIDrv->u32SurveyResultsCount) {
1560 u8bssDscListIndex = i;
1562 PRINT_INFO(HOSTINF_DBG, "Connecting to network of Bss Idx %d and SSID %s and channel %d \n",
1563 u8bssDscListIndex, pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].SSID,
1564 pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].Channel);
1566 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1568 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1569 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = (u8 *)WILC_MALLOC(6);
1570 WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
1573 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1574 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1575 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->ssidLen + 1);
1576 WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
1577 pstrHostIFconnectAttr->ssidLen);
1578 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1581 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1582 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1583 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->IEsLen);
1584 WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
1585 pstrHostIFconnectAttr->IEsLen);
1588 pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1589 pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1590 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1591 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1594 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1595 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1597 /* IEs to be inserted in Association Request */
1598 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1599 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1600 strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1601 strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1604 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
1605 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1606 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1607 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
1610 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1612 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
1613 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1614 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1615 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1618 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1620 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
1621 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1622 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
1623 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
1627 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ;
1628 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1629 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1630 strWIDList[u32WidsCount].ps8WidVal = (s8 *)&u8bssDscListIndex;
1634 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1635 * firmware at chip reset when processing the WIDs of the Connect Request.
1636 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1637 /* ////////////////////// */
1638 gu32WidConnRstHack = 0;
1639 /* ////////////////////// */
1642 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, (u32)pstrWFIDrv);
1644 PRINT_ER("Handle_Connect()] failed to send config packet\n");
1645 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
1647 pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1651 PRINT_ER("Required BSSID not found\n");
1652 WILC_ERRORREPORT(s32Error, WILC_NOT_FOUND);
1657 /* if we try to connect to an already connected AP then discard the request */
1659 if (WILC_memcmp(pstrHostIFconnectAttr->pu8bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
1661 s32Error = WILC_SUCCESS;
1662 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1666 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1668 /*Bug4218: Parsing Join Param*/
1669 #ifdef WILC_PARSE_SCAN_IN_HOST
1670 ptstrJoinBssParam = (tstrJoinBssParam *)pstrHostIFconnectAttr->pJoinParams;
1671 if (ptstrJoinBssParam == NULL) {
1672 PRINT_ER("Required BSSID not found\n");
1673 WILC_ERRORREPORT(s32Error, WILC_NOT_FOUND);
1675 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1677 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1678 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = (u8 *)WILC_MALLOC(6);
1679 WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
1682 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1683 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1684 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->ssidLen + 1);
1685 WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
1686 pstrHostIFconnectAttr->ssidLen);
1687 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1690 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1691 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1692 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->IEsLen);
1693 WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
1694 pstrHostIFconnectAttr->IEsLen);
1697 pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1698 pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1699 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1700 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1702 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
1703 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
1704 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
1705 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
1708 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
1709 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
1710 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
1711 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
1714 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
1715 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
1716 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
1717 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
1720 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1721 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1723 /* IEs to be inserted in Association Request */
1724 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1725 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1726 strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1727 strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1731 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1733 gu32FlushedInfoElemAsocSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1734 gu8FlushedInfoElemAsoc = WILC_MALLOC(gu32FlushedInfoElemAsocSize);
1735 memcpy(gu8FlushedInfoElemAsoc, pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
1736 gu32FlushedInfoElemAsocSize);
1739 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
1740 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1741 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1742 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
1746 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
1747 gu8Flushed11iMode = pstrWFIDrv->strWILC_UsrConnReq.u8security;
1749 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1752 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
1753 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1754 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1755 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1759 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
1760 gu8FlushedAuthType = (u8)pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type;
1762 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1764 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
1765 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1766 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
1767 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
1771 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
1772 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->u8channel);
1775 #ifndef WILC_PARSE_SCAN_IN_HOST
1776 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
1777 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1778 strWIDList[u32WidsCount].s32ValueSize = MAX_SSID_LEN + 7;
1779 strWIDList[u32WidsCount].ps8WidVal = WILC_MALLOC(strWIDList[u32WidsCount].s32ValueSize);
1781 if (strWIDList[u32WidsCount].ps8WidVal == NULL) {
1782 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
1785 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1787 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1788 WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
1789 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1791 pu8CurrByte += MAX_SSID_LEN;
1792 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1793 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1795 PRINT_ER("Channel out of range\n");
1796 *(pu8CurrByte++) = 0xFF;
1798 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1799 WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
1803 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1804 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1808 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
1809 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1811 /*Sending NoA attributes during connection*/
1812 strWIDList[u32WidsCount].s32ValueSize = 112; /* 79; */
1813 strWIDList[u32WidsCount].ps8WidVal = WILC_MALLOC(strWIDList[u32WidsCount].s32ValueSize);
1816 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1817 gu32FlushedJoinReqSize = strWIDList[u32WidsCount].s32ValueSize;
1818 gu8FlushedJoinReq = WILC_MALLOC(gu32FlushedJoinReqSize);
1820 if (strWIDList[u32WidsCount].ps8WidVal == NULL) {
1821 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
1824 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1827 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1828 WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
1829 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1831 pu8CurrByte += MAX_SSID_LEN;
1834 *(pu8CurrByte++) = INFRASTRUCTURE;
1836 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1837 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1839 PRINT_ER("Channel out of range\n");
1840 *(pu8CurrByte++) = 0xFF;
1843 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1844 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1845 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1848 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1849 WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
1854 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1855 WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
1860 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1861 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1862 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1864 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1865 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1866 /* Supported rates*/
1867 WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
1868 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1871 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1872 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1874 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1877 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1878 /* copy this information to the user request */
1879 pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
1882 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1883 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1884 /* rsn group policy*/
1885 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1886 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1888 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1889 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1890 /* rsn pcip policy*/
1891 WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
1892 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1894 /* rsn auth policy*/
1895 WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
1896 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1898 /* rsn auth policy*/
1899 WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
1900 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1903 *(pu8CurrByte++) = REAL_JOIN_REQ;
1906 *(pu8CurrByte++) = ptstrJoinBssParam->u8NoaEnbaled;
1907 if (ptstrJoinBssParam->u8NoaEnbaled) {
1908 PRINT_D(HOSTINF_DBG, "NOA present\n");
1910 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1911 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1912 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1913 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1915 *(pu8CurrByte++) = ptstrJoinBssParam->u8Index;
1917 *(pu8CurrByte++) = ptstrJoinBssParam->u8OppEnable;
1919 if (ptstrJoinBssParam->u8OppEnable)
1920 *(pu8CurrByte++) = ptstrJoinBssParam->u8CtWindow;
1922 *(pu8CurrByte++) = ptstrJoinBssParam->u8Count;
1924 WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->au8Duration, sizeof(ptstrJoinBssParam->au8Duration));
1926 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Duration);
1928 WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->au8Interval, sizeof(ptstrJoinBssParam->au8Interval));
1930 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Interval);
1932 WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
1934 pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1937 PRINT_D(HOSTINF_DBG, "NOA not present\n");
1941 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1942 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1945 #endif /* #ifdef WILC_PARSE_SCAN_IN_HOST*/
1949 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1950 * firmware at chip reset when processing the WIDs of the Connect Request.
1951 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1952 /* ////////////////////// */
1953 gu32WidConnRstHack = 0;
1954 /* ////////////////////// */
1958 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1959 memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
1960 gu8FlushedJoinReqDrvHandler = (u32)pstrWFIDrv;
1963 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1965 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1966 WILC_memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->pu8bssid, ETH_ALEN);
1968 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]));
1969 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]));
1972 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, (u32)pstrWFIDrv);
1974 PRINT_ER("Handle_Connect()] failed to send config packet\n");
1975 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
1977 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
1978 pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1982 WILC_CATCH(s32Error)
1984 tstrConnectInfo strConnectInfo;
1986 WILC_TimerStop(&(pstrWFIDrv->hConnectTimer), NULL);
1988 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
1990 WILC_memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1992 if (pstrHostIFconnectAttr->pfConnectResult != NULL) {
1993 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1994 WILC_memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
1997 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1998 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1999 strConnectInfo.pu8ReqIEs = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->IEsLen);
2000 WILC_memcpy(strConnectInfo.pu8ReqIEs,
2001 pstrHostIFconnectAttr->pu8IEs,
2002 pstrHostIFconnectAttr->IEsLen);
2005 pstrHostIFconnectAttr->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2009 pstrHostIFconnectAttr->pvUserArg);
2010 /*Change state to idle*/
2011 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2013 if (strConnectInfo.pu8ReqIEs != NULL) {
2014 WILC_FREE(strConnectInfo.pu8ReqIEs);
2015 strConnectInfo.pu8ReqIEs = NULL;
2019 PRINT_ER("Connect callback function pointer is NULL \n");
2023 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
2024 /* Deallocate pstrHostIFconnectAttr->pu8bssid which was prevoisuly allocated by the sending thread */
2025 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
2026 WILC_FREE(pstrHostIFconnectAttr->pu8bssid);
2027 pstrHostIFconnectAttr->pu8bssid = NULL;
2030 /* Deallocate pstrHostIFconnectAttr->pu8ssid which was prevoisuly allocated by the sending thread */
2031 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
2032 WILC_FREE(pstrHostIFconnectAttr->pu8ssid);
2033 pstrHostIFconnectAttr->pu8ssid = NULL;
2036 /* Deallocate pstrHostIFconnectAttr->pu8IEs which was prevoisuly allocated by the sending thread */
2037 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
2038 WILC_FREE(pstrHostIFconnectAttr->pu8IEs);
2039 pstrHostIFconnectAttr->pu8IEs = NULL;
2042 if (pu8CurrByte != NULL) {
2043 WILC_FREE(pu8CurrByte);
2049 * @brief Handle_FlushConnect
2050 * @details Sending config packet to firmware to flush an old connection
2051 * after switching FW from station one to hybrid one
2052 * @param[in] void * drvHandler
2053 * @return Error code.
2054 * @author Amr Abdel-Moghny
2059 static s32 Handle_FlushConnect(void *drvHandler)
2061 s32 s32Error = WILC_SUCCESS;
2062 tstrWID strWIDList[5];
2063 u32 u32WidsCount = 0;
2064 u8 *pu8CurrByte = NULL;
2067 /* IEs to be inserted in Association Request */
2068 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
2069 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
2070 strWIDList[u32WidsCount].ps8WidVal = gu8FlushedInfoElemAsoc;
2071 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedInfoElemAsocSize;
2074 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
2075 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
2076 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
2077 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(gu8Flushed11iMode));
2082 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
2083 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
2084 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
2085 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&gu8FlushedAuthType);
2089 #ifdef WILC_PARSE_SCAN_IN_HOST
2090 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
2091 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
2092 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedJoinReqSize;
2093 strWIDList[u32WidsCount].ps8WidVal = (s8 *)gu8FlushedJoinReq;
2094 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
2096 pu8CurrByte += FLUSHED_BYTE_POS;
2097 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
2103 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, gu8FlushedJoinReqDrvHandler);
2105 PRINT_ER("Handle_Flush_Connect()] failed to send config packet\n");
2106 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
2109 WILC_CATCH(s32Error)
2118 * @brief Handle_ConnectTimeout
2119 * @details Call connect notification callback function indicating connection failure
2121 * @return Error code.
2126 static s32 Handle_ConnectTimeout(void *drvHandler)
2128 s32 s32Error = WILC_SUCCESS;
2129 tstrConnectInfo strConnectInfo;
2131 u16 u16DummyReasonCode = 0;
2132 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
2134 if (pstrWFIDrv == NULL) {
2135 PRINT_ER("Driver handler is NULL\n");
2139 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2141 gbScanWhileConnected = false;
2144 WILC_memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
2147 /* First, we will notify the upper layer with the Connection failure {through the Connect Callback function},
2148 * then we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2149 * WID_DISCONNECT} */
2150 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2151 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2152 WILC_memcpy(strConnectInfo.au8bssid,
2153 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
2156 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2157 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
2158 strConnectInfo.pu8ReqIEs = (u8 *)WILC_MALLOC(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2159 WILC_memcpy(strConnectInfo.pu8ReqIEs,
2160 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2161 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2164 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2168 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2170 /* Deallocation of strConnectInfo.pu8ReqIEs */
2171 if (strConnectInfo.pu8ReqIEs != NULL) {
2172 WILC_FREE(strConnectInfo.pu8ReqIEs);
2173 strConnectInfo.pu8ReqIEs = NULL;
2176 PRINT_ER("Connect callback function pointer is NULL \n");
2179 /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2180 * WID_DISCONNECT} */
2181 strWID.u16WIDid = (u16)WID_DISCONNECT;
2182 strWID.enuWIDtype = WID_CHAR;
2183 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
2184 strWID.s32ValueSize = sizeof(char);
2186 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2188 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
2190 PRINT_ER("Failed to send dissconect config packet\n");
2193 /* Deallocation of the Saved Connect Request in the global Handle */
2194 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2195 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
2196 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
2197 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2200 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2201 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
2202 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2205 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2206 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2207 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
2208 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2211 WILC_memset(u8ConnectedSSID, 0, ETH_ALEN);
2213 /*Freeing flushed join request params on connect timeout*/
2214 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
2215 WILC_FREE(gu8FlushedJoinReq);
2216 gu8FlushedJoinReq = NULL;
2218 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
2219 WILC_FREE(gu8FlushedInfoElemAsoc);
2220 gu8FlushedInfoElemAsoc = NULL;
2227 * @brief Handle_RcvdNtwrkInfo
2228 * @details Handling received network information
2229 * @param[in] tstrRcvdNetworkInfo* pstrRcvdNetworkInfo
2230 * @return Error code.
2235 static s32 Handle_RcvdNtwrkInfo(void *drvHandler, tstrRcvdNetworkInfo *pstrRcvdNetworkInfo)
2238 bool bNewNtwrkFound;
2242 s32 s32Error = WILC_SUCCESS;
2243 tstrNetworkInfo *pstrNetworkInfo = NULL;
2244 void *pJoinParams = NULL;
2246 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2250 bNewNtwrkFound = true;
2251 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
2253 /*if there is a an ongoing scan request*/
2254 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2255 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
2256 ParseNetworkInfo(pstrRcvdNetworkInfo->pu8Buffer, &pstrNetworkInfo);
2257 if ((pstrNetworkInfo == NULL)
2258 || (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
2259 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
2262 /* check whether this network is discovered before */
2263 for (i = 0; i < pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
2265 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
2266 (pstrNetworkInfo->au8bssid != NULL)) {
2267 if (WILC_memcmp(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
2268 pstrNetworkInfo->au8bssid, 6) == 0) {
2269 if (pstrNetworkInfo->s8rssi <= pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
2270 /*we have already found this network with better rssi, so keep the old cached one and don't
2271 * send anything to the upper layer */
2272 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
2275 /* here the same already found network is found again but with a better rssi, so just update
2276 * the rssi for this cached network and send this updated network to the upper layer but
2277 * don't add a new record for it */
2278 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
2279 bNewNtwrkFound = false;
2286 if (bNewNtwrkFound == true) {
2287 /* here it is confirmed that it is a new discovered network,
2288 * so add its record then call the User CallBack function */
2290 PRINT_D(HOSTINF_DBG, "New network found\n");
2292 if (pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
2293 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
2295 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
2296 && (pstrNetworkInfo->au8bssid != NULL)) {
2297 WILC_memcpy(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
2298 pstrNetworkInfo->au8bssid, 6);
2300 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount++;
2302 pstrNetworkInfo->bNewNetwork = true;
2303 /*Bug4218: Parsing Join Param*/
2304 /* add new BSS to JoinBssTable */
2305 #ifdef WILC_PARSE_SCAN_IN_HOST
2306 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
2307 #endif /*WILC_PARSE_SCAN_IN_HOST*/
2309 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2310 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid,
2316 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit \n");
2319 pstrNetworkInfo->bNewNetwork = false;
2320 /* just call the User CallBack function to send the same discovered network with its updated RSSI */
2321 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2322 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2327 WILC_CATCH(s32Error)
2333 /* Deallocate pstrRcvdNetworkInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2334 if (pstrRcvdNetworkInfo->pu8Buffer != NULL) {
2335 WILC_FREE(pstrRcvdNetworkInfo->pu8Buffer);
2336 pstrRcvdNetworkInfo->pu8Buffer = NULL;
2339 /*free structure allocated*/
2340 if (pstrNetworkInfo != NULL) {
2341 DeallocateNetworkInfo(pstrNetworkInfo);
2342 pstrNetworkInfo = NULL;
2349 * @brief Handle_RcvdGnrlAsyncInfo
2350 * @details Handling received asynchrous general network information
2351 * @param[in] tstrRcvdGnrlAsyncInfo* pstrRcvdGnrlAsyncInfo
2352 * @return Error code.
2357 static s32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncInfo *pstrRcvdGnrlAsyncInfo)
2359 /* TODO: mostafa: till now, this function just handles only the received mac status msg, */
2360 /* which carries only 1 WID which have WID ID = WID_STATUS */
2361 s32 s32Error = WILC_SUCCESS;
2365 u16 u16WidID = (u16)WID_NIL;
2368 u8 u8MacStatusReasonCode;
2369 u8 u8MacStatusAdditionalInfo;
2370 tstrConnectInfo strConnectInfo;
2371 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2372 s32 s32Err = WILC_SUCCESS;
2373 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
2374 if (pstrWFIDrv == NULL) {
2375 PRINT_ER("Driver handler is NULL\n");
2377 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", pstrWFIDrv->enuHostIFstate,
2378 pstrRcvdGnrlAsyncInfo->pu8Buffer[7]);
2380 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
2381 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) ||
2382 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2383 if ((pstrRcvdGnrlAsyncInfo->pu8Buffer == NULL) ||
2384 (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
2385 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
2388 u8MsgType = pstrRcvdGnrlAsyncInfo->pu8Buffer[0];
2390 /* Check whether the received message type is 'I' */
2391 if ('I' != u8MsgType) {
2392 PRINT_ER("Received Message format incorrect.\n");
2393 WILC_ERRORREPORT(s32Error, WILC_FAIL);
2396 /* Extract message ID */
2397 u8MsgID = pstrRcvdGnrlAsyncInfo->pu8Buffer[1];
2399 /* Extract message Length */
2400 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[2], pstrRcvdGnrlAsyncInfo->pu8Buffer[3]);
2402 /* Extract WID ID [expected to be = WID_STATUS] */
2403 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[4], pstrRcvdGnrlAsyncInfo->pu8Buffer[5]);
2405 /* Extract WID Length [expected to be = 1] */
2406 u8WidLen = pstrRcvdGnrlAsyncInfo->pu8Buffer[6];
2408 /* get the WID value [expected to be one of two values: either MAC_CONNECTED = (1) or MAC_DISCONNECTED = (0)] */
2409 u8MacStatus = pstrRcvdGnrlAsyncInfo->pu8Buffer[7];
2410 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->pu8Buffer[8];
2411 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->pu8Buffer[9];
2412 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2413 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2414 /* our station had sent Association Request frame, so here it will get the Association Response frame then parse it */
2415 u32 u32RcvdAssocRespInfoLen;
2416 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
2418 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2420 WILC_memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
2422 if (u8MacStatus == MAC_CONNECTED) {
2423 WILC_memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
2425 host_int_get_assoc_res_info((WILC_WFIDrvHandle)pstrWFIDrv,
2427 MAX_ASSOC_RESP_FRAME_SIZE,
2428 &u32RcvdAssocRespInfoLen);
2430 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
2432 if (u32RcvdAssocRespInfoLen != 0) {
2434 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
2435 s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
2436 &pstrConnectRespInfo);
2438 PRINT_ER("ParseAssocRespInfo() returned error %d \n", s32Err);
2440 /* use the necessary parsed Info from the Received Association Response */
2441 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
2443 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
2444 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
2445 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
2446 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
2449 strConnectInfo.pu8RespIEs = (u8 *)WILC_MALLOC(pstrConnectRespInfo->u16RespIEsLen);
2450 WILC_memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
2451 pstrConnectRespInfo->u16RespIEsLen);
2455 /* deallocate the Assoc. Resp. parsed structure as it is not needed anymore */
2456 if (pstrConnectRespInfo != NULL) {
2457 DeallocateAssocRespInfo(pstrConnectRespInfo);
2458 pstrConnectRespInfo = NULL;
2464 /* The station has just received mac status and it also received assoc. response which
2465 * it was waiting for.
2466 * So check first the matching between the received mac status and the received status code in Asoc Resp */
2467 if ((u8MacStatus == MAC_CONNECTED) &&
2468 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
2469 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE \n");
2470 WILC_memset(u8ConnectedSSID, 0, ETH_ALEN);
2472 } else if (u8MacStatus == MAC_DISCONNECTED) {
2473 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
2474 WILC_memset(u8ConnectedSSID, 0, ETH_ALEN);
2477 /* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */
2478 /* through a structure of type tstrConnectRespInfo */
2479 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2480 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
2481 WILC_memcpy(strConnectInfo.au8bssid, pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
2483 if ((u8MacStatus == MAC_CONNECTED) &&
2484 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
2485 WILC_memcpy(pstrWFIDrv->au8AssociatedBSSID,
2486 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
2491 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2492 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
2493 strConnectInfo.pu8ReqIEs = (u8 *)WILC_MALLOC(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2494 WILC_memcpy(strConnectInfo.pu8ReqIEs,
2495 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2496 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2500 WILC_TimerStop(&(pstrWFIDrv->hConnectTimer), NULL);
2501 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2505 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2508 /* if received mac status is MAC_CONNECTED and
2509 * received status code in Asoc Resp is SUCCESSFUL_STATUSCODE, change state to CONNECTED
2510 * else change state to IDLE */
2511 if ((u8MacStatus == MAC_CONNECTED) &&
2512 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
2513 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2515 host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 0, 0);
2518 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
2519 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTED;
2521 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2522 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
2523 g_obtainingIP = true;
2524 WILC_TimerStart(&hDuringIpTimer, 10000, NULL, NULL);
2527 #ifdef WILC_PARSE_SCAN_IN_HOST
2528 /* open a BA session if possible */
2529 /* if(pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable) */
2533 /* host_int_addBASession(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid,0, */
2534 /* BA_SESSION_DEFAULT_BUFFER_SIZE,BA_SESSION_DEFAULT_TIMEOUT); */
2536 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
2537 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2538 gbScanWhileConnected = false;
2542 if (strConnectInfo.pu8RespIEs != NULL) {
2543 WILC_FREE(strConnectInfo.pu8RespIEs);
2544 strConnectInfo.pu8RespIEs = NULL;
2547 if (strConnectInfo.pu8ReqIEs != NULL) {
2548 WILC_FREE(strConnectInfo.pu8ReqIEs);
2549 strConnectInfo.pu8ReqIEs = NULL;
2553 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2554 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
2555 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
2556 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2559 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2560 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
2561 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2564 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2565 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2566 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
2567 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2570 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2571 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)) {
2572 /* Disassociation or Deauthentication frame has been received */
2573 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
2575 WILC_memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
2577 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2578 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >> \n\n");
2579 WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL);
2580 Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED);
2583 strDisconnectNotifInfo.u16reason = 0;
2584 strDisconnectNotifInfo.ie = NULL;
2585 strDisconnectNotifInfo.ie_len = 0;
2587 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2588 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2590 g_obtainingIP = false;
2591 host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 0, 0);
2594 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
2597 &strDisconnectNotifInfo,
2598 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2601 PRINT_ER("Connect result callback function is NULL \n");
2604 WILC_memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
2609 /* if Information Elements were retrieved from the Received deauth/disassoc frame, then they
2610 * should be deallocated here */
2612 * if(strDisconnectNotifInfo.ie != NULL)
2614 * WILC_FREE(strDisconnectNotifInfo.ie);
2615 * strDisconnectNotifInfo.ie = NULL;
2619 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2620 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
2621 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
2622 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2625 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2626 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
2627 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2630 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2631 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2632 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
2633 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2637 /*Freeing flushed join request params on receiving*/
2638 /*MAC_DISCONNECTED while connected*/
2639 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
2640 WILC_FREE(gu8FlushedJoinReq);
2641 gu8FlushedJoinReq = NULL;
2643 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
2644 WILC_FREE(gu8FlushedInfoElemAsoc);
2645 gu8FlushedInfoElemAsoc = NULL;
2648 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2649 gbScanWhileConnected = false;
2651 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2652 (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
2653 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
2654 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >> \n\n");
2655 /*Abort the running scan*/
2656 WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL);
2657 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2658 Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED);
2665 WILC_CATCH(s32Error)
2670 /* Deallocate pstrRcvdGnrlAsyncInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2671 if (pstrRcvdGnrlAsyncInfo->pu8Buffer != NULL) {
2672 WILC_FREE(pstrRcvdGnrlAsyncInfo->pu8Buffer);
2673 pstrRcvdGnrlAsyncInfo->pu8Buffer = NULL;
2681 * @details Sending config packet to firmware to set key
2682 * @param[in] tstrHostIFkeyAttr* pstrHostIFkeyAttr
2683 * @return Error code.
2688 static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr)
2690 s32 s32Error = WILC_SUCCESS;
2692 #ifdef WILC_AP_EXTERNAL_MLME
2693 tstrWID strWIDList[5];
2699 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2702 switch (pstrHostIFkeyAttr->enuKeyType) {
2707 #ifdef WILC_AP_EXTERNAL_MLME
2708 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2710 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
2711 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
2712 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
2713 strWIDList[0].enuWIDtype = WID_CHAR;
2714 strWIDList[0].s32ValueSize = sizeof(char);
2715 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8mode));
2717 strWIDList[1].u16WIDid = WID_AUTH_TYPE;
2718 strWIDList[1].enuWIDtype = WID_CHAR;
2719 strWIDList[1].s32ValueSize = sizeof(char);
2720 strWIDList[1].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type));
2722 strWIDList[2].u16WIDid = (u16)WID_KEY_ID;
2723 strWIDList[2].enuWIDtype = WID_CHAR;
2725 strWIDList[2].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
2726 strWIDList[2].s32ValueSize = sizeof(char);
2729 pu8keybuf = (u8 *)WILC_MALLOC(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2732 if (pu8keybuf == NULL) {
2733 PRINT_ER("No buffer to send Key\n");
2737 WILC_memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
2738 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2741 WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
2743 strWIDList[3].u16WIDid = (u16)WID_WEP_KEY_VALUE;
2744 strWIDList[3].enuWIDtype = WID_STR;
2745 strWIDList[3].s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen;
2746 strWIDList[3].ps8WidVal = (s8 *)pu8keybuf;
2749 s32Error = SendConfigPkt(SET_CFG, strWIDList, 4, true, (u32)pstrWFIDrv);
2750 WILC_FREE(pu8keybuf);
2756 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2757 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
2758 pu8keybuf = (u8 *)WILC_MALLOC(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2);
2759 if (pu8keybuf == NULL) {
2760 PRINT_ER("No buffer to send Key\n");
2763 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2765 WILC_memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, 1);
2767 WILC_memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
2768 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2770 WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
2772 strWID.u16WIDid = (u16)WID_ADD_WEP_KEY;
2773 strWID.enuWIDtype = WID_STR;
2774 strWID.ps8WidVal = (s8 *)pu8keybuf;
2775 strWID.s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2;
2777 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2778 WILC_FREE(pu8keybuf);
2779 } else if (pstrHostIFkeyAttr->u8KeyAction & REMOVEKEY) {
2781 PRINT_D(HOSTINF_DBG, "Removing key\n");
2782 strWID.u16WIDid = (u16)WID_REMOVE_WEP_KEY;
2783 strWID.enuWIDtype = WID_STR;
2785 s8idxarray[0] = (s8)pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2786 strWID.ps8WidVal = s8idxarray;
2787 strWID.s32ValueSize = 1;
2789 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2791 strWID.u16WIDid = (u16)WID_KEY_ID;
2792 strWID.enuWIDtype = WID_CHAR;
2793 strWID.ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
2794 strWID.s32ValueSize = sizeof(char);
2796 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
2798 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2800 up(&(pstrWFIDrv->hSemTestKeyBlock));
2804 #ifdef WILC_AP_EXTERNAL_MLME
2805 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2806 pu8keybuf = (u8 *)WILC_MALLOC(RX_MIC_KEY_MSG_LEN);
2807 if (pu8keybuf == NULL) {
2808 PRINT_ER("No buffer to send RxGTK Key\n");
2810 goto _WPARxGtk_end_case_;
2813 WILC_memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
2816 /*|----------------------------------------------------------------------------|
2817 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2818 * |------------|---------|-------|------------|---------------|----------------|
2819 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2823 if (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq != NULL)
2824 WILC_memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
2827 WILC_memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2829 WILC_memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2831 WILC_memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2832 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2833 /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */
2834 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
2835 strWIDList[0].enuWIDtype = WID_CHAR;
2836 strWIDList[0].s32ValueSize = sizeof(char);
2837 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
2839 strWIDList[1].u16WIDid = (u16)WID_ADD_RX_GTK;
2840 strWIDList[1].enuWIDtype = WID_STR;
2841 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
2842 strWIDList[1].s32ValueSize = RX_MIC_KEY_MSG_LEN;
2844 s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, true, (u32)pstrWFIDrv);
2846 WILC_FREE(pu8keybuf);
2848 /* ////////////////////////// */
2849 up(&(pstrWFIDrv->hSemTestKeyBlock));
2850 /* ///////////////////////// */
2854 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2855 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
2857 pu8keybuf = (u8 *)WILC_MALLOC(RX_MIC_KEY_MSG_LEN);
2858 if (pu8keybuf == NULL) {
2859 PRINT_ER("No buffer to send RxGTK Key\n");
2861 goto _WPARxGtk_end_case_;
2864 WILC_memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
2867 /*|----------------------------------------------------------------------------|
2868 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2869 * |------------|---------|-------|------------|---------------|----------------|
2870 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2872 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
2873 WILC_memcpy(pu8keybuf, pstrWFIDrv->au8AssociatedBSSID, ETH_ALEN);
2875 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED \n");
2878 WILC_memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
2880 WILC_memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2882 WILC_memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2883 WILC_memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2884 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2886 strWID.u16WIDid = (u16)WID_ADD_RX_GTK;
2887 strWID.enuWIDtype = WID_STR;
2888 strWID.ps8WidVal = (s8 *)pu8keybuf;
2889 strWID.s32ValueSize = RX_MIC_KEY_MSG_LEN;
2891 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2893 WILC_FREE(pu8keybuf);
2895 /* ////////////////////////// */
2896 up(&(pstrWFIDrv->hSemTestKeyBlock));
2897 /* ///////////////////////// */
2899 _WPARxGtk_end_case_:
2900 WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
2901 WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq);
2908 #ifdef WILC_AP_EXTERNAL_MLME
2909 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2912 pu8keybuf = (u8 *)WILC_MALLOC(PTK_KEY_MSG_LEN + 1);
2916 if (pu8keybuf == NULL) {
2917 PRINT_ER("No buffer to send PTK Key\n");
2919 goto _WPAPtk_end_case_;
2923 /*|-----------------------------------------------------------------------------|
2924 * |Station address | keyidx |Key Length |Temporal Key | Rx Michael Key |Tx Michael Key |
2925 * |----------------|------------ |--------------|----------------|---------------|
2926 | 6 bytes | 1 byte | 1byte | 16 bytes | 8 bytes | 8 bytes |
2927 |-----------------------------------------------------------------------------|*/
2929 WILC_memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
2931 WILC_memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2932 WILC_memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2934 WILC_memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2935 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2938 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
2939 strWIDList[0].enuWIDtype = WID_CHAR;
2940 strWIDList[0].s32ValueSize = sizeof(char);
2941 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
2943 strWIDList[1].u16WIDid = (u16)WID_ADD_PTK;
2944 strWIDList[1].enuWIDtype = WID_STR;
2945 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
2946 strWIDList[1].s32ValueSize = PTK_KEY_MSG_LEN + 1;
2948 s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, true, (u32)pstrWFIDrv);
2949 WILC_FREE(pu8keybuf);
2951 /* ////////////////////////// */
2952 up(&(pstrWFIDrv->hSemTestKeyBlock));
2953 /* ///////////////////////// */
2956 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2959 pu8keybuf = (u8 *)WILC_MALLOC(PTK_KEY_MSG_LEN);
2963 if (pu8keybuf == NULL) {
2964 PRINT_ER("No buffer to send PTK Key\n");
2966 goto _WPAPtk_end_case_;
2970 /*|-----------------------------------------------------------------------------|
2971 * |Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
2972 * |----------------|------------|--------------|----------------|---------------|
2973 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
2974 |-----------------------------------------------------------------------------|*/
2976 WILC_memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
2978 WILC_memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2980 WILC_memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2981 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2984 strWID.u16WIDid = (u16)WID_ADD_PTK;
2985 strWID.enuWIDtype = WID_STR;
2986 strWID.ps8WidVal = (s8 *)pu8keybuf;
2987 strWID.s32ValueSize = PTK_KEY_MSG_LEN;
2989 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2990 WILC_FREE(pu8keybuf);
2992 /* ////////////////////////// */
2993 up(&(pstrWFIDrv->hSemTestKeyBlock));
2994 /* ///////////////////////// */
2998 WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
3007 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
3009 pu8keybuf = (u8 *)WILC_MALLOC((pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1);
3010 if (pu8keybuf == NULL) {
3011 PRINT_ER("No buffer to send PMKSA Key\n");
3015 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid;
3017 for (i = 0; i < pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid; i++) {
3019 WILC_memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, ETH_ALEN);
3020 WILC_memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, PMKID_LEN);
3023 strWID.u16WIDid = (u16)WID_PMKID_INFO;
3024 strWID.enuWIDtype = WID_STR;
3025 strWID.ps8WidVal = (s8 *)pu8keybuf;
3026 strWID.s32ValueSize = (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1;
3028 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3030 WILC_FREE(pu8keybuf);
3035 PRINT_ER("Failed to send key config packet\n");
3043 * @brief Handle_Disconnect
3044 * @details Sending config packet to firmware to disconnect
3051 static void Handle_Disconnect(void *drvHandler)
3055 s32 s32Error = WILC_SUCCESS;
3056 u16 u16DummyReasonCode = 0;
3057 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3060 strWID.u16WIDid = (u16)WID_DISCONNECT;
3061 strWID.enuWIDtype = WID_CHAR;
3062 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
3063 strWID.s32ValueSize = sizeof(char);
3067 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
3069 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3071 g_obtainingIP = false;
3072 host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 0, 0);
3075 WILC_memset(u8ConnectedSSID, 0, ETH_ALEN);
3077 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3080 PRINT_ER("Failed to send dissconect config packet\n");
3081 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3083 tstrDisconnectNotifInfo strDisconnectNotifInfo;
3085 WILC_memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
3087 strDisconnectNotifInfo.u16reason = 0;
3088 strDisconnectNotifInfo.ie = NULL;
3089 strDisconnectNotifInfo.ie_len = 0;
3091 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
3092 WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL);
3093 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
3094 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
3096 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
3099 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
3102 /*Stop connect timer, if connection in progress*/
3103 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3104 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
3105 WILC_TimerStop(&(pstrWFIDrv->hConnectTimer), NULL);
3108 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
3109 0, &strDisconnectNotifInfo, pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
3111 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL \n");
3114 gbScanWhileConnected = false;
3116 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
3118 WILC_memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
3122 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
3123 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
3124 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
3125 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
3128 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
3129 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
3130 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
3133 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
3134 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
3135 WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
3136 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
3141 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
3142 WILC_FREE(gu8FlushedJoinReq);
3143 gu8FlushedJoinReq = NULL;
3145 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
3146 WILC_FREE(gu8FlushedInfoElemAsoc);
3147 gu8FlushedInfoElemAsoc = NULL;
3152 WILC_CATCH(s32Error)
3157 /* ////////////////////////// */
3158 up(&(pstrWFIDrv->hSemTestDisconnectBlock));
3159 /* ///////////////////////// */
3164 void resolve_disconnect_aberration(void *drvHandler)
3166 tstrWILC_WFIDrv *pstrWFIDrv;
3168 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3169 if (pstrWFIDrv == NULL)
3171 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTING)) {
3172 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
3173 host_int_disconnect((WILC_WFIDrvHandle)pstrWFIDrv, 1);
3176 static s32 Switch_Log_Terminal(void *drvHandler)
3180 s32 s32Error = WILC_SUCCESS;
3182 static char dummy = 9;
3183 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3185 strWID.u16WIDid = (u16)WID_LOGTerminal_Switch;
3186 strWID.enuWIDtype = WID_CHAR;
3187 strWID.ps8WidVal = &dummy;
3188 strWID.s32ValueSize = sizeof(char);
3190 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3194 PRINT_D(HOSTINF_DBG, "Failed to switch log terminal\n");
3195 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
3197 PRINT_INFO(HOSTINF_DBG, "MAC address set :: \n");
3202 WILC_CATCH(s32Error)
3211 * @brief Handle_GetChnl
3212 * @details Sending config packet to get channel
3220 static s32 Handle_GetChnl(void *drvHandler)
3223 s32 s32Error = WILC_SUCCESS;
3225 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
3226 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3227 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
3228 strWID.enuWIDtype = WID_CHAR;
3229 strWID.ps8WidVal = (s8 *)&gu8Chnl;
3230 strWID.s32ValueSize = sizeof(char);
3232 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
3234 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3235 /*get the value by searching the local copy*/
3237 PRINT_ER("Failed to get channel number\n");
3238 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3242 WILC_CATCH(s32Error)
3246 up(&(pstrWFIDrv->hSemGetCHNL));
3256 * @brief Handle_GetRssi
3257 * @details Sending config packet to get RSSI
3264 static void Handle_GetRssi(void *drvHandler)
3266 s32 s32Error = WILC_SUCCESS;
3268 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3270 strWID.u16WIDid = (u16)WID_RSSI;
3271 strWID.enuWIDtype = WID_CHAR;
3272 strWID.ps8WidVal = &gs8Rssi;
3273 strWID.s32ValueSize = sizeof(char);
3276 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
3278 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3280 PRINT_ER("Failed to get RSSI value\n");
3281 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3284 WILC_CATCH(s32Error)
3288 up(&(pstrWFIDrv->hSemGetRSSI));
3294 static void Handle_GetLinkspeed(void *drvHandler)
3296 s32 s32Error = WILC_SUCCESS;
3298 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3302 strWID.u16WIDid = (u16)WID_LINKSPEED;
3303 strWID.enuWIDtype = WID_CHAR;
3304 strWID.ps8WidVal = &gs8lnkspd;
3305 strWID.s32ValueSize = sizeof(char);
3307 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
3309 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3311 PRINT_ER("Failed to get LINKSPEED value\n");
3312 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3315 WILC_CATCH(s32Error)
3319 up(&(pstrWFIDrv->hSemGetLINKSPEED));
3324 s32 Handle_GetStatistics(void *drvHandler, tstrStatistics *pstrStatistics)
3326 tstrWID strWIDList[5];
3327 uint32_t u32WidsCount = 0, s32Error = 0;
3329 strWIDList[u32WidsCount].u16WIDid = WID_LINKSPEED;
3330 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
3331 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
3332 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u8LinkSpeed));
3335 strWIDList[u32WidsCount].u16WIDid = WID_RSSI;
3336 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
3337 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
3338 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->s8RSSI));
3341 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
3342 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
3343 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
3344 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxCount));
3347 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
3348 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
3349 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
3350 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32RxCount));
3353 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
3354 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
3355 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
3356 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxFailureCount));
3359 s32Error = SendConfigPkt(GET_CFG, strWIDList, u32WidsCount, false, (u32)drvHandler);
3362 PRINT_ER("Failed to send scan paramters config packet\n");
3363 /* WILC_ERRORREPORT(s32Error, s32Error); */
3371 #ifdef WILC_AP_EXTERNAL_MLME
3375 * @brief Handle_Get_InActiveTime
3376 * @details Sending config packet to set mac adddress for station and
3385 static s32 Handle_Get_InActiveTime(void *drvHandler, tstrHostIfStaInactiveT *strHostIfStaInactiveT)
3388 s32 s32Error = WILC_SUCCESS;
3391 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3394 strWID.u16WIDid = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
3395 strWID.enuWIDtype = WID_STR;
3396 strWID.s32ValueSize = ETH_ALEN;
3397 strWID.ps8WidVal = (u8 *)WILC_MALLOC(strWID.s32ValueSize);
3400 stamac = strWID.ps8WidVal;
3401 WILC_memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
3404 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
3407 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3408 /*get the value by searching the local copy*/
3410 PRINT_ER("Failed to SET incative time\n");
3411 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3415 strWID.u16WIDid = (u16)WID_GET_INACTIVE_TIME;
3416 strWID.enuWIDtype = WID_INT;
3417 strWID.ps8WidVal = (s8 *)&gu32InactiveTime;
3418 strWID.s32ValueSize = sizeof(u32);
3421 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3422 /*get the value by searching the local copy*/
3424 PRINT_ER("Failed to get incative time\n");
3425 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3429 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
3431 up(&(pstrWFIDrv->hSemInactiveTime));
3432 WILC_CATCH(s32Error)
3446 * @brief Handle_AddBeacon
3447 * @details Sending config packet to add beacon
3448 * @param[in] tstrHostIFSetBeacon* pstrSetBeaconParam
3454 static void Handle_AddBeacon(void *drvHandler, tstrHostIFSetBeacon *pstrSetBeaconParam)
3456 s32 s32Error = WILC_SUCCESS;
3459 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3460 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
3462 strWID.u16WIDid = (u16)WID_ADD_BEACON;
3463 strWID.enuWIDtype = WID_BIN;
3464 strWID.s32ValueSize = pstrSetBeaconParam->u32HeadLen + pstrSetBeaconParam->u32TailLen + 16;
3465 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3466 if (strWID.ps8WidVal == NULL) {
3467 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3470 pu8CurrByte = strWID.ps8WidVal;
3471 *pu8CurrByte++ = (pstrSetBeaconParam->u32Interval & 0xFF);
3472 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 8) & 0xFF);
3473 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 16) & 0xFF);
3474 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 24) & 0xFF);
3476 *pu8CurrByte++ = (pstrSetBeaconParam->u32DTIMPeriod & 0xFF);
3477 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 8) & 0xFF);
3478 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 16) & 0xFF);
3479 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 24) & 0xFF);
3481 *pu8CurrByte++ = (pstrSetBeaconParam->u32HeadLen & 0xFF);
3482 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 8) & 0xFF);
3483 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 16) & 0xFF);
3484 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 24) & 0xFF);
3486 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Head, pstrSetBeaconParam->u32HeadLen);
3487 pu8CurrByte += pstrSetBeaconParam->u32HeadLen;
3489 *pu8CurrByte++ = (pstrSetBeaconParam->u32TailLen & 0xFF);
3490 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 8) & 0xFF);
3491 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 16) & 0xFF);
3492 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 24) & 0xFF);
3494 /* Bug 4599 : if tail length = 0 skip copying */
3495 if (pstrSetBeaconParam->pu8Tail > 0)
3496 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Tail, pstrSetBeaconParam->u32TailLen);
3497 pu8CurrByte += pstrSetBeaconParam->u32TailLen;
3502 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3504 PRINT_ER("Failed to send add beacon config packet\n");
3505 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3508 WILC_CATCH(s32Error)
3511 WILC_FREE_IF_TRUE(strWID.ps8WidVal);
3512 WILC_FREE_IF_TRUE(pstrSetBeaconParam->pu8Head);
3513 WILC_FREE_IF_TRUE(pstrSetBeaconParam->pu8Tail);
3518 * @brief Handle_AddBeacon
3519 * @details Sending config packet to delete beacon
3520 * @param[in] tstrHostIFDelBeacon* pstrDelBeacon
3526 static void Handle_DelBeacon(void *drvHandler, tstrHostIFDelBeacon *pstrDelBeacon)
3528 s32 s32Error = WILC_SUCCESS;
3531 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3532 strWID.u16WIDid = (u16)WID_DEL_BEACON;
3533 strWID.enuWIDtype = WID_CHAR;
3534 strWID.s32ValueSize = sizeof(char);
3535 strWID.ps8WidVal = &gu8DelBcn;
3537 if (strWID.ps8WidVal == NULL) {
3538 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3541 pu8CurrByte = strWID.ps8WidVal;
3543 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
3544 /* TODO: build del beacon message*/
3547 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3550 PRINT_ER("Failed to send delete beacon config packet\n");
3551 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3554 WILC_CATCH(s32Error)
3561 * @brief WILC_HostIf_PackStaParam
3562 * @details Handling packing of the station params in a buffer
3563 * @param[in] u8* pu8Buffer, tstrWILC_AddStaParam* pstrStationParam
3569 static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer, tstrWILC_AddStaParam *pstrStationParam)
3573 pu8CurrByte = pu8Buffer;
3575 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
3576 WILC_memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
3577 pu8CurrByte += ETH_ALEN;
3579 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
3580 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
3582 *pu8CurrByte++ = pstrStationParam->u8NumRates;
3583 if (pstrStationParam->u8NumRates > 0) {
3584 WILC_memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
3586 pu8CurrByte += pstrStationParam->u8NumRates;
3588 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
3589 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
3590 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
3592 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
3593 WILC_memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
3594 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
3596 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
3597 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
3599 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
3600 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
3601 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
3602 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
3604 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
3606 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
3607 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
3609 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
3610 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
3612 return pu8CurrByte - pu8Buffer;
3616 * @brief Handle_AddStation
3617 * @details Sending config packet to add station
3618 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3624 static void Handle_AddStation(void *drvHandler, tstrWILC_AddStaParam *pstrStationParam)
3626 s32 s32Error = WILC_SUCCESS;
3629 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3630 PRINT_D(HOSTINF_DBG, "Handling add station\n");
3631 strWID.u16WIDid = (u16)WID_ADD_STA;
3632 strWID.enuWIDtype = WID_BIN;
3633 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3635 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3636 if (strWID.ps8WidVal == NULL) {
3637 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3640 pu8CurrByte = strWID.ps8WidVal;
3641 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3644 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3645 if (s32Error != WILC_SUCCESS) {
3647 PRINT_ER("Failed to send add station config packet\n");
3648 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3651 WILC_CATCH(s32Error)
3654 WILC_FREE_IF_TRUE(pstrStationParam->pu8Rates);
3655 WILC_FREE_IF_TRUE(strWID.ps8WidVal);
3659 * @brief Handle_DelAllSta
3660 * @details Sending config packet to delete station
3661 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3667 static void Handle_DelAllSta(void *drvHandler, tstrHostIFDelAllSta *pstrDelAllStaParam)
3669 s32 s32Error = WILC_SUCCESS;
3672 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3674 u8 au8Zero_Buff[6] = {0};
3675 strWID.u16WIDid = (u16)WID_DEL_ALL_STA;
3676 strWID.enuWIDtype = WID_STR;
3677 strWID.s32ValueSize = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1;
3679 PRINT_D(HOSTINF_DBG, "Handling delete station \n");
3681 strWID.ps8WidVal = WILC_MALLOC((pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1);
3682 if (strWID.ps8WidVal == NULL) {
3683 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3686 pu8CurrByte = strWID.ps8WidVal;
3688 *(pu8CurrByte++) = pstrDelAllStaParam->u8Num_AssocSta;
3690 for (i = 0; i < MAX_NUM_STA; i++) {
3691 if (memcmp(pstrDelAllStaParam->au8Sta_DelAllSta[i], au8Zero_Buff, ETH_ALEN))
3692 WILC_memcpy(pu8CurrByte, pstrDelAllStaParam->au8Sta_DelAllSta[i], ETH_ALEN);
3696 pu8CurrByte += ETH_ALEN;
3700 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3703 PRINT_ER("Failed to send add station config packe\n");
3704 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3707 WILC_CATCH(s32Error)
3710 WILC_FREE_IF_TRUE(strWID.ps8WidVal);
3717 * @brief Handle_DelStation
3718 * @details Sending config packet to delete station
3719 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3725 static void Handle_DelStation(void *drvHandler, tstrHostIFDelSta *pstrDelStaParam)
3727 s32 s32Error = WILC_SUCCESS;
3730 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3732 strWID.u16WIDid = (u16)WID_REMOVE_STA;
3733 strWID.enuWIDtype = WID_BIN;
3734 strWID.s32ValueSize = ETH_ALEN;
3736 PRINT_D(HOSTINF_DBG, "Handling delete station \n");
3738 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3739 if (strWID.ps8WidVal == NULL) {
3740 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3743 pu8CurrByte = strWID.ps8WidVal;
3745 WILC_memcpy(pu8CurrByte, pstrDelStaParam->au8MacAddr, ETH_ALEN);
3748 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3751 PRINT_ER("Failed to send add station config packe\n");
3752 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3755 WILC_CATCH(s32Error)
3758 WILC_FREE_IF_TRUE(strWID.ps8WidVal);
3763 * @brief Handle_EditStation
3764 * @details Sending config packet to edit station
3765 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3771 static void Handle_EditStation(void *drvHandler, tstrWILC_AddStaParam *pstrStationParam)
3773 s32 s32Error = WILC_SUCCESS;
3776 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3778 strWID.u16WIDid = (u16)WID_EDIT_STA;
3779 strWID.enuWIDtype = WID_BIN;
3780 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3782 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
3783 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3784 if (strWID.ps8WidVal == NULL) {
3785 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3788 pu8CurrByte = strWID.ps8WidVal;
3789 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3792 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3795 PRINT_ER("Failed to send edit station config packet\n");
3796 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3799 WILC_CATCH(s32Error)
3802 WILC_FREE_IF_TRUE(pstrStationParam->pu8Rates);
3803 WILC_FREE_IF_TRUE(strWID.ps8WidVal);
3805 #endif /*WILC_AP_EXTERNAL_MLME*/
3809 * @brief Handle_RemainOnChan
3810 * @details Sending config packet to edit station
3811 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3817 static int Handle_RemainOnChan(void *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan)
3819 s32 s32Error = WILC_SUCCESS;
3820 u8 u8remain_on_chan_flag;
3822 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3824 /*If it's a pendig remain-on-channel, don't overwrite gWFiDrvHandle values (since incoming msg is garbbage)*/
3825 if (!pstrWFIDrv->u8RemainOnChan_pendingreq) {
3826 pstrWFIDrv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
3827 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
3828 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
3829 pstrWFIDrv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
3830 pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
3832 /*Set the channel to use it as a wid val*/
3833 pstrHostIfRemainOnChan->u16Channel = pstrWFIDrv->strHostIfRemainOnChan.u16Channel;
3836 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
3837 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
3838 pstrWFIDrv->u8RemainOnChan_pendingreq = 1;
3839 WILC_ERRORREPORT(s32Error, WILC_BUSY);
3841 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3842 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
3843 WILC_ERRORREPORT(s32Error, WILC_BUSY);
3846 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3847 if (g_obtainingIP || connecting) {
3848 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
3849 WILC_ERRORREPORT(s32Error, WILC_BUSY);
3853 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
3855 u8remain_on_chan_flag = true;
3856 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
3857 strWID.enuWIDtype = WID_STR;
3858 strWID.s32ValueSize = 2;
3859 strWID.ps8WidVal = (s8 *)WILC_MALLOC(strWID.s32ValueSize);
3861 if (strWID.ps8WidVal == NULL) {
3862 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3865 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
3866 strWID.ps8WidVal[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
3869 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3870 if (s32Error != WILC_SUCCESS) {
3871 PRINT_ER("Failed to set remain on channel\n");
3876 P2P_LISTEN_STATE = 1;
3877 WILC_TimerStart(&(pstrWFIDrv->hRemainOnChannel), pstrHostIfRemainOnChan->u32duration, (void *)pstrWFIDrv, NULL);
3879 /*Calling CFG ready_on_channel*/
3880 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady) {
3881 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady(pstrWFIDrv->strHostIfRemainOnChan.pVoid);
3884 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
3885 pstrWFIDrv->u8RemainOnChan_pendingreq = 0;
3891 * @brief Handle_RegisterFrame
3899 static int Handle_RegisterFrame(void *drvHandler, tstrHostIfRegisterFrame *pstrHostIfRegisterFrame)
3901 s32 s32Error = WILC_SUCCESS;
3904 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3906 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
3908 /*prepare configuration packet*/
3909 strWID.u16WIDid = (u16)WID_REGISTER_FRAME;
3910 strWID.enuWIDtype = WID_STR;
3911 strWID.ps8WidVal = WILC_MALLOC(sizeof(u16) + 2);
3912 if (strWID.ps8WidVal == NULL) {
3913 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3916 pu8CurrByte = strWID.ps8WidVal;
3918 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
3919 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
3920 WILC_memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
3923 strWID.s32ValueSize = sizeof(u16) + 2;
3927 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3929 PRINT_ER("Failed to frame register config packet\n");
3930 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
3934 WILC_CATCH(s32Error)
3943 * @brief Handle_ListenStateExpired
3944 * @details Handle of listen state expiration
3946 * @return Error code.
3951 #define FALSE_FRMWR_CHANNEL 100
3952 static u32 Handle_ListenStateExpired(void *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan)
3954 u8 u8remain_on_chan_flag;
3956 s32 s32Error = WILC_SUCCESS;
3957 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3959 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
3962 /*Make sure we are already in listen state*/
3963 /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/
3964 if (P2P_LISTEN_STATE) {
3965 u8remain_on_chan_flag = false;
3966 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
3967 strWID.enuWIDtype = WID_STR;
3968 strWID.s32ValueSize = 2;
3969 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3971 if (strWID.ps8WidVal == NULL) {
3972 PRINT_ER("Failed to allocate memory\n");
3975 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
3976 strWID.ps8WidVal[1] = FALSE_FRMWR_CHANNEL;
3979 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3980 if (s32Error != WILC_SUCCESS) {
3981 PRINT_ER("Failed to set remain on channel\n");
3985 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired) {
3986 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired(pstrWFIDrv->strHostIfRemainOnChan.pVoid
3987 , pstrHostIfRemainOnChan->u32ListenSessionID);
3989 P2P_LISTEN_STATE = 0;
3991 PRINT_D(GENERIC_DBG, "Not in listen state\n");
3992 s32Error = WILC_FAIL;
4001 * @brief ListenTimerCB
4002 * @details Callback function of remain-on-channel timer
4004 * @return Error code.
4009 static void ListenTimerCB(void *pvArg)
4011 s32 s32Error = WILC_SUCCESS;
4012 tstrHostIFmsg strHostIFmsg;
4013 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)pvArg;
4014 /*Stopping remain-on-channel timer*/
4015 WILC_TimerStop(&(pstrWFIDrv->hRemainOnChannel), NULL);
4017 /* prepare the Timer Callback message */
4018 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4019 strHostIFmsg.u16MsgId = HOST_IF_MSG_LISTEN_TIMER_FIRED;
4020 strHostIFmsg.drvHandler = pstrWFIDrv;
4021 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID;
4023 /* send the message */
4024 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4026 WILC_ERRORREPORT(s32Error, s32Error);
4028 WILC_CATCH(s32Error)
4037 * @brief Handle_EditStation
4038 * @details Sending config packet to edit station
4039 * @param[in] tstrWILC_AddStaParam* pstrStationParam
4045 static void Handle_PowerManagement(void *drvHandler, tstrHostIfPowerMgmtParam *strPowerMgmtParam)
4047 s32 s32Error = WILC_SUCCESS;
4050 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4051 strWID.u16WIDid = (u16)WID_POWER_MANAGEMENT;
4053 if (strPowerMgmtParam->bIsEnabled == true) {
4054 s8PowerMode = MIN_FAST_PS;
4056 s8PowerMode = NO_POWERSAVE;
4058 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
4059 strWID.ps8WidVal = &s8PowerMode;
4060 strWID.s32ValueSize = sizeof(char);
4062 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
4065 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4067 PRINT_ER("Failed to send power management config packet\n");
4068 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
4071 WILC_CATCH(s32Error)
4078 * @brief Handle_SetMulticastFilter
4079 * @details Set Multicast filter in firmware
4080 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4086 static void Handle_SetMulticastFilter(void *drvHandler, tstrHostIFSetMulti *strHostIfSetMulti)
4088 s32 s32Error = WILC_SUCCESS;
4092 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
4094 strWID.u16WIDid = (u16)WID_SETUP_MULTICAST_FILTER;
4095 strWID.enuWIDtype = WID_BIN;
4096 strWID.s32ValueSize = sizeof(tstrHostIFSetMulti) + ((strHostIfSetMulti->u32count) * ETH_ALEN);
4097 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
4098 if (strWID.ps8WidVal == NULL) {
4099 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
4102 pu8CurrByte = strWID.ps8WidVal;
4103 *pu8CurrByte++ = (strHostIfSetMulti->bIsEnabled & 0xFF);
4104 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 8) & 0xFF);
4105 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 16) & 0xFF);
4106 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 24) & 0xFF);
4108 *pu8CurrByte++ = (strHostIfSetMulti->u32count & 0xFF);
4109 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 8) & 0xFF);
4110 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 16) & 0xFF);
4111 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 24) & 0xFF);
4113 if ((strHostIfSetMulti->u32count) > 0)
4114 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->u32count) * ETH_ALEN));
4117 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)drvHandler);
4119 PRINT_ER("Failed to send setup multicast config packet\n");
4120 WILC_ERRORREPORT(s32Error, WILC_FAIL);
4123 WILC_CATCH(s32Error)
4126 WILC_FREE_IF_TRUE(strWID.ps8WidVal);
4133 * @brief Handle_AddBASession
4134 * @details Add block ack session
4135 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4137 * @author Amr Abdel-Moghny
4141 static s32 Handle_AddBASession(void *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
4143 s32 s32Error = WILC_SUCCESS;
4145 int AddbaTimeout = 100;
4147 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4149 PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x \nTID=%d \nBufferSize == %d \nSessionTimeOut = %d\n",
4150 strHostIfBASessionInfo->au8Bssid[0],
4151 strHostIfBASessionInfo->au8Bssid[1],
4152 strHostIfBASessionInfo->au8Bssid[2],
4153 strHostIfBASessionInfo->u16BufferSize,
4154 strHostIfBASessionInfo->u16SessionTimeout,
4155 strHostIfBASessionInfo->u8Ted);
4157 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
4158 strWID.enuWIDtype = WID_STR;
4159 strWID.ps8WidVal = (u8 *)WILC_MALLOC(BLOCK_ACK_REQ_SIZE);
4160 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4161 ptr = strWID.ps8WidVal;
4162 /* *ptr++ = 0x14; */
4166 WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4168 *ptr++ = strHostIfBASessionInfo->u8Ted;
4172 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
4173 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
4175 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
4176 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
4178 *ptr++ = (AddbaTimeout & 0xFF);
4179 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
4180 /* Group Buffer Max Frames*/
4182 /* Group Buffer Timeout */
4185 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4187 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
4190 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
4191 strWID.enuWIDtype = WID_STR;
4192 strWID.s32ValueSize = 15;
4193 ptr = strWID.ps8WidVal;
4194 /* *ptr++ = 0x14; */
4198 WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4201 *ptr++ = strHostIfBASessionInfo->u8Ted;
4205 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
4206 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
4209 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4211 if (strWID.ps8WidVal != NULL)
4212 WILC_FREE(strWID.ps8WidVal);
4221 * @brief Handle_DelBASession
4222 * @details Delete block ack session
4223 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4225 * @author Amr Abdel-Moghny
4229 static s32 Handle_DelBASession(void *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
4231 s32 s32Error = WILC_SUCCESS;
4234 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4236 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x \nTID=%d\n",
4237 strHostIfBASessionInfo->au8Bssid[0],
4238 strHostIfBASessionInfo->au8Bssid[1],
4239 strHostIfBASessionInfo->au8Bssid[2],
4240 strHostIfBASessionInfo->u8Ted);
4242 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
4243 strWID.enuWIDtype = WID_STR;
4244 strWID.ps8WidVal = (u8 *)WILC_MALLOC(BLOCK_ACK_REQ_SIZE);
4245 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4246 ptr = strWID.ps8WidVal;
4247 /* *ptr++ = 0x14; */
4251 WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4253 *ptr++ = strHostIfBASessionInfo->u8Ted;
4254 /* BA direction = recipent*/
4257 *ptr++ = 32; /* Unspecific QOS reason */
4259 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4261 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
4264 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
4265 strWID.enuWIDtype = WID_STR;
4266 strWID.s32ValueSize = 15;
4267 ptr = strWID.ps8WidVal;
4268 /* *ptr++ = 0x14; */
4272 WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4275 *ptr++ = strHostIfBASessionInfo->u8Ted;
4277 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4279 if (strWID.ps8WidVal != NULL)
4280 WILC_FREE(strWID.ps8WidVal);
4291 * @brief Handle_DelAllRxBASessions
4292 * @details Delete all Rx BA sessions
4293 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4295 * @author Abdelrahman Sobhy
4299 static s32 Handle_DelAllRxBASessions(void *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
4301 s32 s32Error = WILC_SUCCESS;
4304 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4306 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x \nTID=%d\n",
4307 strHostIfBASessionInfo->au8Bssid[0],
4308 strHostIfBASessionInfo->au8Bssid[1],
4309 strHostIfBASessionInfo->au8Bssid[2],
4310 strHostIfBASessionInfo->u8Ted);
4312 strWID.u16WIDid = (u16)WID_DEL_ALL_RX_BA;
4313 strWID.enuWIDtype = WID_STR;
4314 strWID.ps8WidVal = (u8 *)WILC_MALLOC(BLOCK_ACK_REQ_SIZE);
4315 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4316 ptr = strWID.ps8WidVal;
4320 WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4322 *ptr++ = strHostIfBASessionInfo->u8Ted;
4323 /* BA direction = recipent*/
4326 *ptr++ = 32; /* Unspecific QOS reason */
4328 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4330 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
4333 if (strWID.ps8WidVal != NULL)
4334 WILC_FREE(strWID.ps8WidVal);
4344 * @brief hostIFthread
4345 * @details Main thread to handle message queue requests
4346 * @param[in] void* pvArg
4352 static int hostIFthread(void *pvArg)
4355 tstrHostIFmsg strHostIFmsg;
4356 tstrWILC_WFIDrv *pstrWFIDrv;
4358 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4361 WILC_MsgQueueRecv(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), &u32Ret, NULL);
4362 pstrWFIDrv = (tstrWILC_WFIDrv *)strHostIFmsg.drvHandler;
4363 if (strHostIFmsg.u16MsgId == HOST_IF_MSG_EXIT) {
4364 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
4369 /*Re-Queue HIF message*/
4370 if ((!g_wilc_initialized)) {
4371 PRINT_D(GENERIC_DBG, "--WAIT--");
4373 WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4377 if (strHostIFmsg.u16MsgId == HOST_IF_MSG_CONNECT && pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
4378 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
4379 WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4384 switch (strHostIFmsg.u16MsgId) {
4385 case HOST_IF_MSG_Q_IDLE:
4386 Handle_wait_msg_q_empty();
4389 case HOST_IF_MSG_SCAN:
4390 Handle_Scan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr);
4393 case HOST_IF_MSG_CONNECT:
4394 Handle_Connect(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr);
4398 case HOST_IF_MSG_FLUSH_CONNECT:
4399 Handle_FlushConnect(strHostIFmsg.drvHandler);
4402 case HOST_IF_MSG_RCVD_NTWRK_INFO:
4403 Handle_RcvdNtwrkInfo(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo);
4406 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
4407 Handle_RcvdGnrlAsyncInfo(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo);
4410 case HOST_IF_MSG_KEY:
4411 Handle_Key(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr);
4414 case HOST_IF_MSG_CFG_PARAMS:
4416 Handle_CfgParam(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFCfgParamAttr);
4419 case HOST_IF_MSG_SET_CHANNEL:
4420 Handle_SetChannel(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFSetChan);
4423 case HOST_IF_MSG_DISCONNECT:
4424 Handle_Disconnect(strHostIFmsg.drvHandler);
4427 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
4428 WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL);
4429 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
4432 /*Allow chip sleep, only if both interfaces are not connected*/
4433 if (!linux_wlan_get_num_conn_ifcs()) {
4434 chip_sleep_manually(INFINITE_SLEEP_TIME);
4437 Handle_ScanDone(strHostIFmsg.drvHandler, SCAN_EVENT_DONE);
4440 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
4441 Handle_RemainOnChan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
4446 case HOST_IF_MSG_GET_RSSI:
4447 Handle_GetRssi(strHostIFmsg.drvHandler);
4450 case HOST_IF_MSG_GET_LINKSPEED:
4451 Handle_GetLinkspeed(strHostIFmsg.drvHandler);
4454 case HOST_IF_MSG_GET_STATISTICS:
4455 Handle_GetStatistics(strHostIFmsg.drvHandler, (tstrStatistics *)strHostIFmsg.uniHostIFmsgBody.pUserData);
4458 case HOST_IF_MSG_GET_CHNL:
4459 Handle_GetChnl(strHostIFmsg.drvHandler);
4462 #ifdef WILC_AP_EXTERNAL_MLME
4463 case HOST_IF_MSG_ADD_BEACON:
4464 Handle_AddBeacon(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFSetBeacon);
4467 case HOST_IF_MSG_DEL_BEACON:
4468 Handle_DelBeacon(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFDelBeacon);
4471 case HOST_IF_MSG_ADD_STATION:
4472 Handle_AddStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strAddStaParam);
4475 case HOST_IF_MSG_DEL_STATION:
4476 Handle_DelStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strDelStaParam);
4479 case HOST_IF_MSG_EDIT_STATION:
4480 Handle_EditStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strEditStaParam);
4483 case HOST_IF_MSG_GET_INACTIVETIME:
4484 Handle_Get_InActiveTime(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfStaInactiveT);
4487 #endif /*WILC_AP_EXTERNAL_MLME*/
4488 case HOST_IF_MSG_SCAN_TIMER_FIRED:
4489 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
4491 Handle_ScanDone(strHostIFmsg.drvHandler, SCAN_EVENT_ABORTED);
4494 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
4495 PRINT_D(HOSTINF_DBG, "Connect Timeout \n");
4496 Handle_ConnectTimeout(strHostIFmsg.drvHandler);
4499 case HOST_IF_MSG_POWER_MGMT:
4500 Handle_PowerManagement(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strPowerMgmtparam);
4503 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
4504 Handle_SetWfiDrvHandler(&strHostIFmsg.uniHostIFmsgBody.strHostIfSetDrvHandler);
4507 case HOST_IF_MSG_SET_OPERATION_MODE:
4508 Handle_SetOperationMode(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetOperationMode);
4511 case HOST_IF_MSG_SET_IPADDRESS:
4512 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
4513 Handle_set_IPAddress(strHostIFmsg.drvHandler, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx);
4516 case HOST_IF_MSG_GET_IPADDRESS:
4517 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
4518 Handle_get_IPAddress(strHostIFmsg.drvHandler, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx);
4522 case HOST_IF_MSG_SET_MAC_ADDRESS:
4523 Handle_SetMacAddress(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMacAddress);
4527 case HOST_IF_MSG_GET_MAC_ADDRESS:
4528 Handle_GetMacAddress(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfGetMacAddress);
4532 case HOST_IF_MSG_REMAIN_ON_CHAN:
4533 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
4534 Handle_RemainOnChan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
4537 case HOST_IF_MSG_REGISTER_FRAME:
4538 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
4539 Handle_RegisterFrame(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame);
4542 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
4543 Handle_ListenStateExpired(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
4547 case HOST_IF_MSG_SET_MULTICAST_FILTER:
4548 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
4549 Handle_SetMulticastFilter(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMulti);
4553 case HOST_IF_MSG_ADD_BA_SESSION:
4554 Handle_AddBASession(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo);
4557 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
4558 Handle_DelAllRxBASessions(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo);
4561 case HOST_IF_MSG_DEL_ALL_STA:
4562 Handle_DelAllSta(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFDelAllSta);
4566 PRINT_ER("[Host Interface] undefined Received Msg ID \n");
4571 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
4572 up(&hSemHostIFthrdEnd);
4576 static void TimerCB_Scan(void *pvArg)
4578 tstrHostIFmsg strHostIFmsg;
4580 /* prepare the Timer Callback message */
4581 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4582 strHostIFmsg.drvHandler = pvArg;
4583 strHostIFmsg.u16MsgId = HOST_IF_MSG_SCAN_TIMER_FIRED;
4585 /* send the message */
4586 WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4589 static void TimerCB_Connect(void *pvArg)
4591 tstrHostIFmsg strHostIFmsg;
4593 /* prepare the Timer Callback message */
4594 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4595 strHostIFmsg.drvHandler = pvArg;
4596 strHostIFmsg.u16MsgId = HOST_IF_MSG_CONNECT_TIMER_FIRED;
4598 /* send the message */
4599 WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4604 * @brief removes wpa/wpa2 keys
4605 * @details only in BSS STA mode if External Supplicant support is enabled.
4606 * removes all WPA/WPA2 station key entries from MAC hardware.
4607 * @param[in,out] handle to the wifi driver
4608 * @param[in] 6 bytes of Station Adress in the station entry table
4609 * @return Error code indicating success/failure
4612 * @date 8 March 2012
4615 /* Check implementation in core adding 9 bytes to the input! */
4616 s32 host_int_remove_key(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8StaAddress)
4618 s32 s32Error = WILC_SUCCESS;
4620 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4622 strWID.u16WIDid = (u16)WID_REMOVE_KEY;
4623 strWID.enuWIDtype = WID_STR;
4624 strWID.ps8WidVal = (s8 *)pu8StaAddress;
4625 strWID.s32ValueSize = 6;
4632 * @brief removes WEP key
4633 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4634 * remove a WEP key entry from MAC HW.
4635 * The BSS Station automatically finds the index of the entry using its
4636 * BSS ID and removes that entry from the MAC hardware.
4637 * @param[in,out] handle to the wifi driver
4638 * @param[in] 6 bytes of Station Adress in the station entry table
4639 * @return Error code indicating success/failure
4640 * @note NO need for the STA add since it is not used for processing
4642 * @date 8 March 2012
4645 s32 host_int_remove_wep_key(WILC_WFIDrvHandle hWFIDrv, u8 u8keyIdx)
4647 s32 s32Error = WILC_SUCCESS;
4648 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4649 tstrHostIFmsg strHostIFmsg;
4652 if (pstrWFIDrv == NULL) {
4653 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4656 /* prepare the Remove Wep Key Message */
4657 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4660 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4661 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4662 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = REMOVEKEY;
4663 strHostIFmsg.drvHandler = hWFIDrv;
4667 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4668 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8keyIdx;
4670 /* send the message */
4671 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4673 PRINT_ER("Error in sending message queue : Request to remove WEP key \n");
4674 down(&(pstrWFIDrv->hSemTestKeyBlock));
4676 WILC_CATCH(s32Error)
4684 * @brief sets WEP default key
4685 * @details Sets the index of the WEP encryption key in use,
4687 * @param[in,out] handle to the wifi driver
4688 * @param[in] key index ( 0, 1, 2, 3)
4689 * @return Error code indicating success/failure
4692 * @date 8 March 2012
4695 s32 host_int_set_WEPDefaultKeyID(WILC_WFIDrvHandle hWFIDrv, u8 u8Index)
4697 s32 s32Error = WILC_SUCCESS;
4698 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4699 tstrHostIFmsg strHostIFmsg;
4702 if (pstrWFIDrv == NULL) {
4703 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4706 /* prepare the Key Message */
4707 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4710 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4711 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4712 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = DEFAULTKEY;
4713 strHostIFmsg.drvHandler = hWFIDrv;
4716 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4717 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Index;
4719 /* send the message */
4720 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4722 PRINT_ER("Error in sending message queue : Default key index\n");
4723 down(&(pstrWFIDrv->hSemTestKeyBlock));
4725 WILC_CATCH(s32Error)
4734 * @brief sets WEP deafault key
4735 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4736 * sets WEP key entry into MAC hardware when it receives the
4737 * corresponding request from NDIS.
4738 * @param[in,out] handle to the wifi driver
4739 * @param[in] message containing WEP Key in the following format
4740 *|---------------------------------------|
4741 *|Key ID Value | Key Length | Key |
4742 *|-------------|------------|------------|
4743 | 1byte | 1byte | Key Length |
4744 ||---------------------------------------|
4746 * @return Error code indicating success/failure
4749 * @date 8 March 2012
4752 s32 host_int_add_wep_key_bss_sta(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx)
4755 s32 s32Error = WILC_SUCCESS;
4756 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4757 tstrHostIFmsg strHostIFmsg;
4759 if (pstrWFIDrv == NULL) {
4760 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4764 /* prepare the Key Message */
4765 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4768 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4769 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4770 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
4771 strHostIFmsg.drvHandler = hWFIDrv;
4774 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4775 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = (u8 *)WILC_MALLOC(u8WepKeylen);
4777 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
4778 pu8WepKey, u8WepKeylen);
4781 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4782 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4784 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4785 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4787 /* send the message */
4788 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4790 PRINT_ER("Error in sending message queue :WEP Key\n");
4791 down(&(pstrWFIDrv->hSemTestKeyBlock));
4793 WILC_CATCH(s32Error)
4801 #ifdef WILC_AP_EXTERNAL_MLME
4804 * @brief host_int_add_wep_key_bss_ap
4805 * @details valid only in BSS AP mode if External Supplicant support is enabled.
4806 * sets WEP key entry into MAC hardware when it receives the
4808 * corresponding request from NDIS.
4809 * @param[in,out] handle to the wifi driver
4812 * @return Error code indicating success/failure
4818 s32 host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx, u8 u8mode, AUTHTYPE_T tenuAuth_type)
4821 s32 s32Error = WILC_SUCCESS;
4822 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4823 tstrHostIFmsg strHostIFmsg;
4826 if (pstrWFIDrv == NULL) {
4827 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4831 /* prepare the Key Message */
4832 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4835 for (i = 0; i < u8WepKeylen; i++)
4836 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
4838 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4839 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4840 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
4841 strHostIFmsg.drvHandler = hWFIDrv;
4844 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4845 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = (u8 *)WILC_MALLOC((u8WepKeylen));
4848 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
4849 pu8WepKey, (u8WepKeylen));
4852 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4853 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4855 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4856 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4858 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4859 uniHostIFkeyAttr.strHostIFwepAttr.u8mode = u8mode;
4861 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4862 uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type = tenuAuth_type;
4863 /* send the message */
4864 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4867 PRINT_ER("Error in sending message queue :WEP Key\n");
4868 down(&(pstrWFIDrv->hSemTestKeyBlock));
4870 WILC_CATCH(s32Error)
4879 * @brief adds ptk Key
4881 * @param[in,out] handle to the wifi driver
4882 * @param[in] message containing PTK Key in the following format
4883 *|-----------------------------------------------------------------------------|
4884 *|Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
4885 *|----------------|------------|--------------|----------------|---------------|
4886 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
4887 ||-----------------------------------------------------------------------------|
4888 * @return Error code indicating success/failure
4891 * @date 8 March 2012
4894 s32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen,
4895 const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode, u8 u8Idx)
4897 s32 s32Error = WILC_SUCCESS;
4898 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4899 tstrHostIFmsg strHostIFmsg;
4900 u8 u8KeyLen = u8PtkKeylen;
4902 if (pstrWFIDrv == NULL) {
4903 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4905 if (pu8RxMic != NULL) {
4906 u8KeyLen += RX_MIC_KEY_LEN;
4908 if (pu8TxMic != NULL) {
4909 u8KeyLen += TX_MIC_KEY_LEN;
4912 /* prepare the Key Message */
4913 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4916 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4917 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WPAPtk;
4918 #ifdef WILC_AP_EXTERNAL_MLME
4919 if (mode == AP_MODE) {
4920 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
4921 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4922 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8Idx;
4925 if (mode == STATION_MODE)
4926 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
4929 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4930 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = (u8 *)WILC_MALLOC(u8PtkKeylen);
4933 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
4934 pu8Ptk, u8PtkKeylen);
4936 if (pu8RxMic != NULL) {
4938 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
4939 pu8RxMic, RX_MIC_KEY_LEN);
4941 for (i = 0; i < RX_MIC_KEY_LEN; i++)
4942 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
4945 if (pu8TxMic != NULL) {
4947 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
4948 pu8TxMic, TX_MIC_KEY_LEN);
4950 for (i = 0; i < TX_MIC_KEY_LEN; i++)
4951 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
4955 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4956 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
4958 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4959 uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
4960 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4961 uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr = mac_addr;
4962 strHostIFmsg.drvHandler = hWFIDrv;
4964 /* send the message */
4965 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
4968 PRINT_ER("Error in sending message queue: PTK Key\n");
4970 /* ////////////// */
4971 down(&(pstrWFIDrv->hSemTestKeyBlock));
4972 /* WILC_Sleep(100); */
4975 WILC_CATCH(s32Error)
4984 * @brief adds Rx GTk Key
4986 * @param[in,out] handle to the wifi driver
4987 * @param[in] pu8RxGtk : contains temporal key | Rx Mic | Tx Mic
4988 * u8GtkKeylen :The total key length
4990 * @return Error code indicating success/failure
4993 * @date 8 March 2012
4996 s32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen,
4997 u8 u8KeyIdx, u32 u32KeyRSClen, const u8 *KeyRSC,
4998 const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode)
5000 s32 s32Error = WILC_SUCCESS;
5001 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5002 tstrHostIFmsg strHostIFmsg;
5003 u8 u8KeyLen = u8GtkKeylen;
5005 if (pstrWFIDrv == NULL) {
5006 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5008 /* prepare the Key Message */
5009 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5012 if (pu8RxMic != NULL) {
5013 u8KeyLen += RX_MIC_KEY_LEN;
5015 if (pu8TxMic != NULL) {
5016 u8KeyLen += TX_MIC_KEY_LEN;
5018 if (KeyRSC != NULL) {
5019 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5020 uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq = (u8 *)WILC_MALLOC(u32KeyRSClen);
5022 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq,
5023 KeyRSC, u32KeyRSClen);
5027 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
5028 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WPARxGtk;
5029 strHostIFmsg.drvHandler = hWFIDrv;
5031 #ifdef WILC_AP_EXTERNAL_MLME
5032 if (mode == AP_MODE) {
5033 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
5034 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
5037 if (mode == STATION_MODE)
5038 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
5041 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5042 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = (u8 *)WILC_MALLOC(u8KeyLen);
5044 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
5045 pu8RxGtk, u8GtkKeylen);
5047 if (pu8RxMic != NULL) {
5049 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
5050 pu8RxMic, RX_MIC_KEY_LEN);
5053 if (pu8TxMic != NULL) {
5055 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
5056 pu8TxMic, TX_MIC_KEY_LEN);
5060 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5061 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8KeyIdx;
5062 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5063 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
5065 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5066 uniHostIFkeyAttr.strHostIFwpaAttr.u8seqlen = u32KeyRSClen;
5070 /* send the message */
5071 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5073 PRINT_ER("Error in sending message queue: RX GTK\n");
5074 /* ////////////// */
5075 down(&(pstrWFIDrv->hSemTestKeyBlock));
5076 /* WILC_Sleep(100); */
5079 WILC_CATCH(s32Error)
5087 * @brief host_int_set_pmkid_info
5088 * @details caches the pmkid valid only in BSS STA mode if External Supplicant
5089 * support is enabled. This Function sets the PMKID in firmware
5090 * when host drivr receives the corresponding request from NDIS.
5091 * The firmware then includes theset PMKID in the appropriate
5093 * @param[in,out] handle to the wifi driver
5094 * @param[in] message containing PMKID Info in the following format
5095 *|-----------------------------------------------------------------|
5096 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
5097 *|-----------|------------|----------|-------|----------|----------|
5098 | 1 | 6 | 16 | ... | 6 | 16 |
5099 ||-----------------------------------------------------------------|
5100 * @return Error code indicating success/failure
5103 * @date 8 March 2012
5106 s32 host_int_set_pmkid_info(WILC_WFIDrvHandle hWFIDrv, tstrHostIFpmkidAttr *pu8PmkidInfoArray)
5108 s32 s32Error = WILC_SUCCESS;
5109 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5110 tstrHostIFmsg strHostIFmsg;
5114 if (pstrWFIDrv == NULL) {
5115 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5118 /* prepare the Key Message */
5119 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5121 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
5122 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = PMKSA;
5123 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
5124 strHostIFmsg.drvHandler = hWFIDrv;
5126 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
5128 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
5131 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
5135 /* send the message */
5136 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5138 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
5140 WILC_CATCH(s32Error)
5149 * @brief gets the cached the pmkid info
5150 * @details valid only in BSS STA mode if External Supplicant
5151 * support is enabled. This Function sets the PMKID in firmware
5152 * when host drivr receives the corresponding request from NDIS.
5153 * The firmware then includes theset PMKID in the appropriate
5155 * @param[in,out] handle to the wifi driver,
5156 * message containing PMKID Info in the following format
5157 *|-----------------------------------------------------------------|
5158 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
5159 *|-----------|------------|----------|-------|----------|----------|
5160 | 1 | 6 | 16 | ... | 6 | 16 |
5161 ||-----------------------------------------------------------------|
5163 * @return Error code indicating success/failure
5166 * @date 8 March 2012
5169 s32 host_int_get_pmkid_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PmkidInfoArray,
5170 u32 u32PmkidInfoLen)
5172 s32 s32Error = WILC_SUCCESS;
5174 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5176 strWID.u16WIDid = (u16)WID_PMKID_INFO;
5177 strWID.enuWIDtype = WID_STR;
5178 strWID.s32ValueSize = u32PmkidInfoLen;
5179 strWID.ps8WidVal = pu8PmkidInfoArray;
5185 * @brief sets the pass phrase
5186 * @details AP/STA mode. This function gives the pass phrase used to
5187 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5188 * The length of the field can vary from 8 to 64 bytes,
5189 * the lower layer should get the
5190 * @param[in,out] handle to the wifi driver,
5191 * @param[in] String containing PSK
5192 * @return Error code indicating success/failure
5195 * @date 8 March 2012
5198 s32 host_int_set_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PassPhrase,
5201 s32 s32Error = WILC_SUCCESS;
5203 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5205 /* u8 u8Psklength = WILC_strlen(pu8PassPhrase); */
5206 /*validating psk length*/
5207 if ((u8Psklength > 7) && (u8Psklength < 65)) {
5208 strWID.u16WIDid = (u16)WID_11I_PSK;
5209 strWID.enuWIDtype = WID_STR;
5210 strWID.ps8WidVal = pu8PassPhrase;
5211 strWID.s32ValueSize = u8Psklength;
5217 * @brief host_int_get_MacAddress
5218 * @details gets mac address
5219 * @param[in,out] handle to the wifi driver,
5221 * @return Error code indicating success/failure
5224 * @date 19 April 2012
5227 s32 host_int_get_MacAddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8MacAddress)
5229 s32 s32Error = WILC_SUCCESS;
5230 tstrHostIFmsg strHostIFmsg;
5233 /* prepare the Message */
5234 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5236 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_MAC_ADDRESS;
5237 strHostIFmsg.uniHostIFmsgBody.strHostIfGetMacAddress.u8MacAddress = pu8MacAddress;
5238 strHostIFmsg.drvHandler = hWFIDrv;
5239 /* send the message */
5240 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5242 PRINT_ER("Failed to send get mac address\n");
5246 down(&hWaitResponse);
5251 * @brief host_int_set_MacAddress
5252 * @details sets mac address
5253 * @param[in,out] handle to the wifi driver,
5255 * @return Error code indicating success/failure
5258 * @date 16 July 2012
5261 s32 host_int_set_MacAddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8MacAddress)
5263 s32 s32Error = WILC_SUCCESS;
5264 tstrHostIFmsg strHostIFmsg;
5266 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
5268 /* prepare setting mac address message */
5269 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5270 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_MAC_ADDRESS;
5271 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIfSetMacAddress.u8MacAddress, pu8MacAddress, ETH_ALEN);
5272 strHostIFmsg.drvHandler = hWFIDrv;
5274 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5276 PRINT_ER("Failed to send message queue: Set mac address\n");
5277 WILC_ERRORREPORT(s32Error, s32Error);
5279 WILC_CATCH(s32Error)
5289 * @brief host_int_get_RSNAConfigPSKPassPhrase
5290 * @details gets the pass phrase:AP/STA mode. This function gets the pass phrase used to
5291 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5292 * The length of the field can vary from 8 to 64 bytes,
5293 * the lower layer should get the
5294 * @param[in,out] handle to the wifi driver,
5295 * String containing PSK
5296 * @return Error code indicating success/failure
5299 * @date 8 March 2012
5302 s32 host_int_get_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv,
5303 u8 *pu8PassPhrase, u8 u8Psklength)
5305 s32 s32Error = WILC_SUCCESS;
5307 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5309 strWID.u16WIDid = (u16)WID_11I_PSK;
5310 strWID.enuWIDtype = WID_STR;
5311 strWID.s32ValueSize = u8Psklength;
5312 strWID.ps8WidVal = pu8PassPhrase;
5318 * @brief host_int_get_site_survey_results
5319 * @details gets the site survey results
5320 * @param[in,out] handle to the wifi driver,
5321 * Message containing site survey results in the
5323 *|---------------------------------------------------|
5324 | MsgLength | fragNo. | MsgBodyLength | MsgBody |
5325 ||-----------|-----------|---------------|-----------|
5327 | ----------------------------------------- | ----------------
5329 ||---------------------------------------|
5330 | Network1 | Netweork2 | ... | Network5 |
5331 ||---------------------------------------|
5332 | 44 | 44 | ... | 44 |
5333 | -------------------------- | ---------------------------------------
5335 ||---------------------------------------------------------------------|
5336 | SSID | BSS Type | Channel | Security Status| BSSID | RSSI |Reserved |
5339 ||------|----------|---------|----------------|-------|------|---------|
5340 | 33 | 1 | 1 | 1 | 6 | 1 | 1 |
5341 ||---------------------------------------------------------------------|
5342 * @return Error code indicating success/failure
5345 * @date 8 March 2012
5348 #ifndef CONNECT_DIRECT
5349 s32 host_int_get_site_survey_results(WILC_WFIDrvHandle hWFIDrv,
5350 u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE],
5351 u32 u32MaxSiteSrvyFragLen)
5353 s32 s32Error = WILC_SUCCESS;
5354 tstrWID astrWIDList[2];
5355 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5357 astrWIDList[0].u16WIDid = (u16)WID_SITE_SURVEY_RESULTS;
5358 astrWIDList[0].enuWIDtype = WID_STR;
5359 astrWIDList[0].ps8WidVal = ppu8RcvdSiteSurveyResults[0];
5360 astrWIDList[0].s32ValueSize = u32MaxSiteSrvyFragLen;
5362 astrWIDList[1].u16WIDid = (u16)WID_SITE_SURVEY_RESULTS;
5363 astrWIDList[1].enuWIDtype = WID_STR;
5364 astrWIDList[1].ps8WidVal = ppu8RcvdSiteSurveyResults[1];
5365 astrWIDList[1].s32ValueSize = u32MaxSiteSrvyFragLen;
5367 s32Error = SendConfigPkt(GET_CFG, astrWIDList, 2, true, (u32)pstrWFIDrv);
5369 /*get the value by searching the local copy*/
5371 PRINT_ER("Failed to send config packet to get survey results\n");
5372 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
5375 WILC_CATCH(s32Error)
5385 * @brief sets a start scan request
5387 * @param[in,out] handle to the wifi driver,
5388 * @param[in] Scan Source one of the following values
5391 * OBSS_PERIODIC_SCAN BIT1
5392 * OBSS_ONETIME_SCAN BIT2
5393 * @return Error code indicating success/failure
5396 * @date 8 March 2012
5399 s32 host_int_set_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 scanSource)
5401 s32 s32Error = WILC_SUCCESS;
5403 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5405 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
5406 strWID.enuWIDtype = WID_CHAR;
5407 strWID.ps8WidVal = (s8 *)&scanSource;
5408 strWID.s32ValueSize = sizeof(char);
5414 * @brief host_int_get_start_scan_req
5415 * @details gets a start scan request
5416 * @param[in,out] handle to the wifi driver,
5417 * @param[in] Scan Source one of the following values
5420 * OBSS_PERIODIC_SCAN BIT1
5421 * OBSS_ONETIME_SCAN BIT2
5422 * @return Error code indicating success/failure
5425 * @date 8 March 2012
5429 s32 host_int_get_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ScanSource)
5431 s32 s32Error = WILC_SUCCESS;
5433 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5435 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
5436 strWID.enuWIDtype = WID_CHAR;
5437 strWID.ps8WidVal = (s8 *)pu8ScanSource;
5438 strWID.s32ValueSize = sizeof(char);
5444 * @brief host_int_set_join_req
5445 * @details sets a join request
5446 * @param[in,out] handle to the wifi driver,
5447 * @param[in] Index of the bss descriptor
5448 * @return Error code indicating success/failure
5451 * @date 8 March 2012
5454 s32 host_int_set_join_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8bssid,
5455 const u8 *pu8ssid, size_t ssidLen,
5456 const u8 *pu8IEs, size_t IEsLen,
5457 tWILCpfConnectResult pfConnectResult, void *pvUserArg,
5458 u8 u8security, AUTHTYPE_T tenuAuth_type,
5462 s32 s32Error = WILC_SUCCESS;
5463 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5464 tstrHostIFmsg strHostIFmsg;
5465 tenuScanConnTimer enuScanConnTimer;
5467 if (pstrWFIDrv == NULL || pfConnectResult == NULL) {
5468 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5471 if (hWFIDrv == NULL) {
5472 PRINT_ER("Driver not initialized: gWFiDrvHandle = NULL\n");
5473 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5476 if (pJoinParams == NULL) {
5477 PRINT_ER("Unable to Join - JoinParams is NULL\n");
5478 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5482 * if(gWFiDrvHandle->strWILC_UsrScanReq.u32RcvdChCount == 0)
5484 * PRINT_ER("No scan results exist: Scanning should be done\n");
5485 * WILC_ERRORREPORT(s32Error, WILC_FAIL);
5488 /* prepare the Connect Message */
5489 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5491 strHostIFmsg.u16MsgId = HOST_IF_MSG_CONNECT;
5493 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.u8security = u8security;
5494 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.tenuAuth_type = tenuAuth_type;
5495 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.u8channel = u8channel;
5496 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pfConnectResult = pfConnectResult;
5497 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pvUserArg = pvUserArg;
5498 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pJoinParams = pJoinParams;
5499 strHostIFmsg.drvHandler = hWFIDrv;
5501 if (pu8bssid != NULL) {
5502 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8bssid = (u8 *)WILC_MALLOC(6); /* will be deallocated by the receiving thread */
5503 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8bssid,
5507 if (pu8ssid != NULL) {
5508 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.ssidLen = ssidLen;
5509 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8ssid = (u8 *)WILC_MALLOC(ssidLen); /* will be deallocated by the receiving thread */
5510 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8ssid,
5515 if (pu8IEs != NULL) {
5516 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.IEsLen = IEsLen;
5517 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8IEs = (u8 *)WILC_MALLOC(IEsLen); /* will be deallocated by the receiving thread */
5518 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8IEs,
5521 if (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTING) {
5522 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTING;
5524 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", pstrWFIDrv->enuHostIFstate);
5526 /* send the message */
5527 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5529 PRINT_ER("Failed to send message queue: Set join request\n");
5530 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5533 enuScanConnTimer = CONNECT_TIMER;
5534 WILC_TimerStart(&(pstrWFIDrv->hConnectTimer), HOST_IF_CONNECT_TIMEOUT, (void *) hWFIDrv, NULL);
5536 WILC_CATCH(s32Error)
5545 * @brief Flush a join request parameters to FW, but actual connection
5546 * @details The function is called in situation where WILC is connected to AP and
5547 * required to switch to hybrid FW for P2P connection
5548 * @param[in] handle to the wifi driver,
5549 * @return Error code indicating success/failure
5551 * @author Amr Abdel-Moghny
5556 s32 host_int_flush_join_req(WILC_WFIDrvHandle hWFIDrv)
5558 s32 s32Error = WILC_SUCCESS;
5559 tstrHostIFmsg strHostIFmsg;
5561 if (!gu8FlushedJoinReq) {
5562 s32Error = WILC_FAIL;
5567 if (hWFIDrv == NULL) {
5568 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5572 strHostIFmsg.u16MsgId = HOST_IF_MSG_FLUSH_CONNECT;
5573 strHostIFmsg.drvHandler = hWFIDrv;
5575 /* send the message */
5576 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5578 PRINT_ER("Failed to send message queue: Flush join request\n");
5579 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5582 WILC_CATCH(s32Error)
5590 * @brief host_int_disconnect
5591 * @details disconnects from the currently associated network
5592 * @param[in,out] handle to the wifi driver,
5593 * @param[in] Reason Code of the Disconnection
5594 * @return Error code indicating success/failure
5597 * @date 8 March 2012
5600 s32 host_int_disconnect(WILC_WFIDrvHandle hWFIDrv, u16 u16ReasonCode)
5602 s32 s32Error = WILC_SUCCESS;
5603 tstrHostIFmsg strHostIFmsg;
5604 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5606 if (pstrWFIDrv == NULL) {
5607 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
5608 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5611 if (pstrWFIDrv == NULL) {
5612 PRINT_ER("gWFiDrvHandle = NULL\n");
5613 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5616 /* prepare the Disconnect Message */
5617 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5619 strHostIFmsg.u16MsgId = HOST_IF_MSG_DISCONNECT;
5620 strHostIFmsg.drvHandler = hWFIDrv;
5622 /* send the message */
5623 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5625 PRINT_ER("Failed to send message queue: disconnect\n");
5626 /* ////////////// */
5627 down(&(pstrWFIDrv->hSemTestDisconnectBlock));
5630 WILC_CATCH(s32Error)
5639 * @brief host_int_disconnect_station
5640 * @details disconnects a sta
5641 * @param[in,out] handle to the wifi driver,
5642 * @param[in] Association Id of the station to be disconnected
5643 * @return Error code indicating success/failure
5646 * @date 8 March 2012
5649 s32 host_int_disconnect_station(WILC_WFIDrvHandle hWFIDrv, u8 assoc_id)
5651 s32 s32Error = WILC_SUCCESS;
5653 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5655 strWID.u16WIDid = (u16)WID_DISCONNECT;
5656 strWID.enuWIDtype = WID_CHAR;
5657 strWID.ps8WidVal = (s8 *)&assoc_id;
5658 strWID.s32ValueSize = sizeof(char);
5664 * @brief host_int_get_assoc_req_info
5665 * @details gets a Association request info
5666 * @param[in,out] handle to the wifi driver,
5667 * Message containg assoc. req info in the following format
5668 * ------------------------------------------------------------------------
5669 | Management Frame Format |
5670 ||-------------------------------------------------------------------|
5671 ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS |
5672 ||-------------|--------|--|--|-----|----------------|----------|----|
5673 | 2 |2 |6 |6 |6 | 2 |0 - 2312 | 4 |
5674 ||-------------------------------------------------------------------|
5676 | Association Request Frame - Frame Body |
5677 ||-------------------------------------------------------------------|
5678 | Capability Information | Listen Interval | SSID | Supported Rates |
5679 ||------------------------|-----------------|------|-----------------|
5680 | 2 | 2 | 2-34 | 3-10 |
5681 | ---------------------------------------------------------------------
5682 * @return Error code indicating success/failure
5685 * @date 8 March 2012
5689 s32 host_int_get_assoc_req_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocReqInfo,
5690 u32 u32AssocReqInfoLen)
5692 s32 s32Error = WILC_SUCCESS;
5694 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5696 strWID.u16WIDid = (u16)WID_ASSOC_REQ_INFO;
5697 strWID.enuWIDtype = WID_STR;
5698 strWID.ps8WidVal = pu8AssocReqInfo;
5699 strWID.s32ValueSize = u32AssocReqInfoLen;
5706 * @brief gets a Association Response info
5708 * @param[in,out] handle to the wifi driver,
5709 * Message containg assoc. resp info
5710 * @return Error code indicating success/failure
5713 * @date 8 March 2012
5716 s32 host_int_get_assoc_res_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocRespInfo,
5717 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
5719 s32 s32Error = WILC_SUCCESS;
5721 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5723 if (pstrWFIDrv == NULL) {
5724 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
5725 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5728 strWID.u16WIDid = (u16)WID_ASSOC_RES_INFO;
5729 strWID.enuWIDtype = WID_STR;
5730 strWID.ps8WidVal = pu8AssocRespInfo;
5731 strWID.s32ValueSize = u32MaxAssocRespInfoLen;
5734 /* Sending Configuration packet */
5735 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
5737 PRINT_ER("Failed to send association response config packet\n");
5738 *pu32RcvdAssocRespInfoLen = 0;
5739 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
5741 *pu32RcvdAssocRespInfoLen = strWID.s32ValueSize;
5744 WILC_CATCH(s32Error)
5752 * @brief gets a Association Response info
5753 * @details Valid only in STA mode. This function gives the RSSI
5754 * values observed in all the channels at the time of scanning.
5755 * The length of the field is 1 greater that the total number of
5756 * channels supported. Byte 0 contains the number of channels while
5757 * each of Byte N contains the observed RSSI value for the channel index N.
5758 * @param[in,out] handle to the wifi driver,
5759 * array of scanned channels' RSSI
5760 * @return Error code indicating success/failure
5763 * @date 8 March 2012
5766 s32 host_int_get_rx_power_level(WILC_WFIDrvHandle hWFIDrv, u8 *pu8RxPowerLevel,
5767 u32 u32RxPowerLevelLen)
5769 s32 s32Error = WILC_SUCCESS;
5771 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5773 strWID.u16WIDid = (u16)WID_RX_POWER_LEVEL;
5774 strWID.enuWIDtype = WID_STR;
5775 strWID.ps8WidVal = pu8RxPowerLevel;
5776 strWID.s32ValueSize = u32RxPowerLevelLen;
5783 * @brief sets a channel
5785 * @param[in,out] handle to the wifi driver,
5786 * @param[in] Index of the channel to be set
5787 *|-------------------------------------------------------------------|
5788 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5790 ||-------------------------------------------------------------------|
5791 * @return Error code indicating success/failure
5794 * @date 8 March 2012
5797 s32 host_int_set_mac_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 u8ChNum)
5799 s32 s32Error = WILC_SUCCESS;
5800 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5801 tstrHostIFmsg strHostIFmsg;
5803 if (pstrWFIDrv == NULL) {
5804 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5807 /* prepare the set channel message */
5808 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5809 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_CHANNEL;
5810 strHostIFmsg.uniHostIFmsgBody.strHostIFSetChan.u8SetChan = u8ChNum;
5811 strHostIFmsg.drvHandler = hWFIDrv;
5813 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5815 WILC_ERRORREPORT(s32Error, s32Error);
5817 WILC_CATCH(s32Error)
5826 s32 host_int_wait_msg_queue_idle(void)
5828 s32 s32Error = WILC_SUCCESS;
5830 tstrHostIFmsg strHostIFmsg;
5832 /* prepare the set driver handler message */
5834 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5835 strHostIFmsg.u16MsgId = HOST_IF_MSG_Q_IDLE;
5836 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5838 WILC_ERRORREPORT(s32Error, s32Error);
5840 WILC_CATCH(s32Error)
5845 /* wait untill MSG Q is empty */
5846 down(&hWaitResponse);
5852 s32 host_int_set_wfi_drv_handler(u32 u32address)
5854 s32 s32Error = WILC_SUCCESS;
5856 tstrHostIFmsg strHostIFmsg;
5859 /* prepare the set driver handler message */
5861 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5862 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_WFIDRV_HANDLER;
5863 strHostIFmsg.uniHostIFmsgBody.strHostIfSetDrvHandler.u32Address = u32address;
5864 /* strHostIFmsg.drvHandler=hWFIDrv; */
5866 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5868 WILC_ERRORREPORT(s32Error, s32Error);
5870 WILC_CATCH(s32Error)
5880 s32 host_int_set_operation_mode(WILC_WFIDrvHandle hWFIDrv, u32 u32mode)
5882 s32 s32Error = WILC_SUCCESS;
5884 tstrHostIFmsg strHostIFmsg;
5887 /* prepare the set driver handler message */
5889 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5890 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_OPERATION_MODE;
5891 strHostIFmsg.uniHostIFmsgBody.strHostIfSetOperationMode.u32Mode = u32mode;
5892 strHostIFmsg.drvHandler = hWFIDrv;
5894 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5896 WILC_ERRORREPORT(s32Error, s32Error);
5898 WILC_CATCH(s32Error)
5907 * @brief gets the current channel index
5909 * @param[in,out] handle to the wifi driver,
5910 * current channel index
5911 *|-----------------------------------------------------------------------|
5912 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5914 ||-----------------------------------------------------------------------|
5915 * @return Error code indicating success/failure
5918 * @date 8 March 2012
5921 s32 host_int_get_host_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ChNo)
5923 s32 s32Error = WILC_SUCCESS;
5924 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5925 tstrHostIFmsg strHostIFmsg;
5927 if (pstrWFIDrv == NULL) {
5928 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
5929 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5932 /* prepare the Get Channel Message */
5933 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5935 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_CHNL;
5936 strHostIFmsg.drvHandler = hWFIDrv;
5938 /* send the message */
5939 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
5941 PRINT_ER("Failed to send get host channel param's message queue ");
5942 down(&(pstrWFIDrv->hSemGetCHNL));
5947 WILC_CATCH(s32Error)
5958 * @brief host_int_test_set_int_wid
5959 * @details Test function for setting wids
5960 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr
5961 * @return Error code indicating success/failure
5964 * @date 8 March 2012
5967 s32 host_int_test_set_int_wid(WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr)
5969 s32 s32Error = WILC_SUCCESS;
5971 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5974 if (pstrWFIDrv == NULL) {
5975 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
5976 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5979 /*prepare configuration packet*/
5980 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
5981 strWID.enuWIDtype = WID_INT;
5982 strWID.ps8WidVal = (char *)&u32TestMemAddr;
5983 strWID.s32ValueSize = sizeof(u32);
5986 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
5988 PRINT_ER("Test Function: Failed to set wid value\n");
5989 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
5991 PRINT_D(HOSTINF_DBG, "Successfully set wid value\n");
5995 WILC_CATCH(s32Error)
6002 #ifdef WILC_AP_EXTERNAL_MLME
6004 * @brief host_int_get_inactive_time
6006 * @param[in,out] handle to the wifi driver,
6007 * current sta macaddress, inactive_time
6014 s32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, const u8 *mac, u32 *pu32InactiveTime)
6016 s32 s32Error = WILC_SUCCESS;
6017 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6018 tstrHostIFmsg strHostIFmsg;
6020 if (pstrWFIDrv == NULL) {
6021 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
6022 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6025 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6028 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIfStaInactiveT.mac,
6031 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_INACTIVETIME;
6032 strHostIFmsg.drvHandler = hWFIDrv;
6034 /* send the message */
6035 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6037 PRINT_ER("Failed to send get host channel param's message queue ");
6039 down(&(pstrWFIDrv->hSemInactiveTime));
6041 *pu32InactiveTime = gu32InactiveTime;
6043 WILC_CATCH(s32Error)
6051 * @brief host_int_test_get_int_wid
6052 * @details Test function for getting wids
6053 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32* pu32TestMemAddr
6054 * @return Error code indicating success/failure
6057 * @date 8 March 2012
6060 s32 host_int_test_get_int_wid(WILC_WFIDrvHandle hWFIDrv, u32 *pu32TestMemAddr)
6063 s32 s32Error = WILC_SUCCESS;
6065 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6068 if (pstrWFIDrv == NULL) {
6069 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
6070 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6073 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
6074 strWID.enuWIDtype = WID_INT;
6075 strWID.ps8WidVal = (s8 *)pu32TestMemAddr;
6076 strWID.s32ValueSize = sizeof(u32);
6078 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
6079 /*get the value by searching the local copy*/
6081 PRINT_ER("Test Function: Failed to get wid value\n");
6082 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
6084 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
6088 WILC_CATCH(s32Error)
6097 * @brief host_int_get_rssi
6098 * @details gets the currently maintained RSSI value for the station.
6099 * The received signal strength value in dB.
6100 * The range of valid values is -128 to 0.
6101 * @param[in,out] handle to the wifi driver,
6103 * @return Error code indicating success/failure
6106 * @date 8 March 2012
6109 s32 host_int_get_rssi(WILC_WFIDrvHandle hWFIDrv, s8 *ps8Rssi)
6111 s32 s32Error = WILC_SUCCESS;
6112 tstrHostIFmsg strHostIFmsg;
6113 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6116 /* prepare the Get RSSI Message */
6117 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6119 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_RSSI;
6120 strHostIFmsg.drvHandler = hWFIDrv;
6122 /* send the message */
6123 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6125 PRINT_ER("Failed to send get host channel param's message queue ");
6129 down(&(pstrWFIDrv->hSemGetRSSI));
6132 if (ps8Rssi == NULL) {
6133 PRINT_ER("RSS pointer value is null");
6144 s32 host_int_get_link_speed(WILC_WFIDrvHandle hWFIDrv, s8 *ps8lnkspd)
6146 tstrHostIFmsg strHostIFmsg;
6147 s32 s32Error = WILC_SUCCESS;
6149 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6153 /* prepare the Get LINKSPEED Message */
6154 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6156 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_LINKSPEED;
6157 strHostIFmsg.drvHandler = hWFIDrv;
6159 /* send the message */
6160 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6162 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
6166 down(&(pstrWFIDrv->hSemGetLINKSPEED));
6169 if (ps8lnkspd == NULL) {
6170 PRINT_ER("LINKSPEED pointer value is null");
6175 *ps8lnkspd = gs8lnkspd;
6181 s32 host_int_get_statistics(WILC_WFIDrvHandle hWFIDrv, tstrStatistics *pstrStatistics)
6183 s32 s32Error = WILC_SUCCESS;
6184 tstrHostIFmsg strHostIFmsg;
6187 /* prepare the Get RSSI Message */
6188 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6190 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_STATISTICS;
6191 strHostIFmsg.uniHostIFmsgBody.pUserData = (char *)pstrStatistics;
6192 strHostIFmsg.drvHandler = hWFIDrv;
6193 /* send the message */
6194 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6196 PRINT_ER("Failed to send get host channel param's message queue ");
6200 down(&hWaitResponse);
6206 * @brief host_int_scan
6207 * @details scans a set of channels
6208 * @param[in,out] handle to the wifi driver,
6209 * @param[in] Scan source
6210 * Scan Type PASSIVE_SCAN = 0,
6213 * Channels Array length
6214 * Scan Callback function
6215 * @return Error code indicating success/failure
6218 * @date 8 March 2012
6221 s32 host_int_scan(WILC_WFIDrvHandle hWFIDrv, u8 u8ScanSource,
6222 u8 u8ScanType, u8 *pu8ChnlFreqList,
6223 u8 u8ChnlListLen, const u8 *pu8IEs,
6224 size_t IEsLen, tWILCpfScanResult ScanResult,
6225 void *pvUserArg, tstrHiddenNetwork *pstrHiddenNetwork)
6227 s32 s32Error = WILC_SUCCESS;
6228 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6229 tstrHostIFmsg strHostIFmsg;
6230 tenuScanConnTimer enuScanConnTimer;
6232 if (pstrWFIDrv == NULL || ScanResult == NULL) {
6233 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6237 /* prepare the Scan Message */
6238 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6240 strHostIFmsg.u16MsgId = HOST_IF_MSG_SCAN;
6242 if (pstrHiddenNetwork != NULL) {
6243 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.strHiddenNetwork.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
6244 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.strHiddenNetwork.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
6247 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
6249 strHostIFmsg.drvHandler = hWFIDrv;
6250 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ScanSource = u8ScanSource;
6251 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ScanType = u8ScanType;
6252 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pfScanResult = ScanResult;
6253 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pvUserArg = pvUserArg;
6255 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ChnlListLen = u8ChnlListLen;
6256 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8ChnlFreqList = (u8 *)WILC_MALLOC(u8ChnlListLen); /* will be deallocated by the receiving thread */
6257 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8ChnlFreqList,
6258 pu8ChnlFreqList, u8ChnlListLen);
6260 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.IEsLen = IEsLen;
6261 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8IEs = (u8 *)WILC_MALLOC(IEsLen); /* will be deallocated by the receiving thread */
6262 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8IEs,
6265 /* send the message */
6266 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6268 PRINT_ER("Error in sending message queue scanning parameters: Error(%d)\n", s32Error);
6269 WILC_ERRORREPORT(s32Error, WILC_FAIL);
6272 enuScanConnTimer = SCAN_TIMER;
6273 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
6274 WILC_TimerStart(&(pstrWFIDrv->hScanTimer), HOST_IF_SCAN_TIMEOUT, (void *) hWFIDrv, NULL);
6277 WILC_CATCH(s32Error)
6285 * @brief hif_set_cfg
6286 * @details sets configuration wids values
6287 * @param[in,out] handle to the wifi driver,
6288 * @param[in] WID, WID value
6289 * @return Error code indicating success/failure
6292 * @date 8 March 2012
6295 s32 hif_set_cfg(WILC_WFIDrvHandle hWFIDrv, tstrCfgParamVal *pstrCfgParamVal)
6298 s32 s32Error = WILC_SUCCESS;
6299 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6301 tstrHostIFmsg strHostIFmsg;
6304 if (pstrWFIDrv == NULL) {
6305 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6307 /* prepare the WiphyParams Message */
6308 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6309 strHostIFmsg.u16MsgId = HOST_IF_MSG_CFG_PARAMS;
6310 strHostIFmsg.uniHostIFmsgBody.strHostIFCfgParamAttr.pstrCfgParamVal = *pstrCfgParamVal;
6311 strHostIFmsg.drvHandler = hWFIDrv;
6313 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6315 WILC_CATCH(s32Error)
6325 * @brief hif_get_cfg
6326 * @details gets configuration wids values
6327 * @param[in,out] handle to the wifi driver,
6330 * @return Error code indicating success/failure
6334 * @date 8 March 2012
6337 s32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, u16 u16WID, u16 *pu16WID_Value)
6339 s32 s32Error = WILC_SUCCESS;
6340 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6342 down(&(pstrWFIDrv->gtOsCfgValuesSem));
6344 if (pstrWFIDrv == NULL) {
6345 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
6346 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6348 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
6352 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.bss_type;
6356 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.auth_type;
6359 case WID_AUTH_TIMEOUT:
6360 *pu16WID_Value = pstrWFIDrv->strCfgValues.auth_timeout;
6363 case WID_POWER_MANAGEMENT:
6364 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.power_mgmt_mode;
6367 case WID_SHORT_RETRY_LIMIT:
6368 *pu16WID_Value = pstrWFIDrv->strCfgValues.short_retry_limit;
6371 case WID_LONG_RETRY_LIMIT:
6372 *pu16WID_Value = pstrWFIDrv->strCfgValues.long_retry_limit;
6375 case WID_FRAG_THRESHOLD:
6376 *pu16WID_Value = pstrWFIDrv->strCfgValues.frag_threshold;
6379 case WID_RTS_THRESHOLD:
6380 *pu16WID_Value = pstrWFIDrv->strCfgValues.rts_threshold;
6384 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.preamble_type;
6387 case WID_SHORT_SLOT_ALLOWED:
6388 *pu16WID_Value = (u16) pstrWFIDrv->strCfgValues.short_slot_allowed;
6391 case WID_11N_TXOP_PROT_DISABLE:
6392 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.txop_prot_disabled;
6395 case WID_BEACON_INTERVAL:
6396 *pu16WID_Value = pstrWFIDrv->strCfgValues.beacon_interval;
6399 case WID_DTIM_PERIOD:
6400 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.dtim_period;
6403 case WID_SITE_SURVEY:
6404 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.site_survey_enabled;
6407 case WID_SITE_SURVEY_SCAN_TIME:
6408 *pu16WID_Value = pstrWFIDrv->strCfgValues.site_survey_scan_time;
6411 case WID_ACTIVE_SCAN_TIME:
6412 *pu16WID_Value = pstrWFIDrv->strCfgValues.active_scan_time;
6415 case WID_PASSIVE_SCAN_TIME:
6416 *pu16WID_Value = pstrWFIDrv->strCfgValues.passive_scan_time;
6419 case WID_CURRENT_TX_RATE:
6420 *pu16WID_Value = pstrWFIDrv->strCfgValues.curr_tx_rate;
6427 up(&(pstrWFIDrv->gtOsCfgValuesSem));
6429 WILC_CATCH(s32Error)
6436 /*****************************************************************************/
6437 /* Notification Functions */
6438 /*****************************************************************************/
6440 * @brief notifies host with join and leave requests
6441 * @details This function prepares an Information frame having the
6442 * information about a joining/leaving station.
6443 * @param[in,out] handle to the wifi driver,
6444 * @param[in] 6 byte Sta Adress
6445 * Join or leave flag:
6448 * @return Error code indicating success/failure
6451 * @date 8 March 2012
6454 void host_int_send_join_leave_info_to_host
6455 (u16 assocId, u8 *stationAddr, bool joining)
6459 * @brief notifies host with stations found in scan
6460 * @details sends the beacon/probe response from scan
6461 * @param[in,out] handle to the wifi driver,
6462 * @param[in] Sta Address,
6464 * Rssi of the Station found
6465 * @return Error code indicating success/failure
6468 * @date 8 March 2012
6472 void GetPeriodicRSSI(void *pvArg)
6474 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)pvArg;
6475 if (pstrWFIDrv == NULL) {
6476 PRINT_ER("Driver handler is NULL\n");
6480 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
6481 s32 s32Error = WILC_SUCCESS;
6482 tstrHostIFmsg strHostIFmsg;
6484 /* prepare the Get RSSI Message */
6485 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6487 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_RSSI;
6488 strHostIFmsg.drvHandler = pstrWFIDrv;
6490 /* send the message */
6491 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6493 PRINT_ER("Failed to send get host channel param's message queue ");
6497 WILC_TimerStart(&(g_hPeriodicRSSI), 5000, (void *)pstrWFIDrv, NULL);
6501 void host_int_send_network_info_to_host
6502 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
6506 * @brief host_int_init
6507 * @details host interface initialization function
6508 * @param[in,out] handle to the wifi driver,
6511 * @date 8 March 2012
6514 static u32 u32Intialized;
6515 static u32 msgQ_created;
6516 static u32 clients_count;
6518 s32 host_int_init(WILC_WFIDrvHandle *phWFIDrv)
6520 s32 s32Error = WILC_SUCCESS;
6521 tstrWILC_WFIDrv *pstrWFIDrv;
6523 /*if(u32Intialized == 1)
6525 * PRINT_D(HOSTINF_DBG,"Host interface is previously initialized\n");
6526 * *phWFIDrv = (WILC_WFIDrvHandle)gWFiDrvHandle; //Will be adjusted later for P2P
6529 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
6531 gbScanWhileConnected = false;
6533 sema_init(&hWaitResponse, 0);
6537 /*Allocate host interface private structure*/
6538 pstrWFIDrv = (tstrWILC_WFIDrv *)WILC_MALLOC(sizeof(tstrWILC_WFIDrv));
6539 if (pstrWFIDrv == NULL) {
6540 /* WILC_ERRORREPORT(s32Error,WILC_NO_MEM); */
6541 s32Error = WILC_NO_MEM;
6542 PRINT_ER("Failed to allocate memory\n");
6545 WILC_memset(pstrWFIDrv, 0, sizeof(tstrWILC_WFIDrv));
6546 /*return driver handle to user*/
6547 *phWFIDrv = (WILC_WFIDrvHandle)pstrWFIDrv;
6548 /*save into globl handle*/
6550 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
6552 g_obtainingIP = false;
6555 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", pstrWFIDrv);
6556 /* /////////////////////////////////////// */
6557 if (clients_count == 0) {
6558 sema_init(&hSemHostIFthrdEnd, 0);
6559 sema_init(&hSemDeinitDrvHandle, 0);
6561 sema_init(&hSemHostIntDeinit, 1);
6564 sema_init(&(pstrWFIDrv->hSemTestKeyBlock), 0);
6565 sema_init(&(pstrWFIDrv->hSemTestDisconnectBlock), 0);
6566 sema_init(&(pstrWFIDrv->hSemGetRSSI), 0);
6567 sema_init(&(pstrWFIDrv->hSemGetLINKSPEED), 0);
6568 sema_init(&(pstrWFIDrv->hSemGetCHNL), 0);
6569 sema_init(&(pstrWFIDrv->hSemInactiveTime), 0);
6571 /* /////////////////////////////////////// */
6575 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
6577 if (clients_count == 0) {
6579 s32Error = WILC_MsgQueueCreate(&gMsgQHostIF, NULL);
6583 PRINT_ER("Failed to creat MQ\n");
6587 HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread");
6588 if (IS_ERR(HostIFthreadHandler)) {
6589 PRINT_ER("Failed to creat Thread\n");
6590 s32Error = WILC_FAIL;
6593 s32Error = WILC_TimerCreate(&(g_hPeriodicRSSI), GetPeriodicRSSI, NULL);
6595 PRINT_ER("Failed to creat Timer\n");
6598 WILC_TimerStart(&(g_hPeriodicRSSI), 5000, (void *)pstrWFIDrv, NULL);
6603 s32Error = WILC_TimerCreate(&(pstrWFIDrv->hScanTimer), TimerCB_Scan, NULL);
6605 PRINT_ER("Failed to creat Timer\n");
6609 s32Error = WILC_TimerCreate(&(pstrWFIDrv->hConnectTimer), TimerCB_Connect, NULL);
6611 PRINT_ER("Failed to creat Timer\n");
6617 /*Remain on channel timer*/
6618 s32Error = WILC_TimerCreate(&(pstrWFIDrv->hRemainOnChannel), ListenTimerCB, NULL);
6620 PRINT_ER("Failed to creat Remain-on-channel Timer\n");
6625 sema_init(&(pstrWFIDrv->gtOsCfgValuesSem), 1);
6626 down(&(pstrWFIDrv->gtOsCfgValuesSem));
6634 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
6635 /* gWFiDrvHandle->bPendingConnRequest = false; */
6637 /*Initialize CFG WIDS Defualt Values*/
6639 pstrWFIDrv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
6640 pstrWFIDrv->strCfgValues.scan_source = DEFAULT_SCAN;
6641 pstrWFIDrv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
6642 pstrWFIDrv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
6643 pstrWFIDrv->strCfgValues.curr_tx_rate = AUTORATE;
6648 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
6652 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",
6654 pstrWFIDrv->strCfgValues.site_survey_enabled, pstrWFIDrv->strCfgValues.scan_source,
6655 pstrWFIDrv->strCfgValues.active_scan_time, pstrWFIDrv->strCfgValues.passive_scan_time,
6656 pstrWFIDrv->strCfgValues.curr_tx_rate);
6659 up(&(pstrWFIDrv->gtOsCfgValuesSem));
6661 /*TODO Code to setup simulation to be removed later*/
6662 /*Intialize configurator module*/
6663 s32Error = CoreConfiguratorInit();
6665 PRINT_ER("Failed to initialize core configurator\n");
6670 /*Initialize Simulaor*/
6671 CoreConfigSimulatorInit();
6675 clients_count++; /* increase number of created entities */
6681 if (pstrWFIDrv != NULL)
6682 WILC_FREE(pstrWFIDrv);
6685 WILC_TimerDestroy(&(pstrWFIDrv->hRemainOnChannel), NULL);
6688 up(&(pstrWFIDrv->gtOsCfgValuesSem));
6689 WILC_TimerDestroy(&(pstrWFIDrv->hConnectTimer), NULL);
6691 WILC_TimerDestroy(&(pstrWFIDrv->hScanTimer), NULL);
6693 kthread_stop(HostIFthreadHandler);
6695 WILC_MsgQueueDestroy(&gMsgQHostIF, NULL);
6702 * @brief host_int_deinit
6703 * @details host interface initialization function
6704 * @param[in,out] handle to the wifi driver,
6707 * @date 8 March 2012
6711 s32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv)
6713 s32 s32Error = WILC_SUCCESS;
6714 tstrHostIFmsg strHostIFmsg;
6717 /*obtain driver handle*/
6718 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6719 /*if(u32Intialized == 0)
6721 * PRINT_ER("Host Interface is not initialized\n");
6727 if (pstrWFIDrv == NULL) {
6728 PRINT_ER("pstrWFIDrv = NULL\n");
6732 down(&hSemHostIntDeinit);
6734 terminated_handle = pstrWFIDrv;
6735 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
6738 /*Destroy all timers before acquiring hSemDeinitDrvHandle*/
6739 /*to guarantee handling all messages befor proceeding*/
6740 if (WILC_TimerDestroy(&(pstrWFIDrv->hScanTimer), NULL)) {
6741 PRINT_D(HOSTINF_DBG, ">> Scan timer is active \n");
6742 /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */
6745 if (WILC_TimerDestroy(&(pstrWFIDrv->hConnectTimer), NULL)) {
6746 PRINT_D(HOSTINF_DBG, ">> Connect timer is active \n");
6747 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6751 if (WILC_TimerDestroy(&(g_hPeriodicRSSI), NULL)) {
6752 PRINT_D(HOSTINF_DBG, ">> Connect timer is active \n");
6753 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6757 /*Destroy Remain-onchannel Timer*/
6758 WILC_TimerDestroy(&(pstrWFIDrv->hRemainOnChannel), NULL);
6761 host_int_set_wfi_drv_handler((u32)NULL);
6762 down(&hSemDeinitDrvHandle);
6765 /*Calling the CFG80211 scan done function with the abort flag set to true*/
6766 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
6767 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
6768 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
6770 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
6772 /*deinit configurator and simulator*/
6774 CoreConfigSimulatorDeInit();
6776 CoreConfiguratorDeInit();
6781 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
6783 gbScanWhileConnected = false;
6785 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6787 if (clients_count == 1) {
6788 if (WILC_TimerDestroy(&g_hPeriodicRSSI, NULL)) {
6789 PRINT_D(HOSTINF_DBG, ">> Connect timer is active \n");
6790 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6792 strHostIFmsg.u16MsgId = HOST_IF_MSG_EXIT;
6793 strHostIFmsg.drvHandler = hWFIDrv;
6796 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6797 if (s32Error != WILC_SUCCESS) {
6798 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
6801 down(&hSemHostIFthrdEnd);
6805 WILC_MsgQueueDestroy(&gMsgQHostIF, NULL);
6809 down(&(pstrWFIDrv->gtOsCfgValuesSem));
6811 /*Setting the gloabl driver handler with NULL*/
6813 /* gWFiDrvHandle = NULL; */
6814 if (pstrWFIDrv != NULL) {
6815 WILC_FREE(pstrWFIDrv);
6816 /* pstrWFIDrv=NULL; */
6820 clients_count--; /* Decrease number of created entities */
6821 terminated_handle = NULL;
6822 up(&hSemHostIntDeinit);
6828 * @brief NetworkInfoReceived
6829 * @details function to to be called when network info packet is received
6830 * @param[in] pu8Buffer the received packet
6831 * @param[in] u32Length length of the received packet
6838 void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
6840 s32 s32Error = WILC_SUCCESS;
6841 tstrHostIFmsg strHostIFmsg;
6843 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
6845 drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6846 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
6851 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
6852 PRINT_ER("NetworkInfo received but driver not init[%p]\n", pstrWFIDrv);
6856 /* prepare the Asynchronous Network Info message */
6857 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6859 strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_NTWRK_INFO;
6860 strHostIFmsg.drvHandler = pstrWFIDrv;
6862 strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.u32Length = u32Length;
6863 strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.pu8Buffer = (u8 *)WILC_MALLOC(u32Length); /* will be deallocated by the receiving thread */
6864 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.pu8Buffer,
6865 pu8Buffer, u32Length);
6867 /* send the message */
6868 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6870 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
6878 * @brief GnrlAsyncInfoReceived
6879 * @details function to be called when general Asynchronous info packet is received
6880 * @param[in] pu8Buffer the received packet
6881 * @param[in] u32Length length of the received packet
6888 void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
6890 s32 s32Error = WILC_SUCCESS;
6891 tstrHostIFmsg strHostIFmsg;
6893 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
6896 down(&hSemHostIntDeinit);
6898 drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6899 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
6900 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received \n");
6903 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
6904 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
6906 up(&hSemHostIntDeinit);
6910 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL) {
6911 /* received mac status is not needed when there is no current Connect Request */
6912 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
6914 up(&hSemHostIntDeinit);
6918 /* prepare the General Asynchronous Info message */
6919 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6922 strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
6923 strHostIFmsg.drvHandler = pstrWFIDrv;
6926 strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.u32Length = u32Length;
6927 strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.pu8Buffer = (u8 *)WILC_MALLOC(u32Length); /* will be deallocated by the receiving thread */
6928 WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.pu8Buffer,
6929 pu8Buffer, u32Length);
6931 /* send the message */
6932 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6934 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
6938 up(&hSemHostIntDeinit);
6943 * @brief host_int_ScanCompleteReceived
6944 * @details Setting scan complete received notifcation in message queue
6945 * @param[in] u8* pu8Buffer, u32 u32Length
6946 * @return Error code.
6951 void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
6953 s32 s32Error = WILC_SUCCESS;
6954 tstrHostIFmsg strHostIFmsg;
6956 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
6957 drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6958 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
6961 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", pstrWFIDrv);
6963 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
6967 /*if there is an ongoing scan request*/
6968 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
6969 /* prepare theScan Done message */
6970 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6972 strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
6973 strHostIFmsg.drvHandler = pstrWFIDrv;
6976 /* will be deallocated by the receiving thread */
6977 /*no need to send message body*/
6979 /*strHostIFmsg.uniHostIFmsgBody.strScanComplete.u32Length = u32Length;
6980 * strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer = (u8*)WILC_MALLOC(u32Length);
6981 * WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer,
6982 * pu8Buffer, u32Length); */
6984 /* send the message */
6985 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
6987 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
6998 * @brief host_int_remain_on_channel
7000 * @param[in] Handle to wifi driver
7001 * Duration to remain on channel
7002 * Channel to remain on
7003 * Pointer to fn to be called on receive frames in listen state
7004 * Pointer to remain-on-channel expired fn
7006 * @return Error code.
7011 s32 host_int_remain_on_channel(WILC_WFIDrvHandle hWFIDrv, u32 u32SessionID, u32 u32duration, u16 chan, tWILCpfRemainOnChanExpired RemainOnChanExpired, tWILCpfRemainOnChanReady RemainOnChanReady, void *pvUserArg)
7013 s32 s32Error = WILC_SUCCESS;
7014 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7015 tstrHostIFmsg strHostIFmsg;
7017 if (pstrWFIDrv == NULL) {
7018 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7021 /* prepare the remainonchan Message */
7022 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7024 /* prepare the WiphyParams Message */
7025 strHostIFmsg.u16MsgId = HOST_IF_MSG_REMAIN_ON_CHAN;
7026 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u16Channel = chan;
7027 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pRemainOnChanExpired = RemainOnChanExpired;
7028 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pRemainOnChanReady = RemainOnChanReady;
7029 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pVoid = pvUserArg;
7030 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32duration = u32duration;
7031 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
7032 strHostIFmsg.drvHandler = hWFIDrv;
7034 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7036 WILC_ERRORREPORT(s32Error, s32Error);
7038 WILC_CATCH(s32Error)
7047 * @brief host_int_ListenStateExpired
7049 * @param[in] Handle to wifi driver
7050 * Duration to remain on channel
7051 * Channel to remain on
7052 * Pointer to fn to be called on receive frames in listen state
7053 * Pointer to remain-on-channel expired fn
7055 * @return Error code.
7060 s32 host_int_ListenStateExpired(WILC_WFIDrvHandle hWFIDrv, u32 u32SessionID)
7062 s32 s32Error = WILC_SUCCESS;
7063 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7064 tstrHostIFmsg strHostIFmsg;
7066 if (pstrWFIDrv == NULL) {
7067 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7070 /*Stopping remain-on-channel timer*/
7071 WILC_TimerStop(&(pstrWFIDrv->hRemainOnChannel), NULL);
7073 /* prepare the timer fire Message */
7074 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7075 strHostIFmsg.u16MsgId = HOST_IF_MSG_LISTEN_TIMER_FIRED;
7076 strHostIFmsg.drvHandler = hWFIDrv;
7077 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
7079 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7081 WILC_ERRORREPORT(s32Error, s32Error);
7083 WILC_CATCH(s32Error)
7091 * @brief host_int_frame_register
7093 * @param[in] Handle to wifi driver
7094 * @return Error code.
7098 s32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, u16 u16FrameType, bool bReg)
7100 s32 s32Error = WILC_SUCCESS;
7101 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7102 tstrHostIFmsg strHostIFmsg;
7104 if (pstrWFIDrv == NULL) {
7105 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7108 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7110 /* prepare the WiphyParams Message */
7111 strHostIFmsg.u16MsgId = HOST_IF_MSG_REGISTER_FRAME;
7112 switch (u16FrameType) {
7114 PRINT_D(HOSTINF_DBG, "ACTION\n");
7115 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u8Regid = ACTION_FRM_IDX;
7119 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
7120 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u8Regid = PROBE_REQ_IDX;
7124 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
7127 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u16FrameType = u16FrameType;
7128 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.bReg = bReg;
7129 strHostIFmsg.drvHandler = hWFIDrv;
7131 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7133 WILC_ERRORREPORT(s32Error, s32Error);
7135 WILC_CATCH(s32Error)
7146 #ifdef WILC_AP_EXTERNAL_MLME
7148 * @brief host_int_add_beacon
7149 * @details Setting add beacon params in message queue
7150 * @param[in] WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
7151 * u32 u32DTIMPeriod,u32 u32HeadLen, u8* pu8Head,
7152 * u32 u32TailLen, u8* pu8Tail
7153 * @return Error code.
7158 s32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
7160 u32 u32HeadLen, u8 *pu8Head,
7161 u32 u32TailLen, u8 *pu8Tail)
7163 s32 s32Error = WILC_SUCCESS;
7164 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7165 tstrHostIFmsg strHostIFmsg;
7166 tstrHostIFSetBeacon *pstrSetBeaconParam = &strHostIFmsg.uniHostIFmsgBody.strHostIFSetBeacon;
7168 if (pstrWFIDrv == NULL) {
7169 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7172 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7174 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
7177 /* prepare the WiphyParams Message */
7178 strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_BEACON;
7179 strHostIFmsg.drvHandler = hWFIDrv;
7180 pstrSetBeaconParam->u32Interval = u32Interval;
7181 pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
7182 pstrSetBeaconParam->u32HeadLen = u32HeadLen;
7183 pstrSetBeaconParam->pu8Head = (u8 *)WILC_MALLOC(u32HeadLen);
7184 if (pstrSetBeaconParam->pu8Head == NULL) {
7185 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
7187 WILC_memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
7188 pstrSetBeaconParam->u32TailLen = u32TailLen;
7190 /* Bug 4599 : if tail length = 0 skip allocating & copying */
7191 if (u32TailLen > 0) {
7192 pstrSetBeaconParam->pu8Tail = (u8 *)WILC_MALLOC(u32TailLen);
7193 if (pstrSetBeaconParam->pu8Tail == NULL) {
7194 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
7196 WILC_memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen);
7198 pstrSetBeaconParam->pu8Tail = NULL;
7201 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7203 WILC_ERRORREPORT(s32Error, s32Error);
7206 WILC_CATCH(s32Error)
7208 if (pstrSetBeaconParam->pu8Head != NULL) {
7209 WILC_FREE(pstrSetBeaconParam->pu8Head);
7212 if (pstrSetBeaconParam->pu8Tail != NULL) {
7213 WILC_FREE(pstrSetBeaconParam->pu8Tail);
7223 * @brief host_int_del_beacon
7224 * @details Setting add beacon params in message queue
7225 * @param[in] WILC_WFIDrvHandle hWFIDrv
7226 * @return Error code.
7231 s32 host_int_del_beacon(WILC_WFIDrvHandle hWFIDrv)
7233 s32 s32Error = WILC_SUCCESS;
7234 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7235 tstrHostIFmsg strHostIFmsg;
7237 if (pstrWFIDrv == NULL) {
7238 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7241 /* prepare the WiphyParams Message */
7242 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_BEACON;
7243 strHostIFmsg.drvHandler = hWFIDrv;
7244 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
7246 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7247 WILC_ERRORCHECK(s32Error);
7249 WILC_CATCH(s32Error)
7257 * @brief host_int_add_station
7258 * @details Setting add station params in message queue
7259 * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7260 * @return Error code.
7265 s32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrStaParams)
7267 s32 s32Error = WILC_SUCCESS;
7268 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7269 tstrHostIFmsg strHostIFmsg;
7270 tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam;
7273 if (pstrWFIDrv == NULL) {
7274 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7277 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7279 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
7282 /* prepare the WiphyParams Message */
7283 strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_STATION;
7284 strHostIFmsg.drvHandler = hWFIDrv;
7286 WILC_memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam));
7287 if (pstrAddStationMsg->u8NumRates > 0) {
7288 u8 *rates = WILC_MALLOC(pstrAddStationMsg->u8NumRates);
7289 WILC_NULLCHECK(s32Error, rates);
7291 WILC_memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
7292 pstrAddStationMsg->pu8Rates = rates;
7296 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7298 WILC_ERRORREPORT(s32Error, s32Error);
7301 WILC_CATCH(s32Error)
7308 * @brief host_int_del_station
7309 * @details Setting delete station params in message queue
7310 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr
7311 * @return Error code.
7316 s32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8MacAddr)
7318 s32 s32Error = WILC_SUCCESS;
7319 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7320 tstrHostIFmsg strHostIFmsg;
7321 tstrHostIFDelSta *pstrDelStationMsg = &strHostIFmsg.uniHostIFmsgBody.strDelStaParam;
7323 if (pstrWFIDrv == NULL) {
7324 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7327 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7329 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
7333 /* prepare the WiphyParams Message */
7334 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_STATION;
7335 strHostIFmsg.drvHandler = hWFIDrv;
7337 /*BugID_4795: Handling situation of deleting all stations*/
7338 if (pu8MacAddr == NULL)
7339 WILC_memset(pstrDelStationMsg->au8MacAddr, 255, ETH_ALEN);
7341 WILC_memcpy(pstrDelStationMsg->au8MacAddr, pu8MacAddr, ETH_ALEN);
7343 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7345 WILC_ERRORREPORT(s32Error, s32Error);
7348 WILC_CATCH(s32Error)
7354 * @brief host_int_del_allstation
7355 * @details Setting del station params in message queue
7356 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]s
7357 * @return Error code.
7362 s32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN])
7364 s32 s32Error = WILC_SUCCESS;
7365 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7366 tstrHostIFmsg strHostIFmsg;
7367 tstrHostIFDelAllSta *pstrDelAllStationMsg = &strHostIFmsg.uniHostIFmsgBody.strHostIFDelAllSta;
7368 u8 au8Zero_Buff[ETH_ALEN] = {0};
7373 if (pstrWFIDrv == NULL) {
7374 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7377 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7379 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
7381 /* prepare the WiphyParams Message */
7382 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_ALL_STA;
7383 strHostIFmsg.drvHandler = hWFIDrv;
7385 /* Handling situation of deauthenticing all associated stations*/
7386 for (i = 0; i < MAX_NUM_STA; i++) {
7387 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
7388 WILC_memcpy(pstrDelAllStationMsg->au8Sta_DelAllSta[i], pu8MacAddr[i], ETH_ALEN);
7389 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],
7390 pstrDelAllStationMsg->au8Sta_DelAllSta[i][5]);
7395 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
7399 pstrDelAllStationMsg->u8Num_AssocSta = u8AssocNumb;
7400 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7404 WILC_ERRORREPORT(s32Error, s32Error);
7407 WILC_CATCH(s32Error)
7411 down(&hWaitResponse);
7418 * @brief host_int_edit_station
7419 * @details Setting edit station params in message queue
7420 * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7421 * @return Error code.
7426 s32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrStaParams)
7428 s32 s32Error = WILC_SUCCESS;
7429 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7430 tstrHostIFmsg strHostIFmsg;
7431 tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam;
7433 if (pstrWFIDrv == NULL) {
7434 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7437 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
7439 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7442 /* prepare the WiphyParams Message */
7443 strHostIFmsg.u16MsgId = HOST_IF_MSG_EDIT_STATION;
7444 strHostIFmsg.drvHandler = hWFIDrv;
7446 WILC_memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam));
7447 if (pstrAddStationMsg->u8NumRates > 0) {
7448 u8 *rates = WILC_MALLOC(pstrAddStationMsg->u8NumRates);
7449 WILC_NULLCHECK(s32Error, rates);
7450 WILC_memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
7451 pstrAddStationMsg->pu8Rates = rates;
7454 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7456 WILC_ERRORREPORT(s32Error, s32Error);
7458 WILC_CATCH(s32Error)
7463 #endif /*WILC_AP_EXTERNAL_MLME*/
7464 uint32_t wilc_get_chipid(uint8_t);
7466 s32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, bool bIsEnabled, u32 u32Timeout)
7468 s32 s32Error = WILC_SUCCESS;
7469 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7470 tstrHostIFmsg strHostIFmsg;
7471 tstrHostIfPowerMgmtParam *pstrPowerMgmtParam = &strHostIFmsg.uniHostIFmsgBody.strPowerMgmtparam;
7473 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d << \n\n", bIsEnabled);
7475 if (pstrWFIDrv == NULL) {
7476 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7479 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
7481 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7484 /* prepare the WiphyParams Message */
7485 strHostIFmsg.u16MsgId = HOST_IF_MSG_POWER_MGMT;
7486 strHostIFmsg.drvHandler = hWFIDrv;
7488 pstrPowerMgmtParam->bIsEnabled = bIsEnabled;
7489 pstrPowerMgmtParam->u32Timeout = u32Timeout;
7492 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7494 WILC_ERRORREPORT(s32Error, s32Error);
7496 WILC_CATCH(s32Error)
7502 s32 host_int_setup_multicast_filter(WILC_WFIDrvHandle hWFIDrv, bool bIsEnabled, u32 u32count)
7504 s32 s32Error = WILC_SUCCESS;
7506 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7507 tstrHostIFmsg strHostIFmsg;
7508 tstrHostIFSetMulti *pstrMulticastFilterParam = &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMulti;
7511 if (pstrWFIDrv == NULL) {
7512 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7515 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
7517 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7520 /* prepare the WiphyParams Message */
7521 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_MULTICAST_FILTER;
7522 strHostIFmsg.drvHandler = hWFIDrv;
7524 pstrMulticastFilterParam->bIsEnabled = bIsEnabled;
7525 pstrMulticastFilterParam->u32count = u32count;
7527 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7529 WILC_ERRORREPORT(s32Error, s32Error);
7531 WILC_CATCH(s32Error)
7539 /*Bug4218: Parsing Join Param*/
7540 #ifdef WILC_PARSE_SCAN_IN_HOST
7542 /*Bug4218: Parsing Join Param*/
7544 * @brief host_int_ParseJoinBssParam
7545 * @details Parse Needed Join Parameters and save it in a new JoinBssParam entry
7546 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7551 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
7553 tstrJoinBssParam *pNewJoinBssParam = NULL;
7562 u8 pcipherTotalCount = 0;
7563 u8 authTotalCount = 0;
7566 pu8IEs = ptstrNetworkInfo->pu8IEs;
7567 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
7569 pNewJoinBssParam = WILC_MALLOC(sizeof(tstrJoinBssParam));
7570 if (pNewJoinBssParam != NULL) {
7571 WILC_memset(pNewJoinBssParam, 0, sizeof(tstrJoinBssParam));
7572 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
7573 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
7574 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
7575 WILC_memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
7577 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/
7578 WILC_memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
7579 pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen;
7580 WILC_memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
7581 WILC_memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
7582 /*for(i=0; i<pNewJoinBssParam->ssidLen;i++)
7583 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/
7585 /* parse supported rates: */
7586 while (index < u16IEsLen) {
7587 /* supportedRates IE */
7588 if (pu8IEs[index] == SUPP_RATES_IE) {
7589 /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */
7590 suppRatesNo = pu8IEs[index + 1];
7591 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
7592 index += 2; /* skipping ID and length bytes; */
7594 for (i = 0; i < suppRatesNo; i++) {
7595 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
7596 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */
7598 index += suppRatesNo;
7601 /* Ext SupportedRates IE */
7602 else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
7603 /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */
7604 /* checking if no of ext. supp and supp rates < max limit */
7605 extSuppRatesNo = pu8IEs[index + 1];
7606 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
7607 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
7609 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
7611 /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */
7612 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
7613 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
7614 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */
7616 index += extSuppRatesNo;
7620 else if (pu8IEs[index] == HT_CAPABILITY_IE) {
7621 /* if IE found set the flag */
7622 pNewJoinBssParam->ht_capable = true;
7623 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7624 /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */
7626 } else if ((pu8IEs[index] == WMM_IE) && /* WMM Element ID */
7627 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
7628 (pu8IEs[index + 4] == 0xF2) && /* OUI */
7629 (pu8IEs[index + 5] == 0x02) && /* OUI Type */
7630 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) && /* OUI Sub Type */
7631 (pu8IEs[index + 7] == 0x01)) {
7632 /* Presence of WMM Info/Param element indicates WMM capability */
7633 pNewJoinBssParam->wmm_cap = true;
7635 /* Check if Bit 7 is set indicating U-APSD capability */
7636 if (pu8IEs[index + 8] & (1 << 7)) {
7637 pNewJoinBssParam->uapsd_cap = true;
7639 index += pu8IEs[index + 1] + 2;
7643 else if ((pu8IEs[index] == P2P_IE) && /* P2P Element ID */
7644 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
7645 (pu8IEs[index + 4] == 0x9a) && /* OUI */
7646 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) { /* OUI Type */
7648 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
7649 pNewJoinBssParam->u8NoaEnbaled = 1;
7650 pNewJoinBssParam->u8Index = pu8IEs[index + 9];
7652 /* Check if Bit 7 is set indicating Opss capability */
7653 if (pu8IEs[index + 10] & (1 << 7)) {
7654 pNewJoinBssParam->u8OppEnable = 1;
7655 pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10];
7657 pNewJoinBssParam->u8OppEnable = 0;
7659 PRINT_D(GENERIC_DBG, "P2P Dump \n");
7660 for (i = 0; i < pu8IEs[index + 7]; i++)
7661 PRINT_D(GENERIC_DBG, " %x \n", pu8IEs[index + 9 + i]);
7663 pNewJoinBssParam->u8Count = pu8IEs[index + 11];
7664 u16P2P_count = index + 12;
7666 WILC_memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4);
7669 WILC_memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4);
7672 WILC_memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
7674 index += pu8IEs[index + 1] + 2;
7679 else if ((pu8IEs[index] == RSN_IE) ||
7680 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
7681 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
7682 (pu8IEs[index + 5] == 0x01))) {
7683 u16 rsnIndex = index;
7684 /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]);
7685 * for(i=0; i<pu8IEs[rsnIndex+1]; i++)
7687 * PRINT_D(HOSTINF_DBG,"%0x ",pu8IEs[rsnIndex+2+i]);
7689 if (pu8IEs[rsnIndex] == RSN_IE) {
7690 pNewJoinBssParam->mode_802_11i = 2;
7691 /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */
7692 } else { /* check if rsn was previously parsed */
7693 if (pNewJoinBssParam->mode_802_11i == 0)
7694 pNewJoinBssParam->mode_802_11i = 1;
7695 /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */
7698 rsnIndex += 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */
7699 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
7701 /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x \n",pNewJoinBssParam->rsn_grp_policy); */
7702 /* initialize policies with invalid values */
7704 jumpOffset = pu8IEs[rsnIndex] * 4; /* total no.of bytes of pcipher field (count*4) */
7706 /*parsing pairwise cipher*/
7708 /* saving 3 pcipher max. */
7709 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7710 rsnIndex += 2; /* jump 2 bytes of pcipher count */
7712 /* PRINT_D(HOSTINF_DBG,"\npcipher:%d \n",pcipherCount); */
7713 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
7714 /* each count corresponds to 4 bytes, only last byte is saved */
7715 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7716 /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */
7718 pcipherTotalCount += pcipherCount;
7719 rsnIndex += jumpOffset;
7721 jumpOffset = pu8IEs[rsnIndex] * 4;
7723 /*parsing AKM suite (auth_policy)*/
7724 /* saving 3 auth policies max. */
7725 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7726 rsnIndex += 2; /* jump 2 bytes of pcipher count */
7728 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
7729 /* each count corresponds to 4 bytes, only last byte is saved */
7730 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7732 authTotalCount += authCount;
7733 rsnIndex += jumpOffset;
7734 /*pasring rsn cap. only if rsn IE*/
7735 if (pu8IEs[index] == RSN_IE) {
7736 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
7737 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
7740 pNewJoinBssParam->rsn_found = true;
7741 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7744 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7751 return (void *)pNewJoinBssParam;
7755 void host_int_freeJoinParams(void *pJoinParams)
7757 if ((tstrJoinBssParam *)pJoinParams != NULL)
7758 WILC_FREE((tstrJoinBssParam *)pJoinParams);
7760 PRINT_ER("Unable to FREE null pointer\n");
7762 #endif /*WILC_PARSE_SCAN_IN_HOST*/
7766 * @brief host_int_addBASession
7767 * @details Open a block Ack session with the given parameters
7768 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7770 * @author anoureldin
7774 static int host_int_addBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID, short int BufferSize,
7775 short int SessionTimeout, void *drvHandler)
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);
7786 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7788 /* prepare the WiphyParams Message */
7789 strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_BA_SESSION;
7791 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7792 pBASessionInfo->u8Ted = TID;
7793 pBASessionInfo->u16BufferSize = BufferSize;
7794 pBASessionInfo->u16SessionTimeout = SessionTimeout;
7795 strHostIFmsg.drvHandler = hWFIDrv;
7797 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7799 WILC_ERRORREPORT(s32Error, s32Error);
7801 WILC_CATCH(s32Error)
7810 s32 host_int_delBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID)
7812 s32 s32Error = WILC_SUCCESS;
7813 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7814 tstrHostIFmsg strHostIFmsg;
7815 tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
7817 if (pstrWFIDrv == NULL) {
7818 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7821 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7823 /* prepare the WiphyParams Message */
7824 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_BA_SESSION;
7826 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7827 pBASessionInfo->u8Ted = TID;
7828 strHostIFmsg.drvHandler = hWFIDrv;
7830 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7832 WILC_ERRORREPORT(s32Error, s32Error);
7834 WILC_CATCH(s32Error)
7840 down(&hWaitResponse);
7845 s32 host_int_del_All_Rx_BASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID)
7847 s32 s32Error = WILC_SUCCESS;
7848 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7849 tstrHostIFmsg strHostIFmsg;
7850 tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
7852 if (pstrWFIDrv == NULL) {
7853 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7856 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7858 /* prepare the WiphyParams Message */
7859 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
7861 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7862 pBASessionInfo->u8Ted = TID;
7863 strHostIFmsg.drvHandler = hWFIDrv;
7865 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7867 WILC_ERRORREPORT(s32Error, s32Error);
7869 WILC_CATCH(s32Error)
7875 down(&hWaitResponse);
7881 * @brief host_int_setup_ipaddress
7882 * @details setup IP in firmware
7883 * @param[in] Handle to wifi driver
7884 * @return Error code.
7885 * @author Abdelrahman Sobhy
7888 s32 host_int_setup_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *u16ipadd, u8 idx)
7890 s32 s32Error = WILC_SUCCESS;
7891 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7892 tstrHostIFmsg strHostIFmsg;
7894 /* TODO: Enable This feature on softap firmware */
7897 if (pstrWFIDrv == NULL) {
7898 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7901 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7903 /* prepare the WiphyParams Message */
7904 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_IPADDRESS;
7906 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr = u16ipadd;
7907 strHostIFmsg.drvHandler = hWFIDrv;
7908 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx = idx;
7910 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7912 WILC_ERRORREPORT(s32Error, s32Error);
7914 WILC_CATCH(s32Error)
7925 * @brief host_int_get_ipaddress
7926 * @details Get IP from firmware
7927 * @param[in] Handle to wifi driver
7928 * @return Error code.
7929 * @author Abdelrahman Sobhy
7932 s32 host_int_get_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *u16ipadd, u8 idx)
7934 s32 s32Error = WILC_SUCCESS;
7935 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7936 tstrHostIFmsg strHostIFmsg;
7938 if (pstrWFIDrv == NULL) {
7939 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7942 WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7944 /* prepare the WiphyParams Message */
7945 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_IPADDRESS;
7947 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr = u16ipadd;
7948 strHostIFmsg.drvHandler = hWFIDrv;
7949 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx = idx;
7951 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
7953 WILC_ERRORREPORT(s32Error, s32Error);
7955 WILC_CATCH(s32Error)