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 struct timer_list hDuringIpTimer;
13 extern u8 g_wilc_initialized;
14 /*****************************************************************************/
16 /*****************************************************************************/
18 /* Message types of the Host IF Message Queue*/
19 #define HOST_IF_MSG_SCAN 0
20 #define HOST_IF_MSG_CONNECT 1
21 #define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
22 #define HOST_IF_MSG_KEY 3
23 #define HOST_IF_MSG_RCVD_NTWRK_INFO 4
24 #define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
25 #define HOST_IF_MSG_CFG_PARAMS 6
26 #define HOST_IF_MSG_SET_CHANNEL 7
27 #define HOST_IF_MSG_DISCONNECT 8
28 #define HOST_IF_MSG_GET_RSSI 9
29 #define HOST_IF_MSG_GET_CHNL 10
30 #define HOST_IF_MSG_ADD_BEACON 11
31 #define HOST_IF_MSG_DEL_BEACON 12
32 #define HOST_IF_MSG_ADD_STATION 13
33 #define HOST_IF_MSG_DEL_STATION 14
34 #define HOST_IF_MSG_EDIT_STATION 15
35 #define HOST_IF_MSG_SCAN_TIMER_FIRED 16
36 #define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
37 #define HOST_IF_MSG_POWER_MGMT 18
38 #define HOST_IF_MSG_GET_INACTIVETIME 19
39 #define HOST_IF_MSG_REMAIN_ON_CHAN 20
40 #define HOST_IF_MSG_REGISTER_FRAME 21
41 #define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
42 #define HOST_IF_MSG_GET_LINKSPEED 23
43 #define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
44 #define HOST_IF_MSG_SET_MAC_ADDRESS 25
45 #define HOST_IF_MSG_GET_MAC_ADDRESS 26
46 #define HOST_IF_MSG_SET_OPERATION_MODE 27
47 #define HOST_IF_MSG_SET_IPADDRESS 28
48 #define HOST_IF_MSG_GET_IPADDRESS 29
49 #define HOST_IF_MSG_FLUSH_CONNECT 30
50 #define HOST_IF_MSG_GET_STATISTICS 31
51 #define HOST_IF_MSG_SET_MULTICAST_FILTER 32
52 #define HOST_IF_MSG_ADD_BA_SESSION 33
53 #define HOST_IF_MSG_DEL_BA_SESSION 34
54 #define HOST_IF_MSG_Q_IDLE 35
55 #define HOST_IF_MSG_DEL_ALL_STA 36
56 #define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
57 #define HOST_IF_MSG_EXIT 100
59 #define HOST_IF_SCAN_TIMEOUT 4000
60 #define HOST_IF_CONNECT_TIMEOUT 9500
62 #define BA_SESSION_DEFAULT_BUFFER_SIZE 16
63 #define BA_SESSION_DEFAULT_TIMEOUT 1000
64 #define BLOCK_ACK_REQ_SIZE 0x14
65 /*****************************************************************************/
66 /* Type Definitions */
67 /*****************************************************************************/
70 * @struct tstrHostIFCfgParamAttr
71 * @brief Structure to hold Host IF CFG Params Attributes
75 * @author Mai Daftedar
79 typedef struct _tstrHostIFCfgParamAttr {
80 tstrCfgParamVal pstrCfgParamVal;
82 } tstrHostIFCfgParamAttr;
85 * @struct tstrHostIFwpaAttr
86 * @brief Structure to hold Host IF Scan Attributes
90 * @author Mai Daftedar
94 typedef struct _tstrHostIFwpaAttr {
106 * @struct tstrHostIFwepAttr
107 * @brief Structure to hold Host IF Scan Attributes
111 * @author Mai Daftedar
112 * @date 25 March 2012
115 typedef struct _tstrHostIFwepAttr {
120 AUTHTYPE_T tenuAuth_type;
125 * @struct tuniHostIFkeyAttr
126 * @brief Structure to hold Host IF Scan Attributes
130 * @author Mai Daftedar
131 * @date 25 March 2012
134 typedef union _tuniHostIFkeyAttr {
135 tstrHostIFwepAttr strHostIFwepAttr;
136 tstrHostIFwpaAttr strHostIFwpaAttr;
137 tstrHostIFpmkidAttr strHostIFpmkidAttr;
141 * @struct tstrHostIFkeyAttr
142 * @brief Structure to hold Host IF Scan Attributes
146 * @author Mai Daftedar
147 * @date 25 March 2012
150 typedef struct _tstrHostIFkeyAttr {
151 tenuKeyType enuKeyType;
153 tuniHostIFkeyAttr uniHostIFkeyAttr;
160 * @struct tstrHostIFscanAttr
161 * @brief Structure to hold Host IF Scan Attributes
165 * @author Mostafa Abu Bakr
166 * @date 25 March 2012
169 typedef struct _tstrHostIFscanAttr {
176 tWILCpfScanResult pfScanResult;
179 tstrHiddenNetwork strHiddenNetwork;
181 } tstrHostIFscanAttr;
184 * @struct tstrHostIFconnectAttr
185 * @brief Structure to hold Host IF Connect Attributes
189 * @author Mostafa Abu Bakr
190 * @date 25 March 2012
193 typedef struct _tstrHostIFconnectAttr {
200 tWILCpfConnectResult pfConnectResult;
202 AUTHTYPE_T tenuAuth_type;
205 } tstrHostIFconnectAttr;
208 * @struct tstrRcvdGnrlAsyncInfo
209 * @brief Structure to hold Received General Asynchronous info
213 * @author Mostafa Abu Bakr
214 * @date 25 March 2012
217 typedef struct _tstrRcvdGnrlAsyncInfo {
220 } tstrRcvdGnrlAsyncInfo;
223 * @struct tstrHostIFSetChan
224 * @brief Set Channel message body
228 * @author Mai Daftedar
229 * @date 25 March 2012
232 typedef struct _tstrHostIFSetChan {
237 * @struct tstrHostIFSetChan
238 * @brief Get Channel message body
242 * @author Mai Daftedar
246 typedef struct _tstrHostIFGetChan {
250 /*bug3819: Add Scan acomplete notification to host*/
252 * @struct tstrScanComplete
253 * @brief hold received Async. Scan Complete message body
258 * @date 25 March 2012
261 /*typedef struct _tstrScanComplete
265 * } tstrScanComplete;*/
268 * @struct tstrHostIFSetBeacon
269 * @brief Set Beacon message body
273 * @author Adham Abozaeid
277 typedef struct _tstrHostIFSetBeacon {
278 u32 u32Interval; /*!< Beacon Interval. Period between two successive beacons on air */
279 u32 u32DTIMPeriod; /*!< DTIM Period. Indicates how many Beacon frames
280 * (including the current frame) appear before the next DTIM */
281 u32 u32HeadLen; /*!< Length of the head buffer in bytes */
282 u8 *pu8Head; /*!< Pointer to the beacon's head buffer. Beacon's head is the part
283 * from the beacon's start till the TIM element, NOT including the TIM */
284 u32 u32TailLen; /*!< Length of the tail buffer in bytes */
285 u8 *pu8Tail; /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just
286 * after the TIM inormation element */
287 } tstrHostIFSetBeacon;
292 * @struct tstrHostIFDelBeacon
293 * @brief Del Beacon message body
297 * @author Adham Abozaeid
301 typedef struct _tstrHostIFDelBeacon {
303 } tstrHostIFDelBeacon;
306 * @struct tstrHostIFSetMulti
307 * @brief set Multicast filter Address
311 * @author Abdelrahman Sobhy
312 * @date 30 August 2013
313 * @version 1.0 Description
319 } tstrHostIFSetMulti;
322 * @struct tstrHostIFDelAllSta
323 * @brief Deauth station message body
327 * @author Mai Daftedar
328 * @date 09 April 2014
329 * @version 1.0 Description
333 u8 au8Sta_DelAllSta[MAX_NUM_STA][ETH_ALEN];
335 } tstrHostIFDelAllSta;
338 * @struct tstrHostIFDelSta
339 * @brief Delete station message body
343 * @author Adham Abozaeid
345 * @version 1.0 Description
349 u8 au8MacAddr[ETH_ALEN];
353 * @struct tstrTimerCb
354 * @brief Timer callback message body
358 * @author Mostafa Abu Bakr
359 * @date 25 March 2012
362 typedef struct _tstrTimerCb {
363 void *pvUsrArg; /*!< Private data passed at timer start */
367 * @struct tstrHostIfPowerMgmtParam
368 * @brief Power management message body
372 * @author Adham Abozaeid
373 * @date 24 November 2012
380 } tstrHostIfPowerMgmtParam;
383 * @struct tstrHostIFSetIPAddr
384 * @brief set IP Address message body
388 * @author Abdelrahman Sobhy
389 * @date 30 August 2013
390 * @version 1.0 Description
396 } tstrHostIFSetIPAddr;
399 * @struct tstrHostIfStaInactiveT
400 * @brief Get station message body
404 * @author Mai Daftedar
405 * @date 16 April 2013
411 } tstrHostIfStaInactiveT;
414 * @union tuniHostIFmsgBody
415 * @brief Message body for the Host Interface message_q
419 * @author Mostafa Abu Bakr
420 * @date 25 March 2012
423 typedef union _tuniHostIFmsgBody {
424 tstrHostIFscanAttr strHostIFscanAttr; /*!< Host IF Scan Request Attributes message body */
425 tstrHostIFconnectAttr strHostIFconnectAttr; /*!< Host IF Connect Request Attributes message body */
426 tstrRcvdNetworkInfo strRcvdNetworkInfo; /*!< Received Asynchronous Network Info message body */
427 tstrRcvdGnrlAsyncInfo strRcvdGnrlAsyncInfo; /*!< Received General Asynchronous Info message body */
428 tstrHostIFkeyAttr strHostIFkeyAttr; /*!<>*/
429 tstrHostIFCfgParamAttr strHostIFCfgParamAttr; /*! <CFG Parameter message Body> */
430 tstrHostIFSetChan strHostIFSetChan;
431 tstrHostIFGetChan strHostIFGetChan;
432 tstrHostIFSetBeacon strHostIFSetBeacon; /*!< Set beacon message body */
433 tstrHostIFDelBeacon strHostIFDelBeacon; /*!< Del beacon message body */
434 tstrWILC_AddStaParam strAddStaParam; /*!< Add station message body */
435 tstrHostIFDelSta strDelStaParam; /*!< Del Station message body */
436 tstrWILC_AddStaParam strEditStaParam; /*!< Edit station message body */
437 /* tstrScanComplete strScanComplete; / *Received Async. Scan Complete message body* / */
438 tstrTimerCb strTimerCb; /*!< Timer callback message body */
439 tstrHostIfPowerMgmtParam strPowerMgmtparam; /*!< Power Management message body */
440 tstrHostIfStaInactiveT strHostIfStaInactiveT;
441 tstrHostIFSetIPAddr strHostIfSetIP;
442 tstrHostIfSetDrvHandler strHostIfSetDrvHandler;
443 tstrHostIFSetMulti strHostIfSetMulti;
444 tstrHostIfSetOperationMode strHostIfSetOperationMode;
445 tstrHostIfSetMacAddress strHostIfSetMacAddress;
446 tstrHostIfGetMacAddress strHostIfGetMacAddress;
447 tstrHostIfBASessionInfo strHostIfBASessionInfo;
449 tstrHostIfRemainOnChan strHostIfRemainOnChan;
450 tstrHostIfRegisterFrame strHostIfRegisterFrame;
453 tstrHostIFDelAllSta strHostIFDelAllSta;
457 * @struct tstrHostIFmsg
458 * @brief Host Interface message
462 * @author Mostafa Abu Bakr
463 * @date 25 March 2012
466 typedef struct _tstrHostIFmsg {
467 u16 u16MsgId; /*!< Message ID */
468 tuniHostIFmsgBody uniHostIFmsgBody; /*!< Message body */
469 tstrWILC_WFIDrv *drvHandler;
472 #ifdef CONNECT_DIRECT
473 typedef struct _tstrWidJoinReqExt {
474 char SSID[MAX_SSID_LEN];
480 /*Bug4218: Parsing Join Param*/
481 #ifdef WILC_PARSE_SCAN_IN_HOST
482 /*Struct containg joinParam of each AP*/
483 typedef struct _tstrJoinBssParam {
489 char ssid[MAX_SSID_LEN];
491 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
498 u8 rsn_pcip_policy[3];
499 u8 rsn_auth_policy[3];
501 struct _tstrJoinParam *nextJoinBss;
514 /*Bug4218: Parsing Join Param*/
515 /*a linked list table containing needed join parameters entries for each AP found in most recent scan*/
516 typedef struct _tstrBssTable {
518 tstrJoinBssParam *head;
519 tstrJoinBssParam *tail;
521 #endif /*WILC_PARSE_SCAN_IN_HOST*/
526 SCAN_CONNECT_TIMER_FORCE_32BIT = 0xFFFFFFFF
529 /*****************************************************************************/
531 /* Global Variabls */
533 /*****************************************************************************/
536 tstrWILC_WFIDrv *terminated_handle;
537 tstrWILC_WFIDrv *gWFiDrvHandle;
538 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
539 bool g_obtainingIP = false;
542 static struct task_struct *HostIFthreadHandler;
543 static WILC_MsgQueueHandle gMsgQHostIF;
544 static struct semaphore hSemHostIFthrdEnd;
546 struct semaphore hSemDeinitDrvHandle;
547 static struct semaphore hWaitResponse;
548 struct semaphore hSemHostIntDeinit;
549 struct timer_list g_hPeriodicRSSI;
553 u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
555 #ifndef CONNECT_DIRECT
556 static u8 gapu8RcvdSurveyResults[2][MAX_SURVEY_RESULT_FRAG_SIZE];
559 static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE];
561 bool gbScanWhileConnected = false;
566 static u8 gs8SetIP[2][4];
567 static u8 gs8GetIP[2][4];
568 #ifdef WILC_AP_EXTERNAL_MLME
569 static u32 gu32InactiveTime;
572 static u32 gu32WidConnRstHack;
575 u8 *gu8FlushedJoinReq;
576 u8 *gu8FlushedInfoElemAsoc;
577 u8 gu8Flushed11iMode;
578 u8 gu8FlushedAuthType;
579 u32 gu32FlushedJoinReqSize;
580 u32 gu32FlushedInfoElemAsocSize;
581 u32 gu8FlushedJoinReqDrvHandler;
582 #define REAL_JOIN_REQ 0
583 #define FLUSHED_JOIN_REQ 1
584 #define FLUSHED_BYTE_POS 79 /* Position the byte indicating flushing in the flushed request */
586 /*Bug4218: Parsing Join Param*/
587 #ifdef WILC_PARSE_SCAN_IN_HOST
588 /*Bug4218: Parsing Join Param*/
589 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
590 #endif /*WILC_PARSE_SCAN_IN_HOST*/
592 extern void chip_sleep_manually(u32 u32SleepTime);
593 extern int linux_wlan_get_num_conn_ifcs(void);
596 * @brief Handle_SetChannel
597 * @details Sending config packet to firmware to set channel
598 * @param[in] tstrHostIFSetChan* pstrHostIFSetChan
599 * @return Error code.
604 static s32 Handle_SetChannel(tstrWILC_WFIDrv *drvHandler, tstrHostIFSetChan *pstrHostIFSetChan)
607 s32 s32Error = WILC_SUCCESS;
609 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
611 /*prepare configuration packet*/
612 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
613 strWID.enuWIDtype = WID_CHAR;
614 strWID.ps8WidVal = (char *)&(pstrHostIFSetChan->u8SetChan);
615 strWID.s32ValueSize = sizeof(char);
617 PRINT_D(HOSTINF_DBG, "Setting channel\n");
619 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
621 PRINT_ER("Failed to set channel\n");
622 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
632 * @brief Handle_SetWfiDrvHandler
633 * @details Sending config packet to firmware to set driver handler
634 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
635 * @return Error code.
640 static s32 Handle_SetWfiDrvHandler(tstrHostIfSetDrvHandler *pstrHostIfSetDrvHandler)
643 s32 s32Error = WILC_SUCCESS;
645 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)((pstrHostIfSetDrvHandler->u32Address));
648 /*prepare configuration packet*/
649 strWID.u16WIDid = (u16)WID_SET_DRV_HANDLER;
650 strWID.enuWIDtype = WID_INT;
651 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetDrvHandler->u32Address);
652 strWID.s32ValueSize = sizeof(u32);
656 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
659 if ((pstrHostIfSetDrvHandler->u32Address) == (u32)NULL)
660 up(&hSemDeinitDrvHandle);
664 PRINT_ER("Failed to set driver handler\n");
665 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
676 * @brief Handle_SetWfiAPDrvHandler
677 * @details Sending config packet to firmware to set driver handler
678 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
679 * @return Error code.
684 static s32 Handle_SetOperationMode(tstrWILC_WFIDrv *drvHandler, tstrHostIfSetOperationMode *pstrHostIfSetOperationMode)
687 s32 s32Error = WILC_SUCCESS;
689 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
692 /*prepare configuration packet*/
693 strWID.u16WIDid = (u16)WID_SET_OPERATION_MODE;
694 strWID.enuWIDtype = WID_INT;
695 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetOperationMode->u32Mode);
696 strWID.s32ValueSize = sizeof(u32);
699 PRINT_INFO(HOSTINF_DBG, "pstrWFIDrv= %p\n", pstrWFIDrv);
701 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
704 if ((pstrHostIfSetOperationMode->u32Mode) == (u32)NULL)
705 up(&hSemDeinitDrvHandle);
709 PRINT_ER("Failed to set driver handler\n");
710 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
721 * @brief host_int_set_IPAddress
722 * @details Setting IP address params in message queue
723 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
724 * @return Error code.
729 s32 Handle_set_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 *pu8IPAddr, u8 idx)
732 s32 s32Error = WILC_SUCCESS;
734 char firmwareIPAddress[4] = {0};
735 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
737 if (pu8IPAddr[0] < 192)
740 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n", idx, pu8IPAddr);
742 memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN);
744 /*prepare configuration packet*/
745 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
746 strWID.enuWIDtype = WID_STR;
747 strWID.ps8WidVal = (u8 *)pu8IPAddr;
748 strWID.s32ValueSize = IP_ALEN;
750 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
754 host_int_get_ipaddress(drvHandler, firmwareIPAddress, idx);
757 PRINT_D(HOSTINF_DBG, "Failed to set IP address\n");
758 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
760 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
773 * @brief Handle_get_IPAddress
774 * @details Setting IP address params in message queue
775 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
776 * @return Error code.
781 s32 Handle_get_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 *pu8IPAddr, u8 idx)
784 s32 s32Error = WILC_SUCCESS;
786 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
788 /*prepare configuration packet*/
789 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
790 strWID.enuWIDtype = WID_STR;
791 strWID.ps8WidVal = WILC_MALLOC(IP_ALEN);
792 strWID.s32ValueSize = IP_ALEN;
794 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
796 PRINT_INFO(HOSTINF_DBG, "%pI4\n", strWID.ps8WidVal);
798 memcpy(gs8GetIP[idx], strWID.ps8WidVal, IP_ALEN);
800 /*get the value by searching the local copy*/
801 kfree(strWID.ps8WidVal);
803 if (memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0)
804 host_int_setup_ipaddress(pstrWFIDrv, gs8SetIP[idx], idx);
806 if (s32Error != WILC_SUCCESS) {
807 PRINT_ER("Failed to get IP address\n");
808 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
810 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
811 PRINT_INFO(HOSTINF_DBG, "%pI4\n", gs8GetIP[idx]);
812 PRINT_INFO(HOSTINF_DBG, "\n");
826 * @brief Handle_SetMacAddress
827 * @details Setting mac address
828 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
829 * @return Error code.
830 * @author Amr Abdel-Moghny
831 * @date November 2013
834 static s32 Handle_SetMacAddress(tstrWILC_WFIDrv *drvHandler, tstrHostIfSetMacAddress *pstrHostIfSetMacAddress)
837 s32 s32Error = WILC_SUCCESS;
839 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
840 u8 *mac_buf = WILC_MALLOC(ETH_ALEN);
842 if (mac_buf == NULL) {
843 PRINT_ER("No buffer to send mac address\n");
846 memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
848 /*prepare configuration packet*/
849 strWID.u16WIDid = (u16)WID_MAC_ADDR;
850 strWID.enuWIDtype = WID_STR;
851 strWID.ps8WidVal = mac_buf;
852 strWID.s32ValueSize = ETH_ALEN;
853 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]);
855 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
857 PRINT_ER("Failed to set mac address\n");
858 WILC_ERRORREPORT(s32Error, WILC_FAIL);
872 * @brief Handle_GetMacAddress
873 * @details Getting mac address
874 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
875 * @return Error code.
876 * @author Amr Abdel-Moghny
880 static s32 Handle_GetMacAddress(tstrWILC_WFIDrv *drvHandler, tstrHostIfGetMacAddress *pstrHostIfGetMacAddress)
883 s32 s32Error = WILC_SUCCESS;
886 /*prepare configuration packet*/
887 strWID.u16WIDid = (u16)WID_MAC_ADDR;
888 strWID.enuWIDtype = WID_STR;
889 strWID.ps8WidVal = pstrHostIfGetMacAddress->u8MacAddress;
890 strWID.s32ValueSize = ETH_ALEN;
893 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, false, (u32)drvHandler);
895 PRINT_ER("Failed to get mac address\n");
896 WILC_ERRORREPORT(s32Error, WILC_FAIL);
909 * @brief Handle_CfgParam
910 * @details Sending config packet to firmware to set CFG params
911 * @param[in] tstrHostIFCfgParamAttr* strHostIFCfgParamAttr
912 * @return Error code.
917 static s32 Handle_CfgParam(tstrWILC_WFIDrv *drvHandler, tstrHostIFCfgParamAttr *strHostIFCfgParamAttr)
919 s32 s32Error = WILC_SUCCESS;
920 tstrWID strWIDList[32];
922 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
925 down(&(pstrWFIDrv->gtOsCfgValuesSem));
928 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
930 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BSS_TYPE) {
931 /*----------------------------------------------------------*/
932 /*Input Value: INFRASTRUCTURE = 1, */
933 /* INDEPENDENT= 2, */
935 /*----------------------------------------------------------*/
936 /* validate input then copy>> need to check value 4 and 5 */
937 if (strHostIFCfgParamAttr->pstrCfgParamVal.bss_type < 6) {
938 strWIDList[u8WidCnt].u16WIDid = WID_BSS_TYPE;
939 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
940 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
941 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
942 pstrWFIDrv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
944 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
948 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTH_TYPE) {
949 /*------------------------------------------------------*/
950 /*Input Values: OPEN_SYSTEM = 0, */
951 /* SHARED_KEY = 1, */
953 /*------------------------------------------------------*/
954 /*validate Possible values*/
955 if ((strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 1 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 2 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 5) {
956 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TYPE;
957 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
958 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
959 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
960 pstrWFIDrv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
962 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
966 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTHEN_TIMEOUT) {
967 /* range is 1 to 65535. */
968 if (strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout < 65536) {
969 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TIMEOUT;
970 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
971 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
972 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
973 pstrWFIDrv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
975 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
979 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & POWER_MANAGEMENT) {
980 /*-----------------------------------------------------------*/
981 /*Input Values: NO_POWERSAVE = 0, */
982 /* MIN_FAST_PS = 1, */
983 /* MAX_FAST_PS = 2, */
984 /* MIN_PSPOLL_PS = 3, */
985 /* MAX_PSPOLL_PS = 4 */
986 /*----------------------------------------------------------*/
987 if (strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode < 5) {
988 strWIDList[u8WidCnt].u16WIDid = WID_POWER_MANAGEMENT;
989 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
990 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
991 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
992 pstrWFIDrv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
994 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
998 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_SHORT) {
999 /* range from 1 to 256 */
1000 if ((strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit < 256)) {
1001 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_RETRY_LIMIT;
1002 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
1003 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1004 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1005 pstrWFIDrv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
1007 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1011 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_LONG) {
1012 /* range from 1 to 256 */
1013 if ((strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit < 256)) {
1014 strWIDList[u8WidCnt].u16WIDid = WID_LONG_RETRY_LIMIT;
1015 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
1017 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1018 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1019 pstrWFIDrv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
1021 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1025 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & FRAG_THRESHOLD) {
1027 if (strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold < 7937) {
1028 strWIDList[u8WidCnt].u16WIDid = WID_FRAG_THRESHOLD;
1029 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
1030 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1031 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1032 pstrWFIDrv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
1034 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1038 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RTS_THRESHOLD) {
1039 /* range 256 to 65535 */
1040 if (strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold < 65536) {
1041 strWIDList[u8WidCnt].u16WIDid = WID_RTS_THRESHOLD;
1042 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
1043 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1044 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1045 pstrWFIDrv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
1047 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1051 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PREAMBLE) {
1052 /*-----------------------------------------------------*/
1053 /*Input Values: Short= 0, */
1056 /*------------------------------------------------------*/
1057 if (strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type < 3) {
1058 strWIDList[u8WidCnt].u16WIDid = WID_PREAMBLE;
1059 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
1060 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1061 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1062 pstrWFIDrv->strCfgValues.preamble_type = strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
1064 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1068 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SHORT_SLOT_ALLOWED) {
1069 if (strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed < 2) {
1070 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_SLOT_ALLOWED;
1071 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
1072 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1073 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1074 pstrWFIDrv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
1076 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1080 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & TXOP_PROT_DISABLE) {
1081 /*Description: used to Disable RTS-CTS protection for TXOP burst*/
1082 /*transmission when the acknowledgement policy is No-Ack or Block-Ack */
1083 /* this information is useful for external supplicant */
1084 /*Input Values: 1 for enable and 0 for disable. */
1085 if (strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled < 2) {
1086 strWIDList[u8WidCnt].u16WIDid = WID_11N_TXOP_PROT_DISABLE;
1087 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
1088 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1089 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1090 pstrWFIDrv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
1092 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1096 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BEACON_INTERVAL) {
1097 /* range is 1 to 65535. */
1098 if (strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval < 65536) {
1099 strWIDList[u8WidCnt].u16WIDid = WID_BEACON_INTERVAL;
1100 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
1101 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1102 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1103 pstrWFIDrv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
1105 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1109 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & DTIM_PERIOD) {
1110 /* range is 1 to 255. */
1111 if (strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period < 256) {
1112 strWIDList[u8WidCnt].u16WIDid = WID_DTIM_PERIOD;
1113 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
1114 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1115 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1116 pstrWFIDrv->strCfgValues.dtim_period = strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
1118 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1122 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY) {
1123 /*----------------------------------------------------------------------*/
1124 /*Input Values: SITE_SURVEY_1CH = 0, i.e.: currently set channel */
1125 /* SITE_SURVEY_ALL_CH = 1, */
1126 /* SITE_SURVEY_OFF = 2 */
1127 /*----------------------------------------------------------------------*/
1128 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled < 3) {
1129 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY;
1130 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
1131 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1132 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1133 pstrWFIDrv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
1135 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1139 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY_SCAN_TIME) {
1140 /* range is 1 to 65535. */
1141 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time < 65536) {
1142 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY_SCAN_TIME;
1143 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
1144 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1145 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1146 pstrWFIDrv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
1148 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1152 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & ACTIVE_SCANTIME) {
1153 /* range is 1 to 65535. */
1154 if (strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time < 65536) {
1155 strWIDList[u8WidCnt].u16WIDid = WID_ACTIVE_SCAN_TIME;
1156 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
1157 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1158 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1159 pstrWFIDrv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
1161 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1165 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PASSIVE_SCANTIME) {
1166 /* range is 1 to 65535. */
1167 if (strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time < 65536) {
1168 strWIDList[u8WidCnt].u16WIDid = WID_PASSIVE_SCAN_TIME;
1169 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
1170 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1171 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1172 pstrWFIDrv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
1174 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1178 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & CURRENT_TX_RATE) {
1179 CURRENT_TX_RATE_T curr_tx_rate = strHostIFCfgParamAttr->pstrCfgParamVal.curr_tx_rate;
1180 /*----------------------------------------------------------------------*/
1181 /*Rates: 1 2 5.5 11 6 9 12 18 24 36 48 54 Auto */
1182 /*InputValues: 1 2 3 4 5 6 7 8 9 10 11 12 0 */
1183 /*----------------------------------------------------------------------*/
1185 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
1186 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
1187 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
1188 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
1189 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
1190 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
1191 strWIDList[u8WidCnt].u16WIDid = WID_CURRENT_TX_RATE;
1192 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&curr_tx_rate;
1193 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1194 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1195 pstrWFIDrv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
1197 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1201 s32Error = SendConfigPkt(SET_CFG, strWIDList, u8WidCnt, false, (u32)pstrWFIDrv);
1204 PRINT_ER("Error in setting CFG params\n");
1206 WILC_CATCH(s32Error)
1209 up(&(pstrWFIDrv->gtOsCfgValuesSem));
1215 * @brief Handle_wait_msg_q_empty
1216 * @details this should be the last msg and then the msg Q becomes idle
1217 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1218 * @return Error code.
1223 static s32 Handle_wait_msg_q_empty(void)
1225 s32 s32Error = WILC_SUCCESS;
1227 g_wilc_initialized = 0;
1233 * @brief Handle_Scan
1234 * @details Sending config packet to firmware to set the scan params
1235 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1236 * @return Error code.
1241 static s32 Handle_Scan(tstrWILC_WFIDrv *drvHandler, tstrHostIFscanAttr *pstrHostIFscanAttr)
1243 s32 s32Error = WILC_SUCCESS;
1244 tstrWID strWIDList[5];
1245 u32 u32WidsCount = 0;
1249 u8 *pu8HdnNtwrksWidVal = NULL;
1250 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
1252 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1253 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", pstrWFIDrv->enuHostIFstate);
1255 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->pfScanResult;
1256 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->pvUserArg;
1261 if ((pstrWFIDrv->enuHostIFstate >= HOST_IF_SCANNING) && (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTED)) {
1262 /* here we either in HOST_IF_SCANNING, HOST_IF_WAITING_CONN_REQ or HOST_IF_WAITING_CONN_RESP */
1263 PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", pstrWFIDrv->enuHostIFstate);
1264 WILC_ERRORREPORT(s32Error, WILC_BUSY);
1267 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
1268 if (g_obtainingIP || connecting) {
1269 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
1270 WILC_ERRORREPORT(s32Error, WILC_BUSY);
1274 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1277 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount = 0;
1280 strWIDList[u32WidsCount].u16WIDid = (u16)WID_SSID_PROBE_REQ;
1281 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1283 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++)
1284 valuesize += ((pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
1285 pu8HdnNtwrksWidVal = WILC_MALLOC(valuesize + 1);
1286 strWIDList[u32WidsCount].ps8WidVal = pu8HdnNtwrksWidVal;
1287 if (strWIDList[u32WidsCount].ps8WidVal != NULL) {
1288 pu8Buffer = strWIDList[u32WidsCount].ps8WidVal;
1290 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum;
1292 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum);
1294 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) {
1295 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1296 memcpy(pu8Buffer, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen);
1297 pu8Buffer += pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1302 strWIDList[u32WidsCount].s32ValueSize = (s32)(valuesize + 1);
1306 /*filling cfg param array*/
1308 /* if((pstrHostIFscanAttr->pu8IEs != NULL) && (pstrHostIFscanAttr->IEsLen != 0)) */
1310 /* IEs to be inserted in Probe Request */
1311 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_PROBE;
1312 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1313 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8IEs;
1314 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->IEsLen;
1319 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_TYPE;
1320 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1321 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1322 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanType));
1325 /*list of channels to be scanned*/
1326 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_CHANNEL_LIST;
1327 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1329 /* Bug 4648: Convert channel numbers to start from 0 not 1. */
1330 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL && pstrHostIFscanAttr->u8ChnlListLen > 0) {
1333 for (i = 0; i < pstrHostIFscanAttr->u8ChnlListLen; i++) {
1334 if (pstrHostIFscanAttr->pu8ChnlFreqList[i] > 0)
1335 pstrHostIFscanAttr->pu8ChnlFreqList[i] = pstrHostIFscanAttr->pu8ChnlFreqList[i] - 1;
1339 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8ChnlFreqList;
1340 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->u8ChnlListLen;
1344 strWIDList[u32WidsCount].u16WIDid = WID_START_SCAN_REQ;
1345 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1346 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1347 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanSource));
1350 /*keep the state as is , no need to change it*/
1351 /* gWFiDrvHandle->enuHostIFstate = HOST_IF_SCANNING; */
1353 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
1354 gbScanWhileConnected = true;
1355 else if (pstrWFIDrv->enuHostIFstate == HOST_IF_IDLE)
1356 gbScanWhileConnected = false;
1358 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, (u32)pstrWFIDrv);
1361 PRINT_ER("Failed to send scan paramters config packet\n");
1362 WILC_ERRORREPORT(s32Error, s32Error);
1364 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
1367 WILC_CATCH(s32Error)
1369 del_timer(&pstrWFIDrv->hScanTimer);
1370 /*if there is an ongoing scan request*/
1371 Handle_ScanDone(drvHandler, SCAN_EVENT_ABORTED);
1374 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1375 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
1376 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
1377 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1380 /* Deallocate pstrHostIFscanAttr->pu8IEs which was previously allocated by the sending thread */
1381 if (pstrHostIFscanAttr->pu8IEs != NULL) {
1382 kfree(pstrHostIFscanAttr->pu8IEs);
1383 pstrHostIFscanAttr->pu8IEs = NULL;
1385 if (pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo != NULL) {
1386 kfree(pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo);
1387 pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo = NULL;
1390 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1391 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
1392 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
1393 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1396 if (pu8HdnNtwrksWidVal != NULL)
1397 kfree(pu8HdnNtwrksWidVal);
1403 * @brief Handle_ScanDone
1404 * @details Call scan notification callback function
1406 * @return Error code.
1411 static s32 Handle_ScanDone(tstrWILC_WFIDrv *drvHandler, tenuScanEvent enuEvent)
1413 s32 s32Error = WILC_SUCCESS;
1415 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
1418 u8 u8abort_running_scan;
1422 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
1425 /*Ask FW to abort the running scan, if any*/
1426 if (enuEvent == SCAN_EVENT_ABORTED) {
1427 PRINT_D(GENERIC_DBG, "Abort running scan\n");
1428 u8abort_running_scan = 1;
1429 strWID.u16WIDid = (u16)WID_ABORT_RUNNING_SCAN;
1430 strWID.enuWIDtype = WID_CHAR;
1431 strWID.ps8WidVal = (s8 *)&u8abort_running_scan;
1432 strWID.s32ValueSize = sizeof(char);
1435 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
1436 if (s32Error != WILC_SUCCESS) {
1437 PRINT_ER("Failed to set abort running scan\n");
1438 WILC_ERRORREPORT(s32Error, WILC_FAIL);
1440 WILC_CATCH(s32Error)
1445 if (pstrWFIDrv == NULL) {
1446 PRINT_ER("Driver handler is NULL\n");
1450 /*if there is an ongoing scan request*/
1451 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
1452 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
1453 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
1454 /*delete current scan request*/
1455 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
1462 * @brief Handle_Connect
1463 * @details Sending config packet to firmware to starting connection
1464 * @param[in] tstrHostIFconnectAttr* pstrHostIFconnectAttr
1465 * @return Error code.
1470 u8 u8ConnectedSSID[6] = {0};
1471 static s32 Handle_Connect(tstrWILC_WFIDrv *drvHandler, tstrHostIFconnectAttr *pstrHostIFconnectAttr)
1473 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
1474 s32 s32Error = WILC_SUCCESS;
1475 tstrWID strWIDList[8];
1476 u32 u32WidsCount = 0, dummyval = 0;
1477 /* char passphrase[] = "12345678"; */
1478 #ifndef CONNECT_DIRECT
1479 s32 s32Err = WILC_SUCCESS;
1481 u8 u8bssDscListIndex;
1482 wid_site_survey_reslts_s *pstrSurveyResults = NULL;
1484 u8 *pu8CurrByte = NULL;
1485 /*Bug4218: Parsing Join Param*/
1486 #ifdef WILC_PARSE_SCAN_IN_HOST
1487 tstrJoinBssParam *ptstrJoinBssParam;
1488 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1492 PRINT_D(GENERIC_DBG, "Handling connect request\n");
1494 #ifndef CONNECT_DIRECT
1495 memset(gapu8RcvdSurveyResults[0], 0, MAX_SURVEY_RESULT_FRAG_SIZE);
1496 memset(gapu8RcvdSurveyResults[1], 0, MAX_SURVEY_RESULT_FRAG_SIZE);
1499 PRINT_D(HOSTINF_DBG, "Getting site survey results\n");
1500 s32Err = host_int_get_site_survey_results(pstrWFIDrv,
1501 gapu8RcvdSurveyResults,
1502 MAX_SURVEY_RESULT_FRAG_SIZE);
1504 PRINT_ER("Failed to get site survey results\n");
1505 WILC_ERRORREPORT(s32Error, WILC_FAIL);
1508 s32Err = ParseSurveyResults(gapu8RcvdSurveyResults, &pstrSurveyResults,
1509 &pstrWFIDrv->u32SurveyResultsCount);
1512 if (s32Err == WILC_SUCCESS) {
1513 /* use the parsed info in pstrSurveyResults, then deallocate it */
1514 PRINT_D(HOSTINF_DBG, "Copying site survey results in global structure, then deallocate\n");
1515 for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) {
1516 memcpy(&pstrWFIDrv->astrSurveyResults[i], &pstrSurveyResults[i],
1517 sizeof(wid_site_survey_reslts_s));
1520 DeallocateSurveyResults(pstrSurveyResults);
1522 WILC_ERRORREPORT(s32Error, WILC_FAIL);
1523 PRINT_ER("ParseSurveyResults() Error(%d)\n", s32Err);
1527 for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) {
1528 if (memcmp(pstrWFIDrv->astrSurveyResults[i].SSID,
1529 pstrHostIFconnectAttr->pu8ssid,
1530 pstrHostIFconnectAttr->ssidLen) == 0) {
1531 PRINT_INFO(HOSTINF_DBG, "Network with required SSID is found %s\n", pstrHostIFconnectAttr->pu8ssid);
1532 if (pstrHostIFconnectAttr->pu8bssid == NULL) {
1533 /* BSSID is not passed from the user, so decision of matching
1534 * is done by SSID only */
1535 PRINT_INFO(HOSTINF_DBG, "BSSID is not passed from the user\n");
1538 /* BSSID is also passed from the user, so decision of matching
1539 * should consider also this passed BSSID */
1541 if (memcmp(pstrWFIDrv->astrSurveyResults[i].BSSID,
1542 pstrHostIFconnectAttr->pu8bssid,
1544 PRINT_INFO(HOSTINF_DBG, "BSSID is passed from the user and matched\n");
1551 if (i < pstrWFIDrv->u32SurveyResultsCount) {
1552 u8bssDscListIndex = i;
1554 PRINT_INFO(HOSTINF_DBG, "Connecting to network of Bss Idx%d and SSID %s and channel%d\n",
1555 u8bssDscListIndex, pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].SSID,
1556 pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].Channel);
1558 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1560 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1561 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = WILC_MALLOC(6);
1562 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
1565 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1566 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1567 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = WILC_MALLOC(pstrHostIFconnectAttr->ssidLen + 1);
1568 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
1569 pstrHostIFconnectAttr->ssidLen);
1570 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1573 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1574 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1575 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = WILC_MALLOC(pstrHostIFconnectAttr->IEsLen);
1576 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
1577 pstrHostIFconnectAttr->IEsLen);
1580 pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1581 pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1582 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1583 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1586 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1587 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1589 /* IEs to be inserted in Association Request */
1590 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1591 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1592 strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1593 strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1596 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
1597 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1598 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1599 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
1602 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1604 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
1605 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1606 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1607 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1610 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1612 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
1613 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1614 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
1615 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
1619 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ;
1620 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1621 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1622 strWIDList[u32WidsCount].ps8WidVal = (s8 *)&u8bssDscListIndex;
1625 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1626 * firmware at chip reset when processing the WIDs of the Connect Request.
1627 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1628 /* ////////////////////// */
1629 gu32WidConnRstHack = 0;
1630 /* ////////////////////// */
1632 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, (u32)pstrWFIDrv);
1634 PRINT_ER("Handle_Connect()] failed to send config packet\n");
1635 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
1637 pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1641 PRINT_ER("Required BSSID not found\n");
1642 WILC_ERRORREPORT(s32Error, WILC_NOT_FOUND);
1647 /* if we try to connect to an already connected AP then discard the request */
1649 if (memcmp(pstrHostIFconnectAttr->pu8bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
1651 s32Error = WILC_SUCCESS;
1652 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1656 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1658 /*Bug4218: Parsing Join Param*/
1659 #ifdef WILC_PARSE_SCAN_IN_HOST
1660 ptstrJoinBssParam = (tstrJoinBssParam *)pstrHostIFconnectAttr->pJoinParams;
1661 if (ptstrJoinBssParam == NULL) {
1662 PRINT_ER("Required BSSID not found\n");
1663 WILC_ERRORREPORT(s32Error, WILC_NOT_FOUND);
1665 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1667 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1668 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = WILC_MALLOC(6);
1669 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
1672 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1673 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1674 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = WILC_MALLOC(pstrHostIFconnectAttr->ssidLen + 1);
1675 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
1676 pstrHostIFconnectAttr->ssidLen);
1677 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1680 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1681 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1682 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = WILC_MALLOC(pstrHostIFconnectAttr->IEsLen);
1683 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
1684 pstrHostIFconnectAttr->IEsLen);
1687 pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1688 pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1689 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1690 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1692 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
1693 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
1694 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
1695 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
1698 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
1699 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
1700 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
1701 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
1704 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
1705 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
1706 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
1707 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
1710 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1711 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1713 /* IEs to be inserted in Association Request */
1714 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1715 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1716 strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1717 strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1721 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1723 gu32FlushedInfoElemAsocSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1724 gu8FlushedInfoElemAsoc = WILC_MALLOC(gu32FlushedInfoElemAsocSize);
1725 memcpy(gu8FlushedInfoElemAsoc, pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
1726 gu32FlushedInfoElemAsocSize);
1729 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
1730 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1731 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1732 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
1736 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
1737 gu8Flushed11iMode = pstrWFIDrv->strWILC_UsrConnReq.u8security;
1739 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1742 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
1743 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1744 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1745 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1749 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
1750 gu8FlushedAuthType = (u8)pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type;
1752 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1754 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
1755 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1756 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
1757 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
1761 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
1762 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->u8channel);
1765 #ifndef WILC_PARSE_SCAN_IN_HOST
1766 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
1767 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1768 strWIDList[u32WidsCount].s32ValueSize = MAX_SSID_LEN + 7;
1769 strWIDList[u32WidsCount].ps8WidVal = WILC_MALLOC(strWIDList[u32WidsCount].s32ValueSize);
1771 if (strWIDList[u32WidsCount].ps8WidVal == NULL)
1772 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
1774 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1776 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1777 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
1778 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1780 pu8CurrByte += MAX_SSID_LEN;
1781 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1782 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1784 PRINT_ER("Channel out of range\n");
1785 *(pu8CurrByte++) = 0xFF;
1787 if (pstrHostIFconnectAttr->pu8bssid != NULL)
1788 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
1791 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1792 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1796 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
1797 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1799 /*Sending NoA attributes during connection*/
1800 strWIDList[u32WidsCount].s32ValueSize = 112; /* 79; */
1801 strWIDList[u32WidsCount].ps8WidVal = WILC_MALLOC(strWIDList[u32WidsCount].s32ValueSize);
1804 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1805 gu32FlushedJoinReqSize = strWIDList[u32WidsCount].s32ValueSize;
1806 gu8FlushedJoinReq = WILC_MALLOC(gu32FlushedJoinReqSize);
1808 if (strWIDList[u32WidsCount].ps8WidVal == NULL)
1809 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
1811 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1814 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1815 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
1816 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1818 pu8CurrByte += MAX_SSID_LEN;
1821 *(pu8CurrByte++) = INFRASTRUCTURE;
1823 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1824 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1826 PRINT_ER("Channel out of range\n");
1827 *(pu8CurrByte++) = 0xFF;
1830 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1831 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1832 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1835 if (pstrHostIFconnectAttr->pu8bssid != NULL)
1836 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
1840 if (pstrHostIFconnectAttr->pu8bssid != NULL)
1841 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
1845 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1846 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1847 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1849 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1850 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1851 /* Supported rates*/
1852 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
1853 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1856 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1857 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1859 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1862 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1863 /* copy this information to the user request */
1864 pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
1867 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1868 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1869 /* rsn group policy*/
1870 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1871 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1873 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1874 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1875 /* rsn pcip policy*/
1876 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
1877 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1879 /* rsn auth policy*/
1880 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
1881 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1883 /* rsn auth policy*/
1884 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
1885 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1888 *(pu8CurrByte++) = REAL_JOIN_REQ;
1891 *(pu8CurrByte++) = ptstrJoinBssParam->u8NoaEnbaled;
1892 if (ptstrJoinBssParam->u8NoaEnbaled) {
1893 PRINT_D(HOSTINF_DBG, "NOA present\n");
1895 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1896 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1897 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1898 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1900 *(pu8CurrByte++) = ptstrJoinBssParam->u8Index;
1902 *(pu8CurrByte++) = ptstrJoinBssParam->u8OppEnable;
1904 if (ptstrJoinBssParam->u8OppEnable)
1905 *(pu8CurrByte++) = ptstrJoinBssParam->u8CtWindow;
1907 *(pu8CurrByte++) = ptstrJoinBssParam->u8Count;
1909 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Duration, sizeof(ptstrJoinBssParam->au8Duration));
1911 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Duration);
1913 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Interval, sizeof(ptstrJoinBssParam->au8Interval));
1915 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Interval);
1917 memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
1919 pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1922 PRINT_D(HOSTINF_DBG, "NOA not present\n");
1926 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1927 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1930 #endif /* #ifdef WILC_PARSE_SCAN_IN_HOST*/
1933 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1934 * firmware at chip reset when processing the WIDs of the Connect Request.
1935 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1936 /* ////////////////////// */
1937 gu32WidConnRstHack = 0;
1938 /* ////////////////////// */
1941 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1942 memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
1943 gu8FlushedJoinReqDrvHandler = (u32)pstrWFIDrv;
1946 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1948 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1949 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->pu8bssid, ETH_ALEN);
1951 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]));
1952 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]));
1955 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, (u32)pstrWFIDrv);
1957 PRINT_ER("Handle_Connect()] failed to send config packet\n");
1958 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
1960 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
1961 pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1965 WILC_CATCH(s32Error)
1967 tstrConnectInfo strConnectInfo;
1969 del_timer(&pstrWFIDrv->hConnectTimer);
1971 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
1973 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1975 if (pstrHostIFconnectAttr->pfConnectResult != NULL) {
1976 if (pstrHostIFconnectAttr->pu8bssid != NULL)
1977 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
1979 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1980 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1981 strConnectInfo.pu8ReqIEs = WILC_MALLOC(pstrHostIFconnectAttr->IEsLen);
1982 memcpy(strConnectInfo.pu8ReqIEs,
1983 pstrHostIFconnectAttr->pu8IEs,
1984 pstrHostIFconnectAttr->IEsLen);
1987 pstrHostIFconnectAttr->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1991 pstrHostIFconnectAttr->pvUserArg);
1992 /*Change state to idle*/
1993 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
1995 if (strConnectInfo.pu8ReqIEs != NULL) {
1996 kfree(strConnectInfo.pu8ReqIEs);
1997 strConnectInfo.pu8ReqIEs = NULL;
2001 PRINT_ER("Connect callback function pointer is NULL\n");
2005 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
2006 /* Deallocate pstrHostIFconnectAttr->pu8bssid which was prevoisuly allocated by the sending thread */
2007 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
2008 kfree(pstrHostIFconnectAttr->pu8bssid);
2009 pstrHostIFconnectAttr->pu8bssid = NULL;
2012 /* Deallocate pstrHostIFconnectAttr->pu8ssid which was prevoisuly allocated by the sending thread */
2013 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
2014 kfree(pstrHostIFconnectAttr->pu8ssid);
2015 pstrHostIFconnectAttr->pu8ssid = NULL;
2018 /* Deallocate pstrHostIFconnectAttr->pu8IEs which was prevoisuly allocated by the sending thread */
2019 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
2020 kfree(pstrHostIFconnectAttr->pu8IEs);
2021 pstrHostIFconnectAttr->pu8IEs = NULL;
2024 if (pu8CurrByte != NULL)
2030 * @brief Handle_FlushConnect
2031 * @details Sending config packet to firmware to flush an old connection
2032 * after switching FW from station one to hybrid one
2033 * @param[in] void * drvHandler
2034 * @return Error code.
2035 * @author Amr Abdel-Moghny
2040 static s32 Handle_FlushConnect(tstrWILC_WFIDrv *drvHandler)
2042 s32 s32Error = WILC_SUCCESS;
2043 tstrWID strWIDList[5];
2044 u32 u32WidsCount = 0;
2045 u8 *pu8CurrByte = NULL;
2048 /* IEs to be inserted in Association Request */
2049 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
2050 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
2051 strWIDList[u32WidsCount].ps8WidVal = gu8FlushedInfoElemAsoc;
2052 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedInfoElemAsocSize;
2055 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
2056 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
2057 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
2058 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(gu8Flushed11iMode));
2063 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
2064 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
2065 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
2066 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&gu8FlushedAuthType);
2070 #ifdef WILC_PARSE_SCAN_IN_HOST
2071 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
2072 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
2073 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedJoinReqSize;
2074 strWIDList[u32WidsCount].ps8WidVal = (s8 *)gu8FlushedJoinReq;
2075 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
2077 pu8CurrByte += FLUSHED_BYTE_POS;
2078 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
2084 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, gu8FlushedJoinReqDrvHandler);
2086 PRINT_ER("Handle_Flush_Connect()] failed to send config packet\n");
2087 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
2090 WILC_CATCH(s32Error)
2099 * @brief Handle_ConnectTimeout
2100 * @details Call connect notification callback function indicating connection failure
2102 * @return Error code.
2107 static s32 Handle_ConnectTimeout(tstrWILC_WFIDrv *drvHandler)
2109 s32 s32Error = WILC_SUCCESS;
2110 tstrConnectInfo strConnectInfo;
2112 u16 u16DummyReasonCode = 0;
2113 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
2115 if (pstrWFIDrv == NULL) {
2116 PRINT_ER("Driver handler is NULL\n");
2120 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2122 gbScanWhileConnected = false;
2125 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
2128 /* First, we will notify the upper layer with the Connection failure {through the Connect Callback function},
2129 * then we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2130 * WID_DISCONNECT} */
2131 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2132 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2133 memcpy(strConnectInfo.au8bssid,
2134 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
2137 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2138 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
2139 strConnectInfo.pu8ReqIEs = WILC_MALLOC(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2140 memcpy(strConnectInfo.pu8ReqIEs,
2141 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2142 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2145 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2149 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2151 /* Deallocation of strConnectInfo.pu8ReqIEs */
2152 if (strConnectInfo.pu8ReqIEs != NULL) {
2153 kfree(strConnectInfo.pu8ReqIEs);
2154 strConnectInfo.pu8ReqIEs = NULL;
2157 PRINT_ER("Connect callback function pointer is NULL\n");
2160 /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2161 * WID_DISCONNECT} */
2162 strWID.u16WIDid = (u16)WID_DISCONNECT;
2163 strWID.enuWIDtype = WID_CHAR;
2164 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
2165 strWID.s32ValueSize = sizeof(char);
2167 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2169 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
2171 PRINT_ER("Failed to send dissconect config packet\n");
2173 /* Deallocation of the Saved Connect Request in the global Handle */
2174 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2175 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
2176 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
2177 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2180 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2181 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
2182 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2185 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2186 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2187 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
2188 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2191 memset(u8ConnectedSSID, 0, ETH_ALEN);
2193 /*Freeing flushed join request params on connect timeout*/
2194 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
2195 kfree(gu8FlushedJoinReq);
2196 gu8FlushedJoinReq = NULL;
2198 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
2199 kfree(gu8FlushedInfoElemAsoc);
2200 gu8FlushedInfoElemAsoc = NULL;
2207 * @brief Handle_RcvdNtwrkInfo
2208 * @details Handling received network information
2209 * @param[in] tstrRcvdNetworkInfo* pstrRcvdNetworkInfo
2210 * @return Error code.
2215 static s32 Handle_RcvdNtwrkInfo(tstrWILC_WFIDrv *drvHandler, tstrRcvdNetworkInfo *pstrRcvdNetworkInfo)
2218 bool bNewNtwrkFound;
2222 s32 s32Error = WILC_SUCCESS;
2223 tstrNetworkInfo *pstrNetworkInfo = NULL;
2224 void *pJoinParams = NULL;
2226 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2230 bNewNtwrkFound = true;
2231 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
2233 /*if there is a an ongoing scan request*/
2234 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2235 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
2236 ParseNetworkInfo(pstrRcvdNetworkInfo->pu8Buffer, &pstrNetworkInfo);
2237 if ((pstrNetworkInfo == NULL)
2238 || (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
2239 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
2242 /* check whether this network is discovered before */
2243 for (i = 0; i < pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
2245 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
2246 (pstrNetworkInfo->au8bssid != NULL)) {
2247 if (memcmp(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
2248 pstrNetworkInfo->au8bssid, 6) == 0) {
2249 if (pstrNetworkInfo->s8rssi <= pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
2250 /*we have already found this network with better rssi, so keep the old cached one and don't
2251 * send anything to the upper layer */
2252 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
2255 /* here the same already found network is found again but with a better rssi, so just update
2256 * the rssi for this cached network and send this updated network to the upper layer but
2257 * don't add a new record for it */
2258 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
2259 bNewNtwrkFound = false;
2266 if (bNewNtwrkFound == true) {
2267 /* here it is confirmed that it is a new discovered network,
2268 * so add its record then call the User CallBack function */
2270 PRINT_D(HOSTINF_DBG, "New network found\n");
2272 if (pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
2273 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
2275 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
2276 && (pstrNetworkInfo->au8bssid != NULL)) {
2277 memcpy(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
2278 pstrNetworkInfo->au8bssid, 6);
2280 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount++;
2282 pstrNetworkInfo->bNewNetwork = true;
2283 /*Bug4218: Parsing Join Param*/
2284 /* add new BSS to JoinBssTable */
2285 #ifdef WILC_PARSE_SCAN_IN_HOST
2286 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
2287 #endif /*WILC_PARSE_SCAN_IN_HOST*/
2289 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2290 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid,
2296 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
2299 pstrNetworkInfo->bNewNetwork = false;
2300 /* just call the User CallBack function to send the same discovered network with its updated RSSI */
2301 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2302 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2307 WILC_CATCH(s32Error)
2313 /* Deallocate pstrRcvdNetworkInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2314 if (pstrRcvdNetworkInfo->pu8Buffer != NULL) {
2315 kfree(pstrRcvdNetworkInfo->pu8Buffer);
2316 pstrRcvdNetworkInfo->pu8Buffer = NULL;
2319 /*free structure allocated*/
2320 if (pstrNetworkInfo != NULL) {
2321 DeallocateNetworkInfo(pstrNetworkInfo);
2322 pstrNetworkInfo = NULL;
2329 * @brief Handle_RcvdGnrlAsyncInfo
2330 * @details Handling received asynchrous general network information
2331 * @param[in] tstrRcvdGnrlAsyncInfo* pstrRcvdGnrlAsyncInfo
2332 * @return Error code.
2337 static s32 Handle_RcvdGnrlAsyncInfo(tstrWILC_WFIDrv *drvHandler, tstrRcvdGnrlAsyncInfo *pstrRcvdGnrlAsyncInfo)
2339 /* TODO: mostafa: till now, this function just handles only the received mac status msg, */
2340 /* which carries only 1 WID which have WID ID = WID_STATUS */
2341 s32 s32Error = WILC_SUCCESS;
2345 u16 u16WidID = (u16)WID_NIL;
2348 u8 u8MacStatusReasonCode;
2349 u8 u8MacStatusAdditionalInfo;
2350 tstrConnectInfo strConnectInfo;
2351 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2352 s32 s32Err = WILC_SUCCESS;
2353 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
2355 if (pstrWFIDrv == NULL)
2356 PRINT_ER("Driver handler is NULL\n");
2357 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", pstrWFIDrv->enuHostIFstate,
2358 pstrRcvdGnrlAsyncInfo->pu8Buffer[7]);
2360 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
2361 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) ||
2362 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2363 if ((pstrRcvdGnrlAsyncInfo->pu8Buffer == NULL) ||
2364 (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
2365 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
2368 u8MsgType = pstrRcvdGnrlAsyncInfo->pu8Buffer[0];
2370 /* Check whether the received message type is 'I' */
2371 if ('I' != u8MsgType) {
2372 PRINT_ER("Received Message format incorrect.\n");
2373 WILC_ERRORREPORT(s32Error, WILC_FAIL);
2376 /* Extract message ID */
2377 u8MsgID = pstrRcvdGnrlAsyncInfo->pu8Buffer[1];
2379 /* Extract message Length */
2380 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[2], pstrRcvdGnrlAsyncInfo->pu8Buffer[3]);
2382 /* Extract WID ID [expected to be = WID_STATUS] */
2383 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[4], pstrRcvdGnrlAsyncInfo->pu8Buffer[5]);
2385 /* Extract WID Length [expected to be = 1] */
2386 u8WidLen = pstrRcvdGnrlAsyncInfo->pu8Buffer[6];
2388 /* get the WID value [expected to be one of two values: either MAC_CONNECTED = (1) or MAC_DISCONNECTED = (0)] */
2389 u8MacStatus = pstrRcvdGnrlAsyncInfo->pu8Buffer[7];
2390 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->pu8Buffer[8];
2391 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->pu8Buffer[9];
2392 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2393 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2394 /* our station had sent Association Request frame, so here it will get the Association Response frame then parse it */
2395 u32 u32RcvdAssocRespInfoLen;
2396 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
2398 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2400 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
2402 if (u8MacStatus == MAC_CONNECTED) {
2403 memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
2405 host_int_get_assoc_res_info(pstrWFIDrv,
2407 MAX_ASSOC_RESP_FRAME_SIZE,
2408 &u32RcvdAssocRespInfoLen);
2410 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
2412 if (u32RcvdAssocRespInfoLen != 0) {
2414 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
2415 s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
2416 &pstrConnectRespInfo);
2418 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
2420 /* use the necessary parsed Info from the Received Association Response */
2421 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
2423 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
2424 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
2425 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
2426 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
2429 strConnectInfo.pu8RespIEs = WILC_MALLOC(pstrConnectRespInfo->u16RespIEsLen);
2430 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
2431 pstrConnectRespInfo->u16RespIEsLen);
2435 /* deallocate the Assoc. Resp. parsed structure as it is not needed anymore */
2436 if (pstrConnectRespInfo != NULL) {
2437 DeallocateAssocRespInfo(pstrConnectRespInfo);
2438 pstrConnectRespInfo = NULL;
2444 /* The station has just received mac status and it also received assoc. response which
2445 * it was waiting for.
2446 * So check first the matching between the received mac status and the received status code in Asoc Resp */
2447 if ((u8MacStatus == MAC_CONNECTED) &&
2448 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
2449 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
2450 memset(u8ConnectedSSID, 0, ETH_ALEN);
2452 } else if (u8MacStatus == MAC_DISCONNECTED) {
2453 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
2454 memset(u8ConnectedSSID, 0, ETH_ALEN);
2457 /* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */
2458 /* through a structure of type tstrConnectRespInfo */
2459 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2460 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
2461 memcpy(strConnectInfo.au8bssid, pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
2463 if ((u8MacStatus == MAC_CONNECTED) &&
2464 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
2465 memcpy(pstrWFIDrv->au8AssociatedBSSID,
2466 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
2471 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2472 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
2473 strConnectInfo.pu8ReqIEs = WILC_MALLOC(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2474 memcpy(strConnectInfo.pu8ReqIEs,
2475 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2476 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2480 del_timer(&pstrWFIDrv->hConnectTimer);
2481 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2485 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2488 /* if received mac status is MAC_CONNECTED and
2489 * received status code in Asoc Resp is SUCCESSFUL_STATUSCODE, change state to CONNECTED
2490 * else change state to IDLE */
2491 if ((u8MacStatus == MAC_CONNECTED) &&
2492 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
2493 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2495 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
2498 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
2499 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTED;
2501 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2502 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
2503 g_obtainingIP = true;
2504 mod_timer(&hDuringIpTimer,
2505 jiffies + msecs_to_jiffies(10000));
2508 #ifdef WILC_PARSE_SCAN_IN_HOST
2509 /* open a BA session if possible */
2510 /* if(pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable) */
2514 /* host_int_addBASession(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid,0, */
2515 /* BA_SESSION_DEFAULT_BUFFER_SIZE,BA_SESSION_DEFAULT_TIMEOUT); */
2517 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
2518 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2519 gbScanWhileConnected = false;
2523 if (strConnectInfo.pu8RespIEs != NULL) {
2524 kfree(strConnectInfo.pu8RespIEs);
2525 strConnectInfo.pu8RespIEs = NULL;
2528 if (strConnectInfo.pu8ReqIEs != NULL) {
2529 kfree(strConnectInfo.pu8ReqIEs);
2530 strConnectInfo.pu8ReqIEs = NULL;
2534 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2535 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
2536 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
2537 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2540 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2541 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
2542 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2545 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2546 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2547 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
2548 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2551 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2552 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)) {
2553 /* Disassociation or Deauthentication frame has been received */
2554 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
2556 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
2558 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2559 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
2560 del_timer(&pstrWFIDrv->hScanTimer);
2561 Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED);
2564 strDisconnectNotifInfo.u16reason = 0;
2565 strDisconnectNotifInfo.ie = NULL;
2566 strDisconnectNotifInfo.ie_len = 0;
2568 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2569 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2571 g_obtainingIP = false;
2572 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
2575 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
2578 &strDisconnectNotifInfo,
2579 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2582 PRINT_ER("Connect result callback function is NULL\n");
2585 memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
2590 /* if Information Elements were retrieved from the Received deauth/disassoc frame, then they
2591 * should be deallocated here */
2593 * if(strDisconnectNotifInfo.ie != NULL)
2595 * kfree(strDisconnectNotifInfo.ie);
2596 * strDisconnectNotifInfo.ie = NULL;
2600 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2601 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
2602 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
2603 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2606 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2607 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
2608 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2611 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2612 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2613 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
2614 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2618 /*Freeing flushed join request params on receiving*/
2619 /*MAC_DISCONNECTED while connected*/
2620 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
2621 kfree(gu8FlushedJoinReq);
2622 gu8FlushedJoinReq = NULL;
2624 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
2625 kfree(gu8FlushedInfoElemAsoc);
2626 gu8FlushedInfoElemAsoc = NULL;
2629 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2630 gbScanWhileConnected = false;
2632 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2633 (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
2634 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
2635 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
2636 /*Abort the running scan*/
2637 del_timer(&pstrWFIDrv->hScanTimer);
2638 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult)
2639 Handle_ScanDone(pstrWFIDrv, SCAN_EVENT_ABORTED);
2645 WILC_CATCH(s32Error)
2650 /* Deallocate pstrRcvdGnrlAsyncInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2651 if (pstrRcvdGnrlAsyncInfo->pu8Buffer != NULL) {
2652 kfree(pstrRcvdGnrlAsyncInfo->pu8Buffer);
2653 pstrRcvdGnrlAsyncInfo->pu8Buffer = NULL;
2661 * @details Sending config packet to firmware to set key
2662 * @param[in] tstrHostIFkeyAttr* pstrHostIFkeyAttr
2663 * @return Error code.
2668 static int Handle_Key(tstrWILC_WFIDrv *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr)
2670 s32 s32Error = WILC_SUCCESS;
2672 #ifdef WILC_AP_EXTERNAL_MLME
2673 tstrWID strWIDList[5];
2679 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2682 switch (pstrHostIFkeyAttr->enuKeyType) {
2687 #ifdef WILC_AP_EXTERNAL_MLME
2688 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2690 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
2691 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
2692 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
2693 strWIDList[0].enuWIDtype = WID_CHAR;
2694 strWIDList[0].s32ValueSize = sizeof(char);
2695 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8mode));
2697 strWIDList[1].u16WIDid = WID_AUTH_TYPE;
2698 strWIDList[1].enuWIDtype = WID_CHAR;
2699 strWIDList[1].s32ValueSize = sizeof(char);
2700 strWIDList[1].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type));
2702 strWIDList[2].u16WIDid = (u16)WID_KEY_ID;
2703 strWIDList[2].enuWIDtype = WID_CHAR;
2705 strWIDList[2].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
2706 strWIDList[2].s32ValueSize = sizeof(char);
2709 pu8keybuf = WILC_MALLOC(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2712 if (pu8keybuf == NULL) {
2713 PRINT_ER("No buffer to send Key\n");
2717 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
2718 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2721 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
2723 strWIDList[3].u16WIDid = (u16)WID_WEP_KEY_VALUE;
2724 strWIDList[3].enuWIDtype = WID_STR;
2725 strWIDList[3].s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen;
2726 strWIDList[3].ps8WidVal = (s8 *)pu8keybuf;
2729 s32Error = SendConfigPkt(SET_CFG, strWIDList, 4, true, (u32)pstrWFIDrv);
2736 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2737 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
2738 pu8keybuf = WILC_MALLOC(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2);
2739 if (pu8keybuf == NULL) {
2740 PRINT_ER("No buffer to send Key\n");
2743 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2745 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, 1);
2747 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
2748 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2750 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
2752 strWID.u16WIDid = (u16)WID_ADD_WEP_KEY;
2753 strWID.enuWIDtype = WID_STR;
2754 strWID.ps8WidVal = (s8 *)pu8keybuf;
2755 strWID.s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2;
2757 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2759 } else if (pstrHostIFkeyAttr->u8KeyAction & REMOVEKEY) {
2761 PRINT_D(HOSTINF_DBG, "Removing key\n");
2762 strWID.u16WIDid = (u16)WID_REMOVE_WEP_KEY;
2763 strWID.enuWIDtype = WID_STR;
2765 s8idxarray[0] = (s8)pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2766 strWID.ps8WidVal = s8idxarray;
2767 strWID.s32ValueSize = 1;
2769 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2771 strWID.u16WIDid = (u16)WID_KEY_ID;
2772 strWID.enuWIDtype = WID_CHAR;
2773 strWID.ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
2774 strWID.s32ValueSize = sizeof(char);
2776 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
2778 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2780 up(&(pstrWFIDrv->hSemTestKeyBlock));
2784 #ifdef WILC_AP_EXTERNAL_MLME
2785 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2786 pu8keybuf = WILC_MALLOC(RX_MIC_KEY_MSG_LEN);
2787 if (pu8keybuf == NULL) {
2788 PRINT_ER("No buffer to send RxGTK Key\n");
2790 goto _WPARxGtk_end_case_;
2793 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
2796 /*|----------------------------------------------------------------------------|
2797 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2798 * |------------|---------|-------|------------|---------------|----------------|
2799 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2803 if (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq != NULL)
2804 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
2807 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2809 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2811 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2812 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2813 /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */
2814 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
2815 strWIDList[0].enuWIDtype = WID_CHAR;
2816 strWIDList[0].s32ValueSize = sizeof(char);
2817 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
2819 strWIDList[1].u16WIDid = (u16)WID_ADD_RX_GTK;
2820 strWIDList[1].enuWIDtype = WID_STR;
2821 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
2822 strWIDList[1].s32ValueSize = RX_MIC_KEY_MSG_LEN;
2824 s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, true, (u32)pstrWFIDrv);
2828 /* ////////////////////////// */
2829 up(&(pstrWFIDrv->hSemTestKeyBlock));
2830 /* ///////////////////////// */
2834 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2835 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
2837 pu8keybuf = WILC_MALLOC(RX_MIC_KEY_MSG_LEN);
2838 if (pu8keybuf == NULL) {
2839 PRINT_ER("No buffer to send RxGTK Key\n");
2841 goto _WPARxGtk_end_case_;
2844 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
2847 /*|----------------------------------------------------------------------------|
2848 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2849 * |------------|---------|-------|------------|---------------|----------------|
2850 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2852 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
2853 memcpy(pu8keybuf, pstrWFIDrv->au8AssociatedBSSID, ETH_ALEN);
2855 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
2857 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
2859 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2861 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2862 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2863 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2865 strWID.u16WIDid = (u16)WID_ADD_RX_GTK;
2866 strWID.enuWIDtype = WID_STR;
2867 strWID.ps8WidVal = (s8 *)pu8keybuf;
2868 strWID.s32ValueSize = RX_MIC_KEY_MSG_LEN;
2870 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2874 /* ////////////////////////// */
2875 up(&(pstrWFIDrv->hSemTestKeyBlock));
2876 /* ///////////////////////// */
2878 _WPARxGtk_end_case_:
2879 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
2880 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq);
2887 #ifdef WILC_AP_EXTERNAL_MLME
2888 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2891 pu8keybuf = WILC_MALLOC(PTK_KEY_MSG_LEN + 1);
2895 if (pu8keybuf == NULL) {
2896 PRINT_ER("No buffer to send PTK Key\n");
2898 goto _WPAPtk_end_case_;
2902 /*|-----------------------------------------------------------------------------|
2903 * |Station address | keyidx |Key Length |Temporal Key | Rx Michael Key |Tx Michael Key |
2904 * |----------------|------------ |--------------|----------------|---------------|
2905 | 6 bytes | 1 byte | 1byte | 16 bytes | 8 bytes | 8 bytes |
2906 |-----------------------------------------------------------------------------|*/
2908 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
2910 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2911 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2913 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2914 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2917 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
2918 strWIDList[0].enuWIDtype = WID_CHAR;
2919 strWIDList[0].s32ValueSize = sizeof(char);
2920 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
2922 strWIDList[1].u16WIDid = (u16)WID_ADD_PTK;
2923 strWIDList[1].enuWIDtype = WID_STR;
2924 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
2925 strWIDList[1].s32ValueSize = PTK_KEY_MSG_LEN + 1;
2927 s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, true, (u32)pstrWFIDrv);
2930 /* ////////////////////////// */
2931 up(&(pstrWFIDrv->hSemTestKeyBlock));
2932 /* ///////////////////////// */
2935 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2938 pu8keybuf = WILC_MALLOC(PTK_KEY_MSG_LEN);
2942 if (pu8keybuf == NULL) {
2943 PRINT_ER("No buffer to send PTK Key\n");
2945 goto _WPAPtk_end_case_;
2949 /*|-----------------------------------------------------------------------------|
2950 * |Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
2951 * |----------------|------------|--------------|----------------|---------------|
2952 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
2953 |-----------------------------------------------------------------------------|*/
2955 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
2957 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2959 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2960 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2963 strWID.u16WIDid = (u16)WID_ADD_PTK;
2964 strWID.enuWIDtype = WID_STR;
2965 strWID.ps8WidVal = (s8 *)pu8keybuf;
2966 strWID.s32ValueSize = PTK_KEY_MSG_LEN;
2968 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2971 /* ////////////////////////// */
2972 up(&(pstrWFIDrv->hSemTestKeyBlock));
2973 /* ///////////////////////// */
2977 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
2986 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
2988 pu8keybuf = WILC_MALLOC((pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1);
2989 if (pu8keybuf == NULL) {
2990 PRINT_ER("No buffer to send PMKSA Key\n");
2994 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid;
2996 for (i = 0; i < pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid; i++) {
2998 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, ETH_ALEN);
2999 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, PMKID_LEN);
3002 strWID.u16WIDid = (u16)WID_PMKID_INFO;
3003 strWID.enuWIDtype = WID_STR;
3004 strWID.ps8WidVal = (s8 *)pu8keybuf;
3005 strWID.s32ValueSize = (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1;
3007 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3014 PRINT_ER("Failed to send key config packet\n");
3022 * @brief Handle_Disconnect
3023 * @details Sending config packet to firmware to disconnect
3030 static void Handle_Disconnect(tstrWILC_WFIDrv *drvHandler)
3034 s32 s32Error = WILC_SUCCESS;
3035 u16 u16DummyReasonCode = 0;
3036 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3039 strWID.u16WIDid = (u16)WID_DISCONNECT;
3040 strWID.enuWIDtype = WID_CHAR;
3041 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
3042 strWID.s32ValueSize = sizeof(char);
3046 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
3048 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3050 g_obtainingIP = false;
3051 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
3054 memset(u8ConnectedSSID, 0, ETH_ALEN);
3056 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3059 PRINT_ER("Failed to send dissconect config packet\n");
3060 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3062 tstrDisconnectNotifInfo strDisconnectNotifInfo;
3064 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
3066 strDisconnectNotifInfo.u16reason = 0;
3067 strDisconnectNotifInfo.ie = NULL;
3068 strDisconnectNotifInfo.ie_len = 0;
3070 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
3071 del_timer(&pstrWFIDrv->hScanTimer);
3072 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
3073 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
3075 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
3078 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
3081 /*Stop connect timer, if connection in progress*/
3082 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3083 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
3084 del_timer(&pstrWFIDrv->hConnectTimer);
3087 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
3088 0, &strDisconnectNotifInfo, pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
3090 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
3093 gbScanWhileConnected = false;
3095 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
3097 memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
3101 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
3102 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
3103 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
3104 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
3107 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
3108 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
3109 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
3112 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
3113 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
3114 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
3115 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
3120 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
3121 kfree(gu8FlushedJoinReq);
3122 gu8FlushedJoinReq = NULL;
3124 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
3125 kfree(gu8FlushedInfoElemAsoc);
3126 gu8FlushedInfoElemAsoc = NULL;
3131 WILC_CATCH(s32Error)
3136 /* ////////////////////////// */
3137 up(&(pstrWFIDrv->hSemTestDisconnectBlock));
3138 /* ///////////////////////// */
3143 void resolve_disconnect_aberration(tstrWILC_WFIDrv *drvHandler)
3145 tstrWILC_WFIDrv *pstrWFIDrv;
3147 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3148 if (pstrWFIDrv == NULL)
3150 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTING)) {
3151 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
3152 host_int_disconnect(pstrWFIDrv, 1);
3155 static s32 Switch_Log_Terminal(tstrWILC_WFIDrv *drvHandler)
3159 s32 s32Error = WILC_SUCCESS;
3161 static char dummy = 9;
3162 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3164 strWID.u16WIDid = (u16)WID_LOGTerminal_Switch;
3165 strWID.enuWIDtype = WID_CHAR;
3166 strWID.ps8WidVal = &dummy;
3167 strWID.s32ValueSize = sizeof(char);
3169 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3173 PRINT_D(HOSTINF_DBG, "Failed to switch log terminal\n");
3174 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
3176 PRINT_INFO(HOSTINF_DBG, "MAC address set ::\n");
3181 WILC_CATCH(s32Error)
3190 * @brief Handle_GetChnl
3191 * @details Sending config packet to get channel
3199 static s32 Handle_GetChnl(tstrWILC_WFIDrv *drvHandler)
3202 s32 s32Error = WILC_SUCCESS;
3204 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
3205 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3207 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
3208 strWID.enuWIDtype = WID_CHAR;
3209 strWID.ps8WidVal = (s8 *)&gu8Chnl;
3210 strWID.s32ValueSize = sizeof(char);
3212 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
3214 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3215 /*get the value by searching the local copy*/
3217 PRINT_ER("Failed to get channel number\n");
3218 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3222 WILC_CATCH(s32Error)
3226 up(&(pstrWFIDrv->hSemGetCHNL));
3236 * @brief Handle_GetRssi
3237 * @details Sending config packet to get RSSI
3244 static void Handle_GetRssi(tstrWILC_WFIDrv *drvHandler)
3246 s32 s32Error = WILC_SUCCESS;
3248 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3250 strWID.u16WIDid = (u16)WID_RSSI;
3251 strWID.enuWIDtype = WID_CHAR;
3252 strWID.ps8WidVal = &gs8Rssi;
3253 strWID.s32ValueSize = sizeof(char);
3256 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
3258 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3260 PRINT_ER("Failed to get RSSI value\n");
3261 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3264 WILC_CATCH(s32Error)
3268 up(&(pstrWFIDrv->hSemGetRSSI));
3274 static void Handle_GetLinkspeed(tstrWILC_WFIDrv *drvHandler)
3276 s32 s32Error = WILC_SUCCESS;
3278 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3282 strWID.u16WIDid = (u16)WID_LINKSPEED;
3283 strWID.enuWIDtype = WID_CHAR;
3284 strWID.ps8WidVal = &gs8lnkspd;
3285 strWID.s32ValueSize = sizeof(char);
3287 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
3289 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3291 PRINT_ER("Failed to get LINKSPEED value\n");
3292 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3295 WILC_CATCH(s32Error)
3299 up(&(pstrWFIDrv->hSemGetLINKSPEED));
3304 s32 Handle_GetStatistics(tstrWILC_WFIDrv *drvHandler, tstrStatistics *pstrStatistics)
3306 tstrWID strWIDList[5];
3307 uint32_t u32WidsCount = 0, s32Error = 0;
3309 strWIDList[u32WidsCount].u16WIDid = WID_LINKSPEED;
3310 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
3311 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
3312 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u8LinkSpeed));
3315 strWIDList[u32WidsCount].u16WIDid = WID_RSSI;
3316 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
3317 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
3318 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->s8RSSI));
3321 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
3322 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
3323 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
3324 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxCount));
3327 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
3328 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
3329 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
3330 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32RxCount));
3333 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
3334 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
3335 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
3336 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxFailureCount));
3339 s32Error = SendConfigPkt(GET_CFG, strWIDList, u32WidsCount, false, (u32)drvHandler);
3342 PRINT_ER("Failed to send scan paramters config packet\n");
3343 /* WILC_ERRORREPORT(s32Error, s32Error); */
3351 #ifdef WILC_AP_EXTERNAL_MLME
3355 * @brief Handle_Get_InActiveTime
3356 * @details Sending config packet to set mac adddress for station and
3365 static s32 Handle_Get_InActiveTime(tstrWILC_WFIDrv *drvHandler, tstrHostIfStaInactiveT *strHostIfStaInactiveT)
3368 s32 s32Error = WILC_SUCCESS;
3371 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3374 strWID.u16WIDid = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
3375 strWID.enuWIDtype = WID_STR;
3376 strWID.s32ValueSize = ETH_ALEN;
3377 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3380 stamac = strWID.ps8WidVal;
3381 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
3384 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
3387 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3388 /*get the value by searching the local copy*/
3390 PRINT_ER("Failed to SET incative time\n");
3391 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3395 strWID.u16WIDid = (u16)WID_GET_INACTIVE_TIME;
3396 strWID.enuWIDtype = WID_INT;
3397 strWID.ps8WidVal = (s8 *)&gu32InactiveTime;
3398 strWID.s32ValueSize = sizeof(u32);
3401 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3402 /*get the value by searching the local copy*/
3404 PRINT_ER("Failed to get incative time\n");
3405 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3409 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
3411 up(&(pstrWFIDrv->hSemInactiveTime));
3412 WILC_CATCH(s32Error)
3426 * @brief Handle_AddBeacon
3427 * @details Sending config packet to add beacon
3428 * @param[in] tstrHostIFSetBeacon* pstrSetBeaconParam
3434 static void Handle_AddBeacon(tstrWILC_WFIDrv *drvHandler, tstrHostIFSetBeacon *pstrSetBeaconParam)
3436 s32 s32Error = WILC_SUCCESS;
3439 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3441 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
3443 strWID.u16WIDid = (u16)WID_ADD_BEACON;
3444 strWID.enuWIDtype = WID_BIN;
3445 strWID.s32ValueSize = pstrSetBeaconParam->u32HeadLen + pstrSetBeaconParam->u32TailLen + 16;
3446 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3447 if (strWID.ps8WidVal == NULL)
3448 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3450 pu8CurrByte = strWID.ps8WidVal;
3451 *pu8CurrByte++ = (pstrSetBeaconParam->u32Interval & 0xFF);
3452 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 8) & 0xFF);
3453 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 16) & 0xFF);
3454 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 24) & 0xFF);
3456 *pu8CurrByte++ = (pstrSetBeaconParam->u32DTIMPeriod & 0xFF);
3457 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 8) & 0xFF);
3458 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 16) & 0xFF);
3459 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 24) & 0xFF);
3461 *pu8CurrByte++ = (pstrSetBeaconParam->u32HeadLen & 0xFF);
3462 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 8) & 0xFF);
3463 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 16) & 0xFF);
3464 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 24) & 0xFF);
3466 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Head, pstrSetBeaconParam->u32HeadLen);
3467 pu8CurrByte += pstrSetBeaconParam->u32HeadLen;
3469 *pu8CurrByte++ = (pstrSetBeaconParam->u32TailLen & 0xFF);
3470 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 8) & 0xFF);
3471 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 16) & 0xFF);
3472 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 24) & 0xFF);
3474 /* Bug 4599 : if tail length = 0 skip copying */
3475 if (pstrSetBeaconParam->pu8Tail > 0)
3476 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Tail, pstrSetBeaconParam->u32TailLen);
3477 pu8CurrByte += pstrSetBeaconParam->u32TailLen;
3482 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3484 PRINT_ER("Failed to send add beacon config packet\n");
3485 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3488 WILC_CATCH(s32Error)
3491 kfree(strWID.ps8WidVal);
3492 kfree(pstrSetBeaconParam->pu8Head);
3493 kfree(pstrSetBeaconParam->pu8Tail);
3498 * @brief Handle_AddBeacon
3499 * @details Sending config packet to delete beacon
3500 * @param[in] tstrHostIFDelBeacon* pstrDelBeacon
3506 static void Handle_DelBeacon(tstrWILC_WFIDrv *drvHandler, tstrHostIFDelBeacon *pstrDelBeacon)
3508 s32 s32Error = WILC_SUCCESS;
3511 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3513 strWID.u16WIDid = (u16)WID_DEL_BEACON;
3514 strWID.enuWIDtype = WID_CHAR;
3515 strWID.s32ValueSize = sizeof(char);
3516 strWID.ps8WidVal = &gu8DelBcn;
3518 if (strWID.ps8WidVal == NULL)
3519 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3521 pu8CurrByte = strWID.ps8WidVal;
3523 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
3524 /* TODO: build del beacon message*/
3527 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3530 PRINT_ER("Failed to send delete beacon config packet\n");
3531 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3534 WILC_CATCH(s32Error)
3541 * @brief WILC_HostIf_PackStaParam
3542 * @details Handling packing of the station params in a buffer
3543 * @param[in] u8* pu8Buffer, tstrWILC_AddStaParam* pstrStationParam
3549 static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer, tstrWILC_AddStaParam *pstrStationParam)
3553 pu8CurrByte = pu8Buffer;
3555 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
3556 memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
3557 pu8CurrByte += ETH_ALEN;
3559 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
3560 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
3562 *pu8CurrByte++ = pstrStationParam->u8NumRates;
3563 if (pstrStationParam->u8NumRates > 0)
3564 memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
3565 pu8CurrByte += pstrStationParam->u8NumRates;
3567 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
3568 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
3569 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
3571 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
3572 memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
3573 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
3575 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
3576 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
3578 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
3579 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
3580 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
3581 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
3583 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
3585 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
3586 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
3588 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
3589 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
3591 return pu8CurrByte - pu8Buffer;
3595 * @brief Handle_AddStation
3596 * @details Sending config packet to add station
3597 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3603 static void Handle_AddStation(tstrWILC_WFIDrv *drvHandler, tstrWILC_AddStaParam *pstrStationParam)
3605 s32 s32Error = WILC_SUCCESS;
3608 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3610 PRINT_D(HOSTINF_DBG, "Handling add station\n");
3611 strWID.u16WIDid = (u16)WID_ADD_STA;
3612 strWID.enuWIDtype = WID_BIN;
3613 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3615 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3616 if (strWID.ps8WidVal == NULL)
3617 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3619 pu8CurrByte = strWID.ps8WidVal;
3620 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3623 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3624 if (s32Error != WILC_SUCCESS) {
3626 PRINT_ER("Failed to send add station config packet\n");
3627 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3630 WILC_CATCH(s32Error)
3633 kfree(pstrStationParam->pu8Rates);
3634 kfree(strWID.ps8WidVal);
3638 * @brief Handle_DelAllSta
3639 * @details Sending config packet to delete station
3640 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3646 static void Handle_DelAllSta(tstrWILC_WFIDrv *drvHandler, tstrHostIFDelAllSta *pstrDelAllStaParam)
3648 s32 s32Error = WILC_SUCCESS;
3652 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3654 u8 au8Zero_Buff[6] = {0};
3656 strWID.u16WIDid = (u16)WID_DEL_ALL_STA;
3657 strWID.enuWIDtype = WID_STR;
3658 strWID.s32ValueSize = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1;
3660 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
3662 strWID.ps8WidVal = WILC_MALLOC((pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1);
3663 if (strWID.ps8WidVal == NULL)
3664 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3666 pu8CurrByte = strWID.ps8WidVal;
3668 *(pu8CurrByte++) = pstrDelAllStaParam->u8Num_AssocSta;
3670 for (i = 0; i < MAX_NUM_STA; i++) {
3671 if (memcmp(pstrDelAllStaParam->au8Sta_DelAllSta[i], au8Zero_Buff, ETH_ALEN))
3672 memcpy(pu8CurrByte, pstrDelAllStaParam->au8Sta_DelAllSta[i], ETH_ALEN);
3676 pu8CurrByte += ETH_ALEN;
3680 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3683 PRINT_ER("Failed to send add station config packet\n");
3684 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3687 WILC_CATCH(s32Error)
3690 kfree(strWID.ps8WidVal);
3697 * @brief Handle_DelStation
3698 * @details Sending config packet to delete station
3699 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3705 static void Handle_DelStation(tstrWILC_WFIDrv *drvHandler, tstrHostIFDelSta *pstrDelStaParam)
3707 s32 s32Error = WILC_SUCCESS;
3710 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3712 strWID.u16WIDid = (u16)WID_REMOVE_STA;
3713 strWID.enuWIDtype = WID_BIN;
3714 strWID.s32ValueSize = ETH_ALEN;
3716 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
3718 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3719 if (strWID.ps8WidVal == NULL)
3720 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3722 pu8CurrByte = strWID.ps8WidVal;
3724 memcpy(pu8CurrByte, pstrDelStaParam->au8MacAddr, ETH_ALEN);
3727 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3730 PRINT_ER("Failed to send add station config packet\n");
3731 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3734 WILC_CATCH(s32Error)
3737 kfree(strWID.ps8WidVal);
3742 * @brief Handle_EditStation
3743 * @details Sending config packet to edit station
3744 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3750 static void Handle_EditStation(tstrWILC_WFIDrv *drvHandler, tstrWILC_AddStaParam *pstrStationParam)
3752 s32 s32Error = WILC_SUCCESS;
3755 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3757 strWID.u16WIDid = (u16)WID_EDIT_STA;
3758 strWID.enuWIDtype = WID_BIN;
3759 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3761 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
3762 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3763 if (strWID.ps8WidVal == NULL)
3764 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3766 pu8CurrByte = strWID.ps8WidVal;
3767 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3770 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
3773 PRINT_ER("Failed to send edit station config packet\n");
3774 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3777 WILC_CATCH(s32Error)
3780 kfree(pstrStationParam->pu8Rates);
3781 kfree(strWID.ps8WidVal);
3783 #endif /*WILC_AP_EXTERNAL_MLME*/
3787 * @brief Handle_RemainOnChan
3788 * @details Sending config packet to edit station
3789 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3795 static int Handle_RemainOnChan(tstrWILC_WFIDrv *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan)
3797 s32 s32Error = WILC_SUCCESS;
3798 u8 u8remain_on_chan_flag;
3800 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3802 /*If it's a pendig remain-on-channel, don't overwrite gWFiDrvHandle values (since incoming msg is garbbage)*/
3803 if (!pstrWFIDrv->u8RemainOnChan_pendingreq) {
3804 pstrWFIDrv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
3805 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
3806 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
3807 pstrWFIDrv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
3808 pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
3810 /*Set the channel to use it as a wid val*/
3811 pstrHostIfRemainOnChan->u16Channel = pstrWFIDrv->strHostIfRemainOnChan.u16Channel;
3814 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
3815 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
3816 pstrWFIDrv->u8RemainOnChan_pendingreq = 1;
3817 WILC_ERRORREPORT(s32Error, WILC_BUSY);
3819 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3820 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
3821 WILC_ERRORREPORT(s32Error, WILC_BUSY);
3824 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3825 if (g_obtainingIP || connecting) {
3826 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
3827 WILC_ERRORREPORT(s32Error, WILC_BUSY);
3831 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
3833 u8remain_on_chan_flag = true;
3834 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
3835 strWID.enuWIDtype = WID_STR;
3836 strWID.s32ValueSize = 2;
3837 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3839 if (strWID.ps8WidVal == NULL)
3840 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3842 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
3843 strWID.ps8WidVal[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
3846 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3847 if (s32Error != WILC_SUCCESS)
3848 PRINT_ER("Failed to set remain on channel\n");
3852 P2P_LISTEN_STATE = 1;
3853 pstrWFIDrv->hRemainOnChannel.data = (unsigned long)pstrWFIDrv;
3854 mod_timer(&pstrWFIDrv->hRemainOnChannel,
3856 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
3858 /*Calling CFG ready_on_channel*/
3859 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady)
3860 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady(pstrWFIDrv->strHostIfRemainOnChan.pVoid);
3862 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
3863 pstrWFIDrv->u8RemainOnChan_pendingreq = 0;
3869 * @brief Handle_RegisterFrame
3877 static int Handle_RegisterFrame(tstrWILC_WFIDrv *drvHandler, tstrHostIfRegisterFrame *pstrHostIfRegisterFrame)
3879 s32 s32Error = WILC_SUCCESS;
3882 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3884 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
3886 /*prepare configuration packet*/
3887 strWID.u16WIDid = (u16)WID_REGISTER_FRAME;
3888 strWID.enuWIDtype = WID_STR;
3889 strWID.ps8WidVal = WILC_MALLOC(sizeof(u16) + 2);
3890 if (strWID.ps8WidVal == NULL)
3891 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
3893 pu8CurrByte = strWID.ps8WidVal;
3895 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
3896 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
3897 memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
3900 strWID.s32ValueSize = sizeof(u16) + 2;
3904 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3906 PRINT_ER("Failed to frame register config packet\n");
3907 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
3911 WILC_CATCH(s32Error)
3920 * @brief Handle_ListenStateExpired
3921 * @details Handle of listen state expiration
3923 * @return Error code.
3928 #define FALSE_FRMWR_CHANNEL 100
3929 static u32 Handle_ListenStateExpired(tstrWILC_WFIDrv *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan)
3931 u8 u8remain_on_chan_flag;
3933 s32 s32Error = WILC_SUCCESS;
3934 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3936 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
3939 /*Make sure we are already in listen state*/
3940 /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/
3941 if (P2P_LISTEN_STATE) {
3942 u8remain_on_chan_flag = false;
3943 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
3944 strWID.enuWIDtype = WID_STR;
3945 strWID.s32ValueSize = 2;
3946 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3948 if (strWID.ps8WidVal == NULL)
3949 PRINT_ER("Failed to allocate memory\n");
3951 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
3952 strWID.ps8WidVal[1] = FALSE_FRMWR_CHANNEL;
3955 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
3956 if (s32Error != WILC_SUCCESS) {
3957 PRINT_ER("Failed to set remain on channel\n");
3961 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired) {
3962 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired(pstrWFIDrv->strHostIfRemainOnChan.pVoid
3963 , pstrHostIfRemainOnChan->u32ListenSessionID);
3965 P2P_LISTEN_STATE = 0;
3967 PRINT_D(GENERIC_DBG, "Not in listen state\n");
3968 s32Error = WILC_FAIL;
3977 * @brief ListenTimerCB
3978 * @details Callback function of remain-on-channel timer
3980 * @return Error code.
3985 static void ListenTimerCB(unsigned long arg)
3987 s32 s32Error = WILC_SUCCESS;
3988 tstrHostIFmsg strHostIFmsg;
3989 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)arg;
3990 /*Stopping remain-on-channel timer*/
3991 del_timer(&pstrWFIDrv->hRemainOnChannel);
3993 /* prepare the Timer Callback message */
3994 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
3995 strHostIFmsg.u16MsgId = HOST_IF_MSG_LISTEN_TIMER_FIRED;
3996 strHostIFmsg.drvHandler = pstrWFIDrv;
3997 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID;
3999 /* send the message */
4000 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
4002 WILC_ERRORREPORT(s32Error, s32Error);
4003 WILC_CATCH(s32Error)
4012 * @brief Handle_EditStation
4013 * @details Sending config packet to edit station
4014 * @param[in] tstrWILC_AddStaParam* pstrStationParam
4020 static void Handle_PowerManagement(tstrWILC_WFIDrv *drvHandler, tstrHostIfPowerMgmtParam *strPowerMgmtParam)
4022 s32 s32Error = WILC_SUCCESS;
4025 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4027 strWID.u16WIDid = (u16)WID_POWER_MANAGEMENT;
4029 if (strPowerMgmtParam->bIsEnabled == true)
4030 s8PowerMode = MIN_FAST_PS;
4032 s8PowerMode = NO_POWERSAVE;
4033 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
4034 strWID.ps8WidVal = &s8PowerMode;
4035 strWID.s32ValueSize = sizeof(char);
4037 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
4040 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4042 PRINT_ER("Failed to send power management config packet\n");
4043 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
4046 WILC_CATCH(s32Error)
4053 * @brief Handle_SetMulticastFilter
4054 * @details Set Multicast filter in firmware
4055 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4061 static void Handle_SetMulticastFilter(tstrWILC_WFIDrv *drvHandler, tstrHostIFSetMulti *strHostIfSetMulti)
4063 s32 s32Error = WILC_SUCCESS;
4067 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
4069 strWID.u16WIDid = (u16)WID_SETUP_MULTICAST_FILTER;
4070 strWID.enuWIDtype = WID_BIN;
4071 strWID.s32ValueSize = sizeof(tstrHostIFSetMulti) + ((strHostIfSetMulti->u32count) * ETH_ALEN);
4072 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
4073 if (strWID.ps8WidVal == NULL)
4074 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
4076 pu8CurrByte = strWID.ps8WidVal;
4077 *pu8CurrByte++ = (strHostIfSetMulti->bIsEnabled & 0xFF);
4078 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 8) & 0xFF);
4079 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 16) & 0xFF);
4080 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 24) & 0xFF);
4082 *pu8CurrByte++ = (strHostIfSetMulti->u32count & 0xFF);
4083 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 8) & 0xFF);
4084 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 16) & 0xFF);
4085 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 24) & 0xFF);
4087 if ((strHostIfSetMulti->u32count) > 0)
4088 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->u32count) * ETH_ALEN));
4091 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)drvHandler);
4093 PRINT_ER("Failed to send setup multicast config packet\n");
4094 WILC_ERRORREPORT(s32Error, WILC_FAIL);
4097 WILC_CATCH(s32Error)
4100 kfree(strWID.ps8WidVal);
4107 * @brief Handle_AddBASession
4108 * @details Add block ack session
4109 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4111 * @author Amr Abdel-Moghny
4115 static s32 Handle_AddBASession(tstrWILC_WFIDrv *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
4117 s32 s32Error = WILC_SUCCESS;
4119 int AddbaTimeout = 100;
4121 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4123 PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\nBufferSize == %d\nSessionTimeOut = %d\n",
4124 strHostIfBASessionInfo->au8Bssid[0],
4125 strHostIfBASessionInfo->au8Bssid[1],
4126 strHostIfBASessionInfo->au8Bssid[2],
4127 strHostIfBASessionInfo->u16BufferSize,
4128 strHostIfBASessionInfo->u16SessionTimeout,
4129 strHostIfBASessionInfo->u8Ted);
4131 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
4132 strWID.enuWIDtype = WID_STR;
4133 strWID.ps8WidVal = WILC_MALLOC(BLOCK_ACK_REQ_SIZE);
4134 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4135 ptr = strWID.ps8WidVal;
4136 /* *ptr++ = 0x14; */
4140 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4142 *ptr++ = strHostIfBASessionInfo->u8Ted;
4146 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
4147 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
4149 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
4150 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
4152 *ptr++ = (AddbaTimeout & 0xFF);
4153 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
4154 /* Group Buffer Max Frames*/
4156 /* Group Buffer Timeout */
4159 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4161 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
4164 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
4165 strWID.enuWIDtype = WID_STR;
4166 strWID.s32ValueSize = 15;
4167 ptr = strWID.ps8WidVal;
4168 /* *ptr++ = 0x14; */
4172 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4175 *ptr++ = strHostIfBASessionInfo->u8Ted;
4179 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
4180 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
4183 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4185 if (strWID.ps8WidVal != NULL)
4186 kfree(strWID.ps8WidVal);
4195 * @brief Handle_DelBASession
4196 * @details Delete block ack session
4197 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4199 * @author Amr Abdel-Moghny
4203 static s32 Handle_DelBASession(tstrWILC_WFIDrv *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
4205 s32 s32Error = WILC_SUCCESS;
4208 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4210 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
4211 strHostIfBASessionInfo->au8Bssid[0],
4212 strHostIfBASessionInfo->au8Bssid[1],
4213 strHostIfBASessionInfo->au8Bssid[2],
4214 strHostIfBASessionInfo->u8Ted);
4216 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
4217 strWID.enuWIDtype = WID_STR;
4218 strWID.ps8WidVal = WILC_MALLOC(BLOCK_ACK_REQ_SIZE);
4219 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4220 ptr = strWID.ps8WidVal;
4221 /* *ptr++ = 0x14; */
4225 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4227 *ptr++ = strHostIfBASessionInfo->u8Ted;
4228 /* BA direction = recipent*/
4231 *ptr++ = 32; /* Unspecific QOS reason */
4233 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4235 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
4238 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
4239 strWID.enuWIDtype = WID_STR;
4240 strWID.s32ValueSize = 15;
4241 ptr = strWID.ps8WidVal;
4242 /* *ptr++ = 0x14; */
4246 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4249 *ptr++ = strHostIfBASessionInfo->u8Ted;
4251 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4253 if (strWID.ps8WidVal != NULL)
4254 kfree(strWID.ps8WidVal);
4265 * @brief Handle_DelAllRxBASessions
4266 * @details Delete all Rx BA sessions
4267 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4269 * @author Abdelrahman Sobhy
4273 static s32 Handle_DelAllRxBASessions(tstrWILC_WFIDrv *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
4275 s32 s32Error = WILC_SUCCESS;
4278 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4280 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
4281 strHostIfBASessionInfo->au8Bssid[0],
4282 strHostIfBASessionInfo->au8Bssid[1],
4283 strHostIfBASessionInfo->au8Bssid[2],
4284 strHostIfBASessionInfo->u8Ted);
4286 strWID.u16WIDid = (u16)WID_DEL_ALL_RX_BA;
4287 strWID.enuWIDtype = WID_STR;
4288 strWID.ps8WidVal = WILC_MALLOC(BLOCK_ACK_REQ_SIZE);
4289 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4290 ptr = strWID.ps8WidVal;
4294 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
4296 *ptr++ = strHostIfBASessionInfo->u8Ted;
4297 /* BA direction = recipent*/
4300 *ptr++ = 32; /* Unspecific QOS reason */
4302 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
4304 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
4307 if (strWID.ps8WidVal != NULL)
4308 kfree(strWID.ps8WidVal);
4318 * @brief hostIFthread
4319 * @details Main thread to handle message queue requests
4320 * @param[in] void* pvArg
4326 static int hostIFthread(void *pvArg)
4329 tstrHostIFmsg strHostIFmsg;
4330 tstrWILC_WFIDrv *pstrWFIDrv;
4332 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4335 WILC_MsgQueueRecv(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), &u32Ret);
4336 pstrWFIDrv = (tstrWILC_WFIDrv *)strHostIFmsg.drvHandler;
4337 if (strHostIFmsg.u16MsgId == HOST_IF_MSG_EXIT) {
4338 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
4343 /*Re-Queue HIF message*/
4344 if ((!g_wilc_initialized)) {
4345 PRINT_D(GENERIC_DBG, "--WAIT--");
4346 usleep_range(200 * 1000, 200 * 1000);
4347 WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
4351 if (strHostIFmsg.u16MsgId == HOST_IF_MSG_CONNECT && pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
4352 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
4353 WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
4354 usleep_range(2 * 1000, 2 * 1000);
4358 switch (strHostIFmsg.u16MsgId) {
4359 case HOST_IF_MSG_Q_IDLE:
4360 Handle_wait_msg_q_empty();
4363 case HOST_IF_MSG_SCAN:
4364 Handle_Scan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr);
4367 case HOST_IF_MSG_CONNECT:
4368 Handle_Connect(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr);
4372 case HOST_IF_MSG_FLUSH_CONNECT:
4373 Handle_FlushConnect(strHostIFmsg.drvHandler);
4376 case HOST_IF_MSG_RCVD_NTWRK_INFO:
4377 Handle_RcvdNtwrkInfo(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo);
4380 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
4381 Handle_RcvdGnrlAsyncInfo(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo);
4384 case HOST_IF_MSG_KEY:
4385 Handle_Key(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr);
4388 case HOST_IF_MSG_CFG_PARAMS:
4390 Handle_CfgParam(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFCfgParamAttr);
4393 case HOST_IF_MSG_SET_CHANNEL:
4394 Handle_SetChannel(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFSetChan);
4397 case HOST_IF_MSG_DISCONNECT:
4398 Handle_Disconnect(strHostIFmsg.drvHandler);
4401 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
4402 del_timer(&pstrWFIDrv->hScanTimer);
4403 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
4406 /*Allow chip sleep, only if both interfaces are not connected*/
4407 if (!linux_wlan_get_num_conn_ifcs())
4408 chip_sleep_manually(INFINITE_SLEEP_TIME);
4410 Handle_ScanDone(strHostIFmsg.drvHandler, SCAN_EVENT_DONE);
4413 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
4414 Handle_RemainOnChan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
4419 case HOST_IF_MSG_GET_RSSI:
4420 Handle_GetRssi(strHostIFmsg.drvHandler);
4423 case HOST_IF_MSG_GET_LINKSPEED:
4424 Handle_GetLinkspeed(strHostIFmsg.drvHandler);
4427 case HOST_IF_MSG_GET_STATISTICS:
4428 Handle_GetStatistics(strHostIFmsg.drvHandler, (tstrStatistics *)strHostIFmsg.uniHostIFmsgBody.pUserData);
4431 case HOST_IF_MSG_GET_CHNL:
4432 Handle_GetChnl(strHostIFmsg.drvHandler);
4435 #ifdef WILC_AP_EXTERNAL_MLME
4436 case HOST_IF_MSG_ADD_BEACON:
4437 Handle_AddBeacon(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFSetBeacon);
4440 case HOST_IF_MSG_DEL_BEACON:
4441 Handle_DelBeacon(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFDelBeacon);
4444 case HOST_IF_MSG_ADD_STATION:
4445 Handle_AddStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strAddStaParam);
4448 case HOST_IF_MSG_DEL_STATION:
4449 Handle_DelStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strDelStaParam);
4452 case HOST_IF_MSG_EDIT_STATION:
4453 Handle_EditStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strEditStaParam);
4456 case HOST_IF_MSG_GET_INACTIVETIME:
4457 Handle_Get_InActiveTime(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfStaInactiveT);
4460 #endif /*WILC_AP_EXTERNAL_MLME*/
4461 case HOST_IF_MSG_SCAN_TIMER_FIRED:
4462 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
4464 Handle_ScanDone(strHostIFmsg.drvHandler, SCAN_EVENT_ABORTED);
4467 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
4468 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
4469 Handle_ConnectTimeout(strHostIFmsg.drvHandler);
4472 case HOST_IF_MSG_POWER_MGMT:
4473 Handle_PowerManagement(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strPowerMgmtparam);
4476 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
4477 Handle_SetWfiDrvHandler(&strHostIFmsg.uniHostIFmsgBody.strHostIfSetDrvHandler);
4480 case HOST_IF_MSG_SET_OPERATION_MODE:
4481 Handle_SetOperationMode(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetOperationMode);
4484 case HOST_IF_MSG_SET_IPADDRESS:
4485 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
4486 Handle_set_IPAddress(strHostIFmsg.drvHandler, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx);
4489 case HOST_IF_MSG_GET_IPADDRESS:
4490 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
4491 Handle_get_IPAddress(strHostIFmsg.drvHandler, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx);
4495 case HOST_IF_MSG_SET_MAC_ADDRESS:
4496 Handle_SetMacAddress(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMacAddress);
4500 case HOST_IF_MSG_GET_MAC_ADDRESS:
4501 Handle_GetMacAddress(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfGetMacAddress);
4505 case HOST_IF_MSG_REMAIN_ON_CHAN:
4506 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
4507 Handle_RemainOnChan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
4510 case HOST_IF_MSG_REGISTER_FRAME:
4511 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
4512 Handle_RegisterFrame(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame);
4515 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
4516 Handle_ListenStateExpired(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
4520 case HOST_IF_MSG_SET_MULTICAST_FILTER:
4521 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
4522 Handle_SetMulticastFilter(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMulti);
4526 case HOST_IF_MSG_ADD_BA_SESSION:
4527 Handle_AddBASession(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo);
4530 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
4531 Handle_DelAllRxBASessions(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo);
4534 case HOST_IF_MSG_DEL_ALL_STA:
4535 Handle_DelAllSta(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFDelAllSta);
4539 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
4544 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
4545 up(&hSemHostIFthrdEnd);
4549 static void TimerCB_Scan(unsigned long arg)
4551 void *pvArg = (void *)arg;
4552 tstrHostIFmsg strHostIFmsg;
4554 /* prepare the Timer Callback message */
4555 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4556 strHostIFmsg.drvHandler = pvArg;
4557 strHostIFmsg.u16MsgId = HOST_IF_MSG_SCAN_TIMER_FIRED;
4559 /* send the message */
4560 WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
4563 static void TimerCB_Connect(unsigned long arg)
4565 void *pvArg = (void *)arg;
4566 tstrHostIFmsg strHostIFmsg;
4568 /* prepare the Timer Callback message */
4569 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4570 strHostIFmsg.drvHandler = pvArg;
4571 strHostIFmsg.u16MsgId = HOST_IF_MSG_CONNECT_TIMER_FIRED;
4573 /* send the message */
4574 WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
4579 * @brief removes wpa/wpa2 keys
4580 * @details only in BSS STA mode if External Supplicant support is enabled.
4581 * removes all WPA/WPA2 station key entries from MAC hardware.
4582 * @param[in,out] handle to the wifi driver
4583 * @param[in] 6 bytes of Station Adress in the station entry table
4584 * @return Error code indicating success/failure
4587 * @date 8 March 2012
4590 /* Check implementation in core adding 9 bytes to the input! */
4591 s32 host_int_remove_key(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8StaAddress)
4593 s32 s32Error = WILC_SUCCESS;
4595 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4597 strWID.u16WIDid = (u16)WID_REMOVE_KEY;
4598 strWID.enuWIDtype = WID_STR;
4599 strWID.ps8WidVal = (s8 *)pu8StaAddress;
4600 strWID.s32ValueSize = 6;
4607 * @brief removes WEP key
4608 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4609 * remove a WEP key entry from MAC HW.
4610 * The BSS Station automatically finds the index of the entry using its
4611 * BSS ID and removes that entry from the MAC hardware.
4612 * @param[in,out] handle to the wifi driver
4613 * @param[in] 6 bytes of Station Adress in the station entry table
4614 * @return Error code indicating success/failure
4615 * @note NO need for the STA add since it is not used for processing
4617 * @date 8 March 2012
4620 s32 host_int_remove_wep_key(tstrWILC_WFIDrv *hWFIDrv, u8 u8keyIdx)
4622 s32 s32Error = WILC_SUCCESS;
4623 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4624 tstrHostIFmsg strHostIFmsg;
4627 if (pstrWFIDrv == NULL)
4628 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4630 /* prepare the Remove Wep Key Message */
4631 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4634 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4635 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4636 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = REMOVEKEY;
4637 strHostIFmsg.drvHandler = hWFIDrv;
4641 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4642 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8keyIdx;
4644 /* send the message */
4645 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
4647 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
4648 down(&(pstrWFIDrv->hSemTestKeyBlock));
4650 WILC_CATCH(s32Error)
4658 * @brief sets WEP default key
4659 * @details Sets the index of the WEP encryption key in use,
4661 * @param[in,out] handle to the wifi driver
4662 * @param[in] key index ( 0, 1, 2, 3)
4663 * @return Error code indicating success/failure
4666 * @date 8 March 2012
4669 s32 host_int_set_WEPDefaultKeyID(tstrWILC_WFIDrv *hWFIDrv, u8 u8Index)
4671 s32 s32Error = WILC_SUCCESS;
4672 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4673 tstrHostIFmsg strHostIFmsg;
4676 if (pstrWFIDrv == NULL)
4677 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4679 /* prepare the Key Message */
4680 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4683 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4684 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4685 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = DEFAULTKEY;
4686 strHostIFmsg.drvHandler = hWFIDrv;
4689 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4690 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Index;
4692 /* send the message */
4693 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
4695 PRINT_ER("Error in sending message queue : Default key index\n");
4696 down(&(pstrWFIDrv->hSemTestKeyBlock));
4698 WILC_CATCH(s32Error)
4707 * @brief sets WEP deafault key
4708 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4709 * sets WEP key entry into MAC hardware when it receives the
4710 * corresponding request from NDIS.
4711 * @param[in,out] handle to the wifi driver
4712 * @param[in] message containing WEP Key in the following format
4713 *|---------------------------------------|
4714 *|Key ID Value | Key Length | Key |
4715 *|-------------|------------|------------|
4716 | 1byte | 1byte | Key Length |
4717 ||---------------------------------------|
4719 * @return Error code indicating success/failure
4722 * @date 8 March 2012
4725 s32 host_int_add_wep_key_bss_sta(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx)
4728 s32 s32Error = WILC_SUCCESS;
4729 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4730 tstrHostIFmsg strHostIFmsg;
4732 if (pstrWFIDrv == NULL)
4733 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4736 /* prepare the Key Message */
4737 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4740 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4741 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4742 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
4743 strHostIFmsg.drvHandler = hWFIDrv;
4746 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4747 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = WILC_MALLOC(u8WepKeylen);
4749 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
4750 pu8WepKey, u8WepKeylen);
4753 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4754 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4756 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4757 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4759 /* send the message */
4760 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
4762 PRINT_ER("Error in sending message queue :WEP Key\n");
4763 down(&(pstrWFIDrv->hSemTestKeyBlock));
4765 WILC_CATCH(s32Error)
4773 #ifdef WILC_AP_EXTERNAL_MLME
4776 * @brief host_int_add_wep_key_bss_ap
4777 * @details valid only in BSS AP mode if External Supplicant support is enabled.
4778 * sets WEP key entry into MAC hardware when it receives the
4780 * corresponding request from NDIS.
4781 * @param[in,out] handle to the wifi driver
4784 * @return Error code indicating success/failure
4790 s32 host_int_add_wep_key_bss_ap(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx, u8 u8mode, AUTHTYPE_T tenuAuth_type)
4793 s32 s32Error = WILC_SUCCESS;
4794 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4795 tstrHostIFmsg strHostIFmsg;
4798 if (pstrWFIDrv == NULL)
4799 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4802 /* prepare the Key Message */
4803 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4806 for (i = 0; i < u8WepKeylen; i++)
4807 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
4809 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4810 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4811 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
4812 strHostIFmsg.drvHandler = hWFIDrv;
4815 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4816 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = WILC_MALLOC((u8WepKeylen));
4819 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
4820 pu8WepKey, (u8WepKeylen));
4823 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4824 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4826 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4827 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4829 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4830 uniHostIFkeyAttr.strHostIFwepAttr.u8mode = u8mode;
4832 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4833 uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type = tenuAuth_type;
4834 /* send the message */
4835 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
4838 PRINT_ER("Error in sending message queue :WEP Key\n");
4839 down(&(pstrWFIDrv->hSemTestKeyBlock));
4841 WILC_CATCH(s32Error)
4850 * @brief adds ptk Key
4852 * @param[in,out] handle to the wifi driver
4853 * @param[in] message containing PTK Key in the following format
4854 *|-----------------------------------------------------------------------------|
4855 *|Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
4856 *|----------------|------------|--------------|----------------|---------------|
4857 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
4858 ||-----------------------------------------------------------------------------|
4859 * @return Error code indicating success/failure
4862 * @date 8 March 2012
4865 s32 host_int_add_ptk(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen,
4866 const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode, u8 u8Idx)
4868 s32 s32Error = WILC_SUCCESS;
4869 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4870 tstrHostIFmsg strHostIFmsg;
4871 u8 u8KeyLen = u8PtkKeylen;
4874 if (pstrWFIDrv == NULL)
4875 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4876 if (pu8RxMic != NULL)
4877 u8KeyLen += RX_MIC_KEY_LEN;
4878 if (pu8TxMic != NULL)
4879 u8KeyLen += TX_MIC_KEY_LEN;
4881 /* prepare the Key Message */
4882 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4885 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4886 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WPAPtk;
4887 #ifdef WILC_AP_EXTERNAL_MLME
4888 if (mode == AP_MODE) {
4889 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
4890 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4891 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8Idx;
4894 if (mode == STATION_MODE)
4895 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
4898 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4899 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = WILC_MALLOC(u8PtkKeylen);
4902 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
4903 pu8Ptk, u8PtkKeylen);
4905 if (pu8RxMic != NULL) {
4907 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
4908 pu8RxMic, RX_MIC_KEY_LEN);
4910 for (i = 0; i < RX_MIC_KEY_LEN; i++)
4911 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
4914 if (pu8TxMic != NULL) {
4916 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
4917 pu8TxMic, TX_MIC_KEY_LEN);
4919 for (i = 0; i < TX_MIC_KEY_LEN; i++)
4920 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
4924 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4925 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
4927 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4928 uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
4929 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4930 uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr = mac_addr;
4931 strHostIFmsg.drvHandler = hWFIDrv;
4933 /* send the message */
4934 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
4937 PRINT_ER("Error in sending message queue: PTK Key\n");
4939 /* ////////////// */
4940 down(&(pstrWFIDrv->hSemTestKeyBlock));
4943 WILC_CATCH(s32Error)
4952 * @brief adds Rx GTk Key
4954 * @param[in,out] handle to the wifi driver
4955 * @param[in] pu8RxGtk : contains temporal key | Rx Mic | Tx Mic
4956 * u8GtkKeylen :The total key length
4958 * @return Error code indicating success/failure
4961 * @date 8 March 2012
4964 s32 host_int_add_rx_gtk(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen,
4965 u8 u8KeyIdx, u32 u32KeyRSClen, const u8 *KeyRSC,
4966 const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode)
4968 s32 s32Error = WILC_SUCCESS;
4969 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4970 tstrHostIFmsg strHostIFmsg;
4971 u8 u8KeyLen = u8GtkKeylen;
4973 if (pstrWFIDrv == NULL)
4974 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4975 /* prepare the Key Message */
4976 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
4979 if (pu8RxMic != NULL)
4980 u8KeyLen += RX_MIC_KEY_LEN;
4981 if (pu8TxMic != NULL)
4982 u8KeyLen += TX_MIC_KEY_LEN;
4983 if (KeyRSC != NULL) {
4984 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4985 uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq = WILC_MALLOC(u32KeyRSClen);
4987 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq,
4988 KeyRSC, u32KeyRSClen);
4992 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4993 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WPARxGtk;
4994 strHostIFmsg.drvHandler = hWFIDrv;
4996 #ifdef WILC_AP_EXTERNAL_MLME
4997 if (mode == AP_MODE) {
4998 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
4999 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
5002 if (mode == STATION_MODE)
5003 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
5006 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5007 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = WILC_MALLOC(u8KeyLen);
5009 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
5010 pu8RxGtk, u8GtkKeylen);
5012 if (pu8RxMic != NULL) {
5014 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
5015 pu8RxMic, RX_MIC_KEY_LEN);
5018 if (pu8TxMic != NULL) {
5020 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
5021 pu8TxMic, TX_MIC_KEY_LEN);
5025 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5026 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8KeyIdx;
5027 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5028 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
5030 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5031 uniHostIFkeyAttr.strHostIFwpaAttr.u8seqlen = u32KeyRSClen;
5035 /* send the message */
5036 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5038 PRINT_ER("Error in sending message queue: RX GTK\n");
5039 /* ////////////// */
5040 down(&(pstrWFIDrv->hSemTestKeyBlock));
5043 WILC_CATCH(s32Error)
5051 * @brief host_int_set_pmkid_info
5052 * @details caches the pmkid valid only in BSS STA mode if External Supplicant
5053 * support is enabled. This Function sets the PMKID in firmware
5054 * when host drivr receives the corresponding request from NDIS.
5055 * The firmware then includes theset PMKID in the appropriate
5057 * @param[in,out] handle to the wifi driver
5058 * @param[in] message containing PMKID Info in the following format
5059 *|-----------------------------------------------------------------|
5060 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
5061 *|-----------|------------|----------|-------|----------|----------|
5062 | 1 | 6 | 16 | ... | 6 | 16 |
5063 ||-----------------------------------------------------------------|
5064 * @return Error code indicating success/failure
5067 * @date 8 March 2012
5070 s32 host_int_set_pmkid_info(tstrWILC_WFIDrv *hWFIDrv, tstrHostIFpmkidAttr *pu8PmkidInfoArray)
5072 s32 s32Error = WILC_SUCCESS;
5073 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5074 tstrHostIFmsg strHostIFmsg;
5078 if (pstrWFIDrv == NULL)
5079 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5081 /* prepare the Key Message */
5082 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5084 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
5085 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = PMKSA;
5086 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
5087 strHostIFmsg.drvHandler = hWFIDrv;
5089 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
5091 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
5094 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
5098 /* send the message */
5099 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5101 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
5103 WILC_CATCH(s32Error)
5112 * @brief gets the cached the pmkid info
5113 * @details valid only in BSS STA mode if External Supplicant
5114 * support is enabled. This Function sets the PMKID in firmware
5115 * when host drivr receives the corresponding request from NDIS.
5116 * The firmware then includes theset PMKID in the appropriate
5118 * @param[in,out] handle to the wifi driver,
5119 * message containing PMKID Info in the following format
5120 *|-----------------------------------------------------------------|
5121 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
5122 *|-----------|------------|----------|-------|----------|----------|
5123 | 1 | 6 | 16 | ... | 6 | 16 |
5124 ||-----------------------------------------------------------------|
5126 * @return Error code indicating success/failure
5129 * @date 8 March 2012
5132 s32 host_int_get_pmkid_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8PmkidInfoArray,
5133 u32 u32PmkidInfoLen)
5135 s32 s32Error = WILC_SUCCESS;
5137 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5139 strWID.u16WIDid = (u16)WID_PMKID_INFO;
5140 strWID.enuWIDtype = WID_STR;
5141 strWID.s32ValueSize = u32PmkidInfoLen;
5142 strWID.ps8WidVal = pu8PmkidInfoArray;
5148 * @brief sets the pass phrase
5149 * @details AP/STA mode. This function gives the pass phrase used to
5150 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5151 * The length of the field can vary from 8 to 64 bytes,
5152 * the lower layer should get the
5153 * @param[in,out] handle to the wifi driver,
5154 * @param[in] String containing PSK
5155 * @return Error code indicating success/failure
5158 * @date 8 March 2012
5161 s32 host_int_set_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8PassPhrase,
5164 s32 s32Error = WILC_SUCCESS;
5167 /*validating psk length*/
5168 if ((u8Psklength > 7) && (u8Psklength < 65)) {
5169 strWID.u16WIDid = (u16)WID_11I_PSK;
5170 strWID.enuWIDtype = WID_STR;
5171 strWID.ps8WidVal = pu8PassPhrase;
5172 strWID.s32ValueSize = u8Psklength;
5178 * @brief host_int_get_MacAddress
5179 * @details gets mac address
5180 * @param[in,out] handle to the wifi driver,
5182 * @return Error code indicating success/failure
5185 * @date 19 April 2012
5188 s32 host_int_get_MacAddress(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8MacAddress)
5190 s32 s32Error = WILC_SUCCESS;
5191 tstrHostIFmsg strHostIFmsg;
5194 /* prepare the Message */
5195 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5197 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_MAC_ADDRESS;
5198 strHostIFmsg.uniHostIFmsgBody.strHostIfGetMacAddress.u8MacAddress = pu8MacAddress;
5199 strHostIFmsg.drvHandler = hWFIDrv;
5200 /* send the message */
5201 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5203 PRINT_ER("Failed to send get mac address\n");
5207 down(&hWaitResponse);
5212 * @brief host_int_set_MacAddress
5213 * @details sets mac address
5214 * @param[in,out] handle to the wifi driver,
5216 * @return Error code indicating success/failure
5219 * @date 16 July 2012
5222 s32 host_int_set_MacAddress(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8MacAddress)
5224 s32 s32Error = WILC_SUCCESS;
5225 tstrHostIFmsg strHostIFmsg;
5227 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
5229 /* prepare setting mac address message */
5230 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5231 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_MAC_ADDRESS;
5232 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIfSetMacAddress.u8MacAddress, pu8MacAddress, ETH_ALEN);
5233 strHostIFmsg.drvHandler = hWFIDrv;
5235 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5237 PRINT_ER("Failed to send message queue: Set mac address\n");
5238 WILC_ERRORREPORT(s32Error, s32Error);
5240 WILC_CATCH(s32Error)
5250 * @brief host_int_get_RSNAConfigPSKPassPhrase
5251 * @details gets the pass phrase:AP/STA mode. This function gets the pass phrase used to
5252 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5253 * The length of the field can vary from 8 to 64 bytes,
5254 * the lower layer should get the
5255 * @param[in,out] handle to the wifi driver,
5256 * String containing PSK
5257 * @return Error code indicating success/failure
5260 * @date 8 March 2012
5263 s32 host_int_get_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv *hWFIDrv,
5264 u8 *pu8PassPhrase, u8 u8Psklength)
5266 s32 s32Error = WILC_SUCCESS;
5268 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5270 strWID.u16WIDid = (u16)WID_11I_PSK;
5271 strWID.enuWIDtype = WID_STR;
5272 strWID.s32ValueSize = u8Psklength;
5273 strWID.ps8WidVal = pu8PassPhrase;
5279 * @brief host_int_get_site_survey_results
5280 * @details gets the site survey results
5281 * @param[in,out] handle to the wifi driver,
5282 * Message containing site survey results in the
5284 *|---------------------------------------------------|
5285 | MsgLength | fragNo. | MsgBodyLength | MsgBody |
5286 ||-----------|-----------|---------------|-----------|
5288 | ----------------------------------------- | ----------------
5290 ||---------------------------------------|
5291 | Network1 | Netweork2 | ... | Network5 |
5292 ||---------------------------------------|
5293 | 44 | 44 | ... | 44 |
5294 | -------------------------- | ---------------------------------------
5296 ||---------------------------------------------------------------------|
5297 | SSID | BSS Type | Channel | Security Status| BSSID | RSSI |Reserved |
5300 ||------|----------|---------|----------------|-------|------|---------|
5301 | 33 | 1 | 1 | 1 | 6 | 1 | 1 |
5302 ||---------------------------------------------------------------------|
5303 * @return Error code indicating success/failure
5306 * @date 8 March 2012
5309 #ifndef CONNECT_DIRECT
5310 s32 host_int_get_site_survey_results(tstrWILC_WFIDrv *hWFIDrv,
5311 u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE],
5312 u32 u32MaxSiteSrvyFragLen)
5314 s32 s32Error = WILC_SUCCESS;
5315 tstrWID astrWIDList[2];
5316 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5318 astrWIDList[0].u16WIDid = (u16)WID_SITE_SURVEY_RESULTS;
5319 astrWIDList[0].enuWIDtype = WID_STR;
5320 astrWIDList[0].ps8WidVal = ppu8RcvdSiteSurveyResults[0];
5321 astrWIDList[0].s32ValueSize = u32MaxSiteSrvyFragLen;
5323 astrWIDList[1].u16WIDid = (u16)WID_SITE_SURVEY_RESULTS;
5324 astrWIDList[1].enuWIDtype = WID_STR;
5325 astrWIDList[1].ps8WidVal = ppu8RcvdSiteSurveyResults[1];
5326 astrWIDList[1].s32ValueSize = u32MaxSiteSrvyFragLen;
5328 s32Error = SendConfigPkt(GET_CFG, astrWIDList, 2, true, (u32)pstrWFIDrv);
5330 /*get the value by searching the local copy*/
5332 PRINT_ER("Failed to send config packet to get survey results\n");
5333 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
5336 WILC_CATCH(s32Error)
5346 * @brief sets a start scan request
5348 * @param[in,out] handle to the wifi driver,
5349 * @param[in] Scan Source one of the following values
5352 * OBSS_PERIODIC_SCAN BIT1
5353 * OBSS_ONETIME_SCAN BIT2
5354 * @return Error code indicating success/failure
5357 * @date 8 March 2012
5360 s32 host_int_set_start_scan_req(tstrWILC_WFIDrv *hWFIDrv, u8 scanSource)
5362 s32 s32Error = WILC_SUCCESS;
5364 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5366 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
5367 strWID.enuWIDtype = WID_CHAR;
5368 strWID.ps8WidVal = (s8 *)&scanSource;
5369 strWID.s32ValueSize = sizeof(char);
5375 * @brief host_int_get_start_scan_req
5376 * @details gets a start scan request
5377 * @param[in,out] handle to the wifi driver,
5378 * @param[in] Scan Source one of the following values
5381 * OBSS_PERIODIC_SCAN BIT1
5382 * OBSS_ONETIME_SCAN BIT2
5383 * @return Error code indicating success/failure
5386 * @date 8 March 2012
5390 s32 host_int_get_start_scan_req(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8ScanSource)
5392 s32 s32Error = WILC_SUCCESS;
5394 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5396 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
5397 strWID.enuWIDtype = WID_CHAR;
5398 strWID.ps8WidVal = (s8 *)pu8ScanSource;
5399 strWID.s32ValueSize = sizeof(char);
5405 * @brief host_int_set_join_req
5406 * @details sets a join request
5407 * @param[in,out] handle to the wifi driver,
5408 * @param[in] Index of the bss descriptor
5409 * @return Error code indicating success/failure
5412 * @date 8 March 2012
5415 s32 host_int_set_join_req(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8bssid,
5416 const u8 *pu8ssid, size_t ssidLen,
5417 const u8 *pu8IEs, size_t IEsLen,
5418 tWILCpfConnectResult pfConnectResult, void *pvUserArg,
5419 u8 u8security, AUTHTYPE_T tenuAuth_type,
5423 s32 s32Error = WILC_SUCCESS;
5424 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5425 tstrHostIFmsg strHostIFmsg;
5426 tenuScanConnTimer enuScanConnTimer;
5428 if (pstrWFIDrv == NULL || pfConnectResult == NULL)
5429 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5431 if (hWFIDrv == NULL) {
5432 PRINT_ER("Driver not initialized: gWFiDrvHandle = NULL\n");
5433 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5436 if (pJoinParams == NULL) {
5437 PRINT_ER("Unable to Join - JoinParams is NULL\n");
5438 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5442 * if(gWFiDrvHandle->strWILC_UsrScanReq.u32RcvdChCount == 0)
5444 * PRINT_ER("No scan results exist: Scanning should be done\n");
5445 * WILC_ERRORREPORT(s32Error, WILC_FAIL);
5448 /* prepare the Connect Message */
5449 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5451 strHostIFmsg.u16MsgId = HOST_IF_MSG_CONNECT;
5453 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.u8security = u8security;
5454 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.tenuAuth_type = tenuAuth_type;
5455 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.u8channel = u8channel;
5456 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pfConnectResult = pfConnectResult;
5457 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pvUserArg = pvUserArg;
5458 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pJoinParams = pJoinParams;
5459 strHostIFmsg.drvHandler = hWFIDrv;
5461 if (pu8bssid != NULL) {
5462 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8bssid = WILC_MALLOC(6); /* will be deallocated by the receiving thread */
5463 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8bssid,
5467 if (pu8ssid != NULL) {
5468 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.ssidLen = ssidLen;
5469 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8ssid = WILC_MALLOC(ssidLen); /* will be deallocated by the receiving thread */
5470 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8ssid,
5475 if (pu8IEs != NULL) {
5476 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.IEsLen = IEsLen;
5477 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8IEs = WILC_MALLOC(IEsLen); /* will be deallocated by the receiving thread */
5478 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8IEs,
5481 if (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTING)
5482 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTING;
5484 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", pstrWFIDrv->enuHostIFstate);
5486 /* send the message */
5487 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5489 PRINT_ER("Failed to send message queue: Set join request\n");
5490 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5493 enuScanConnTimer = CONNECT_TIMER;
5494 pstrWFIDrv->hConnectTimer.data = (unsigned long)hWFIDrv;
5495 mod_timer(&pstrWFIDrv->hConnectTimer,
5496 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
5498 WILC_CATCH(s32Error)
5507 * @brief Flush a join request parameters to FW, but actual connection
5508 * @details The function is called in situation where WILC is connected to AP and
5509 * required to switch to hybrid FW for P2P connection
5510 * @param[in] handle to the wifi driver,
5511 * @return Error code indicating success/failure
5513 * @author Amr Abdel-Moghny
5518 s32 host_int_flush_join_req(tstrWILC_WFIDrv *hWFIDrv)
5520 s32 s32Error = WILC_SUCCESS;
5521 tstrHostIFmsg strHostIFmsg;
5523 if (!gu8FlushedJoinReq) {
5524 s32Error = WILC_FAIL;
5529 if (hWFIDrv == NULL)
5530 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5533 strHostIFmsg.u16MsgId = HOST_IF_MSG_FLUSH_CONNECT;
5534 strHostIFmsg.drvHandler = hWFIDrv;
5536 /* send the message */
5537 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5539 PRINT_ER("Failed to send message queue: Flush join request\n");
5540 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5543 WILC_CATCH(s32Error)
5551 * @brief host_int_disconnect
5552 * @details disconnects from the currently associated network
5553 * @param[in,out] handle to the wifi driver,
5554 * @param[in] Reason Code of the Disconnection
5555 * @return Error code indicating success/failure
5558 * @date 8 March 2012
5561 s32 host_int_disconnect(tstrWILC_WFIDrv *hWFIDrv, u16 u16ReasonCode)
5563 s32 s32Error = WILC_SUCCESS;
5564 tstrHostIFmsg strHostIFmsg;
5565 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5567 if (pstrWFIDrv == NULL) {
5568 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
5569 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5572 if (pstrWFIDrv == NULL) {
5573 PRINT_ER("gWFiDrvHandle = NULL\n");
5574 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5577 /* prepare the Disconnect Message */
5578 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5580 strHostIFmsg.u16MsgId = HOST_IF_MSG_DISCONNECT;
5581 strHostIFmsg.drvHandler = hWFIDrv;
5583 /* send the message */
5584 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5586 PRINT_ER("Failed to send message queue: disconnect\n");
5587 /* ////////////// */
5588 down(&(pstrWFIDrv->hSemTestDisconnectBlock));
5591 WILC_CATCH(s32Error)
5600 * @brief host_int_disconnect_station
5601 * @details disconnects a sta
5602 * @param[in,out] handle to the wifi driver,
5603 * @param[in] Association Id of the station to be disconnected
5604 * @return Error code indicating success/failure
5607 * @date 8 March 2012
5610 s32 host_int_disconnect_station(tstrWILC_WFIDrv *hWFIDrv, u8 assoc_id)
5612 s32 s32Error = WILC_SUCCESS;
5614 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5616 strWID.u16WIDid = (u16)WID_DISCONNECT;
5617 strWID.enuWIDtype = WID_CHAR;
5618 strWID.ps8WidVal = (s8 *)&assoc_id;
5619 strWID.s32ValueSize = sizeof(char);
5625 * @brief host_int_get_assoc_req_info
5626 * @details gets a Association request info
5627 * @param[in,out] handle to the wifi driver,
5628 * Message containg assoc. req info in the following format
5629 * ------------------------------------------------------------------------
5630 | Management Frame Format |
5631 ||-------------------------------------------------------------------|
5632 ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS |
5633 ||-------------|--------|--|--|-----|----------------|----------|----|
5634 | 2 |2 |6 |6 |6 | 2 |0 - 2312 | 4 |
5635 ||-------------------------------------------------------------------|
5637 | Association Request Frame - Frame Body |
5638 ||-------------------------------------------------------------------|
5639 | Capability Information | Listen Interval | SSID | Supported Rates |
5640 ||------------------------|-----------------|------|-----------------|
5641 | 2 | 2 | 2-34 | 3-10 |
5642 | ---------------------------------------------------------------------
5643 * @return Error code indicating success/failure
5646 * @date 8 March 2012
5650 s32 host_int_get_assoc_req_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8AssocReqInfo,
5651 u32 u32AssocReqInfoLen)
5653 s32 s32Error = WILC_SUCCESS;
5655 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5657 strWID.u16WIDid = (u16)WID_ASSOC_REQ_INFO;
5658 strWID.enuWIDtype = WID_STR;
5659 strWID.ps8WidVal = pu8AssocReqInfo;
5660 strWID.s32ValueSize = u32AssocReqInfoLen;
5667 * @brief gets a Association Response info
5669 * @param[in,out] handle to the wifi driver,
5670 * Message containg assoc. resp info
5671 * @return Error code indicating success/failure
5674 * @date 8 March 2012
5677 s32 host_int_get_assoc_res_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8AssocRespInfo,
5678 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
5680 s32 s32Error = WILC_SUCCESS;
5682 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5684 if (pstrWFIDrv == NULL) {
5685 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
5686 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5689 strWID.u16WIDid = (u16)WID_ASSOC_RES_INFO;
5690 strWID.enuWIDtype = WID_STR;
5691 strWID.ps8WidVal = pu8AssocRespInfo;
5692 strWID.s32ValueSize = u32MaxAssocRespInfoLen;
5695 /* Sending Configuration packet */
5696 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
5698 PRINT_ER("Failed to send association response config packet\n");
5699 *pu32RcvdAssocRespInfoLen = 0;
5700 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
5702 *pu32RcvdAssocRespInfoLen = strWID.s32ValueSize;
5705 WILC_CATCH(s32Error)
5713 * @brief gets a Association Response info
5714 * @details Valid only in STA mode. This function gives the RSSI
5715 * values observed in all the channels at the time of scanning.
5716 * The length of the field is 1 greater that the total number of
5717 * channels supported. Byte 0 contains the number of channels while
5718 * each of Byte N contains the observed RSSI value for the channel index N.
5719 * @param[in,out] handle to the wifi driver,
5720 * array of scanned channels' RSSI
5721 * @return Error code indicating success/failure
5724 * @date 8 March 2012
5727 s32 host_int_get_rx_power_level(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8RxPowerLevel,
5728 u32 u32RxPowerLevelLen)
5730 s32 s32Error = WILC_SUCCESS;
5732 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5734 strWID.u16WIDid = (u16)WID_RX_POWER_LEVEL;
5735 strWID.enuWIDtype = WID_STR;
5736 strWID.ps8WidVal = pu8RxPowerLevel;
5737 strWID.s32ValueSize = u32RxPowerLevelLen;
5744 * @brief sets a channel
5746 * @param[in,out] handle to the wifi driver,
5747 * @param[in] Index of the channel to be set
5748 *|-------------------------------------------------------------------|
5749 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5751 ||-------------------------------------------------------------------|
5752 * @return Error code indicating success/failure
5755 * @date 8 March 2012
5758 s32 host_int_set_mac_chnl_num(tstrWILC_WFIDrv *hWFIDrv, u8 u8ChNum)
5760 s32 s32Error = WILC_SUCCESS;
5761 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5762 tstrHostIFmsg strHostIFmsg;
5764 if (pstrWFIDrv == NULL)
5765 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5767 /* prepare the set channel message */
5768 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5769 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_CHANNEL;
5770 strHostIFmsg.uniHostIFmsgBody.strHostIFSetChan.u8SetChan = u8ChNum;
5771 strHostIFmsg.drvHandler = hWFIDrv;
5773 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5775 WILC_ERRORREPORT(s32Error, s32Error);
5776 WILC_CATCH(s32Error)
5785 s32 host_int_wait_msg_queue_idle(void)
5787 s32 s32Error = WILC_SUCCESS;
5789 tstrHostIFmsg strHostIFmsg;
5791 /* prepare the set driver handler message */
5793 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5794 strHostIFmsg.u16MsgId = HOST_IF_MSG_Q_IDLE;
5795 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5797 WILC_ERRORREPORT(s32Error, s32Error);
5798 WILC_CATCH(s32Error)
5803 /* wait untill MSG Q is empty */
5804 down(&hWaitResponse);
5810 s32 host_int_set_wfi_drv_handler(tstrWILC_WFIDrv *u32address)
5812 s32 s32Error = WILC_SUCCESS;
5814 tstrHostIFmsg strHostIFmsg;
5817 /* prepare the set driver handler message */
5819 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5820 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_WFIDRV_HANDLER;
5821 strHostIFmsg.uniHostIFmsgBody.strHostIfSetDrvHandler.u32Address = u32address;
5822 /* strHostIFmsg.drvHandler=hWFIDrv; */
5824 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5826 WILC_ERRORREPORT(s32Error, s32Error);
5827 WILC_CATCH(s32Error)
5837 s32 host_int_set_operation_mode(tstrWILC_WFIDrv *hWFIDrv, u32 u32mode)
5839 s32 s32Error = WILC_SUCCESS;
5841 tstrHostIFmsg strHostIFmsg;
5844 /* prepare the set driver handler message */
5846 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5847 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_OPERATION_MODE;
5848 strHostIFmsg.uniHostIFmsgBody.strHostIfSetOperationMode.u32Mode = u32mode;
5849 strHostIFmsg.drvHandler = hWFIDrv;
5851 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5853 WILC_ERRORREPORT(s32Error, s32Error);
5854 WILC_CATCH(s32Error)
5863 * @brief gets the current channel index
5865 * @param[in,out] handle to the wifi driver,
5866 * current channel index
5867 *|-----------------------------------------------------------------------|
5868 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5870 ||-----------------------------------------------------------------------|
5871 * @return Error code indicating success/failure
5874 * @date 8 March 2012
5877 s32 host_int_get_host_chnl_num(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8ChNo)
5879 s32 s32Error = WILC_SUCCESS;
5880 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5881 tstrHostIFmsg strHostIFmsg;
5883 if (pstrWFIDrv == NULL) {
5884 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
5885 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5888 /* prepare the Get Channel Message */
5889 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5891 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_CHNL;
5892 strHostIFmsg.drvHandler = hWFIDrv;
5894 /* send the message */
5895 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5897 PRINT_ER("Failed to send get host channel param's message queue ");
5898 down(&(pstrWFIDrv->hSemGetCHNL));
5903 WILC_CATCH(s32Error)
5914 * @brief host_int_test_set_int_wid
5915 * @details Test function for setting wids
5916 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr
5917 * @return Error code indicating success/failure
5920 * @date 8 March 2012
5923 s32 host_int_test_set_int_wid(tstrWILC_WFIDrv *hWFIDrv, u32 u32TestMemAddr)
5925 s32 s32Error = WILC_SUCCESS;
5927 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5930 if (pstrWFIDrv == NULL) {
5931 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
5932 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5935 /*prepare configuration packet*/
5936 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
5937 strWID.enuWIDtype = WID_INT;
5938 strWID.ps8WidVal = (char *)&u32TestMemAddr;
5939 strWID.s32ValueSize = sizeof(u32);
5942 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
5944 PRINT_ER("Test Function: Failed to set wid value\n");
5945 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
5947 PRINT_D(HOSTINF_DBG, "Successfully set wid value\n");
5951 WILC_CATCH(s32Error)
5958 #ifdef WILC_AP_EXTERNAL_MLME
5960 * @brief host_int_get_inactive_time
5962 * @param[in,out] handle to the wifi driver,
5963 * current sta macaddress, inactive_time
5970 s32 host_int_get_inactive_time(tstrWILC_WFIDrv *hWFIDrv, const u8 *mac, u32 *pu32InactiveTime)
5972 s32 s32Error = WILC_SUCCESS;
5973 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5974 tstrHostIFmsg strHostIFmsg;
5976 if (pstrWFIDrv == NULL) {
5977 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
5978 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5981 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
5984 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIfStaInactiveT.mac,
5987 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_INACTIVETIME;
5988 strHostIFmsg.drvHandler = hWFIDrv;
5990 /* send the message */
5991 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
5993 PRINT_ER("Failed to send get host channel param's message queue ");
5995 down(&(pstrWFIDrv->hSemInactiveTime));
5997 *pu32InactiveTime = gu32InactiveTime;
5999 WILC_CATCH(s32Error)
6007 * @brief host_int_test_get_int_wid
6008 * @details Test function for getting wids
6009 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32* pu32TestMemAddr
6010 * @return Error code indicating success/failure
6013 * @date 8 March 2012
6016 s32 host_int_test_get_int_wid(tstrWILC_WFIDrv *hWFIDrv, u32 *pu32TestMemAddr)
6019 s32 s32Error = WILC_SUCCESS;
6021 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6024 if (pstrWFIDrv == NULL) {
6025 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
6026 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6029 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
6030 strWID.enuWIDtype = WID_INT;
6031 strWID.ps8WidVal = (s8 *)pu32TestMemAddr;
6032 strWID.s32ValueSize = sizeof(u32);
6034 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
6035 /*get the value by searching the local copy*/
6037 PRINT_ER("Test Function: Failed to get wid value\n");
6038 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
6040 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
6044 WILC_CATCH(s32Error)
6053 * @brief host_int_get_rssi
6054 * @details gets the currently maintained RSSI value for the station.
6055 * The received signal strength value in dB.
6056 * The range of valid values is -128 to 0.
6057 * @param[in,out] handle to the wifi driver,
6059 * @return Error code indicating success/failure
6062 * @date 8 March 2012
6065 s32 host_int_get_rssi(tstrWILC_WFIDrv *hWFIDrv, s8 *ps8Rssi)
6067 s32 s32Error = WILC_SUCCESS;
6068 tstrHostIFmsg strHostIFmsg;
6069 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6072 /* prepare the Get RSSI Message */
6073 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6075 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_RSSI;
6076 strHostIFmsg.drvHandler = hWFIDrv;
6078 /* send the message */
6079 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
6081 PRINT_ER("Failed to send get host channel param's message queue ");
6085 down(&(pstrWFIDrv->hSemGetRSSI));
6088 if (ps8Rssi == NULL) {
6089 PRINT_ER("RSS pointer value is null");
6100 s32 host_int_get_link_speed(tstrWILC_WFIDrv *hWFIDrv, s8 *ps8lnkspd)
6102 tstrHostIFmsg strHostIFmsg;
6103 s32 s32Error = WILC_SUCCESS;
6105 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6109 /* prepare the Get LINKSPEED Message */
6110 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6112 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_LINKSPEED;
6113 strHostIFmsg.drvHandler = hWFIDrv;
6115 /* send the message */
6116 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
6118 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
6122 down(&(pstrWFIDrv->hSemGetLINKSPEED));
6125 if (ps8lnkspd == NULL) {
6126 PRINT_ER("LINKSPEED pointer value is null");
6131 *ps8lnkspd = gs8lnkspd;
6137 s32 host_int_get_statistics(tstrWILC_WFIDrv *hWFIDrv, tstrStatistics *pstrStatistics)
6139 s32 s32Error = WILC_SUCCESS;
6140 tstrHostIFmsg strHostIFmsg;
6143 /* prepare the Get RSSI Message */
6144 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6146 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_STATISTICS;
6147 strHostIFmsg.uniHostIFmsgBody.pUserData = (char *)pstrStatistics;
6148 strHostIFmsg.drvHandler = hWFIDrv;
6149 /* send the message */
6150 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
6152 PRINT_ER("Failed to send get host channel param's message queue ");
6156 down(&hWaitResponse);
6162 * @brief host_int_scan
6163 * @details scans a set of channels
6164 * @param[in,out] handle to the wifi driver,
6165 * @param[in] Scan source
6166 * Scan Type PASSIVE_SCAN = 0,
6169 * Channels Array length
6170 * Scan Callback function
6171 * @return Error code indicating success/failure
6174 * @date 8 March 2012
6177 s32 host_int_scan(tstrWILC_WFIDrv *hWFIDrv, u8 u8ScanSource,
6178 u8 u8ScanType, u8 *pu8ChnlFreqList,
6179 u8 u8ChnlListLen, const u8 *pu8IEs,
6180 size_t IEsLen, tWILCpfScanResult ScanResult,
6181 void *pvUserArg, tstrHiddenNetwork *pstrHiddenNetwork)
6183 s32 s32Error = WILC_SUCCESS;
6184 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6185 tstrHostIFmsg strHostIFmsg;
6186 tenuScanConnTimer enuScanConnTimer;
6188 if (pstrWFIDrv == NULL || ScanResult == NULL)
6189 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6192 /* prepare the Scan Message */
6193 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6195 strHostIFmsg.u16MsgId = HOST_IF_MSG_SCAN;
6197 if (pstrHiddenNetwork != NULL) {
6198 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.strHiddenNetwork.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
6199 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.strHiddenNetwork.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
6202 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
6204 strHostIFmsg.drvHandler = hWFIDrv;
6205 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ScanSource = u8ScanSource;
6206 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ScanType = u8ScanType;
6207 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pfScanResult = ScanResult;
6208 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pvUserArg = pvUserArg;
6210 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ChnlListLen = u8ChnlListLen;
6211 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8ChnlFreqList = WILC_MALLOC(u8ChnlListLen); /* will be deallocated by the receiving thread */
6212 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8ChnlFreqList,
6213 pu8ChnlFreqList, u8ChnlListLen);
6215 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.IEsLen = IEsLen;
6216 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8IEs = WILC_MALLOC(IEsLen); /* will be deallocated by the receiving thread */
6217 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8IEs,
6220 /* send the message */
6221 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
6223 PRINT_ER("Error in sending message queue scanning parameters: Error(%d)\n", s32Error);
6224 WILC_ERRORREPORT(s32Error, WILC_FAIL);
6227 enuScanConnTimer = SCAN_TIMER;
6228 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
6229 pstrWFIDrv->hScanTimer.data = (unsigned long)hWFIDrv;
6230 mod_timer(&pstrWFIDrv->hScanTimer,
6231 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
6233 WILC_CATCH(s32Error)
6241 * @brief hif_set_cfg
6242 * @details sets configuration wids values
6243 * @param[in,out] handle to the wifi driver,
6244 * @param[in] WID, WID value
6245 * @return Error code indicating success/failure
6248 * @date 8 March 2012
6251 s32 hif_set_cfg(tstrWILC_WFIDrv *hWFIDrv, tstrCfgParamVal *pstrCfgParamVal)
6254 s32 s32Error = WILC_SUCCESS;
6255 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6257 tstrHostIFmsg strHostIFmsg;
6260 if (pstrWFIDrv == NULL)
6261 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6262 /* prepare the WiphyParams Message */
6263 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6264 strHostIFmsg.u16MsgId = HOST_IF_MSG_CFG_PARAMS;
6265 strHostIFmsg.uniHostIFmsgBody.strHostIFCfgParamAttr.pstrCfgParamVal = *pstrCfgParamVal;
6266 strHostIFmsg.drvHandler = hWFIDrv;
6268 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
6270 WILC_CATCH(s32Error)
6280 * @brief hif_get_cfg
6281 * @details gets configuration wids values
6282 * @param[in,out] handle to the wifi driver,
6285 * @return Error code indicating success/failure
6289 * @date 8 March 2012
6292 s32 hif_get_cfg(tstrWILC_WFIDrv *hWFIDrv, u16 u16WID, u16 *pu16WID_Value)
6294 s32 s32Error = WILC_SUCCESS;
6295 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6297 down(&(pstrWFIDrv->gtOsCfgValuesSem));
6299 if (pstrWFIDrv == NULL) {
6300 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
6301 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6303 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
6307 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.bss_type;
6311 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.auth_type;
6314 case WID_AUTH_TIMEOUT:
6315 *pu16WID_Value = pstrWFIDrv->strCfgValues.auth_timeout;
6318 case WID_POWER_MANAGEMENT:
6319 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.power_mgmt_mode;
6322 case WID_SHORT_RETRY_LIMIT:
6323 *pu16WID_Value = pstrWFIDrv->strCfgValues.short_retry_limit;
6326 case WID_LONG_RETRY_LIMIT:
6327 *pu16WID_Value = pstrWFIDrv->strCfgValues.long_retry_limit;
6330 case WID_FRAG_THRESHOLD:
6331 *pu16WID_Value = pstrWFIDrv->strCfgValues.frag_threshold;
6334 case WID_RTS_THRESHOLD:
6335 *pu16WID_Value = pstrWFIDrv->strCfgValues.rts_threshold;
6339 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.preamble_type;
6342 case WID_SHORT_SLOT_ALLOWED:
6343 *pu16WID_Value = (u16) pstrWFIDrv->strCfgValues.short_slot_allowed;
6346 case WID_11N_TXOP_PROT_DISABLE:
6347 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.txop_prot_disabled;
6350 case WID_BEACON_INTERVAL:
6351 *pu16WID_Value = pstrWFIDrv->strCfgValues.beacon_interval;
6354 case WID_DTIM_PERIOD:
6355 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.dtim_period;
6358 case WID_SITE_SURVEY:
6359 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.site_survey_enabled;
6362 case WID_SITE_SURVEY_SCAN_TIME:
6363 *pu16WID_Value = pstrWFIDrv->strCfgValues.site_survey_scan_time;
6366 case WID_ACTIVE_SCAN_TIME:
6367 *pu16WID_Value = pstrWFIDrv->strCfgValues.active_scan_time;
6370 case WID_PASSIVE_SCAN_TIME:
6371 *pu16WID_Value = pstrWFIDrv->strCfgValues.passive_scan_time;
6374 case WID_CURRENT_TX_RATE:
6375 *pu16WID_Value = pstrWFIDrv->strCfgValues.curr_tx_rate;
6382 up(&(pstrWFIDrv->gtOsCfgValuesSem));
6384 WILC_CATCH(s32Error)
6391 /*****************************************************************************/
6392 /* Notification Functions */
6393 /*****************************************************************************/
6395 * @brief notifies host with join and leave requests
6396 * @details This function prepares an Information frame having the
6397 * information about a joining/leaving station.
6398 * @param[in,out] handle to the wifi driver,
6399 * @param[in] 6 byte Sta Adress
6400 * Join or leave flag:
6403 * @return Error code indicating success/failure
6406 * @date 8 March 2012
6409 void host_int_send_join_leave_info_to_host
6410 (u16 assocId, u8 *stationAddr, bool joining)
6414 * @brief notifies host with stations found in scan
6415 * @details sends the beacon/probe response from scan
6416 * @param[in,out] handle to the wifi driver,
6417 * @param[in] Sta Address,
6419 * Rssi of the Station found
6420 * @return Error code indicating success/failure
6423 * @date 8 March 2012
6427 static void GetPeriodicRSSI(unsigned long arg)
6429 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)arg;
6431 if (pstrWFIDrv == NULL) {
6432 PRINT_ER("Driver handler is NULL\n");
6436 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
6437 s32 s32Error = WILC_SUCCESS;
6438 tstrHostIFmsg strHostIFmsg;
6440 /* prepare the Get RSSI Message */
6441 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6443 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_RSSI;
6444 strHostIFmsg.drvHandler = pstrWFIDrv;
6446 /* send the message */
6447 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
6449 PRINT_ER("Failed to send get host channel param's message queue ");
6453 g_hPeriodicRSSI.data = (unsigned long)pstrWFIDrv;
6454 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
6458 void host_int_send_network_info_to_host
6459 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
6463 * @brief host_int_init
6464 * @details host interface initialization function
6465 * @param[in,out] handle to the wifi driver,
6468 * @date 8 March 2012
6471 static u32 u32Intialized;
6472 static u32 msgQ_created;
6473 static u32 clients_count;
6475 s32 host_int_init(tstrWILC_WFIDrv **phWFIDrv)
6477 s32 s32Error = WILC_SUCCESS;
6478 tstrWILC_WFIDrv *pstrWFIDrv;
6480 /*if(u32Intialized == 1)
6482 * PRINT_D(HOSTINF_DBG,"Host interface is previously initialized\n");
6483 * *phWFIDrv = (WILC_WFIDrvHandle)gWFiDrvHandle; //Will be adjusted later for P2P
6486 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
6488 gbScanWhileConnected = false;
6490 sema_init(&hWaitResponse, 0);
6494 /*Allocate host interface private structure*/
6495 pstrWFIDrv = WILC_MALLOC(sizeof(tstrWILC_WFIDrv));
6496 if (pstrWFIDrv == NULL) {
6497 /* WILC_ERRORREPORT(s32Error,WILC_NO_MEM); */
6498 s32Error = WILC_NO_MEM;
6499 PRINT_ER("Failed to allocate memory\n");
6502 memset(pstrWFIDrv, 0, sizeof(tstrWILC_WFIDrv));
6503 /*return driver handle to user*/
6504 *phWFIDrv = pstrWFIDrv;
6505 /*save into globl handle*/
6507 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
6509 g_obtainingIP = false;
6512 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", pstrWFIDrv);
6513 /* /////////////////////////////////////// */
6514 if (clients_count == 0) {
6515 sema_init(&hSemHostIFthrdEnd, 0);
6516 sema_init(&hSemDeinitDrvHandle, 0);
6518 sema_init(&hSemHostIntDeinit, 1);
6521 sema_init(&(pstrWFIDrv->hSemTestKeyBlock), 0);
6522 sema_init(&(pstrWFIDrv->hSemTestDisconnectBlock), 0);
6523 sema_init(&(pstrWFIDrv->hSemGetRSSI), 0);
6524 sema_init(&(pstrWFIDrv->hSemGetLINKSPEED), 0);
6525 sema_init(&(pstrWFIDrv->hSemGetCHNL), 0);
6526 sema_init(&(pstrWFIDrv->hSemInactiveTime), 0);
6528 /* /////////////////////////////////////// */
6532 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
6534 if (clients_count == 0) {
6535 s32Error = WILC_MsgQueueCreate(&gMsgQHostIF);
6538 PRINT_ER("Failed to creat MQ\n");
6542 HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread");
6543 if (IS_ERR(HostIFthreadHandler)) {
6544 PRINT_ER("Failed to creat Thread\n");
6545 s32Error = WILC_FAIL;
6548 setup_timer(&g_hPeriodicRSSI, GetPeriodicRSSI,
6549 (unsigned long)pstrWFIDrv);
6550 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
6554 setup_timer(&pstrWFIDrv->hScanTimer, TimerCB_Scan, 0);
6556 setup_timer(&pstrWFIDrv->hConnectTimer, TimerCB_Connect, 0);
6559 /*Remain on channel timer*/
6560 setup_timer(&pstrWFIDrv->hRemainOnChannel, ListenTimerCB, 0);
6563 sema_init(&(pstrWFIDrv->gtOsCfgValuesSem), 1);
6564 down(&(pstrWFIDrv->gtOsCfgValuesSem));
6566 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
6567 /* gWFiDrvHandle->bPendingConnRequest = false; */
6569 /*Initialize CFG WIDS Defualt Values*/
6571 pstrWFIDrv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
6572 pstrWFIDrv->strCfgValues.scan_source = DEFAULT_SCAN;
6573 pstrWFIDrv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
6574 pstrWFIDrv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
6575 pstrWFIDrv->strCfgValues.curr_tx_rate = AUTORATE;
6580 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
6584 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",
6586 pstrWFIDrv->strCfgValues.site_survey_enabled, pstrWFIDrv->strCfgValues.scan_source,
6587 pstrWFIDrv->strCfgValues.active_scan_time, pstrWFIDrv->strCfgValues.passive_scan_time,
6588 pstrWFIDrv->strCfgValues.curr_tx_rate);
6591 up(&(pstrWFIDrv->gtOsCfgValuesSem));
6593 /*TODO Code to setup simulation to be removed later*/
6594 /*Intialize configurator module*/
6595 s32Error = CoreConfiguratorInit();
6597 PRINT_ER("Failed to initialize core configurator\n");
6602 clients_count++; /* increase number of created entities */
6608 if (pstrWFIDrv != NULL)
6611 del_timer_sync(&pstrWFIDrv->hRemainOnChannel);
6614 up(&(pstrWFIDrv->gtOsCfgValuesSem));
6615 del_timer_sync(&pstrWFIDrv->hConnectTimer);
6616 del_timer_sync(&pstrWFIDrv->hScanTimer);
6617 kthread_stop(HostIFthreadHandler);
6619 WILC_MsgQueueDestroy(&gMsgQHostIF);
6626 * @brief host_int_deinit
6627 * @details host interface initialization function
6628 * @param[in,out] handle to the wifi driver,
6631 * @date 8 March 2012
6635 s32 host_int_deinit(tstrWILC_WFIDrv *hWFIDrv)
6637 s32 s32Error = WILC_SUCCESS;
6638 tstrHostIFmsg strHostIFmsg;
6641 /*obtain driver handle*/
6642 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6643 /*if(u32Intialized == 0)
6645 * PRINT_ER("Host Interface is not initialized\n");
6651 if (pstrWFIDrv == NULL) {
6652 PRINT_ER("pstrWFIDrv = NULL\n");
6656 down(&hSemHostIntDeinit);
6658 terminated_handle = pstrWFIDrv;
6659 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
6662 /*Destroy all timers before acquiring hSemDeinitDrvHandle*/
6663 /*to guarantee handling all messages befor proceeding*/
6664 if (del_timer_sync(&pstrWFIDrv->hScanTimer)) {
6665 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
6666 /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */
6669 if (del_timer_sync(&pstrWFIDrv->hConnectTimer)) {
6670 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
6671 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6675 if (del_timer_sync(&g_hPeriodicRSSI)) {
6676 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
6677 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6681 /*Destroy Remain-onchannel Timer*/
6682 del_timer_sync(&pstrWFIDrv->hRemainOnChannel);
6685 host_int_set_wfi_drv_handler(NULL);
6686 down(&hSemDeinitDrvHandle);
6689 /*Calling the CFG80211 scan done function with the abort flag set to true*/
6690 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
6691 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
6692 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
6694 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
6696 /*deinit configurator and simulator*/
6697 CoreConfiguratorDeInit();
6699 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
6701 gbScanWhileConnected = false;
6703 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6705 if (clients_count == 1) {
6706 if (del_timer_sync(&g_hPeriodicRSSI)) {
6707 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
6708 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6710 strHostIFmsg.u16MsgId = HOST_IF_MSG_EXIT;
6711 strHostIFmsg.drvHandler = hWFIDrv;
6714 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
6715 if (s32Error != WILC_SUCCESS)
6716 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
6718 down(&hSemHostIFthrdEnd);
6720 WILC_MsgQueueDestroy(&gMsgQHostIF);
6724 down(&(pstrWFIDrv->gtOsCfgValuesSem));
6726 /*Setting the gloabl driver handler with NULL*/
6728 /* gWFiDrvHandle = NULL; */
6729 if (pstrWFIDrv != NULL) {
6731 /* pstrWFIDrv=NULL; */
6735 clients_count--; /* Decrease number of created entities */
6736 terminated_handle = NULL;
6737 up(&hSemHostIntDeinit);
6743 * @brief NetworkInfoReceived
6744 * @details function to to be called when network info packet is received
6745 * @param[in] pu8Buffer the received packet
6746 * @param[in] u32Length length of the received packet
6753 void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
6755 s32 s32Error = WILC_SUCCESS;
6756 tstrHostIFmsg strHostIFmsg;
6758 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
6760 drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6761 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
6766 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
6767 PRINT_ER("NetworkInfo received but driver not init[%p]\n", pstrWFIDrv);
6771 /* prepare the Asynchronous Network Info message */
6772 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6774 strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_NTWRK_INFO;
6775 strHostIFmsg.drvHandler = pstrWFIDrv;
6777 strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.u32Length = u32Length;
6778 strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.pu8Buffer = WILC_MALLOC(u32Length); /* will be deallocated by the receiving thread */
6779 memcpy(strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.pu8Buffer,
6780 pu8Buffer, u32Length);
6782 /* send the message */
6783 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
6785 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
6789 * @brief GnrlAsyncInfoReceived
6790 * @details function to be called when general Asynchronous info packet is received
6791 * @param[in] pu8Buffer the received packet
6792 * @param[in] u32Length length of the received packet
6799 void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
6801 s32 s32Error = WILC_SUCCESS;
6802 tstrHostIFmsg strHostIFmsg;
6804 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
6807 down(&hSemHostIntDeinit);
6809 drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6810 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
6811 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
6814 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
6815 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
6817 up(&hSemHostIntDeinit);
6821 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL) {
6822 /* received mac status is not needed when there is no current Connect Request */
6823 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
6825 up(&hSemHostIntDeinit);
6829 /* prepare the General Asynchronous Info message */
6830 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6833 strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
6834 strHostIFmsg.drvHandler = pstrWFIDrv;
6837 strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.u32Length = u32Length;
6838 strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.pu8Buffer = WILC_MALLOC(u32Length); /* will be deallocated by the receiving thread */
6839 memcpy(strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.pu8Buffer,
6840 pu8Buffer, u32Length);
6842 /* send the message */
6843 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
6845 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
6848 up(&hSemHostIntDeinit);
6852 * @brief host_int_ScanCompleteReceived
6853 * @details Setting scan complete received notifcation in message queue
6854 * @param[in] u8* pu8Buffer, u32 u32Length
6855 * @return Error code.
6860 void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
6862 s32 s32Error = WILC_SUCCESS;
6863 tstrHostIFmsg strHostIFmsg;
6865 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
6867 drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6868 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
6871 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", pstrWFIDrv);
6873 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle)
6876 /*if there is an ongoing scan request*/
6877 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
6878 /* prepare theScan Done message */
6879 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6881 strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
6882 strHostIFmsg.drvHandler = pstrWFIDrv;
6885 /* will be deallocated by the receiving thread */
6886 /*no need to send message body*/
6888 /*strHostIFmsg.uniHostIFmsgBody.strScanComplete.u32Length = u32Length;
6889 * strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer = (u8*)WILC_MALLOC(u32Length);
6890 * memcpy(strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer,
6891 * pu8Buffer, u32Length); */
6893 /* send the message */
6894 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
6896 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
6906 * @brief host_int_remain_on_channel
6908 * @param[in] Handle to wifi driver
6909 * Duration to remain on channel
6910 * Channel to remain on
6911 * Pointer to fn to be called on receive frames in listen state
6912 * Pointer to remain-on-channel expired fn
6914 * @return Error code.
6919 s32 host_int_remain_on_channel(tstrWILC_WFIDrv *hWFIDrv, u32 u32SessionID, u32 u32duration, u16 chan, tWILCpfRemainOnChanExpired RemainOnChanExpired, tWILCpfRemainOnChanReady RemainOnChanReady, void *pvUserArg)
6921 s32 s32Error = WILC_SUCCESS;
6922 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6923 tstrHostIFmsg strHostIFmsg;
6925 if (pstrWFIDrv == NULL)
6926 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6928 /* prepare the remainonchan Message */
6929 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6931 /* prepare the WiphyParams Message */
6932 strHostIFmsg.u16MsgId = HOST_IF_MSG_REMAIN_ON_CHAN;
6933 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u16Channel = chan;
6934 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pRemainOnChanExpired = RemainOnChanExpired;
6935 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pRemainOnChanReady = RemainOnChanReady;
6936 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pVoid = pvUserArg;
6937 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32duration = u32duration;
6938 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
6939 strHostIFmsg.drvHandler = hWFIDrv;
6941 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
6943 WILC_ERRORREPORT(s32Error, s32Error);
6944 WILC_CATCH(s32Error)
6953 * @brief host_int_ListenStateExpired
6955 * @param[in] Handle to wifi driver
6956 * Duration to remain on channel
6957 * Channel to remain on
6958 * Pointer to fn to be called on receive frames in listen state
6959 * Pointer to remain-on-channel expired fn
6961 * @return Error code.
6966 s32 host_int_ListenStateExpired(tstrWILC_WFIDrv *hWFIDrv, u32 u32SessionID)
6968 s32 s32Error = WILC_SUCCESS;
6969 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6970 tstrHostIFmsg strHostIFmsg;
6972 if (pstrWFIDrv == NULL)
6973 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6975 /*Stopping remain-on-channel timer*/
6976 del_timer(&pstrWFIDrv->hRemainOnChannel);
6978 /* prepare the timer fire Message */
6979 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
6980 strHostIFmsg.u16MsgId = HOST_IF_MSG_LISTEN_TIMER_FIRED;
6981 strHostIFmsg.drvHandler = hWFIDrv;
6982 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
6984 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
6986 WILC_ERRORREPORT(s32Error, s32Error);
6987 WILC_CATCH(s32Error)
6995 * @brief host_int_frame_register
6997 * @param[in] Handle to wifi driver
6998 * @return Error code.
7002 s32 host_int_frame_register(tstrWILC_WFIDrv *hWFIDrv, u16 u16FrameType, bool bReg)
7004 s32 s32Error = WILC_SUCCESS;
7005 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7006 tstrHostIFmsg strHostIFmsg;
7008 if (pstrWFIDrv == NULL)
7009 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7011 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7013 /* prepare the WiphyParams Message */
7014 strHostIFmsg.u16MsgId = HOST_IF_MSG_REGISTER_FRAME;
7015 switch (u16FrameType) {
7017 PRINT_D(HOSTINF_DBG, "ACTION\n");
7018 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u8Regid = ACTION_FRM_IDX;
7022 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
7023 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u8Regid = PROBE_REQ_IDX;
7027 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
7030 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u16FrameType = u16FrameType;
7031 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.bReg = bReg;
7032 strHostIFmsg.drvHandler = hWFIDrv;
7034 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7036 WILC_ERRORREPORT(s32Error, s32Error);
7037 WILC_CATCH(s32Error)
7048 #ifdef WILC_AP_EXTERNAL_MLME
7050 * @brief host_int_add_beacon
7051 * @details Setting add beacon params in message queue
7052 * @param[in] WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
7053 * u32 u32DTIMPeriod,u32 u32HeadLen, u8* pu8Head,
7054 * u32 u32TailLen, u8* pu8Tail
7055 * @return Error code.
7060 s32 host_int_add_beacon(tstrWILC_WFIDrv *hWFIDrv, u32 u32Interval,
7062 u32 u32HeadLen, u8 *pu8Head,
7063 u32 u32TailLen, u8 *pu8Tail)
7065 s32 s32Error = WILC_SUCCESS;
7066 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7067 tstrHostIFmsg strHostIFmsg;
7068 tstrHostIFSetBeacon *pstrSetBeaconParam = &strHostIFmsg.uniHostIFmsgBody.strHostIFSetBeacon;
7070 if (pstrWFIDrv == NULL)
7071 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7073 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7075 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
7078 /* prepare the WiphyParams Message */
7079 strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_BEACON;
7080 strHostIFmsg.drvHandler = hWFIDrv;
7081 pstrSetBeaconParam->u32Interval = u32Interval;
7082 pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
7083 pstrSetBeaconParam->u32HeadLen = u32HeadLen;
7084 pstrSetBeaconParam->pu8Head = WILC_MALLOC(u32HeadLen);
7085 if (pstrSetBeaconParam->pu8Head == NULL)
7086 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
7087 memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
7088 pstrSetBeaconParam->u32TailLen = u32TailLen;
7090 /* Bug 4599 : if tail length = 0 skip allocating & copying */
7091 if (u32TailLen > 0) {
7092 pstrSetBeaconParam->pu8Tail = WILC_MALLOC(u32TailLen);
7093 if (pstrSetBeaconParam->pu8Tail == NULL)
7094 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
7095 memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen);
7097 pstrSetBeaconParam->pu8Tail = NULL;
7100 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7102 WILC_ERRORREPORT(s32Error, s32Error);
7104 WILC_CATCH(s32Error)
7106 if (pstrSetBeaconParam->pu8Head != NULL)
7107 kfree(pstrSetBeaconParam->pu8Head);
7109 if (pstrSetBeaconParam->pu8Tail != NULL)
7110 kfree(pstrSetBeaconParam->pu8Tail);
7119 * @brief host_int_del_beacon
7120 * @details Setting add beacon params in message queue
7121 * @param[in] WILC_WFIDrvHandle hWFIDrv
7122 * @return Error code.
7127 s32 host_int_del_beacon(tstrWILC_WFIDrv *hWFIDrv)
7129 s32 s32Error = WILC_SUCCESS;
7130 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7131 tstrHostIFmsg strHostIFmsg;
7133 if (pstrWFIDrv == NULL)
7134 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7136 /* prepare the WiphyParams Message */
7137 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_BEACON;
7138 strHostIFmsg.drvHandler = hWFIDrv;
7139 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
7141 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7142 WILC_ERRORCHECK(s32Error);
7144 WILC_CATCH(s32Error)
7152 * @brief host_int_add_station
7153 * @details Setting add station params in message queue
7154 * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7155 * @return Error code.
7160 s32 host_int_add_station(tstrWILC_WFIDrv *hWFIDrv, tstrWILC_AddStaParam *pstrStaParams)
7162 s32 s32Error = WILC_SUCCESS;
7163 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7164 tstrHostIFmsg strHostIFmsg;
7165 tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam;
7168 if (pstrWFIDrv == NULL)
7169 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7171 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7173 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
7176 /* prepare the WiphyParams Message */
7177 strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_STATION;
7178 strHostIFmsg.drvHandler = hWFIDrv;
7180 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam));
7181 if (pstrAddStationMsg->u8NumRates > 0) {
7182 u8 *rates = WILC_MALLOC(pstrAddStationMsg->u8NumRates);
7184 WILC_NULLCHECK(s32Error, rates);
7186 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
7187 pstrAddStationMsg->pu8Rates = rates;
7191 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7193 WILC_ERRORREPORT(s32Error, s32Error);
7195 WILC_CATCH(s32Error)
7202 * @brief host_int_del_station
7203 * @details Setting delete station params in message queue
7204 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr
7205 * @return Error code.
7210 s32 host_int_del_station(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8MacAddr)
7212 s32 s32Error = WILC_SUCCESS;
7213 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7214 tstrHostIFmsg strHostIFmsg;
7215 tstrHostIFDelSta *pstrDelStationMsg = &strHostIFmsg.uniHostIFmsgBody.strDelStaParam;
7217 if (pstrWFIDrv == NULL)
7218 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7220 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7222 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
7226 /* prepare the WiphyParams Message */
7227 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_STATION;
7228 strHostIFmsg.drvHandler = hWFIDrv;
7230 /*BugID_4795: Handling situation of deleting all stations*/
7231 if (pu8MacAddr == NULL)
7232 memset(pstrDelStationMsg->au8MacAddr, 255, ETH_ALEN);
7234 memcpy(pstrDelStationMsg->au8MacAddr, pu8MacAddr, ETH_ALEN);
7236 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7238 WILC_ERRORREPORT(s32Error, s32Error);
7240 WILC_CATCH(s32Error)
7246 * @brief host_int_del_allstation
7247 * @details Setting del station params in message queue
7248 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]s
7249 * @return Error code.
7254 s32 host_int_del_allstation(tstrWILC_WFIDrv *hWFIDrv, u8 pu8MacAddr[][ETH_ALEN])
7256 s32 s32Error = WILC_SUCCESS;
7257 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7258 tstrHostIFmsg strHostIFmsg;
7259 tstrHostIFDelAllSta *pstrDelAllStationMsg = &strHostIFmsg.uniHostIFmsgBody.strHostIFDelAllSta;
7260 u8 au8Zero_Buff[ETH_ALEN] = {0};
7265 if (pstrWFIDrv == NULL)
7266 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7268 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7270 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
7272 /* prepare the WiphyParams Message */
7273 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_ALL_STA;
7274 strHostIFmsg.drvHandler = hWFIDrv;
7276 /* Handling situation of deauthenticing all associated stations*/
7277 for (i = 0; i < MAX_NUM_STA; i++) {
7278 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
7279 memcpy(pstrDelAllStationMsg->au8Sta_DelAllSta[i], pu8MacAddr[i], ETH_ALEN);
7280 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],
7281 pstrDelAllStationMsg->au8Sta_DelAllSta[i][5]);
7286 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
7290 pstrDelAllStationMsg->u8Num_AssocSta = u8AssocNumb;
7291 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7295 WILC_ERRORREPORT(s32Error, s32Error);
7297 WILC_CATCH(s32Error)
7301 down(&hWaitResponse);
7308 * @brief host_int_edit_station
7309 * @details Setting edit station params in message queue
7310 * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7311 * @return Error code.
7316 s32 host_int_edit_station(tstrWILC_WFIDrv *hWFIDrv, tstrWILC_AddStaParam *pstrStaParams)
7318 s32 s32Error = WILC_SUCCESS;
7319 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7320 tstrHostIFmsg strHostIFmsg;
7321 tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam;
7323 if (pstrWFIDrv == NULL)
7324 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7326 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
7328 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7331 /* prepare the WiphyParams Message */
7332 strHostIFmsg.u16MsgId = HOST_IF_MSG_EDIT_STATION;
7333 strHostIFmsg.drvHandler = hWFIDrv;
7335 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam));
7336 if (pstrAddStationMsg->u8NumRates > 0) {
7337 u8 *rates = WILC_MALLOC(pstrAddStationMsg->u8NumRates);
7339 WILC_NULLCHECK(s32Error, rates);
7340 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
7341 pstrAddStationMsg->pu8Rates = rates;
7344 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7346 WILC_ERRORREPORT(s32Error, s32Error);
7347 WILC_CATCH(s32Error)
7352 #endif /*WILC_AP_EXTERNAL_MLME*/
7353 uint32_t wilc_get_chipid(uint8_t);
7355 s32 host_int_set_power_mgmt(tstrWILC_WFIDrv *hWFIDrv, bool bIsEnabled, u32 u32Timeout)
7357 s32 s32Error = WILC_SUCCESS;
7358 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7359 tstrHostIFmsg strHostIFmsg;
7360 tstrHostIfPowerMgmtParam *pstrPowerMgmtParam = &strHostIFmsg.uniHostIFmsgBody.strPowerMgmtparam;
7362 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
7364 if (pstrWFIDrv == NULL)
7365 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7367 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
7369 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7372 /* prepare the WiphyParams Message */
7373 strHostIFmsg.u16MsgId = HOST_IF_MSG_POWER_MGMT;
7374 strHostIFmsg.drvHandler = hWFIDrv;
7376 pstrPowerMgmtParam->bIsEnabled = bIsEnabled;
7377 pstrPowerMgmtParam->u32Timeout = u32Timeout;
7380 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7382 WILC_ERRORREPORT(s32Error, s32Error);
7383 WILC_CATCH(s32Error)
7389 s32 host_int_setup_multicast_filter(tstrWILC_WFIDrv *hWFIDrv, bool bIsEnabled, u32 u32count)
7391 s32 s32Error = WILC_SUCCESS;
7393 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7394 tstrHostIFmsg strHostIFmsg;
7395 tstrHostIFSetMulti *pstrMulticastFilterParam = &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMulti;
7398 if (pstrWFIDrv == NULL)
7399 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7401 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
7403 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7406 /* prepare the WiphyParams Message */
7407 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_MULTICAST_FILTER;
7408 strHostIFmsg.drvHandler = hWFIDrv;
7410 pstrMulticastFilterParam->bIsEnabled = bIsEnabled;
7411 pstrMulticastFilterParam->u32count = u32count;
7413 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7415 WILC_ERRORREPORT(s32Error, s32Error);
7416 WILC_CATCH(s32Error)
7424 /*Bug4218: Parsing Join Param*/
7425 #ifdef WILC_PARSE_SCAN_IN_HOST
7427 /*Bug4218: Parsing Join Param*/
7429 * @brief host_int_ParseJoinBssParam
7430 * @details Parse Needed Join Parameters and save it in a new JoinBssParam entry
7431 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7436 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
7438 tstrJoinBssParam *pNewJoinBssParam = NULL;
7447 u8 pcipherTotalCount = 0;
7448 u8 authTotalCount = 0;
7451 pu8IEs = ptstrNetworkInfo->pu8IEs;
7452 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
7454 pNewJoinBssParam = WILC_MALLOC(sizeof(tstrJoinBssParam));
7455 if (pNewJoinBssParam != NULL) {
7456 memset(pNewJoinBssParam, 0, sizeof(tstrJoinBssParam));
7457 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
7458 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
7459 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
7460 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
7462 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/
7463 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
7464 pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen;
7465 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
7466 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
7467 /*for(i=0; i<pNewJoinBssParam->ssidLen;i++)
7468 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/
7470 /* parse supported rates: */
7471 while (index < u16IEsLen) {
7472 /* supportedRates IE */
7473 if (pu8IEs[index] == SUPP_RATES_IE) {
7474 /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */
7475 suppRatesNo = pu8IEs[index + 1];
7476 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
7477 index += 2; /* skipping ID and length bytes; */
7479 for (i = 0; i < suppRatesNo; i++) {
7480 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
7481 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */
7483 index += suppRatesNo;
7486 /* Ext SupportedRates IE */
7487 else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
7488 /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */
7489 /* checking if no of ext. supp and supp rates < max limit */
7490 extSuppRatesNo = pu8IEs[index + 1];
7491 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
7492 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
7494 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
7496 /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */
7497 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
7498 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
7499 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */
7501 index += extSuppRatesNo;
7505 else if (pu8IEs[index] == HT_CAPABILITY_IE) {
7506 /* if IE found set the flag */
7507 pNewJoinBssParam->ht_capable = true;
7508 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7509 /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */
7511 } else if ((pu8IEs[index] == WMM_IE) && /* WMM Element ID */
7512 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
7513 (pu8IEs[index + 4] == 0xF2) && /* OUI */
7514 (pu8IEs[index + 5] == 0x02) && /* OUI Type */
7515 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) && /* OUI Sub Type */
7516 (pu8IEs[index + 7] == 0x01)) {
7517 /* Presence of WMM Info/Param element indicates WMM capability */
7518 pNewJoinBssParam->wmm_cap = true;
7520 /* Check if Bit 7 is set indicating U-APSD capability */
7521 if (pu8IEs[index + 8] & (1 << 7))
7522 pNewJoinBssParam->uapsd_cap = true;
7523 index += pu8IEs[index + 1] + 2;
7527 else if ((pu8IEs[index] == P2P_IE) && /* P2P Element ID */
7528 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
7529 (pu8IEs[index + 4] == 0x9a) && /* OUI */
7530 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) { /* OUI Type */
7533 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
7534 pNewJoinBssParam->u8NoaEnbaled = 1;
7535 pNewJoinBssParam->u8Index = pu8IEs[index + 9];
7537 /* Check if Bit 7 is set indicating Opss capability */
7538 if (pu8IEs[index + 10] & (1 << 7)) {
7539 pNewJoinBssParam->u8OppEnable = 1;
7540 pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10];
7542 pNewJoinBssParam->u8OppEnable = 0;
7544 PRINT_D(GENERIC_DBG, "P2P Dump\n");
7545 for (i = 0; i < pu8IEs[index + 7]; i++)
7546 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
7548 pNewJoinBssParam->u8Count = pu8IEs[index + 11];
7549 u16P2P_count = index + 12;
7551 memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4);
7554 memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4);
7557 memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
7559 index += pu8IEs[index + 1] + 2;
7564 else if ((pu8IEs[index] == RSN_IE) ||
7565 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
7566 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
7567 (pu8IEs[index + 5] == 0x01))) {
7568 u16 rsnIndex = index;
7569 /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]);
7570 * for(i=0; i<pu8IEs[rsnIndex+1]; i++)
7572 * PRINT_D(HOSTINF_DBG,"%0x ",pu8IEs[rsnIndex+2+i]);
7574 if (pu8IEs[rsnIndex] == RSN_IE) {
7575 pNewJoinBssParam->mode_802_11i = 2;
7576 /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */
7577 } else { /* check if rsn was previously parsed */
7578 if (pNewJoinBssParam->mode_802_11i == 0)
7579 pNewJoinBssParam->mode_802_11i = 1;
7580 /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */
7583 rsnIndex += 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */
7584 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
7586 /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x\n",pNewJoinBssParam->rsn_grp_policy); */
7587 /* initialize policies with invalid values */
7589 jumpOffset = pu8IEs[rsnIndex] * 4; /* total no.of bytes of pcipher field (count*4) */
7591 /*parsing pairwise cipher*/
7593 /* saving 3 pcipher max. */
7594 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7595 rsnIndex += 2; /* jump 2 bytes of pcipher count */
7597 /* PRINT_D(HOSTINF_DBG,"\npcipher:%d\n",pcipherCount); */
7598 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
7599 /* each count corresponds to 4 bytes, only last byte is saved */
7600 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7601 /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */
7603 pcipherTotalCount += pcipherCount;
7604 rsnIndex += jumpOffset;
7606 jumpOffset = pu8IEs[rsnIndex] * 4;
7608 /*parsing AKM suite (auth_policy)*/
7609 /* saving 3 auth policies max. */
7610 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7611 rsnIndex += 2; /* jump 2 bytes of pcipher count */
7613 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
7614 /* each count corresponds to 4 bytes, only last byte is saved */
7615 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7617 authTotalCount += authCount;
7618 rsnIndex += jumpOffset;
7619 /*pasring rsn cap. only if rsn IE*/
7620 if (pu8IEs[index] == RSN_IE) {
7621 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
7622 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
7625 pNewJoinBssParam->rsn_found = true;
7626 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7629 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7636 return (void *)pNewJoinBssParam;
7640 void host_int_freeJoinParams(void *pJoinParams)
7642 if ((tstrJoinBssParam *)pJoinParams != NULL)
7643 kfree((tstrJoinBssParam *)pJoinParams);
7645 PRINT_ER("Unable to FREE null pointer\n");
7647 #endif /*WILC_PARSE_SCAN_IN_HOST*/
7651 * @brief host_int_addBASession
7652 * @details Open a block Ack session with the given parameters
7653 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7655 * @author anoureldin
7659 static int host_int_addBASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID, short int BufferSize,
7660 short int SessionTimeout, void *drvHandler)
7662 s32 s32Error = WILC_SUCCESS;
7663 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7664 tstrHostIFmsg strHostIFmsg;
7665 tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
7667 if (pstrWFIDrv == NULL)
7668 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7670 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7672 /* prepare the WiphyParams Message */
7673 strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_BA_SESSION;
7675 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7676 pBASessionInfo->u8Ted = TID;
7677 pBASessionInfo->u16BufferSize = BufferSize;
7678 pBASessionInfo->u16SessionTimeout = SessionTimeout;
7679 strHostIFmsg.drvHandler = hWFIDrv;
7681 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7683 WILC_ERRORREPORT(s32Error, s32Error);
7684 WILC_CATCH(s32Error)
7693 s32 host_int_delBASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID)
7695 s32 s32Error = WILC_SUCCESS;
7696 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7697 tstrHostIFmsg strHostIFmsg;
7698 tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
7700 if (pstrWFIDrv == NULL)
7701 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7703 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7705 /* prepare the WiphyParams Message */
7706 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_BA_SESSION;
7708 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7709 pBASessionInfo->u8Ted = TID;
7710 strHostIFmsg.drvHandler = hWFIDrv;
7712 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7714 WILC_ERRORREPORT(s32Error, s32Error);
7715 WILC_CATCH(s32Error)
7721 down(&hWaitResponse);
7726 s32 host_int_del_All_Rx_BASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID)
7728 s32 s32Error = WILC_SUCCESS;
7729 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7730 tstrHostIFmsg strHostIFmsg;
7731 tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
7733 if (pstrWFIDrv == NULL)
7734 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7736 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7738 /* prepare the WiphyParams Message */
7739 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
7741 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7742 pBASessionInfo->u8Ted = TID;
7743 strHostIFmsg.drvHandler = hWFIDrv;
7745 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7747 WILC_ERRORREPORT(s32Error, s32Error);
7748 WILC_CATCH(s32Error)
7754 down(&hWaitResponse);
7760 * @brief host_int_setup_ipaddress
7761 * @details setup IP in firmware
7762 * @param[in] Handle to wifi driver
7763 * @return Error code.
7764 * @author Abdelrahman Sobhy
7767 s32 host_int_setup_ipaddress(tstrWILC_WFIDrv *hWFIDrv, u8 *u16ipadd, u8 idx)
7769 s32 s32Error = WILC_SUCCESS;
7770 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7771 tstrHostIFmsg strHostIFmsg;
7773 /* TODO: Enable This feature on softap firmware */
7776 if (pstrWFIDrv == NULL)
7777 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7779 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7781 /* prepare the WiphyParams Message */
7782 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_IPADDRESS;
7784 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr = u16ipadd;
7785 strHostIFmsg.drvHandler = hWFIDrv;
7786 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx = idx;
7788 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7790 WILC_ERRORREPORT(s32Error, s32Error);
7791 WILC_CATCH(s32Error)
7802 * @brief host_int_get_ipaddress
7803 * @details Get IP from firmware
7804 * @param[in] Handle to wifi driver
7805 * @return Error code.
7806 * @author Abdelrahman Sobhy
7809 s32 host_int_get_ipaddress(tstrWILC_WFIDrv *hWFIDrv, u8 *u16ipadd, u8 idx)
7811 s32 s32Error = WILC_SUCCESS;
7812 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7813 tstrHostIFmsg strHostIFmsg;
7815 if (pstrWFIDrv == NULL)
7816 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
7818 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
7820 /* prepare the WiphyParams Message */
7821 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_IPADDRESS;
7823 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr = u16ipadd;
7824 strHostIFmsg.drvHandler = hWFIDrv;
7825 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx = idx;
7827 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
7829 WILC_ERRORREPORT(s32Error, s32Error);
7830 WILC_CATCH(s32Error)