1 #include "host_interface.h"
2 #include "coreconfigurator.h"
4 extern s32
TransportInit(void);
5 extern s32
TransportDeInit(void);
8 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
9 extern WILC_TimerHandle hDuringIpTimer
;
12 extern bool bEnablePS
;
14 extern u8 g_wilc_initialized
;
15 /*****************************************************************************/
17 /*****************************************************************************/
19 /* Message types of the Host IF Message Queue*/
20 #define HOST_IF_MSG_SCAN 0
21 #define HOST_IF_MSG_CONNECT 1
22 #define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
23 #define HOST_IF_MSG_KEY 3
24 #define HOST_IF_MSG_RCVD_NTWRK_INFO 4
25 #define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
26 #define HOST_IF_MSG_CFG_PARAMS 6
27 #define HOST_IF_MSG_SET_CHANNEL 7
28 #define HOST_IF_MSG_DISCONNECT 8
29 #define HOST_IF_MSG_GET_RSSI 9
30 #define HOST_IF_MSG_GET_CHNL 10
31 #define HOST_IF_MSG_ADD_BEACON 11
32 #define HOST_IF_MSG_DEL_BEACON 12
33 #define HOST_IF_MSG_ADD_STATION 13
34 #define HOST_IF_MSG_DEL_STATION 14
35 #define HOST_IF_MSG_EDIT_STATION 15
36 #define HOST_IF_MSG_SCAN_TIMER_FIRED 16
37 #define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
38 #define HOST_IF_MSG_POWER_MGMT 18
39 #define HOST_IF_MSG_GET_INACTIVETIME 19
40 #define HOST_IF_MSG_REMAIN_ON_CHAN 20
41 #define HOST_IF_MSG_REGISTER_FRAME 21
42 #define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
43 #define HOST_IF_MSG_GET_LINKSPEED 23
44 #define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
45 #define HOST_IF_MSG_SET_MAC_ADDRESS 25
46 #define HOST_IF_MSG_GET_MAC_ADDRESS 26
47 #define HOST_IF_MSG_SET_OPERATION_MODE 27
48 #define HOST_IF_MSG_SET_IPADDRESS 28
49 #define HOST_IF_MSG_GET_IPADDRESS 29
50 #define HOST_IF_MSG_FLUSH_CONNECT 30
51 #define HOST_IF_MSG_GET_STATISTICS 31
52 #define HOST_IF_MSG_SET_MULTICAST_FILTER 32
53 #define HOST_IF_MSG_ADD_BA_SESSION 33
54 #define HOST_IF_MSG_DEL_BA_SESSION 34
55 #define HOST_IF_MSG_Q_IDLE 35
56 #define HOST_IF_MSG_DEL_ALL_STA 36
57 #define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
58 #define HOST_IF_MSG_EXIT 100
60 #define HOST_IF_SCAN_TIMEOUT 4000
61 #define HOST_IF_CONNECT_TIMEOUT 9500
63 #define BA_SESSION_DEFAULT_BUFFER_SIZE 16
64 #define BA_SESSION_DEFAULT_TIMEOUT 1000
65 #define BLOCK_ACK_REQ_SIZE 0x14
66 /*****************************************************************************/
67 /* Type Definitions */
68 /*****************************************************************************/
71 * @struct tstrHostIFCfgParamAttr
72 * @brief Structure to hold Host IF CFG Params Attributes
76 * @author Mai Daftedar
80 typedef struct _tstrHostIFCfgParamAttr
{
81 tstrCfgParamVal pstrCfgParamVal
;
83 } tstrHostIFCfgParamAttr
;
86 * @struct tstrHostIFwpaAttr
87 * @brief Structure to hold Host IF Scan Attributes
91 * @author Mai Daftedar
95 typedef struct _tstrHostIFwpaAttr
{
107 * @struct tstrHostIFwepAttr
108 * @brief Structure to hold Host IF Scan Attributes
112 * @author Mai Daftedar
113 * @date 25 March 2012
116 typedef struct _tstrHostIFwepAttr
{
121 AUTHTYPE_T tenuAuth_type
;
126 * @struct tuniHostIFkeyAttr
127 * @brief Structure to hold Host IF Scan Attributes
131 * @author Mai Daftedar
132 * @date 25 March 2012
135 typedef union _tuniHostIFkeyAttr
{
136 tstrHostIFwepAttr strHostIFwepAttr
;
137 tstrHostIFwpaAttr strHostIFwpaAttr
;
138 tstrHostIFpmkidAttr strHostIFpmkidAttr
;
142 * @struct tstrHostIFkeyAttr
143 * @brief Structure to hold Host IF Scan Attributes
147 * @author Mai Daftedar
148 * @date 25 March 2012
151 typedef struct _tstrHostIFkeyAttr
{
152 tenuKeyType enuKeyType
;
154 tuniHostIFkeyAttr uniHostIFkeyAttr
;
161 * @struct tstrHostIFscanAttr
162 * @brief Structure to hold Host IF Scan Attributes
166 * @author Mostafa Abu Bakr
167 * @date 25 March 2012
170 typedef struct _tstrHostIFscanAttr
{
177 tWILCpfScanResult pfScanResult
;
180 tstrHiddenNetwork strHiddenNetwork
;
182 } tstrHostIFscanAttr
;
185 * @struct tstrHostIFconnectAttr
186 * @brief Structure to hold Host IF Connect Attributes
190 * @author Mostafa Abu Bakr
191 * @date 25 March 2012
194 typedef struct _tstrHostIFconnectAttr
{
201 tWILCpfConnectResult pfConnectResult
;
203 AUTHTYPE_T tenuAuth_type
;
206 } tstrHostIFconnectAttr
;
209 * @struct tstrRcvdGnrlAsyncInfo
210 * @brief Structure to hold Received General Asynchronous info
214 * @author Mostafa Abu Bakr
215 * @date 25 March 2012
218 typedef struct _tstrRcvdGnrlAsyncInfo
{
221 } tstrRcvdGnrlAsyncInfo
;
224 * @struct tstrHostIFSetChan
225 * @brief Set Channel message body
229 * @author Mai Daftedar
230 * @date 25 March 2012
233 typedef struct _tstrHostIFSetChan
{
238 * @struct tstrHostIFSetChan
239 * @brief Get Channel message body
243 * @author Mai Daftedar
247 typedef struct _tstrHostIFGetChan
{
251 /*bug3819: Add Scan acomplete notification to host*/
253 * @struct tstrScanComplete
254 * @brief hold received Async. Scan Complete message body
259 * @date 25 March 2012
262 /*typedef struct _tstrScanComplete
266 * } tstrScanComplete;*/
269 * @struct tstrHostIFSetBeacon
270 * @brief Set Beacon message body
274 * @author Adham Abozaeid
278 typedef struct _tstrHostIFSetBeacon
{
279 u32 u32Interval
; /*!< Beacon Interval. Period between two successive beacons on air */
280 u32 u32DTIMPeriod
; /*!< DTIM Period. Indicates how many Beacon frames
281 * (including the current frame) appear before the next DTIM */
282 u32 u32HeadLen
; /*!< Length of the head buffer in bytes */
283 u8
*pu8Head
; /*!< Pointer to the beacon's head buffer. Beacon's head is the part
284 * from the beacon's start till the TIM element, NOT including the TIM */
285 u32 u32TailLen
; /*!< Length of the tail buffer in bytes */
286 u8
*pu8Tail
; /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just
287 * after the TIM inormation element */
288 } tstrHostIFSetBeacon
;
293 * @struct tstrHostIFDelBeacon
294 * @brief Del Beacon message body
298 * @author Adham Abozaeid
302 typedef struct _tstrHostIFDelBeacon
{
304 } tstrHostIFDelBeacon
;
307 * @struct tstrHostIFSetMulti
308 * @brief set Multicast filter Address
312 * @author Abdelrahman Sobhy
313 * @date 30 August 2013
314 * @version 1.0 Description
320 } tstrHostIFSetMulti
;
323 * @struct tstrHostIFDelAllSta
324 * @brief Deauth station message body
328 * @author Mai Daftedar
329 * @date 09 April 2014
330 * @version 1.0 Description
334 u8 au8Sta_DelAllSta
[MAX_NUM_STA
][ETH_ALEN
];
336 } tstrHostIFDelAllSta
;
339 * @struct tstrHostIFDelSta
340 * @brief Delete station message body
344 * @author Adham Abozaeid
346 * @version 1.0 Description
350 u8 au8MacAddr
[ETH_ALEN
];
354 * @struct tstrTimerCb
355 * @brief Timer callback message body
359 * @author Mostafa Abu Bakr
360 * @date 25 March 2012
363 typedef struct _tstrTimerCb
{
364 void *pvUsrArg
; /*!< Private data passed at timer start */
368 * @struct tstrHostIfPowerMgmtParam
369 * @brief Power management message body
373 * @author Adham Abozaeid
374 * @date 24 November 2012
381 } tstrHostIfPowerMgmtParam
;
384 * @struct tstrHostIFSetIPAddr
385 * @brief set IP Address message body
389 * @author Abdelrahman Sobhy
390 * @date 30 August 2013
391 * @version 1.0 Description
397 } tstrHostIFSetIPAddr
;
400 * @struct tstrHostIfStaInactiveT
401 * @brief Get station message body
405 * @author Mai Daftedar
406 * @date 16 April 2013
412 } tstrHostIfStaInactiveT
;
415 * @union tuniHostIFmsgBody
416 * @brief Message body for the Host Interface message_q
420 * @author Mostafa Abu Bakr
421 * @date 25 March 2012
424 typedef union _tuniHostIFmsgBody
{
425 tstrHostIFscanAttr strHostIFscanAttr
; /*!< Host IF Scan Request Attributes message body */
426 tstrHostIFconnectAttr strHostIFconnectAttr
; /*!< Host IF Connect Request Attributes message body */
427 tstrRcvdNetworkInfo strRcvdNetworkInfo
; /*!< Received Asynchronous Network Info message body */
428 tstrRcvdGnrlAsyncInfo strRcvdGnrlAsyncInfo
; /*!< Received General Asynchronous Info message body */
429 tstrHostIFkeyAttr strHostIFkeyAttr
; /*!<>*/
430 tstrHostIFCfgParamAttr strHostIFCfgParamAttr
; /*! <CFG Parameter message Body> */
431 tstrHostIFSetChan strHostIFSetChan
;
432 tstrHostIFGetChan strHostIFGetChan
;
433 tstrHostIFSetBeacon strHostIFSetBeacon
; /*!< Set beacon message body */
434 tstrHostIFDelBeacon strHostIFDelBeacon
; /*!< Del beacon message body */
435 tstrWILC_AddStaParam strAddStaParam
; /*!< Add station message body */
436 tstrHostIFDelSta strDelStaParam
; /*!< Del Station message body */
437 tstrWILC_AddStaParam strEditStaParam
; /*!< Edit station message body */
438 /* tstrScanComplete strScanComplete; / *Received Async. Scan Complete message body* / */
439 tstrTimerCb strTimerCb
; /*!< Timer callback message body */
440 tstrHostIfPowerMgmtParam strPowerMgmtparam
; /*!< Power Management message body */
441 tstrHostIfStaInactiveT strHostIfStaInactiveT
;
442 tstrHostIFSetIPAddr strHostIfSetIP
;
443 tstrHostIfSetDrvHandler strHostIfSetDrvHandler
;
444 tstrHostIFSetMulti strHostIfSetMulti
;
445 tstrHostIfSetOperationMode strHostIfSetOperationMode
;
446 tstrHostIfSetMacAddress strHostIfSetMacAddress
;
447 tstrHostIfGetMacAddress strHostIfGetMacAddress
;
448 tstrHostIfBASessionInfo strHostIfBASessionInfo
;
450 tstrHostIfRemainOnChan strHostIfRemainOnChan
;
451 tstrHostIfRegisterFrame strHostIfRegisterFrame
;
454 tstrHostIFDelAllSta strHostIFDelAllSta
;
458 * @struct tstrHostIFmsg
459 * @brief Host Interface message
463 * @author Mostafa Abu Bakr
464 * @date 25 March 2012
467 typedef struct _tstrHostIFmsg
{
468 u16 u16MsgId
; /*!< Message ID */
469 tuniHostIFmsgBody uniHostIFmsgBody
; /*!< Message body */
473 #ifdef CONNECT_DIRECT
474 typedef struct _tstrWidJoinReqExt
{
475 char SSID
[MAX_SSID_LEN
];
481 /*Bug4218: Parsing Join Param*/
482 #ifdef WILC_PARSE_SCAN_IN_HOST
483 /*Struct containg joinParam of each AP*/
484 typedef struct _tstrJoinBssParam
{
490 char ssid
[MAX_SSID_LEN
];
492 u8 supp_rates
[MAX_RATES_SUPPORTED
+ 1];
499 u8 rsn_pcip_policy
[3];
500 u8 rsn_auth_policy
[3];
502 struct _tstrJoinParam
*nextJoinBss
;
515 /*Bug4218: Parsing Join Param*/
516 /*a linked list table containing needed join parameters entries for each AP found in most recent scan*/
517 typedef struct _tstrBssTable
{
519 tstrJoinBssParam
*head
;
520 tstrJoinBssParam
*tail
;
522 #endif /*WILC_PARSE_SCAN_IN_HOST*/
527 SCAN_CONNECT_TIMER_FORCE_32BIT
= 0xFFFFFFFF
530 /*****************************************************************************/
532 /* Global Variabls */
534 /*****************************************************************************/
537 tstrWILC_WFIDrv
*terminated_handle
;
538 tstrWILC_WFIDrv
*gWFiDrvHandle
;
539 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
540 bool g_obtainingIP
= false;
543 static struct task_struct
*HostIFthreadHandler
;
544 static WILC_MsgQueueHandle gMsgQHostIF
;
545 static struct semaphore hSemHostIFthrdEnd
;
547 struct semaphore hSemDeinitDrvHandle
;
548 static struct semaphore hWaitResponse
;
549 struct semaphore hSemHostIntDeinit
;
550 WILC_TimerHandle g_hPeriodicRSSI
;
554 u8 gau8MulticastMacAddrList
[WILC_MULTICAST_TABLE_SIZE
][ETH_ALEN
];
556 #ifndef CONNECT_DIRECT
557 static u8 gapu8RcvdSurveyResults
[2][MAX_SURVEY_RESULT_FRAG_SIZE
];
560 static u8 gapu8RcvdAssocResp
[MAX_ASSOC_RESP_FRAME_SIZE
];
562 bool gbScanWhileConnected
= false;
567 static u8 gs8SetIP
[2][4];
568 static u8 gs8GetIP
[2][4];
569 #ifdef WILC_AP_EXTERNAL_MLME
570 static u32 gu32InactiveTime
;
573 static u32 gu32WidConnRstHack
;
576 u8
*gu8FlushedJoinReq
;
577 u8
*gu8FlushedInfoElemAsoc
;
578 u8 gu8Flushed11iMode
;
579 u8 gu8FlushedAuthType
;
580 u32 gu32FlushedJoinReqSize
;
581 u32 gu32FlushedInfoElemAsocSize
;
582 u32 gu8FlushedJoinReqDrvHandler
;
583 #define REAL_JOIN_REQ 0
584 #define FLUSHED_JOIN_REQ 1
585 #define FLUSHED_BYTE_POS 79 /* Position the byte indicating flushing in the flushed request */
587 /*Bug4218: Parsing Join Param*/
588 #ifdef WILC_PARSE_SCAN_IN_HOST
589 /*Bug4218: Parsing Join Param*/
590 static void *host_int_ParseJoinBssParam(tstrNetworkInfo
*ptstrNetworkInfo
);
591 #endif /*WILC_PARSE_SCAN_IN_HOST*/
593 extern void chip_sleep_manually(u32 u32SleepTime
);
594 extern int linux_wlan_get_num_conn_ifcs(void);
597 * @brief Handle_SetChannel
598 * @details Sending config packet to firmware to set channel
599 * @param[in] tstrHostIFSetChan* pstrHostIFSetChan
600 * @return Error code.
605 static s32
Handle_SetChannel(void *drvHandler
, tstrHostIFSetChan
*pstrHostIFSetChan
)
608 s32 s32Error
= WILC_SUCCESS
;
610 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
612 /*prepare configuration packet*/
613 strWID
.u16WIDid
= (u16
)WID_CURRENT_CHANNEL
;
614 strWID
.enuWIDtype
= WID_CHAR
;
615 strWID
.ps8WidVal
= (char *)&(pstrHostIFSetChan
->u8SetChan
);
616 strWID
.s32ValueSize
= sizeof(char);
618 PRINT_D(HOSTINF_DBG
, "Setting channel\n");
620 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
622 PRINT_ER("Failed to set channel\n");
623 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
633 * @brief Handle_SetWfiDrvHandler
634 * @details Sending config packet to firmware to set driver handler
635 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
636 * @return Error code.
641 static s32
Handle_SetWfiDrvHandler(tstrHostIfSetDrvHandler
*pstrHostIfSetDrvHandler
)
644 s32 s32Error
= WILC_SUCCESS
;
646 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)((pstrHostIfSetDrvHandler
->u32Address
));
649 /*prepare configuration packet*/
650 strWID
.u16WIDid
= (u16
)WID_SET_DRV_HANDLER
;
651 strWID
.enuWIDtype
= WID_INT
;
652 strWID
.ps8WidVal
= (s8
*)&(pstrHostIfSetDrvHandler
->u32Address
);
653 strWID
.s32ValueSize
= sizeof(u32
);
657 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
660 if ((pstrHostIfSetDrvHandler
->u32Address
) == (u32
)NULL
)
661 up(&hSemDeinitDrvHandle
);
665 PRINT_ER("Failed to set driver handler\n");
666 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
677 * @brief Handle_SetWfiAPDrvHandler
678 * @details Sending config packet to firmware to set driver handler
679 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
680 * @return Error code.
685 static s32
Handle_SetOperationMode(void *drvHandler
, tstrHostIfSetOperationMode
*pstrHostIfSetOperationMode
)
688 s32 s32Error
= WILC_SUCCESS
;
690 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
693 /*prepare configuration packet*/
694 strWID
.u16WIDid
= (u16
)WID_SET_OPERATION_MODE
;
695 strWID
.enuWIDtype
= WID_INT
;
696 strWID
.ps8WidVal
= (s8
*)&(pstrHostIfSetOperationMode
->u32Mode
);
697 strWID
.s32ValueSize
= sizeof(u32
);
700 PRINT_INFO(HOSTINF_DBG
, "pstrWFIDrv= %p\n", pstrWFIDrv
);
702 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
705 if ((pstrHostIfSetOperationMode
->u32Mode
) == (u32
)NULL
)
706 up(&hSemDeinitDrvHandle
);
710 PRINT_ER("Failed to set driver handler\n");
711 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
722 * @brief host_int_set_IPAddress
723 * @details Setting IP address params in message queue
724 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
725 * @return Error code.
730 s32
Handle_set_IPAddress(void *drvHandler
, u8
*pu8IPAddr
, u8 idx
)
733 s32 s32Error
= WILC_SUCCESS
;
735 char firmwareIPAddress
[4] = {0};
736 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
738 if (pu8IPAddr
[0] < 192)
741 PRINT_INFO(HOSTINF_DBG
, "Indx = %d, Handling set IP = %pI4\n", idx
, pu8IPAddr
);
743 WILC_memcpy(gs8SetIP
[idx
], pu8IPAddr
, IP_ALEN
);
745 /*prepare configuration packet*/
746 strWID
.u16WIDid
= (u16
)WID_IP_ADDRESS
;
747 strWID
.enuWIDtype
= WID_STR
;
748 strWID
.ps8WidVal
= (u8
*)pu8IPAddr
;
749 strWID
.s32ValueSize
= IP_ALEN
;
751 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
755 host_int_get_ipaddress((WILC_WFIDrvHandle
)drvHandler
, firmwareIPAddress
, idx
);
758 PRINT_D(HOSTINF_DBG
, "Failed to set IP address\n");
759 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
761 PRINT_INFO(HOSTINF_DBG
, "IP address set\n");
774 * @brief Handle_get_IPAddress
775 * @details Setting IP address params in message queue
776 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
777 * @return Error code.
782 s32
Handle_get_IPAddress(void *drvHandler
, u8
*pu8IPAddr
, u8 idx
)
785 s32 s32Error
= WILC_SUCCESS
;
787 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
789 /*prepare configuration packet*/
790 strWID
.u16WIDid
= (u16
)WID_IP_ADDRESS
;
791 strWID
.enuWIDtype
= WID_STR
;
792 strWID
.ps8WidVal
= (u8
*)WILC_MALLOC(IP_ALEN
);
793 strWID
.s32ValueSize
= IP_ALEN
;
795 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
797 PRINT_INFO(HOSTINF_DBG
, "%pI4\n", strWID
.ps8WidVal
);
799 WILC_memcpy(gs8GetIP
[idx
], strWID
.ps8WidVal
, IP_ALEN
);
801 /*get the value by searching the local copy*/
802 WILC_FREE(strWID
.ps8WidVal
);
804 if (WILC_memcmp(gs8GetIP
[idx
], gs8SetIP
[idx
], IP_ALEN
) != 0)
805 host_int_setup_ipaddress((WILC_WFIDrvHandle
)pstrWFIDrv
, gs8SetIP
[idx
], idx
);
807 if (s32Error
!= WILC_SUCCESS
) {
808 PRINT_ER("Failed to get IP address\n");
809 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
811 PRINT_INFO(HOSTINF_DBG
, "IP address retrieved:: u8IfIdx = %d\n", idx
);
812 PRINT_INFO(HOSTINF_DBG
, "%pI4\n", gs8GetIP
[idx
]);
813 PRINT_INFO(HOSTINF_DBG
, "\n");
827 * @brief Handle_SetMacAddress
828 * @details Setting mac address
829 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
830 * @return Error code.
831 * @author Amr Abdel-Moghny
832 * @date November 2013
835 static s32
Handle_SetMacAddress(void *drvHandler
, tstrHostIfSetMacAddress
*pstrHostIfSetMacAddress
)
838 s32 s32Error
= WILC_SUCCESS
;
840 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
841 u8
*mac_buf
= (u8
*)WILC_MALLOC(ETH_ALEN
);
843 if (mac_buf
== NULL
) {
844 PRINT_ER("No buffer to send mac address\n");
847 WILC_memcpy(mac_buf
, pstrHostIfSetMacAddress
->u8MacAddress
, ETH_ALEN
);
849 /*prepare configuration packet*/
850 strWID
.u16WIDid
= (u16
)WID_MAC_ADDR
;
851 strWID
.enuWIDtype
= WID_STR
;
852 strWID
.ps8WidVal
= mac_buf
;
853 strWID
.s32ValueSize
= ETH_ALEN
;
854 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]);
856 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
858 PRINT_ER("Failed to set mac address\n");
859 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
873 * @brief Handle_GetMacAddress
874 * @details Getting mac address
875 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
876 * @return Error code.
877 * @author Amr Abdel-Moghny
881 static s32
Handle_GetMacAddress(void *drvHandler
, tstrHostIfGetMacAddress
*pstrHostIfGetMacAddress
)
884 s32 s32Error
= WILC_SUCCESS
;
887 /*prepare configuration packet*/
888 strWID
.u16WIDid
= (u16
)WID_MAC_ADDR
;
889 strWID
.enuWIDtype
= WID_STR
;
890 strWID
.ps8WidVal
= pstrHostIfGetMacAddress
->u8MacAddress
;
891 strWID
.s32ValueSize
= ETH_ALEN
;
894 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, false, (u32
)drvHandler
);
896 PRINT_ER("Failed to get mac address\n");
897 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
910 * @brief Handle_CfgParam
911 * @details Sending config packet to firmware to set CFG params
912 * @param[in] tstrHostIFCfgParamAttr* strHostIFCfgParamAttr
913 * @return Error code.
918 static s32
Handle_CfgParam(void *drvHandler
, tstrHostIFCfgParamAttr
*strHostIFCfgParamAttr
)
920 s32 s32Error
= WILC_SUCCESS
;
921 tstrWID strWIDList
[32];
923 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
926 down(&(pstrWFIDrv
->gtOsCfgValuesSem
));
929 PRINT_D(HOSTINF_DBG
, "Setting CFG params\n");
931 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& BSS_TYPE
) {
932 /*----------------------------------------------------------*/
933 /*Input Value: INFRASTRUCTURE = 1, */
934 /* INDEPENDENT= 2, */
936 /*----------------------------------------------------------*/
937 /* validate input then copy>> need to check value 4 and 5 */
938 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.bss_type
< 6) {
939 strWIDList
[u8WidCnt
].u16WIDid
= WID_BSS_TYPE
;
940 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.bss_type
;
941 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
942 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
943 pstrWFIDrv
->strCfgValues
.bss_type
= (u8
)strHostIFCfgParamAttr
->pstrCfgParamVal
.bss_type
;
945 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
949 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& AUTH_TYPE
) {
950 /*------------------------------------------------------*/
951 /*Input Values: OPEN_SYSTEM = 0, */
952 /* SHARED_KEY = 1, */
954 /*------------------------------------------------------*/
955 /*validate Possible values*/
956 if ((strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_type
) == 1 || (strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_type
) == 2 || (strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_type
) == 5) {
957 strWIDList
[u8WidCnt
].u16WIDid
= WID_AUTH_TYPE
;
958 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_type
;
959 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
960 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
961 pstrWFIDrv
->strCfgValues
.auth_type
= (u8
)strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_type
;
963 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
967 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& AUTHEN_TIMEOUT
) {
968 /* range is 1 to 65535. */
969 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_timeout
> 0 && strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_timeout
< 65536) {
970 strWIDList
[u8WidCnt
].u16WIDid
= WID_AUTH_TIMEOUT
;
971 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_timeout
;
972 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
973 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
974 pstrWFIDrv
->strCfgValues
.auth_timeout
= strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_timeout
;
976 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
980 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& POWER_MANAGEMENT
) {
981 /*-----------------------------------------------------------*/
982 /*Input Values: NO_POWERSAVE = 0, */
983 /* MIN_FAST_PS = 1, */
984 /* MAX_FAST_PS = 2, */
985 /* MIN_PSPOLL_PS = 3, */
986 /* MAX_PSPOLL_PS = 4 */
987 /*----------------------------------------------------------*/
988 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.power_mgmt_mode
< 5) {
989 strWIDList
[u8WidCnt
].u16WIDid
= WID_POWER_MANAGEMENT
;
990 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.power_mgmt_mode
;
991 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
992 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
993 pstrWFIDrv
->strCfgValues
.power_mgmt_mode
= (u8
)strHostIFCfgParamAttr
->pstrCfgParamVal
.power_mgmt_mode
;
995 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
999 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& RETRY_SHORT
) {
1000 /* range from 1 to 256 */
1001 if ((strHostIFCfgParamAttr
->pstrCfgParamVal
.short_retry_limit
> 0) && (strHostIFCfgParamAttr
->pstrCfgParamVal
.short_retry_limit
< 256)) {
1002 strWIDList
[u8WidCnt
].u16WIDid
= WID_SHORT_RETRY_LIMIT
;
1003 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.short_retry_limit
;
1004 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1005 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1006 pstrWFIDrv
->strCfgValues
.short_retry_limit
= strHostIFCfgParamAttr
->pstrCfgParamVal
.short_retry_limit
;
1008 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1012 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& RETRY_LONG
) {
1013 /* range from 1 to 256 */
1014 if ((strHostIFCfgParamAttr
->pstrCfgParamVal
.long_retry_limit
> 0) && (strHostIFCfgParamAttr
->pstrCfgParamVal
.long_retry_limit
< 256)) {
1015 strWIDList
[u8WidCnt
].u16WIDid
= WID_LONG_RETRY_LIMIT
;
1016 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.long_retry_limit
;
1018 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1019 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1020 pstrWFIDrv
->strCfgValues
.long_retry_limit
= strHostIFCfgParamAttr
->pstrCfgParamVal
.long_retry_limit
;
1022 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1026 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& FRAG_THRESHOLD
) {
1028 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.frag_threshold
> 255 && strHostIFCfgParamAttr
->pstrCfgParamVal
.frag_threshold
< 7937) {
1029 strWIDList
[u8WidCnt
].u16WIDid
= WID_FRAG_THRESHOLD
;
1030 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.frag_threshold
;
1031 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1032 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1033 pstrWFIDrv
->strCfgValues
.frag_threshold
= strHostIFCfgParamAttr
->pstrCfgParamVal
.frag_threshold
;
1035 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1039 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& RTS_THRESHOLD
) {
1040 /* range 256 to 65535 */
1041 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.rts_threshold
> 255 && strHostIFCfgParamAttr
->pstrCfgParamVal
.rts_threshold
< 65536) {
1042 strWIDList
[u8WidCnt
].u16WIDid
= WID_RTS_THRESHOLD
;
1043 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.rts_threshold
;
1044 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1045 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1046 pstrWFIDrv
->strCfgValues
.rts_threshold
= strHostIFCfgParamAttr
->pstrCfgParamVal
.rts_threshold
;
1048 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1052 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& PREAMBLE
) {
1053 /*-----------------------------------------------------*/
1054 /*Input Values: Short= 0, */
1057 /*------------------------------------------------------*/
1058 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.preamble_type
< 3) {
1059 strWIDList
[u8WidCnt
].u16WIDid
= WID_PREAMBLE
;
1060 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.preamble_type
;
1061 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
1062 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
1063 pstrWFIDrv
->strCfgValues
.preamble_type
= strHostIFCfgParamAttr
->pstrCfgParamVal
.preamble_type
;
1065 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1069 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& SHORT_SLOT_ALLOWED
) {
1070 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.short_slot_allowed
< 2) {
1071 strWIDList
[u8WidCnt
].u16WIDid
= WID_SHORT_SLOT_ALLOWED
;
1072 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.short_slot_allowed
;
1073 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
1074 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
1075 pstrWFIDrv
->strCfgValues
.short_slot_allowed
= (u8
)strHostIFCfgParamAttr
->pstrCfgParamVal
.short_slot_allowed
;
1077 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1081 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& TXOP_PROT_DISABLE
) {
1082 /*Description: used to Disable RTS-CTS protection for TXOP burst*/
1083 /*transmission when the acknowledgement policy is No-Ack or Block-Ack */
1084 /* this information is useful for external supplicant */
1085 /*Input Values: 1 for enable and 0 for disable. */
1086 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.txop_prot_disabled
< 2) {
1087 strWIDList
[u8WidCnt
].u16WIDid
= WID_11N_TXOP_PROT_DISABLE
;
1088 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.txop_prot_disabled
;
1089 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
1090 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
1091 pstrWFIDrv
->strCfgValues
.txop_prot_disabled
= (u8
)strHostIFCfgParamAttr
->pstrCfgParamVal
.txop_prot_disabled
;
1093 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1097 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& BEACON_INTERVAL
) {
1098 /* range is 1 to 65535. */
1099 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.beacon_interval
> 0 && strHostIFCfgParamAttr
->pstrCfgParamVal
.beacon_interval
< 65536) {
1100 strWIDList
[u8WidCnt
].u16WIDid
= WID_BEACON_INTERVAL
;
1101 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.beacon_interval
;
1102 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1103 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1104 pstrWFIDrv
->strCfgValues
.beacon_interval
= strHostIFCfgParamAttr
->pstrCfgParamVal
.beacon_interval
;
1106 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1110 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& DTIM_PERIOD
) {
1111 /* range is 1 to 255. */
1112 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.dtim_period
> 0 && strHostIFCfgParamAttr
->pstrCfgParamVal
.dtim_period
< 256) {
1113 strWIDList
[u8WidCnt
].u16WIDid
= WID_DTIM_PERIOD
;
1114 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.dtim_period
;
1115 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
1116 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
1117 pstrWFIDrv
->strCfgValues
.dtim_period
= strHostIFCfgParamAttr
->pstrCfgParamVal
.dtim_period
;
1119 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1123 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& SITE_SURVEY
) {
1124 /*----------------------------------------------------------------------*/
1125 /*Input Values: SITE_SURVEY_1CH = 0, i.e.: currently set channel */
1126 /* SITE_SURVEY_ALL_CH = 1, */
1127 /* SITE_SURVEY_OFF = 2 */
1128 /*----------------------------------------------------------------------*/
1129 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_enabled
< 3) {
1130 strWIDList
[u8WidCnt
].u16WIDid
= WID_SITE_SURVEY
;
1131 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_enabled
;
1132 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
1133 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
1134 pstrWFIDrv
->strCfgValues
.site_survey_enabled
= (u8
)strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_enabled
;
1136 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1140 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& SITE_SURVEY_SCAN_TIME
) {
1141 /* range is 1 to 65535. */
1142 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_scan_time
> 0 && strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_scan_time
< 65536) {
1143 strWIDList
[u8WidCnt
].u16WIDid
= WID_SITE_SURVEY_SCAN_TIME
;
1144 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_scan_time
;
1145 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1146 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1147 pstrWFIDrv
->strCfgValues
.site_survey_scan_time
= strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_scan_time
;
1149 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1153 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& ACTIVE_SCANTIME
) {
1154 /* range is 1 to 65535. */
1155 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.active_scan_time
> 0 && strHostIFCfgParamAttr
->pstrCfgParamVal
.active_scan_time
< 65536) {
1156 strWIDList
[u8WidCnt
].u16WIDid
= WID_ACTIVE_SCAN_TIME
;
1157 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.active_scan_time
;
1158 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1159 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1160 pstrWFIDrv
->strCfgValues
.active_scan_time
= strHostIFCfgParamAttr
->pstrCfgParamVal
.active_scan_time
;
1162 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1166 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& PASSIVE_SCANTIME
) {
1167 /* range is 1 to 65535. */
1168 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.passive_scan_time
> 0 && strHostIFCfgParamAttr
->pstrCfgParamVal
.passive_scan_time
< 65536) {
1169 strWIDList
[u8WidCnt
].u16WIDid
= WID_PASSIVE_SCAN_TIME
;
1170 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.passive_scan_time
;
1171 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1172 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1173 pstrWFIDrv
->strCfgValues
.passive_scan_time
= strHostIFCfgParamAttr
->pstrCfgParamVal
.passive_scan_time
;
1175 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1179 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& CURRENT_TX_RATE
) {
1180 CURRENT_TX_RATE_T curr_tx_rate
= strHostIFCfgParamAttr
->pstrCfgParamVal
.curr_tx_rate
;
1181 /*----------------------------------------------------------------------*/
1182 /*Rates: 1 2 5.5 11 6 9 12 18 24 36 48 54 Auto */
1183 /*InputValues: 1 2 3 4 5 6 7 8 9 10 11 12 0 */
1184 /*----------------------------------------------------------------------*/
1186 if (curr_tx_rate
== AUTORATE
|| curr_tx_rate
== MBPS_1
1187 || curr_tx_rate
== MBPS_2
|| curr_tx_rate
== MBPS_5_5
1188 || curr_tx_rate
== MBPS_11
|| curr_tx_rate
== MBPS_6
1189 || curr_tx_rate
== MBPS_9
|| curr_tx_rate
== MBPS_12
1190 || curr_tx_rate
== MBPS_18
|| curr_tx_rate
== MBPS_24
1191 || curr_tx_rate
== MBPS_36
|| curr_tx_rate
== MBPS_48
|| curr_tx_rate
== MBPS_54
) {
1192 strWIDList
[u8WidCnt
].u16WIDid
= WID_CURRENT_TX_RATE
;
1193 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&curr_tx_rate
;
1194 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1195 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1196 pstrWFIDrv
->strCfgValues
.curr_tx_rate
= (u8
)curr_tx_rate
;
1198 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1202 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, u8WidCnt
, false, (u32
)pstrWFIDrv
);
1205 PRINT_ER("Error in setting CFG params\n");
1207 WILC_CATCH(s32Error
)
1210 up(&(pstrWFIDrv
->gtOsCfgValuesSem
));
1216 * @brief Handle_wait_msg_q_empty
1217 * @details this should be the last msg and then the msg Q becomes idle
1218 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1219 * @return Error code.
1224 static s32
Handle_wait_msg_q_empty(void)
1226 s32 s32Error
= WILC_SUCCESS
;
1228 g_wilc_initialized
= 0;
1234 * @brief Handle_Scan
1235 * @details Sending config packet to firmware to set the scan params
1236 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1237 * @return Error code.
1242 static s32
Handle_Scan(void *drvHandler
, tstrHostIFscanAttr
*pstrHostIFscanAttr
)
1244 s32 s32Error
= WILC_SUCCESS
;
1245 tstrWID strWIDList
[5];
1246 u32 u32WidsCount
= 0;
1250 u8
*pu8HdnNtwrksWidVal
= NULL
;
1251 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*) drvHandler
;
1253 PRINT_D(HOSTINF_DBG
, "Setting SCAN params\n");
1254 PRINT_D(HOSTINF_DBG
, "Scanning: In [%d] state\n", pstrWFIDrv
->enuHostIFstate
);
1256 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
= pstrHostIFscanAttr
->pfScanResult
;
1257 pstrWFIDrv
->strWILC_UsrScanReq
.u32UserScanPvoid
= pstrHostIFscanAttr
->pvUserArg
;
1262 if ((pstrWFIDrv
->enuHostIFstate
>= HOST_IF_SCANNING
) && (pstrWFIDrv
->enuHostIFstate
< HOST_IF_CONNECTED
)) {
1263 /* here we either in HOST_IF_SCANNING, HOST_IF_WAITING_CONN_REQ or HOST_IF_WAITING_CONN_RESP */
1264 PRINT_D(GENERIC_DBG
, "Don't scan we are already in [%d] state\n", pstrWFIDrv
->enuHostIFstate
);
1265 WILC_ERRORREPORT(s32Error
, WILC_BUSY
);
1268 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
1269 if (g_obtainingIP
|| connecting
) {
1270 PRINT_D(GENERIC_DBG
, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
1271 WILC_ERRORREPORT(s32Error
, WILC_BUSY
);
1275 PRINT_D(HOSTINF_DBG
, "Setting SCAN params\n");
1278 pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
= 0;
1281 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_SSID_PROBE_REQ
;
1282 strWIDList
[u32WidsCount
].enuWIDtype
= WID_STR
;
1284 for (i
= 0; i
< pstrHostIFscanAttr
->strHiddenNetwork
.u8ssidnum
; i
++)
1285 valuesize
+= ((pstrHostIFscanAttr
->strHiddenNetwork
.pstrHiddenNetworkInfo
[i
].u8ssidlen
) + 1);
1286 pu8HdnNtwrksWidVal
= WILC_MALLOC(valuesize
+ 1);
1287 strWIDList
[u32WidsCount
].ps8WidVal
= pu8HdnNtwrksWidVal
;
1288 if (strWIDList
[u32WidsCount
].ps8WidVal
!= NULL
) {
1289 pu8Buffer
= strWIDList
[u32WidsCount
].ps8WidVal
;
1291 *pu8Buffer
++ = pstrHostIFscanAttr
->strHiddenNetwork
.u8ssidnum
;
1293 PRINT_D(HOSTINF_DBG
, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr
->strHiddenNetwork
.u8ssidnum
);
1295 for (i
= 0; i
< pstrHostIFscanAttr
->strHiddenNetwork
.u8ssidnum
; i
++) {
1296 *pu8Buffer
++ = pstrHostIFscanAttr
->strHiddenNetwork
.pstrHiddenNetworkInfo
[i
].u8ssidlen
;
1297 WILC_memcpy(pu8Buffer
, pstrHostIFscanAttr
->strHiddenNetwork
.pstrHiddenNetworkInfo
[i
].pu8ssid
, pstrHostIFscanAttr
->strHiddenNetwork
.pstrHiddenNetworkInfo
[i
].u8ssidlen
);
1298 pu8Buffer
+= pstrHostIFscanAttr
->strHiddenNetwork
.pstrHiddenNetworkInfo
[i
].u8ssidlen
;
1303 strWIDList
[u32WidsCount
].s32ValueSize
= (s32
)(valuesize
+ 1);
1307 /*filling cfg param array*/
1309 /* if((pstrHostIFscanAttr->pu8IEs != NULL) && (pstrHostIFscanAttr->IEsLen != 0)) */
1311 /* IEs to be inserted in Probe Request */
1312 strWIDList
[u32WidsCount
].u16WIDid
= WID_INFO_ELEMENT_PROBE
;
1313 strWIDList
[u32WidsCount
].enuWIDtype
= WID_BIN_DATA
;
1314 strWIDList
[u32WidsCount
].ps8WidVal
= pstrHostIFscanAttr
->pu8IEs
;
1315 strWIDList
[u32WidsCount
].s32ValueSize
= pstrHostIFscanAttr
->IEsLen
;
1320 strWIDList
[u32WidsCount
].u16WIDid
= WID_SCAN_TYPE
;
1321 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
1322 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
1323 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrHostIFscanAttr
->u8ScanType
));
1326 /*list of channels to be scanned*/
1327 strWIDList
[u32WidsCount
].u16WIDid
= WID_SCAN_CHANNEL_LIST
;
1328 strWIDList
[u32WidsCount
].enuWIDtype
= WID_BIN_DATA
;
1330 /* Bug 4648: Convert channel numbers to start from 0 not 1. */
1331 if (pstrHostIFscanAttr
->pu8ChnlFreqList
!= NULL
&& pstrHostIFscanAttr
->u8ChnlListLen
> 0) {
1334 for (i
= 0; i
< pstrHostIFscanAttr
->u8ChnlListLen
; i
++) {
1335 if (pstrHostIFscanAttr
->pu8ChnlFreqList
[i
] > 0)
1336 pstrHostIFscanAttr
->pu8ChnlFreqList
[i
] = pstrHostIFscanAttr
->pu8ChnlFreqList
[i
] - 1;
1340 strWIDList
[u32WidsCount
].ps8WidVal
= pstrHostIFscanAttr
->pu8ChnlFreqList
;
1341 strWIDList
[u32WidsCount
].s32ValueSize
= pstrHostIFscanAttr
->u8ChnlListLen
;
1345 strWIDList
[u32WidsCount
].u16WIDid
= WID_START_SCAN_REQ
;
1346 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
1347 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
1348 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrHostIFscanAttr
->u8ScanSource
));
1351 /*keep the state as is , no need to change it*/
1352 /* gWFiDrvHandle->enuHostIFstate = HOST_IF_SCANNING; */
1354 if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_CONNECTED
) {
1355 gbScanWhileConnected
= true;
1356 } else if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_IDLE
) {
1357 gbScanWhileConnected
= false;
1360 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, u32WidsCount
, false, (u32
)pstrWFIDrv
);
1363 PRINT_ER("Failed to send scan paramters config packet\n");
1364 WILC_ERRORREPORT(s32Error
, s32Error
);
1366 PRINT_D(HOSTINF_DBG
, "Successfully sent SCAN params config packet\n");
1369 WILC_CATCH(s32Error
)
1371 WILC_TimerStop(&(pstrWFIDrv
->hScanTimer
), NULL
);
1372 /*if there is an ongoing scan request*/
1373 Handle_ScanDone(drvHandler
, SCAN_EVENT_ABORTED
);
1376 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1377 if (pstrHostIFscanAttr
->pu8ChnlFreqList
!= NULL
) {
1378 WILC_FREE(pstrHostIFscanAttr
->pu8ChnlFreqList
);
1379 pstrHostIFscanAttr
->pu8ChnlFreqList
= NULL
;
1382 /* Deallocate pstrHostIFscanAttr->pu8IEs which was previously allocated by the sending thread */
1383 if (pstrHostIFscanAttr
->pu8IEs
!= NULL
) {
1384 WILC_FREE(pstrHostIFscanAttr
->pu8IEs
);
1385 pstrHostIFscanAttr
->pu8IEs
= NULL
;
1387 if (pstrHostIFscanAttr
->strHiddenNetwork
.pstrHiddenNetworkInfo
!= NULL
) {
1388 WILC_FREE(pstrHostIFscanAttr
->strHiddenNetwork
.pstrHiddenNetworkInfo
);
1389 pstrHostIFscanAttr
->strHiddenNetwork
.pstrHiddenNetworkInfo
= NULL
;
1392 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1393 if (pstrHostIFscanAttr
->pu8ChnlFreqList
!= NULL
) {
1394 WILC_FREE(pstrHostIFscanAttr
->pu8ChnlFreqList
);
1395 pstrHostIFscanAttr
->pu8ChnlFreqList
= NULL
;
1398 if (pu8HdnNtwrksWidVal
!= NULL
)
1399 WILC_FREE(pu8HdnNtwrksWidVal
);
1405 * @brief Handle_ScanDone
1406 * @details Call scan notification callback function
1408 * @return Error code.
1413 static s32
Handle_ScanDone(void *drvHandler
, tenuScanEvent enuEvent
)
1415 s32 s32Error
= WILC_SUCCESS
;
1417 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
1420 u8 u8abort_running_scan
;
1424 PRINT_D(HOSTINF_DBG
, "in Handle_ScanDone()\n");
1427 /*Ask FW to abort the running scan, if any*/
1428 if (enuEvent
== SCAN_EVENT_ABORTED
) {
1429 PRINT_D(GENERIC_DBG
, "Abort running scan\n");
1430 u8abort_running_scan
= 1;
1431 strWID
.u16WIDid
= (u16
)WID_ABORT_RUNNING_SCAN
;
1432 strWID
.enuWIDtype
= WID_CHAR
;
1433 strWID
.ps8WidVal
= (s8
*)&u8abort_running_scan
;
1434 strWID
.s32ValueSize
= sizeof(char);
1437 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
1438 if (s32Error
!= WILC_SUCCESS
) {
1439 PRINT_ER("Failed to set abort running scan\n");
1440 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
1442 WILC_CATCH(s32Error
)
1447 if (pstrWFIDrv
== NULL
) {
1448 PRINT_ER("Driver handler is NULL\n");
1452 /*if there is an ongoing scan request*/
1453 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
1454 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult(enuEvent
, NULL
,
1455 pstrWFIDrv
->strWILC_UsrScanReq
.u32UserScanPvoid
, NULL
);
1456 /*delete current scan request*/
1457 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
= NULL
;
1464 * @brief Handle_Connect
1465 * @details Sending config packet to firmware to starting connection
1466 * @param[in] tstrHostIFconnectAttr* pstrHostIFconnectAttr
1467 * @return Error code.
1472 u8 u8ConnectedSSID
[6] = {0};
1473 static s32
Handle_Connect(void *drvHandler
, tstrHostIFconnectAttr
*pstrHostIFconnectAttr
)
1475 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*) drvHandler
;
1476 s32 s32Error
= WILC_SUCCESS
;
1477 tstrWID strWIDList
[8];
1478 u32 u32WidsCount
= 0, dummyval
= 0;
1479 /* char passphrase[] = "12345678"; */
1480 #ifndef CONNECT_DIRECT
1481 s32 s32Err
= WILC_SUCCESS
;
1483 u8 u8bssDscListIndex
;
1484 wid_site_survey_reslts_s
*pstrSurveyResults
= NULL
;
1486 u8
*pu8CurrByte
= NULL
;
1487 /*Bug4218: Parsing Join Param*/
1488 #ifdef WILC_PARSE_SCAN_IN_HOST
1489 tstrJoinBssParam
*ptstrJoinBssParam
;
1490 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1494 PRINT_D(GENERIC_DBG
, "Handling connect request\n");
1496 #ifndef CONNECT_DIRECT
1497 WILC_memset(gapu8RcvdSurveyResults
[0], 0, MAX_SURVEY_RESULT_FRAG_SIZE
);
1498 WILC_memset(gapu8RcvdSurveyResults
[1], 0, MAX_SURVEY_RESULT_FRAG_SIZE
);
1501 PRINT_D(HOSTINF_DBG
, "Getting site survey results\n");
1502 s32Err
= host_int_get_site_survey_results((WILC_WFIDrvHandle
)pstrWFIDrv
,
1503 gapu8RcvdSurveyResults
,
1504 MAX_SURVEY_RESULT_FRAG_SIZE
);
1506 PRINT_ER("Failed to get site survey results\n");
1507 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
1510 s32Err
= ParseSurveyResults(gapu8RcvdSurveyResults
, &pstrSurveyResults
,
1511 &pstrWFIDrv
->u32SurveyResultsCount
);
1514 if (s32Err
== WILC_SUCCESS
) {
1515 /* use the parsed info in pstrSurveyResults, then deallocate it */
1516 PRINT_D(HOSTINF_DBG
, "Copying site survey results in global structure, then deallocate\n");
1517 for (i
= 0; i
< pstrWFIDrv
->u32SurveyResultsCount
; i
++) {
1518 WILC_memcpy(&pstrWFIDrv
->astrSurveyResults
[i
], &pstrSurveyResults
[i
],
1519 sizeof(wid_site_survey_reslts_s
));
1522 DeallocateSurveyResults(pstrSurveyResults
);
1524 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
1525 PRINT_ER("ParseSurveyResults() Error(%d)\n", s32Err
);
1529 for (i
= 0; i
< pstrWFIDrv
->u32SurveyResultsCount
; i
++) {
1530 if (WILC_memcmp(pstrWFIDrv
->astrSurveyResults
[i
].SSID
,
1531 pstrHostIFconnectAttr
->pu8ssid
,
1532 pstrHostIFconnectAttr
->ssidLen
) == 0) {
1533 PRINT_INFO(HOSTINF_DBG
, "Network with required SSID is found %s\n", pstrHostIFconnectAttr
->pu8ssid
);
1534 if (pstrHostIFconnectAttr
->pu8bssid
== NULL
) {
1535 /* BSSID is not passed from the user, so decision of matching
1536 * is done by SSID only */
1537 PRINT_INFO(HOSTINF_DBG
, "BSSID is not passed from the user\n");
1540 /* BSSID is also passed from the user, so decision of matching
1541 * should consider also this passed BSSID */
1543 if (WILC_memcmp(pstrWFIDrv
->astrSurveyResults
[i
].BSSID
,
1544 pstrHostIFconnectAttr
->pu8bssid
,
1546 PRINT_INFO(HOSTINF_DBG
, "BSSID is passed from the user and matched\n");
1553 if (i
< pstrWFIDrv
->u32SurveyResultsCount
) {
1554 u8bssDscListIndex
= i
;
1556 PRINT_INFO(HOSTINF_DBG
, "Connecting to network of Bss Idx%d and SSID %s and channel%d\n",
1557 u8bssDscListIndex
, pstrWFIDrv
->astrSurveyResults
[u8bssDscListIndex
].SSID
,
1558 pstrWFIDrv
->astrSurveyResults
[u8bssDscListIndex
].Channel
);
1560 PRINT_INFO(HOSTINF_DBG
, "Saving connection parameters in global structure\n");
1562 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
) {
1563 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
= (u8
*)WILC_MALLOC(6);
1564 WILC_memcpy(pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
, pstrHostIFconnectAttr
->pu8bssid
, 6);
1567 pstrWFIDrv
->strWILC_UsrConnReq
.ssidLen
= pstrHostIFconnectAttr
->ssidLen
;
1568 if (pstrHostIFconnectAttr
->pu8ssid
!= NULL
) {
1569 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
= (u8
*)WILC_MALLOC(pstrHostIFconnectAttr
->ssidLen
+ 1);
1570 WILC_memcpy(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
, pstrHostIFconnectAttr
->pu8ssid
,
1571 pstrHostIFconnectAttr
->ssidLen
);
1572 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
[pstrHostIFconnectAttr
->ssidLen
] = '\0';
1575 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
= pstrHostIFconnectAttr
->IEsLen
;
1576 if (pstrHostIFconnectAttr
->pu8IEs
!= NULL
) {
1577 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
= (u8
*)WILC_MALLOC(pstrHostIFconnectAttr
->IEsLen
);
1578 WILC_memcpy(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
, pstrHostIFconnectAttr
->pu8IEs
,
1579 pstrHostIFconnectAttr
->IEsLen
);
1582 pstrWFIDrv
->strWILC_UsrConnReq
.u8security
= pstrHostIFconnectAttr
->u8security
;
1583 pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
= pstrHostIFconnectAttr
->tenuAuth_type
;
1584 pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
= pstrHostIFconnectAttr
->pfConnectResult
;
1585 pstrWFIDrv
->strWILC_UsrConnReq
.u32UserConnectPvoid
= pstrHostIFconnectAttr
->pvUserArg
;
1588 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1589 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1591 /* IEs to be inserted in Association Request */
1592 strWIDList
[u32WidsCount
].u16WIDid
= WID_INFO_ELEMENT_ASSOCIATE
;
1593 strWIDList
[u32WidsCount
].enuWIDtype
= WID_BIN_DATA
;
1594 strWIDList
[u32WidsCount
].ps8WidVal
= pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
;
1595 strWIDList
[u32WidsCount
].s32ValueSize
= pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
;
1598 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_11I_MODE
;
1599 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
1600 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
1601 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrWFIDrv
->strWILC_UsrConnReq
.u8security
));
1604 PRINT_INFO(HOSTINF_DBG
, "Encrypt Mode = %x\n", pstrWFIDrv
->strWILC_UsrConnReq
.u8security
);
1606 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_AUTH_TYPE
;
1607 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
1608 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
1609 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
);
1612 PRINT_INFO(HOSTINF_DBG
, "Authentication Type = %x\n", pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
);
1614 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
1615 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1616 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
1617 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
1621 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_JOIN_REQ
;
1622 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
1623 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
1624 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)&u8bssDscListIndex
;
1627 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1628 * firmware at chip reset when processing the WIDs of the Connect Request.
1629 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1630 /* ////////////////////// */
1631 gu32WidConnRstHack
= 0;
1632 /* ////////////////////// */
1634 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, u32WidsCount
, false, (u32
)pstrWFIDrv
);
1636 PRINT_ER("Handle_Connect()] failed to send config packet\n");
1637 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
1639 pstrWFIDrv
->enuHostIFstate
= HOST_IF_WAITING_CONN_RESP
;
1643 PRINT_ER("Required BSSID not found\n");
1644 WILC_ERRORREPORT(s32Error
, WILC_NOT_FOUND
);
1649 /* if we try to connect to an already connected AP then discard the request */
1651 if (WILC_memcmp(pstrHostIFconnectAttr
->pu8bssid
, u8ConnectedSSID
, ETH_ALEN
) == 0) {
1653 s32Error
= WILC_SUCCESS
;
1654 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1658 PRINT_INFO(HOSTINF_DBG
, "Saving connection parameters in global structure\n");
1660 /*Bug4218: Parsing Join Param*/
1661 #ifdef WILC_PARSE_SCAN_IN_HOST
1662 ptstrJoinBssParam
= (tstrJoinBssParam
*)pstrHostIFconnectAttr
->pJoinParams
;
1663 if (ptstrJoinBssParam
== NULL
) {
1664 PRINT_ER("Required BSSID not found\n");
1665 WILC_ERRORREPORT(s32Error
, WILC_NOT_FOUND
);
1667 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1669 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
) {
1670 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
= (u8
*)WILC_MALLOC(6);
1671 WILC_memcpy(pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
, pstrHostIFconnectAttr
->pu8bssid
, 6);
1674 pstrWFIDrv
->strWILC_UsrConnReq
.ssidLen
= pstrHostIFconnectAttr
->ssidLen
;
1675 if (pstrHostIFconnectAttr
->pu8ssid
!= NULL
) {
1676 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
= (u8
*)WILC_MALLOC(pstrHostIFconnectAttr
->ssidLen
+ 1);
1677 WILC_memcpy(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
, pstrHostIFconnectAttr
->pu8ssid
,
1678 pstrHostIFconnectAttr
->ssidLen
);
1679 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
[pstrHostIFconnectAttr
->ssidLen
] = '\0';
1682 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
= pstrHostIFconnectAttr
->IEsLen
;
1683 if (pstrHostIFconnectAttr
->pu8IEs
!= NULL
) {
1684 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
= (u8
*)WILC_MALLOC(pstrHostIFconnectAttr
->IEsLen
);
1685 WILC_memcpy(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
, pstrHostIFconnectAttr
->pu8IEs
,
1686 pstrHostIFconnectAttr
->IEsLen
);
1689 pstrWFIDrv
->strWILC_UsrConnReq
.u8security
= pstrHostIFconnectAttr
->u8security
;
1690 pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
= pstrHostIFconnectAttr
->tenuAuth_type
;
1691 pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
= pstrHostIFconnectAttr
->pfConnectResult
;
1692 pstrWFIDrv
->strWILC_UsrConnReq
.u32UserConnectPvoid
= pstrHostIFconnectAttr
->pvUserArg
;
1694 strWIDList
[u32WidsCount
].u16WIDid
= WID_SUCCESS_FRAME_COUNT
;
1695 strWIDList
[u32WidsCount
].enuWIDtype
= WID_INT
;
1696 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(u32
);
1697 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(dummyval
));
1700 strWIDList
[u32WidsCount
].u16WIDid
= WID_RECEIVED_FRAGMENT_COUNT
;
1701 strWIDList
[u32WidsCount
].enuWIDtype
= WID_INT
;
1702 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(u32
);
1703 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(dummyval
));
1706 strWIDList
[u32WidsCount
].u16WIDid
= WID_FAILED_COUNT
;
1707 strWIDList
[u32WidsCount
].enuWIDtype
= WID_INT
;
1708 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(u32
);
1709 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(dummyval
));
1712 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1713 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1715 /* IEs to be inserted in Association Request */
1716 strWIDList
[u32WidsCount
].u16WIDid
= WID_INFO_ELEMENT_ASSOCIATE
;
1717 strWIDList
[u32WidsCount
].enuWIDtype
= WID_BIN_DATA
;
1718 strWIDList
[u32WidsCount
].ps8WidVal
= pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
;
1719 strWIDList
[u32WidsCount
].s32ValueSize
= pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
;
1723 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr
->pu8ssid
, 7)) {
1725 gu32FlushedInfoElemAsocSize
= pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
;
1726 gu8FlushedInfoElemAsoc
= WILC_MALLOC(gu32FlushedInfoElemAsocSize
);
1727 memcpy(gu8FlushedInfoElemAsoc
, pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
,
1728 gu32FlushedInfoElemAsocSize
);
1731 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_11I_MODE
;
1732 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
1733 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
1734 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrWFIDrv
->strWILC_UsrConnReq
.u8security
));
1738 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr
->pu8ssid
, 7))
1739 gu8Flushed11iMode
= pstrWFIDrv
->strWILC_UsrConnReq
.u8security
;
1741 PRINT_INFO(HOSTINF_DBG
, "Encrypt Mode = %x\n", pstrWFIDrv
->strWILC_UsrConnReq
.u8security
);
1744 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_AUTH_TYPE
;
1745 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
1746 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
1747 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
);
1751 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr
->pu8ssid
, 7))
1752 gu8FlushedAuthType
= (u8
)pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
;
1754 PRINT_INFO(HOSTINF_DBG
, "Authentication Type = %x\n", pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
);
1756 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
1757 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1758 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
1759 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
1763 PRINT_D(HOSTINF_DBG
, "Connecting to network of SSID %s on channel %d\n",
1764 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
, pstrHostIFconnectAttr
->u8channel
);
1767 #ifndef WILC_PARSE_SCAN_IN_HOST
1768 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_JOIN_REQ_EXTENDED
;
1769 strWIDList
[u32WidsCount
].enuWIDtype
= WID_STR
;
1770 strWIDList
[u32WidsCount
].s32ValueSize
= MAX_SSID_LEN
+ 7;
1771 strWIDList
[u32WidsCount
].ps8WidVal
= WILC_MALLOC(strWIDList
[u32WidsCount
].s32ValueSize
);
1773 if (strWIDList
[u32WidsCount
].ps8WidVal
== NULL
)
1774 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
1776 pu8CurrByte
= strWIDList
[u32WidsCount
].ps8WidVal
;
1778 if (pstrHostIFconnectAttr
->pu8ssid
!= NULL
) {
1779 WILC_memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->pu8ssid
, pstrHostIFconnectAttr
->ssidLen
);
1780 pu8CurrByte
[pstrHostIFconnectAttr
->ssidLen
] = '\0';
1782 pu8CurrByte
+= MAX_SSID_LEN
;
1783 if ((pstrHostIFconnectAttr
->u8channel
>= 1) && (pstrHostIFconnectAttr
->u8channel
<= 14)) {
1784 *(pu8CurrByte
++) = pstrHostIFconnectAttr
->u8channel
;
1786 PRINT_ER("Channel out of range\n");
1787 *(pu8CurrByte
++) = 0xFF;
1789 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
)
1790 WILC_memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->pu8bssid
, 6);
1793 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1794 pu8CurrByte
= strWIDList
[u32WidsCount
].ps8WidVal
;
1798 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_JOIN_REQ_EXTENDED
;
1799 strWIDList
[u32WidsCount
].enuWIDtype
= WID_STR
;
1801 /*Sending NoA attributes during connection*/
1802 strWIDList
[u32WidsCount
].s32ValueSize
= 112; /* 79; */
1803 strWIDList
[u32WidsCount
].ps8WidVal
= WILC_MALLOC(strWIDList
[u32WidsCount
].s32ValueSize
);
1806 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr
->pu8ssid
, 7)) {
1807 gu32FlushedJoinReqSize
= strWIDList
[u32WidsCount
].s32ValueSize
;
1808 gu8FlushedJoinReq
= WILC_MALLOC(gu32FlushedJoinReqSize
);
1810 if (strWIDList
[u32WidsCount
].ps8WidVal
== NULL
)
1811 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
1813 pu8CurrByte
= strWIDList
[u32WidsCount
].ps8WidVal
;
1816 if (pstrHostIFconnectAttr
->pu8ssid
!= NULL
) {
1817 WILC_memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->pu8ssid
, pstrHostIFconnectAttr
->ssidLen
);
1818 pu8CurrByte
[pstrHostIFconnectAttr
->ssidLen
] = '\0';
1820 pu8CurrByte
+= MAX_SSID_LEN
;
1823 *(pu8CurrByte
++) = INFRASTRUCTURE
;
1825 if ((pstrHostIFconnectAttr
->u8channel
>= 1) && (pstrHostIFconnectAttr
->u8channel
<= 14)) {
1826 *(pu8CurrByte
++) = pstrHostIFconnectAttr
->u8channel
;
1828 PRINT_ER("Channel out of range\n");
1829 *(pu8CurrByte
++) = 0xFF;
1832 *(pu8CurrByte
++) = (ptstrJoinBssParam
->cap_info
) & 0xFF;
1833 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->cap_info
) >> 8) & 0xFF;
1834 PRINT_D(HOSTINF_DBG
, "* Cap Info %0x*\n", (*(pu8CurrByte
- 2) | ((*(pu8CurrByte
- 1)) << 8)));
1837 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
)
1838 WILC_memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->pu8bssid
, 6);
1842 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
)
1843 WILC_memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->pu8bssid
, 6);
1847 *(pu8CurrByte
++) = (ptstrJoinBssParam
->beacon_period
) & 0xFF;
1848 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->beacon_period
) >> 8) & 0xFF;
1849 PRINT_D(HOSTINF_DBG
, "* Beacon Period %d*\n", (*(pu8CurrByte
- 2) | ((*(pu8CurrByte
- 1)) << 8)));
1851 *(pu8CurrByte
++) = ptstrJoinBssParam
->dtim_period
;
1852 PRINT_D(HOSTINF_DBG
, "* DTIM Period %d*\n", (*(pu8CurrByte
- 1)));
1853 /* Supported rates*/
1854 WILC_memcpy(pu8CurrByte
, ptstrJoinBssParam
->supp_rates
, MAX_RATES_SUPPORTED
+ 1);
1855 pu8CurrByte
+= (MAX_RATES_SUPPORTED
+ 1);
1858 *(pu8CurrByte
++) = ptstrJoinBssParam
->wmm_cap
;
1859 PRINT_D(HOSTINF_DBG
, "* wmm cap%d*\n", (*(pu8CurrByte
- 1)));
1861 *(pu8CurrByte
++) = ptstrJoinBssParam
->uapsd_cap
;
1864 *(pu8CurrByte
++) = ptstrJoinBssParam
->ht_capable
;
1865 /* copy this information to the user request */
1866 pstrWFIDrv
->strWILC_UsrConnReq
.IsHTCapable
= ptstrJoinBssParam
->ht_capable
;
1869 *(pu8CurrByte
++) = ptstrJoinBssParam
->rsn_found
;
1870 PRINT_D(HOSTINF_DBG
, "* rsn found %d*\n", *(pu8CurrByte
- 1));
1871 /* rsn group policy*/
1872 *(pu8CurrByte
++) = ptstrJoinBssParam
->rsn_grp_policy
;
1873 PRINT_D(HOSTINF_DBG
, "* rsn group policy %0x*\n", (*(pu8CurrByte
- 1)));
1875 *(pu8CurrByte
++) = ptstrJoinBssParam
->mode_802_11i
;
1876 PRINT_D(HOSTINF_DBG
, "* mode_802_11i %d*\n", (*(pu8CurrByte
- 1)));
1877 /* rsn pcip policy*/
1878 WILC_memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_pcip_policy
, sizeof(ptstrJoinBssParam
->rsn_pcip_policy
));
1879 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_pcip_policy
);
1881 /* rsn auth policy*/
1882 WILC_memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_auth_policy
, sizeof(ptstrJoinBssParam
->rsn_auth_policy
));
1883 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_auth_policy
);
1885 /* rsn auth policy*/
1886 WILC_memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_cap
, sizeof(ptstrJoinBssParam
->rsn_cap
));
1887 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_cap
);
1890 *(pu8CurrByte
++) = REAL_JOIN_REQ
;
1893 *(pu8CurrByte
++) = ptstrJoinBssParam
->u8NoaEnbaled
;
1894 if (ptstrJoinBssParam
->u8NoaEnbaled
) {
1895 PRINT_D(HOSTINF_DBG
, "NOA present\n");
1897 *(pu8CurrByte
++) = (ptstrJoinBssParam
->tsf
) & 0xFF;
1898 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 8) & 0xFF;
1899 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 16) & 0xFF;
1900 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 24) & 0xFF;
1902 *(pu8CurrByte
++) = ptstrJoinBssParam
->u8Index
;
1904 *(pu8CurrByte
++) = ptstrJoinBssParam
->u8OppEnable
;
1906 if (ptstrJoinBssParam
->u8OppEnable
)
1907 *(pu8CurrByte
++) = ptstrJoinBssParam
->u8CtWindow
;
1909 *(pu8CurrByte
++) = ptstrJoinBssParam
->u8Count
;
1911 WILC_memcpy(pu8CurrByte
, ptstrJoinBssParam
->au8Duration
, sizeof(ptstrJoinBssParam
->au8Duration
));
1913 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->au8Duration
);
1915 WILC_memcpy(pu8CurrByte
, ptstrJoinBssParam
->au8Interval
, sizeof(ptstrJoinBssParam
->au8Interval
));
1917 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->au8Interval
);
1919 WILC_memcpy(pu8CurrByte
, ptstrJoinBssParam
->au8StartTime
, sizeof(ptstrJoinBssParam
->au8StartTime
));
1921 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->au8StartTime
);
1924 PRINT_D(HOSTINF_DBG
, "NOA not present\n");
1928 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1929 pu8CurrByte
= strWIDList
[u32WidsCount
].ps8WidVal
;
1932 #endif /* #ifdef WILC_PARSE_SCAN_IN_HOST*/
1935 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1936 * firmware at chip reset when processing the WIDs of the Connect Request.
1937 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1938 /* ////////////////////// */
1939 gu32WidConnRstHack
= 0;
1940 /* ////////////////////// */
1943 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr
->pu8ssid
, 7)) {
1944 memcpy(gu8FlushedJoinReq
, pu8CurrByte
, gu32FlushedJoinReqSize
);
1945 gu8FlushedJoinReqDrvHandler
= (u32
)pstrWFIDrv
;
1948 PRINT_D(GENERIC_DBG
, "send HOST_IF_WAITING_CONN_RESP\n");
1950 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
) {
1951 WILC_memcpy(u8ConnectedSSID
, pstrHostIFconnectAttr
->pu8bssid
, ETH_ALEN
);
1953 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]));
1954 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]));
1957 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, u32WidsCount
, false, (u32
)pstrWFIDrv
);
1959 PRINT_ER("Handle_Connect()] failed to send config packet\n");
1960 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
1962 PRINT_D(GENERIC_DBG
, "set HOST_IF_WAITING_CONN_RESP\n");
1963 pstrWFIDrv
->enuHostIFstate
= HOST_IF_WAITING_CONN_RESP
;
1967 WILC_CATCH(s32Error
)
1969 tstrConnectInfo strConnectInfo
;
1971 WILC_TimerStop(&(pstrWFIDrv
->hConnectTimer
), NULL
);
1973 PRINT_D(HOSTINF_DBG
, "could not start connecting to the required network\n");
1975 WILC_memset(&strConnectInfo
, 0, sizeof(tstrConnectInfo
));
1977 if (pstrHostIFconnectAttr
->pfConnectResult
!= NULL
) {
1978 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
)
1979 WILC_memcpy(strConnectInfo
.au8bssid
, pstrHostIFconnectAttr
->pu8bssid
, 6);
1981 if (pstrHostIFconnectAttr
->pu8IEs
!= NULL
) {
1982 strConnectInfo
.ReqIEsLen
= pstrHostIFconnectAttr
->IEsLen
;
1983 strConnectInfo
.pu8ReqIEs
= (u8
*)WILC_MALLOC(pstrHostIFconnectAttr
->IEsLen
);
1984 WILC_memcpy(strConnectInfo
.pu8ReqIEs
,
1985 pstrHostIFconnectAttr
->pu8IEs
,
1986 pstrHostIFconnectAttr
->IEsLen
);
1989 pstrHostIFconnectAttr
->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP
,
1993 pstrHostIFconnectAttr
->pvUserArg
);
1994 /*Change state to idle*/
1995 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
1997 if (strConnectInfo
.pu8ReqIEs
!= NULL
) {
1998 WILC_FREE(strConnectInfo
.pu8ReqIEs
);
1999 strConnectInfo
.pu8ReqIEs
= NULL
;
2003 PRINT_ER("Connect callback function pointer is NULL\n");
2007 PRINT_D(HOSTINF_DBG
, "Deallocating connection parameters\n");
2008 /* Deallocate pstrHostIFconnectAttr->pu8bssid which was prevoisuly allocated by the sending thread */
2009 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
) {
2010 WILC_FREE(pstrHostIFconnectAttr
->pu8bssid
);
2011 pstrHostIFconnectAttr
->pu8bssid
= NULL
;
2014 /* Deallocate pstrHostIFconnectAttr->pu8ssid which was prevoisuly allocated by the sending thread */
2015 if (pstrHostIFconnectAttr
->pu8ssid
!= NULL
) {
2016 WILC_FREE(pstrHostIFconnectAttr
->pu8ssid
);
2017 pstrHostIFconnectAttr
->pu8ssid
= NULL
;
2020 /* Deallocate pstrHostIFconnectAttr->pu8IEs which was prevoisuly allocated by the sending thread */
2021 if (pstrHostIFconnectAttr
->pu8IEs
!= NULL
) {
2022 WILC_FREE(pstrHostIFconnectAttr
->pu8IEs
);
2023 pstrHostIFconnectAttr
->pu8IEs
= NULL
;
2026 if (pu8CurrByte
!= NULL
)
2027 WILC_FREE(pu8CurrByte
);
2032 * @brief Handle_FlushConnect
2033 * @details Sending config packet to firmware to flush an old connection
2034 * after switching FW from station one to hybrid one
2035 * @param[in] void * drvHandler
2036 * @return Error code.
2037 * @author Amr Abdel-Moghny
2042 static s32
Handle_FlushConnect(void *drvHandler
)
2044 s32 s32Error
= WILC_SUCCESS
;
2045 tstrWID strWIDList
[5];
2046 u32 u32WidsCount
= 0;
2047 u8
*pu8CurrByte
= NULL
;
2050 /* IEs to be inserted in Association Request */
2051 strWIDList
[u32WidsCount
].u16WIDid
= WID_INFO_ELEMENT_ASSOCIATE
;
2052 strWIDList
[u32WidsCount
].enuWIDtype
= WID_BIN_DATA
;
2053 strWIDList
[u32WidsCount
].ps8WidVal
= gu8FlushedInfoElemAsoc
;
2054 strWIDList
[u32WidsCount
].s32ValueSize
= gu32FlushedInfoElemAsocSize
;
2057 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_11I_MODE
;
2058 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
2059 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
2060 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(gu8Flushed11iMode
));
2065 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_AUTH_TYPE
;
2066 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
2067 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
2068 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&gu8FlushedAuthType
);
2072 #ifdef WILC_PARSE_SCAN_IN_HOST
2073 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_JOIN_REQ_EXTENDED
;
2074 strWIDList
[u32WidsCount
].enuWIDtype
= WID_STR
;
2075 strWIDList
[u32WidsCount
].s32ValueSize
= gu32FlushedJoinReqSize
;
2076 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)gu8FlushedJoinReq
;
2077 pu8CurrByte
= strWIDList
[u32WidsCount
].ps8WidVal
;
2079 pu8CurrByte
+= FLUSHED_BYTE_POS
;
2080 *(pu8CurrByte
) = FLUSHED_JOIN_REQ
;
2086 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, u32WidsCount
, false, gu8FlushedJoinReqDrvHandler
);
2088 PRINT_ER("Handle_Flush_Connect()] failed to send config packet\n");
2089 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
2092 WILC_CATCH(s32Error
)
2101 * @brief Handle_ConnectTimeout
2102 * @details Call connect notification callback function indicating connection failure
2104 * @return Error code.
2109 static s32
Handle_ConnectTimeout(void *drvHandler
)
2111 s32 s32Error
= WILC_SUCCESS
;
2112 tstrConnectInfo strConnectInfo
;
2114 u16 u16DummyReasonCode
= 0;
2115 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*) drvHandler
;
2117 if (pstrWFIDrv
== NULL
) {
2118 PRINT_ER("Driver handler is NULL\n");
2122 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
2124 gbScanWhileConnected
= false;
2127 WILC_memset(&strConnectInfo
, 0, sizeof(tstrConnectInfo
));
2130 /* First, we will notify the upper layer with the Connection failure {through the Connect Callback function},
2131 * then we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2132 * WID_DISCONNECT} */
2133 if (pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
!= NULL
) {
2134 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
!= NULL
) {
2135 WILC_memcpy(strConnectInfo
.au8bssid
,
2136 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
, 6);
2139 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
!= NULL
) {
2140 strConnectInfo
.ReqIEsLen
= pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
;
2141 strConnectInfo
.pu8ReqIEs
= (u8
*)WILC_MALLOC(pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
);
2142 WILC_memcpy(strConnectInfo
.pu8ReqIEs
,
2143 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
,
2144 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
);
2147 pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP
,
2151 pstrWFIDrv
->strWILC_UsrConnReq
.u32UserConnectPvoid
);
2153 /* Deallocation of strConnectInfo.pu8ReqIEs */
2154 if (strConnectInfo
.pu8ReqIEs
!= NULL
) {
2155 WILC_FREE(strConnectInfo
.pu8ReqIEs
);
2156 strConnectInfo
.pu8ReqIEs
= NULL
;
2159 PRINT_ER("Connect callback function pointer is NULL\n");
2162 /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2163 * WID_DISCONNECT} */
2164 strWID
.u16WIDid
= (u16
)WID_DISCONNECT
;
2165 strWID
.enuWIDtype
= WID_CHAR
;
2166 strWID
.ps8WidVal
= (s8
*)&u16DummyReasonCode
;
2167 strWID
.s32ValueSize
= sizeof(char);
2169 PRINT_D(HOSTINF_DBG
, "Sending disconnect request\n");
2171 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false, (u32
)pstrWFIDrv
);
2173 PRINT_ER("Failed to send dissconect config packet\n");
2175 /* Deallocation of the Saved Connect Request in the global Handle */
2176 pstrWFIDrv
->strWILC_UsrConnReq
.ssidLen
= 0;
2177 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
!= NULL
) {
2178 WILC_FREE(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
);
2179 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
= NULL
;
2182 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
!= NULL
) {
2183 WILC_FREE(pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
);
2184 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
= NULL
;
2187 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
= 0;
2188 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
!= NULL
) {
2189 WILC_FREE(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
);
2190 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
= NULL
;
2193 WILC_memset(u8ConnectedSSID
, 0, ETH_ALEN
);
2195 /*Freeing flushed join request params on connect timeout*/
2196 if (gu8FlushedJoinReq
!= NULL
&& gu8FlushedJoinReqDrvHandler
== (u32
)drvHandler
) {
2197 WILC_FREE(gu8FlushedJoinReq
);
2198 gu8FlushedJoinReq
= NULL
;
2200 if (gu8FlushedInfoElemAsoc
!= NULL
&& gu8FlushedJoinReqDrvHandler
== (u32
)drvHandler
) {
2201 WILC_FREE(gu8FlushedInfoElemAsoc
);
2202 gu8FlushedInfoElemAsoc
= NULL
;
2209 * @brief Handle_RcvdNtwrkInfo
2210 * @details Handling received network information
2211 * @param[in] tstrRcvdNetworkInfo* pstrRcvdNetworkInfo
2212 * @return Error code.
2217 static s32
Handle_RcvdNtwrkInfo(void *drvHandler
, tstrRcvdNetworkInfo
*pstrRcvdNetworkInfo
)
2220 bool bNewNtwrkFound
;
2224 s32 s32Error
= WILC_SUCCESS
;
2225 tstrNetworkInfo
*pstrNetworkInfo
= NULL
;
2226 void *pJoinParams
= NULL
;
2228 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
2232 bNewNtwrkFound
= true;
2233 PRINT_INFO(HOSTINF_DBG
, "Handling received network info\n");
2235 /*if there is a an ongoing scan request*/
2236 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
2237 PRINT_D(HOSTINF_DBG
, "State: Scanning, parsing network information received\n");
2238 ParseNetworkInfo(pstrRcvdNetworkInfo
->pu8Buffer
, &pstrNetworkInfo
);
2239 if ((pstrNetworkInfo
== NULL
)
2240 || (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
== NULL
)) {
2241 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
2244 /* check whether this network is discovered before */
2245 for (i
= 0; i
< pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
; i
++) {
2247 if ((pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[i
].au8bssid
!= NULL
) &&
2248 (pstrNetworkInfo
->au8bssid
!= NULL
)) {
2249 if (WILC_memcmp(pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[i
].au8bssid
,
2250 pstrNetworkInfo
->au8bssid
, 6) == 0) {
2251 if (pstrNetworkInfo
->s8rssi
<= pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[i
].s8rssi
) {
2252 /*we have already found this network with better rssi, so keep the old cached one and don't
2253 * send anything to the upper layer */
2254 PRINT_D(HOSTINF_DBG
, "Network previously discovered\n");
2257 /* here the same already found network is found again but with a better rssi, so just update
2258 * the rssi for this cached network and send this updated network to the upper layer but
2259 * don't add a new record for it */
2260 pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[i
].s8rssi
= pstrNetworkInfo
->s8rssi
;
2261 bNewNtwrkFound
= false;
2268 if (bNewNtwrkFound
== true) {
2269 /* here it is confirmed that it is a new discovered network,
2270 * so add its record then call the User CallBack function */
2272 PRINT_D(HOSTINF_DBG
, "New network found\n");
2274 if (pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
< MAX_NUM_SCANNED_NETWORKS
) {
2275 pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
].s8rssi
= pstrNetworkInfo
->s8rssi
;
2277 if ((pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
].au8bssid
!= NULL
)
2278 && (pstrNetworkInfo
->au8bssid
!= NULL
)) {
2279 WILC_memcpy(pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
].au8bssid
,
2280 pstrNetworkInfo
->au8bssid
, 6);
2282 pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
++;
2284 pstrNetworkInfo
->bNewNetwork
= true;
2285 /*Bug4218: Parsing Join Param*/
2286 /* add new BSS to JoinBssTable */
2287 #ifdef WILC_PARSE_SCAN_IN_HOST
2288 pJoinParams
= host_int_ParseJoinBssParam(pstrNetworkInfo
);
2289 #endif /*WILC_PARSE_SCAN_IN_HOST*/
2291 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND
, pstrNetworkInfo
,
2292 pstrWFIDrv
->strWILC_UsrScanReq
.u32UserScanPvoid
,
2298 PRINT_WRN(HOSTINF_DBG
, "Discovered networks exceeded max. limit\n");
2301 pstrNetworkInfo
->bNewNetwork
= false;
2302 /* just call the User CallBack function to send the same discovered network with its updated RSSI */
2303 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND
, pstrNetworkInfo
,
2304 pstrWFIDrv
->strWILC_UsrScanReq
.u32UserScanPvoid
, NULL
);
2309 WILC_CATCH(s32Error
)
2315 /* Deallocate pstrRcvdNetworkInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2316 if (pstrRcvdNetworkInfo
->pu8Buffer
!= NULL
) {
2317 WILC_FREE(pstrRcvdNetworkInfo
->pu8Buffer
);
2318 pstrRcvdNetworkInfo
->pu8Buffer
= NULL
;
2321 /*free structure allocated*/
2322 if (pstrNetworkInfo
!= NULL
) {
2323 DeallocateNetworkInfo(pstrNetworkInfo
);
2324 pstrNetworkInfo
= NULL
;
2331 * @brief Handle_RcvdGnrlAsyncInfo
2332 * @details Handling received asynchrous general network information
2333 * @param[in] tstrRcvdGnrlAsyncInfo* pstrRcvdGnrlAsyncInfo
2334 * @return Error code.
2339 static s32
Handle_RcvdGnrlAsyncInfo(void *drvHandler
, tstrRcvdGnrlAsyncInfo
*pstrRcvdGnrlAsyncInfo
)
2341 /* TODO: mostafa: till now, this function just handles only the received mac status msg, */
2342 /* which carries only 1 WID which have WID ID = WID_STATUS */
2343 s32 s32Error
= WILC_SUCCESS
;
2347 u16 u16WidID
= (u16
)WID_NIL
;
2350 u8 u8MacStatusReasonCode
;
2351 u8 u8MacStatusAdditionalInfo
;
2352 tstrConnectInfo strConnectInfo
;
2353 tstrDisconnectNotifInfo strDisconnectNotifInfo
;
2354 s32 s32Err
= WILC_SUCCESS
;
2355 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*) drvHandler
;
2357 if (pstrWFIDrv
== NULL
)
2358 PRINT_ER("Driver handler is NULL\n");
2359 PRINT_D(GENERIC_DBG
, "Current State = %d,Received state = %d\n", pstrWFIDrv
->enuHostIFstate
,
2360 pstrRcvdGnrlAsyncInfo
->pu8Buffer
[7]);
2362 if ((pstrWFIDrv
->enuHostIFstate
== HOST_IF_WAITING_CONN_RESP
) ||
2363 (pstrWFIDrv
->enuHostIFstate
== HOST_IF_CONNECTED
) ||
2364 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
2365 if ((pstrRcvdGnrlAsyncInfo
->pu8Buffer
== NULL
) ||
2366 (pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
== NULL
)) {
2367 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
2370 u8MsgType
= pstrRcvdGnrlAsyncInfo
->pu8Buffer
[0];
2372 /* Check whether the received message type is 'I' */
2373 if ('I' != u8MsgType
) {
2374 PRINT_ER("Received Message format incorrect.\n");
2375 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
2378 /* Extract message ID */
2379 u8MsgID
= pstrRcvdGnrlAsyncInfo
->pu8Buffer
[1];
2381 /* Extract message Length */
2382 u16MsgLen
= MAKE_WORD16(pstrRcvdGnrlAsyncInfo
->pu8Buffer
[2], pstrRcvdGnrlAsyncInfo
->pu8Buffer
[3]);
2384 /* Extract WID ID [expected to be = WID_STATUS] */
2385 u16WidID
= MAKE_WORD16(pstrRcvdGnrlAsyncInfo
->pu8Buffer
[4], pstrRcvdGnrlAsyncInfo
->pu8Buffer
[5]);
2387 /* Extract WID Length [expected to be = 1] */
2388 u8WidLen
= pstrRcvdGnrlAsyncInfo
->pu8Buffer
[6];
2390 /* get the WID value [expected to be one of two values: either MAC_CONNECTED = (1) or MAC_DISCONNECTED = (0)] */
2391 u8MacStatus
= pstrRcvdGnrlAsyncInfo
->pu8Buffer
[7];
2392 u8MacStatusReasonCode
= pstrRcvdGnrlAsyncInfo
->pu8Buffer
[8];
2393 u8MacStatusAdditionalInfo
= pstrRcvdGnrlAsyncInfo
->pu8Buffer
[9];
2394 PRINT_INFO(HOSTINF_DBG
, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus
, u8MacStatusReasonCode
, u8MacStatusAdditionalInfo
);
2395 if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_WAITING_CONN_RESP
) {
2396 /* our station had sent Association Request frame, so here it will get the Association Response frame then parse it */
2397 u32 u32RcvdAssocRespInfoLen
;
2398 tstrConnectRespInfo
*pstrConnectRespInfo
= NULL
;
2400 PRINT_D(HOSTINF_DBG
, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus
, u8MacStatusReasonCode
, u8MacStatusAdditionalInfo
);
2402 WILC_memset(&strConnectInfo
, 0, sizeof(tstrConnectInfo
));
2404 if (u8MacStatus
== MAC_CONNECTED
) {
2405 WILC_memset(gapu8RcvdAssocResp
, 0, MAX_ASSOC_RESP_FRAME_SIZE
);
2407 host_int_get_assoc_res_info((WILC_WFIDrvHandle
)pstrWFIDrv
,
2409 MAX_ASSOC_RESP_FRAME_SIZE
,
2410 &u32RcvdAssocRespInfoLen
);
2412 PRINT_INFO(HOSTINF_DBG
, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen
);
2414 if (u32RcvdAssocRespInfoLen
!= 0) {
2416 PRINT_D(HOSTINF_DBG
, "Parsing association response\n");
2417 s32Err
= ParseAssocRespInfo(gapu8RcvdAssocResp
, u32RcvdAssocRespInfoLen
,
2418 &pstrConnectRespInfo
);
2420 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err
);
2422 /* use the necessary parsed Info from the Received Association Response */
2423 strConnectInfo
.u16ConnectStatus
= pstrConnectRespInfo
->u16ConnectStatus
;
2425 if (strConnectInfo
.u16ConnectStatus
== SUCCESSFUL_STATUSCODE
) {
2426 PRINT_INFO(HOSTINF_DBG
, "Association response received : Successful connection status\n");
2427 if (pstrConnectRespInfo
->pu8RespIEs
!= NULL
) {
2428 strConnectInfo
.u16RespIEsLen
= pstrConnectRespInfo
->u16RespIEsLen
;
2431 strConnectInfo
.pu8RespIEs
= (u8
*)WILC_MALLOC(pstrConnectRespInfo
->u16RespIEsLen
);
2432 WILC_memcpy(strConnectInfo
.pu8RespIEs
, pstrConnectRespInfo
->pu8RespIEs
,
2433 pstrConnectRespInfo
->u16RespIEsLen
);
2437 /* deallocate the Assoc. Resp. parsed structure as it is not needed anymore */
2438 if (pstrConnectRespInfo
!= NULL
) {
2439 DeallocateAssocRespInfo(pstrConnectRespInfo
);
2440 pstrConnectRespInfo
= NULL
;
2446 /* The station has just received mac status and it also received assoc. response which
2447 * it was waiting for.
2448 * So check first the matching between the received mac status and the received status code in Asoc Resp */
2449 if ((u8MacStatus
== MAC_CONNECTED
) &&
2450 (strConnectInfo
.u16ConnectStatus
!= SUCCESSFUL_STATUSCODE
)) {
2451 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
2452 WILC_memset(u8ConnectedSSID
, 0, ETH_ALEN
);
2454 } else if (u8MacStatus
== MAC_DISCONNECTED
) {
2455 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
2456 WILC_memset(u8ConnectedSSID
, 0, ETH_ALEN
);
2459 /* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */
2460 /* through a structure of type tstrConnectRespInfo */
2461 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
!= NULL
) {
2462 PRINT_D(HOSTINF_DBG
, "Retrieving actual BSSID from AP\n");
2463 WILC_memcpy(strConnectInfo
.au8bssid
, pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
, 6);
2465 if ((u8MacStatus
== MAC_CONNECTED
) &&
2466 (strConnectInfo
.u16ConnectStatus
== SUCCESSFUL_STATUSCODE
)) {
2467 WILC_memcpy(pstrWFIDrv
->au8AssociatedBSSID
,
2468 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
, ETH_ALEN
);
2473 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
!= NULL
) {
2474 strConnectInfo
.ReqIEsLen
= pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
;
2475 strConnectInfo
.pu8ReqIEs
= (u8
*)WILC_MALLOC(pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
);
2476 WILC_memcpy(strConnectInfo
.pu8ReqIEs
,
2477 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
,
2478 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
);
2482 WILC_TimerStop(&(pstrWFIDrv
->hConnectTimer
), NULL
);
2483 pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP
,
2487 pstrWFIDrv
->strWILC_UsrConnReq
.u32UserConnectPvoid
);
2490 /* if received mac status is MAC_CONNECTED and
2491 * received status code in Asoc Resp is SUCCESSFUL_STATUSCODE, change state to CONNECTED
2492 * else change state to IDLE */
2493 if ((u8MacStatus
== MAC_CONNECTED
) &&
2494 (strConnectInfo
.u16ConnectStatus
== SUCCESSFUL_STATUSCODE
)) {
2495 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2497 host_int_set_power_mgmt((WILC_WFIDrvHandle
)pstrWFIDrv
, 0, 0);
2500 PRINT_D(HOSTINF_DBG
, "MAC status : CONNECTED and Connect Status : Successful\n");
2501 pstrWFIDrv
->enuHostIFstate
= HOST_IF_CONNECTED
;
2503 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2504 PRINT_D(GENERIC_DBG
, "Obtaining an IP, Disable Scan\n");
2505 g_obtainingIP
= true;
2506 WILC_TimerStart(&hDuringIpTimer
, 10000, NULL
, NULL
);
2509 #ifdef WILC_PARSE_SCAN_IN_HOST
2510 /* open a BA session if possible */
2511 /* if(pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable) */
2515 /* host_int_addBASession(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid,0, */
2516 /* BA_SESSION_DEFAULT_BUFFER_SIZE,BA_SESSION_DEFAULT_TIMEOUT); */
2518 PRINT_D(HOSTINF_DBG
, "MAC status : %d and Connect Status : %d\n", u8MacStatus
, strConnectInfo
.u16ConnectStatus
);
2519 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
2520 gbScanWhileConnected
= false;
2524 if (strConnectInfo
.pu8RespIEs
!= NULL
) {
2525 WILC_FREE(strConnectInfo
.pu8RespIEs
);
2526 strConnectInfo
.pu8RespIEs
= NULL
;
2529 if (strConnectInfo
.pu8ReqIEs
!= NULL
) {
2530 WILC_FREE(strConnectInfo
.pu8ReqIEs
);
2531 strConnectInfo
.pu8ReqIEs
= NULL
;
2535 pstrWFIDrv
->strWILC_UsrConnReq
.ssidLen
= 0;
2536 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
!= NULL
) {
2537 WILC_FREE(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
);
2538 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
= NULL
;
2541 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
!= NULL
) {
2542 WILC_FREE(pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
);
2543 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
= NULL
;
2546 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
= 0;
2547 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
!= NULL
) {
2548 WILC_FREE(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
);
2549 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
= NULL
;
2552 } else if ((u8MacStatus
== MAC_DISCONNECTED
) &&
2553 (pstrWFIDrv
->enuHostIFstate
== HOST_IF_CONNECTED
)) {
2554 /* Disassociation or Deauthentication frame has been received */
2555 PRINT_D(HOSTINF_DBG
, "Received MAC_DISCONNECTED from the FW\n");
2557 WILC_memset(&strDisconnectNotifInfo
, 0, sizeof(tstrDisconnectNotifInfo
));
2559 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
2560 PRINT_D(HOSTINF_DBG
, "\n\n<< Abort the running OBSS Scan >>\n\n");
2561 WILC_TimerStop(&(pstrWFIDrv
->hScanTimer
), NULL
);
2562 Handle_ScanDone((void *)pstrWFIDrv
, SCAN_EVENT_ABORTED
);
2565 strDisconnectNotifInfo
.u16reason
= 0;
2566 strDisconnectNotifInfo
.ie
= NULL
;
2567 strDisconnectNotifInfo
.ie_len
= 0;
2569 if (pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
!= NULL
) {
2570 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2572 g_obtainingIP
= false;
2573 host_int_set_power_mgmt((WILC_WFIDrvHandle
)pstrWFIDrv
, 0, 0);
2576 pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF
,
2579 &strDisconnectNotifInfo
,
2580 pstrWFIDrv
->strWILC_UsrConnReq
.u32UserConnectPvoid
);
2583 PRINT_ER("Connect result callback function is NULL\n");
2586 WILC_memset(pstrWFIDrv
->au8AssociatedBSSID
, 0, ETH_ALEN
);
2591 /* if Information Elements were retrieved from the Received deauth/disassoc frame, then they
2592 * should be deallocated here */
2594 * if(strDisconnectNotifInfo.ie != NULL)
2596 * WILC_FREE(strDisconnectNotifInfo.ie);
2597 * strDisconnectNotifInfo.ie = NULL;
2601 pstrWFIDrv
->strWILC_UsrConnReq
.ssidLen
= 0;
2602 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
!= NULL
) {
2603 WILC_FREE(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
);
2604 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
= NULL
;
2607 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
!= NULL
) {
2608 WILC_FREE(pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
);
2609 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
= NULL
;
2612 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
= 0;
2613 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
!= NULL
) {
2614 WILC_FREE(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
);
2615 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
= NULL
;
2619 /*Freeing flushed join request params on receiving*/
2620 /*MAC_DISCONNECTED while connected*/
2621 if (gu8FlushedJoinReq
!= NULL
&& gu8FlushedJoinReqDrvHandler
== (u32
)drvHandler
) {
2622 WILC_FREE(gu8FlushedJoinReq
);
2623 gu8FlushedJoinReq
= NULL
;
2625 if (gu8FlushedInfoElemAsoc
!= NULL
&& gu8FlushedJoinReqDrvHandler
== (u32
)drvHandler
) {
2626 WILC_FREE(gu8FlushedInfoElemAsoc
);
2627 gu8FlushedInfoElemAsoc
= NULL
;
2630 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
2631 gbScanWhileConnected
= false;
2633 } else if ((u8MacStatus
== MAC_DISCONNECTED
) &&
2634 (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
!= NULL
)) {
2635 PRINT_D(HOSTINF_DBG
, "Received MAC_DISCONNECTED from the FW while scanning\n");
2636 PRINT_D(HOSTINF_DBG
, "\n\n<< Abort the running Scan >>\n\n");
2637 /*Abort the running scan*/
2638 WILC_TimerStop(&(pstrWFIDrv
->hScanTimer
), NULL
);
2639 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
)
2640 Handle_ScanDone((void *)pstrWFIDrv
, SCAN_EVENT_ABORTED
);
2646 WILC_CATCH(s32Error
)
2651 /* Deallocate pstrRcvdGnrlAsyncInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2652 if (pstrRcvdGnrlAsyncInfo
->pu8Buffer
!= NULL
) {
2653 WILC_FREE(pstrRcvdGnrlAsyncInfo
->pu8Buffer
);
2654 pstrRcvdGnrlAsyncInfo
->pu8Buffer
= NULL
;
2662 * @details Sending config packet to firmware to set key
2663 * @param[in] tstrHostIFkeyAttr* pstrHostIFkeyAttr
2664 * @return Error code.
2669 static int Handle_Key(void *drvHandler
, tstrHostIFkeyAttr
*pstrHostIFkeyAttr
)
2671 s32 s32Error
= WILC_SUCCESS
;
2673 #ifdef WILC_AP_EXTERNAL_MLME
2674 tstrWID strWIDList
[5];
2680 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
2683 switch (pstrHostIFkeyAttr
->enuKeyType
) {
2688 #ifdef WILC_AP_EXTERNAL_MLME
2689 if (pstrHostIFkeyAttr
->u8KeyAction
& ADDKEY_AP
) {
2691 PRINT_D(HOSTINF_DBG
, "Handling WEP key\n");
2692 PRINT_D(GENERIC_DBG
, "ID Hostint is %d\n", (pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
));
2693 strWIDList
[0].u16WIDid
= (u16
)WID_11I_MODE
;
2694 strWIDList
[0].enuWIDtype
= WID_CHAR
;
2695 strWIDList
[0].s32ValueSize
= sizeof(char);
2696 strWIDList
[0].ps8WidVal
= (s8
*)(&(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8mode
));
2698 strWIDList
[1].u16WIDid
= WID_AUTH_TYPE
;
2699 strWIDList
[1].enuWIDtype
= WID_CHAR
;
2700 strWIDList
[1].s32ValueSize
= sizeof(char);
2701 strWIDList
[1].ps8WidVal
= (s8
*)(&(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.tenuAuth_type
));
2703 strWIDList
[2].u16WIDid
= (u16
)WID_KEY_ID
;
2704 strWIDList
[2].enuWIDtype
= WID_CHAR
;
2706 strWIDList
[2].ps8WidVal
= (s8
*)(&(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
));
2707 strWIDList
[2].s32ValueSize
= sizeof(char);
2710 pu8keybuf
= (u8
*)WILC_MALLOC(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
);
2713 if (pu8keybuf
== NULL
) {
2714 PRINT_ER("No buffer to send Key\n");
2718 WILC_memcpy(pu8keybuf
, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
,
2719 pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
);
2722 WILC_FREE(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
);
2724 strWIDList
[3].u16WIDid
= (u16
)WID_WEP_KEY_VALUE
;
2725 strWIDList
[3].enuWIDtype
= WID_STR
;
2726 strWIDList
[3].s32ValueSize
= pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
;
2727 strWIDList
[3].ps8WidVal
= (s8
*)pu8keybuf
;
2730 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, 4, true, (u32
)pstrWFIDrv
);
2731 WILC_FREE(pu8keybuf
);
2737 if (pstrHostIFkeyAttr
->u8KeyAction
& ADDKEY
) {
2738 PRINT_D(HOSTINF_DBG
, "Handling WEP key\n");
2739 pu8keybuf
= (u8
*)WILC_MALLOC(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
+ 2);
2740 if (pu8keybuf
== NULL
) {
2741 PRINT_ER("No buffer to send Key\n");
2744 pu8keybuf
[0] = pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
;
2746 WILC_memcpy(pu8keybuf
+ 1, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
, 1);
2748 WILC_memcpy(pu8keybuf
+ 2, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
,
2749 pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
);
2751 WILC_FREE(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
);
2753 strWID
.u16WIDid
= (u16
)WID_ADD_WEP_KEY
;
2754 strWID
.enuWIDtype
= WID_STR
;
2755 strWID
.ps8WidVal
= (s8
*)pu8keybuf
;
2756 strWID
.s32ValueSize
= pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
+ 2;
2758 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
2759 WILC_FREE(pu8keybuf
);
2760 } else if (pstrHostIFkeyAttr
->u8KeyAction
& REMOVEKEY
) {
2762 PRINT_D(HOSTINF_DBG
, "Removing key\n");
2763 strWID
.u16WIDid
= (u16
)WID_REMOVE_WEP_KEY
;
2764 strWID
.enuWIDtype
= WID_STR
;
2766 s8idxarray
[0] = (s8
)pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
;
2767 strWID
.ps8WidVal
= s8idxarray
;
2768 strWID
.s32ValueSize
= 1;
2770 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
2772 strWID
.u16WIDid
= (u16
)WID_KEY_ID
;
2773 strWID
.enuWIDtype
= WID_CHAR
;
2774 strWID
.ps8WidVal
= (s8
*)(&(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
));
2775 strWID
.s32ValueSize
= sizeof(char);
2777 PRINT_D(HOSTINF_DBG
, "Setting default key index\n");
2779 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
2781 up(&(pstrWFIDrv
->hSemTestKeyBlock
));
2785 #ifdef WILC_AP_EXTERNAL_MLME
2786 if (pstrHostIFkeyAttr
->u8KeyAction
& ADDKEY_AP
) {
2787 pu8keybuf
= (u8
*)WILC_MALLOC(RX_MIC_KEY_MSG_LEN
);
2788 if (pu8keybuf
== NULL
) {
2789 PRINT_ER("No buffer to send RxGTK Key\n");
2791 goto _WPARxGtk_end_case_
;
2794 WILC_memset(pu8keybuf
, 0, RX_MIC_KEY_MSG_LEN
);
2797 /*|----------------------------------------------------------------------------|
2798 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2799 * |------------|---------|-------|------------|---------------|----------------|
2800 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2804 if (pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8seq
!= NULL
)
2805 WILC_memcpy(pu8keybuf
+ 6, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8seq
, 8);
2808 WILC_memcpy(pu8keybuf
+ 14, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8keyidx
, 1);
2810 WILC_memcpy(pu8keybuf
+ 15, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
, 1);
2812 WILC_memcpy(pu8keybuf
+ 16, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
,
2813 pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
);
2814 /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */
2815 strWIDList
[0].u16WIDid
= (u16
)WID_11I_MODE
;
2816 strWIDList
[0].enuWIDtype
= WID_CHAR
;
2817 strWIDList
[0].s32ValueSize
= sizeof(char);
2818 strWIDList
[0].ps8WidVal
= (s8
*)(&(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Ciphermode
));
2820 strWIDList
[1].u16WIDid
= (u16
)WID_ADD_RX_GTK
;
2821 strWIDList
[1].enuWIDtype
= WID_STR
;
2822 strWIDList
[1].ps8WidVal
= (s8
*)pu8keybuf
;
2823 strWIDList
[1].s32ValueSize
= RX_MIC_KEY_MSG_LEN
;
2825 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, 2, true, (u32
)pstrWFIDrv
);
2827 WILC_FREE(pu8keybuf
);
2829 /* ////////////////////////// */
2830 up(&(pstrWFIDrv
->hSemTestKeyBlock
));
2831 /* ///////////////////////// */
2835 if (pstrHostIFkeyAttr
->u8KeyAction
& ADDKEY
) {
2836 PRINT_D(HOSTINF_DBG
, "Handling group key(Rx) function\n");
2838 pu8keybuf
= (u8
*)WILC_MALLOC(RX_MIC_KEY_MSG_LEN
);
2839 if (pu8keybuf
== NULL
) {
2840 PRINT_ER("No buffer to send RxGTK Key\n");
2842 goto _WPARxGtk_end_case_
;
2845 WILC_memset(pu8keybuf
, 0, RX_MIC_KEY_MSG_LEN
);
2848 /*|----------------------------------------------------------------------------|
2849 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2850 * |------------|---------|-------|------------|---------------|----------------|
2851 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2853 if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_CONNECTED
) {
2854 WILC_memcpy(pu8keybuf
, pstrWFIDrv
->au8AssociatedBSSID
, ETH_ALEN
);
2856 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
2859 WILC_memcpy(pu8keybuf
+ 6, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8seq
, 8);
2861 WILC_memcpy(pu8keybuf
+ 14, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8keyidx
, 1);
2863 WILC_memcpy(pu8keybuf
+ 15, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
, 1);
2864 WILC_memcpy(pu8keybuf
+ 16, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
,
2865 pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
);
2867 strWID
.u16WIDid
= (u16
)WID_ADD_RX_GTK
;
2868 strWID
.enuWIDtype
= WID_STR
;
2869 strWID
.ps8WidVal
= (s8
*)pu8keybuf
;
2870 strWID
.s32ValueSize
= RX_MIC_KEY_MSG_LEN
;
2872 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
2874 WILC_FREE(pu8keybuf
);
2876 /* ////////////////////////// */
2877 up(&(pstrWFIDrv
->hSemTestKeyBlock
));
2878 /* ///////////////////////// */
2880 _WPARxGtk_end_case_
:
2881 WILC_FREE(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
);
2882 WILC_FREE(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8seq
);
2889 #ifdef WILC_AP_EXTERNAL_MLME
2890 if (pstrHostIFkeyAttr
->u8KeyAction
& ADDKEY_AP
) {
2893 pu8keybuf
= (u8
*)WILC_MALLOC(PTK_KEY_MSG_LEN
+ 1);
2897 if (pu8keybuf
== NULL
) {
2898 PRINT_ER("No buffer to send PTK Key\n");
2900 goto _WPAPtk_end_case_
;
2904 /*|-----------------------------------------------------------------------------|
2905 * |Station address | keyidx |Key Length |Temporal Key | Rx Michael Key |Tx Michael Key |
2906 * |----------------|------------ |--------------|----------------|---------------|
2907 | 6 bytes | 1 byte | 1byte | 16 bytes | 8 bytes | 8 bytes |
2908 |-----------------------------------------------------------------------------|*/
2910 WILC_memcpy(pu8keybuf
, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8macaddr
, 6); /*1 bytes Key Length */
2912 WILC_memcpy(pu8keybuf
+ 6, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8keyidx
, 1);
2913 WILC_memcpy(pu8keybuf
+ 7, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
, 1);
2915 WILC_memcpy(pu8keybuf
+ 8, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
,
2916 pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
);
2919 strWIDList
[0].u16WIDid
= (u16
)WID_11I_MODE
;
2920 strWIDList
[0].enuWIDtype
= WID_CHAR
;
2921 strWIDList
[0].s32ValueSize
= sizeof(char);
2922 strWIDList
[0].ps8WidVal
= (s8
*)(&(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Ciphermode
));
2924 strWIDList
[1].u16WIDid
= (u16
)WID_ADD_PTK
;
2925 strWIDList
[1].enuWIDtype
= WID_STR
;
2926 strWIDList
[1].ps8WidVal
= (s8
*)pu8keybuf
;
2927 strWIDList
[1].s32ValueSize
= PTK_KEY_MSG_LEN
+ 1;
2929 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, 2, true, (u32
)pstrWFIDrv
);
2930 WILC_FREE(pu8keybuf
);
2932 /* ////////////////////////// */
2933 up(&(pstrWFIDrv
->hSemTestKeyBlock
));
2934 /* ///////////////////////// */
2937 if (pstrHostIFkeyAttr
->u8KeyAction
& ADDKEY
) {
2940 pu8keybuf
= (u8
*)WILC_MALLOC(PTK_KEY_MSG_LEN
);
2944 if (pu8keybuf
== NULL
) {
2945 PRINT_ER("No buffer to send PTK Key\n");
2947 goto _WPAPtk_end_case_
;
2951 /*|-----------------------------------------------------------------------------|
2952 * |Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
2953 * |----------------|------------|--------------|----------------|---------------|
2954 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
2955 |-----------------------------------------------------------------------------|*/
2957 WILC_memcpy(pu8keybuf
, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8macaddr
, 6); /*1 bytes Key Length */
2959 WILC_memcpy(pu8keybuf
+ 6, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
, 1);
2961 WILC_memcpy(pu8keybuf
+ 7, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
,
2962 pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
);
2965 strWID
.u16WIDid
= (u16
)WID_ADD_PTK
;
2966 strWID
.enuWIDtype
= WID_STR
;
2967 strWID
.ps8WidVal
= (s8
*)pu8keybuf
;
2968 strWID
.s32ValueSize
= PTK_KEY_MSG_LEN
;
2970 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
2971 WILC_FREE(pu8keybuf
);
2973 /* ////////////////////////// */
2974 up(&(pstrWFIDrv
->hSemTestKeyBlock
));
2975 /* ///////////////////////// */
2979 WILC_FREE(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
);
2988 PRINT_D(HOSTINF_DBG
, "Handling PMKSA key\n");
2990 pu8keybuf
= (u8
*)WILC_MALLOC((pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFpmkidAttr
.numpmkid
* PMKSA_KEY_LEN
) + 1);
2991 if (pu8keybuf
== NULL
) {
2992 PRINT_ER("No buffer to send PMKSA Key\n");
2996 pu8keybuf
[0] = pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFpmkidAttr
.numpmkid
;
2998 for (i
= 0; i
< pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFpmkidAttr
.numpmkid
; i
++) {
3000 WILC_memcpy(pu8keybuf
+ ((PMKSA_KEY_LEN
* i
) + 1), pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFpmkidAttr
.pmkidlist
[i
].bssid
, ETH_ALEN
);
3001 WILC_memcpy(pu8keybuf
+ ((PMKSA_KEY_LEN
* i
) + ETH_ALEN
+ 1), pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFpmkidAttr
.pmkidlist
[i
].pmkid
, PMKID_LEN
);
3004 strWID
.u16WIDid
= (u16
)WID_PMKID_INFO
;
3005 strWID
.enuWIDtype
= WID_STR
;
3006 strWID
.ps8WidVal
= (s8
*)pu8keybuf
;
3007 strWID
.s32ValueSize
= (pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFpmkidAttr
.numpmkid
* PMKSA_KEY_LEN
) + 1;
3009 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
3011 WILC_FREE(pu8keybuf
);
3016 PRINT_ER("Failed to send key config packet\n");
3024 * @brief Handle_Disconnect
3025 * @details Sending config packet to firmware to disconnect
3032 static void Handle_Disconnect(void *drvHandler
)
3036 s32 s32Error
= WILC_SUCCESS
;
3037 u16 u16DummyReasonCode
= 0;
3038 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3041 strWID
.u16WIDid
= (u16
)WID_DISCONNECT
;
3042 strWID
.enuWIDtype
= WID_CHAR
;
3043 strWID
.ps8WidVal
= (s8
*)&u16DummyReasonCode
;
3044 strWID
.s32ValueSize
= sizeof(char);
3048 PRINT_D(HOSTINF_DBG
, "Sending disconnect request\n");
3050 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3052 g_obtainingIP
= false;
3053 host_int_set_power_mgmt((WILC_WFIDrvHandle
)pstrWFIDrv
, 0, 0);
3056 WILC_memset(u8ConnectedSSID
, 0, ETH_ALEN
);
3058 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false, (u32
)pstrWFIDrv
);
3061 PRINT_ER("Failed to send dissconect config packet\n");
3062 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3064 tstrDisconnectNotifInfo strDisconnectNotifInfo
;
3066 WILC_memset(&strDisconnectNotifInfo
, 0, sizeof(tstrDisconnectNotifInfo
));
3068 strDisconnectNotifInfo
.u16reason
= 0;
3069 strDisconnectNotifInfo
.ie
= NULL
;
3070 strDisconnectNotifInfo
.ie_len
= 0;
3072 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
3073 WILC_TimerStop(&(pstrWFIDrv
->hScanTimer
), NULL
);
3074 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult(SCAN_EVENT_ABORTED
, NULL
,
3075 pstrWFIDrv
->strWILC_UsrScanReq
.u32UserScanPvoid
, NULL
);
3077 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
= NULL
;
3080 if (pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
!= NULL
) {
3083 /*Stop connect timer, if connection in progress*/
3084 if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_WAITING_CONN_RESP
) {
3085 PRINT_D(HOSTINF_DBG
, "Upper layer requested termination of connection\n");
3086 WILC_TimerStop(&(pstrWFIDrv
->hConnectTimer
), NULL
);
3089 pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF
, NULL
,
3090 0, &strDisconnectNotifInfo
, pstrWFIDrv
->strWILC_UsrConnReq
.u32UserConnectPvoid
);
3092 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
3095 gbScanWhileConnected
= false;
3097 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
3099 WILC_memset(pstrWFIDrv
->au8AssociatedBSSID
, 0, ETH_ALEN
);
3103 pstrWFIDrv
->strWILC_UsrConnReq
.ssidLen
= 0;
3104 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
!= NULL
) {
3105 WILC_FREE(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
);
3106 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
= NULL
;
3109 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
!= NULL
) {
3110 WILC_FREE(pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
);
3111 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
= NULL
;
3114 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
= 0;
3115 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
!= NULL
) {
3116 WILC_FREE(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
);
3117 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
= NULL
;
3122 if (gu8FlushedJoinReq
!= NULL
&& gu8FlushedJoinReqDrvHandler
== (u32
)drvHandler
) {
3123 WILC_FREE(gu8FlushedJoinReq
);
3124 gu8FlushedJoinReq
= NULL
;
3126 if (gu8FlushedInfoElemAsoc
!= NULL
&& gu8FlushedJoinReqDrvHandler
== (u32
)drvHandler
) {
3127 WILC_FREE(gu8FlushedInfoElemAsoc
);
3128 gu8FlushedInfoElemAsoc
= NULL
;
3133 WILC_CATCH(s32Error
)
3138 /* ////////////////////////// */
3139 up(&(pstrWFIDrv
->hSemTestDisconnectBlock
));
3140 /* ///////////////////////// */
3145 void resolve_disconnect_aberration(void *drvHandler
)
3147 tstrWILC_WFIDrv
*pstrWFIDrv
;
3149 pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3150 if (pstrWFIDrv
== NULL
)
3152 if ((pstrWFIDrv
->enuHostIFstate
== HOST_IF_WAITING_CONN_RESP
) || (pstrWFIDrv
->enuHostIFstate
== HOST_IF_CONNECTING
)) {
3153 PRINT_D(HOSTINF_DBG
, "\n\n<< correcting Supplicant state machine >>\n\n");
3154 host_int_disconnect((WILC_WFIDrvHandle
)pstrWFIDrv
, 1);
3157 static s32
Switch_Log_Terminal(void *drvHandler
)
3161 s32 s32Error
= WILC_SUCCESS
;
3163 static char dummy
= 9;
3164 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3166 strWID
.u16WIDid
= (u16
)WID_LOGTerminal_Switch
;
3167 strWID
.enuWIDtype
= WID_CHAR
;
3168 strWID
.ps8WidVal
= &dummy
;
3169 strWID
.s32ValueSize
= sizeof(char);
3171 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
3175 PRINT_D(HOSTINF_DBG
, "Failed to switch log terminal\n");
3176 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
3178 PRINT_INFO(HOSTINF_DBG
, "MAC address set ::\n");
3183 WILC_CATCH(s32Error
)
3192 * @brief Handle_GetChnl
3193 * @details Sending config packet to get channel
3201 static s32
Handle_GetChnl(void *drvHandler
)
3204 s32 s32Error
= WILC_SUCCESS
;
3206 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
3207 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3209 strWID
.u16WIDid
= (u16
)WID_CURRENT_CHANNEL
;
3210 strWID
.enuWIDtype
= WID_CHAR
;
3211 strWID
.ps8WidVal
= (s8
*)&gu8Chnl
;
3212 strWID
.s32ValueSize
= sizeof(char);
3214 PRINT_D(HOSTINF_DBG
, "Getting channel value\n");
3216 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
3217 /*get the value by searching the local copy*/
3219 PRINT_ER("Failed to get channel number\n");
3220 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3224 WILC_CATCH(s32Error
)
3228 up(&(pstrWFIDrv
->hSemGetCHNL
));
3238 * @brief Handle_GetRssi
3239 * @details Sending config packet to get RSSI
3246 static void Handle_GetRssi(void *drvHandler
)
3248 s32 s32Error
= WILC_SUCCESS
;
3250 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3252 strWID
.u16WIDid
= (u16
)WID_RSSI
;
3253 strWID
.enuWIDtype
= WID_CHAR
;
3254 strWID
.ps8WidVal
= &gs8Rssi
;
3255 strWID
.s32ValueSize
= sizeof(char);
3258 PRINT_D(HOSTINF_DBG
, "Getting RSSI value\n");
3260 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
3262 PRINT_ER("Failed to get RSSI value\n");
3263 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3266 WILC_CATCH(s32Error
)
3270 up(&(pstrWFIDrv
->hSemGetRSSI
));
3276 static void Handle_GetLinkspeed(void *drvHandler
)
3278 s32 s32Error
= WILC_SUCCESS
;
3280 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3284 strWID
.u16WIDid
= (u16
)WID_LINKSPEED
;
3285 strWID
.enuWIDtype
= WID_CHAR
;
3286 strWID
.ps8WidVal
= &gs8lnkspd
;
3287 strWID
.s32ValueSize
= sizeof(char);
3289 PRINT_D(HOSTINF_DBG
, "Getting LINKSPEED value\n");
3291 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
3293 PRINT_ER("Failed to get LINKSPEED value\n");
3294 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3297 WILC_CATCH(s32Error
)
3301 up(&(pstrWFIDrv
->hSemGetLINKSPEED
));
3306 s32
Handle_GetStatistics(void *drvHandler
, tstrStatistics
*pstrStatistics
)
3308 tstrWID strWIDList
[5];
3309 uint32_t u32WidsCount
= 0, s32Error
= 0;
3311 strWIDList
[u32WidsCount
].u16WIDid
= WID_LINKSPEED
;
3312 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
3313 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
3314 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrStatistics
->u8LinkSpeed
));
3317 strWIDList
[u32WidsCount
].u16WIDid
= WID_RSSI
;
3318 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
3319 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
3320 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrStatistics
->s8RSSI
));
3323 strWIDList
[u32WidsCount
].u16WIDid
= WID_SUCCESS_FRAME_COUNT
;
3324 strWIDList
[u32WidsCount
].enuWIDtype
= WID_INT
;
3325 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(u32
);
3326 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrStatistics
->u32TxCount
));
3329 strWIDList
[u32WidsCount
].u16WIDid
= WID_RECEIVED_FRAGMENT_COUNT
;
3330 strWIDList
[u32WidsCount
].enuWIDtype
= WID_INT
;
3331 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(u32
);
3332 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrStatistics
->u32RxCount
));
3335 strWIDList
[u32WidsCount
].u16WIDid
= WID_FAILED_COUNT
;
3336 strWIDList
[u32WidsCount
].enuWIDtype
= WID_INT
;
3337 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(u32
);
3338 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrStatistics
->u32TxFailureCount
));
3341 s32Error
= SendConfigPkt(GET_CFG
, strWIDList
, u32WidsCount
, false, (u32
)drvHandler
);
3344 PRINT_ER("Failed to send scan paramters config packet\n");
3345 /* WILC_ERRORREPORT(s32Error, s32Error); */
3353 #ifdef WILC_AP_EXTERNAL_MLME
3357 * @brief Handle_Get_InActiveTime
3358 * @details Sending config packet to set mac adddress for station and
3367 static s32
Handle_Get_InActiveTime(void *drvHandler
, tstrHostIfStaInactiveT
*strHostIfStaInactiveT
)
3370 s32 s32Error
= WILC_SUCCESS
;
3373 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3376 strWID
.u16WIDid
= (u16
)WID_SET_STA_MAC_INACTIVE_TIME
;
3377 strWID
.enuWIDtype
= WID_STR
;
3378 strWID
.s32ValueSize
= ETH_ALEN
;
3379 strWID
.ps8WidVal
= (u8
*)WILC_MALLOC(strWID
.s32ValueSize
);
3382 stamac
= strWID
.ps8WidVal
;
3383 WILC_memcpy(stamac
, strHostIfStaInactiveT
->mac
, ETH_ALEN
);
3386 PRINT_D(CFG80211_DBG
, "SETING STA inactive time\n");
3389 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
3390 /*get the value by searching the local copy*/
3392 PRINT_ER("Failed to SET incative time\n");
3393 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3397 strWID
.u16WIDid
= (u16
)WID_GET_INACTIVE_TIME
;
3398 strWID
.enuWIDtype
= WID_INT
;
3399 strWID
.ps8WidVal
= (s8
*)&gu32InactiveTime
;
3400 strWID
.s32ValueSize
= sizeof(u32
);
3403 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
3404 /*get the value by searching the local copy*/
3406 PRINT_ER("Failed to get incative time\n");
3407 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3411 PRINT_D(CFG80211_DBG
, "Getting inactive time : %d\n", gu32InactiveTime
);
3413 up(&(pstrWFIDrv
->hSemInactiveTime
));
3414 WILC_CATCH(s32Error
)
3428 * @brief Handle_AddBeacon
3429 * @details Sending config packet to add beacon
3430 * @param[in] tstrHostIFSetBeacon* pstrSetBeaconParam
3436 static void Handle_AddBeacon(void *drvHandler
, tstrHostIFSetBeacon
*pstrSetBeaconParam
)
3438 s32 s32Error
= WILC_SUCCESS
;
3441 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3443 PRINT_D(HOSTINF_DBG
, "Adding BEACON\n");
3445 strWID
.u16WIDid
= (u16
)WID_ADD_BEACON
;
3446 strWID
.enuWIDtype
= WID_BIN
;
3447 strWID
.s32ValueSize
= pstrSetBeaconParam
->u32HeadLen
+ pstrSetBeaconParam
->u32TailLen
+ 16;
3448 strWID
.ps8WidVal
= WILC_MALLOC(strWID
.s32ValueSize
);
3449 if (strWID
.ps8WidVal
== NULL
)
3450 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3452 pu8CurrByte
= strWID
.ps8WidVal
;
3453 *pu8CurrByte
++ = (pstrSetBeaconParam
->u32Interval
& 0xFF);
3454 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32Interval
>> 8) & 0xFF);
3455 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32Interval
>> 16) & 0xFF);
3456 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32Interval
>> 24) & 0xFF);
3458 *pu8CurrByte
++ = (pstrSetBeaconParam
->u32DTIMPeriod
& 0xFF);
3459 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32DTIMPeriod
>> 8) & 0xFF);
3460 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32DTIMPeriod
>> 16) & 0xFF);
3461 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32DTIMPeriod
>> 24) & 0xFF);
3463 *pu8CurrByte
++ = (pstrSetBeaconParam
->u32HeadLen
& 0xFF);
3464 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32HeadLen
>> 8) & 0xFF);
3465 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32HeadLen
>> 16) & 0xFF);
3466 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32HeadLen
>> 24) & 0xFF);
3468 memcpy(pu8CurrByte
, pstrSetBeaconParam
->pu8Head
, pstrSetBeaconParam
->u32HeadLen
);
3469 pu8CurrByte
+= pstrSetBeaconParam
->u32HeadLen
;
3471 *pu8CurrByte
++ = (pstrSetBeaconParam
->u32TailLen
& 0xFF);
3472 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32TailLen
>> 8) & 0xFF);
3473 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32TailLen
>> 16) & 0xFF);
3474 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32TailLen
>> 24) & 0xFF);
3476 /* Bug 4599 : if tail length = 0 skip copying */
3477 if (pstrSetBeaconParam
->pu8Tail
> 0)
3478 memcpy(pu8CurrByte
, pstrSetBeaconParam
->pu8Tail
, pstrSetBeaconParam
->u32TailLen
);
3479 pu8CurrByte
+= pstrSetBeaconParam
->u32TailLen
;
3484 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false, (u32
)pstrWFIDrv
);
3486 PRINT_ER("Failed to send add beacon config packet\n");
3487 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3490 WILC_CATCH(s32Error
)
3493 WILC_FREE_IF_TRUE(strWID
.ps8WidVal
);
3494 WILC_FREE_IF_TRUE(pstrSetBeaconParam
->pu8Head
);
3495 WILC_FREE_IF_TRUE(pstrSetBeaconParam
->pu8Tail
);
3500 * @brief Handle_AddBeacon
3501 * @details Sending config packet to delete beacon
3502 * @param[in] tstrHostIFDelBeacon* pstrDelBeacon
3508 static void Handle_DelBeacon(void *drvHandler
, tstrHostIFDelBeacon
*pstrDelBeacon
)
3510 s32 s32Error
= WILC_SUCCESS
;
3513 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3515 strWID
.u16WIDid
= (u16
)WID_DEL_BEACON
;
3516 strWID
.enuWIDtype
= WID_CHAR
;
3517 strWID
.s32ValueSize
= sizeof(char);
3518 strWID
.ps8WidVal
= &gu8DelBcn
;
3520 if (strWID
.ps8WidVal
== NULL
)
3521 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3523 pu8CurrByte
= strWID
.ps8WidVal
;
3525 PRINT_D(HOSTINF_DBG
, "Deleting BEACON\n");
3526 /* TODO: build del beacon message*/
3529 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false, (u32
)pstrWFIDrv
);
3532 PRINT_ER("Failed to send delete beacon config packet\n");
3533 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3536 WILC_CATCH(s32Error
)
3543 * @brief WILC_HostIf_PackStaParam
3544 * @details Handling packing of the station params in a buffer
3545 * @param[in] u8* pu8Buffer, tstrWILC_AddStaParam* pstrStationParam
3551 static u32
WILC_HostIf_PackStaParam(u8
*pu8Buffer
, tstrWILC_AddStaParam
*pstrStationParam
)
3555 pu8CurrByte
= pu8Buffer
;
3557 PRINT_D(HOSTINF_DBG
, "Packing STA params\n");
3558 WILC_memcpy(pu8CurrByte
, pstrStationParam
->au8BSSID
, ETH_ALEN
);
3559 pu8CurrByte
+= ETH_ALEN
;
3561 *pu8CurrByte
++ = pstrStationParam
->u16AssocID
& 0xFF;
3562 *pu8CurrByte
++ = (pstrStationParam
->u16AssocID
>> 8) & 0xFF;
3564 *pu8CurrByte
++ = pstrStationParam
->u8NumRates
;
3565 if (pstrStationParam
->u8NumRates
> 0)
3566 WILC_memcpy(pu8CurrByte
, pstrStationParam
->pu8Rates
, pstrStationParam
->u8NumRates
);
3567 pu8CurrByte
+= pstrStationParam
->u8NumRates
;
3569 *pu8CurrByte
++ = pstrStationParam
->bIsHTSupported
;
3570 *pu8CurrByte
++ = pstrStationParam
->u16HTCapInfo
& 0xFF;
3571 *pu8CurrByte
++ = (pstrStationParam
->u16HTCapInfo
>> 8) & 0xFF;
3573 *pu8CurrByte
++ = pstrStationParam
->u8AmpduParams
;
3574 WILC_memcpy(pu8CurrByte
, pstrStationParam
->au8SuppMCsSet
, WILC_SUPP_MCS_SET_SIZE
);
3575 pu8CurrByte
+= WILC_SUPP_MCS_SET_SIZE
;
3577 *pu8CurrByte
++ = pstrStationParam
->u16HTExtParams
& 0xFF;
3578 *pu8CurrByte
++ = (pstrStationParam
->u16HTExtParams
>> 8) & 0xFF;
3580 *pu8CurrByte
++ = pstrStationParam
->u32TxBeamformingCap
& 0xFF;
3581 *pu8CurrByte
++ = (pstrStationParam
->u32TxBeamformingCap
>> 8) & 0xFF;
3582 *pu8CurrByte
++ = (pstrStationParam
->u32TxBeamformingCap
>> 16) & 0xFF;
3583 *pu8CurrByte
++ = (pstrStationParam
->u32TxBeamformingCap
>> 24) & 0xFF;
3585 *pu8CurrByte
++ = pstrStationParam
->u8ASELCap
;
3587 *pu8CurrByte
++ = pstrStationParam
->u16FlagsMask
& 0xFF;
3588 *pu8CurrByte
++ = (pstrStationParam
->u16FlagsMask
>> 8) & 0xFF;
3590 *pu8CurrByte
++ = pstrStationParam
->u16FlagsSet
& 0xFF;
3591 *pu8CurrByte
++ = (pstrStationParam
->u16FlagsSet
>> 8) & 0xFF;
3593 return pu8CurrByte
- pu8Buffer
;
3597 * @brief Handle_AddStation
3598 * @details Sending config packet to add station
3599 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3605 static void Handle_AddStation(void *drvHandler
, tstrWILC_AddStaParam
*pstrStationParam
)
3607 s32 s32Error
= WILC_SUCCESS
;
3610 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3612 PRINT_D(HOSTINF_DBG
, "Handling add station\n");
3613 strWID
.u16WIDid
= (u16
)WID_ADD_STA
;
3614 strWID
.enuWIDtype
= WID_BIN
;
3615 strWID
.s32ValueSize
= WILC_ADD_STA_LENGTH
+ pstrStationParam
->u8NumRates
;
3617 strWID
.ps8WidVal
= WILC_MALLOC(strWID
.s32ValueSize
);
3618 if (strWID
.ps8WidVal
== NULL
)
3619 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3621 pu8CurrByte
= strWID
.ps8WidVal
;
3622 pu8CurrByte
+= WILC_HostIf_PackStaParam(pu8CurrByte
, pstrStationParam
);
3625 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false, (u32
)pstrWFIDrv
);
3626 if (s32Error
!= WILC_SUCCESS
) {
3628 PRINT_ER("Failed to send add station config packet\n");
3629 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3632 WILC_CATCH(s32Error
)
3635 WILC_FREE_IF_TRUE(pstrStationParam
->pu8Rates
);
3636 WILC_FREE_IF_TRUE(strWID
.ps8WidVal
);
3640 * @brief Handle_DelAllSta
3641 * @details Sending config packet to delete station
3642 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3648 static void Handle_DelAllSta(void *drvHandler
, tstrHostIFDelAllSta
*pstrDelAllStaParam
)
3650 s32 s32Error
= WILC_SUCCESS
;
3654 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3656 u8 au8Zero_Buff
[6] = {0};
3658 strWID
.u16WIDid
= (u16
)WID_DEL_ALL_STA
;
3659 strWID
.enuWIDtype
= WID_STR
;
3660 strWID
.s32ValueSize
= (pstrDelAllStaParam
->u8Num_AssocSta
* ETH_ALEN
) + 1;
3662 PRINT_D(HOSTINF_DBG
, "Handling delete station\n");
3664 strWID
.ps8WidVal
= WILC_MALLOC((pstrDelAllStaParam
->u8Num_AssocSta
* ETH_ALEN
) + 1);
3665 if (strWID
.ps8WidVal
== NULL
)
3666 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3668 pu8CurrByte
= strWID
.ps8WidVal
;
3670 *(pu8CurrByte
++) = pstrDelAllStaParam
->u8Num_AssocSta
;
3672 for (i
= 0; i
< MAX_NUM_STA
; i
++) {
3673 if (memcmp(pstrDelAllStaParam
->au8Sta_DelAllSta
[i
], au8Zero_Buff
, ETH_ALEN
))
3674 WILC_memcpy(pu8CurrByte
, pstrDelAllStaParam
->au8Sta_DelAllSta
[i
], ETH_ALEN
);
3678 pu8CurrByte
+= ETH_ALEN
;
3682 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
3685 PRINT_ER("Failed to send add station config packet\n");
3686 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3689 WILC_CATCH(s32Error
)
3692 WILC_FREE_IF_TRUE(strWID
.ps8WidVal
);
3699 * @brief Handle_DelStation
3700 * @details Sending config packet to delete station
3701 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3707 static void Handle_DelStation(void *drvHandler
, tstrHostIFDelSta
*pstrDelStaParam
)
3709 s32 s32Error
= WILC_SUCCESS
;
3712 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3714 strWID
.u16WIDid
= (u16
)WID_REMOVE_STA
;
3715 strWID
.enuWIDtype
= WID_BIN
;
3716 strWID
.s32ValueSize
= ETH_ALEN
;
3718 PRINT_D(HOSTINF_DBG
, "Handling delete station\n");
3720 strWID
.ps8WidVal
= WILC_MALLOC(strWID
.s32ValueSize
);
3721 if (strWID
.ps8WidVal
== NULL
)
3722 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3724 pu8CurrByte
= strWID
.ps8WidVal
;
3726 WILC_memcpy(pu8CurrByte
, pstrDelStaParam
->au8MacAddr
, ETH_ALEN
);
3729 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false, (u32
)pstrWFIDrv
);
3732 PRINT_ER("Failed to send add station config packet\n");
3733 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3736 WILC_CATCH(s32Error
)
3739 WILC_FREE_IF_TRUE(strWID
.ps8WidVal
);
3744 * @brief Handle_EditStation
3745 * @details Sending config packet to edit station
3746 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3752 static void Handle_EditStation(void *drvHandler
, tstrWILC_AddStaParam
*pstrStationParam
)
3754 s32 s32Error
= WILC_SUCCESS
;
3757 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3759 strWID
.u16WIDid
= (u16
)WID_EDIT_STA
;
3760 strWID
.enuWIDtype
= WID_BIN
;
3761 strWID
.s32ValueSize
= WILC_ADD_STA_LENGTH
+ pstrStationParam
->u8NumRates
;
3763 PRINT_D(HOSTINF_DBG
, "Handling edit station\n");
3764 strWID
.ps8WidVal
= WILC_MALLOC(strWID
.s32ValueSize
);
3765 if (strWID
.ps8WidVal
== NULL
)
3766 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3768 pu8CurrByte
= strWID
.ps8WidVal
;
3769 pu8CurrByte
+= WILC_HostIf_PackStaParam(pu8CurrByte
, pstrStationParam
);
3772 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false, (u32
)pstrWFIDrv
);
3775 PRINT_ER("Failed to send edit station config packet\n");
3776 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3779 WILC_CATCH(s32Error
)
3782 WILC_FREE_IF_TRUE(pstrStationParam
->pu8Rates
);
3783 WILC_FREE_IF_TRUE(strWID
.ps8WidVal
);
3785 #endif /*WILC_AP_EXTERNAL_MLME*/
3789 * @brief Handle_RemainOnChan
3790 * @details Sending config packet to edit station
3791 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3797 static int Handle_RemainOnChan(void *drvHandler
, tstrHostIfRemainOnChan
*pstrHostIfRemainOnChan
)
3799 s32 s32Error
= WILC_SUCCESS
;
3800 u8 u8remain_on_chan_flag
;
3802 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*) drvHandler
;
3804 /*If it's a pendig remain-on-channel, don't overwrite gWFiDrvHandle values (since incoming msg is garbbage)*/
3805 if (!pstrWFIDrv
->u8RemainOnChan_pendingreq
) {
3806 pstrWFIDrv
->strHostIfRemainOnChan
.pVoid
= pstrHostIfRemainOnChan
->pVoid
;
3807 pstrWFIDrv
->strHostIfRemainOnChan
.pRemainOnChanExpired
= pstrHostIfRemainOnChan
->pRemainOnChanExpired
;
3808 pstrWFIDrv
->strHostIfRemainOnChan
.pRemainOnChanReady
= pstrHostIfRemainOnChan
->pRemainOnChanReady
;
3809 pstrWFIDrv
->strHostIfRemainOnChan
.u16Channel
= pstrHostIfRemainOnChan
->u16Channel
;
3810 pstrWFIDrv
->strHostIfRemainOnChan
.u32ListenSessionID
= pstrHostIfRemainOnChan
->u32ListenSessionID
;
3812 /*Set the channel to use it as a wid val*/
3813 pstrHostIfRemainOnChan
->u16Channel
= pstrWFIDrv
->strHostIfRemainOnChan
.u16Channel
;
3816 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
!= NULL
) {
3817 PRINT_INFO(GENERIC_DBG
, "Required to remain on chan while scanning return\n");
3818 pstrWFIDrv
->u8RemainOnChan_pendingreq
= 1;
3819 WILC_ERRORREPORT(s32Error
, WILC_BUSY
);
3821 if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_WAITING_CONN_RESP
) {
3822 PRINT_INFO(GENERIC_DBG
, "Required to remain on chan while connecting return\n");
3823 WILC_ERRORREPORT(s32Error
, WILC_BUSY
);
3826 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3827 if (g_obtainingIP
|| connecting
) {
3828 PRINT_D(GENERIC_DBG
, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
3829 WILC_ERRORREPORT(s32Error
, WILC_BUSY
);
3833 PRINT_D(HOSTINF_DBG
, "Setting channel :%d\n", pstrHostIfRemainOnChan
->u16Channel
);
3835 u8remain_on_chan_flag
= true;
3836 strWID
.u16WIDid
= (u16
)WID_REMAIN_ON_CHAN
;
3837 strWID
.enuWIDtype
= WID_STR
;
3838 strWID
.s32ValueSize
= 2;
3839 strWID
.ps8WidVal
= (s8
*)WILC_MALLOC(strWID
.s32ValueSize
);
3841 if (strWID
.ps8WidVal
== NULL
)
3842 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3844 strWID
.ps8WidVal
[0] = u8remain_on_chan_flag
;
3845 strWID
.ps8WidVal
[1] = (s8
)pstrHostIfRemainOnChan
->u16Channel
;
3848 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
3849 if (s32Error
!= WILC_SUCCESS
)
3850 PRINT_ER("Failed to set remain on channel\n");
3854 P2P_LISTEN_STATE
= 1;
3855 WILC_TimerStart(&(pstrWFIDrv
->hRemainOnChannel
), pstrHostIfRemainOnChan
->u32duration
, (void *)pstrWFIDrv
, NULL
);
3857 /*Calling CFG ready_on_channel*/
3858 if (pstrWFIDrv
->strHostIfRemainOnChan
.pRemainOnChanReady
)
3859 pstrWFIDrv
->strHostIfRemainOnChan
.pRemainOnChanReady(pstrWFIDrv
->strHostIfRemainOnChan
.pVoid
);
3861 if (pstrWFIDrv
->u8RemainOnChan_pendingreq
)
3862 pstrWFIDrv
->u8RemainOnChan_pendingreq
= 0;
3868 * @brief Handle_RegisterFrame
3876 static int Handle_RegisterFrame(void *drvHandler
, tstrHostIfRegisterFrame
*pstrHostIfRegisterFrame
)
3878 s32 s32Error
= WILC_SUCCESS
;
3881 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3883 PRINT_D(HOSTINF_DBG
, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame
->bReg
, pstrHostIfRegisterFrame
->u16FrameType
);
3885 /*prepare configuration packet*/
3886 strWID
.u16WIDid
= (u16
)WID_REGISTER_FRAME
;
3887 strWID
.enuWIDtype
= WID_STR
;
3888 strWID
.ps8WidVal
= WILC_MALLOC(sizeof(u16
) + 2);
3889 if (strWID
.ps8WidVal
== NULL
)
3890 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3892 pu8CurrByte
= strWID
.ps8WidVal
;
3894 *pu8CurrByte
++ = pstrHostIfRegisterFrame
->bReg
;
3895 *pu8CurrByte
++ = pstrHostIfRegisterFrame
->u8Regid
;
3896 WILC_memcpy(pu8CurrByte
, &(pstrHostIfRegisterFrame
->u16FrameType
), sizeof(u16
));
3899 strWID
.s32ValueSize
= sizeof(u16
) + 2;
3903 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
3905 PRINT_ER("Failed to frame register config packet\n");
3906 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
3910 WILC_CATCH(s32Error
)
3919 * @brief Handle_ListenStateExpired
3920 * @details Handle of listen state expiration
3922 * @return Error code.
3927 #define FALSE_FRMWR_CHANNEL 100
3928 static u32
Handle_ListenStateExpired(void *drvHandler
, tstrHostIfRemainOnChan
*pstrHostIfRemainOnChan
)
3930 u8 u8remain_on_chan_flag
;
3932 s32 s32Error
= WILC_SUCCESS
;
3933 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*) drvHandler
;
3935 PRINT_D(HOSTINF_DBG
, "CANCEL REMAIN ON CHAN\n");
3938 /*Make sure we are already in listen state*/
3939 /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/
3940 if (P2P_LISTEN_STATE
) {
3941 u8remain_on_chan_flag
= false;
3942 strWID
.u16WIDid
= (u16
)WID_REMAIN_ON_CHAN
;
3943 strWID
.enuWIDtype
= WID_STR
;
3944 strWID
.s32ValueSize
= 2;
3945 strWID
.ps8WidVal
= WILC_MALLOC(strWID
.s32ValueSize
);
3947 if (strWID
.ps8WidVal
== NULL
)
3948 PRINT_ER("Failed to allocate memory\n");
3950 strWID
.ps8WidVal
[0] = u8remain_on_chan_flag
;
3951 strWID
.ps8WidVal
[1] = FALSE_FRMWR_CHANNEL
;
3954 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
3955 if (s32Error
!= WILC_SUCCESS
) {
3956 PRINT_ER("Failed to set remain on channel\n");
3960 if (pstrWFIDrv
->strHostIfRemainOnChan
.pRemainOnChanExpired
) {
3961 pstrWFIDrv
->strHostIfRemainOnChan
.pRemainOnChanExpired(pstrWFIDrv
->strHostIfRemainOnChan
.pVoid
3962 , pstrHostIfRemainOnChan
->u32ListenSessionID
);
3964 P2P_LISTEN_STATE
= 0;
3966 PRINT_D(GENERIC_DBG
, "Not in listen state\n");
3967 s32Error
= WILC_FAIL
;
3976 * @brief ListenTimerCB
3977 * @details Callback function of remain-on-channel timer
3979 * @return Error code.
3984 static void ListenTimerCB(void *pvArg
)
3986 s32 s32Error
= WILC_SUCCESS
;
3987 tstrHostIFmsg strHostIFmsg
;
3988 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)pvArg
;
3989 /*Stopping remain-on-channel timer*/
3990 WILC_TimerStop(&(pstrWFIDrv
->hRemainOnChannel
), NULL
);
3992 /* prepare the Timer Callback message */
3993 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
3994 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_LISTEN_TIMER_FIRED
;
3995 strHostIFmsg
.drvHandler
= pstrWFIDrv
;
3996 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.u32ListenSessionID
= pstrWFIDrv
->strHostIfRemainOnChan
.u32ListenSessionID
;
3998 /* send the message */
3999 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
4001 WILC_ERRORREPORT(s32Error
, s32Error
);
4002 WILC_CATCH(s32Error
)
4011 * @brief Handle_EditStation
4012 * @details Sending config packet to edit station
4013 * @param[in] tstrWILC_AddStaParam* pstrStationParam
4019 static void Handle_PowerManagement(void *drvHandler
, tstrHostIfPowerMgmtParam
*strPowerMgmtParam
)
4021 s32 s32Error
= WILC_SUCCESS
;
4024 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
4026 strWID
.u16WIDid
= (u16
)WID_POWER_MANAGEMENT
;
4028 if (strPowerMgmtParam
->bIsEnabled
== true) {
4029 s8PowerMode
= MIN_FAST_PS
;
4031 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(void *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 WILC_FREE_IF_TRUE(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(void *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
= (u8
*)WILC_MALLOC(BLOCK_ACK_REQ_SIZE
);
4134 strWID
.s32ValueSize
= BLOCK_ACK_REQ_SIZE
;
4135 ptr
= strWID
.ps8WidVal
;
4136 /* *ptr++ = 0x14; */
4140 WILC_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 WILC_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 WILC_FREE(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(void *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
= (u8
*)WILC_MALLOC(BLOCK_ACK_REQ_SIZE
);
4219 strWID
.s32ValueSize
= BLOCK_ACK_REQ_SIZE
;
4220 ptr
= strWID
.ps8WidVal
;
4221 /* *ptr++ = 0x14; */
4225 WILC_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 WILC_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 WILC_FREE(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(void *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
= (u8
*)WILC_MALLOC(BLOCK_ACK_REQ_SIZE
);
4289 strWID
.s32ValueSize
= BLOCK_ACK_REQ_SIZE
;
4290 ptr
= strWID
.ps8WidVal
;
4294 WILC_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 WILC_FREE(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 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4335 WILC_MsgQueueRecv(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), &u32Ret
, NULL
);
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--");
4347 WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
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
), NULL
);
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 WILC_TimerStop(&(pstrWFIDrv
->hScanTimer
), NULL
);
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(void *pvArg
)
4551 tstrHostIFmsg strHostIFmsg
;
4553 /* prepare the Timer Callback message */
4554 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4555 strHostIFmsg
.drvHandler
= pvArg
;
4556 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SCAN_TIMER_FIRED
;
4558 /* send the message */
4559 WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
4562 static void TimerCB_Connect(void *pvArg
)
4564 tstrHostIFmsg strHostIFmsg
;
4566 /* prepare the Timer Callback message */
4567 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4568 strHostIFmsg
.drvHandler
= pvArg
;
4569 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_CONNECT_TIMER_FIRED
;
4571 /* send the message */
4572 WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
4577 * @brief removes wpa/wpa2 keys
4578 * @details only in BSS STA mode if External Supplicant support is enabled.
4579 * removes all WPA/WPA2 station key entries from MAC hardware.
4580 * @param[in,out] handle to the wifi driver
4581 * @param[in] 6 bytes of Station Adress in the station entry table
4582 * @return Error code indicating success/failure
4585 * @date 8 March 2012
4588 /* Check implementation in core adding 9 bytes to the input! */
4589 s32
host_int_remove_key(WILC_WFIDrvHandle hWFIDrv
, const u8
*pu8StaAddress
)
4591 s32 s32Error
= WILC_SUCCESS
;
4593 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4595 strWID
.u16WIDid
= (u16
)WID_REMOVE_KEY
;
4596 strWID
.enuWIDtype
= WID_STR
;
4597 strWID
.ps8WidVal
= (s8
*)pu8StaAddress
;
4598 strWID
.s32ValueSize
= 6;
4605 * @brief removes WEP key
4606 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4607 * remove a WEP key entry from MAC HW.
4608 * The BSS Station automatically finds the index of the entry using its
4609 * BSS ID and removes that entry from the MAC hardware.
4610 * @param[in,out] handle to the wifi driver
4611 * @param[in] 6 bytes of Station Adress in the station entry table
4612 * @return Error code indicating success/failure
4613 * @note NO need for the STA add since it is not used for processing
4615 * @date 8 March 2012
4618 s32
host_int_remove_wep_key(WILC_WFIDrvHandle hWFIDrv
, u8 u8keyIdx
)
4620 s32 s32Error
= WILC_SUCCESS
;
4621 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
4622 tstrHostIFmsg strHostIFmsg
;
4625 if (pstrWFIDrv
== NULL
)
4626 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
4628 /* prepare the Remove Wep Key Message */
4629 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4632 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
4633 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= WEP
;
4634 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= REMOVEKEY
;
4635 strHostIFmsg
.drvHandler
= hWFIDrv
;
4639 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4640 uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
= u8keyIdx
;
4642 /* send the message */
4643 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
4645 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
4646 down(&(pstrWFIDrv
->hSemTestKeyBlock
));
4648 WILC_CATCH(s32Error
)
4656 * @brief sets WEP default key
4657 * @details Sets the index of the WEP encryption key in use,
4659 * @param[in,out] handle to the wifi driver
4660 * @param[in] key index ( 0, 1, 2, 3)
4661 * @return Error code indicating success/failure
4664 * @date 8 March 2012
4667 s32
host_int_set_WEPDefaultKeyID(WILC_WFIDrvHandle hWFIDrv
, u8 u8Index
)
4669 s32 s32Error
= WILC_SUCCESS
;
4670 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
4671 tstrHostIFmsg strHostIFmsg
;
4674 if (pstrWFIDrv
== NULL
)
4675 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
4677 /* prepare the Key Message */
4678 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4681 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
4682 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= WEP
;
4683 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= DEFAULTKEY
;
4684 strHostIFmsg
.drvHandler
= hWFIDrv
;
4687 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4688 uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
= u8Index
;
4690 /* send the message */
4691 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
4693 PRINT_ER("Error in sending message queue : Default key index\n");
4694 down(&(pstrWFIDrv
->hSemTestKeyBlock
));
4696 WILC_CATCH(s32Error
)
4705 * @brief sets WEP deafault key
4706 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4707 * sets WEP key entry into MAC hardware when it receives the
4708 * corresponding request from NDIS.
4709 * @param[in,out] handle to the wifi driver
4710 * @param[in] message containing WEP Key in the following format
4711 *|---------------------------------------|
4712 *|Key ID Value | Key Length | Key |
4713 *|-------------|------------|------------|
4714 | 1byte | 1byte | Key Length |
4715 ||---------------------------------------|
4717 * @return Error code indicating success/failure
4720 * @date 8 March 2012
4723 s32
host_int_add_wep_key_bss_sta(WILC_WFIDrvHandle hWFIDrv
, const u8
*pu8WepKey
, u8 u8WepKeylen
, u8 u8Keyidx
)
4726 s32 s32Error
= WILC_SUCCESS
;
4727 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
4728 tstrHostIFmsg strHostIFmsg
;
4730 if (pstrWFIDrv
== NULL
)
4731 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
4734 /* prepare the Key Message */
4735 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4738 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
4739 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= WEP
;
4740 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY
;
4741 strHostIFmsg
.drvHandler
= hWFIDrv
;
4744 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4745 uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
= (u8
*)WILC_MALLOC(u8WepKeylen
);
4747 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
,
4748 pu8WepKey
, u8WepKeylen
);
4751 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4752 uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
= (u8WepKeylen
);
4754 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4755 uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
= u8Keyidx
;
4757 /* send the message */
4758 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
4760 PRINT_ER("Error in sending message queue :WEP Key\n");
4761 down(&(pstrWFIDrv
->hSemTestKeyBlock
));
4763 WILC_CATCH(s32Error
)
4771 #ifdef WILC_AP_EXTERNAL_MLME
4774 * @brief host_int_add_wep_key_bss_ap
4775 * @details valid only in BSS AP mode if External Supplicant support is enabled.
4776 * sets WEP key entry into MAC hardware when it receives the
4778 * corresponding request from NDIS.
4779 * @param[in,out] handle to the wifi driver
4782 * @return Error code indicating success/failure
4788 s32
host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv
, const u8
*pu8WepKey
, u8 u8WepKeylen
, u8 u8Keyidx
, u8 u8mode
, AUTHTYPE_T tenuAuth_type
)
4791 s32 s32Error
= WILC_SUCCESS
;
4792 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
4793 tstrHostIFmsg strHostIFmsg
;
4796 if (pstrWFIDrv
== NULL
)
4797 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
4800 /* prepare the Key Message */
4801 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4804 for (i
= 0; i
< u8WepKeylen
; i
++)
4805 PRINT_INFO(HOSTAPD_DBG
, "KEY is %x\n", pu8WepKey
[i
]);
4807 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
4808 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= WEP
;
4809 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY_AP
;
4810 strHostIFmsg
.drvHandler
= hWFIDrv
;
4813 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4814 uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
= (u8
*)WILC_MALLOC((u8WepKeylen
));
4817 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
,
4818 pu8WepKey
, (u8WepKeylen
));
4821 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4822 uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
= (u8WepKeylen
);
4824 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4825 uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
= u8Keyidx
;
4827 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4828 uniHostIFkeyAttr
.strHostIFwepAttr
.u8mode
= u8mode
;
4830 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4831 uniHostIFkeyAttr
.strHostIFwepAttr
.tenuAuth_type
= tenuAuth_type
;
4832 /* send the message */
4833 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
4836 PRINT_ER("Error in sending message queue :WEP Key\n");
4837 down(&(pstrWFIDrv
->hSemTestKeyBlock
));
4839 WILC_CATCH(s32Error
)
4848 * @brief adds ptk Key
4850 * @param[in,out] handle to the wifi driver
4851 * @param[in] message containing PTK Key in the following format
4852 *|-----------------------------------------------------------------------------|
4853 *|Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
4854 *|----------------|------------|--------------|----------------|---------------|
4855 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
4856 ||-----------------------------------------------------------------------------|
4857 * @return Error code indicating success/failure
4860 * @date 8 March 2012
4863 s32
host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv
, const u8
*pu8Ptk
, u8 u8PtkKeylen
,
4864 const u8
*mac_addr
, const u8
*pu8RxMic
, const u8
*pu8TxMic
, u8 mode
, u8 u8Ciphermode
, u8 u8Idx
)
4866 s32 s32Error
= WILC_SUCCESS
;
4867 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
4868 tstrHostIFmsg strHostIFmsg
;
4869 u8 u8KeyLen
= u8PtkKeylen
;
4872 if (pstrWFIDrv
== NULL
)
4873 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
4874 if (pu8RxMic
!= NULL
)
4875 u8KeyLen
+= RX_MIC_KEY_LEN
;
4876 if (pu8TxMic
!= NULL
)
4877 u8KeyLen
+= TX_MIC_KEY_LEN
;
4879 /* prepare the Key Message */
4880 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4883 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
4884 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= WPAPtk
;
4885 #ifdef WILC_AP_EXTERNAL_MLME
4886 if (mode
== AP_MODE
) {
4887 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY_AP
;
4888 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4889 uniHostIFkeyAttr
.strHostIFwpaAttr
.u8keyidx
= u8Idx
;
4892 if (mode
== STATION_MODE
)
4893 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY
;
4896 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4897 uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
= (u8
*)WILC_MALLOC(u8PtkKeylen
);
4900 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
,
4901 pu8Ptk
, u8PtkKeylen
);
4903 if (pu8RxMic
!= NULL
) {
4905 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
+ 16,
4906 pu8RxMic
, RX_MIC_KEY_LEN
);
4908 for (i
= 0; i
< RX_MIC_KEY_LEN
; i
++)
4909 PRINT_INFO(CFG80211_DBG
, "PairwiseRx[%d] = %x\n", i
, pu8RxMic
[i
]);
4912 if (pu8TxMic
!= NULL
) {
4914 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
+ 24,
4915 pu8TxMic
, TX_MIC_KEY_LEN
);
4917 for (i
= 0; i
< TX_MIC_KEY_LEN
; i
++)
4918 PRINT_INFO(CFG80211_DBG
, "PairwiseTx[%d] = %x\n", i
, pu8TxMic
[i
]);
4922 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4923 uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
= u8KeyLen
;
4925 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4926 uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Ciphermode
= u8Ciphermode
;
4927 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4928 uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8macaddr
= mac_addr
;
4929 strHostIFmsg
.drvHandler
= hWFIDrv
;
4931 /* send the message */
4932 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
4935 PRINT_ER("Error in sending message queue: PTK Key\n");
4937 /* ////////////// */
4938 down(&(pstrWFIDrv
->hSemTestKeyBlock
));
4939 /* WILC_Sleep(100); */
4942 WILC_CATCH(s32Error
)
4951 * @brief adds Rx GTk Key
4953 * @param[in,out] handle to the wifi driver
4954 * @param[in] pu8RxGtk : contains temporal key | Rx Mic | Tx Mic
4955 * u8GtkKeylen :The total key length
4957 * @return Error code indicating success/failure
4960 * @date 8 March 2012
4963 s32
host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv
, const u8
*pu8RxGtk
, u8 u8GtkKeylen
,
4964 u8 u8KeyIdx
, u32 u32KeyRSClen
, const u8
*KeyRSC
,
4965 const u8
*pu8RxMic
, const u8
*pu8TxMic
, u8 mode
, u8 u8Ciphermode
)
4967 s32 s32Error
= WILC_SUCCESS
;
4968 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
4969 tstrHostIFmsg strHostIFmsg
;
4970 u8 u8KeyLen
= u8GtkKeylen
;
4972 if (pstrWFIDrv
== NULL
)
4973 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
4974 /* prepare the Key Message */
4975 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4978 if (pu8RxMic
!= NULL
)
4979 u8KeyLen
+= RX_MIC_KEY_LEN
;
4980 if (pu8TxMic
!= NULL
)
4981 u8KeyLen
+= TX_MIC_KEY_LEN
;
4982 if (KeyRSC
!= NULL
) {
4983 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4984 uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8seq
= (u8
*)WILC_MALLOC(u32KeyRSClen
);
4986 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8seq
,
4987 KeyRSC
, u32KeyRSClen
);
4991 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
4992 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= WPARxGtk
;
4993 strHostIFmsg
.drvHandler
= hWFIDrv
;
4995 #ifdef WILC_AP_EXTERNAL_MLME
4996 if (mode
== AP_MODE
) {
4997 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY_AP
;
4998 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Ciphermode
= u8Ciphermode
;
5001 if (mode
== STATION_MODE
)
5002 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY
;
5005 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
5006 uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
= (u8
*)WILC_MALLOC(u8KeyLen
);
5008 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
,
5009 pu8RxGtk
, u8GtkKeylen
);
5011 if (pu8RxMic
!= NULL
) {
5013 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
+ 16,
5014 pu8RxMic
, RX_MIC_KEY_LEN
);
5017 if (pu8TxMic
!= NULL
) {
5019 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
+ 24,
5020 pu8TxMic
, TX_MIC_KEY_LEN
);
5024 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
5025 uniHostIFkeyAttr
.strHostIFwpaAttr
.u8keyidx
= u8KeyIdx
;
5026 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
5027 uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
= u8KeyLen
;
5029 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
5030 uniHostIFkeyAttr
.strHostIFwpaAttr
.u8seqlen
= u32KeyRSClen
;
5034 /* send the message */
5035 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
5037 PRINT_ER("Error in sending message queue: RX GTK\n");
5038 /* ////////////// */
5039 down(&(pstrWFIDrv
->hSemTestKeyBlock
));
5040 /* WILC_Sleep(100); */
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(WILC_WFIDrvHandle 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 WILC_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 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFpmkidAttr
.pmkidlist
[i
].bssid
, &pu8PmkidInfoArray
->pmkidlist
[i
].bssid
,
5094 WILC_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
), NULL
);
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(WILC_WFIDrvHandle 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(WILC_WFIDrvHandle hWFIDrv
, u8
*pu8PassPhrase
,
5164 s32 s32Error
= WILC_SUCCESS
;
5166 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5168 /* u8 u8Psklength = WILC_strlen(pu8PassPhrase); */
5169 /*validating psk length*/
5170 if ((u8Psklength
> 7) && (u8Psklength
< 65)) {
5171 strWID
.u16WIDid
= (u16
)WID_11I_PSK
;
5172 strWID
.enuWIDtype
= WID_STR
;
5173 strWID
.ps8WidVal
= pu8PassPhrase
;
5174 strWID
.s32ValueSize
= u8Psklength
;
5180 * @brief host_int_get_MacAddress
5181 * @details gets mac address
5182 * @param[in,out] handle to the wifi driver,
5184 * @return Error code indicating success/failure
5187 * @date 19 April 2012
5190 s32
host_int_get_MacAddress(WILC_WFIDrvHandle hWFIDrv
, u8
*pu8MacAddress
)
5192 s32 s32Error
= WILC_SUCCESS
;
5193 tstrHostIFmsg strHostIFmsg
;
5196 /* prepare the Message */
5197 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5199 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_MAC_ADDRESS
;
5200 strHostIFmsg
.uniHostIFmsgBody
.strHostIfGetMacAddress
.u8MacAddress
= pu8MacAddress
;
5201 strHostIFmsg
.drvHandler
= hWFIDrv
;
5202 /* send the message */
5203 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
5205 PRINT_ER("Failed to send get mac address\n");
5209 down(&hWaitResponse
);
5214 * @brief host_int_set_MacAddress
5215 * @details sets mac address
5216 * @param[in,out] handle to the wifi driver,
5218 * @return Error code indicating success/failure
5221 * @date 16 July 2012
5224 s32
host_int_set_MacAddress(WILC_WFIDrvHandle hWFIDrv
, u8
*pu8MacAddress
)
5226 s32 s32Error
= WILC_SUCCESS
;
5227 tstrHostIFmsg strHostIFmsg
;
5229 PRINT_D(GENERIC_DBG
, "mac addr = %x:%x:%x\n", pu8MacAddress
[0], pu8MacAddress
[1], pu8MacAddress
[2]);
5231 /* prepare setting mac address message */
5232 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5233 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SET_MAC_ADDRESS
;
5234 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetMacAddress
.u8MacAddress
, pu8MacAddress
, ETH_ALEN
);
5235 strHostIFmsg
.drvHandler
= hWFIDrv
;
5237 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
5239 PRINT_ER("Failed to send message queue: Set mac address\n");
5240 WILC_ERRORREPORT(s32Error
, s32Error
);
5242 WILC_CATCH(s32Error
)
5252 * @brief host_int_get_RSNAConfigPSKPassPhrase
5253 * @details gets the pass phrase:AP/STA mode. This function gets the pass phrase used to
5254 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5255 * The length of the field can vary from 8 to 64 bytes,
5256 * the lower layer should get the
5257 * @param[in,out] handle to the wifi driver,
5258 * String containing PSK
5259 * @return Error code indicating success/failure
5262 * @date 8 March 2012
5265 s32
host_int_get_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv
,
5266 u8
*pu8PassPhrase
, u8 u8Psklength
)
5268 s32 s32Error
= WILC_SUCCESS
;
5270 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5272 strWID
.u16WIDid
= (u16
)WID_11I_PSK
;
5273 strWID
.enuWIDtype
= WID_STR
;
5274 strWID
.s32ValueSize
= u8Psklength
;
5275 strWID
.ps8WidVal
= pu8PassPhrase
;
5281 * @brief host_int_get_site_survey_results
5282 * @details gets the site survey results
5283 * @param[in,out] handle to the wifi driver,
5284 * Message containing site survey results in the
5286 *|---------------------------------------------------|
5287 | MsgLength | fragNo. | MsgBodyLength | MsgBody |
5288 ||-----------|-----------|---------------|-----------|
5290 | ----------------------------------------- | ----------------
5292 ||---------------------------------------|
5293 | Network1 | Netweork2 | ... | Network5 |
5294 ||---------------------------------------|
5295 | 44 | 44 | ... | 44 |
5296 | -------------------------- | ---------------------------------------
5298 ||---------------------------------------------------------------------|
5299 | SSID | BSS Type | Channel | Security Status| BSSID | RSSI |Reserved |
5302 ||------|----------|---------|----------------|-------|------|---------|
5303 | 33 | 1 | 1 | 1 | 6 | 1 | 1 |
5304 ||---------------------------------------------------------------------|
5305 * @return Error code indicating success/failure
5308 * @date 8 March 2012
5311 #ifndef CONNECT_DIRECT
5312 s32
host_int_get_site_survey_results(WILC_WFIDrvHandle hWFIDrv
,
5313 u8 ppu8RcvdSiteSurveyResults
[][MAX_SURVEY_RESULT_FRAG_SIZE
],
5314 u32 u32MaxSiteSrvyFragLen
)
5316 s32 s32Error
= WILC_SUCCESS
;
5317 tstrWID astrWIDList
[2];
5318 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5320 astrWIDList
[0].u16WIDid
= (u16
)WID_SITE_SURVEY_RESULTS
;
5321 astrWIDList
[0].enuWIDtype
= WID_STR
;
5322 astrWIDList
[0].ps8WidVal
= ppu8RcvdSiteSurveyResults
[0];
5323 astrWIDList
[0].s32ValueSize
= u32MaxSiteSrvyFragLen
;
5325 astrWIDList
[1].u16WIDid
= (u16
)WID_SITE_SURVEY_RESULTS
;
5326 astrWIDList
[1].enuWIDtype
= WID_STR
;
5327 astrWIDList
[1].ps8WidVal
= ppu8RcvdSiteSurveyResults
[1];
5328 astrWIDList
[1].s32ValueSize
= u32MaxSiteSrvyFragLen
;
5330 s32Error
= SendConfigPkt(GET_CFG
, astrWIDList
, 2, true, (u32
)pstrWFIDrv
);
5332 /*get the value by searching the local copy*/
5334 PRINT_ER("Failed to send config packet to get survey results\n");
5335 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
5338 WILC_CATCH(s32Error
)
5348 * @brief sets a start scan request
5350 * @param[in,out] handle to the wifi driver,
5351 * @param[in] Scan Source one of the following values
5354 * OBSS_PERIODIC_SCAN BIT1
5355 * OBSS_ONETIME_SCAN BIT2
5356 * @return Error code indicating success/failure
5359 * @date 8 March 2012
5362 s32
host_int_set_start_scan_req(WILC_WFIDrvHandle hWFIDrv
, u8 scanSource
)
5364 s32 s32Error
= WILC_SUCCESS
;
5366 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5368 strWID
.u16WIDid
= (u16
)WID_START_SCAN_REQ
;
5369 strWID
.enuWIDtype
= WID_CHAR
;
5370 strWID
.ps8WidVal
= (s8
*)&scanSource
;
5371 strWID
.s32ValueSize
= sizeof(char);
5377 * @brief host_int_get_start_scan_req
5378 * @details gets a start scan request
5379 * @param[in,out] handle to the wifi driver,
5380 * @param[in] Scan Source one of the following values
5383 * OBSS_PERIODIC_SCAN BIT1
5384 * OBSS_ONETIME_SCAN BIT2
5385 * @return Error code indicating success/failure
5388 * @date 8 March 2012
5392 s32
host_int_get_start_scan_req(WILC_WFIDrvHandle hWFIDrv
, u8
*pu8ScanSource
)
5394 s32 s32Error
= WILC_SUCCESS
;
5396 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5398 strWID
.u16WIDid
= (u16
)WID_START_SCAN_REQ
;
5399 strWID
.enuWIDtype
= WID_CHAR
;
5400 strWID
.ps8WidVal
= (s8
*)pu8ScanSource
;
5401 strWID
.s32ValueSize
= sizeof(char);
5407 * @brief host_int_set_join_req
5408 * @details sets a join request
5409 * @param[in,out] handle to the wifi driver,
5410 * @param[in] Index of the bss descriptor
5411 * @return Error code indicating success/failure
5414 * @date 8 March 2012
5417 s32
host_int_set_join_req(WILC_WFIDrvHandle hWFIDrv
, u8
*pu8bssid
,
5418 const u8
*pu8ssid
, size_t ssidLen
,
5419 const u8
*pu8IEs
, size_t IEsLen
,
5420 tWILCpfConnectResult pfConnectResult
, void *pvUserArg
,
5421 u8 u8security
, AUTHTYPE_T tenuAuth_type
,
5425 s32 s32Error
= WILC_SUCCESS
;
5426 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5427 tstrHostIFmsg strHostIFmsg
;
5428 tenuScanConnTimer enuScanConnTimer
;
5430 if (pstrWFIDrv
== NULL
|| pfConnectResult
== NULL
)
5431 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5433 if (hWFIDrv
== NULL
) {
5434 PRINT_ER("Driver not initialized: gWFiDrvHandle = NULL\n");
5435 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
5438 if (pJoinParams
== NULL
) {
5439 PRINT_ER("Unable to Join - JoinParams is NULL\n");
5440 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
5444 * if(gWFiDrvHandle->strWILC_UsrScanReq.u32RcvdChCount == 0)
5446 * PRINT_ER("No scan results exist: Scanning should be done\n");
5447 * WILC_ERRORREPORT(s32Error, WILC_FAIL);
5450 /* prepare the Connect Message */
5451 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5453 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_CONNECT
;
5455 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.u8security
= u8security
;
5456 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.tenuAuth_type
= tenuAuth_type
;
5457 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.u8channel
= u8channel
;
5458 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pfConnectResult
= pfConnectResult
;
5459 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pvUserArg
= pvUserArg
;
5460 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pJoinParams
= pJoinParams
;
5461 strHostIFmsg
.drvHandler
= hWFIDrv
;
5463 if (pu8bssid
!= NULL
) {
5464 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pu8bssid
= (u8
*)WILC_MALLOC(6); /* will be deallocated by the receiving thread */
5465 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pu8bssid
,
5469 if (pu8ssid
!= NULL
) {
5470 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.ssidLen
= ssidLen
;
5471 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pu8ssid
= (u8
*)WILC_MALLOC(ssidLen
); /* will be deallocated by the receiving thread */
5472 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pu8ssid
,
5477 if (pu8IEs
!= NULL
) {
5478 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.IEsLen
= IEsLen
;
5479 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pu8IEs
= (u8
*)WILC_MALLOC(IEsLen
); /* will be deallocated by the receiving thread */
5480 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pu8IEs
,
5483 if (pstrWFIDrv
->enuHostIFstate
< HOST_IF_CONNECTING
) {
5484 pstrWFIDrv
->enuHostIFstate
= HOST_IF_CONNECTING
;
5486 PRINT_D(GENERIC_DBG
, "Don't set state to 'connecting' as state is %d\n", pstrWFIDrv
->enuHostIFstate
);
5488 /* send the message */
5489 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
5491 PRINT_ER("Failed to send message queue: Set join request\n");
5492 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
5495 enuScanConnTimer
= CONNECT_TIMER
;
5496 WILC_TimerStart(&(pstrWFIDrv
->hConnectTimer
), HOST_IF_CONNECT_TIMEOUT
, (void *) hWFIDrv
, NULL
);
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(WILC_WFIDrvHandle 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
), NULL
);
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(WILC_WFIDrvHandle 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 WILC_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
), NULL
);
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(WILC_WFIDrvHandle 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(WILC_WFIDrvHandle 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(WILC_WFIDrvHandle 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(WILC_WFIDrvHandle 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(WILC_WFIDrvHandle 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 WILC_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
), NULL
);
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 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5794 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_Q_IDLE
;
5795 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
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(u32 u32address
)
5812 s32 s32Error
= WILC_SUCCESS
;
5814 tstrHostIFmsg strHostIFmsg
;
5817 /* prepare the set driver handler message */
5819 WILC_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
), NULL
);
5826 WILC_ERRORREPORT(s32Error
, s32Error
);
5827 WILC_CATCH(s32Error
)
5837 s32
host_int_set_operation_mode(WILC_WFIDrvHandle hWFIDrv
, u32 u32mode
)
5839 s32 s32Error
= WILC_SUCCESS
;
5841 tstrHostIFmsg strHostIFmsg
;
5844 /* prepare the set driver handler message */
5846 WILC_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
), NULL
);
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(WILC_WFIDrvHandle 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 WILC_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
), NULL
);
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(WILC_WFIDrvHandle 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(WILC_WFIDrvHandle 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 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5984 WILC_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
), NULL
);
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(WILC_WFIDrvHandle 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(WILC_WFIDrvHandle 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 WILC_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
), NULL
);
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(WILC_WFIDrvHandle 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 WILC_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
), NULL
);
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(WILC_WFIDrvHandle hWFIDrv
, tstrStatistics
*pstrStatistics
)
6139 s32 s32Error
= WILC_SUCCESS
;
6140 tstrHostIFmsg strHostIFmsg
;
6143 /* prepare the Get RSSI Message */
6144 WILC_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
), NULL
);
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(WILC_WFIDrvHandle 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 WILC_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
= (u8
*)WILC_MALLOC(u8ChnlListLen
); /* will be deallocated by the receiving thread */
6212 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.pu8ChnlFreqList
,
6213 pu8ChnlFreqList
, u8ChnlListLen
);
6215 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.IEsLen
= IEsLen
;
6216 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.pu8IEs
= (u8
*)WILC_MALLOC(IEsLen
); /* will be deallocated by the receiving thread */
6217 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.pu8IEs
,
6220 /* send the message */
6221 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
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 WILC_TimerStart(&(pstrWFIDrv
->hScanTimer
), HOST_IF_SCAN_TIMEOUT
, (void *) hWFIDrv
, NULL
);
6232 WILC_CATCH(s32Error
)
6240 * @brief hif_set_cfg
6241 * @details sets configuration wids values
6242 * @param[in,out] handle to the wifi driver,
6243 * @param[in] WID, WID value
6244 * @return Error code indicating success/failure
6247 * @date 8 March 2012
6250 s32
hif_set_cfg(WILC_WFIDrvHandle hWFIDrv
, tstrCfgParamVal
*pstrCfgParamVal
)
6253 s32 s32Error
= WILC_SUCCESS
;
6254 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6256 tstrHostIFmsg strHostIFmsg
;
6259 if (pstrWFIDrv
== NULL
)
6260 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
6261 /* prepare the WiphyParams Message */
6262 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6263 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_CFG_PARAMS
;
6264 strHostIFmsg
.uniHostIFmsgBody
.strHostIFCfgParamAttr
.pstrCfgParamVal
= *pstrCfgParamVal
;
6265 strHostIFmsg
.drvHandler
= hWFIDrv
;
6267 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
6269 WILC_CATCH(s32Error
)
6279 * @brief hif_get_cfg
6280 * @details gets configuration wids values
6281 * @param[in,out] handle to the wifi driver,
6284 * @return Error code indicating success/failure
6288 * @date 8 March 2012
6291 s32
hif_get_cfg(WILC_WFIDrvHandle hWFIDrv
, u16 u16WID
, u16
*pu16WID_Value
)
6293 s32 s32Error
= WILC_SUCCESS
;
6294 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6296 down(&(pstrWFIDrv
->gtOsCfgValuesSem
));
6298 if (pstrWFIDrv
== NULL
) {
6299 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
6300 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
6302 PRINT_D(HOSTINF_DBG
, "Getting configuration parameters\n");
6306 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.bss_type
;
6310 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.auth_type
;
6313 case WID_AUTH_TIMEOUT
:
6314 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.auth_timeout
;
6317 case WID_POWER_MANAGEMENT
:
6318 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.power_mgmt_mode
;
6321 case WID_SHORT_RETRY_LIMIT
:
6322 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.short_retry_limit
;
6325 case WID_LONG_RETRY_LIMIT
:
6326 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.long_retry_limit
;
6329 case WID_FRAG_THRESHOLD
:
6330 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.frag_threshold
;
6333 case WID_RTS_THRESHOLD
:
6334 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.rts_threshold
;
6338 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.preamble_type
;
6341 case WID_SHORT_SLOT_ALLOWED
:
6342 *pu16WID_Value
= (u16
) pstrWFIDrv
->strCfgValues
.short_slot_allowed
;
6345 case WID_11N_TXOP_PROT_DISABLE
:
6346 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.txop_prot_disabled
;
6349 case WID_BEACON_INTERVAL
:
6350 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.beacon_interval
;
6353 case WID_DTIM_PERIOD
:
6354 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.dtim_period
;
6357 case WID_SITE_SURVEY
:
6358 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.site_survey_enabled
;
6361 case WID_SITE_SURVEY_SCAN_TIME
:
6362 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.site_survey_scan_time
;
6365 case WID_ACTIVE_SCAN_TIME
:
6366 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.active_scan_time
;
6369 case WID_PASSIVE_SCAN_TIME
:
6370 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.passive_scan_time
;
6373 case WID_CURRENT_TX_RATE
:
6374 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.curr_tx_rate
;
6381 up(&(pstrWFIDrv
->gtOsCfgValuesSem
));
6383 WILC_CATCH(s32Error
)
6390 /*****************************************************************************/
6391 /* Notification Functions */
6392 /*****************************************************************************/
6394 * @brief notifies host with join and leave requests
6395 * @details This function prepares an Information frame having the
6396 * information about a joining/leaving station.
6397 * @param[in,out] handle to the wifi driver,
6398 * @param[in] 6 byte Sta Adress
6399 * Join or leave flag:
6402 * @return Error code indicating success/failure
6405 * @date 8 March 2012
6408 void host_int_send_join_leave_info_to_host
6409 (u16 assocId
, u8
*stationAddr
, bool joining
)
6413 * @brief notifies host with stations found in scan
6414 * @details sends the beacon/probe response from scan
6415 * @param[in,out] handle to the wifi driver,
6416 * @param[in] Sta Address,
6418 * Rssi of the Station found
6419 * @return Error code indicating success/failure
6422 * @date 8 March 2012
6426 void GetPeriodicRSSI(void *pvArg
)
6428 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)pvArg
;
6430 if (pstrWFIDrv
== NULL
) {
6431 PRINT_ER("Driver handler is NULL\n");
6435 if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_CONNECTED
) {
6436 s32 s32Error
= WILC_SUCCESS
;
6437 tstrHostIFmsg strHostIFmsg
;
6439 /* prepare the Get RSSI Message */
6440 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6442 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_RSSI
;
6443 strHostIFmsg
.drvHandler
= pstrWFIDrv
;
6445 /* send the message */
6446 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
6448 PRINT_ER("Failed to send get host channel param's message queue ");
6452 WILC_TimerStart(&(g_hPeriodicRSSI
), 5000, (void *)pstrWFIDrv
, NULL
);
6456 void host_int_send_network_info_to_host
6457 (u8
*macStartAddress
, u16 u16RxFrameLen
, s8 s8Rssi
)
6461 * @brief host_int_init
6462 * @details host interface initialization function
6463 * @param[in,out] handle to the wifi driver,
6466 * @date 8 March 2012
6469 static u32 u32Intialized
;
6470 static u32 msgQ_created
;
6471 static u32 clients_count
;
6473 s32
host_int_init(WILC_WFIDrvHandle
*phWFIDrv
)
6475 s32 s32Error
= WILC_SUCCESS
;
6476 tstrWILC_WFIDrv
*pstrWFIDrv
;
6478 /*if(u32Intialized == 1)
6480 * PRINT_D(HOSTINF_DBG,"Host interface is previously initialized\n");
6481 * *phWFIDrv = (WILC_WFIDrvHandle)gWFiDrvHandle; //Will be adjusted later for P2P
6484 PRINT_D(HOSTINF_DBG
, "Initializing host interface for client %d\n", clients_count
+ 1);
6486 gbScanWhileConnected
= false;
6488 sema_init(&hWaitResponse
, 0);
6492 /*Allocate host interface private structure*/
6493 pstrWFIDrv
= (tstrWILC_WFIDrv
*)WILC_MALLOC(sizeof(tstrWILC_WFIDrv
));
6494 if (pstrWFIDrv
== NULL
) {
6495 /* WILC_ERRORREPORT(s32Error,WILC_NO_MEM); */
6496 s32Error
= WILC_NO_MEM
;
6497 PRINT_ER("Failed to allocate memory\n");
6500 WILC_memset(pstrWFIDrv
, 0, sizeof(tstrWILC_WFIDrv
));
6501 /*return driver handle to user*/
6502 *phWFIDrv
= (WILC_WFIDrvHandle
)pstrWFIDrv
;
6503 /*save into globl handle*/
6505 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
6507 g_obtainingIP
= false;
6510 PRINT_D(HOSTINF_DBG
, "Global handle pointer value=%p\n", pstrWFIDrv
);
6511 /* /////////////////////////////////////// */
6512 if (clients_count
== 0) {
6513 sema_init(&hSemHostIFthrdEnd
, 0);
6514 sema_init(&hSemDeinitDrvHandle
, 0);
6516 sema_init(&hSemHostIntDeinit
, 1);
6519 sema_init(&(pstrWFIDrv
->hSemTestKeyBlock
), 0);
6520 sema_init(&(pstrWFIDrv
->hSemTestDisconnectBlock
), 0);
6521 sema_init(&(pstrWFIDrv
->hSemGetRSSI
), 0);
6522 sema_init(&(pstrWFIDrv
->hSemGetLINKSPEED
), 0);
6523 sema_init(&(pstrWFIDrv
->hSemGetCHNL
), 0);
6524 sema_init(&(pstrWFIDrv
->hSemInactiveTime
), 0);
6526 /* /////////////////////////////////////// */
6530 PRINT_D(HOSTINF_DBG
, "INIT: CLIENT COUNT %d\n", clients_count
);
6532 if (clients_count
== 0) {
6534 s32Error
= WILC_MsgQueueCreate(&gMsgQHostIF
, NULL
);
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 s32Error
= WILC_TimerCreate(&(g_hPeriodicRSSI
), GetPeriodicRSSI
, NULL
);
6550 PRINT_ER("Failed to creat Timer\n");
6553 WILC_TimerStart(&(g_hPeriodicRSSI
), 5000, (void *)pstrWFIDrv
, NULL
);
6558 s32Error
= WILC_TimerCreate(&(pstrWFIDrv
->hScanTimer
), TimerCB_Scan
, NULL
);
6560 PRINT_ER("Failed to creat Timer\n");
6564 s32Error
= WILC_TimerCreate(&(pstrWFIDrv
->hConnectTimer
), TimerCB_Connect
, NULL
);
6566 PRINT_ER("Failed to creat Timer\n");
6572 /*Remain on channel timer*/
6573 s32Error
= WILC_TimerCreate(&(pstrWFIDrv
->hRemainOnChannel
), ListenTimerCB
, NULL
);
6575 PRINT_ER("Failed to creat Remain-on-channel Timer\n");
6580 sema_init(&(pstrWFIDrv
->gtOsCfgValuesSem
), 1);
6581 down(&(pstrWFIDrv
->gtOsCfgValuesSem
));
6583 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
6584 /* gWFiDrvHandle->bPendingConnRequest = false; */
6586 /*Initialize CFG WIDS Defualt Values*/
6588 pstrWFIDrv
->strCfgValues
.site_survey_enabled
= SITE_SURVEY_OFF
;
6589 pstrWFIDrv
->strCfgValues
.scan_source
= DEFAULT_SCAN
;
6590 pstrWFIDrv
->strCfgValues
.active_scan_time
= ACTIVE_SCAN_TIME
;
6591 pstrWFIDrv
->strCfgValues
.passive_scan_time
= PASSIVE_SCAN_TIME
;
6592 pstrWFIDrv
->strCfgValues
.curr_tx_rate
= AUTORATE
;
6597 pstrWFIDrv
->u64P2p_MgmtTimeout
= 0;
6601 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",
6603 pstrWFIDrv
->strCfgValues
.site_survey_enabled
, pstrWFIDrv
->strCfgValues
.scan_source
,
6604 pstrWFIDrv
->strCfgValues
.active_scan_time
, pstrWFIDrv
->strCfgValues
.passive_scan_time
,
6605 pstrWFIDrv
->strCfgValues
.curr_tx_rate
);
6608 up(&(pstrWFIDrv
->gtOsCfgValuesSem
));
6610 /*TODO Code to setup simulation to be removed later*/
6611 /*Intialize configurator module*/
6612 s32Error
= CoreConfiguratorInit();
6614 PRINT_ER("Failed to initialize core configurator\n");
6619 clients_count
++; /* increase number of created entities */
6625 if (pstrWFIDrv
!= NULL
)
6626 WILC_FREE(pstrWFIDrv
);
6629 WILC_TimerDestroy(&(pstrWFIDrv
->hRemainOnChannel
), NULL
);
6632 up(&(pstrWFIDrv
->gtOsCfgValuesSem
));
6633 WILC_TimerDestroy(&(pstrWFIDrv
->hConnectTimer
), NULL
);
6635 WILC_TimerDestroy(&(pstrWFIDrv
->hScanTimer
), NULL
);
6637 kthread_stop(HostIFthreadHandler
);
6639 WILC_MsgQueueDestroy(&gMsgQHostIF
, NULL
);
6646 * @brief host_int_deinit
6647 * @details host interface initialization function
6648 * @param[in,out] handle to the wifi driver,
6651 * @date 8 March 2012
6655 s32
host_int_deinit(WILC_WFIDrvHandle hWFIDrv
)
6657 s32 s32Error
= WILC_SUCCESS
;
6658 tstrHostIFmsg strHostIFmsg
;
6661 /*obtain driver handle*/
6662 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6663 /*if(u32Intialized == 0)
6665 * PRINT_ER("Host Interface is not initialized\n");
6671 if (pstrWFIDrv
== NULL
) {
6672 PRINT_ER("pstrWFIDrv = NULL\n");
6676 down(&hSemHostIntDeinit
);
6678 terminated_handle
= pstrWFIDrv
;
6679 PRINT_D(HOSTINF_DBG
, "De-initializing host interface for client %d\n", clients_count
);
6682 /*Destroy all timers before acquiring hSemDeinitDrvHandle*/
6683 /*to guarantee handling all messages befor proceeding*/
6684 if (WILC_TimerDestroy(&(pstrWFIDrv
->hScanTimer
), NULL
)) {
6685 PRINT_D(HOSTINF_DBG
, ">> Scan timer is active\n");
6686 /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */
6689 if (WILC_TimerDestroy(&(pstrWFIDrv
->hConnectTimer
), NULL
)) {
6690 PRINT_D(HOSTINF_DBG
, ">> Connect timer is active\n");
6691 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6695 if (WILC_TimerDestroy(&(g_hPeriodicRSSI
), NULL
)) {
6696 PRINT_D(HOSTINF_DBG
, ">> Connect timer is active\n");
6697 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6701 /*Destroy Remain-onchannel Timer*/
6702 WILC_TimerDestroy(&(pstrWFIDrv
->hRemainOnChannel
), NULL
);
6705 host_int_set_wfi_drv_handler((u32
)NULL
);
6706 down(&hSemDeinitDrvHandle
);
6709 /*Calling the CFG80211 scan done function with the abort flag set to true*/
6710 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
6711 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult(SCAN_EVENT_ABORTED
, NULL
,
6712 pstrWFIDrv
->strWILC_UsrScanReq
.u32UserScanPvoid
, NULL
);
6714 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
= NULL
;
6716 /*deinit configurator and simulator*/
6717 CoreConfiguratorDeInit();
6719 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
6721 gbScanWhileConnected
= false;
6723 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6725 if (clients_count
== 1) {
6726 if (WILC_TimerDestroy(&g_hPeriodicRSSI
, NULL
)) {
6727 PRINT_D(HOSTINF_DBG
, ">> Connect timer is active\n");
6728 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6730 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_EXIT
;
6731 strHostIFmsg
.drvHandler
= hWFIDrv
;
6734 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
6735 if (s32Error
!= WILC_SUCCESS
)
6736 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error
);
6738 down(&hSemHostIFthrdEnd
);
6742 WILC_MsgQueueDestroy(&gMsgQHostIF
, NULL
);
6746 down(&(pstrWFIDrv
->gtOsCfgValuesSem
));
6748 /*Setting the gloabl driver handler with NULL*/
6750 /* gWFiDrvHandle = NULL; */
6751 if (pstrWFIDrv
!= NULL
) {
6752 WILC_FREE(pstrWFIDrv
);
6753 /* pstrWFIDrv=NULL; */
6757 clients_count
--; /* Decrease number of created entities */
6758 terminated_handle
= NULL
;
6759 up(&hSemHostIntDeinit
);
6765 * @brief NetworkInfoReceived
6766 * @details function to to be called when network info packet is received
6767 * @param[in] pu8Buffer the received packet
6768 * @param[in] u32Length length of the received packet
6775 void NetworkInfoReceived(u8
*pu8Buffer
, u32 u32Length
)
6777 s32 s32Error
= WILC_SUCCESS
;
6778 tstrHostIFmsg strHostIFmsg
;
6780 tstrWILC_WFIDrv
*pstrWFIDrv
= NULL
;
6782 drvHandler
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
6783 pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
6788 if (pstrWFIDrv
== NULL
|| pstrWFIDrv
== terminated_handle
) {
6789 PRINT_ER("NetworkInfo received but driver not init[%p]\n", pstrWFIDrv
);
6793 /* prepare the Asynchronous Network Info message */
6794 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6796 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_RCVD_NTWRK_INFO
;
6797 strHostIFmsg
.drvHandler
= pstrWFIDrv
;
6799 strHostIFmsg
.uniHostIFmsgBody
.strRcvdNetworkInfo
.u32Length
= u32Length
;
6800 strHostIFmsg
.uniHostIFmsgBody
.strRcvdNetworkInfo
.pu8Buffer
= (u8
*)WILC_MALLOC(u32Length
); /* will be deallocated by the receiving thread */
6801 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strRcvdNetworkInfo
.pu8Buffer
,
6802 pu8Buffer
, u32Length
);
6804 /* send the message */
6805 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
6807 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error
);
6814 * @brief GnrlAsyncInfoReceived
6815 * @details function to be called when general Asynchronous info packet is received
6816 * @param[in] pu8Buffer the received packet
6817 * @param[in] u32Length length of the received packet
6824 void GnrlAsyncInfoReceived(u8
*pu8Buffer
, u32 u32Length
)
6826 s32 s32Error
= WILC_SUCCESS
;
6827 tstrHostIFmsg strHostIFmsg
;
6829 tstrWILC_WFIDrv
*pstrWFIDrv
= NULL
;
6832 down(&hSemHostIntDeinit
);
6834 drvHandler
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
6835 pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
6836 PRINT_D(HOSTINF_DBG
, "General asynchronous info packet received\n");
6839 if (pstrWFIDrv
== NULL
|| pstrWFIDrv
== terminated_handle
) {
6840 PRINT_D(HOSTINF_DBG
, "Wifi driver handler is equal to NULL\n");
6842 up(&hSemHostIntDeinit
);
6846 if (pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
== NULL
) {
6847 /* received mac status is not needed when there is no current Connect Request */
6848 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
6850 up(&hSemHostIntDeinit
);
6854 /* prepare the General Asynchronous Info message */
6855 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6858 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO
;
6859 strHostIFmsg
.drvHandler
= pstrWFIDrv
;
6862 strHostIFmsg
.uniHostIFmsgBody
.strRcvdGnrlAsyncInfo
.u32Length
= u32Length
;
6863 strHostIFmsg
.uniHostIFmsgBody
.strRcvdGnrlAsyncInfo
.pu8Buffer
= (u8
*)WILC_MALLOC(u32Length
); /* will be deallocated by the receiving thread */
6864 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strRcvdGnrlAsyncInfo
.pu8Buffer
,
6865 pu8Buffer
, u32Length
);
6867 /* send the message */
6868 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
6870 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error
);
6873 up(&hSemHostIntDeinit
);
6878 * @brief host_int_ScanCompleteReceived
6879 * @details Setting scan complete received notifcation in message queue
6880 * @param[in] u8* pu8Buffer, u32 u32Length
6881 * @return Error code.
6886 void host_int_ScanCompleteReceived(u8
*pu8Buffer
, u32 u32Length
)
6888 s32 s32Error
= WILC_SUCCESS
;
6889 tstrHostIFmsg strHostIFmsg
;
6891 tstrWILC_WFIDrv
*pstrWFIDrv
= NULL
;
6893 drvHandler
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
6894 pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
6897 PRINT_D(GENERIC_DBG
, "Scan notification received %p\n", pstrWFIDrv
);
6899 if (pstrWFIDrv
== NULL
|| pstrWFIDrv
== terminated_handle
)
6902 /*if there is an ongoing scan request*/
6903 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
6904 /* prepare theScan Done message */
6905 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6907 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_RCVD_SCAN_COMPLETE
;
6908 strHostIFmsg
.drvHandler
= pstrWFIDrv
;
6911 /* will be deallocated by the receiving thread */
6912 /*no need to send message body*/
6914 /*strHostIFmsg.uniHostIFmsgBody.strScanComplete.u32Length = u32Length;
6915 * strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer = (u8*)WILC_MALLOC(u32Length);
6916 * WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer,
6917 * pu8Buffer, u32Length); */
6919 /* send the message */
6920 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
6922 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error
);
6932 * @brief host_int_remain_on_channel
6934 * @param[in] Handle to wifi driver
6935 * Duration to remain on channel
6936 * Channel to remain on
6937 * Pointer to fn to be called on receive frames in listen state
6938 * Pointer to remain-on-channel expired fn
6940 * @return Error code.
6945 s32
host_int_remain_on_channel(WILC_WFIDrvHandle hWFIDrv
, u32 u32SessionID
, u32 u32duration
, u16 chan
, tWILCpfRemainOnChanExpired RemainOnChanExpired
, tWILCpfRemainOnChanReady RemainOnChanReady
, void *pvUserArg
)
6947 s32 s32Error
= WILC_SUCCESS
;
6948 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6949 tstrHostIFmsg strHostIFmsg
;
6951 if (pstrWFIDrv
== NULL
)
6952 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
6954 /* prepare the remainonchan Message */
6955 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6957 /* prepare the WiphyParams Message */
6958 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_REMAIN_ON_CHAN
;
6959 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.u16Channel
= chan
;
6960 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.pRemainOnChanExpired
= RemainOnChanExpired
;
6961 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.pRemainOnChanReady
= RemainOnChanReady
;
6962 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.pVoid
= pvUserArg
;
6963 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.u32duration
= u32duration
;
6964 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.u32ListenSessionID
= u32SessionID
;
6965 strHostIFmsg
.drvHandler
= hWFIDrv
;
6967 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
6969 WILC_ERRORREPORT(s32Error
, s32Error
);
6970 WILC_CATCH(s32Error
)
6979 * @brief host_int_ListenStateExpired
6981 * @param[in] Handle to wifi driver
6982 * Duration to remain on channel
6983 * Channel to remain on
6984 * Pointer to fn to be called on receive frames in listen state
6985 * Pointer to remain-on-channel expired fn
6987 * @return Error code.
6992 s32
host_int_ListenStateExpired(WILC_WFIDrvHandle hWFIDrv
, u32 u32SessionID
)
6994 s32 s32Error
= WILC_SUCCESS
;
6995 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6996 tstrHostIFmsg strHostIFmsg
;
6998 if (pstrWFIDrv
== NULL
)
6999 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7001 /*Stopping remain-on-channel timer*/
7002 WILC_TimerStop(&(pstrWFIDrv
->hRemainOnChannel
), NULL
);
7004 /* prepare the timer fire Message */
7005 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7006 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_LISTEN_TIMER_FIRED
;
7007 strHostIFmsg
.drvHandler
= hWFIDrv
;
7008 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.u32ListenSessionID
= u32SessionID
;
7010 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7012 WILC_ERRORREPORT(s32Error
, s32Error
);
7013 WILC_CATCH(s32Error
)
7021 * @brief host_int_frame_register
7023 * @param[in] Handle to wifi driver
7024 * @return Error code.
7028 s32
host_int_frame_register(WILC_WFIDrvHandle hWFIDrv
, u16 u16FrameType
, bool bReg
)
7030 s32 s32Error
= WILC_SUCCESS
;
7031 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7032 tstrHostIFmsg strHostIFmsg
;
7034 if (pstrWFIDrv
== NULL
)
7035 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7037 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7039 /* prepare the WiphyParams Message */
7040 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_REGISTER_FRAME
;
7041 switch (u16FrameType
) {
7043 PRINT_D(HOSTINF_DBG
, "ACTION\n");
7044 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRegisterFrame
.u8Regid
= ACTION_FRM_IDX
;
7048 PRINT_D(HOSTINF_DBG
, "PROBE REQ\n");
7049 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRegisterFrame
.u8Regid
= PROBE_REQ_IDX
;
7053 PRINT_D(HOSTINF_DBG
, "Not valid frame type\n");
7056 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRegisterFrame
.u16FrameType
= u16FrameType
;
7057 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRegisterFrame
.bReg
= bReg
;
7058 strHostIFmsg
.drvHandler
= hWFIDrv
;
7060 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7062 WILC_ERRORREPORT(s32Error
, s32Error
);
7063 WILC_CATCH(s32Error
)
7074 #ifdef WILC_AP_EXTERNAL_MLME
7076 * @brief host_int_add_beacon
7077 * @details Setting add beacon params in message queue
7078 * @param[in] WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
7079 * u32 u32DTIMPeriod,u32 u32HeadLen, u8* pu8Head,
7080 * u32 u32TailLen, u8* pu8Tail
7081 * @return Error code.
7086 s32
host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv
, u32 u32Interval
,
7088 u32 u32HeadLen
, u8
*pu8Head
,
7089 u32 u32TailLen
, u8
*pu8Tail
)
7091 s32 s32Error
= WILC_SUCCESS
;
7092 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7093 tstrHostIFmsg strHostIFmsg
;
7094 tstrHostIFSetBeacon
*pstrSetBeaconParam
= &strHostIFmsg
.uniHostIFmsgBody
.strHostIFSetBeacon
;
7096 if (pstrWFIDrv
== NULL
)
7097 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7099 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7101 PRINT_D(HOSTINF_DBG
, "Setting adding beacon message queue params\n");
7104 /* prepare the WiphyParams Message */
7105 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_ADD_BEACON
;
7106 strHostIFmsg
.drvHandler
= hWFIDrv
;
7107 pstrSetBeaconParam
->u32Interval
= u32Interval
;
7108 pstrSetBeaconParam
->u32DTIMPeriod
= u32DTIMPeriod
;
7109 pstrSetBeaconParam
->u32HeadLen
= u32HeadLen
;
7110 pstrSetBeaconParam
->pu8Head
= (u8
*)WILC_MALLOC(u32HeadLen
);
7111 if (pstrSetBeaconParam
->pu8Head
== NULL
)
7112 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
7113 WILC_memcpy(pstrSetBeaconParam
->pu8Head
, pu8Head
, u32HeadLen
);
7114 pstrSetBeaconParam
->u32TailLen
= u32TailLen
;
7116 /* Bug 4599 : if tail length = 0 skip allocating & copying */
7117 if (u32TailLen
> 0) {
7118 pstrSetBeaconParam
->pu8Tail
= (u8
*)WILC_MALLOC(u32TailLen
);
7119 if (pstrSetBeaconParam
->pu8Tail
== NULL
)
7120 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
7121 WILC_memcpy(pstrSetBeaconParam
->pu8Tail
, pu8Tail
, u32TailLen
);
7123 pstrSetBeaconParam
->pu8Tail
= NULL
;
7126 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7128 WILC_ERRORREPORT(s32Error
, s32Error
);
7130 WILC_CATCH(s32Error
)
7132 if (pstrSetBeaconParam
->pu8Head
!= NULL
)
7133 WILC_FREE(pstrSetBeaconParam
->pu8Head
);
7135 if (pstrSetBeaconParam
->pu8Tail
!= NULL
)
7136 WILC_FREE(pstrSetBeaconParam
->pu8Tail
);
7145 * @brief host_int_del_beacon
7146 * @details Setting add beacon params in message queue
7147 * @param[in] WILC_WFIDrvHandle hWFIDrv
7148 * @return Error code.
7153 s32
host_int_del_beacon(WILC_WFIDrvHandle hWFIDrv
)
7155 s32 s32Error
= WILC_SUCCESS
;
7156 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7157 tstrHostIFmsg strHostIFmsg
;
7159 if (pstrWFIDrv
== NULL
)
7160 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7162 /* prepare the WiphyParams Message */
7163 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_DEL_BEACON
;
7164 strHostIFmsg
.drvHandler
= hWFIDrv
;
7165 PRINT_D(HOSTINF_DBG
, "Setting deleting beacon message queue params\n");
7167 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7168 WILC_ERRORCHECK(s32Error
);
7170 WILC_CATCH(s32Error
)
7178 * @brief host_int_add_station
7179 * @details Setting add station params in message queue
7180 * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7181 * @return Error code.
7186 s32
host_int_add_station(WILC_WFIDrvHandle hWFIDrv
, tstrWILC_AddStaParam
*pstrStaParams
)
7188 s32 s32Error
= WILC_SUCCESS
;
7189 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7190 tstrHostIFmsg strHostIFmsg
;
7191 tstrWILC_AddStaParam
*pstrAddStationMsg
= &strHostIFmsg
.uniHostIFmsgBody
.strAddStaParam
;
7194 if (pstrWFIDrv
== NULL
)
7195 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7197 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7199 PRINT_D(HOSTINF_DBG
, "Setting adding station message queue params\n");
7202 /* prepare the WiphyParams Message */
7203 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_ADD_STATION
;
7204 strHostIFmsg
.drvHandler
= hWFIDrv
;
7206 WILC_memcpy(pstrAddStationMsg
, pstrStaParams
, sizeof(tstrWILC_AddStaParam
));
7207 if (pstrAddStationMsg
->u8NumRates
> 0) {
7208 u8
*rates
= WILC_MALLOC(pstrAddStationMsg
->u8NumRates
);
7210 WILC_NULLCHECK(s32Error
, rates
);
7212 WILC_memcpy(rates
, pstrStaParams
->pu8Rates
, pstrAddStationMsg
->u8NumRates
);
7213 pstrAddStationMsg
->pu8Rates
= rates
;
7217 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7219 WILC_ERRORREPORT(s32Error
, s32Error
);
7221 WILC_CATCH(s32Error
)
7228 * @brief host_int_del_station
7229 * @details Setting delete station params in message queue
7230 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr
7231 * @return Error code.
7236 s32
host_int_del_station(WILC_WFIDrvHandle hWFIDrv
, const u8
*pu8MacAddr
)
7238 s32 s32Error
= WILC_SUCCESS
;
7239 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7240 tstrHostIFmsg strHostIFmsg
;
7241 tstrHostIFDelSta
*pstrDelStationMsg
= &strHostIFmsg
.uniHostIFmsgBody
.strDelStaParam
;
7243 if (pstrWFIDrv
== NULL
)
7244 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7246 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7248 PRINT_D(HOSTINF_DBG
, "Setting deleting station message queue params\n");
7252 /* prepare the WiphyParams Message */
7253 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_DEL_STATION
;
7254 strHostIFmsg
.drvHandler
= hWFIDrv
;
7256 /*BugID_4795: Handling situation of deleting all stations*/
7257 if (pu8MacAddr
== NULL
)
7258 WILC_memset(pstrDelStationMsg
->au8MacAddr
, 255, ETH_ALEN
);
7260 WILC_memcpy(pstrDelStationMsg
->au8MacAddr
, pu8MacAddr
, ETH_ALEN
);
7262 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7264 WILC_ERRORREPORT(s32Error
, s32Error
);
7266 WILC_CATCH(s32Error
)
7272 * @brief host_int_del_allstation
7273 * @details Setting del station params in message queue
7274 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]s
7275 * @return Error code.
7280 s32
host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv
, u8 pu8MacAddr
[][ETH_ALEN
])
7282 s32 s32Error
= WILC_SUCCESS
;
7283 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7284 tstrHostIFmsg strHostIFmsg
;
7285 tstrHostIFDelAllSta
*pstrDelAllStationMsg
= &strHostIFmsg
.uniHostIFmsgBody
.strHostIFDelAllSta
;
7286 u8 au8Zero_Buff
[ETH_ALEN
] = {0};
7291 if (pstrWFIDrv
== NULL
)
7292 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7294 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7296 PRINT_D(HOSTINF_DBG
, "Setting deauthenticating station message queue params\n");
7298 /* prepare the WiphyParams Message */
7299 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_DEL_ALL_STA
;
7300 strHostIFmsg
.drvHandler
= hWFIDrv
;
7302 /* Handling situation of deauthenticing all associated stations*/
7303 for (i
= 0; i
< MAX_NUM_STA
; i
++) {
7304 if (memcmp(pu8MacAddr
[i
], au8Zero_Buff
, ETH_ALEN
)) {
7305 WILC_memcpy(pstrDelAllStationMsg
->au8Sta_DelAllSta
[i
], pu8MacAddr
[i
], ETH_ALEN
);
7306 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],
7307 pstrDelAllStationMsg
->au8Sta_DelAllSta
[i
][5]);
7312 PRINT_D(CFG80211_DBG
, "NO ASSOCIATED STAS\n");
7316 pstrDelAllStationMsg
->u8Num_AssocSta
= u8AssocNumb
;
7317 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7321 WILC_ERRORREPORT(s32Error
, s32Error
);
7323 WILC_CATCH(s32Error
)
7327 down(&hWaitResponse
);
7334 * @brief host_int_edit_station
7335 * @details Setting edit station params in message queue
7336 * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7337 * @return Error code.
7342 s32
host_int_edit_station(WILC_WFIDrvHandle hWFIDrv
, tstrWILC_AddStaParam
*pstrStaParams
)
7344 s32 s32Error
= WILC_SUCCESS
;
7345 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7346 tstrHostIFmsg strHostIFmsg
;
7347 tstrWILC_AddStaParam
*pstrAddStationMsg
= &strHostIFmsg
.uniHostIFmsgBody
.strAddStaParam
;
7349 if (pstrWFIDrv
== NULL
)
7350 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7352 PRINT_D(HOSTINF_DBG
, "Setting editing station message queue params\n");
7354 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7357 /* prepare the WiphyParams Message */
7358 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_EDIT_STATION
;
7359 strHostIFmsg
.drvHandler
= hWFIDrv
;
7361 WILC_memcpy(pstrAddStationMsg
, pstrStaParams
, sizeof(tstrWILC_AddStaParam
));
7362 if (pstrAddStationMsg
->u8NumRates
> 0) {
7363 u8
*rates
= WILC_MALLOC(pstrAddStationMsg
->u8NumRates
);
7365 WILC_NULLCHECK(s32Error
, rates
);
7366 WILC_memcpy(rates
, pstrStaParams
->pu8Rates
, pstrAddStationMsg
->u8NumRates
);
7367 pstrAddStationMsg
->pu8Rates
= rates
;
7370 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7372 WILC_ERRORREPORT(s32Error
, s32Error
);
7373 WILC_CATCH(s32Error
)
7378 #endif /*WILC_AP_EXTERNAL_MLME*/
7379 uint32_t wilc_get_chipid(uint8_t);
7381 s32
host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv
, bool bIsEnabled
, u32 u32Timeout
)
7383 s32 s32Error
= WILC_SUCCESS
;
7384 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7385 tstrHostIFmsg strHostIFmsg
;
7386 tstrHostIfPowerMgmtParam
*pstrPowerMgmtParam
= &strHostIFmsg
.uniHostIFmsgBody
.strPowerMgmtparam
;
7388 PRINT_INFO(HOSTINF_DBG
, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled
);
7390 if (pstrWFIDrv
== NULL
)
7391 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7393 PRINT_D(HOSTINF_DBG
, "Setting Power management message queue params\n");
7395 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7398 /* prepare the WiphyParams Message */
7399 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_POWER_MGMT
;
7400 strHostIFmsg
.drvHandler
= hWFIDrv
;
7402 pstrPowerMgmtParam
->bIsEnabled
= bIsEnabled
;
7403 pstrPowerMgmtParam
->u32Timeout
= u32Timeout
;
7406 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7408 WILC_ERRORREPORT(s32Error
, s32Error
);
7409 WILC_CATCH(s32Error
)
7415 s32
host_int_setup_multicast_filter(WILC_WFIDrvHandle hWFIDrv
, bool bIsEnabled
, u32 u32count
)
7417 s32 s32Error
= WILC_SUCCESS
;
7419 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7420 tstrHostIFmsg strHostIFmsg
;
7421 tstrHostIFSetMulti
*pstrMulticastFilterParam
= &strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetMulti
;
7424 if (pstrWFIDrv
== NULL
)
7425 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7427 PRINT_D(HOSTINF_DBG
, "Setting Multicast Filter params\n");
7429 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7432 /* prepare the WiphyParams Message */
7433 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SET_MULTICAST_FILTER
;
7434 strHostIFmsg
.drvHandler
= hWFIDrv
;
7436 pstrMulticastFilterParam
->bIsEnabled
= bIsEnabled
;
7437 pstrMulticastFilterParam
->u32count
= u32count
;
7439 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7441 WILC_ERRORREPORT(s32Error
, s32Error
);
7442 WILC_CATCH(s32Error
)
7450 /*Bug4218: Parsing Join Param*/
7451 #ifdef WILC_PARSE_SCAN_IN_HOST
7453 /*Bug4218: Parsing Join Param*/
7455 * @brief host_int_ParseJoinBssParam
7456 * @details Parse Needed Join Parameters and save it in a new JoinBssParam entry
7457 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7462 static void *host_int_ParseJoinBssParam(tstrNetworkInfo
*ptstrNetworkInfo
)
7464 tstrJoinBssParam
*pNewJoinBssParam
= NULL
;
7473 u8 pcipherTotalCount
= 0;
7474 u8 authTotalCount
= 0;
7477 pu8IEs
= ptstrNetworkInfo
->pu8IEs
;
7478 u16IEsLen
= ptstrNetworkInfo
->u16IEsLen
;
7480 pNewJoinBssParam
= WILC_MALLOC(sizeof(tstrJoinBssParam
));
7481 if (pNewJoinBssParam
!= NULL
) {
7482 WILC_memset(pNewJoinBssParam
, 0, sizeof(tstrJoinBssParam
));
7483 pNewJoinBssParam
->dtim_period
= ptstrNetworkInfo
->u8DtimPeriod
;
7484 pNewJoinBssParam
->beacon_period
= ptstrNetworkInfo
->u16BeaconPeriod
;
7485 pNewJoinBssParam
->cap_info
= ptstrNetworkInfo
->u16CapInfo
;
7486 WILC_memcpy(pNewJoinBssParam
->au8bssid
, ptstrNetworkInfo
->au8bssid
, 6);
7488 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/
7489 WILC_memcpy((u8
*)pNewJoinBssParam
->ssid
, ptstrNetworkInfo
->au8ssid
, ptstrNetworkInfo
->u8SsidLen
+ 1);
7490 pNewJoinBssParam
->ssidLen
= ptstrNetworkInfo
->u8SsidLen
;
7491 WILC_memset(pNewJoinBssParam
->rsn_pcip_policy
, 0xFF, 3);
7492 WILC_memset(pNewJoinBssParam
->rsn_auth_policy
, 0xFF, 3);
7493 /*for(i=0; i<pNewJoinBssParam->ssidLen;i++)
7494 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/
7496 /* parse supported rates: */
7497 while (index
< u16IEsLen
) {
7498 /* supportedRates IE */
7499 if (pu8IEs
[index
] == SUPP_RATES_IE
) {
7500 /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */
7501 suppRatesNo
= pu8IEs
[index
+ 1];
7502 pNewJoinBssParam
->supp_rates
[0] = suppRatesNo
;
7503 index
+= 2; /* skipping ID and length bytes; */
7505 for (i
= 0; i
< suppRatesNo
; i
++) {
7506 pNewJoinBssParam
->supp_rates
[i
+ 1] = pu8IEs
[index
+ i
];
7507 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */
7509 index
+= suppRatesNo
;
7512 /* Ext SupportedRates IE */
7513 else if (pu8IEs
[index
] == EXT_SUPP_RATES_IE
) {
7514 /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */
7515 /* checking if no of ext. supp and supp rates < max limit */
7516 extSuppRatesNo
= pu8IEs
[index
+ 1];
7517 if (extSuppRatesNo
> (MAX_RATES_SUPPORTED
- suppRatesNo
))
7518 pNewJoinBssParam
->supp_rates
[0] = MAX_RATES_SUPPORTED
;
7520 pNewJoinBssParam
->supp_rates
[0] += extSuppRatesNo
;
7522 /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */
7523 for (i
= 0; i
< (pNewJoinBssParam
->supp_rates
[0] - suppRatesNo
); i
++) {
7524 pNewJoinBssParam
->supp_rates
[suppRatesNo
+ i
+ 1] = pu8IEs
[index
+ i
];
7525 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */
7527 index
+= extSuppRatesNo
;
7531 else if (pu8IEs
[index
] == HT_CAPABILITY_IE
) {
7532 /* if IE found set the flag */
7533 pNewJoinBssParam
->ht_capable
= true;
7534 index
+= pu8IEs
[index
+ 1] + 2; /* ID,Length bytes and IE body */
7535 /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */
7537 } else if ((pu8IEs
[index
] == WMM_IE
) && /* WMM Element ID */
7538 (pu8IEs
[index
+ 2] == 0x00) && (pu8IEs
[index
+ 3] == 0x50) &&
7539 (pu8IEs
[index
+ 4] == 0xF2) && /* OUI */
7540 (pu8IEs
[index
+ 5] == 0x02) && /* OUI Type */
7541 ((pu8IEs
[index
+ 6] == 0x00) || (pu8IEs
[index
+ 6] == 0x01)) && /* OUI Sub Type */
7542 (pu8IEs
[index
+ 7] == 0x01)) {
7543 /* Presence of WMM Info/Param element indicates WMM capability */
7544 pNewJoinBssParam
->wmm_cap
= true;
7546 /* Check if Bit 7 is set indicating U-APSD capability */
7547 if (pu8IEs
[index
+ 8] & (1 << 7))
7548 pNewJoinBssParam
->uapsd_cap
= true;
7549 index
+= pu8IEs
[index
+ 1] + 2;
7553 else if ((pu8IEs
[index
] == P2P_IE
) && /* P2P Element ID */
7554 (pu8IEs
[index
+ 2] == 0x50) && (pu8IEs
[index
+ 3] == 0x6f) &&
7555 (pu8IEs
[index
+ 4] == 0x9a) && /* OUI */
7556 (pu8IEs
[index
+ 5] == 0x09) && (pu8IEs
[index
+ 6] == 0x0c)) { /* OUI Type */
7559 pNewJoinBssParam
->tsf
= ptstrNetworkInfo
->u32Tsf
;
7560 pNewJoinBssParam
->u8NoaEnbaled
= 1;
7561 pNewJoinBssParam
->u8Index
= pu8IEs
[index
+ 9];
7563 /* Check if Bit 7 is set indicating Opss capability */
7564 if (pu8IEs
[index
+ 10] & (1 << 7)) {
7565 pNewJoinBssParam
->u8OppEnable
= 1;
7566 pNewJoinBssParam
->u8CtWindow
= pu8IEs
[index
+ 10];
7568 pNewJoinBssParam
->u8OppEnable
= 0;
7570 PRINT_D(GENERIC_DBG
, "P2P Dump\n");
7571 for (i
= 0; i
< pu8IEs
[index
+ 7]; i
++)
7572 PRINT_D(GENERIC_DBG
, " %x\n", pu8IEs
[index
+ 9 + i
]);
7574 pNewJoinBssParam
->u8Count
= pu8IEs
[index
+ 11];
7575 u16P2P_count
= index
+ 12;
7577 WILC_memcpy(pNewJoinBssParam
->au8Duration
, pu8IEs
+ u16P2P_count
, 4);
7580 WILC_memcpy(pNewJoinBssParam
->au8Interval
, pu8IEs
+ u16P2P_count
, 4);
7583 WILC_memcpy(pNewJoinBssParam
->au8StartTime
, pu8IEs
+ u16P2P_count
, 4);
7585 index
+= pu8IEs
[index
+ 1] + 2;
7590 else if ((pu8IEs
[index
] == RSN_IE
) ||
7591 ((pu8IEs
[index
] == WPA_IE
) && (pu8IEs
[index
+ 2] == 0x00) &&
7592 (pu8IEs
[index
+ 3] == 0x50) && (pu8IEs
[index
+ 4] == 0xF2) &&
7593 (pu8IEs
[index
+ 5] == 0x01))) {
7594 u16 rsnIndex
= index
;
7595 /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]);
7596 * for(i=0; i<pu8IEs[rsnIndex+1]; i++)
7598 * PRINT_D(HOSTINF_DBG,"%0x ",pu8IEs[rsnIndex+2+i]);
7600 if (pu8IEs
[rsnIndex
] == RSN_IE
) {
7601 pNewJoinBssParam
->mode_802_11i
= 2;
7602 /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */
7603 } else { /* check if rsn was previously parsed */
7604 if (pNewJoinBssParam
->mode_802_11i
== 0)
7605 pNewJoinBssParam
->mode_802_11i
= 1;
7606 /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */
7609 rsnIndex
+= 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */
7610 pNewJoinBssParam
->rsn_grp_policy
= pu8IEs
[rsnIndex
];
7612 /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x\n",pNewJoinBssParam->rsn_grp_policy); */
7613 /* initialize policies with invalid values */
7615 jumpOffset
= pu8IEs
[rsnIndex
] * 4; /* total no.of bytes of pcipher field (count*4) */
7617 /*parsing pairwise cipher*/
7619 /* saving 3 pcipher max. */
7620 pcipherCount
= (pu8IEs
[rsnIndex
] > 3) ? 3 : pu8IEs
[rsnIndex
];
7621 rsnIndex
+= 2; /* jump 2 bytes of pcipher count */
7623 /* PRINT_D(HOSTINF_DBG,"\npcipher:%d\n",pcipherCount); */
7624 for (i
= pcipherTotalCount
, j
= 0; i
< pcipherCount
+ pcipherTotalCount
&& i
< 3; i
++, j
++) {
7625 /* each count corresponds to 4 bytes, only last byte is saved */
7626 pNewJoinBssParam
->rsn_pcip_policy
[i
] = pu8IEs
[rsnIndex
+ ((j
+ 1) * 4) - 1];
7627 /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */
7629 pcipherTotalCount
+= pcipherCount
;
7630 rsnIndex
+= jumpOffset
;
7632 jumpOffset
= pu8IEs
[rsnIndex
] * 4;
7634 /*parsing AKM suite (auth_policy)*/
7635 /* saving 3 auth policies max. */
7636 authCount
= (pu8IEs
[rsnIndex
] > 3) ? 3 : pu8IEs
[rsnIndex
];
7637 rsnIndex
+= 2; /* jump 2 bytes of pcipher count */
7639 for (i
= authTotalCount
, j
= 0; i
< authTotalCount
+ authCount
; i
++, j
++) {
7640 /* each count corresponds to 4 bytes, only last byte is saved */
7641 pNewJoinBssParam
->rsn_auth_policy
[i
] = pu8IEs
[rsnIndex
+ ((j
+ 1) * 4) - 1];
7643 authTotalCount
+= authCount
;
7644 rsnIndex
+= jumpOffset
;
7645 /*pasring rsn cap. only if rsn IE*/
7646 if (pu8IEs
[index
] == RSN_IE
) {
7647 pNewJoinBssParam
->rsn_cap
[0] = pu8IEs
[rsnIndex
];
7648 pNewJoinBssParam
->rsn_cap
[1] = pu8IEs
[rsnIndex
+ 1];
7651 pNewJoinBssParam
->rsn_found
= true;
7652 index
+= pu8IEs
[index
+ 1] + 2; /* ID,Length bytes and IE body */
7655 index
+= pu8IEs
[index
+ 1] + 2; /* ID,Length bytes and IE body */
7662 return (void *)pNewJoinBssParam
;
7666 void host_int_freeJoinParams(void *pJoinParams
)
7668 if ((tstrJoinBssParam
*)pJoinParams
!= NULL
)
7669 WILC_FREE((tstrJoinBssParam
*)pJoinParams
);
7671 PRINT_ER("Unable to FREE null pointer\n");
7673 #endif /*WILC_PARSE_SCAN_IN_HOST*/
7677 * @brief host_int_addBASession
7678 * @details Open a block Ack session with the given parameters
7679 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7681 * @author anoureldin
7685 static int host_int_addBASession(WILC_WFIDrvHandle hWFIDrv
, char *pBSSID
, char TID
, short int BufferSize
,
7686 short int SessionTimeout
, void *drvHandler
)
7688 s32 s32Error
= WILC_SUCCESS
;
7689 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7690 tstrHostIFmsg strHostIFmsg
;
7691 tstrHostIfBASessionInfo
*pBASessionInfo
= &strHostIFmsg
.uniHostIFmsgBody
.strHostIfBASessionInfo
;
7693 if (pstrWFIDrv
== NULL
)
7694 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7696 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7698 /* prepare the WiphyParams Message */
7699 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_ADD_BA_SESSION
;
7701 memcpy(pBASessionInfo
->au8Bssid
, pBSSID
, ETH_ALEN
);
7702 pBASessionInfo
->u8Ted
= TID
;
7703 pBASessionInfo
->u16BufferSize
= BufferSize
;
7704 pBASessionInfo
->u16SessionTimeout
= SessionTimeout
;
7705 strHostIFmsg
.drvHandler
= hWFIDrv
;
7707 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7709 WILC_ERRORREPORT(s32Error
, s32Error
);
7710 WILC_CATCH(s32Error
)
7719 s32
host_int_delBASession(WILC_WFIDrvHandle hWFIDrv
, char *pBSSID
, char TID
)
7721 s32 s32Error
= WILC_SUCCESS
;
7722 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7723 tstrHostIFmsg strHostIFmsg
;
7724 tstrHostIfBASessionInfo
*pBASessionInfo
= &strHostIFmsg
.uniHostIFmsgBody
.strHostIfBASessionInfo
;
7726 if (pstrWFIDrv
== NULL
)
7727 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7729 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7731 /* prepare the WiphyParams Message */
7732 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_DEL_BA_SESSION
;
7734 memcpy(pBASessionInfo
->au8Bssid
, pBSSID
, ETH_ALEN
);
7735 pBASessionInfo
->u8Ted
= TID
;
7736 strHostIFmsg
.drvHandler
= hWFIDrv
;
7738 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7740 WILC_ERRORREPORT(s32Error
, s32Error
);
7741 WILC_CATCH(s32Error
)
7747 down(&hWaitResponse
);
7752 s32
host_int_del_All_Rx_BASession(WILC_WFIDrvHandle hWFIDrv
, char *pBSSID
, char TID
)
7754 s32 s32Error
= WILC_SUCCESS
;
7755 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7756 tstrHostIFmsg strHostIFmsg
;
7757 tstrHostIfBASessionInfo
*pBASessionInfo
= &strHostIFmsg
.uniHostIFmsgBody
.strHostIfBASessionInfo
;
7759 if (pstrWFIDrv
== NULL
)
7760 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7762 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7764 /* prepare the WiphyParams Message */
7765 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS
;
7767 memcpy(pBASessionInfo
->au8Bssid
, pBSSID
, ETH_ALEN
);
7768 pBASessionInfo
->u8Ted
= TID
;
7769 strHostIFmsg
.drvHandler
= hWFIDrv
;
7771 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7773 WILC_ERRORREPORT(s32Error
, s32Error
);
7774 WILC_CATCH(s32Error
)
7780 down(&hWaitResponse
);
7786 * @brief host_int_setup_ipaddress
7787 * @details setup IP in firmware
7788 * @param[in] Handle to wifi driver
7789 * @return Error code.
7790 * @author Abdelrahman Sobhy
7793 s32
host_int_setup_ipaddress(WILC_WFIDrvHandle hWFIDrv
, u8
*u16ipadd
, u8 idx
)
7795 s32 s32Error
= WILC_SUCCESS
;
7796 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7797 tstrHostIFmsg strHostIFmsg
;
7799 /* TODO: Enable This feature on softap firmware */
7802 if (pstrWFIDrv
== NULL
)
7803 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7805 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7807 /* prepare the WiphyParams Message */
7808 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SET_IPADDRESS
;
7810 strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.au8IPAddr
= u16ipadd
;
7811 strHostIFmsg
.drvHandler
= hWFIDrv
;
7812 strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.idx
= idx
;
7814 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7816 WILC_ERRORREPORT(s32Error
, s32Error
);
7817 WILC_CATCH(s32Error
)
7828 * @brief host_int_get_ipaddress
7829 * @details Get IP from firmware
7830 * @param[in] Handle to wifi driver
7831 * @return Error code.
7832 * @author Abdelrahman Sobhy
7835 s32
host_int_get_ipaddress(WILC_WFIDrvHandle hWFIDrv
, u8
*u16ipadd
, u8 idx
)
7837 s32 s32Error
= WILC_SUCCESS
;
7838 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7839 tstrHostIFmsg strHostIFmsg
;
7841 if (pstrWFIDrv
== NULL
)
7842 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7844 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7846 /* prepare the WiphyParams Message */
7847 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_IPADDRESS
;
7849 strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.au8IPAddr
= u16ipadd
;
7850 strHostIFmsg
.drvHandler
= hWFIDrv
;
7851 strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.idx
= idx
;
7853 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7855 WILC_ERRORREPORT(s32Error
, s32Error
);
7856 WILC_CATCH(s32Error
)