1 #include "host_interface.h"
2 #include "coreconfigurator.h"
4 extern s32
TransportInit(void);
5 extern s32
TransportDeInit(void);
8 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
9 extern WILC_TimerHandle hDuringIpTimer
;
12 extern bool bEnablePS
;
14 extern u8 g_wilc_initialized
;
15 /*****************************************************************************/
17 /*****************************************************************************/
19 /* Message types of the Host IF Message Queue*/
20 #define HOST_IF_MSG_SCAN 0
21 #define HOST_IF_MSG_CONNECT 1
22 #define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
23 #define HOST_IF_MSG_KEY 3
24 #define HOST_IF_MSG_RCVD_NTWRK_INFO 4
25 #define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
26 #define HOST_IF_MSG_CFG_PARAMS 6
27 #define HOST_IF_MSG_SET_CHANNEL 7
28 #define HOST_IF_MSG_DISCONNECT 8
29 #define HOST_IF_MSG_GET_RSSI 9
30 #define HOST_IF_MSG_GET_CHNL 10
31 #define HOST_IF_MSG_ADD_BEACON 11
32 #define HOST_IF_MSG_DEL_BEACON 12
33 #define HOST_IF_MSG_ADD_STATION 13
34 #define HOST_IF_MSG_DEL_STATION 14
35 #define HOST_IF_MSG_EDIT_STATION 15
36 #define HOST_IF_MSG_SCAN_TIMER_FIRED 16
37 #define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
38 #define HOST_IF_MSG_POWER_MGMT 18
39 #define HOST_IF_MSG_GET_INACTIVETIME 19
40 #define HOST_IF_MSG_REMAIN_ON_CHAN 20
41 #define HOST_IF_MSG_REGISTER_FRAME 21
42 #define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
43 #define HOST_IF_MSG_GET_LINKSPEED 23
44 #define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
45 #define HOST_IF_MSG_SET_MAC_ADDRESS 25
46 #define HOST_IF_MSG_GET_MAC_ADDRESS 26
47 #define HOST_IF_MSG_SET_OPERATION_MODE 27
48 #define HOST_IF_MSG_SET_IPADDRESS 28
49 #define HOST_IF_MSG_GET_IPADDRESS 29
50 #define HOST_IF_MSG_FLUSH_CONNECT 30
51 #define HOST_IF_MSG_GET_STATISTICS 31
52 #define HOST_IF_MSG_SET_MULTICAST_FILTER 32
53 #define HOST_IF_MSG_ADD_BA_SESSION 33
54 #define HOST_IF_MSG_DEL_BA_SESSION 34
55 #define HOST_IF_MSG_Q_IDLE 35
56 #define HOST_IF_MSG_DEL_ALL_STA 36
57 #define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
58 #define HOST_IF_MSG_EXIT 100
60 #define HOST_IF_SCAN_TIMEOUT 4000
61 #define HOST_IF_CONNECT_TIMEOUT 9500
63 #define BA_SESSION_DEFAULT_BUFFER_SIZE 16
64 #define BA_SESSION_DEFAULT_TIMEOUT 1000
65 #define BLOCK_ACK_REQ_SIZE 0x14
66 /*****************************************************************************/
67 /* Type Definitions */
68 /*****************************************************************************/
71 * @struct tstrHostIFCfgParamAttr
72 * @brief Structure to hold Host IF CFG Params Attributes
76 * @author Mai Daftedar
80 typedef struct _tstrHostIFCfgParamAttr
{
81 tstrCfgParamVal pstrCfgParamVal
;
83 } tstrHostIFCfgParamAttr
;
86 * @struct tstrHostIFwpaAttr
87 * @brief Structure to hold Host IF Scan Attributes
91 * @author Mai Daftedar
95 typedef struct _tstrHostIFwpaAttr
{
107 * @struct tstrHostIFwepAttr
108 * @brief Structure to hold Host IF Scan Attributes
112 * @author Mai Daftedar
113 * @date 25 March 2012
116 typedef struct _tstrHostIFwepAttr
{
121 AUTHTYPE_T tenuAuth_type
;
126 * @struct tuniHostIFkeyAttr
127 * @brief Structure to hold Host IF Scan Attributes
131 * @author Mai Daftedar
132 * @date 25 March 2012
135 typedef union _tuniHostIFkeyAttr
{
136 tstrHostIFwepAttr strHostIFwepAttr
;
137 tstrHostIFwpaAttr strHostIFwpaAttr
;
138 tstrHostIFpmkidAttr strHostIFpmkidAttr
;
142 * @struct tstrHostIFkeyAttr
143 * @brief Structure to hold Host IF Scan Attributes
147 * @author Mai Daftedar
148 * @date 25 March 2012
151 typedef struct _tstrHostIFkeyAttr
{
152 tenuKeyType enuKeyType
;
154 tuniHostIFkeyAttr uniHostIFkeyAttr
;
161 * @struct tstrHostIFscanAttr
162 * @brief Structure to hold Host IF Scan Attributes
166 * @author Mostafa Abu Bakr
167 * @date 25 March 2012
170 typedef struct _tstrHostIFscanAttr
{
177 tWILCpfScanResult pfScanResult
;
180 tstrHiddenNetwork strHiddenNetwork
;
182 } tstrHostIFscanAttr
;
185 * @struct tstrHostIFconnectAttr
186 * @brief Structure to hold Host IF Connect Attributes
190 * @author Mostafa Abu Bakr
191 * @date 25 March 2012
194 typedef struct _tstrHostIFconnectAttr
{
201 tWILCpfConnectResult pfConnectResult
;
203 AUTHTYPE_T tenuAuth_type
;
206 } tstrHostIFconnectAttr
;
209 * @struct tstrRcvdGnrlAsyncInfo
210 * @brief Structure to hold Received General Asynchronous info
214 * @author Mostafa Abu Bakr
215 * @date 25 March 2012
218 typedef struct _tstrRcvdGnrlAsyncInfo
{
221 } tstrRcvdGnrlAsyncInfo
;
224 * @struct tstrHostIFSetChan
225 * @brief Set Channel message body
229 * @author Mai Daftedar
230 * @date 25 March 2012
233 typedef struct _tstrHostIFSetChan
{
238 * @struct tstrHostIFSetChan
239 * @brief Get Channel message body
243 * @author Mai Daftedar
247 typedef struct _tstrHostIFGetChan
{
251 /*bug3819: Add Scan acomplete notification to host*/
253 * @struct tstrScanComplete
254 * @brief hold received Async. Scan Complete message body
259 * @date 25 March 2012
262 /*typedef struct _tstrScanComplete
266 * } tstrScanComplete;*/
269 * @struct tstrHostIFSetBeacon
270 * @brief Set Beacon message body
274 * @author Adham Abozaeid
278 typedef struct _tstrHostIFSetBeacon
{
279 u32 u32Interval
; /*!< Beacon Interval. Period between two successive beacons on air */
280 u32 u32DTIMPeriod
; /*!< DTIM Period. Indicates how many Beacon frames
281 * (including the current frame) appear before the next DTIM */
282 u32 u32HeadLen
; /*!< Length of the head buffer in bytes */
283 u8
*pu8Head
; /*!< Pointer to the beacon's head buffer. Beacon's head is the part
284 * from the beacon's start till the TIM element, NOT including the TIM */
285 u32 u32TailLen
; /*!< Length of the tail buffer in bytes */
286 u8
*pu8Tail
; /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just
287 * after the TIM inormation element */
288 } tstrHostIFSetBeacon
;
293 * @struct tstrHostIFDelBeacon
294 * @brief Del Beacon message body
298 * @author Adham Abozaeid
302 typedef struct _tstrHostIFDelBeacon
{
304 } tstrHostIFDelBeacon
;
307 * @struct tstrHostIFSetMulti
308 * @brief set Multicast filter Address
312 * @author Abdelrahman Sobhy
313 * @date 30 August 2013
314 * @version 1.0 Description
320 } tstrHostIFSetMulti
;
323 * @struct tstrHostIFDelAllSta
324 * @brief Deauth station message body
328 * @author Mai Daftedar
329 * @date 09 April 2014
330 * @version 1.0 Description
334 u8 au8Sta_DelAllSta
[MAX_NUM_STA
][ETH_ALEN
];
336 } tstrHostIFDelAllSta
;
339 * @struct tstrHostIFDelSta
340 * @brief Delete station message body
344 * @author Adham Abozaeid
346 * @version 1.0 Description
350 u8 au8MacAddr
[ETH_ALEN
];
354 * @struct tstrTimerCb
355 * @brief Timer callback message body
359 * @author Mostafa Abu Bakr
360 * @date 25 March 2012
363 typedef struct _tstrTimerCb
{
364 void *pvUsrArg
; /*!< Private data passed at timer start */
368 * @struct tstrHostIfPowerMgmtParam
369 * @brief Power management message body
373 * @author Adham Abozaeid
374 * @date 24 November 2012
381 } tstrHostIfPowerMgmtParam
;
384 * @struct tstrHostIFSetIPAddr
385 * @brief set IP Address message body
389 * @author Abdelrahman Sobhy
390 * @date 30 August 2013
391 * @version 1.0 Description
397 } tstrHostIFSetIPAddr
;
400 * @struct tstrHostIfStaInactiveT
401 * @brief Get station message body
405 * @author Mai Daftedar
406 * @date 16 April 2013
412 } tstrHostIfStaInactiveT
;
415 * @union tuniHostIFmsgBody
416 * @brief Message body for the Host Interface message_q
420 * @author Mostafa Abu Bakr
421 * @date 25 March 2012
424 typedef union _tuniHostIFmsgBody
{
425 tstrHostIFscanAttr strHostIFscanAttr
; /*!< Host IF Scan Request Attributes message body */
426 tstrHostIFconnectAttr strHostIFconnectAttr
; /*!< Host IF Connect Request Attributes message body */
427 tstrRcvdNetworkInfo strRcvdNetworkInfo
; /*!< Received Asynchronous Network Info message body */
428 tstrRcvdGnrlAsyncInfo strRcvdGnrlAsyncInfo
; /*!< Received General Asynchronous Info message body */
429 tstrHostIFkeyAttr strHostIFkeyAttr
; /*!<>*/
430 tstrHostIFCfgParamAttr strHostIFCfgParamAttr
; /*! <CFG Parameter message Body> */
431 tstrHostIFSetChan strHostIFSetChan
;
432 tstrHostIFGetChan strHostIFGetChan
;
433 tstrHostIFSetBeacon strHostIFSetBeacon
; /*!< Set beacon message body */
434 tstrHostIFDelBeacon strHostIFDelBeacon
; /*!< Del beacon message body */
435 tstrWILC_AddStaParam strAddStaParam
; /*!< Add station message body */
436 tstrHostIFDelSta strDelStaParam
; /*!< Del Station message body */
437 tstrWILC_AddStaParam strEditStaParam
; /*!< Edit station message body */
438 /* tstrScanComplete strScanComplete; / *Received Async. Scan Complete message body* / */
439 tstrTimerCb strTimerCb
; /*!< Timer callback message body */
440 tstrHostIfPowerMgmtParam strPowerMgmtparam
; /*!< Power Management message body */
441 tstrHostIfStaInactiveT strHostIfStaInactiveT
;
442 tstrHostIFSetIPAddr strHostIfSetIP
;
443 tstrHostIfSetDrvHandler strHostIfSetDrvHandler
;
444 tstrHostIFSetMulti strHostIfSetMulti
;
445 tstrHostIfSetOperationMode strHostIfSetOperationMode
;
446 tstrHostIfSetMacAddress strHostIfSetMacAddress
;
447 tstrHostIfGetMacAddress strHostIfGetMacAddress
;
448 tstrHostIfBASessionInfo strHostIfBASessionInfo
;
450 tstrHostIfRemainOnChan strHostIfRemainOnChan
;
451 tstrHostIfRegisterFrame strHostIfRegisterFrame
;
454 tstrHostIFDelAllSta strHostIFDelAllSta
;
458 * @struct tstrHostIFmsg
459 * @brief Host Interface message
463 * @author Mostafa Abu Bakr
464 * @date 25 March 2012
467 typedef struct _tstrHostIFmsg
{
468 u16 u16MsgId
; /*!< Message ID */
469 tuniHostIFmsgBody uniHostIFmsgBody
; /*!< Message body */
473 #ifdef CONNECT_DIRECT
474 typedef struct _tstrWidJoinReqExt
{
475 char SSID
[MAX_SSID_LEN
];
481 /*Bug4218: Parsing Join Param*/
482 #ifdef WILC_PARSE_SCAN_IN_HOST
483 /*Struct containg joinParam of each AP*/
484 typedef struct _tstrJoinBssParam
{
490 char ssid
[MAX_SSID_LEN
];
492 u8 supp_rates
[MAX_RATES_SUPPORTED
+ 1];
499 u8 rsn_pcip_policy
[3];
500 u8 rsn_auth_policy
[3];
502 struct _tstrJoinParam
*nextJoinBss
;
515 /*Bug4218: Parsing Join Param*/
516 /*a linked list table containing needed join parameters entries for each AP found in most recent scan*/
517 typedef struct _tstrBssTable
{
519 tstrJoinBssParam
*head
;
520 tstrJoinBssParam
*tail
;
522 #endif /*WILC_PARSE_SCAN_IN_HOST*/
527 SCAN_CONNECT_TIMER_FORCE_32BIT
= 0xFFFFFFFF
530 /*****************************************************************************/
532 /* Global Variabls */
534 /*****************************************************************************/
537 tstrWILC_WFIDrv
*terminated_handle
= NULL
;
538 tstrWILC_WFIDrv
*gWFiDrvHandle
= NULL
;
539 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
540 bool g_obtainingIP
= false;
543 static struct task_struct
*HostIFthreadHandler
;
544 static WILC_MsgQueueHandle gMsgQHostIF
;
545 static struct semaphore hSemHostIFthrdEnd
;
547 struct semaphore hSemDeinitDrvHandle
;
548 static struct semaphore hWaitResponse
;
549 struct semaphore hSemHostIntDeinit
;
550 WILC_TimerHandle g_hPeriodicRSSI
;
554 u8 gau8MulticastMacAddrList
[WILC_MULTICAST_TABLE_SIZE
][ETH_ALEN
];
556 #ifndef CONNECT_DIRECT
557 static u8 gapu8RcvdSurveyResults
[2][MAX_SURVEY_RESULT_FRAG_SIZE
];
560 static u8 gapu8RcvdAssocResp
[MAX_ASSOC_RESP_FRAME_SIZE
];
562 bool gbScanWhileConnected
= false;
567 static u8 gs8SetIP
[2][4];
568 static u8 gs8GetIP
[2][4];
569 #ifdef WILC_AP_EXTERNAL_MLME
570 static u32 gu32InactiveTime
;
574 static u32 gu32WidConnRstHack
;
578 u8
*gu8FlushedJoinReq
;
579 u8
*gu8FlushedInfoElemAsoc
;
580 u8 gu8Flushed11iMode
;
581 u8 gu8FlushedAuthType
;
582 u32 gu32FlushedJoinReqSize
;
583 u32 gu32FlushedInfoElemAsocSize
;
584 u32 gu8FlushedJoinReqDrvHandler
;
585 #define REAL_JOIN_REQ 0
586 #define FLUSHED_JOIN_REQ 1
587 #define FLUSHED_BYTE_POS 79 /* Position the byte indicating flushing in the flushed request */
589 /*Bug4218: Parsing Join Param*/
590 #ifdef WILC_PARSE_SCAN_IN_HOST
591 /*Bug4218: Parsing Join Param*/
592 static void *host_int_ParseJoinBssParam(tstrNetworkInfo
*ptstrNetworkInfo
);
593 #endif /*WILC_PARSE_SCAN_IN_HOST*/
595 extern void chip_sleep_manually(u32 u32SleepTime
);
596 extern int linux_wlan_get_num_conn_ifcs(void);
599 * @brief Handle_SetChannel
600 * @details Sending config packet to firmware to set channel
601 * @param[in] tstrHostIFSetChan* pstrHostIFSetChan
602 * @return Error code.
607 static s32
Handle_SetChannel(void *drvHandler
, tstrHostIFSetChan
*pstrHostIFSetChan
)
610 s32 s32Error
= WILC_SUCCESS
;
612 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
614 /*prepare configuration packet*/
615 strWID
.u16WIDid
= (u16
)WID_CURRENT_CHANNEL
;
616 strWID
.enuWIDtype
= WID_CHAR
;
617 strWID
.ps8WidVal
= (char *)&(pstrHostIFSetChan
->u8SetChan
);
618 strWID
.s32ValueSize
= sizeof(char);
620 PRINT_D(HOSTINF_DBG
, "Setting channel\n");
622 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
624 PRINT_ER("Failed to set channel\n");
625 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
635 * @brief Handle_SetWfiDrvHandler
636 * @details Sending config packet to firmware to set driver handler
637 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
638 * @return Error code.
643 static s32
Handle_SetWfiDrvHandler(tstrHostIfSetDrvHandler
*pstrHostIfSetDrvHandler
)
646 s32 s32Error
= WILC_SUCCESS
;
648 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)((pstrHostIfSetDrvHandler
->u32Address
));
651 /*prepare configuration packet*/
652 strWID
.u16WIDid
= (u16
)WID_SET_DRV_HANDLER
;
653 strWID
.enuWIDtype
= WID_INT
;
654 strWID
.ps8WidVal
= (s8
*)&(pstrHostIfSetDrvHandler
->u32Address
);
655 strWID
.s32ValueSize
= sizeof(u32
);
659 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
662 if ((pstrHostIfSetDrvHandler
->u32Address
) == (u32
)NULL
)
663 up(&hSemDeinitDrvHandle
);
667 PRINT_ER("Failed to set driver handler\n");
668 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
679 * @brief Handle_SetWfiAPDrvHandler
680 * @details Sending config packet to firmware to set driver handler
681 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
682 * @return Error code.
687 static s32
Handle_SetOperationMode(void *drvHandler
, tstrHostIfSetOperationMode
*pstrHostIfSetOperationMode
)
690 s32 s32Error
= WILC_SUCCESS
;
692 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
695 /*prepare configuration packet*/
696 strWID
.u16WIDid
= (u16
)WID_SET_OPERATION_MODE
;
697 strWID
.enuWIDtype
= WID_INT
;
698 strWID
.ps8WidVal
= (s8
*)&(pstrHostIfSetOperationMode
->u32Mode
);
699 strWID
.s32ValueSize
= sizeof(u32
);
702 PRINT_INFO(HOSTINF_DBG
, "pstrWFIDrv= %p \n", pstrWFIDrv
);
704 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
707 if ((pstrHostIfSetOperationMode
->u32Mode
) == (u32
)NULL
)
708 up(&hSemDeinitDrvHandle
);
712 PRINT_ER("Failed to set driver handler\n");
713 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
724 * @brief host_int_set_IPAddress
725 * @details Setting IP address params in message queue
726 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
727 * @return Error code.
732 s32
Handle_set_IPAddress(void *drvHandler
, u8
*pu8IPAddr
, u8 idx
)
735 s32 s32Error
= WILC_SUCCESS
;
737 char firmwareIPAddress
[4] = {0};
738 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
740 if (pu8IPAddr
[0] < 192)
743 PRINT_INFO(HOSTINF_DBG
, "Indx = %d, Handling set IP = %d.%d.%d.%d \n", idx
, pu8IPAddr
[0], pu8IPAddr
[1], pu8IPAddr
[2], pu8IPAddr
[3]);
745 WILC_memcpy(gs8SetIP
[idx
], pu8IPAddr
, IP_ALEN
);
747 /*prepare configuration packet*/
748 strWID
.u16WIDid
= (u16
)WID_IP_ADDRESS
;
749 strWID
.enuWIDtype
= WID_STR
;
750 strWID
.ps8WidVal
= (u8
*)pu8IPAddr
;
751 strWID
.s32ValueSize
= IP_ALEN
;
753 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
757 host_int_get_ipaddress((WILC_WFIDrvHandle
)drvHandler
, firmwareIPAddress
, idx
);
760 PRINT_D(HOSTINF_DBG
, "Failed to set IP address\n");
761 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
763 PRINT_INFO(HOSTINF_DBG
, "IP address set\n");
776 * @brief Handle_get_IPAddress
777 * @details Setting IP address params in message queue
778 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
779 * @return Error code.
784 s32
Handle_get_IPAddress(void *drvHandler
, u8
*pu8IPAddr
, u8 idx
)
787 s32 s32Error
= WILC_SUCCESS
;
789 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
791 /*prepare configuration packet*/
792 strWID
.u16WIDid
= (u16
)WID_IP_ADDRESS
;
793 strWID
.enuWIDtype
= WID_STR
;
794 strWID
.ps8WidVal
= (u8
*)WILC_MALLOC(IP_ALEN
);
795 strWID
.s32ValueSize
= IP_ALEN
;
797 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
799 PRINT_INFO(HOSTINF_DBG
, "%d.%d.%d.%d\n", (u8
)(strWID
.ps8WidVal
[0]), (u8
)(strWID
.ps8WidVal
[1]), (u8
)(strWID
.ps8WidVal
[2]), (u8
)(strWID
.ps8WidVal
[3]));
801 WILC_memcpy(gs8GetIP
[idx
], strWID
.ps8WidVal
, IP_ALEN
);
803 /*get the value by searching the local copy*/
804 WILC_FREE(strWID
.ps8WidVal
);
806 if (WILC_memcmp(gs8GetIP
[idx
], gs8SetIP
[idx
], IP_ALEN
) != 0)
807 host_int_setup_ipaddress((WILC_WFIDrvHandle
)pstrWFIDrv
, gs8SetIP
[idx
], idx
);
809 if (s32Error
!= WILC_SUCCESS
) {
810 PRINT_ER("Failed to get IP address\n");
811 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
813 PRINT_INFO(HOSTINF_DBG
, "IP address retrieved:: u8IfIdx = %d \n", idx
);
814 PRINT_INFO(HOSTINF_DBG
, "%d.%d.%d.%d\n", gs8GetIP
[idx
][0], gs8GetIP
[idx
][1], gs8GetIP
[idx
][2], gs8GetIP
[idx
][3]);
815 PRINT_INFO(HOSTINF_DBG
, "\n");
829 * @brief Handle_SetMacAddress
830 * @details Setting mac address
831 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
832 * @return Error code.
833 * @author Amr Abdel-Moghny
834 * @date November 2013
837 static s32
Handle_SetMacAddress(void *drvHandler
, tstrHostIfSetMacAddress
*pstrHostIfSetMacAddress
)
840 s32 s32Error
= WILC_SUCCESS
;
842 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
843 u8
*mac_buf
= (u8
*)WILC_MALLOC(ETH_ALEN
);
844 if (mac_buf
== NULL
) {
845 PRINT_ER("No buffer to send mac address\n");
848 WILC_memcpy(mac_buf
, pstrHostIfSetMacAddress
->u8MacAddress
, ETH_ALEN
);
850 /*prepare configuration packet*/
851 strWID
.u16WIDid
= (u16
)WID_MAC_ADDR
;
852 strWID
.enuWIDtype
= WID_STR
;
853 strWID
.ps8WidVal
= mac_buf
;
854 strWID
.s32ValueSize
= ETH_ALEN
;
855 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]);
857 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
859 PRINT_ER("Failed to set mac address\n");
860 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
874 * @brief Handle_GetMacAddress
875 * @details Getting mac address
876 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
877 * @return Error code.
878 * @author Amr Abdel-Moghny
882 static s32
Handle_GetMacAddress(void *drvHandler
, tstrHostIfGetMacAddress
*pstrHostIfGetMacAddress
)
885 s32 s32Error
= WILC_SUCCESS
;
888 /*prepare configuration packet*/
889 strWID
.u16WIDid
= (u16
)WID_MAC_ADDR
;
890 strWID
.enuWIDtype
= WID_STR
;
891 strWID
.ps8WidVal
= pstrHostIfGetMacAddress
->u8MacAddress
;
892 strWID
.s32ValueSize
= ETH_ALEN
;
895 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, false, (u32
)drvHandler
);
897 PRINT_ER("Failed to get mac address\n");
898 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
911 * @brief Handle_CfgParam
912 * @details Sending config packet to firmware to set CFG params
913 * @param[in] tstrHostIFCfgParamAttr* strHostIFCfgParamAttr
914 * @return Error code.
919 static s32
Handle_CfgParam(void *drvHandler
, tstrHostIFCfgParamAttr
*strHostIFCfgParamAttr
)
921 s32 s32Error
= WILC_SUCCESS
;
922 tstrWID strWIDList
[32];
924 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
927 down(&(pstrWFIDrv
->gtOsCfgValuesSem
));
930 PRINT_D(HOSTINF_DBG
, "Setting CFG params\n");
932 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& BSS_TYPE
) {
933 /*----------------------------------------------------------*/
934 /*Input Value: INFRASTRUCTURE = 1, */
935 /* INDEPENDENT= 2, */
937 /*----------------------------------------------------------*/
938 /* validate input then copy>> need to check value 4 and 5 */
939 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.bss_type
< 6) {
940 strWIDList
[u8WidCnt
].u16WIDid
= WID_BSS_TYPE
;
941 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.bss_type
;
942 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
943 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
944 pstrWFIDrv
->strCfgValues
.bss_type
= (u8
)strHostIFCfgParamAttr
->pstrCfgParamVal
.bss_type
;
946 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
950 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& AUTH_TYPE
) {
951 /*------------------------------------------------------*/
952 /*Input Values: OPEN_SYSTEM = 0, */
953 /* SHARED_KEY = 1, */
955 /*------------------------------------------------------*/
956 /*validate Possible values*/
957 if ((strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_type
) == 1 || (strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_type
) == 2 || (strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_type
) == 5) {
958 strWIDList
[u8WidCnt
].u16WIDid
= WID_AUTH_TYPE
;
959 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_type
;
960 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
961 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
962 pstrWFIDrv
->strCfgValues
.auth_type
= (u8
)strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_type
;
964 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
968 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& AUTHEN_TIMEOUT
) {
969 /* range is 1 to 65535. */
970 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_timeout
> 0 && strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_timeout
< 65536) {
971 strWIDList
[u8WidCnt
].u16WIDid
= WID_AUTH_TIMEOUT
;
972 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_timeout
;
973 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
974 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
975 pstrWFIDrv
->strCfgValues
.auth_timeout
= strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_timeout
;
977 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
981 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& POWER_MANAGEMENT
) {
982 /*-----------------------------------------------------------*/
983 /*Input Values: NO_POWERSAVE = 0, */
984 /* MIN_FAST_PS = 1, */
985 /* MAX_FAST_PS = 2, */
986 /* MIN_PSPOLL_PS = 3, */
987 /* MAX_PSPOLL_PS = 4 */
988 /*----------------------------------------------------------*/
989 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.power_mgmt_mode
< 5) {
990 strWIDList
[u8WidCnt
].u16WIDid
= WID_POWER_MANAGEMENT
;
991 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.power_mgmt_mode
;
992 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
993 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
994 pstrWFIDrv
->strCfgValues
.power_mgmt_mode
= (u8
)strHostIFCfgParamAttr
->pstrCfgParamVal
.power_mgmt_mode
;
996 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1000 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& RETRY_SHORT
) {
1001 /* range from 1 to 256 */
1002 if ((strHostIFCfgParamAttr
->pstrCfgParamVal
.short_retry_limit
> 0) && (strHostIFCfgParamAttr
->pstrCfgParamVal
.short_retry_limit
< 256)) {
1003 strWIDList
[u8WidCnt
].u16WIDid
= WID_SHORT_RETRY_LIMIT
;
1004 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.short_retry_limit
;
1005 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1006 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1007 pstrWFIDrv
->strCfgValues
.short_retry_limit
= strHostIFCfgParamAttr
->pstrCfgParamVal
.short_retry_limit
;
1009 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1013 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& RETRY_LONG
) {
1014 /* range from 1 to 256 */
1015 if ((strHostIFCfgParamAttr
->pstrCfgParamVal
.long_retry_limit
> 0) && (strHostIFCfgParamAttr
->pstrCfgParamVal
.long_retry_limit
< 256)) {
1016 strWIDList
[u8WidCnt
].u16WIDid
= WID_LONG_RETRY_LIMIT
;
1017 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.long_retry_limit
;
1019 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1020 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1021 pstrWFIDrv
->strCfgValues
.long_retry_limit
= strHostIFCfgParamAttr
->pstrCfgParamVal
.long_retry_limit
;
1023 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1027 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& FRAG_THRESHOLD
) {
1029 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.frag_threshold
> 255 && strHostIFCfgParamAttr
->pstrCfgParamVal
.frag_threshold
< 7937) {
1030 strWIDList
[u8WidCnt
].u16WIDid
= WID_FRAG_THRESHOLD
;
1031 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.frag_threshold
;
1032 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1033 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1034 pstrWFIDrv
->strCfgValues
.frag_threshold
= strHostIFCfgParamAttr
->pstrCfgParamVal
.frag_threshold
;
1036 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1040 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& RTS_THRESHOLD
) {
1041 /* range 256 to 65535 */
1042 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.rts_threshold
> 255 && strHostIFCfgParamAttr
->pstrCfgParamVal
.rts_threshold
< 65536) {
1043 strWIDList
[u8WidCnt
].u16WIDid
= WID_RTS_THRESHOLD
;
1044 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.rts_threshold
;
1045 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1046 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1047 pstrWFIDrv
->strCfgValues
.rts_threshold
= strHostIFCfgParamAttr
->pstrCfgParamVal
.rts_threshold
;
1049 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1053 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& PREAMBLE
) {
1054 /*-----------------------------------------------------*/
1055 /*Input Values: Short= 0, */
1058 /*------------------------------------------------------*/
1059 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.preamble_type
< 3) {
1060 strWIDList
[u8WidCnt
].u16WIDid
= WID_PREAMBLE
;
1061 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.preamble_type
;
1062 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
1063 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
1064 pstrWFIDrv
->strCfgValues
.preamble_type
= strHostIFCfgParamAttr
->pstrCfgParamVal
.preamble_type
;
1066 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1070 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& SHORT_SLOT_ALLOWED
) {
1071 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.short_slot_allowed
< 2) {
1072 strWIDList
[u8WidCnt
].u16WIDid
= WID_SHORT_SLOT_ALLOWED
;
1073 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.short_slot_allowed
;
1074 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
1075 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
1076 pstrWFIDrv
->strCfgValues
.short_slot_allowed
= (u8
)strHostIFCfgParamAttr
->pstrCfgParamVal
.short_slot_allowed
;
1078 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1082 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& TXOP_PROT_DISABLE
) {
1083 /*Description: used to Disable RTS-CTS protection for TXOP burst*/
1084 /*transmission when the acknowledgement policy is No-Ack or Block-Ack */
1085 /* this information is useful for external supplicant */
1086 /*Input Values: 1 for enable and 0 for disable. */
1087 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.txop_prot_disabled
< 2) {
1088 strWIDList
[u8WidCnt
].u16WIDid
= WID_11N_TXOP_PROT_DISABLE
;
1089 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.txop_prot_disabled
;
1090 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
1091 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
1092 pstrWFIDrv
->strCfgValues
.txop_prot_disabled
= (u8
)strHostIFCfgParamAttr
->pstrCfgParamVal
.txop_prot_disabled
;
1094 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1098 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& BEACON_INTERVAL
) {
1099 /* range is 1 to 65535. */
1100 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.beacon_interval
> 0 && strHostIFCfgParamAttr
->pstrCfgParamVal
.beacon_interval
< 65536) {
1101 strWIDList
[u8WidCnt
].u16WIDid
= WID_BEACON_INTERVAL
;
1102 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.beacon_interval
;
1103 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1104 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1105 pstrWFIDrv
->strCfgValues
.beacon_interval
= strHostIFCfgParamAttr
->pstrCfgParamVal
.beacon_interval
;
1107 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1111 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& DTIM_PERIOD
) {
1112 /* range is 1 to 255. */
1113 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.dtim_period
> 0 && strHostIFCfgParamAttr
->pstrCfgParamVal
.dtim_period
< 256) {
1114 strWIDList
[u8WidCnt
].u16WIDid
= WID_DTIM_PERIOD
;
1115 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.dtim_period
;
1116 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
1117 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
1118 pstrWFIDrv
->strCfgValues
.dtim_period
= strHostIFCfgParamAttr
->pstrCfgParamVal
.dtim_period
;
1120 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1124 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& SITE_SURVEY
) {
1125 /*----------------------------------------------------------------------*/
1126 /*Input Values: SITE_SURVEY_1CH = 0, i.e.: currently set channel */
1127 /* SITE_SURVEY_ALL_CH = 1, */
1128 /* SITE_SURVEY_OFF = 2 */
1129 /*----------------------------------------------------------------------*/
1130 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_enabled
< 3) {
1131 strWIDList
[u8WidCnt
].u16WIDid
= WID_SITE_SURVEY
;
1132 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_enabled
;
1133 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
1134 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
1135 pstrWFIDrv
->strCfgValues
.site_survey_enabled
= (u8
)strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_enabled
;
1137 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1141 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& SITE_SURVEY_SCAN_TIME
) {
1142 /* range is 1 to 65535. */
1143 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_scan_time
> 0 && strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_scan_time
< 65536) {
1144 strWIDList
[u8WidCnt
].u16WIDid
= WID_SITE_SURVEY_SCAN_TIME
;
1145 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_scan_time
;
1146 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1147 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1148 pstrWFIDrv
->strCfgValues
.site_survey_scan_time
= strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_scan_time
;
1150 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1154 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& ACTIVE_SCANTIME
) {
1155 /* range is 1 to 65535. */
1156 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.active_scan_time
> 0 && strHostIFCfgParamAttr
->pstrCfgParamVal
.active_scan_time
< 65536) {
1157 strWIDList
[u8WidCnt
].u16WIDid
= WID_ACTIVE_SCAN_TIME
;
1158 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.active_scan_time
;
1159 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1160 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1161 pstrWFIDrv
->strCfgValues
.active_scan_time
= strHostIFCfgParamAttr
->pstrCfgParamVal
.active_scan_time
;
1163 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1167 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& PASSIVE_SCANTIME
) {
1168 /* range is 1 to 65535. */
1169 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.passive_scan_time
> 0 && strHostIFCfgParamAttr
->pstrCfgParamVal
.passive_scan_time
< 65536) {
1170 strWIDList
[u8WidCnt
].u16WIDid
= WID_PASSIVE_SCAN_TIME
;
1171 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.passive_scan_time
;
1172 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1173 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1174 pstrWFIDrv
->strCfgValues
.passive_scan_time
= strHostIFCfgParamAttr
->pstrCfgParamVal
.passive_scan_time
;
1176 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1180 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& CURRENT_TX_RATE
) {
1181 CURRENT_TX_RATE_T curr_tx_rate
= strHostIFCfgParamAttr
->pstrCfgParamVal
.curr_tx_rate
;
1182 /*----------------------------------------------------------------------*/
1183 /*Rates: 1 2 5.5 11 6 9 12 18 24 36 48 54 Auto */
1184 /*InputValues: 1 2 3 4 5 6 7 8 9 10 11 12 0 */
1185 /*----------------------------------------------------------------------*/
1187 if (curr_tx_rate
== AUTORATE
|| curr_tx_rate
== MBPS_1
1188 || curr_tx_rate
== MBPS_2
|| curr_tx_rate
== MBPS_5_5
1189 || curr_tx_rate
== MBPS_11
|| curr_tx_rate
== MBPS_6
1190 || curr_tx_rate
== MBPS_9
|| curr_tx_rate
== MBPS_12
1191 || curr_tx_rate
== MBPS_18
|| curr_tx_rate
== MBPS_24
1192 || curr_tx_rate
== MBPS_36
|| curr_tx_rate
== MBPS_48
|| curr_tx_rate
== MBPS_54
) {
1193 strWIDList
[u8WidCnt
].u16WIDid
= WID_CURRENT_TX_RATE
;
1194 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&curr_tx_rate
;
1195 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1196 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1197 pstrWFIDrv
->strCfgValues
.curr_tx_rate
= (u8
)curr_tx_rate
;
1199 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1203 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, u8WidCnt
, false, (u32
)pstrWFIDrv
);
1206 PRINT_ER("Error in setting CFG params\n");
1208 WILC_CATCH(s32Error
)
1211 up(&(pstrWFIDrv
->gtOsCfgValuesSem
));
1217 * @brief Handle_wait_msg_q_empty
1218 * @details this should be the last msg and then the msg Q becomes idle
1219 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1220 * @return Error code.
1225 static s32
Handle_wait_msg_q_empty(void)
1227 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
;
1628 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1629 * firmware at chip reset when processing the WIDs of the Connect Request.
1630 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1631 /* ////////////////////// */
1632 gu32WidConnRstHack
= 0;
1633 /* ////////////////////// */
1636 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, u32WidsCount
, false, (u32
)pstrWFIDrv
);
1638 PRINT_ER("Handle_Connect()] failed to send config packet\n");
1639 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
1641 pstrWFIDrv
->enuHostIFstate
= HOST_IF_WAITING_CONN_RESP
;
1645 PRINT_ER("Required BSSID not found\n");
1646 WILC_ERRORREPORT(s32Error
, WILC_NOT_FOUND
);
1651 /* if we try to connect to an already connected AP then discard the request */
1653 if (WILC_memcmp(pstrHostIFconnectAttr
->pu8bssid
, u8ConnectedSSID
, ETH_ALEN
) == 0) {
1655 s32Error
= WILC_SUCCESS
;
1656 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1660 PRINT_INFO(HOSTINF_DBG
, "Saving connection parameters in global structure\n");
1662 /*Bug4218: Parsing Join Param*/
1663 #ifdef WILC_PARSE_SCAN_IN_HOST
1664 ptstrJoinBssParam
= (tstrJoinBssParam
*)pstrHostIFconnectAttr
->pJoinParams
;
1665 if (ptstrJoinBssParam
== NULL
) {
1666 PRINT_ER("Required BSSID not found\n");
1667 WILC_ERRORREPORT(s32Error
, WILC_NOT_FOUND
);
1669 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1671 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
) {
1672 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
= (u8
*)WILC_MALLOC(6);
1673 WILC_memcpy(pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
, pstrHostIFconnectAttr
->pu8bssid
, 6);
1676 pstrWFIDrv
->strWILC_UsrConnReq
.ssidLen
= pstrHostIFconnectAttr
->ssidLen
;
1677 if (pstrHostIFconnectAttr
->pu8ssid
!= NULL
) {
1678 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
= (u8
*)WILC_MALLOC(pstrHostIFconnectAttr
->ssidLen
+ 1);
1679 WILC_memcpy(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
, pstrHostIFconnectAttr
->pu8ssid
,
1680 pstrHostIFconnectAttr
->ssidLen
);
1681 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
[pstrHostIFconnectAttr
->ssidLen
] = '\0';
1684 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
= pstrHostIFconnectAttr
->IEsLen
;
1685 if (pstrHostIFconnectAttr
->pu8IEs
!= NULL
) {
1686 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
= (u8
*)WILC_MALLOC(pstrHostIFconnectAttr
->IEsLen
);
1687 WILC_memcpy(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
, pstrHostIFconnectAttr
->pu8IEs
,
1688 pstrHostIFconnectAttr
->IEsLen
);
1691 pstrWFIDrv
->strWILC_UsrConnReq
.u8security
= pstrHostIFconnectAttr
->u8security
;
1692 pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
= pstrHostIFconnectAttr
->tenuAuth_type
;
1693 pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
= pstrHostIFconnectAttr
->pfConnectResult
;
1694 pstrWFIDrv
->strWILC_UsrConnReq
.u32UserConnectPvoid
= pstrHostIFconnectAttr
->pvUserArg
;
1696 strWIDList
[u32WidsCount
].u16WIDid
= WID_SUCCESS_FRAME_COUNT
;
1697 strWIDList
[u32WidsCount
].enuWIDtype
= WID_INT
;
1698 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(u32
);
1699 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(dummyval
));
1702 strWIDList
[u32WidsCount
].u16WIDid
= WID_RECEIVED_FRAGMENT_COUNT
;
1703 strWIDList
[u32WidsCount
].enuWIDtype
= WID_INT
;
1704 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(u32
);
1705 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(dummyval
));
1708 strWIDList
[u32WidsCount
].u16WIDid
= WID_FAILED_COUNT
;
1709 strWIDList
[u32WidsCount
].enuWIDtype
= WID_INT
;
1710 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(u32
);
1711 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(dummyval
));
1714 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1715 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1717 /* IEs to be inserted in Association Request */
1718 strWIDList
[u32WidsCount
].u16WIDid
= WID_INFO_ELEMENT_ASSOCIATE
;
1719 strWIDList
[u32WidsCount
].enuWIDtype
= WID_BIN_DATA
;
1720 strWIDList
[u32WidsCount
].ps8WidVal
= pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
;
1721 strWIDList
[u32WidsCount
].s32ValueSize
= pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
;
1725 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr
->pu8ssid
, 7)) {
1727 gu32FlushedInfoElemAsocSize
= pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
;
1728 gu8FlushedInfoElemAsoc
= WILC_MALLOC(gu32FlushedInfoElemAsocSize
);
1729 memcpy(gu8FlushedInfoElemAsoc
, pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
,
1730 gu32FlushedInfoElemAsocSize
);
1733 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_11I_MODE
;
1734 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
1735 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
1736 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrWFIDrv
->strWILC_UsrConnReq
.u8security
));
1740 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr
->pu8ssid
, 7))
1741 gu8Flushed11iMode
= pstrWFIDrv
->strWILC_UsrConnReq
.u8security
;
1743 PRINT_INFO(HOSTINF_DBG
, "Encrypt Mode = %x\n", pstrWFIDrv
->strWILC_UsrConnReq
.u8security
);
1746 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_AUTH_TYPE
;
1747 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
1748 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
1749 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
);
1753 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr
->pu8ssid
, 7))
1754 gu8FlushedAuthType
= (u8
)pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
;
1756 PRINT_INFO(HOSTINF_DBG
, "Authentication Type = %x\n", pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
);
1758 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
1759 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1760 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
1761 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
1765 PRINT_D(HOSTINF_DBG
, "Connecting to network of SSID %s on channel %d\n",
1766 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
, pstrHostIFconnectAttr
->u8channel
);
1769 #ifndef WILC_PARSE_SCAN_IN_HOST
1770 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_JOIN_REQ_EXTENDED
;
1771 strWIDList
[u32WidsCount
].enuWIDtype
= WID_STR
;
1772 strWIDList
[u32WidsCount
].s32ValueSize
= MAX_SSID_LEN
+ 7;
1773 strWIDList
[u32WidsCount
].ps8WidVal
= WILC_MALLOC(strWIDList
[u32WidsCount
].s32ValueSize
);
1775 if (strWIDList
[u32WidsCount
].ps8WidVal
== NULL
)
1776 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
1778 pu8CurrByte
= strWIDList
[u32WidsCount
].ps8WidVal
;
1780 if (pstrHostIFconnectAttr
->pu8ssid
!= NULL
) {
1781 WILC_memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->pu8ssid
, pstrHostIFconnectAttr
->ssidLen
);
1782 pu8CurrByte
[pstrHostIFconnectAttr
->ssidLen
] = '\0';
1784 pu8CurrByte
+= MAX_SSID_LEN
;
1785 if ((pstrHostIFconnectAttr
->u8channel
>= 1) && (pstrHostIFconnectAttr
->u8channel
<= 14)) {
1786 *(pu8CurrByte
++) = pstrHostIFconnectAttr
->u8channel
;
1788 PRINT_ER("Channel out of range\n");
1789 *(pu8CurrByte
++) = 0xFF;
1791 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
)
1792 WILC_memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->pu8bssid
, 6);
1795 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1796 pu8CurrByte
= strWIDList
[u32WidsCount
].ps8WidVal
;
1800 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_JOIN_REQ_EXTENDED
;
1801 strWIDList
[u32WidsCount
].enuWIDtype
= WID_STR
;
1803 /*Sending NoA attributes during connection*/
1804 strWIDList
[u32WidsCount
].s32ValueSize
= 112; /* 79; */
1805 strWIDList
[u32WidsCount
].ps8WidVal
= WILC_MALLOC(strWIDList
[u32WidsCount
].s32ValueSize
);
1808 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr
->pu8ssid
, 7)) {
1809 gu32FlushedJoinReqSize
= strWIDList
[u32WidsCount
].s32ValueSize
;
1810 gu8FlushedJoinReq
= WILC_MALLOC(gu32FlushedJoinReqSize
);
1812 if (strWIDList
[u32WidsCount
].ps8WidVal
== NULL
)
1813 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
1815 pu8CurrByte
= strWIDList
[u32WidsCount
].ps8WidVal
;
1818 if (pstrHostIFconnectAttr
->pu8ssid
!= NULL
) {
1819 WILC_memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->pu8ssid
, pstrHostIFconnectAttr
->ssidLen
);
1820 pu8CurrByte
[pstrHostIFconnectAttr
->ssidLen
] = '\0';
1822 pu8CurrByte
+= MAX_SSID_LEN
;
1825 *(pu8CurrByte
++) = INFRASTRUCTURE
;
1827 if ((pstrHostIFconnectAttr
->u8channel
>= 1) && (pstrHostIFconnectAttr
->u8channel
<= 14)) {
1828 *(pu8CurrByte
++) = pstrHostIFconnectAttr
->u8channel
;
1830 PRINT_ER("Channel out of range\n");
1831 *(pu8CurrByte
++) = 0xFF;
1834 *(pu8CurrByte
++) = (ptstrJoinBssParam
->cap_info
) & 0xFF;
1835 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->cap_info
) >> 8) & 0xFF;
1836 PRINT_D(HOSTINF_DBG
, "* Cap Info %0x*\n", (*(pu8CurrByte
- 2) | ((*(pu8CurrByte
- 1)) << 8)));
1839 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
)
1840 WILC_memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->pu8bssid
, 6);
1844 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
)
1845 WILC_memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->pu8bssid
, 6);
1849 *(pu8CurrByte
++) = (ptstrJoinBssParam
->beacon_period
) & 0xFF;
1850 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->beacon_period
) >> 8) & 0xFF;
1851 PRINT_D(HOSTINF_DBG
, "* Beacon Period %d*\n", (*(pu8CurrByte
- 2) | ((*(pu8CurrByte
- 1)) << 8)));
1853 *(pu8CurrByte
++) = ptstrJoinBssParam
->dtim_period
;
1854 PRINT_D(HOSTINF_DBG
, "* DTIM Period %d*\n", (*(pu8CurrByte
- 1)));
1855 /* Supported rates*/
1856 WILC_memcpy(pu8CurrByte
, ptstrJoinBssParam
->supp_rates
, MAX_RATES_SUPPORTED
+ 1);
1857 pu8CurrByte
+= (MAX_RATES_SUPPORTED
+ 1);
1860 *(pu8CurrByte
++) = ptstrJoinBssParam
->wmm_cap
;
1861 PRINT_D(HOSTINF_DBG
, "* wmm cap%d*\n", (*(pu8CurrByte
- 1)));
1863 *(pu8CurrByte
++) = ptstrJoinBssParam
->uapsd_cap
;
1866 *(pu8CurrByte
++) = ptstrJoinBssParam
->ht_capable
;
1867 /* copy this information to the user request */
1868 pstrWFIDrv
->strWILC_UsrConnReq
.IsHTCapable
= ptstrJoinBssParam
->ht_capable
;
1871 *(pu8CurrByte
++) = ptstrJoinBssParam
->rsn_found
;
1872 PRINT_D(HOSTINF_DBG
, "* rsn found %d*\n", *(pu8CurrByte
- 1));
1873 /* rsn group policy*/
1874 *(pu8CurrByte
++) = ptstrJoinBssParam
->rsn_grp_policy
;
1875 PRINT_D(HOSTINF_DBG
, "* rsn group policy %0x*\n", (*(pu8CurrByte
- 1)));
1877 *(pu8CurrByte
++) = ptstrJoinBssParam
->mode_802_11i
;
1878 PRINT_D(HOSTINF_DBG
, "* mode_802_11i %d*\n", (*(pu8CurrByte
- 1)));
1879 /* rsn pcip policy*/
1880 WILC_memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_pcip_policy
, sizeof(ptstrJoinBssParam
->rsn_pcip_policy
));
1881 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_pcip_policy
);
1883 /* rsn auth policy*/
1884 WILC_memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_auth_policy
, sizeof(ptstrJoinBssParam
->rsn_auth_policy
));
1885 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_auth_policy
);
1887 /* rsn auth policy*/
1888 WILC_memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_cap
, sizeof(ptstrJoinBssParam
->rsn_cap
));
1889 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_cap
);
1892 *(pu8CurrByte
++) = REAL_JOIN_REQ
;
1895 *(pu8CurrByte
++) = ptstrJoinBssParam
->u8NoaEnbaled
;
1896 if (ptstrJoinBssParam
->u8NoaEnbaled
) {
1897 PRINT_D(HOSTINF_DBG
, "NOA present\n");
1899 *(pu8CurrByte
++) = (ptstrJoinBssParam
->tsf
) & 0xFF;
1900 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 8) & 0xFF;
1901 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 16) & 0xFF;
1902 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 24) & 0xFF;
1904 *(pu8CurrByte
++) = ptstrJoinBssParam
->u8Index
;
1906 *(pu8CurrByte
++) = ptstrJoinBssParam
->u8OppEnable
;
1908 if (ptstrJoinBssParam
->u8OppEnable
)
1909 *(pu8CurrByte
++) = ptstrJoinBssParam
->u8CtWindow
;
1911 *(pu8CurrByte
++) = ptstrJoinBssParam
->u8Count
;
1913 WILC_memcpy(pu8CurrByte
, ptstrJoinBssParam
->au8Duration
, sizeof(ptstrJoinBssParam
->au8Duration
));
1915 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->au8Duration
);
1917 WILC_memcpy(pu8CurrByte
, ptstrJoinBssParam
->au8Interval
, sizeof(ptstrJoinBssParam
->au8Interval
));
1919 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->au8Interval
);
1921 WILC_memcpy(pu8CurrByte
, ptstrJoinBssParam
->au8StartTime
, sizeof(ptstrJoinBssParam
->au8StartTime
));
1923 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->au8StartTime
);
1926 PRINT_D(HOSTINF_DBG
, "NOA not present\n");
1930 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1931 pu8CurrByte
= strWIDList
[u32WidsCount
].ps8WidVal
;
1934 #endif /* #ifdef WILC_PARSE_SCAN_IN_HOST*/
1938 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1939 * firmware at chip reset when processing the WIDs of the Connect Request.
1940 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1941 /* ////////////////////// */
1942 gu32WidConnRstHack
= 0;
1943 /* ////////////////////// */
1947 if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr
->pu8ssid
, 7)) {
1948 memcpy(gu8FlushedJoinReq
, pu8CurrByte
, gu32FlushedJoinReqSize
);
1949 gu8FlushedJoinReqDrvHandler
= (u32
)pstrWFIDrv
;
1952 PRINT_D(GENERIC_DBG
, "send HOST_IF_WAITING_CONN_RESP\n");
1954 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
) {
1955 WILC_memcpy(u8ConnectedSSID
, pstrHostIFconnectAttr
->pu8bssid
, ETH_ALEN
);
1957 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]));
1958 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]));
1961 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, u32WidsCount
, false, (u32
)pstrWFIDrv
);
1963 PRINT_ER("Handle_Connect()] failed to send config packet\n");
1964 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
1966 PRINT_D(GENERIC_DBG
, "set HOST_IF_WAITING_CONN_RESP\n");
1967 pstrWFIDrv
->enuHostIFstate
= HOST_IF_WAITING_CONN_RESP
;
1971 WILC_CATCH(s32Error
)
1973 tstrConnectInfo strConnectInfo
;
1975 WILC_TimerStop(&(pstrWFIDrv
->hConnectTimer
), NULL
);
1977 PRINT_D(HOSTINF_DBG
, "could not start connecting to the required network\n");
1979 WILC_memset(&strConnectInfo
, 0, sizeof(tstrConnectInfo
));
1981 if (pstrHostIFconnectAttr
->pfConnectResult
!= NULL
) {
1982 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
)
1983 WILC_memcpy(strConnectInfo
.au8bssid
, pstrHostIFconnectAttr
->pu8bssid
, 6);
1985 if (pstrHostIFconnectAttr
->pu8IEs
!= NULL
) {
1986 strConnectInfo
.ReqIEsLen
= pstrHostIFconnectAttr
->IEsLen
;
1987 strConnectInfo
.pu8ReqIEs
= (u8
*)WILC_MALLOC(pstrHostIFconnectAttr
->IEsLen
);
1988 WILC_memcpy(strConnectInfo
.pu8ReqIEs
,
1989 pstrHostIFconnectAttr
->pu8IEs
,
1990 pstrHostIFconnectAttr
->IEsLen
);
1993 pstrHostIFconnectAttr
->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP
,
1997 pstrHostIFconnectAttr
->pvUserArg
);
1998 /*Change state to idle*/
1999 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
2001 if (strConnectInfo
.pu8ReqIEs
!= NULL
) {
2002 WILC_FREE(strConnectInfo
.pu8ReqIEs
);
2003 strConnectInfo
.pu8ReqIEs
= NULL
;
2007 PRINT_ER("Connect callback function pointer is NULL \n");
2011 PRINT_D(HOSTINF_DBG
, "Deallocating connection parameters\n");
2012 /* Deallocate pstrHostIFconnectAttr->pu8bssid which was prevoisuly allocated by the sending thread */
2013 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
) {
2014 WILC_FREE(pstrHostIFconnectAttr
->pu8bssid
);
2015 pstrHostIFconnectAttr
->pu8bssid
= NULL
;
2018 /* Deallocate pstrHostIFconnectAttr->pu8ssid which was prevoisuly allocated by the sending thread */
2019 if (pstrHostIFconnectAttr
->pu8ssid
!= NULL
) {
2020 WILC_FREE(pstrHostIFconnectAttr
->pu8ssid
);
2021 pstrHostIFconnectAttr
->pu8ssid
= NULL
;
2024 /* Deallocate pstrHostIFconnectAttr->pu8IEs which was prevoisuly allocated by the sending thread */
2025 if (pstrHostIFconnectAttr
->pu8IEs
!= NULL
) {
2026 WILC_FREE(pstrHostIFconnectAttr
->pu8IEs
);
2027 pstrHostIFconnectAttr
->pu8IEs
= NULL
;
2030 if (pu8CurrByte
!= NULL
)
2031 WILC_FREE(pu8CurrByte
);
2036 * @brief Handle_FlushConnect
2037 * @details Sending config packet to firmware to flush an old connection
2038 * after switching FW from station one to hybrid one
2039 * @param[in] void * drvHandler
2040 * @return Error code.
2041 * @author Amr Abdel-Moghny
2046 static s32
Handle_FlushConnect(void *drvHandler
)
2048 s32 s32Error
= WILC_SUCCESS
;
2049 tstrWID strWIDList
[5];
2050 u32 u32WidsCount
= 0;
2051 u8
*pu8CurrByte
= NULL
;
2054 /* IEs to be inserted in Association Request */
2055 strWIDList
[u32WidsCount
].u16WIDid
= WID_INFO_ELEMENT_ASSOCIATE
;
2056 strWIDList
[u32WidsCount
].enuWIDtype
= WID_BIN_DATA
;
2057 strWIDList
[u32WidsCount
].ps8WidVal
= gu8FlushedInfoElemAsoc
;
2058 strWIDList
[u32WidsCount
].s32ValueSize
= gu32FlushedInfoElemAsocSize
;
2061 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_11I_MODE
;
2062 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
2063 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
2064 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(gu8Flushed11iMode
));
2069 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_AUTH_TYPE
;
2070 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
2071 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
2072 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&gu8FlushedAuthType
);
2076 #ifdef WILC_PARSE_SCAN_IN_HOST
2077 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_JOIN_REQ_EXTENDED
;
2078 strWIDList
[u32WidsCount
].enuWIDtype
= WID_STR
;
2079 strWIDList
[u32WidsCount
].s32ValueSize
= gu32FlushedJoinReqSize
;
2080 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)gu8FlushedJoinReq
;
2081 pu8CurrByte
= strWIDList
[u32WidsCount
].ps8WidVal
;
2083 pu8CurrByte
+= FLUSHED_BYTE_POS
;
2084 *(pu8CurrByte
) = FLUSHED_JOIN_REQ
;
2090 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, u32WidsCount
, false, gu8FlushedJoinReqDrvHandler
);
2092 PRINT_ER("Handle_Flush_Connect()] failed to send config packet\n");
2093 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
2096 WILC_CATCH(s32Error
)
2105 * @brief Handle_ConnectTimeout
2106 * @details Call connect notification callback function indicating connection failure
2108 * @return Error code.
2113 static s32
Handle_ConnectTimeout(void *drvHandler
)
2115 s32 s32Error
= WILC_SUCCESS
;
2116 tstrConnectInfo strConnectInfo
;
2118 u16 u16DummyReasonCode
= 0;
2119 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*) drvHandler
;
2121 if (pstrWFIDrv
== NULL
) {
2122 PRINT_ER("Driver handler is NULL\n");
2126 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
2128 gbScanWhileConnected
= false;
2131 WILC_memset(&strConnectInfo
, 0, sizeof(tstrConnectInfo
));
2134 /* First, we will notify the upper layer with the Connection failure {through the Connect Callback function},
2135 * then we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2136 * WID_DISCONNECT} */
2137 if (pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
!= NULL
) {
2138 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
!= NULL
) {
2139 WILC_memcpy(strConnectInfo
.au8bssid
,
2140 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
, 6);
2143 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
!= NULL
) {
2144 strConnectInfo
.ReqIEsLen
= pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
;
2145 strConnectInfo
.pu8ReqIEs
= (u8
*)WILC_MALLOC(pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
);
2146 WILC_memcpy(strConnectInfo
.pu8ReqIEs
,
2147 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
,
2148 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
);
2151 pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP
,
2155 pstrWFIDrv
->strWILC_UsrConnReq
.u32UserConnectPvoid
);
2157 /* Deallocation of strConnectInfo.pu8ReqIEs */
2158 if (strConnectInfo
.pu8ReqIEs
!= NULL
) {
2159 WILC_FREE(strConnectInfo
.pu8ReqIEs
);
2160 strConnectInfo
.pu8ReqIEs
= NULL
;
2163 PRINT_ER("Connect callback function pointer is NULL \n");
2166 /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2167 * WID_DISCONNECT} */
2168 strWID
.u16WIDid
= (u16
)WID_DISCONNECT
;
2169 strWID
.enuWIDtype
= WID_CHAR
;
2170 strWID
.ps8WidVal
= (s8
*)&u16DummyReasonCode
;
2171 strWID
.s32ValueSize
= sizeof(char);
2173 PRINT_D(HOSTINF_DBG
, "Sending disconnect request\n");
2175 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false, (u32
)pstrWFIDrv
);
2177 PRINT_ER("Failed to send dissconect config packet\n");
2179 /* Deallocation of the Saved Connect Request in the global Handle */
2180 pstrWFIDrv
->strWILC_UsrConnReq
.ssidLen
= 0;
2181 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
!= NULL
) {
2182 WILC_FREE(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
);
2183 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
= NULL
;
2186 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
!= NULL
) {
2187 WILC_FREE(pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
);
2188 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
= NULL
;
2191 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
= 0;
2192 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
!= NULL
) {
2193 WILC_FREE(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
);
2194 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
= NULL
;
2197 WILC_memset(u8ConnectedSSID
, 0, ETH_ALEN
);
2199 /*Freeing flushed join request params on connect timeout*/
2200 if (gu8FlushedJoinReq
!= NULL
&& gu8FlushedJoinReqDrvHandler
== (u32
)drvHandler
) {
2201 WILC_FREE(gu8FlushedJoinReq
);
2202 gu8FlushedJoinReq
= NULL
;
2204 if (gu8FlushedInfoElemAsoc
!= NULL
&& gu8FlushedJoinReqDrvHandler
== (u32
)drvHandler
) {
2205 WILC_FREE(gu8FlushedInfoElemAsoc
);
2206 gu8FlushedInfoElemAsoc
= NULL
;
2213 * @brief Handle_RcvdNtwrkInfo
2214 * @details Handling received network information
2215 * @param[in] tstrRcvdNetworkInfo* pstrRcvdNetworkInfo
2216 * @return Error code.
2221 static s32
Handle_RcvdNtwrkInfo(void *drvHandler
, tstrRcvdNetworkInfo
*pstrRcvdNetworkInfo
)
2224 bool bNewNtwrkFound
;
2228 s32 s32Error
= WILC_SUCCESS
;
2229 tstrNetworkInfo
*pstrNetworkInfo
= NULL
;
2230 void *pJoinParams
= NULL
;
2232 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
2236 bNewNtwrkFound
= true;
2237 PRINT_INFO(HOSTINF_DBG
, "Handling received network info\n");
2239 /*if there is a an ongoing scan request*/
2240 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
2241 PRINT_D(HOSTINF_DBG
, "State: Scanning, parsing network information received\n");
2242 ParseNetworkInfo(pstrRcvdNetworkInfo
->pu8Buffer
, &pstrNetworkInfo
);
2243 if ((pstrNetworkInfo
== NULL
)
2244 || (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
== NULL
)) {
2245 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
2248 /* check whether this network is discovered before */
2249 for (i
= 0; i
< pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
; i
++) {
2251 if ((pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[i
].au8bssid
!= NULL
) &&
2252 (pstrNetworkInfo
->au8bssid
!= NULL
)) {
2253 if (WILC_memcmp(pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[i
].au8bssid
,
2254 pstrNetworkInfo
->au8bssid
, 6) == 0) {
2255 if (pstrNetworkInfo
->s8rssi
<= pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[i
].s8rssi
) {
2256 /*we have already found this network with better rssi, so keep the old cached one and don't
2257 * send anything to the upper layer */
2258 PRINT_D(HOSTINF_DBG
, "Network previously discovered\n");
2261 /* here the same already found network is found again but with a better rssi, so just update
2262 * the rssi for this cached network and send this updated network to the upper layer but
2263 * don't add a new record for it */
2264 pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[i
].s8rssi
= pstrNetworkInfo
->s8rssi
;
2265 bNewNtwrkFound
= false;
2272 if (bNewNtwrkFound
== true) {
2273 /* here it is confirmed that it is a new discovered network,
2274 * so add its record then call the User CallBack function */
2276 PRINT_D(HOSTINF_DBG
, "New network found\n");
2278 if (pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
< MAX_NUM_SCANNED_NETWORKS
) {
2279 pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
].s8rssi
= pstrNetworkInfo
->s8rssi
;
2281 if ((pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
].au8bssid
!= NULL
)
2282 && (pstrNetworkInfo
->au8bssid
!= NULL
)) {
2283 WILC_memcpy(pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
].au8bssid
,
2284 pstrNetworkInfo
->au8bssid
, 6);
2286 pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
++;
2288 pstrNetworkInfo
->bNewNetwork
= true;
2289 /*Bug4218: Parsing Join Param*/
2290 /* add new BSS to JoinBssTable */
2291 #ifdef WILC_PARSE_SCAN_IN_HOST
2292 pJoinParams
= host_int_ParseJoinBssParam(pstrNetworkInfo
);
2293 #endif /*WILC_PARSE_SCAN_IN_HOST*/
2295 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND
, pstrNetworkInfo
,
2296 pstrWFIDrv
->strWILC_UsrScanReq
.u32UserScanPvoid
,
2302 PRINT_WRN(HOSTINF_DBG
, "Discovered networks exceeded max. limit \n");
2305 pstrNetworkInfo
->bNewNetwork
= false;
2306 /* just call the User CallBack function to send the same discovered network with its updated RSSI */
2307 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND
, pstrNetworkInfo
,
2308 pstrWFIDrv
->strWILC_UsrScanReq
.u32UserScanPvoid
, NULL
);
2313 WILC_CATCH(s32Error
)
2319 /* Deallocate pstrRcvdNetworkInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2320 if (pstrRcvdNetworkInfo
->pu8Buffer
!= NULL
) {
2321 WILC_FREE(pstrRcvdNetworkInfo
->pu8Buffer
);
2322 pstrRcvdNetworkInfo
->pu8Buffer
= NULL
;
2325 /*free structure allocated*/
2326 if (pstrNetworkInfo
!= NULL
) {
2327 DeallocateNetworkInfo(pstrNetworkInfo
);
2328 pstrNetworkInfo
= NULL
;
2335 * @brief Handle_RcvdGnrlAsyncInfo
2336 * @details Handling received asynchrous general network information
2337 * @param[in] tstrRcvdGnrlAsyncInfo* pstrRcvdGnrlAsyncInfo
2338 * @return Error code.
2343 static s32
Handle_RcvdGnrlAsyncInfo(void *drvHandler
, tstrRcvdGnrlAsyncInfo
*pstrRcvdGnrlAsyncInfo
)
2345 /* TODO: mostafa: till now, this function just handles only the received mac status msg, */
2346 /* which carries only 1 WID which have WID ID = WID_STATUS */
2347 s32 s32Error
= WILC_SUCCESS
;
2351 u16 u16WidID
= (u16
)WID_NIL
;
2354 u8 u8MacStatusReasonCode
;
2355 u8 u8MacStatusAdditionalInfo
;
2356 tstrConnectInfo strConnectInfo
;
2357 tstrDisconnectNotifInfo strDisconnectNotifInfo
;
2358 s32 s32Err
= WILC_SUCCESS
;
2359 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*) drvHandler
;
2360 if (pstrWFIDrv
== NULL
)
2361 PRINT_ER("Driver handler is NULL\n");
2362 PRINT_D(GENERIC_DBG
, "Current State = %d,Received state = %d\n", pstrWFIDrv
->enuHostIFstate
,
2363 pstrRcvdGnrlAsyncInfo
->pu8Buffer
[7]);
2365 if ((pstrWFIDrv
->enuHostIFstate
== HOST_IF_WAITING_CONN_RESP
) ||
2366 (pstrWFIDrv
->enuHostIFstate
== HOST_IF_CONNECTED
) ||
2367 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
2368 if ((pstrRcvdGnrlAsyncInfo
->pu8Buffer
== NULL
) ||
2369 (pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
== NULL
)) {
2370 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
2373 u8MsgType
= pstrRcvdGnrlAsyncInfo
->pu8Buffer
[0];
2375 /* Check whether the received message type is 'I' */
2376 if ('I' != u8MsgType
) {
2377 PRINT_ER("Received Message format incorrect.\n");
2378 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
2381 /* Extract message ID */
2382 u8MsgID
= pstrRcvdGnrlAsyncInfo
->pu8Buffer
[1];
2384 /* Extract message Length */
2385 u16MsgLen
= MAKE_WORD16(pstrRcvdGnrlAsyncInfo
->pu8Buffer
[2], pstrRcvdGnrlAsyncInfo
->pu8Buffer
[3]);
2387 /* Extract WID ID [expected to be = WID_STATUS] */
2388 u16WidID
= MAKE_WORD16(pstrRcvdGnrlAsyncInfo
->pu8Buffer
[4], pstrRcvdGnrlAsyncInfo
->pu8Buffer
[5]);
2390 /* Extract WID Length [expected to be = 1] */
2391 u8WidLen
= pstrRcvdGnrlAsyncInfo
->pu8Buffer
[6];
2393 /* get the WID value [expected to be one of two values: either MAC_CONNECTED = (1) or MAC_DISCONNECTED = (0)] */
2394 u8MacStatus
= pstrRcvdGnrlAsyncInfo
->pu8Buffer
[7];
2395 u8MacStatusReasonCode
= pstrRcvdGnrlAsyncInfo
->pu8Buffer
[8];
2396 u8MacStatusAdditionalInfo
= pstrRcvdGnrlAsyncInfo
->pu8Buffer
[9];
2397 PRINT_INFO(HOSTINF_DBG
, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus
, u8MacStatusReasonCode
, u8MacStatusAdditionalInfo
);
2398 if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_WAITING_CONN_RESP
) {
2399 /* our station had sent Association Request frame, so here it will get the Association Response frame then parse it */
2400 u32 u32RcvdAssocRespInfoLen
;
2401 tstrConnectRespInfo
*pstrConnectRespInfo
= NULL
;
2403 PRINT_D(HOSTINF_DBG
, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus
, u8MacStatusReasonCode
, u8MacStatusAdditionalInfo
);
2405 WILC_memset(&strConnectInfo
, 0, sizeof(tstrConnectInfo
));
2407 if (u8MacStatus
== MAC_CONNECTED
) {
2408 WILC_memset(gapu8RcvdAssocResp
, 0, MAX_ASSOC_RESP_FRAME_SIZE
);
2410 host_int_get_assoc_res_info((WILC_WFIDrvHandle
)pstrWFIDrv
,
2412 MAX_ASSOC_RESP_FRAME_SIZE
,
2413 &u32RcvdAssocRespInfoLen
);
2415 PRINT_INFO(HOSTINF_DBG
, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen
);
2417 if (u32RcvdAssocRespInfoLen
!= 0) {
2419 PRINT_D(HOSTINF_DBG
, "Parsing association response\n");
2420 s32Err
= ParseAssocRespInfo(gapu8RcvdAssocResp
, u32RcvdAssocRespInfoLen
,
2421 &pstrConnectRespInfo
);
2423 PRINT_ER("ParseAssocRespInfo() returned error %d \n", s32Err
);
2425 /* use the necessary parsed Info from the Received Association Response */
2426 strConnectInfo
.u16ConnectStatus
= pstrConnectRespInfo
->u16ConnectStatus
;
2428 if (strConnectInfo
.u16ConnectStatus
== SUCCESSFUL_STATUSCODE
) {
2429 PRINT_INFO(HOSTINF_DBG
, "Association response received : Successful connection status\n");
2430 if (pstrConnectRespInfo
->pu8RespIEs
!= NULL
) {
2431 strConnectInfo
.u16RespIEsLen
= pstrConnectRespInfo
->u16RespIEsLen
;
2434 strConnectInfo
.pu8RespIEs
= (u8
*)WILC_MALLOC(pstrConnectRespInfo
->u16RespIEsLen
);
2435 WILC_memcpy(strConnectInfo
.pu8RespIEs
, pstrConnectRespInfo
->pu8RespIEs
,
2436 pstrConnectRespInfo
->u16RespIEsLen
);
2440 /* deallocate the Assoc. Resp. parsed structure as it is not needed anymore */
2441 if (pstrConnectRespInfo
!= NULL
) {
2442 DeallocateAssocRespInfo(pstrConnectRespInfo
);
2443 pstrConnectRespInfo
= NULL
;
2449 /* The station has just received mac status and it also received assoc. response which
2450 * it was waiting for.
2451 * So check first the matching between the received mac status and the received status code in Asoc Resp */
2452 if ((u8MacStatus
== MAC_CONNECTED
) &&
2453 (strConnectInfo
.u16ConnectStatus
!= SUCCESSFUL_STATUSCODE
)) {
2454 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE \n");
2455 WILC_memset(u8ConnectedSSID
, 0, ETH_ALEN
);
2457 } else if (u8MacStatus
== MAC_DISCONNECTED
) {
2458 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
2459 WILC_memset(u8ConnectedSSID
, 0, ETH_ALEN
);
2462 /* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */
2463 /* through a structure of type tstrConnectRespInfo */
2464 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
!= NULL
) {
2465 PRINT_D(HOSTINF_DBG
, "Retrieving actual BSSID from AP\n");
2466 WILC_memcpy(strConnectInfo
.au8bssid
, pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
, 6);
2468 if ((u8MacStatus
== MAC_CONNECTED
) &&
2469 (strConnectInfo
.u16ConnectStatus
== SUCCESSFUL_STATUSCODE
)) {
2470 WILC_memcpy(pstrWFIDrv
->au8AssociatedBSSID
,
2471 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
, ETH_ALEN
);
2476 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
!= NULL
) {
2477 strConnectInfo
.ReqIEsLen
= pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
;
2478 strConnectInfo
.pu8ReqIEs
= (u8
*)WILC_MALLOC(pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
);
2479 WILC_memcpy(strConnectInfo
.pu8ReqIEs
,
2480 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
,
2481 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
);
2485 WILC_TimerStop(&(pstrWFIDrv
->hConnectTimer
), NULL
);
2486 pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP
,
2490 pstrWFIDrv
->strWILC_UsrConnReq
.u32UserConnectPvoid
);
2493 /* if received mac status is MAC_CONNECTED and
2494 * received status code in Asoc Resp is SUCCESSFUL_STATUSCODE, change state to CONNECTED
2495 * else change state to IDLE */
2496 if ((u8MacStatus
== MAC_CONNECTED
) &&
2497 (strConnectInfo
.u16ConnectStatus
== SUCCESSFUL_STATUSCODE
)) {
2498 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2500 host_int_set_power_mgmt((WILC_WFIDrvHandle
)pstrWFIDrv
, 0, 0);
2503 PRINT_D(HOSTINF_DBG
, "MAC status : CONNECTED and Connect Status : Successful\n");
2504 pstrWFIDrv
->enuHostIFstate
= HOST_IF_CONNECTED
;
2506 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2507 PRINT_D(GENERIC_DBG
, "Obtaining an IP, Disable Scan\n");
2508 g_obtainingIP
= true;
2509 WILC_TimerStart(&hDuringIpTimer
, 10000, NULL
, NULL
);
2512 #ifdef WILC_PARSE_SCAN_IN_HOST
2513 /* open a BA session if possible */
2514 /* if(pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable) */
2518 /* host_int_addBASession(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid,0, */
2519 /* BA_SESSION_DEFAULT_BUFFER_SIZE,BA_SESSION_DEFAULT_TIMEOUT); */
2521 PRINT_D(HOSTINF_DBG
, "MAC status : %d and Connect Status : %d\n", u8MacStatus
, strConnectInfo
.u16ConnectStatus
);
2522 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
2523 gbScanWhileConnected
= false;
2527 if (strConnectInfo
.pu8RespIEs
!= NULL
) {
2528 WILC_FREE(strConnectInfo
.pu8RespIEs
);
2529 strConnectInfo
.pu8RespIEs
= NULL
;
2532 if (strConnectInfo
.pu8ReqIEs
!= NULL
) {
2533 WILC_FREE(strConnectInfo
.pu8ReqIEs
);
2534 strConnectInfo
.pu8ReqIEs
= NULL
;
2538 pstrWFIDrv
->strWILC_UsrConnReq
.ssidLen
= 0;
2539 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
!= NULL
) {
2540 WILC_FREE(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
);
2541 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
= NULL
;
2544 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
!= NULL
) {
2545 WILC_FREE(pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
);
2546 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
= NULL
;
2549 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
= 0;
2550 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
!= NULL
) {
2551 WILC_FREE(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
);
2552 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
= NULL
;
2555 } else if ((u8MacStatus
== MAC_DISCONNECTED
) &&
2556 (pstrWFIDrv
->enuHostIFstate
== HOST_IF_CONNECTED
)) {
2557 /* Disassociation or Deauthentication frame has been received */
2558 PRINT_D(HOSTINF_DBG
, "Received MAC_DISCONNECTED from the FW\n");
2560 WILC_memset(&strDisconnectNotifInfo
, 0, sizeof(tstrDisconnectNotifInfo
));
2562 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
2563 PRINT_D(HOSTINF_DBG
, "\n\n<< Abort the running OBSS Scan >> \n\n");
2564 WILC_TimerStop(&(pstrWFIDrv
->hScanTimer
), NULL
);
2565 Handle_ScanDone((void *)pstrWFIDrv
, SCAN_EVENT_ABORTED
);
2568 strDisconnectNotifInfo
.u16reason
= 0;
2569 strDisconnectNotifInfo
.ie
= NULL
;
2570 strDisconnectNotifInfo
.ie_len
= 0;
2572 if (pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
!= NULL
) {
2573 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2575 g_obtainingIP
= false;
2576 host_int_set_power_mgmt((WILC_WFIDrvHandle
)pstrWFIDrv
, 0, 0);
2579 pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF
,
2582 &strDisconnectNotifInfo
,
2583 pstrWFIDrv
->strWILC_UsrConnReq
.u32UserConnectPvoid
);
2586 PRINT_ER("Connect result callback function is NULL \n");
2589 WILC_memset(pstrWFIDrv
->au8AssociatedBSSID
, 0, ETH_ALEN
);
2594 /* if Information Elements were retrieved from the Received deauth/disassoc frame, then they
2595 * should be deallocated here */
2597 * if(strDisconnectNotifInfo.ie != NULL)
2599 * WILC_FREE(strDisconnectNotifInfo.ie);
2600 * strDisconnectNotifInfo.ie = NULL;
2604 pstrWFIDrv
->strWILC_UsrConnReq
.ssidLen
= 0;
2605 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
!= NULL
) {
2606 WILC_FREE(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
);
2607 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
= NULL
;
2610 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
!= NULL
) {
2611 WILC_FREE(pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
);
2612 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
= NULL
;
2615 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
= 0;
2616 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
!= NULL
) {
2617 WILC_FREE(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
);
2618 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
= NULL
;
2622 /*Freeing flushed join request params on receiving*/
2623 /*MAC_DISCONNECTED while connected*/
2624 if (gu8FlushedJoinReq
!= NULL
&& gu8FlushedJoinReqDrvHandler
== (u32
)drvHandler
) {
2625 WILC_FREE(gu8FlushedJoinReq
);
2626 gu8FlushedJoinReq
= NULL
;
2628 if (gu8FlushedInfoElemAsoc
!= NULL
&& gu8FlushedJoinReqDrvHandler
== (u32
)drvHandler
) {
2629 WILC_FREE(gu8FlushedInfoElemAsoc
);
2630 gu8FlushedInfoElemAsoc
= NULL
;
2633 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
2634 gbScanWhileConnected
= false;
2636 } else if ((u8MacStatus
== MAC_DISCONNECTED
) &&
2637 (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
!= NULL
)) {
2638 PRINT_D(HOSTINF_DBG
, "Received MAC_DISCONNECTED from the FW while scanning\n");
2639 PRINT_D(HOSTINF_DBG
, "\n\n<< Abort the running Scan >> \n\n");
2640 /*Abort the running scan*/
2641 WILC_TimerStop(&(pstrWFIDrv
->hScanTimer
), NULL
);
2642 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
)
2643 Handle_ScanDone((void *)pstrWFIDrv
, SCAN_EVENT_ABORTED
);
2649 WILC_CATCH(s32Error
)
2654 /* Deallocate pstrRcvdGnrlAsyncInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2655 if (pstrRcvdGnrlAsyncInfo
->pu8Buffer
!= NULL
) {
2656 WILC_FREE(pstrRcvdGnrlAsyncInfo
->pu8Buffer
);
2657 pstrRcvdGnrlAsyncInfo
->pu8Buffer
= NULL
;
2665 * @details Sending config packet to firmware to set key
2666 * @param[in] tstrHostIFkeyAttr* pstrHostIFkeyAttr
2667 * @return Error code.
2672 static int Handle_Key(void *drvHandler
, tstrHostIFkeyAttr
*pstrHostIFkeyAttr
)
2674 s32 s32Error
= WILC_SUCCESS
;
2676 #ifdef WILC_AP_EXTERNAL_MLME
2677 tstrWID strWIDList
[5];
2683 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
2686 switch (pstrHostIFkeyAttr
->enuKeyType
) {
2691 #ifdef WILC_AP_EXTERNAL_MLME
2692 if (pstrHostIFkeyAttr
->u8KeyAction
& ADDKEY_AP
) {
2694 PRINT_D(HOSTINF_DBG
, "Handling WEP key\n");
2695 PRINT_D(GENERIC_DBG
, "ID Hostint is %d\n", (pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
));
2696 strWIDList
[0].u16WIDid
= (u16
)WID_11I_MODE
;
2697 strWIDList
[0].enuWIDtype
= WID_CHAR
;
2698 strWIDList
[0].s32ValueSize
= sizeof(char);
2699 strWIDList
[0].ps8WidVal
= (s8
*)(&(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8mode
));
2701 strWIDList
[1].u16WIDid
= WID_AUTH_TYPE
;
2702 strWIDList
[1].enuWIDtype
= WID_CHAR
;
2703 strWIDList
[1].s32ValueSize
= sizeof(char);
2704 strWIDList
[1].ps8WidVal
= (s8
*)(&(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.tenuAuth_type
));
2706 strWIDList
[2].u16WIDid
= (u16
)WID_KEY_ID
;
2707 strWIDList
[2].enuWIDtype
= WID_CHAR
;
2709 strWIDList
[2].ps8WidVal
= (s8
*)(&(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
));
2710 strWIDList
[2].s32ValueSize
= sizeof(char);
2713 pu8keybuf
= (u8
*)WILC_MALLOC(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
);
2716 if (pu8keybuf
== NULL
) {
2717 PRINT_ER("No buffer to send Key\n");
2721 WILC_memcpy(pu8keybuf
, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
,
2722 pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
);
2725 WILC_FREE(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
);
2727 strWIDList
[3].u16WIDid
= (u16
)WID_WEP_KEY_VALUE
;
2728 strWIDList
[3].enuWIDtype
= WID_STR
;
2729 strWIDList
[3].s32ValueSize
= pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
;
2730 strWIDList
[3].ps8WidVal
= (s8
*)pu8keybuf
;
2733 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, 4, true, (u32
)pstrWFIDrv
);
2734 WILC_FREE(pu8keybuf
);
2740 if (pstrHostIFkeyAttr
->u8KeyAction
& ADDKEY
) {
2741 PRINT_D(HOSTINF_DBG
, "Handling WEP key\n");
2742 pu8keybuf
= (u8
*)WILC_MALLOC(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
+ 2);
2743 if (pu8keybuf
== NULL
) {
2744 PRINT_ER("No buffer to send Key\n");
2747 pu8keybuf
[0] = pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
;
2749 WILC_memcpy(pu8keybuf
+ 1, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
, 1);
2751 WILC_memcpy(pu8keybuf
+ 2, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
,
2752 pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
);
2754 WILC_FREE(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
);
2756 strWID
.u16WIDid
= (u16
)WID_ADD_WEP_KEY
;
2757 strWID
.enuWIDtype
= WID_STR
;
2758 strWID
.ps8WidVal
= (s8
*)pu8keybuf
;
2759 strWID
.s32ValueSize
= pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
+ 2;
2761 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
2762 WILC_FREE(pu8keybuf
);
2763 } else if (pstrHostIFkeyAttr
->u8KeyAction
& REMOVEKEY
) {
2765 PRINT_D(HOSTINF_DBG
, "Removing key\n");
2766 strWID
.u16WIDid
= (u16
)WID_REMOVE_WEP_KEY
;
2767 strWID
.enuWIDtype
= WID_STR
;
2769 s8idxarray
[0] = (s8
)pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
;
2770 strWID
.ps8WidVal
= s8idxarray
;
2771 strWID
.s32ValueSize
= 1;
2773 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
2775 strWID
.u16WIDid
= (u16
)WID_KEY_ID
;
2776 strWID
.enuWIDtype
= WID_CHAR
;
2777 strWID
.ps8WidVal
= (s8
*)(&(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
));
2778 strWID
.s32ValueSize
= sizeof(char);
2780 PRINT_D(HOSTINF_DBG
, "Setting default key index\n");
2782 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
2784 up(&(pstrWFIDrv
->hSemTestKeyBlock
));
2788 #ifdef WILC_AP_EXTERNAL_MLME
2789 if (pstrHostIFkeyAttr
->u8KeyAction
& ADDKEY_AP
) {
2790 pu8keybuf
= (u8
*)WILC_MALLOC(RX_MIC_KEY_MSG_LEN
);
2791 if (pu8keybuf
== NULL
) {
2792 PRINT_ER("No buffer to send RxGTK Key\n");
2794 goto _WPARxGtk_end_case_
;
2797 WILC_memset(pu8keybuf
, 0, RX_MIC_KEY_MSG_LEN
);
2800 /*|----------------------------------------------------------------------------|
2801 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2802 * |------------|---------|-------|------------|---------------|----------------|
2803 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2807 if (pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8seq
!= NULL
)
2808 WILC_memcpy(pu8keybuf
+ 6, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8seq
, 8);
2811 WILC_memcpy(pu8keybuf
+ 14, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8keyidx
, 1);
2813 WILC_memcpy(pu8keybuf
+ 15, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
, 1);
2815 WILC_memcpy(pu8keybuf
+ 16, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
,
2816 pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
);
2817 /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */
2818 strWIDList
[0].u16WIDid
= (u16
)WID_11I_MODE
;
2819 strWIDList
[0].enuWIDtype
= WID_CHAR
;
2820 strWIDList
[0].s32ValueSize
= sizeof(char);
2821 strWIDList
[0].ps8WidVal
= (s8
*)(&(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Ciphermode
));
2823 strWIDList
[1].u16WIDid
= (u16
)WID_ADD_RX_GTK
;
2824 strWIDList
[1].enuWIDtype
= WID_STR
;
2825 strWIDList
[1].ps8WidVal
= (s8
*)pu8keybuf
;
2826 strWIDList
[1].s32ValueSize
= RX_MIC_KEY_MSG_LEN
;
2828 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, 2, true, (u32
)pstrWFIDrv
);
2830 WILC_FREE(pu8keybuf
);
2832 /* ////////////////////////// */
2833 up(&(pstrWFIDrv
->hSemTestKeyBlock
));
2834 /* ///////////////////////// */
2838 if (pstrHostIFkeyAttr
->u8KeyAction
& ADDKEY
) {
2839 PRINT_D(HOSTINF_DBG
, "Handling group key(Rx) function\n");
2841 pu8keybuf
= (u8
*)WILC_MALLOC(RX_MIC_KEY_MSG_LEN
);
2842 if (pu8keybuf
== NULL
) {
2843 PRINT_ER("No buffer to send RxGTK Key\n");
2845 goto _WPARxGtk_end_case_
;
2848 WILC_memset(pu8keybuf
, 0, RX_MIC_KEY_MSG_LEN
);
2851 /*|----------------------------------------------------------------------------|
2852 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2853 * |------------|---------|-------|------------|---------------|----------------|
2854 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2856 if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_CONNECTED
) {
2857 WILC_memcpy(pu8keybuf
, pstrWFIDrv
->au8AssociatedBSSID
, ETH_ALEN
);
2859 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED \n");
2862 WILC_memcpy(pu8keybuf
+ 6, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8seq
, 8);
2864 WILC_memcpy(pu8keybuf
+ 14, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8keyidx
, 1);
2866 WILC_memcpy(pu8keybuf
+ 15, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
, 1);
2867 WILC_memcpy(pu8keybuf
+ 16, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
,
2868 pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
);
2870 strWID
.u16WIDid
= (u16
)WID_ADD_RX_GTK
;
2871 strWID
.enuWIDtype
= WID_STR
;
2872 strWID
.ps8WidVal
= (s8
*)pu8keybuf
;
2873 strWID
.s32ValueSize
= RX_MIC_KEY_MSG_LEN
;
2875 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
2877 WILC_FREE(pu8keybuf
);
2879 /* ////////////////////////// */
2880 up(&(pstrWFIDrv
->hSemTestKeyBlock
));
2881 /* ///////////////////////// */
2883 _WPARxGtk_end_case_
:
2884 WILC_FREE(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
);
2885 WILC_FREE(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8seq
);
2892 #ifdef WILC_AP_EXTERNAL_MLME
2893 if (pstrHostIFkeyAttr
->u8KeyAction
& ADDKEY_AP
) {
2896 pu8keybuf
= (u8
*)WILC_MALLOC(PTK_KEY_MSG_LEN
+ 1);
2900 if (pu8keybuf
== NULL
) {
2901 PRINT_ER("No buffer to send PTK Key\n");
2903 goto _WPAPtk_end_case_
;
2907 /*|-----------------------------------------------------------------------------|
2908 * |Station address | keyidx |Key Length |Temporal Key | Rx Michael Key |Tx Michael Key |
2909 * |----------------|------------ |--------------|----------------|---------------|
2910 | 6 bytes | 1 byte | 1byte | 16 bytes | 8 bytes | 8 bytes |
2911 |-----------------------------------------------------------------------------|*/
2913 WILC_memcpy(pu8keybuf
, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8macaddr
, 6); /*1 bytes Key Length */
2915 WILC_memcpy(pu8keybuf
+ 6, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8keyidx
, 1);
2916 WILC_memcpy(pu8keybuf
+ 7, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
, 1);
2918 WILC_memcpy(pu8keybuf
+ 8, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
,
2919 pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
);
2922 strWIDList
[0].u16WIDid
= (u16
)WID_11I_MODE
;
2923 strWIDList
[0].enuWIDtype
= WID_CHAR
;
2924 strWIDList
[0].s32ValueSize
= sizeof(char);
2925 strWIDList
[0].ps8WidVal
= (s8
*)(&(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Ciphermode
));
2927 strWIDList
[1].u16WIDid
= (u16
)WID_ADD_PTK
;
2928 strWIDList
[1].enuWIDtype
= WID_STR
;
2929 strWIDList
[1].ps8WidVal
= (s8
*)pu8keybuf
;
2930 strWIDList
[1].s32ValueSize
= PTK_KEY_MSG_LEN
+ 1;
2932 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, 2, true, (u32
)pstrWFIDrv
);
2933 WILC_FREE(pu8keybuf
);
2935 /* ////////////////////////// */
2936 up(&(pstrWFIDrv
->hSemTestKeyBlock
));
2937 /* ///////////////////////// */
2940 if (pstrHostIFkeyAttr
->u8KeyAction
& ADDKEY
) {
2943 pu8keybuf
= (u8
*)WILC_MALLOC(PTK_KEY_MSG_LEN
);
2947 if (pu8keybuf
== NULL
) {
2948 PRINT_ER("No buffer to send PTK Key\n");
2950 goto _WPAPtk_end_case_
;
2954 /*|-----------------------------------------------------------------------------|
2955 * |Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
2956 * |----------------|------------|--------------|----------------|---------------|
2957 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
2958 |-----------------------------------------------------------------------------|*/
2960 WILC_memcpy(pu8keybuf
, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8macaddr
, 6); /*1 bytes Key Length */
2962 WILC_memcpy(pu8keybuf
+ 6, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
, 1);
2964 WILC_memcpy(pu8keybuf
+ 7, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
,
2965 pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
);
2968 strWID
.u16WIDid
= (u16
)WID_ADD_PTK
;
2969 strWID
.enuWIDtype
= WID_STR
;
2970 strWID
.ps8WidVal
= (s8
*)pu8keybuf
;
2971 strWID
.s32ValueSize
= PTK_KEY_MSG_LEN
;
2973 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
2974 WILC_FREE(pu8keybuf
);
2976 /* ////////////////////////// */
2977 up(&(pstrWFIDrv
->hSemTestKeyBlock
));
2978 /* ///////////////////////// */
2982 WILC_FREE(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
);
2991 PRINT_D(HOSTINF_DBG
, "Handling PMKSA key\n");
2993 pu8keybuf
= (u8
*)WILC_MALLOC((pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFpmkidAttr
.numpmkid
* PMKSA_KEY_LEN
) + 1);
2994 if (pu8keybuf
== NULL
) {
2995 PRINT_ER("No buffer to send PMKSA Key\n");
2999 pu8keybuf
[0] = pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFpmkidAttr
.numpmkid
;
3001 for (i
= 0; i
< pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFpmkidAttr
.numpmkid
; i
++) {
3003 WILC_memcpy(pu8keybuf
+ ((PMKSA_KEY_LEN
* i
) + 1), pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFpmkidAttr
.pmkidlist
[i
].bssid
, ETH_ALEN
);
3004 WILC_memcpy(pu8keybuf
+ ((PMKSA_KEY_LEN
* i
) + ETH_ALEN
+ 1), pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFpmkidAttr
.pmkidlist
[i
].pmkid
, PMKID_LEN
);
3007 strWID
.u16WIDid
= (u16
)WID_PMKID_INFO
;
3008 strWID
.enuWIDtype
= WID_STR
;
3009 strWID
.ps8WidVal
= (s8
*)pu8keybuf
;
3010 strWID
.s32ValueSize
= (pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFpmkidAttr
.numpmkid
* PMKSA_KEY_LEN
) + 1;
3012 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
3014 WILC_FREE(pu8keybuf
);
3019 PRINT_ER("Failed to send key config packet\n");
3027 * @brief Handle_Disconnect
3028 * @details Sending config packet to firmware to disconnect
3035 static void Handle_Disconnect(void *drvHandler
)
3039 s32 s32Error
= WILC_SUCCESS
;
3040 u16 u16DummyReasonCode
= 0;
3041 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3044 strWID
.u16WIDid
= (u16
)WID_DISCONNECT
;
3045 strWID
.enuWIDtype
= WID_CHAR
;
3046 strWID
.ps8WidVal
= (s8
*)&u16DummyReasonCode
;
3047 strWID
.s32ValueSize
= sizeof(char);
3051 PRINT_D(HOSTINF_DBG
, "Sending disconnect request\n");
3053 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3055 g_obtainingIP
= false;
3056 host_int_set_power_mgmt((WILC_WFIDrvHandle
)pstrWFIDrv
, 0, 0);
3059 WILC_memset(u8ConnectedSSID
, 0, ETH_ALEN
);
3061 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false, (u32
)pstrWFIDrv
);
3064 PRINT_ER("Failed to send dissconect config packet\n");
3065 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3067 tstrDisconnectNotifInfo strDisconnectNotifInfo
;
3069 WILC_memset(&strDisconnectNotifInfo
, 0, sizeof(tstrDisconnectNotifInfo
));
3071 strDisconnectNotifInfo
.u16reason
= 0;
3072 strDisconnectNotifInfo
.ie
= NULL
;
3073 strDisconnectNotifInfo
.ie_len
= 0;
3075 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
3076 WILC_TimerStop(&(pstrWFIDrv
->hScanTimer
), NULL
);
3077 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult(SCAN_EVENT_ABORTED
, NULL
,
3078 pstrWFIDrv
->strWILC_UsrScanReq
.u32UserScanPvoid
, NULL
);
3080 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
= NULL
;
3083 if (pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
!= NULL
) {
3086 /*Stop connect timer, if connection in progress*/
3087 if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_WAITING_CONN_RESP
) {
3088 PRINT_D(HOSTINF_DBG
, "Upper layer requested termination of connection\n");
3089 WILC_TimerStop(&(pstrWFIDrv
->hConnectTimer
), NULL
);
3092 pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF
, NULL
,
3093 0, &strDisconnectNotifInfo
, pstrWFIDrv
->strWILC_UsrConnReq
.u32UserConnectPvoid
);
3095 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL \n");
3098 gbScanWhileConnected
= false;
3100 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
3102 WILC_memset(pstrWFIDrv
->au8AssociatedBSSID
, 0, ETH_ALEN
);
3106 pstrWFIDrv
->strWILC_UsrConnReq
.ssidLen
= 0;
3107 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
!= NULL
) {
3108 WILC_FREE(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
);
3109 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
= NULL
;
3112 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
!= NULL
) {
3113 WILC_FREE(pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
);
3114 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
= NULL
;
3117 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
= 0;
3118 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
!= NULL
) {
3119 WILC_FREE(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
);
3120 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
= NULL
;
3125 if (gu8FlushedJoinReq
!= NULL
&& gu8FlushedJoinReqDrvHandler
== (u32
)drvHandler
) {
3126 WILC_FREE(gu8FlushedJoinReq
);
3127 gu8FlushedJoinReq
= NULL
;
3129 if (gu8FlushedInfoElemAsoc
!= NULL
&& gu8FlushedJoinReqDrvHandler
== (u32
)drvHandler
) {
3130 WILC_FREE(gu8FlushedInfoElemAsoc
);
3131 gu8FlushedInfoElemAsoc
= NULL
;
3136 WILC_CATCH(s32Error
)
3141 /* ////////////////////////// */
3142 up(&(pstrWFIDrv
->hSemTestDisconnectBlock
));
3143 /* ///////////////////////// */
3148 void resolve_disconnect_aberration(void *drvHandler
)
3150 tstrWILC_WFIDrv
*pstrWFIDrv
;
3152 pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3153 if (pstrWFIDrv
== NULL
)
3155 if ((pstrWFIDrv
->enuHostIFstate
== HOST_IF_WAITING_CONN_RESP
) || (pstrWFIDrv
->enuHostIFstate
== HOST_IF_CONNECTING
)) {
3156 PRINT_D(HOSTINF_DBG
, "\n\n<< correcting Supplicant state machine >>\n\n");
3157 host_int_disconnect((WILC_WFIDrvHandle
)pstrWFIDrv
, 1);
3160 static s32
Switch_Log_Terminal(void *drvHandler
)
3164 s32 s32Error
= WILC_SUCCESS
;
3166 static char dummy
= 9;
3167 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3169 strWID
.u16WIDid
= (u16
)WID_LOGTerminal_Switch
;
3170 strWID
.enuWIDtype
= WID_CHAR
;
3171 strWID
.ps8WidVal
= &dummy
;
3172 strWID
.s32ValueSize
= sizeof(char);
3174 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
3178 PRINT_D(HOSTINF_DBG
, "Failed to switch log terminal\n");
3179 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
3181 PRINT_INFO(HOSTINF_DBG
, "MAC address set :: \n");
3186 WILC_CATCH(s32Error
)
3195 * @brief Handle_GetChnl
3196 * @details Sending config packet to get channel
3204 static s32
Handle_GetChnl(void *drvHandler
)
3207 s32 s32Error
= WILC_SUCCESS
;
3209 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
3210 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3211 strWID
.u16WIDid
= (u16
)WID_CURRENT_CHANNEL
;
3212 strWID
.enuWIDtype
= WID_CHAR
;
3213 strWID
.ps8WidVal
= (s8
*)&gu8Chnl
;
3214 strWID
.s32ValueSize
= sizeof(char);
3216 PRINT_D(HOSTINF_DBG
, "Getting channel value\n");
3218 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
3219 /*get the value by searching the local copy*/
3221 PRINT_ER("Failed to get channel number\n");
3222 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3226 WILC_CATCH(s32Error
)
3230 up(&(pstrWFIDrv
->hSemGetCHNL
));
3240 * @brief Handle_GetRssi
3241 * @details Sending config packet to get RSSI
3248 static void Handle_GetRssi(void *drvHandler
)
3250 s32 s32Error
= WILC_SUCCESS
;
3252 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3254 strWID
.u16WIDid
= (u16
)WID_RSSI
;
3255 strWID
.enuWIDtype
= WID_CHAR
;
3256 strWID
.ps8WidVal
= &gs8Rssi
;
3257 strWID
.s32ValueSize
= sizeof(char);
3260 PRINT_D(HOSTINF_DBG
, "Getting RSSI value\n");
3262 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
3264 PRINT_ER("Failed to get RSSI value\n");
3265 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3268 WILC_CATCH(s32Error
)
3272 up(&(pstrWFIDrv
->hSemGetRSSI
));
3278 static void Handle_GetLinkspeed(void *drvHandler
)
3280 s32 s32Error
= WILC_SUCCESS
;
3282 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3286 strWID
.u16WIDid
= (u16
)WID_LINKSPEED
;
3287 strWID
.enuWIDtype
= WID_CHAR
;
3288 strWID
.ps8WidVal
= &gs8lnkspd
;
3289 strWID
.s32ValueSize
= sizeof(char);
3291 PRINT_D(HOSTINF_DBG
, "Getting LINKSPEED value\n");
3293 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
3295 PRINT_ER("Failed to get LINKSPEED value\n");
3296 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3299 WILC_CATCH(s32Error
)
3303 up(&(pstrWFIDrv
->hSemGetLINKSPEED
));
3308 s32
Handle_GetStatistics(void *drvHandler
, tstrStatistics
*pstrStatistics
)
3310 tstrWID strWIDList
[5];
3311 uint32_t u32WidsCount
= 0, s32Error
= 0;
3313 strWIDList
[u32WidsCount
].u16WIDid
= WID_LINKSPEED
;
3314 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
3315 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
3316 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrStatistics
->u8LinkSpeed
));
3319 strWIDList
[u32WidsCount
].u16WIDid
= WID_RSSI
;
3320 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
3321 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
3322 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrStatistics
->s8RSSI
));
3325 strWIDList
[u32WidsCount
].u16WIDid
= WID_SUCCESS_FRAME_COUNT
;
3326 strWIDList
[u32WidsCount
].enuWIDtype
= WID_INT
;
3327 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(u32
);
3328 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrStatistics
->u32TxCount
));
3331 strWIDList
[u32WidsCount
].u16WIDid
= WID_RECEIVED_FRAGMENT_COUNT
;
3332 strWIDList
[u32WidsCount
].enuWIDtype
= WID_INT
;
3333 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(u32
);
3334 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrStatistics
->u32RxCount
));
3337 strWIDList
[u32WidsCount
].u16WIDid
= WID_FAILED_COUNT
;
3338 strWIDList
[u32WidsCount
].enuWIDtype
= WID_INT
;
3339 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(u32
);
3340 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrStatistics
->u32TxFailureCount
));
3343 s32Error
= SendConfigPkt(GET_CFG
, strWIDList
, u32WidsCount
, false, (u32
)drvHandler
);
3346 PRINT_ER("Failed to send scan paramters config packet\n");
3347 /* WILC_ERRORREPORT(s32Error, s32Error); */
3355 #ifdef WILC_AP_EXTERNAL_MLME
3359 * @brief Handle_Get_InActiveTime
3360 * @details Sending config packet to set mac adddress for station and
3369 static s32
Handle_Get_InActiveTime(void *drvHandler
, tstrHostIfStaInactiveT
*strHostIfStaInactiveT
)
3372 s32 s32Error
= WILC_SUCCESS
;
3375 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3378 strWID
.u16WIDid
= (u16
)WID_SET_STA_MAC_INACTIVE_TIME
;
3379 strWID
.enuWIDtype
= WID_STR
;
3380 strWID
.s32ValueSize
= ETH_ALEN
;
3381 strWID
.ps8WidVal
= (u8
*)WILC_MALLOC(strWID
.s32ValueSize
);
3384 stamac
= strWID
.ps8WidVal
;
3385 WILC_memcpy(stamac
, strHostIfStaInactiveT
->mac
, ETH_ALEN
);
3388 PRINT_D(CFG80211_DBG
, "SETING STA inactive time\n");
3391 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
3392 /*get the value by searching the local copy*/
3394 PRINT_ER("Failed to SET incative time\n");
3395 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3399 strWID
.u16WIDid
= (u16
)WID_GET_INACTIVE_TIME
;
3400 strWID
.enuWIDtype
= WID_INT
;
3401 strWID
.ps8WidVal
= (s8
*)&gu32InactiveTime
;
3402 strWID
.s32ValueSize
= sizeof(u32
);
3405 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
3406 /*get the value by searching the local copy*/
3408 PRINT_ER("Failed to get incative time\n");
3409 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3413 PRINT_D(CFG80211_DBG
, "Getting inactive time : %d\n", gu32InactiveTime
);
3415 up(&(pstrWFIDrv
->hSemInactiveTime
));
3416 WILC_CATCH(s32Error
)
3430 * @brief Handle_AddBeacon
3431 * @details Sending config packet to add beacon
3432 * @param[in] tstrHostIFSetBeacon* pstrSetBeaconParam
3438 static void Handle_AddBeacon(void *drvHandler
, tstrHostIFSetBeacon
*pstrSetBeaconParam
)
3440 s32 s32Error
= WILC_SUCCESS
;
3443 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3444 PRINT_D(HOSTINF_DBG
, "Adding BEACON\n");
3446 strWID
.u16WIDid
= (u16
)WID_ADD_BEACON
;
3447 strWID
.enuWIDtype
= WID_BIN
;
3448 strWID
.s32ValueSize
= pstrSetBeaconParam
->u32HeadLen
+ pstrSetBeaconParam
->u32TailLen
+ 16;
3449 strWID
.ps8WidVal
= WILC_MALLOC(strWID
.s32ValueSize
);
3450 if (strWID
.ps8WidVal
== NULL
)
3451 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3453 pu8CurrByte
= strWID
.ps8WidVal
;
3454 *pu8CurrByte
++ = (pstrSetBeaconParam
->u32Interval
& 0xFF);
3455 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32Interval
>> 8) & 0xFF);
3456 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32Interval
>> 16) & 0xFF);
3457 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32Interval
>> 24) & 0xFF);
3459 *pu8CurrByte
++ = (pstrSetBeaconParam
->u32DTIMPeriod
& 0xFF);
3460 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32DTIMPeriod
>> 8) & 0xFF);
3461 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32DTIMPeriod
>> 16) & 0xFF);
3462 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32DTIMPeriod
>> 24) & 0xFF);
3464 *pu8CurrByte
++ = (pstrSetBeaconParam
->u32HeadLen
& 0xFF);
3465 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32HeadLen
>> 8) & 0xFF);
3466 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32HeadLen
>> 16) & 0xFF);
3467 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32HeadLen
>> 24) & 0xFF);
3469 memcpy(pu8CurrByte
, pstrSetBeaconParam
->pu8Head
, pstrSetBeaconParam
->u32HeadLen
);
3470 pu8CurrByte
+= pstrSetBeaconParam
->u32HeadLen
;
3472 *pu8CurrByte
++ = (pstrSetBeaconParam
->u32TailLen
& 0xFF);
3473 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32TailLen
>> 8) & 0xFF);
3474 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32TailLen
>> 16) & 0xFF);
3475 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32TailLen
>> 24) & 0xFF);
3477 /* Bug 4599 : if tail length = 0 skip copying */
3478 if (pstrSetBeaconParam
->pu8Tail
> 0)
3479 memcpy(pu8CurrByte
, pstrSetBeaconParam
->pu8Tail
, pstrSetBeaconParam
->u32TailLen
);
3480 pu8CurrByte
+= pstrSetBeaconParam
->u32TailLen
;
3485 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false, (u32
)pstrWFIDrv
);
3487 PRINT_ER("Failed to send add beacon config packet\n");
3488 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3491 WILC_CATCH(s32Error
)
3494 WILC_FREE_IF_TRUE(strWID
.ps8WidVal
);
3495 WILC_FREE_IF_TRUE(pstrSetBeaconParam
->pu8Head
);
3496 WILC_FREE_IF_TRUE(pstrSetBeaconParam
->pu8Tail
);
3501 * @brief Handle_AddBeacon
3502 * @details Sending config packet to delete beacon
3503 * @param[in] tstrHostIFDelBeacon* pstrDelBeacon
3509 static void Handle_DelBeacon(void *drvHandler
, tstrHostIFDelBeacon
*pstrDelBeacon
)
3511 s32 s32Error
= WILC_SUCCESS
;
3514 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
;
3611 PRINT_D(HOSTINF_DBG
, "Handling add station\n");
3612 strWID
.u16WIDid
= (u16
)WID_ADD_STA
;
3613 strWID
.enuWIDtype
= WID_BIN
;
3614 strWID
.s32ValueSize
= WILC_ADD_STA_LENGTH
+ pstrStationParam
->u8NumRates
;
3616 strWID
.ps8WidVal
= WILC_MALLOC(strWID
.s32ValueSize
);
3617 if (strWID
.ps8WidVal
== NULL
)
3618 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3620 pu8CurrByte
= strWID
.ps8WidVal
;
3621 pu8CurrByte
+= WILC_HostIf_PackStaParam(pu8CurrByte
, pstrStationParam
);
3624 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false, (u32
)pstrWFIDrv
);
3625 if (s32Error
!= WILC_SUCCESS
) {
3627 PRINT_ER("Failed to send add station config packet\n");
3628 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3631 WILC_CATCH(s32Error
)
3634 WILC_FREE_IF_TRUE(pstrStationParam
->pu8Rates
);
3635 WILC_FREE_IF_TRUE(strWID
.ps8WidVal
);
3639 * @brief Handle_DelAllSta
3640 * @details Sending config packet to delete station
3641 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3647 static void Handle_DelAllSta(void *drvHandler
, tstrHostIFDelAllSta
*pstrDelAllStaParam
)
3649 s32 s32Error
= WILC_SUCCESS
;
3652 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3654 u8 au8Zero_Buff
[6] = {0};
3655 strWID
.u16WIDid
= (u16
)WID_DEL_ALL_STA
;
3656 strWID
.enuWIDtype
= WID_STR
;
3657 strWID
.s32ValueSize
= (pstrDelAllStaParam
->u8Num_AssocSta
* ETH_ALEN
) + 1;
3659 PRINT_D(HOSTINF_DBG
, "Handling delete station \n");
3661 strWID
.ps8WidVal
= WILC_MALLOC((pstrDelAllStaParam
->u8Num_AssocSta
* ETH_ALEN
) + 1);
3662 if (strWID
.ps8WidVal
== NULL
)
3663 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3665 pu8CurrByte
= strWID
.ps8WidVal
;
3667 *(pu8CurrByte
++) = pstrDelAllStaParam
->u8Num_AssocSta
;
3669 for (i
= 0; i
< MAX_NUM_STA
; i
++) {
3670 if (memcmp(pstrDelAllStaParam
->au8Sta_DelAllSta
[i
], au8Zero_Buff
, ETH_ALEN
))
3671 WILC_memcpy(pu8CurrByte
, pstrDelAllStaParam
->au8Sta_DelAllSta
[i
], ETH_ALEN
);
3675 pu8CurrByte
+= ETH_ALEN
;
3679 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
3682 PRINT_ER("Failed to send add station config packe\n");
3683 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3686 WILC_CATCH(s32Error
)
3689 WILC_FREE_IF_TRUE(strWID
.ps8WidVal
);
3696 * @brief Handle_DelStation
3697 * @details Sending config packet to delete station
3698 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3704 static void Handle_DelStation(void *drvHandler
, tstrHostIFDelSta
*pstrDelStaParam
)
3706 s32 s32Error
= WILC_SUCCESS
;
3709 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3711 strWID
.u16WIDid
= (u16
)WID_REMOVE_STA
;
3712 strWID
.enuWIDtype
= WID_BIN
;
3713 strWID
.s32ValueSize
= ETH_ALEN
;
3715 PRINT_D(HOSTINF_DBG
, "Handling delete station \n");
3717 strWID
.ps8WidVal
= WILC_MALLOC(strWID
.s32ValueSize
);
3718 if (strWID
.ps8WidVal
== NULL
)
3719 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3721 pu8CurrByte
= strWID
.ps8WidVal
;
3723 WILC_memcpy(pu8CurrByte
, pstrDelStaParam
->au8MacAddr
, ETH_ALEN
);
3726 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false, (u32
)pstrWFIDrv
);
3729 PRINT_ER("Failed to send add station config packe\n");
3730 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3733 WILC_CATCH(s32Error
)
3736 WILC_FREE_IF_TRUE(strWID
.ps8WidVal
);
3741 * @brief Handle_EditStation
3742 * @details Sending config packet to edit station
3743 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3749 static void Handle_EditStation(void *drvHandler
, tstrWILC_AddStaParam
*pstrStationParam
)
3751 s32 s32Error
= WILC_SUCCESS
;
3754 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3756 strWID
.u16WIDid
= (u16
)WID_EDIT_STA
;
3757 strWID
.enuWIDtype
= WID_BIN
;
3758 strWID
.s32ValueSize
= WILC_ADD_STA_LENGTH
+ pstrStationParam
->u8NumRates
;
3760 PRINT_D(HOSTINF_DBG
, "Handling edit station\n");
3761 strWID
.ps8WidVal
= WILC_MALLOC(strWID
.s32ValueSize
);
3762 if (strWID
.ps8WidVal
== NULL
)
3763 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3765 pu8CurrByte
= strWID
.ps8WidVal
;
3766 pu8CurrByte
+= WILC_HostIf_PackStaParam(pu8CurrByte
, pstrStationParam
);
3769 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false, (u32
)pstrWFIDrv
);
3772 PRINT_ER("Failed to send edit station config packet\n");
3773 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3776 WILC_CATCH(s32Error
)
3779 WILC_FREE_IF_TRUE(pstrStationParam
->pu8Rates
);
3780 WILC_FREE_IF_TRUE(strWID
.ps8WidVal
);
3782 #endif /*WILC_AP_EXTERNAL_MLME*/
3786 * @brief Handle_RemainOnChan
3787 * @details Sending config packet to edit station
3788 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3794 static int Handle_RemainOnChan(void *drvHandler
, tstrHostIfRemainOnChan
*pstrHostIfRemainOnChan
)
3796 s32 s32Error
= WILC_SUCCESS
;
3797 u8 u8remain_on_chan_flag
;
3799 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*) drvHandler
;
3801 /*If it's a pendig remain-on-channel, don't overwrite gWFiDrvHandle values (since incoming msg is garbbage)*/
3802 if (!pstrWFIDrv
->u8RemainOnChan_pendingreq
) {
3803 pstrWFIDrv
->strHostIfRemainOnChan
.pVoid
= pstrHostIfRemainOnChan
->pVoid
;
3804 pstrWFIDrv
->strHostIfRemainOnChan
.pRemainOnChanExpired
= pstrHostIfRemainOnChan
->pRemainOnChanExpired
;
3805 pstrWFIDrv
->strHostIfRemainOnChan
.pRemainOnChanReady
= pstrHostIfRemainOnChan
->pRemainOnChanReady
;
3806 pstrWFIDrv
->strHostIfRemainOnChan
.u16Channel
= pstrHostIfRemainOnChan
->u16Channel
;
3807 pstrWFIDrv
->strHostIfRemainOnChan
.u32ListenSessionID
= pstrHostIfRemainOnChan
->u32ListenSessionID
;
3809 /*Set the channel to use it as a wid val*/
3810 pstrHostIfRemainOnChan
->u16Channel
= pstrWFIDrv
->strHostIfRemainOnChan
.u16Channel
;
3813 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
!= NULL
) {
3814 PRINT_INFO(GENERIC_DBG
, "Required to remain on chan while scanning return\n");
3815 pstrWFIDrv
->u8RemainOnChan_pendingreq
= 1;
3816 WILC_ERRORREPORT(s32Error
, WILC_BUSY
);
3818 if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_WAITING_CONN_RESP
) {
3819 PRINT_INFO(GENERIC_DBG
, "Required to remain on chan while connecting return\n");
3820 WILC_ERRORREPORT(s32Error
, WILC_BUSY
);
3823 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3824 if (g_obtainingIP
|| connecting
) {
3825 PRINT_D(GENERIC_DBG
, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
3826 WILC_ERRORREPORT(s32Error
, WILC_BUSY
);
3830 PRINT_D(HOSTINF_DBG
, "Setting channel :%d\n", pstrHostIfRemainOnChan
->u16Channel
);
3832 u8remain_on_chan_flag
= true;
3833 strWID
.u16WIDid
= (u16
)WID_REMAIN_ON_CHAN
;
3834 strWID
.enuWIDtype
= WID_STR
;
3835 strWID
.s32ValueSize
= 2;
3836 strWID
.ps8WidVal
= (s8
*)WILC_MALLOC(strWID
.s32ValueSize
);
3838 if (strWID
.ps8WidVal
== NULL
)
3839 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3841 strWID
.ps8WidVal
[0] = u8remain_on_chan_flag
;
3842 strWID
.ps8WidVal
[1] = (s8
)pstrHostIfRemainOnChan
->u16Channel
;
3845 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
3846 if (s32Error
!= WILC_SUCCESS
)
3847 PRINT_ER("Failed to set remain on channel\n");
3851 P2P_LISTEN_STATE
= 1;
3852 WILC_TimerStart(&(pstrWFIDrv
->hRemainOnChannel
), pstrHostIfRemainOnChan
->u32duration
, (void *)pstrWFIDrv
, NULL
);
3854 /*Calling CFG ready_on_channel*/
3855 if (pstrWFIDrv
->strHostIfRemainOnChan
.pRemainOnChanReady
)
3856 pstrWFIDrv
->strHostIfRemainOnChan
.pRemainOnChanReady(pstrWFIDrv
->strHostIfRemainOnChan
.pVoid
);
3858 if (pstrWFIDrv
->u8RemainOnChan_pendingreq
)
3859 pstrWFIDrv
->u8RemainOnChan_pendingreq
= 0;
3865 * @brief Handle_RegisterFrame
3873 static int Handle_RegisterFrame(void *drvHandler
, tstrHostIfRegisterFrame
*pstrHostIfRegisterFrame
)
3875 s32 s32Error
= WILC_SUCCESS
;
3878 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3880 PRINT_D(HOSTINF_DBG
, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame
->bReg
, pstrHostIfRegisterFrame
->u16FrameType
);
3882 /*prepare configuration packet*/
3883 strWID
.u16WIDid
= (u16
)WID_REGISTER_FRAME
;
3884 strWID
.enuWIDtype
= WID_STR
;
3885 strWID
.ps8WidVal
= WILC_MALLOC(sizeof(u16
) + 2);
3886 if (strWID
.ps8WidVal
== NULL
)
3887 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3889 pu8CurrByte
= strWID
.ps8WidVal
;
3891 *pu8CurrByte
++ = pstrHostIfRegisterFrame
->bReg
;
3892 *pu8CurrByte
++ = pstrHostIfRegisterFrame
->u8Regid
;
3893 WILC_memcpy(pu8CurrByte
, &(pstrHostIfRegisterFrame
->u16FrameType
), sizeof(u16
));
3896 strWID
.s32ValueSize
= sizeof(u16
) + 2;
3900 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
3902 PRINT_ER("Failed to frame register config packet\n");
3903 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
3907 WILC_CATCH(s32Error
)
3916 * @brief Handle_ListenStateExpired
3917 * @details Handle of listen state expiration
3919 * @return Error code.
3924 #define FALSE_FRMWR_CHANNEL 100
3925 static u32
Handle_ListenStateExpired(void *drvHandler
, tstrHostIfRemainOnChan
*pstrHostIfRemainOnChan
)
3927 u8 u8remain_on_chan_flag
;
3929 s32 s32Error
= WILC_SUCCESS
;
3930 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*) drvHandler
;
3932 PRINT_D(HOSTINF_DBG
, "CANCEL REMAIN ON CHAN\n");
3935 /*Make sure we are already in listen state*/
3936 /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/
3937 if (P2P_LISTEN_STATE
) {
3938 u8remain_on_chan_flag
= false;
3939 strWID
.u16WIDid
= (u16
)WID_REMAIN_ON_CHAN
;
3940 strWID
.enuWIDtype
= WID_STR
;
3941 strWID
.s32ValueSize
= 2;
3942 strWID
.ps8WidVal
= WILC_MALLOC(strWID
.s32ValueSize
);
3944 if (strWID
.ps8WidVal
== NULL
)
3945 PRINT_ER("Failed to allocate memory\n");
3947 strWID
.ps8WidVal
[0] = u8remain_on_chan_flag
;
3948 strWID
.ps8WidVal
[1] = FALSE_FRMWR_CHANNEL
;
3951 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
3952 if (s32Error
!= WILC_SUCCESS
) {
3953 PRINT_ER("Failed to set remain on channel\n");
3957 if (pstrWFIDrv
->strHostIfRemainOnChan
.pRemainOnChanExpired
) {
3958 pstrWFIDrv
->strHostIfRemainOnChan
.pRemainOnChanExpired(pstrWFIDrv
->strHostIfRemainOnChan
.pVoid
3959 , pstrHostIfRemainOnChan
->u32ListenSessionID
);
3961 P2P_LISTEN_STATE
= 0;
3963 PRINT_D(GENERIC_DBG
, "Not in listen state\n");
3964 s32Error
= WILC_FAIL
;
3973 * @brief ListenTimerCB
3974 * @details Callback function of remain-on-channel timer
3976 * @return Error code.
3981 static void ListenTimerCB(void *pvArg
)
3983 s32 s32Error
= WILC_SUCCESS
;
3984 tstrHostIFmsg strHostIFmsg
;
3985 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)pvArg
;
3986 /*Stopping remain-on-channel timer*/
3987 WILC_TimerStop(&(pstrWFIDrv
->hRemainOnChannel
), NULL
);
3989 /* prepare the Timer Callback message */
3990 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
3991 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_LISTEN_TIMER_FIRED
;
3992 strHostIFmsg
.drvHandler
= pstrWFIDrv
;
3993 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.u32ListenSessionID
= pstrWFIDrv
->strHostIfRemainOnChan
.u32ListenSessionID
;
3995 /* send the message */
3996 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
3998 WILC_ERRORREPORT(s32Error
, s32Error
);
3999 WILC_CATCH(s32Error
)
4008 * @brief Handle_EditStation
4009 * @details Sending config packet to edit station
4010 * @param[in] tstrWILC_AddStaParam* pstrStationParam
4016 static void Handle_PowerManagement(void *drvHandler
, tstrHostIfPowerMgmtParam
*strPowerMgmtParam
)
4018 s32 s32Error
= WILC_SUCCESS
;
4021 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
4022 strWID
.u16WIDid
= (u16
)WID_POWER_MANAGEMENT
;
4024 if (strPowerMgmtParam
->bIsEnabled
== true) {
4025 s8PowerMode
= MIN_FAST_PS
;
4027 s8PowerMode
= NO_POWERSAVE
;
4029 PRINT_D(HOSTINF_DBG
, "Handling power mgmt to %d\n", s8PowerMode
);
4030 strWID
.ps8WidVal
= &s8PowerMode
;
4031 strWID
.s32ValueSize
= sizeof(char);
4033 PRINT_D(HOSTINF_DBG
, "Handling Power Management\n");
4036 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
4038 PRINT_ER("Failed to send power management config packet\n");
4039 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
4042 WILC_CATCH(s32Error
)
4049 * @brief Handle_SetMulticastFilter
4050 * @details Set Multicast filter in firmware
4051 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4057 static void Handle_SetMulticastFilter(void *drvHandler
, tstrHostIFSetMulti
*strHostIfSetMulti
)
4059 s32 s32Error
= WILC_SUCCESS
;
4063 PRINT_D(HOSTINF_DBG
, "Setup Multicast Filter\n");
4065 strWID
.u16WIDid
= (u16
)WID_SETUP_MULTICAST_FILTER
;
4066 strWID
.enuWIDtype
= WID_BIN
;
4067 strWID
.s32ValueSize
= sizeof(tstrHostIFSetMulti
) + ((strHostIfSetMulti
->u32count
) * ETH_ALEN
);
4068 strWID
.ps8WidVal
= WILC_MALLOC(strWID
.s32ValueSize
);
4069 if (strWID
.ps8WidVal
== NULL
)
4070 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
4072 pu8CurrByte
= strWID
.ps8WidVal
;
4073 *pu8CurrByte
++ = (strHostIfSetMulti
->bIsEnabled
& 0xFF);
4074 *pu8CurrByte
++ = ((strHostIfSetMulti
->bIsEnabled
>> 8) & 0xFF);
4075 *pu8CurrByte
++ = ((strHostIfSetMulti
->bIsEnabled
>> 16) & 0xFF);
4076 *pu8CurrByte
++ = ((strHostIfSetMulti
->bIsEnabled
>> 24) & 0xFF);
4078 *pu8CurrByte
++ = (strHostIfSetMulti
->u32count
& 0xFF);
4079 *pu8CurrByte
++ = ((strHostIfSetMulti
->u32count
>> 8) & 0xFF);
4080 *pu8CurrByte
++ = ((strHostIfSetMulti
->u32count
>> 16) & 0xFF);
4081 *pu8CurrByte
++ = ((strHostIfSetMulti
->u32count
>> 24) & 0xFF);
4083 if ((strHostIfSetMulti
->u32count
) > 0)
4084 memcpy(pu8CurrByte
, gau8MulticastMacAddrList
, ((strHostIfSetMulti
->u32count
) * ETH_ALEN
));
4087 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false, (u32
)drvHandler
);
4089 PRINT_ER("Failed to send setup multicast config packet\n");
4090 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
4093 WILC_CATCH(s32Error
)
4096 WILC_FREE_IF_TRUE(strWID
.ps8WidVal
);
4103 * @brief Handle_AddBASession
4104 * @details Add block ack session
4105 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4107 * @author Amr Abdel-Moghny
4111 static s32
Handle_AddBASession(void *drvHandler
, tstrHostIfBASessionInfo
*strHostIfBASessionInfo
)
4113 s32 s32Error
= WILC_SUCCESS
;
4115 int AddbaTimeout
= 100;
4117 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
4119 PRINT_D(HOSTINF_DBG
, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x \nTID=%d \nBufferSize == %d \nSessionTimeOut = %d\n",
4120 strHostIfBASessionInfo
->au8Bssid
[0],
4121 strHostIfBASessionInfo
->au8Bssid
[1],
4122 strHostIfBASessionInfo
->au8Bssid
[2],
4123 strHostIfBASessionInfo
->u16BufferSize
,
4124 strHostIfBASessionInfo
->u16SessionTimeout
,
4125 strHostIfBASessionInfo
->u8Ted
);
4127 strWID
.u16WIDid
= (u16
)WID_11E_P_ACTION_REQ
;
4128 strWID
.enuWIDtype
= WID_STR
;
4129 strWID
.ps8WidVal
= (u8
*)WILC_MALLOC(BLOCK_ACK_REQ_SIZE
);
4130 strWID
.s32ValueSize
= BLOCK_ACK_REQ_SIZE
;
4131 ptr
= strWID
.ps8WidVal
;
4132 /* *ptr++ = 0x14; */
4136 WILC_memcpy(ptr
, strHostIfBASessionInfo
->au8Bssid
, ETH_ALEN
);
4138 *ptr
++ = strHostIfBASessionInfo
->u8Ted
;
4142 *ptr
++ = (strHostIfBASessionInfo
->u16BufferSize
& 0xFF);
4143 *ptr
++ = ((strHostIfBASessionInfo
->u16BufferSize
>> 16) & 0xFF);
4145 *ptr
++ = (strHostIfBASessionInfo
->u16SessionTimeout
& 0xFF);
4146 *ptr
++ = ((strHostIfBASessionInfo
->u16SessionTimeout
>> 16) & 0xFF);
4148 *ptr
++ = (AddbaTimeout
& 0xFF);
4149 *ptr
++ = ((AddbaTimeout
>> 16) & 0xFF);
4150 /* Group Buffer Max Frames*/
4152 /* Group Buffer Timeout */
4155 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
4157 PRINT_D(HOSTINF_DBG
, "Couldn't open BA Session\n");
4160 strWID
.u16WIDid
= (u16
)WID_11E_P_ACTION_REQ
;
4161 strWID
.enuWIDtype
= WID_STR
;
4162 strWID
.s32ValueSize
= 15;
4163 ptr
= strWID
.ps8WidVal
;
4164 /* *ptr++ = 0x14; */
4168 WILC_memcpy(ptr
, strHostIfBASessionInfo
->au8Bssid
, ETH_ALEN
);
4171 *ptr
++ = strHostIfBASessionInfo
->u8Ted
;
4175 *ptr
++ = (strHostIfBASessionInfo
->u16BufferSize
& 0xFF);
4176 *ptr
++ = ((strHostIfBASessionInfo
->u16SessionTimeout
>> 16) & 0xFF);
4179 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
4181 if (strWID
.ps8WidVal
!= NULL
)
4182 WILC_FREE(strWID
.ps8WidVal
);
4191 * @brief Handle_DelBASession
4192 * @details Delete block ack session
4193 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4195 * @author Amr Abdel-Moghny
4199 static s32
Handle_DelBASession(void *drvHandler
, tstrHostIfBASessionInfo
*strHostIfBASessionInfo
)
4201 s32 s32Error
= WILC_SUCCESS
;
4204 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
4206 PRINT_D(GENERIC_DBG
, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x \nTID=%d\n",
4207 strHostIfBASessionInfo
->au8Bssid
[0],
4208 strHostIfBASessionInfo
->au8Bssid
[1],
4209 strHostIfBASessionInfo
->au8Bssid
[2],
4210 strHostIfBASessionInfo
->u8Ted
);
4212 strWID
.u16WIDid
= (u16
)WID_11E_P_ACTION_REQ
;
4213 strWID
.enuWIDtype
= WID_STR
;
4214 strWID
.ps8WidVal
= (u8
*)WILC_MALLOC(BLOCK_ACK_REQ_SIZE
);
4215 strWID
.s32ValueSize
= BLOCK_ACK_REQ_SIZE
;
4216 ptr
= strWID
.ps8WidVal
;
4217 /* *ptr++ = 0x14; */
4221 WILC_memcpy(ptr
, strHostIfBASessionInfo
->au8Bssid
, ETH_ALEN
);
4223 *ptr
++ = strHostIfBASessionInfo
->u8Ted
;
4224 /* BA direction = recipent*/
4227 *ptr
++ = 32; /* Unspecific QOS reason */
4229 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
4231 PRINT_D(HOSTINF_DBG
, "Couldn't delete BA Session\n");
4234 strWID
.u16WIDid
= (u16
)WID_11E_P_ACTION_REQ
;
4235 strWID
.enuWIDtype
= WID_STR
;
4236 strWID
.s32ValueSize
= 15;
4237 ptr
= strWID
.ps8WidVal
;
4238 /* *ptr++ = 0x14; */
4242 WILC_memcpy(ptr
, strHostIfBASessionInfo
->au8Bssid
, ETH_ALEN
);
4245 *ptr
++ = strHostIfBASessionInfo
->u8Ted
;
4247 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
4249 if (strWID
.ps8WidVal
!= NULL
)
4250 WILC_FREE(strWID
.ps8WidVal
);
4261 * @brief Handle_DelAllRxBASessions
4262 * @details Delete all Rx BA sessions
4263 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4265 * @author Abdelrahman Sobhy
4269 static s32
Handle_DelAllRxBASessions(void *drvHandler
, tstrHostIfBASessionInfo
*strHostIfBASessionInfo
)
4271 s32 s32Error
= WILC_SUCCESS
;
4274 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
4276 PRINT_D(GENERIC_DBG
, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x \nTID=%d\n",
4277 strHostIfBASessionInfo
->au8Bssid
[0],
4278 strHostIfBASessionInfo
->au8Bssid
[1],
4279 strHostIfBASessionInfo
->au8Bssid
[2],
4280 strHostIfBASessionInfo
->u8Ted
);
4282 strWID
.u16WIDid
= (u16
)WID_DEL_ALL_RX_BA
;
4283 strWID
.enuWIDtype
= WID_STR
;
4284 strWID
.ps8WidVal
= (u8
*)WILC_MALLOC(BLOCK_ACK_REQ_SIZE
);
4285 strWID
.s32ValueSize
= BLOCK_ACK_REQ_SIZE
;
4286 ptr
= strWID
.ps8WidVal
;
4290 WILC_memcpy(ptr
, strHostIfBASessionInfo
->au8Bssid
, ETH_ALEN
);
4292 *ptr
++ = strHostIfBASessionInfo
->u8Ted
;
4293 /* BA direction = recipent*/
4296 *ptr
++ = 32; /* Unspecific QOS reason */
4298 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
4300 PRINT_D(HOSTINF_DBG
, "Couldn't delete BA Session\n");
4303 if (strWID
.ps8WidVal
!= NULL
)
4304 WILC_FREE(strWID
.ps8WidVal
);
4314 * @brief hostIFthread
4315 * @details Main thread to handle message queue requests
4316 * @param[in] void* pvArg
4322 static int hostIFthread(void *pvArg
)
4325 tstrHostIFmsg strHostIFmsg
;
4326 tstrWILC_WFIDrv
*pstrWFIDrv
;
4328 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4331 WILC_MsgQueueRecv(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), &u32Ret
, NULL
);
4332 pstrWFIDrv
= (tstrWILC_WFIDrv
*)strHostIFmsg
.drvHandler
;
4333 if (strHostIFmsg
.u16MsgId
== HOST_IF_MSG_EXIT
) {
4334 PRINT_D(GENERIC_DBG
, "THREAD: Exiting HostIfThread\n");
4339 /*Re-Queue HIF message*/
4340 if ((!g_wilc_initialized
)) {
4341 PRINT_D(GENERIC_DBG
, "--WAIT--");
4343 WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
4347 if (strHostIFmsg
.u16MsgId
== HOST_IF_MSG_CONNECT
&& pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
!= NULL
) {
4348 PRINT_D(HOSTINF_DBG
, "Requeue connect request till scan done received\n");
4349 WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
4354 switch (strHostIFmsg
.u16MsgId
) {
4355 case HOST_IF_MSG_Q_IDLE
:
4356 Handle_wait_msg_q_empty();
4359 case HOST_IF_MSG_SCAN
:
4360 Handle_Scan(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
);
4363 case HOST_IF_MSG_CONNECT
:
4364 Handle_Connect(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
);
4368 case HOST_IF_MSG_FLUSH_CONNECT
:
4369 Handle_FlushConnect(strHostIFmsg
.drvHandler
);
4372 case HOST_IF_MSG_RCVD_NTWRK_INFO
:
4373 Handle_RcvdNtwrkInfo(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strRcvdNetworkInfo
);
4376 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO
:
4377 Handle_RcvdGnrlAsyncInfo(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strRcvdGnrlAsyncInfo
);
4380 case HOST_IF_MSG_KEY
:
4381 Handle_Key(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
);
4384 case HOST_IF_MSG_CFG_PARAMS
:
4386 Handle_CfgParam(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIFCfgParamAttr
);
4389 case HOST_IF_MSG_SET_CHANNEL
:
4390 Handle_SetChannel(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIFSetChan
);
4393 case HOST_IF_MSG_DISCONNECT
:
4394 Handle_Disconnect(strHostIFmsg
.drvHandler
);
4397 case HOST_IF_MSG_RCVD_SCAN_COMPLETE
:
4398 WILC_TimerStop(&(pstrWFIDrv
->hScanTimer
), NULL
);
4399 PRINT_D(HOSTINF_DBG
, "scan completed successfully\n");
4402 /*Allow chip sleep, only if both interfaces are not connected*/
4403 if (!linux_wlan_get_num_conn_ifcs())
4404 chip_sleep_manually(INFINITE_SLEEP_TIME
);
4406 Handle_ScanDone(strHostIFmsg
.drvHandler
, SCAN_EVENT_DONE
);
4409 if (pstrWFIDrv
->u8RemainOnChan_pendingreq
)
4410 Handle_RemainOnChan(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
);
4415 case HOST_IF_MSG_GET_RSSI
:
4416 Handle_GetRssi(strHostIFmsg
.drvHandler
);
4419 case HOST_IF_MSG_GET_LINKSPEED
:
4420 Handle_GetLinkspeed(strHostIFmsg
.drvHandler
);
4423 case HOST_IF_MSG_GET_STATISTICS
:
4424 Handle_GetStatistics(strHostIFmsg
.drvHandler
, (tstrStatistics
*)strHostIFmsg
.uniHostIFmsgBody
.pUserData
);
4427 case HOST_IF_MSG_GET_CHNL
:
4428 Handle_GetChnl(strHostIFmsg
.drvHandler
);
4431 #ifdef WILC_AP_EXTERNAL_MLME
4432 case HOST_IF_MSG_ADD_BEACON
:
4433 Handle_AddBeacon(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIFSetBeacon
);
4436 case HOST_IF_MSG_DEL_BEACON
:
4437 Handle_DelBeacon(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIFDelBeacon
);
4440 case HOST_IF_MSG_ADD_STATION
:
4441 Handle_AddStation(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strAddStaParam
);
4444 case HOST_IF_MSG_DEL_STATION
:
4445 Handle_DelStation(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strDelStaParam
);
4448 case HOST_IF_MSG_EDIT_STATION
:
4449 Handle_EditStation(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strEditStaParam
);
4452 case HOST_IF_MSG_GET_INACTIVETIME
:
4453 Handle_Get_InActiveTime(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfStaInactiveT
);
4456 #endif /*WILC_AP_EXTERNAL_MLME*/
4457 case HOST_IF_MSG_SCAN_TIMER_FIRED
:
4458 PRINT_D(HOSTINF_DBG
, "Scan Timeout\n");
4460 Handle_ScanDone(strHostIFmsg
.drvHandler
, SCAN_EVENT_ABORTED
);
4463 case HOST_IF_MSG_CONNECT_TIMER_FIRED
:
4464 PRINT_D(HOSTINF_DBG
, "Connect Timeout \n");
4465 Handle_ConnectTimeout(strHostIFmsg
.drvHandler
);
4468 case HOST_IF_MSG_POWER_MGMT
:
4469 Handle_PowerManagement(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strPowerMgmtparam
);
4472 case HOST_IF_MSG_SET_WFIDRV_HANDLER
:
4473 Handle_SetWfiDrvHandler(&strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetDrvHandler
);
4476 case HOST_IF_MSG_SET_OPERATION_MODE
:
4477 Handle_SetOperationMode(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetOperationMode
);
4480 case HOST_IF_MSG_SET_IPADDRESS
:
4481 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_SET_IPADDRESS\n");
4482 Handle_set_IPAddress(strHostIFmsg
.drvHandler
, strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.au8IPAddr
, strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.idx
);
4485 case HOST_IF_MSG_GET_IPADDRESS
:
4486 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_SET_IPADDRESS\n");
4487 Handle_get_IPAddress(strHostIFmsg
.drvHandler
, strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.au8IPAddr
, strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.idx
);
4491 case HOST_IF_MSG_SET_MAC_ADDRESS
:
4492 Handle_SetMacAddress(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetMacAddress
);
4496 case HOST_IF_MSG_GET_MAC_ADDRESS
:
4497 Handle_GetMacAddress(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfGetMacAddress
);
4501 case HOST_IF_MSG_REMAIN_ON_CHAN
:
4502 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
4503 Handle_RemainOnChan(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
);
4506 case HOST_IF_MSG_REGISTER_FRAME
:
4507 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_REGISTER_FRAME\n");
4508 Handle_RegisterFrame(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfRegisterFrame
);
4511 case HOST_IF_MSG_LISTEN_TIMER_FIRED
:
4512 Handle_ListenStateExpired(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
);
4516 case HOST_IF_MSG_SET_MULTICAST_FILTER
:
4517 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
4518 Handle_SetMulticastFilter(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetMulti
);
4522 case HOST_IF_MSG_ADD_BA_SESSION
:
4523 Handle_AddBASession(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfBASessionInfo
);
4526 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS
:
4527 Handle_DelAllRxBASessions(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfBASessionInfo
);
4530 case HOST_IF_MSG_DEL_ALL_STA
:
4531 Handle_DelAllSta(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIFDelAllSta
);
4535 PRINT_ER("[Host Interface] undefined Received Msg ID \n");
4540 PRINT_D(HOSTINF_DBG
, "Releasing thread exit semaphore\n");
4541 up(&hSemHostIFthrdEnd
);
4545 static void TimerCB_Scan(void *pvArg
)
4547 tstrHostIFmsg strHostIFmsg
;
4549 /* prepare the Timer Callback message */
4550 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4551 strHostIFmsg
.drvHandler
= pvArg
;
4552 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SCAN_TIMER_FIRED
;
4554 /* send the message */
4555 WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
4558 static void TimerCB_Connect(void *pvArg
)
4560 tstrHostIFmsg strHostIFmsg
;
4562 /* prepare the Timer Callback message */
4563 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4564 strHostIFmsg
.drvHandler
= pvArg
;
4565 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_CONNECT_TIMER_FIRED
;
4567 /* send the message */
4568 WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
4573 * @brief removes wpa/wpa2 keys
4574 * @details only in BSS STA mode if External Supplicant support is enabled.
4575 * removes all WPA/WPA2 station key entries from MAC hardware.
4576 * @param[in,out] handle to the wifi driver
4577 * @param[in] 6 bytes of Station Adress in the station entry table
4578 * @return Error code indicating success/failure
4581 * @date 8 March 2012
4584 /* Check implementation in core adding 9 bytes to the input! */
4585 s32
host_int_remove_key(WILC_WFIDrvHandle hWFIDrv
, const u8
*pu8StaAddress
)
4587 s32 s32Error
= WILC_SUCCESS
;
4589 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4591 strWID
.u16WIDid
= (u16
)WID_REMOVE_KEY
;
4592 strWID
.enuWIDtype
= WID_STR
;
4593 strWID
.ps8WidVal
= (s8
*)pu8StaAddress
;
4594 strWID
.s32ValueSize
= 6;
4601 * @brief removes WEP key
4602 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4603 * remove a WEP key entry from MAC HW.
4604 * The BSS Station automatically finds the index of the entry using its
4605 * BSS ID and removes that entry from the MAC hardware.
4606 * @param[in,out] handle to the wifi driver
4607 * @param[in] 6 bytes of Station Adress in the station entry table
4608 * @return Error code indicating success/failure
4609 * @note NO need for the STA add since it is not used for processing
4611 * @date 8 March 2012
4614 s32
host_int_remove_wep_key(WILC_WFIDrvHandle hWFIDrv
, u8 u8keyIdx
)
4616 s32 s32Error
= WILC_SUCCESS
;
4617 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
4618 tstrHostIFmsg strHostIFmsg
;
4621 if (pstrWFIDrv
== NULL
)
4622 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
4624 /* prepare the Remove Wep Key Message */
4625 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4628 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
4629 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= WEP
;
4630 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= REMOVEKEY
;
4631 strHostIFmsg
.drvHandler
= hWFIDrv
;
4635 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4636 uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
= u8keyIdx
;
4638 /* send the message */
4639 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
4641 PRINT_ER("Error in sending message queue : Request to remove WEP key \n");
4642 down(&(pstrWFIDrv
->hSemTestKeyBlock
));
4644 WILC_CATCH(s32Error
)
4652 * @brief sets WEP default key
4653 * @details Sets the index of the WEP encryption key in use,
4655 * @param[in,out] handle to the wifi driver
4656 * @param[in] key index ( 0, 1, 2, 3)
4657 * @return Error code indicating success/failure
4660 * @date 8 March 2012
4663 s32
host_int_set_WEPDefaultKeyID(WILC_WFIDrvHandle hWFIDrv
, u8 u8Index
)
4665 s32 s32Error
= WILC_SUCCESS
;
4666 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
4667 tstrHostIFmsg strHostIFmsg
;
4670 if (pstrWFIDrv
== NULL
)
4671 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
4673 /* prepare the Key Message */
4674 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4677 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
4678 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= WEP
;
4679 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= DEFAULTKEY
;
4680 strHostIFmsg
.drvHandler
= hWFIDrv
;
4683 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4684 uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
= u8Index
;
4686 /* send the message */
4687 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
4689 PRINT_ER("Error in sending message queue : Default key index\n");
4690 down(&(pstrWFIDrv
->hSemTestKeyBlock
));
4692 WILC_CATCH(s32Error
)
4701 * @brief sets WEP deafault key
4702 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4703 * sets WEP key entry into MAC hardware when it receives the
4704 * corresponding request from NDIS.
4705 * @param[in,out] handle to the wifi driver
4706 * @param[in] message containing WEP Key in the following format
4707 *|---------------------------------------|
4708 *|Key ID Value | Key Length | Key |
4709 *|-------------|------------|------------|
4710 | 1byte | 1byte | Key Length |
4711 ||---------------------------------------|
4713 * @return Error code indicating success/failure
4716 * @date 8 March 2012
4719 s32
host_int_add_wep_key_bss_sta(WILC_WFIDrvHandle hWFIDrv
, const u8
*pu8WepKey
, u8 u8WepKeylen
, u8 u8Keyidx
)
4722 s32 s32Error
= WILC_SUCCESS
;
4723 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
4724 tstrHostIFmsg strHostIFmsg
;
4726 if (pstrWFIDrv
== NULL
)
4727 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
4730 /* prepare the Key Message */
4731 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4734 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
4735 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= WEP
;
4736 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY
;
4737 strHostIFmsg
.drvHandler
= hWFIDrv
;
4740 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4741 uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
= (u8
*)WILC_MALLOC(u8WepKeylen
);
4743 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
,
4744 pu8WepKey
, u8WepKeylen
);
4747 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4748 uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
= (u8WepKeylen
);
4750 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4751 uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
= u8Keyidx
;
4753 /* send the message */
4754 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
4756 PRINT_ER("Error in sending message queue :WEP Key\n");
4757 down(&(pstrWFIDrv
->hSemTestKeyBlock
));
4759 WILC_CATCH(s32Error
)
4767 #ifdef WILC_AP_EXTERNAL_MLME
4770 * @brief host_int_add_wep_key_bss_ap
4771 * @details valid only in BSS AP mode if External Supplicant support is enabled.
4772 * sets WEP key entry into MAC hardware when it receives the
4774 * corresponding request from NDIS.
4775 * @param[in,out] handle to the wifi driver
4778 * @return Error code indicating success/failure
4784 s32
host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv
, const u8
*pu8WepKey
, u8 u8WepKeylen
, u8 u8Keyidx
, u8 u8mode
, AUTHTYPE_T tenuAuth_type
)
4787 s32 s32Error
= WILC_SUCCESS
;
4788 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
4789 tstrHostIFmsg strHostIFmsg
;
4792 if (pstrWFIDrv
== NULL
)
4793 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
4796 /* prepare the Key Message */
4797 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4800 for (i
= 0; i
< u8WepKeylen
; i
++)
4801 PRINT_INFO(HOSTAPD_DBG
, "KEY is %x\n", pu8WepKey
[i
]);
4803 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
4804 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= WEP
;
4805 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY_AP
;
4806 strHostIFmsg
.drvHandler
= hWFIDrv
;
4809 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4810 uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
= (u8
*)WILC_MALLOC((u8WepKeylen
));
4813 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
,
4814 pu8WepKey
, (u8WepKeylen
));
4817 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4818 uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
= (u8WepKeylen
);
4820 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4821 uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
= u8Keyidx
;
4823 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4824 uniHostIFkeyAttr
.strHostIFwepAttr
.u8mode
= u8mode
;
4826 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4827 uniHostIFkeyAttr
.strHostIFwepAttr
.tenuAuth_type
= tenuAuth_type
;
4828 /* send the message */
4829 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
4832 PRINT_ER("Error in sending message queue :WEP Key\n");
4833 down(&(pstrWFIDrv
->hSemTestKeyBlock
));
4835 WILC_CATCH(s32Error
)
4844 * @brief adds ptk Key
4846 * @param[in,out] handle to the wifi driver
4847 * @param[in] message containing PTK Key in the following format
4848 *|-----------------------------------------------------------------------------|
4849 *|Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
4850 *|----------------|------------|--------------|----------------|---------------|
4851 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
4852 ||-----------------------------------------------------------------------------|
4853 * @return Error code indicating success/failure
4856 * @date 8 March 2012
4859 s32
host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv
, const u8
*pu8Ptk
, u8 u8PtkKeylen
,
4860 const u8
*mac_addr
, const u8
*pu8RxMic
, const u8
*pu8TxMic
, u8 mode
, u8 u8Ciphermode
, u8 u8Idx
)
4862 s32 s32Error
= WILC_SUCCESS
;
4863 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
4864 tstrHostIFmsg strHostIFmsg
;
4865 u8 u8KeyLen
= u8PtkKeylen
;
4867 if (pstrWFIDrv
== NULL
)
4868 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
4869 if (pu8RxMic
!= NULL
)
4870 u8KeyLen
+= RX_MIC_KEY_LEN
;
4871 if (pu8TxMic
!= NULL
)
4872 u8KeyLen
+= TX_MIC_KEY_LEN
;
4874 /* prepare the Key Message */
4875 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4878 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
4879 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= WPAPtk
;
4880 #ifdef WILC_AP_EXTERNAL_MLME
4881 if (mode
== AP_MODE
) {
4882 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY_AP
;
4883 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4884 uniHostIFkeyAttr
.strHostIFwpaAttr
.u8keyidx
= u8Idx
;
4887 if (mode
== STATION_MODE
)
4888 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY
;
4891 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4892 uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
= (u8
*)WILC_MALLOC(u8PtkKeylen
);
4895 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
,
4896 pu8Ptk
, u8PtkKeylen
);
4898 if (pu8RxMic
!= NULL
) {
4900 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
+ 16,
4901 pu8RxMic
, RX_MIC_KEY_LEN
);
4903 for (i
= 0; i
< RX_MIC_KEY_LEN
; i
++)
4904 PRINT_INFO(CFG80211_DBG
, "PairwiseRx[%d] = %x\n", i
, pu8RxMic
[i
]);
4907 if (pu8TxMic
!= NULL
) {
4909 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
+ 24,
4910 pu8TxMic
, TX_MIC_KEY_LEN
);
4912 for (i
= 0; i
< TX_MIC_KEY_LEN
; i
++)
4913 PRINT_INFO(CFG80211_DBG
, "PairwiseTx[%d] = %x\n", i
, pu8TxMic
[i
]);
4917 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4918 uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
= u8KeyLen
;
4920 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4921 uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Ciphermode
= u8Ciphermode
;
4922 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4923 uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8macaddr
= mac_addr
;
4924 strHostIFmsg
.drvHandler
= hWFIDrv
;
4926 /* send the message */
4927 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
4930 PRINT_ER("Error in sending message queue: PTK Key\n");
4932 /* ////////////// */
4933 down(&(pstrWFIDrv
->hSemTestKeyBlock
));
4934 /* WILC_Sleep(100); */
4937 WILC_CATCH(s32Error
)
4946 * @brief adds Rx GTk Key
4948 * @param[in,out] handle to the wifi driver
4949 * @param[in] pu8RxGtk : contains temporal key | Rx Mic | Tx Mic
4950 * u8GtkKeylen :The total key length
4952 * @return Error code indicating success/failure
4955 * @date 8 March 2012
4958 s32
host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv
, const u8
*pu8RxGtk
, u8 u8GtkKeylen
,
4959 u8 u8KeyIdx
, u32 u32KeyRSClen
, const u8
*KeyRSC
,
4960 const u8
*pu8RxMic
, const u8
*pu8TxMic
, u8 mode
, u8 u8Ciphermode
)
4962 s32 s32Error
= WILC_SUCCESS
;
4963 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
4964 tstrHostIFmsg strHostIFmsg
;
4965 u8 u8KeyLen
= u8GtkKeylen
;
4967 if (pstrWFIDrv
== NULL
)
4968 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
4969 /* prepare the Key Message */
4970 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4973 if (pu8RxMic
!= NULL
)
4974 u8KeyLen
+= RX_MIC_KEY_LEN
;
4975 if (pu8TxMic
!= NULL
)
4976 u8KeyLen
+= TX_MIC_KEY_LEN
;
4977 if (KeyRSC
!= NULL
) {
4978 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4979 uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8seq
= (u8
*)WILC_MALLOC(u32KeyRSClen
);
4981 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8seq
,
4982 KeyRSC
, u32KeyRSClen
);
4986 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
4987 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= WPARxGtk
;
4988 strHostIFmsg
.drvHandler
= hWFIDrv
;
4990 #ifdef WILC_AP_EXTERNAL_MLME
4991 if (mode
== AP_MODE
) {
4992 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY_AP
;
4993 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Ciphermode
= u8Ciphermode
;
4996 if (mode
== STATION_MODE
)
4997 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY
;
5000 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
5001 uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
= (u8
*)WILC_MALLOC(u8KeyLen
);
5003 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
,
5004 pu8RxGtk
, u8GtkKeylen
);
5006 if (pu8RxMic
!= NULL
) {
5008 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
+ 16,
5009 pu8RxMic
, RX_MIC_KEY_LEN
);
5012 if (pu8TxMic
!= NULL
) {
5014 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
+ 24,
5015 pu8TxMic
, TX_MIC_KEY_LEN
);
5019 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
5020 uniHostIFkeyAttr
.strHostIFwpaAttr
.u8keyidx
= u8KeyIdx
;
5021 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
5022 uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
= u8KeyLen
;
5024 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
5025 uniHostIFkeyAttr
.strHostIFwpaAttr
.u8seqlen
= u32KeyRSClen
;
5029 /* send the message */
5030 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
5032 PRINT_ER("Error in sending message queue: RX GTK\n");
5033 /* ////////////// */
5034 down(&(pstrWFIDrv
->hSemTestKeyBlock
));
5035 /* WILC_Sleep(100); */
5038 WILC_CATCH(s32Error
)
5046 * @brief host_int_set_pmkid_info
5047 * @details caches the pmkid valid only in BSS STA mode if External Supplicant
5048 * support is enabled. This Function sets the PMKID in firmware
5049 * when host drivr receives the corresponding request from NDIS.
5050 * The firmware then includes theset PMKID in the appropriate
5052 * @param[in,out] handle to the wifi driver
5053 * @param[in] message containing PMKID Info in the following format
5054 *|-----------------------------------------------------------------|
5055 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
5056 *|-----------|------------|----------|-------|----------|----------|
5057 | 1 | 6 | 16 | ... | 6 | 16 |
5058 ||-----------------------------------------------------------------|
5059 * @return Error code indicating success/failure
5062 * @date 8 March 2012
5065 s32
host_int_set_pmkid_info(WILC_WFIDrvHandle hWFIDrv
, tstrHostIFpmkidAttr
*pu8PmkidInfoArray
)
5067 s32 s32Error
= WILC_SUCCESS
;
5068 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5069 tstrHostIFmsg strHostIFmsg
;
5073 if (pstrWFIDrv
== NULL
)
5074 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5076 /* prepare the Key Message */
5077 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5079 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
5080 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= PMKSA
;
5081 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY
;
5082 strHostIFmsg
.drvHandler
= hWFIDrv
;
5084 for (i
= 0; i
< pu8PmkidInfoArray
->numpmkid
; i
++) {
5086 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFpmkidAttr
.pmkidlist
[i
].bssid
, &pu8PmkidInfoArray
->pmkidlist
[i
].bssid
,
5089 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFpmkidAttr
.pmkidlist
[i
].pmkid
, &pu8PmkidInfoArray
->pmkidlist
[i
].pmkid
,
5093 /* send the message */
5094 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
5096 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
5098 WILC_CATCH(s32Error
)
5107 * @brief gets the cached the pmkid info
5108 * @details valid only in BSS STA mode if External Supplicant
5109 * support is enabled. This Function sets the PMKID in firmware
5110 * when host drivr receives the corresponding request from NDIS.
5111 * The firmware then includes theset PMKID in the appropriate
5113 * @param[in,out] handle to the wifi driver,
5114 * message containing PMKID Info in the following format
5115 *|-----------------------------------------------------------------|
5116 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
5117 *|-----------|------------|----------|-------|----------|----------|
5118 | 1 | 6 | 16 | ... | 6 | 16 |
5119 ||-----------------------------------------------------------------|
5121 * @return Error code indicating success/failure
5124 * @date 8 March 2012
5127 s32
host_int_get_pmkid_info(WILC_WFIDrvHandle hWFIDrv
, u8
*pu8PmkidInfoArray
,
5128 u32 u32PmkidInfoLen
)
5130 s32 s32Error
= WILC_SUCCESS
;
5132 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5134 strWID
.u16WIDid
= (u16
)WID_PMKID_INFO
;
5135 strWID
.enuWIDtype
= WID_STR
;
5136 strWID
.s32ValueSize
= u32PmkidInfoLen
;
5137 strWID
.ps8WidVal
= pu8PmkidInfoArray
;
5143 * @brief sets the pass phrase
5144 * @details AP/STA mode. This function gives the pass phrase used to
5145 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5146 * The length of the field can vary from 8 to 64 bytes,
5147 * the lower layer should get the
5148 * @param[in,out] handle to the wifi driver,
5149 * @param[in] String containing PSK
5150 * @return Error code indicating success/failure
5153 * @date 8 March 2012
5156 s32
host_int_set_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv
, u8
*pu8PassPhrase
,
5159 s32 s32Error
= WILC_SUCCESS
;
5161 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5163 /* u8 u8Psklength = WILC_strlen(pu8PassPhrase); */
5164 /*validating psk length*/
5165 if ((u8Psklength
> 7) && (u8Psklength
< 65)) {
5166 strWID
.u16WIDid
= (u16
)WID_11I_PSK
;
5167 strWID
.enuWIDtype
= WID_STR
;
5168 strWID
.ps8WidVal
= pu8PassPhrase
;
5169 strWID
.s32ValueSize
= u8Psklength
;
5175 * @brief host_int_get_MacAddress
5176 * @details gets mac address
5177 * @param[in,out] handle to the wifi driver,
5179 * @return Error code indicating success/failure
5182 * @date 19 April 2012
5185 s32
host_int_get_MacAddress(WILC_WFIDrvHandle hWFIDrv
, u8
*pu8MacAddress
)
5187 s32 s32Error
= WILC_SUCCESS
;
5188 tstrHostIFmsg strHostIFmsg
;
5191 /* prepare the Message */
5192 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5194 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_MAC_ADDRESS
;
5195 strHostIFmsg
.uniHostIFmsgBody
.strHostIfGetMacAddress
.u8MacAddress
= pu8MacAddress
;
5196 strHostIFmsg
.drvHandler
= hWFIDrv
;
5197 /* send the message */
5198 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
5200 PRINT_ER("Failed to send get mac address\n");
5204 down(&hWaitResponse
);
5209 * @brief host_int_set_MacAddress
5210 * @details sets mac address
5211 * @param[in,out] handle to the wifi driver,
5213 * @return Error code indicating success/failure
5216 * @date 16 July 2012
5219 s32
host_int_set_MacAddress(WILC_WFIDrvHandle hWFIDrv
, u8
*pu8MacAddress
)
5221 s32 s32Error
= WILC_SUCCESS
;
5222 tstrHostIFmsg strHostIFmsg
;
5224 PRINT_D(GENERIC_DBG
, "mac addr = %x:%x:%x\n", pu8MacAddress
[0], pu8MacAddress
[1], pu8MacAddress
[2]);
5226 /* prepare setting mac address message */
5227 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5228 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SET_MAC_ADDRESS
;
5229 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetMacAddress
.u8MacAddress
, pu8MacAddress
, ETH_ALEN
);
5230 strHostIFmsg
.drvHandler
= hWFIDrv
;
5232 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
5234 PRINT_ER("Failed to send message queue: Set mac address\n");
5235 WILC_ERRORREPORT(s32Error
, s32Error
);
5237 WILC_CATCH(s32Error
)
5247 * @brief host_int_get_RSNAConfigPSKPassPhrase
5248 * @details gets the pass phrase:AP/STA mode. This function gets the pass phrase used to
5249 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5250 * The length of the field can vary from 8 to 64 bytes,
5251 * the lower layer should get the
5252 * @param[in,out] handle to the wifi driver,
5253 * String containing PSK
5254 * @return Error code indicating success/failure
5257 * @date 8 March 2012
5260 s32
host_int_get_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv
,
5261 u8
*pu8PassPhrase
, u8 u8Psklength
)
5263 s32 s32Error
= WILC_SUCCESS
;
5265 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5267 strWID
.u16WIDid
= (u16
)WID_11I_PSK
;
5268 strWID
.enuWIDtype
= WID_STR
;
5269 strWID
.s32ValueSize
= u8Psklength
;
5270 strWID
.ps8WidVal
= pu8PassPhrase
;
5276 * @brief host_int_get_site_survey_results
5277 * @details gets the site survey results
5278 * @param[in,out] handle to the wifi driver,
5279 * Message containing site survey results in the
5281 *|---------------------------------------------------|
5282 | MsgLength | fragNo. | MsgBodyLength | MsgBody |
5283 ||-----------|-----------|---------------|-----------|
5285 | ----------------------------------------- | ----------------
5287 ||---------------------------------------|
5288 | Network1 | Netweork2 | ... | Network5 |
5289 ||---------------------------------------|
5290 | 44 | 44 | ... | 44 |
5291 | -------------------------- | ---------------------------------------
5293 ||---------------------------------------------------------------------|
5294 | SSID | BSS Type | Channel | Security Status| BSSID | RSSI |Reserved |
5297 ||------|----------|---------|----------------|-------|------|---------|
5298 | 33 | 1 | 1 | 1 | 6 | 1 | 1 |
5299 ||---------------------------------------------------------------------|
5300 * @return Error code indicating success/failure
5303 * @date 8 March 2012
5306 #ifndef CONNECT_DIRECT
5307 s32
host_int_get_site_survey_results(WILC_WFIDrvHandle hWFIDrv
,
5308 u8 ppu8RcvdSiteSurveyResults
[][MAX_SURVEY_RESULT_FRAG_SIZE
],
5309 u32 u32MaxSiteSrvyFragLen
)
5311 s32 s32Error
= WILC_SUCCESS
;
5312 tstrWID astrWIDList
[2];
5313 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5315 astrWIDList
[0].u16WIDid
= (u16
)WID_SITE_SURVEY_RESULTS
;
5316 astrWIDList
[0].enuWIDtype
= WID_STR
;
5317 astrWIDList
[0].ps8WidVal
= ppu8RcvdSiteSurveyResults
[0];
5318 astrWIDList
[0].s32ValueSize
= u32MaxSiteSrvyFragLen
;
5320 astrWIDList
[1].u16WIDid
= (u16
)WID_SITE_SURVEY_RESULTS
;
5321 astrWIDList
[1].enuWIDtype
= WID_STR
;
5322 astrWIDList
[1].ps8WidVal
= ppu8RcvdSiteSurveyResults
[1];
5323 astrWIDList
[1].s32ValueSize
= u32MaxSiteSrvyFragLen
;
5325 s32Error
= SendConfigPkt(GET_CFG
, astrWIDList
, 2, true, (u32
)pstrWFIDrv
);
5327 /*get the value by searching the local copy*/
5329 PRINT_ER("Failed to send config packet to get survey results\n");
5330 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
5333 WILC_CATCH(s32Error
)
5343 * @brief sets a start scan request
5345 * @param[in,out] handle to the wifi driver,
5346 * @param[in] Scan Source one of the following values
5349 * OBSS_PERIODIC_SCAN BIT1
5350 * OBSS_ONETIME_SCAN BIT2
5351 * @return Error code indicating success/failure
5354 * @date 8 March 2012
5357 s32
host_int_set_start_scan_req(WILC_WFIDrvHandle hWFIDrv
, u8 scanSource
)
5359 s32 s32Error
= WILC_SUCCESS
;
5361 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5363 strWID
.u16WIDid
= (u16
)WID_START_SCAN_REQ
;
5364 strWID
.enuWIDtype
= WID_CHAR
;
5365 strWID
.ps8WidVal
= (s8
*)&scanSource
;
5366 strWID
.s32ValueSize
= sizeof(char);
5372 * @brief host_int_get_start_scan_req
5373 * @details gets a start scan request
5374 * @param[in,out] handle to the wifi driver,
5375 * @param[in] Scan Source one of the following values
5378 * OBSS_PERIODIC_SCAN BIT1
5379 * OBSS_ONETIME_SCAN BIT2
5380 * @return Error code indicating success/failure
5383 * @date 8 March 2012
5387 s32
host_int_get_start_scan_req(WILC_WFIDrvHandle hWFIDrv
, u8
*pu8ScanSource
)
5389 s32 s32Error
= WILC_SUCCESS
;
5391 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5393 strWID
.u16WIDid
= (u16
)WID_START_SCAN_REQ
;
5394 strWID
.enuWIDtype
= WID_CHAR
;
5395 strWID
.ps8WidVal
= (s8
*)pu8ScanSource
;
5396 strWID
.s32ValueSize
= sizeof(char);
5402 * @brief host_int_set_join_req
5403 * @details sets a join request
5404 * @param[in,out] handle to the wifi driver,
5405 * @param[in] Index of the bss descriptor
5406 * @return Error code indicating success/failure
5409 * @date 8 March 2012
5412 s32
host_int_set_join_req(WILC_WFIDrvHandle hWFIDrv
, u8
*pu8bssid
,
5413 const u8
*pu8ssid
, size_t ssidLen
,
5414 const u8
*pu8IEs
, size_t IEsLen
,
5415 tWILCpfConnectResult pfConnectResult
, void *pvUserArg
,
5416 u8 u8security
, AUTHTYPE_T tenuAuth_type
,
5420 s32 s32Error
= WILC_SUCCESS
;
5421 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5422 tstrHostIFmsg strHostIFmsg
;
5423 tenuScanConnTimer enuScanConnTimer
;
5425 if (pstrWFIDrv
== NULL
|| pfConnectResult
== NULL
)
5426 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5428 if (hWFIDrv
== NULL
) {
5429 PRINT_ER("Driver not initialized: gWFiDrvHandle = NULL\n");
5430 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
5433 if (pJoinParams
== NULL
) {
5434 PRINT_ER("Unable to Join - JoinParams is NULL\n");
5435 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
5439 * if(gWFiDrvHandle->strWILC_UsrScanReq.u32RcvdChCount == 0)
5441 * PRINT_ER("No scan results exist: Scanning should be done\n");
5442 * WILC_ERRORREPORT(s32Error, WILC_FAIL);
5445 /* prepare the Connect Message */
5446 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5448 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_CONNECT
;
5450 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.u8security
= u8security
;
5451 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.tenuAuth_type
= tenuAuth_type
;
5452 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.u8channel
= u8channel
;
5453 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pfConnectResult
= pfConnectResult
;
5454 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pvUserArg
= pvUserArg
;
5455 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pJoinParams
= pJoinParams
;
5456 strHostIFmsg
.drvHandler
= hWFIDrv
;
5458 if (pu8bssid
!= NULL
) {
5459 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pu8bssid
= (u8
*)WILC_MALLOC(6); /* will be deallocated by the receiving thread */
5460 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pu8bssid
,
5464 if (pu8ssid
!= NULL
) {
5465 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.ssidLen
= ssidLen
;
5466 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pu8ssid
= (u8
*)WILC_MALLOC(ssidLen
); /* will be deallocated by the receiving thread */
5467 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pu8ssid
,
5472 if (pu8IEs
!= NULL
) {
5473 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.IEsLen
= IEsLen
;
5474 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pu8IEs
= (u8
*)WILC_MALLOC(IEsLen
); /* will be deallocated by the receiving thread */
5475 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pu8IEs
,
5478 if (pstrWFIDrv
->enuHostIFstate
< HOST_IF_CONNECTING
) {
5479 pstrWFIDrv
->enuHostIFstate
= HOST_IF_CONNECTING
;
5481 PRINT_D(GENERIC_DBG
, "Don't set state to 'connecting' as state is %d\n", pstrWFIDrv
->enuHostIFstate
);
5483 /* send the message */
5484 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
5486 PRINT_ER("Failed to send message queue: Set join request\n");
5487 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
5490 enuScanConnTimer
= CONNECT_TIMER
;
5491 WILC_TimerStart(&(pstrWFIDrv
->hConnectTimer
), HOST_IF_CONNECT_TIMEOUT
, (void *) hWFIDrv
, NULL
);
5493 WILC_CATCH(s32Error
)
5502 * @brief Flush a join request parameters to FW, but actual connection
5503 * @details The function is called in situation where WILC is connected to AP and
5504 * required to switch to hybrid FW for P2P connection
5505 * @param[in] handle to the wifi driver,
5506 * @return Error code indicating success/failure
5508 * @author Amr Abdel-Moghny
5513 s32
host_int_flush_join_req(WILC_WFIDrvHandle hWFIDrv
)
5515 s32 s32Error
= WILC_SUCCESS
;
5516 tstrHostIFmsg strHostIFmsg
;
5518 if (!gu8FlushedJoinReq
) {
5519 s32Error
= WILC_FAIL
;
5524 if (hWFIDrv
== NULL
)
5525 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5528 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_FLUSH_CONNECT
;
5529 strHostIFmsg
.drvHandler
= hWFIDrv
;
5531 /* send the message */
5532 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
5534 PRINT_ER("Failed to send message queue: Flush join request\n");
5535 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
5538 WILC_CATCH(s32Error
)
5546 * @brief host_int_disconnect
5547 * @details disconnects from the currently associated network
5548 * @param[in,out] handle to the wifi driver,
5549 * @param[in] Reason Code of the Disconnection
5550 * @return Error code indicating success/failure
5553 * @date 8 March 2012
5556 s32
host_int_disconnect(WILC_WFIDrvHandle hWFIDrv
, u16 u16ReasonCode
)
5558 s32 s32Error
= WILC_SUCCESS
;
5559 tstrHostIFmsg strHostIFmsg
;
5560 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5562 if (pstrWFIDrv
== NULL
) {
5563 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
5564 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5567 if (pstrWFIDrv
== NULL
) {
5568 PRINT_ER("gWFiDrvHandle = NULL\n");
5569 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
5572 /* prepare the Disconnect Message */
5573 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5575 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_DISCONNECT
;
5576 strHostIFmsg
.drvHandler
= hWFIDrv
;
5578 /* send the message */
5579 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
5581 PRINT_ER("Failed to send message queue: disconnect\n");
5582 /* ////////////// */
5583 down(&(pstrWFIDrv
->hSemTestDisconnectBlock
));
5586 WILC_CATCH(s32Error
)
5595 * @brief host_int_disconnect_station
5596 * @details disconnects a sta
5597 * @param[in,out] handle to the wifi driver,
5598 * @param[in] Association Id of the station to be disconnected
5599 * @return Error code indicating success/failure
5602 * @date 8 March 2012
5605 s32
host_int_disconnect_station(WILC_WFIDrvHandle hWFIDrv
, u8 assoc_id
)
5607 s32 s32Error
= WILC_SUCCESS
;
5609 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5611 strWID
.u16WIDid
= (u16
)WID_DISCONNECT
;
5612 strWID
.enuWIDtype
= WID_CHAR
;
5613 strWID
.ps8WidVal
= (s8
*)&assoc_id
;
5614 strWID
.s32ValueSize
= sizeof(char);
5620 * @brief host_int_get_assoc_req_info
5621 * @details gets a Association request info
5622 * @param[in,out] handle to the wifi driver,
5623 * Message containg assoc. req info in the following format
5624 * ------------------------------------------------------------------------
5625 | Management Frame Format |
5626 ||-------------------------------------------------------------------|
5627 ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS |
5628 ||-------------|--------|--|--|-----|----------------|----------|----|
5629 | 2 |2 |6 |6 |6 | 2 |0 - 2312 | 4 |
5630 ||-------------------------------------------------------------------|
5632 | Association Request Frame - Frame Body |
5633 ||-------------------------------------------------------------------|
5634 | Capability Information | Listen Interval | SSID | Supported Rates |
5635 ||------------------------|-----------------|------|-----------------|
5636 | 2 | 2 | 2-34 | 3-10 |
5637 | ---------------------------------------------------------------------
5638 * @return Error code indicating success/failure
5641 * @date 8 March 2012
5645 s32
host_int_get_assoc_req_info(WILC_WFIDrvHandle hWFIDrv
, u8
*pu8AssocReqInfo
,
5646 u32 u32AssocReqInfoLen
)
5648 s32 s32Error
= WILC_SUCCESS
;
5650 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5652 strWID
.u16WIDid
= (u16
)WID_ASSOC_REQ_INFO
;
5653 strWID
.enuWIDtype
= WID_STR
;
5654 strWID
.ps8WidVal
= pu8AssocReqInfo
;
5655 strWID
.s32ValueSize
= u32AssocReqInfoLen
;
5662 * @brief gets a Association Response info
5664 * @param[in,out] handle to the wifi driver,
5665 * Message containg assoc. resp info
5666 * @return Error code indicating success/failure
5669 * @date 8 March 2012
5672 s32
host_int_get_assoc_res_info(WILC_WFIDrvHandle hWFIDrv
, u8
*pu8AssocRespInfo
,
5673 u32 u32MaxAssocRespInfoLen
, u32
*pu32RcvdAssocRespInfoLen
)
5675 s32 s32Error
= WILC_SUCCESS
;
5677 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5679 if (pstrWFIDrv
== NULL
) {
5680 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
5681 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5684 strWID
.u16WIDid
= (u16
)WID_ASSOC_RES_INFO
;
5685 strWID
.enuWIDtype
= WID_STR
;
5686 strWID
.ps8WidVal
= pu8AssocRespInfo
;
5687 strWID
.s32ValueSize
= u32MaxAssocRespInfoLen
;
5690 /* Sending Configuration packet */
5691 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
5693 PRINT_ER("Failed to send association response config packet\n");
5694 *pu32RcvdAssocRespInfoLen
= 0;
5695 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
5697 *pu32RcvdAssocRespInfoLen
= strWID
.s32ValueSize
;
5700 WILC_CATCH(s32Error
)
5708 * @brief gets a Association Response info
5709 * @details Valid only in STA mode. This function gives the RSSI
5710 * values observed in all the channels at the time of scanning.
5711 * The length of the field is 1 greater that the total number of
5712 * channels supported. Byte 0 contains the number of channels while
5713 * each of Byte N contains the observed RSSI value for the channel index N.
5714 * @param[in,out] handle to the wifi driver,
5715 * array of scanned channels' RSSI
5716 * @return Error code indicating success/failure
5719 * @date 8 March 2012
5722 s32
host_int_get_rx_power_level(WILC_WFIDrvHandle hWFIDrv
, u8
*pu8RxPowerLevel
,
5723 u32 u32RxPowerLevelLen
)
5725 s32 s32Error
= WILC_SUCCESS
;
5727 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5729 strWID
.u16WIDid
= (u16
)WID_RX_POWER_LEVEL
;
5730 strWID
.enuWIDtype
= WID_STR
;
5731 strWID
.ps8WidVal
= pu8RxPowerLevel
;
5732 strWID
.s32ValueSize
= u32RxPowerLevelLen
;
5739 * @brief sets a channel
5741 * @param[in,out] handle to the wifi driver,
5742 * @param[in] Index of the channel to be set
5743 *|-------------------------------------------------------------------|
5744 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5746 ||-------------------------------------------------------------------|
5747 * @return Error code indicating success/failure
5750 * @date 8 March 2012
5753 s32
host_int_set_mac_chnl_num(WILC_WFIDrvHandle hWFIDrv
, u8 u8ChNum
)
5755 s32 s32Error
= WILC_SUCCESS
;
5756 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5757 tstrHostIFmsg strHostIFmsg
;
5759 if (pstrWFIDrv
== NULL
)
5760 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5762 /* prepare the set channel message */
5763 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5764 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SET_CHANNEL
;
5765 strHostIFmsg
.uniHostIFmsgBody
.strHostIFSetChan
.u8SetChan
= u8ChNum
;
5766 strHostIFmsg
.drvHandler
= hWFIDrv
;
5768 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
5770 WILC_ERRORREPORT(s32Error
, s32Error
);
5771 WILC_CATCH(s32Error
)
5780 s32
host_int_wait_msg_queue_idle(void)
5782 s32 s32Error
= WILC_SUCCESS
;
5784 tstrHostIFmsg strHostIFmsg
;
5786 /* prepare the set driver handler message */
5788 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5789 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_Q_IDLE
;
5790 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
5792 WILC_ERRORREPORT(s32Error
, s32Error
);
5793 WILC_CATCH(s32Error
)
5798 /* wait untill MSG Q is empty */
5799 down(&hWaitResponse
);
5805 s32
host_int_set_wfi_drv_handler(u32 u32address
)
5807 s32 s32Error
= WILC_SUCCESS
;
5809 tstrHostIFmsg strHostIFmsg
;
5812 /* prepare the set driver handler message */
5814 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5815 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SET_WFIDRV_HANDLER
;
5816 strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetDrvHandler
.u32Address
= u32address
;
5817 /* strHostIFmsg.drvHandler=hWFIDrv; */
5819 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
5821 WILC_ERRORREPORT(s32Error
, s32Error
);
5822 WILC_CATCH(s32Error
)
5832 s32
host_int_set_operation_mode(WILC_WFIDrvHandle hWFIDrv
, u32 u32mode
)
5834 s32 s32Error
= WILC_SUCCESS
;
5836 tstrHostIFmsg strHostIFmsg
;
5839 /* prepare the set driver handler message */
5841 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5842 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SET_OPERATION_MODE
;
5843 strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetOperationMode
.u32Mode
= u32mode
;
5844 strHostIFmsg
.drvHandler
= hWFIDrv
;
5846 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
5848 WILC_ERRORREPORT(s32Error
, s32Error
);
5849 WILC_CATCH(s32Error
)
5858 * @brief gets the current channel index
5860 * @param[in,out] handle to the wifi driver,
5861 * current channel index
5862 *|-----------------------------------------------------------------------|
5863 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5865 ||-----------------------------------------------------------------------|
5866 * @return Error code indicating success/failure
5869 * @date 8 March 2012
5872 s32
host_int_get_host_chnl_num(WILC_WFIDrvHandle hWFIDrv
, u8
*pu8ChNo
)
5874 s32 s32Error
= WILC_SUCCESS
;
5875 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5876 tstrHostIFmsg strHostIFmsg
;
5878 if (pstrWFIDrv
== NULL
) {
5879 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
5880 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5883 /* prepare the Get Channel Message */
5884 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5886 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_CHNL
;
5887 strHostIFmsg
.drvHandler
= hWFIDrv
;
5889 /* send the message */
5890 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
5892 PRINT_ER("Failed to send get host channel param's message queue ");
5893 down(&(pstrWFIDrv
->hSemGetCHNL
));
5898 WILC_CATCH(s32Error
)
5909 * @brief host_int_test_set_int_wid
5910 * @details Test function for setting wids
5911 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr
5912 * @return Error code indicating success/failure
5915 * @date 8 March 2012
5918 s32
host_int_test_set_int_wid(WILC_WFIDrvHandle hWFIDrv
, u32 u32TestMemAddr
)
5920 s32 s32Error
= WILC_SUCCESS
;
5922 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5925 if (pstrWFIDrv
== NULL
) {
5926 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
5927 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5930 /*prepare configuration packet*/
5931 strWID
.u16WIDid
= (u16
)WID_MEMORY_ADDRESS
;
5932 strWID
.enuWIDtype
= WID_INT
;
5933 strWID
.ps8WidVal
= (char *)&u32TestMemAddr
;
5934 strWID
.s32ValueSize
= sizeof(u32
);
5937 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
5939 PRINT_ER("Test Function: Failed to set wid value\n");
5940 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
5942 PRINT_D(HOSTINF_DBG
, "Successfully set wid value\n");
5946 WILC_CATCH(s32Error
)
5953 #ifdef WILC_AP_EXTERNAL_MLME
5955 * @brief host_int_get_inactive_time
5957 * @param[in,out] handle to the wifi driver,
5958 * current sta macaddress, inactive_time
5965 s32
host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv
, const u8
*mac
, u32
*pu32InactiveTime
)
5967 s32 s32Error
= WILC_SUCCESS
;
5968 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5969 tstrHostIFmsg strHostIFmsg
;
5971 if (pstrWFIDrv
== NULL
) {
5972 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
5973 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5976 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5979 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIfStaInactiveT
.mac
,
5982 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_INACTIVETIME
;
5983 strHostIFmsg
.drvHandler
= hWFIDrv
;
5985 /* send the message */
5986 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
5988 PRINT_ER("Failed to send get host channel param's message queue ");
5990 down(&(pstrWFIDrv
->hSemInactiveTime
));
5992 *pu32InactiveTime
= gu32InactiveTime
;
5994 WILC_CATCH(s32Error
)
6002 * @brief host_int_test_get_int_wid
6003 * @details Test function for getting wids
6004 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32* pu32TestMemAddr
6005 * @return Error code indicating success/failure
6008 * @date 8 March 2012
6011 s32
host_int_test_get_int_wid(WILC_WFIDrvHandle hWFIDrv
, u32
*pu32TestMemAddr
)
6014 s32 s32Error
= WILC_SUCCESS
;
6016 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6019 if (pstrWFIDrv
== NULL
) {
6020 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
6021 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
6024 strWID
.u16WIDid
= (u16
)WID_MEMORY_ADDRESS
;
6025 strWID
.enuWIDtype
= WID_INT
;
6026 strWID
.ps8WidVal
= (s8
*)pu32TestMemAddr
;
6027 strWID
.s32ValueSize
= sizeof(u32
);
6029 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true, (u32
)pstrWFIDrv
);
6030 /*get the value by searching the local copy*/
6032 PRINT_ER("Test Function: Failed to get wid value\n");
6033 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
6035 PRINT_D(HOSTINF_DBG
, "Successfully got wid value\n");
6039 WILC_CATCH(s32Error
)
6048 * @brief host_int_get_rssi
6049 * @details gets the currently maintained RSSI value for the station.
6050 * The received signal strength value in dB.
6051 * The range of valid values is -128 to 0.
6052 * @param[in,out] handle to the wifi driver,
6054 * @return Error code indicating success/failure
6057 * @date 8 March 2012
6060 s32
host_int_get_rssi(WILC_WFIDrvHandle hWFIDrv
, s8
*ps8Rssi
)
6062 s32 s32Error
= WILC_SUCCESS
;
6063 tstrHostIFmsg strHostIFmsg
;
6064 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6067 /* prepare the Get RSSI Message */
6068 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6070 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_RSSI
;
6071 strHostIFmsg
.drvHandler
= hWFIDrv
;
6073 /* send the message */
6074 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
6076 PRINT_ER("Failed to send get host channel param's message queue ");
6080 down(&(pstrWFIDrv
->hSemGetRSSI
));
6083 if (ps8Rssi
== NULL
) {
6084 PRINT_ER("RSS pointer value is null");
6095 s32
host_int_get_link_speed(WILC_WFIDrvHandle hWFIDrv
, s8
*ps8lnkspd
)
6097 tstrHostIFmsg strHostIFmsg
;
6098 s32 s32Error
= WILC_SUCCESS
;
6100 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6104 /* prepare the Get LINKSPEED Message */
6105 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6107 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_LINKSPEED
;
6108 strHostIFmsg
.drvHandler
= hWFIDrv
;
6110 /* send the message */
6111 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
6113 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
6117 down(&(pstrWFIDrv
->hSemGetLINKSPEED
));
6120 if (ps8lnkspd
== NULL
) {
6121 PRINT_ER("LINKSPEED pointer value is null");
6126 *ps8lnkspd
= gs8lnkspd
;
6132 s32
host_int_get_statistics(WILC_WFIDrvHandle hWFIDrv
, tstrStatistics
*pstrStatistics
)
6134 s32 s32Error
= WILC_SUCCESS
;
6135 tstrHostIFmsg strHostIFmsg
;
6138 /* prepare the Get RSSI Message */
6139 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6141 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_STATISTICS
;
6142 strHostIFmsg
.uniHostIFmsgBody
.pUserData
= (char *)pstrStatistics
;
6143 strHostIFmsg
.drvHandler
= hWFIDrv
;
6144 /* send the message */
6145 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
6147 PRINT_ER("Failed to send get host channel param's message queue ");
6151 down(&hWaitResponse
);
6157 * @brief host_int_scan
6158 * @details scans a set of channels
6159 * @param[in,out] handle to the wifi driver,
6160 * @param[in] Scan source
6161 * Scan Type PASSIVE_SCAN = 0,
6164 * Channels Array length
6165 * Scan Callback function
6166 * @return Error code indicating success/failure
6169 * @date 8 March 2012
6172 s32
host_int_scan(WILC_WFIDrvHandle hWFIDrv
, u8 u8ScanSource
,
6173 u8 u8ScanType
, u8
*pu8ChnlFreqList
,
6174 u8 u8ChnlListLen
, const u8
*pu8IEs
,
6175 size_t IEsLen
, tWILCpfScanResult ScanResult
,
6176 void *pvUserArg
, tstrHiddenNetwork
*pstrHiddenNetwork
)
6178 s32 s32Error
= WILC_SUCCESS
;
6179 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6180 tstrHostIFmsg strHostIFmsg
;
6181 tenuScanConnTimer enuScanConnTimer
;
6183 if (pstrWFIDrv
== NULL
|| ScanResult
== NULL
)
6184 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
6187 /* prepare the Scan Message */
6188 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6190 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SCAN
;
6192 if (pstrHiddenNetwork
!= NULL
) {
6193 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.strHiddenNetwork
.pstrHiddenNetworkInfo
= pstrHiddenNetwork
->pstrHiddenNetworkInfo
;
6194 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.strHiddenNetwork
.u8ssidnum
= pstrHiddenNetwork
->u8ssidnum
;
6197 PRINT_D(HOSTINF_DBG
, "pstrHiddenNetwork IS EQUAL TO NULL\n");
6199 strHostIFmsg
.drvHandler
= hWFIDrv
;
6200 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.u8ScanSource
= u8ScanSource
;
6201 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.u8ScanType
= u8ScanType
;
6202 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.pfScanResult
= ScanResult
;
6203 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.pvUserArg
= pvUserArg
;
6205 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.u8ChnlListLen
= u8ChnlListLen
;
6206 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.pu8ChnlFreqList
= (u8
*)WILC_MALLOC(u8ChnlListLen
); /* will be deallocated by the receiving thread */
6207 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.pu8ChnlFreqList
,
6208 pu8ChnlFreqList
, u8ChnlListLen
);
6210 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.IEsLen
= IEsLen
;
6211 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.pu8IEs
= (u8
*)WILC_MALLOC(IEsLen
); /* will be deallocated by the receiving thread */
6212 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.pu8IEs
,
6215 /* send the message */
6216 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
6218 PRINT_ER("Error in sending message queue scanning parameters: Error(%d)\n", s32Error
);
6219 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
6222 enuScanConnTimer
= SCAN_TIMER
;
6223 PRINT_D(HOSTINF_DBG
, ">> Starting the SCAN timer\n");
6224 WILC_TimerStart(&(pstrWFIDrv
->hScanTimer
), HOST_IF_SCAN_TIMEOUT
, (void *) hWFIDrv
, NULL
);
6227 WILC_CATCH(s32Error
)
6235 * @brief hif_set_cfg
6236 * @details sets configuration wids values
6237 * @param[in,out] handle to the wifi driver,
6238 * @param[in] WID, WID value
6239 * @return Error code indicating success/failure
6242 * @date 8 March 2012
6245 s32
hif_set_cfg(WILC_WFIDrvHandle hWFIDrv
, tstrCfgParamVal
*pstrCfgParamVal
)
6248 s32 s32Error
= WILC_SUCCESS
;
6249 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6251 tstrHostIFmsg strHostIFmsg
;
6254 if (pstrWFIDrv
== NULL
)
6255 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
6256 /* prepare the WiphyParams Message */
6257 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6258 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_CFG_PARAMS
;
6259 strHostIFmsg
.uniHostIFmsgBody
.strHostIFCfgParamAttr
.pstrCfgParamVal
= *pstrCfgParamVal
;
6260 strHostIFmsg
.drvHandler
= hWFIDrv
;
6262 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
6264 WILC_CATCH(s32Error
)
6274 * @brief hif_get_cfg
6275 * @details gets configuration wids values
6276 * @param[in,out] handle to the wifi driver,
6279 * @return Error code indicating success/failure
6283 * @date 8 March 2012
6286 s32
hif_get_cfg(WILC_WFIDrvHandle hWFIDrv
, u16 u16WID
, u16
*pu16WID_Value
)
6288 s32 s32Error
= WILC_SUCCESS
;
6289 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6291 down(&(pstrWFIDrv
->gtOsCfgValuesSem
));
6293 if (pstrWFIDrv
== NULL
) {
6294 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
6295 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
6297 PRINT_D(HOSTINF_DBG
, "Getting configuration parameters\n");
6301 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.bss_type
;
6305 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.auth_type
;
6308 case WID_AUTH_TIMEOUT
:
6309 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.auth_timeout
;
6312 case WID_POWER_MANAGEMENT
:
6313 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.power_mgmt_mode
;
6316 case WID_SHORT_RETRY_LIMIT
:
6317 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.short_retry_limit
;
6320 case WID_LONG_RETRY_LIMIT
:
6321 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.long_retry_limit
;
6324 case WID_FRAG_THRESHOLD
:
6325 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.frag_threshold
;
6328 case WID_RTS_THRESHOLD
:
6329 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.rts_threshold
;
6333 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.preamble_type
;
6336 case WID_SHORT_SLOT_ALLOWED
:
6337 *pu16WID_Value
= (u16
) pstrWFIDrv
->strCfgValues
.short_slot_allowed
;
6340 case WID_11N_TXOP_PROT_DISABLE
:
6341 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.txop_prot_disabled
;
6344 case WID_BEACON_INTERVAL
:
6345 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.beacon_interval
;
6348 case WID_DTIM_PERIOD
:
6349 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.dtim_period
;
6352 case WID_SITE_SURVEY
:
6353 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.site_survey_enabled
;
6356 case WID_SITE_SURVEY_SCAN_TIME
:
6357 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.site_survey_scan_time
;
6360 case WID_ACTIVE_SCAN_TIME
:
6361 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.active_scan_time
;
6364 case WID_PASSIVE_SCAN_TIME
:
6365 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.passive_scan_time
;
6368 case WID_CURRENT_TX_RATE
:
6369 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.curr_tx_rate
;
6376 up(&(pstrWFIDrv
->gtOsCfgValuesSem
));
6378 WILC_CATCH(s32Error
)
6385 /*****************************************************************************/
6386 /* Notification Functions */
6387 /*****************************************************************************/
6389 * @brief notifies host with join and leave requests
6390 * @details This function prepares an Information frame having the
6391 * information about a joining/leaving station.
6392 * @param[in,out] handle to the wifi driver,
6393 * @param[in] 6 byte Sta Adress
6394 * Join or leave flag:
6397 * @return Error code indicating success/failure
6400 * @date 8 March 2012
6403 void host_int_send_join_leave_info_to_host
6404 (u16 assocId
, u8
*stationAddr
, bool joining
)
6408 * @brief notifies host with stations found in scan
6409 * @details sends the beacon/probe response from scan
6410 * @param[in,out] handle to the wifi driver,
6411 * @param[in] Sta Address,
6413 * Rssi of the Station found
6414 * @return Error code indicating success/failure
6417 * @date 8 March 2012
6421 void GetPeriodicRSSI(void *pvArg
)
6423 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)pvArg
;
6424 if (pstrWFIDrv
== NULL
) {
6425 PRINT_ER("Driver handler is NULL\n");
6429 if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_CONNECTED
) {
6430 s32 s32Error
= WILC_SUCCESS
;
6431 tstrHostIFmsg strHostIFmsg
;
6433 /* prepare the Get RSSI Message */
6434 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6436 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_RSSI
;
6437 strHostIFmsg
.drvHandler
= pstrWFIDrv
;
6439 /* send the message */
6440 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
6442 PRINT_ER("Failed to send get host channel param's message queue ");
6446 WILC_TimerStart(&(g_hPeriodicRSSI
), 5000, (void *)pstrWFIDrv
, NULL
);
6450 void host_int_send_network_info_to_host
6451 (u8
*macStartAddress
, u16 u16RxFrameLen
, s8 s8Rssi
)
6455 * @brief host_int_init
6456 * @details host interface initialization function
6457 * @param[in,out] handle to the wifi driver,
6460 * @date 8 March 2012
6463 static u32 u32Intialized
;
6464 static u32 msgQ_created
;
6465 static u32 clients_count
;
6467 s32
host_int_init(WILC_WFIDrvHandle
*phWFIDrv
)
6469 s32 s32Error
= WILC_SUCCESS
;
6470 tstrWILC_WFIDrv
*pstrWFIDrv
;
6472 /*if(u32Intialized == 1)
6474 * PRINT_D(HOSTINF_DBG,"Host interface is previously initialized\n");
6475 * *phWFIDrv = (WILC_WFIDrvHandle)gWFiDrvHandle; //Will be adjusted later for P2P
6478 PRINT_D(HOSTINF_DBG
, "Initializing host interface for client %d\n", clients_count
+ 1);
6480 gbScanWhileConnected
= false;
6482 sema_init(&hWaitResponse
, 0);
6486 /*Allocate host interface private structure*/
6487 pstrWFIDrv
= (tstrWILC_WFIDrv
*)WILC_MALLOC(sizeof(tstrWILC_WFIDrv
));
6488 if (pstrWFIDrv
== NULL
) {
6489 /* WILC_ERRORREPORT(s32Error,WILC_NO_MEM); */
6490 s32Error
= WILC_NO_MEM
;
6491 PRINT_ER("Failed to allocate memory\n");
6494 WILC_memset(pstrWFIDrv
, 0, sizeof(tstrWILC_WFIDrv
));
6495 /*return driver handle to user*/
6496 *phWFIDrv
= (WILC_WFIDrvHandle
)pstrWFIDrv
;
6497 /*save into globl handle*/
6499 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
6501 g_obtainingIP
= false;
6504 PRINT_D(HOSTINF_DBG
, "Global handle pointer value=%p\n", pstrWFIDrv
);
6505 /* /////////////////////////////////////// */
6506 if (clients_count
== 0) {
6507 sema_init(&hSemHostIFthrdEnd
, 0);
6508 sema_init(&hSemDeinitDrvHandle
, 0);
6510 sema_init(&hSemHostIntDeinit
, 1);
6513 sema_init(&(pstrWFIDrv
->hSemTestKeyBlock
), 0);
6514 sema_init(&(pstrWFIDrv
->hSemTestDisconnectBlock
), 0);
6515 sema_init(&(pstrWFIDrv
->hSemGetRSSI
), 0);
6516 sema_init(&(pstrWFIDrv
->hSemGetLINKSPEED
), 0);
6517 sema_init(&(pstrWFIDrv
->hSemGetCHNL
), 0);
6518 sema_init(&(pstrWFIDrv
->hSemInactiveTime
), 0);
6520 /* /////////////////////////////////////// */
6524 PRINT_D(HOSTINF_DBG
, "INIT: CLIENT COUNT %d\n", clients_count
);
6526 if (clients_count
== 0) {
6528 s32Error
= WILC_MsgQueueCreate(&gMsgQHostIF
, NULL
);
6532 PRINT_ER("Failed to creat MQ\n");
6536 HostIFthreadHandler
= kthread_run(hostIFthread
, NULL
, "WILC_kthread");
6537 if (IS_ERR(HostIFthreadHandler
)) {
6538 PRINT_ER("Failed to creat Thread\n");
6539 s32Error
= WILC_FAIL
;
6542 s32Error
= WILC_TimerCreate(&(g_hPeriodicRSSI
), GetPeriodicRSSI
, NULL
);
6544 PRINT_ER("Failed to creat Timer\n");
6547 WILC_TimerStart(&(g_hPeriodicRSSI
), 5000, (void *)pstrWFIDrv
, NULL
);
6552 s32Error
= WILC_TimerCreate(&(pstrWFIDrv
->hScanTimer
), TimerCB_Scan
, NULL
);
6554 PRINT_ER("Failed to creat Timer\n");
6558 s32Error
= WILC_TimerCreate(&(pstrWFIDrv
->hConnectTimer
), TimerCB_Connect
, NULL
);
6560 PRINT_ER("Failed to creat Timer\n");
6566 /*Remain on channel timer*/
6567 s32Error
= WILC_TimerCreate(&(pstrWFIDrv
->hRemainOnChannel
), ListenTimerCB
, NULL
);
6569 PRINT_ER("Failed to creat Remain-on-channel Timer\n");
6574 sema_init(&(pstrWFIDrv
->gtOsCfgValuesSem
), 1);
6575 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 /*Initialize Simulaor*/
6620 CoreConfigSimulatorInit();
6624 clients_count
++; /* increase number of created entities */
6630 if (pstrWFIDrv
!= NULL
)
6631 WILC_FREE(pstrWFIDrv
);
6634 WILC_TimerDestroy(&(pstrWFIDrv
->hRemainOnChannel
), NULL
);
6637 up(&(pstrWFIDrv
->gtOsCfgValuesSem
));
6638 WILC_TimerDestroy(&(pstrWFIDrv
->hConnectTimer
), NULL
);
6640 WILC_TimerDestroy(&(pstrWFIDrv
->hScanTimer
), NULL
);
6642 kthread_stop(HostIFthreadHandler
);
6644 WILC_MsgQueueDestroy(&gMsgQHostIF
, NULL
);
6651 * @brief host_int_deinit
6652 * @details host interface initialization function
6653 * @param[in,out] handle to the wifi driver,
6656 * @date 8 March 2012
6660 s32
host_int_deinit(WILC_WFIDrvHandle hWFIDrv
)
6662 s32 s32Error
= WILC_SUCCESS
;
6663 tstrHostIFmsg strHostIFmsg
;
6666 /*obtain driver handle*/
6667 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6668 /*if(u32Intialized == 0)
6670 * PRINT_ER("Host Interface is not initialized\n");
6676 if (pstrWFIDrv
== NULL
) {
6677 PRINT_ER("pstrWFIDrv = NULL\n");
6681 down(&hSemHostIntDeinit
);
6683 terminated_handle
= pstrWFIDrv
;
6684 PRINT_D(HOSTINF_DBG
, "De-initializing host interface for client %d\n", clients_count
);
6687 /*Destroy all timers before acquiring hSemDeinitDrvHandle*/
6688 /*to guarantee handling all messages befor proceeding*/
6689 if (WILC_TimerDestroy(&(pstrWFIDrv
->hScanTimer
), NULL
)) {
6690 PRINT_D(HOSTINF_DBG
, ">> Scan timer is active \n");
6691 /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */
6694 if (WILC_TimerDestroy(&(pstrWFIDrv
->hConnectTimer
), NULL
)) {
6695 PRINT_D(HOSTINF_DBG
, ">> Connect timer is active \n");
6696 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6700 if (WILC_TimerDestroy(&(g_hPeriodicRSSI
), NULL
)) {
6701 PRINT_D(HOSTINF_DBG
, ">> Connect timer is active \n");
6702 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6706 /*Destroy Remain-onchannel Timer*/
6707 WILC_TimerDestroy(&(pstrWFIDrv
->hRemainOnChannel
), NULL
);
6710 host_int_set_wfi_drv_handler((u32
)NULL
);
6711 down(&hSemDeinitDrvHandle
);
6714 /*Calling the CFG80211 scan done function with the abort flag set to true*/
6715 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
6716 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult(SCAN_EVENT_ABORTED
, NULL
,
6717 pstrWFIDrv
->strWILC_UsrScanReq
.u32UserScanPvoid
, NULL
);
6719 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
= NULL
;
6721 /*deinit configurator and simulator*/
6723 CoreConfigSimulatorDeInit();
6725 CoreConfiguratorDeInit();
6730 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
6732 gbScanWhileConnected
= false;
6734 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6736 if (clients_count
== 1) {
6737 if (WILC_TimerDestroy(&g_hPeriodicRSSI
, NULL
)) {
6738 PRINT_D(HOSTINF_DBG
, ">> Connect timer is active \n");
6739 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6741 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_EXIT
;
6742 strHostIFmsg
.drvHandler
= hWFIDrv
;
6745 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
6746 if (s32Error
!= WILC_SUCCESS
)
6747 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error
);
6749 down(&hSemHostIFthrdEnd
);
6753 WILC_MsgQueueDestroy(&gMsgQHostIF
, NULL
);
6757 down(&(pstrWFIDrv
->gtOsCfgValuesSem
));
6759 /*Setting the gloabl driver handler with NULL*/
6761 /* gWFiDrvHandle = NULL; */
6762 if (pstrWFIDrv
!= NULL
) {
6763 WILC_FREE(pstrWFIDrv
);
6764 /* pstrWFIDrv=NULL; */
6768 clients_count
--; /* Decrease number of created entities */
6769 terminated_handle
= NULL
;
6770 up(&hSemHostIntDeinit
);
6776 * @brief NetworkInfoReceived
6777 * @details function to to be called when network info packet is received
6778 * @param[in] pu8Buffer the received packet
6779 * @param[in] u32Length length of the received packet
6786 void NetworkInfoReceived(u8
*pu8Buffer
, u32 u32Length
)
6788 s32 s32Error
= WILC_SUCCESS
;
6789 tstrHostIFmsg strHostIFmsg
;
6791 tstrWILC_WFIDrv
*pstrWFIDrv
= NULL
;
6793 drvHandler
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
6794 pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
6799 if (pstrWFIDrv
== NULL
|| pstrWFIDrv
== terminated_handle
) {
6800 PRINT_ER("NetworkInfo received but driver not init[%p]\n", pstrWFIDrv
);
6804 /* prepare the Asynchronous Network Info message */
6805 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6807 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_RCVD_NTWRK_INFO
;
6808 strHostIFmsg
.drvHandler
= pstrWFIDrv
;
6810 strHostIFmsg
.uniHostIFmsgBody
.strRcvdNetworkInfo
.u32Length
= u32Length
;
6811 strHostIFmsg
.uniHostIFmsgBody
.strRcvdNetworkInfo
.pu8Buffer
= (u8
*)WILC_MALLOC(u32Length
); /* will be deallocated by the receiving thread */
6812 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strRcvdNetworkInfo
.pu8Buffer
,
6813 pu8Buffer
, u32Length
);
6815 /* send the message */
6816 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
6818 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error
);
6825 * @brief GnrlAsyncInfoReceived
6826 * @details function to be called when general Asynchronous info packet is received
6827 * @param[in] pu8Buffer the received packet
6828 * @param[in] u32Length length of the received packet
6835 void GnrlAsyncInfoReceived(u8
*pu8Buffer
, u32 u32Length
)
6837 s32 s32Error
= WILC_SUCCESS
;
6838 tstrHostIFmsg strHostIFmsg
;
6840 tstrWILC_WFIDrv
*pstrWFIDrv
= NULL
;
6843 down(&hSemHostIntDeinit
);
6845 drvHandler
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
6846 pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
6847 PRINT_D(HOSTINF_DBG
, "General asynchronous info packet received \n");
6850 if (pstrWFIDrv
== NULL
|| pstrWFIDrv
== terminated_handle
) {
6851 PRINT_D(HOSTINF_DBG
, "Wifi driver handler is equal to NULL\n");
6853 up(&hSemHostIntDeinit
);
6857 if (pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
== NULL
) {
6858 /* received mac status is not needed when there is no current Connect Request */
6859 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
6861 up(&hSemHostIntDeinit
);
6865 /* prepare the General Asynchronous Info message */
6866 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6869 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO
;
6870 strHostIFmsg
.drvHandler
= pstrWFIDrv
;
6873 strHostIFmsg
.uniHostIFmsgBody
.strRcvdGnrlAsyncInfo
.u32Length
= u32Length
;
6874 strHostIFmsg
.uniHostIFmsgBody
.strRcvdGnrlAsyncInfo
.pu8Buffer
= (u8
*)WILC_MALLOC(u32Length
); /* will be deallocated by the receiving thread */
6875 WILC_memcpy(strHostIFmsg
.uniHostIFmsgBody
.strRcvdGnrlAsyncInfo
.pu8Buffer
,
6876 pu8Buffer
, u32Length
);
6878 /* send the message */
6879 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
6881 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error
);
6884 up(&hSemHostIntDeinit
);
6889 * @brief host_int_ScanCompleteReceived
6890 * @details Setting scan complete received notifcation in message queue
6891 * @param[in] u8* pu8Buffer, u32 u32Length
6892 * @return Error code.
6897 void host_int_ScanCompleteReceived(u8
*pu8Buffer
, u32 u32Length
)
6899 s32 s32Error
= WILC_SUCCESS
;
6900 tstrHostIFmsg strHostIFmsg
;
6902 tstrWILC_WFIDrv
*pstrWFIDrv
= NULL
;
6903 drvHandler
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
6904 pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
6907 PRINT_D(GENERIC_DBG
, "Scan notification received %p\n", pstrWFIDrv
);
6909 if (pstrWFIDrv
== NULL
|| pstrWFIDrv
== terminated_handle
)
6912 /*if there is an ongoing scan request*/
6913 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
6914 /* prepare theScan Done message */
6915 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6917 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_RCVD_SCAN_COMPLETE
;
6918 strHostIFmsg
.drvHandler
= pstrWFIDrv
;
6921 /* will be deallocated by the receiving thread */
6922 /*no need to send message body*/
6924 /*strHostIFmsg.uniHostIFmsgBody.strScanComplete.u32Length = u32Length;
6925 * strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer = (u8*)WILC_MALLOC(u32Length);
6926 * WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer,
6927 * pu8Buffer, u32Length); */
6929 /* send the message */
6930 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
6932 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error
);
6942 * @brief host_int_remain_on_channel
6944 * @param[in] Handle to wifi driver
6945 * Duration to remain on channel
6946 * Channel to remain on
6947 * Pointer to fn to be called on receive frames in listen state
6948 * Pointer to remain-on-channel expired fn
6950 * @return Error code.
6955 s32
host_int_remain_on_channel(WILC_WFIDrvHandle hWFIDrv
, u32 u32SessionID
, u32 u32duration
, u16 chan
, tWILCpfRemainOnChanExpired RemainOnChanExpired
, tWILCpfRemainOnChanReady RemainOnChanReady
, void *pvUserArg
)
6957 s32 s32Error
= WILC_SUCCESS
;
6958 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6959 tstrHostIFmsg strHostIFmsg
;
6961 if (pstrWFIDrv
== NULL
)
6962 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
6964 /* prepare the remainonchan Message */
6965 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6967 /* prepare the WiphyParams Message */
6968 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_REMAIN_ON_CHAN
;
6969 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.u16Channel
= chan
;
6970 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.pRemainOnChanExpired
= RemainOnChanExpired
;
6971 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.pRemainOnChanReady
= RemainOnChanReady
;
6972 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.pVoid
= pvUserArg
;
6973 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.u32duration
= u32duration
;
6974 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.u32ListenSessionID
= u32SessionID
;
6975 strHostIFmsg
.drvHandler
= hWFIDrv
;
6977 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
6979 WILC_ERRORREPORT(s32Error
, s32Error
);
6980 WILC_CATCH(s32Error
)
6989 * @brief host_int_ListenStateExpired
6991 * @param[in] Handle to wifi driver
6992 * Duration to remain on channel
6993 * Channel to remain on
6994 * Pointer to fn to be called on receive frames in listen state
6995 * Pointer to remain-on-channel expired fn
6997 * @return Error code.
7002 s32
host_int_ListenStateExpired(WILC_WFIDrvHandle hWFIDrv
, u32 u32SessionID
)
7004 s32 s32Error
= WILC_SUCCESS
;
7005 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7006 tstrHostIFmsg strHostIFmsg
;
7008 if (pstrWFIDrv
== NULL
)
7009 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7011 /*Stopping remain-on-channel timer*/
7012 WILC_TimerStop(&(pstrWFIDrv
->hRemainOnChannel
), NULL
);
7014 /* prepare the timer fire Message */
7015 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7016 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_LISTEN_TIMER_FIRED
;
7017 strHostIFmsg
.drvHandler
= hWFIDrv
;
7018 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.u32ListenSessionID
= u32SessionID
;
7020 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7022 WILC_ERRORREPORT(s32Error
, s32Error
);
7023 WILC_CATCH(s32Error
)
7031 * @brief host_int_frame_register
7033 * @param[in] Handle to wifi driver
7034 * @return Error code.
7038 s32
host_int_frame_register(WILC_WFIDrvHandle hWFIDrv
, u16 u16FrameType
, bool bReg
)
7040 s32 s32Error
= WILC_SUCCESS
;
7041 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7042 tstrHostIFmsg strHostIFmsg
;
7044 if (pstrWFIDrv
== NULL
)
7045 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7047 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7049 /* prepare the WiphyParams Message */
7050 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_REGISTER_FRAME
;
7051 switch (u16FrameType
) {
7053 PRINT_D(HOSTINF_DBG
, "ACTION\n");
7054 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRegisterFrame
.u8Regid
= ACTION_FRM_IDX
;
7058 PRINT_D(HOSTINF_DBG
, "PROBE REQ\n");
7059 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRegisterFrame
.u8Regid
= PROBE_REQ_IDX
;
7063 PRINT_D(HOSTINF_DBG
, "Not valid frame type\n");
7066 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRegisterFrame
.u16FrameType
= u16FrameType
;
7067 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRegisterFrame
.bReg
= bReg
;
7068 strHostIFmsg
.drvHandler
= hWFIDrv
;
7070 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7072 WILC_ERRORREPORT(s32Error
, s32Error
);
7073 WILC_CATCH(s32Error
)
7084 #ifdef WILC_AP_EXTERNAL_MLME
7086 * @brief host_int_add_beacon
7087 * @details Setting add beacon params in message queue
7088 * @param[in] WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
7089 * u32 u32DTIMPeriod,u32 u32HeadLen, u8* pu8Head,
7090 * u32 u32TailLen, u8* pu8Tail
7091 * @return Error code.
7096 s32
host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv
, u32 u32Interval
,
7098 u32 u32HeadLen
, u8
*pu8Head
,
7099 u32 u32TailLen
, u8
*pu8Tail
)
7101 s32 s32Error
= WILC_SUCCESS
;
7102 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7103 tstrHostIFmsg strHostIFmsg
;
7104 tstrHostIFSetBeacon
*pstrSetBeaconParam
= &strHostIFmsg
.uniHostIFmsgBody
.strHostIFSetBeacon
;
7106 if (pstrWFIDrv
== NULL
)
7107 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7109 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7111 PRINT_D(HOSTINF_DBG
, "Setting adding beacon message queue params\n");
7114 /* prepare the WiphyParams Message */
7115 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_ADD_BEACON
;
7116 strHostIFmsg
.drvHandler
= hWFIDrv
;
7117 pstrSetBeaconParam
->u32Interval
= u32Interval
;
7118 pstrSetBeaconParam
->u32DTIMPeriod
= u32DTIMPeriod
;
7119 pstrSetBeaconParam
->u32HeadLen
= u32HeadLen
;
7120 pstrSetBeaconParam
->pu8Head
= (u8
*)WILC_MALLOC(u32HeadLen
);
7121 if (pstrSetBeaconParam
->pu8Head
== NULL
)
7122 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
7123 WILC_memcpy(pstrSetBeaconParam
->pu8Head
, pu8Head
, u32HeadLen
);
7124 pstrSetBeaconParam
->u32TailLen
= u32TailLen
;
7126 /* Bug 4599 : if tail length = 0 skip allocating & copying */
7127 if (u32TailLen
> 0) {
7128 pstrSetBeaconParam
->pu8Tail
= (u8
*)WILC_MALLOC(u32TailLen
);
7129 if (pstrSetBeaconParam
->pu8Tail
== NULL
)
7130 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
7131 WILC_memcpy(pstrSetBeaconParam
->pu8Tail
, pu8Tail
, u32TailLen
);
7133 pstrSetBeaconParam
->pu8Tail
= NULL
;
7136 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7138 WILC_ERRORREPORT(s32Error
, s32Error
);
7140 WILC_CATCH(s32Error
)
7142 if (pstrSetBeaconParam
->pu8Head
!= NULL
)
7143 WILC_FREE(pstrSetBeaconParam
->pu8Head
);
7145 if (pstrSetBeaconParam
->pu8Tail
!= NULL
)
7146 WILC_FREE(pstrSetBeaconParam
->pu8Tail
);
7155 * @brief host_int_del_beacon
7156 * @details Setting add beacon params in message queue
7157 * @param[in] WILC_WFIDrvHandle hWFIDrv
7158 * @return Error code.
7163 s32
host_int_del_beacon(WILC_WFIDrvHandle hWFIDrv
)
7165 s32 s32Error
= WILC_SUCCESS
;
7166 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7167 tstrHostIFmsg strHostIFmsg
;
7169 if (pstrWFIDrv
== NULL
)
7170 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7172 /* prepare the WiphyParams Message */
7173 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_DEL_BEACON
;
7174 strHostIFmsg
.drvHandler
= hWFIDrv
;
7175 PRINT_D(HOSTINF_DBG
, "Setting deleting beacon message queue params\n");
7177 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7178 WILC_ERRORCHECK(s32Error
);
7180 WILC_CATCH(s32Error
)
7188 * @brief host_int_add_station
7189 * @details Setting add station params in message queue
7190 * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7191 * @return Error code.
7196 s32
host_int_add_station(WILC_WFIDrvHandle hWFIDrv
, tstrWILC_AddStaParam
*pstrStaParams
)
7198 s32 s32Error
= WILC_SUCCESS
;
7199 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7200 tstrHostIFmsg strHostIFmsg
;
7201 tstrWILC_AddStaParam
*pstrAddStationMsg
= &strHostIFmsg
.uniHostIFmsgBody
.strAddStaParam
;
7204 if (pstrWFIDrv
== NULL
)
7205 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7207 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7209 PRINT_D(HOSTINF_DBG
, "Setting adding station message queue params\n");
7212 /* prepare the WiphyParams Message */
7213 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_ADD_STATION
;
7214 strHostIFmsg
.drvHandler
= hWFIDrv
;
7216 WILC_memcpy(pstrAddStationMsg
, pstrStaParams
, sizeof(tstrWILC_AddStaParam
));
7217 if (pstrAddStationMsg
->u8NumRates
> 0) {
7218 u8
*rates
= WILC_MALLOC(pstrAddStationMsg
->u8NumRates
);
7219 WILC_NULLCHECK(s32Error
, rates
);
7221 WILC_memcpy(rates
, pstrStaParams
->pu8Rates
, pstrAddStationMsg
->u8NumRates
);
7222 pstrAddStationMsg
->pu8Rates
= rates
;
7226 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7228 WILC_ERRORREPORT(s32Error
, s32Error
);
7230 WILC_CATCH(s32Error
)
7237 * @brief host_int_del_station
7238 * @details Setting delete station params in message queue
7239 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr
7240 * @return Error code.
7245 s32
host_int_del_station(WILC_WFIDrvHandle hWFIDrv
, const u8
*pu8MacAddr
)
7247 s32 s32Error
= WILC_SUCCESS
;
7248 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7249 tstrHostIFmsg strHostIFmsg
;
7250 tstrHostIFDelSta
*pstrDelStationMsg
= &strHostIFmsg
.uniHostIFmsgBody
.strDelStaParam
;
7252 if (pstrWFIDrv
== NULL
)
7253 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7255 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7257 PRINT_D(HOSTINF_DBG
, "Setting deleting station message queue params\n");
7261 /* prepare the WiphyParams Message */
7262 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_DEL_STATION
;
7263 strHostIFmsg
.drvHandler
= hWFIDrv
;
7265 /*BugID_4795: Handling situation of deleting all stations*/
7266 if (pu8MacAddr
== NULL
)
7267 WILC_memset(pstrDelStationMsg
->au8MacAddr
, 255, ETH_ALEN
);
7269 WILC_memcpy(pstrDelStationMsg
->au8MacAddr
, pu8MacAddr
, ETH_ALEN
);
7271 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7273 WILC_ERRORREPORT(s32Error
, s32Error
);
7275 WILC_CATCH(s32Error
)
7281 * @brief host_int_del_allstation
7282 * @details Setting del station params in message queue
7283 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]s
7284 * @return Error code.
7289 s32
host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv
, u8 pu8MacAddr
[][ETH_ALEN
])
7291 s32 s32Error
= WILC_SUCCESS
;
7292 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7293 tstrHostIFmsg strHostIFmsg
;
7294 tstrHostIFDelAllSta
*pstrDelAllStationMsg
= &strHostIFmsg
.uniHostIFmsgBody
.strHostIFDelAllSta
;
7295 u8 au8Zero_Buff
[ETH_ALEN
] = {0};
7300 if (pstrWFIDrv
== NULL
)
7301 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7303 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7305 PRINT_D(HOSTINF_DBG
, "Setting deauthenticating station message queue params\n");
7307 /* prepare the WiphyParams Message */
7308 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_DEL_ALL_STA
;
7309 strHostIFmsg
.drvHandler
= hWFIDrv
;
7311 /* Handling situation of deauthenticing all associated stations*/
7312 for (i
= 0; i
< MAX_NUM_STA
; i
++) {
7313 if (memcmp(pu8MacAddr
[i
], au8Zero_Buff
, ETH_ALEN
)) {
7314 WILC_memcpy(pstrDelAllStationMsg
->au8Sta_DelAllSta
[i
], pu8MacAddr
[i
], ETH_ALEN
);
7315 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],
7316 pstrDelAllStationMsg
->au8Sta_DelAllSta
[i
][5]);
7321 PRINT_D(CFG80211_DBG
, "NO ASSOCIATED STAS\n");
7325 pstrDelAllStationMsg
->u8Num_AssocSta
= u8AssocNumb
;
7326 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7330 WILC_ERRORREPORT(s32Error
, s32Error
);
7332 WILC_CATCH(s32Error
)
7336 down(&hWaitResponse
);
7343 * @brief host_int_edit_station
7344 * @details Setting edit station params in message queue
7345 * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7346 * @return Error code.
7351 s32
host_int_edit_station(WILC_WFIDrvHandle hWFIDrv
, tstrWILC_AddStaParam
*pstrStaParams
)
7353 s32 s32Error
= WILC_SUCCESS
;
7354 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7355 tstrHostIFmsg strHostIFmsg
;
7356 tstrWILC_AddStaParam
*pstrAddStationMsg
= &strHostIFmsg
.uniHostIFmsgBody
.strAddStaParam
;
7358 if (pstrWFIDrv
== NULL
)
7359 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7361 PRINT_D(HOSTINF_DBG
, "Setting editing station message queue params\n");
7363 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7366 /* prepare the WiphyParams Message */
7367 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_EDIT_STATION
;
7368 strHostIFmsg
.drvHandler
= hWFIDrv
;
7370 WILC_memcpy(pstrAddStationMsg
, pstrStaParams
, sizeof(tstrWILC_AddStaParam
));
7371 if (pstrAddStationMsg
->u8NumRates
> 0) {
7372 u8
*rates
= WILC_MALLOC(pstrAddStationMsg
->u8NumRates
);
7373 WILC_NULLCHECK(s32Error
, rates
);
7374 WILC_memcpy(rates
, pstrStaParams
->pu8Rates
, pstrAddStationMsg
->u8NumRates
);
7375 pstrAddStationMsg
->pu8Rates
= rates
;
7378 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7380 WILC_ERRORREPORT(s32Error
, s32Error
);
7381 WILC_CATCH(s32Error
)
7386 #endif /*WILC_AP_EXTERNAL_MLME*/
7387 uint32_t wilc_get_chipid(uint8_t);
7389 s32
host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv
, bool bIsEnabled
, u32 u32Timeout
)
7391 s32 s32Error
= WILC_SUCCESS
;
7392 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7393 tstrHostIFmsg strHostIFmsg
;
7394 tstrHostIfPowerMgmtParam
*pstrPowerMgmtParam
= &strHostIFmsg
.uniHostIFmsgBody
.strPowerMgmtparam
;
7396 PRINT_INFO(HOSTINF_DBG
, "\n\n>> Setting PS to %d << \n\n", bIsEnabled
);
7398 if (pstrWFIDrv
== NULL
)
7399 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7401 PRINT_D(HOSTINF_DBG
, "Setting Power management message queue params\n");
7403 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7406 /* prepare the WiphyParams Message */
7407 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_POWER_MGMT
;
7408 strHostIFmsg
.drvHandler
= hWFIDrv
;
7410 pstrPowerMgmtParam
->bIsEnabled
= bIsEnabled
;
7411 pstrPowerMgmtParam
->u32Timeout
= u32Timeout
;
7414 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7416 WILC_ERRORREPORT(s32Error
, s32Error
);
7417 WILC_CATCH(s32Error
)
7423 s32
host_int_setup_multicast_filter(WILC_WFIDrvHandle hWFIDrv
, bool bIsEnabled
, u32 u32count
)
7425 s32 s32Error
= WILC_SUCCESS
;
7427 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7428 tstrHostIFmsg strHostIFmsg
;
7429 tstrHostIFSetMulti
*pstrMulticastFilterParam
= &strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetMulti
;
7432 if (pstrWFIDrv
== NULL
)
7433 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7435 PRINT_D(HOSTINF_DBG
, "Setting Multicast Filter params\n");
7437 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7440 /* prepare the WiphyParams Message */
7441 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SET_MULTICAST_FILTER
;
7442 strHostIFmsg
.drvHandler
= hWFIDrv
;
7444 pstrMulticastFilterParam
->bIsEnabled
= bIsEnabled
;
7445 pstrMulticastFilterParam
->u32count
= u32count
;
7447 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7449 WILC_ERRORREPORT(s32Error
, s32Error
);
7450 WILC_CATCH(s32Error
)
7458 /*Bug4218: Parsing Join Param*/
7459 #ifdef WILC_PARSE_SCAN_IN_HOST
7461 /*Bug4218: Parsing Join Param*/
7463 * @brief host_int_ParseJoinBssParam
7464 * @details Parse Needed Join Parameters and save it in a new JoinBssParam entry
7465 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7470 static void *host_int_ParseJoinBssParam(tstrNetworkInfo
*ptstrNetworkInfo
)
7472 tstrJoinBssParam
*pNewJoinBssParam
= NULL
;
7481 u8 pcipherTotalCount
= 0;
7482 u8 authTotalCount
= 0;
7485 pu8IEs
= ptstrNetworkInfo
->pu8IEs
;
7486 u16IEsLen
= ptstrNetworkInfo
->u16IEsLen
;
7488 pNewJoinBssParam
= WILC_MALLOC(sizeof(tstrJoinBssParam
));
7489 if (pNewJoinBssParam
!= NULL
) {
7490 WILC_memset(pNewJoinBssParam
, 0, sizeof(tstrJoinBssParam
));
7491 pNewJoinBssParam
->dtim_period
= ptstrNetworkInfo
->u8DtimPeriod
;
7492 pNewJoinBssParam
->beacon_period
= ptstrNetworkInfo
->u16BeaconPeriod
;
7493 pNewJoinBssParam
->cap_info
= ptstrNetworkInfo
->u16CapInfo
;
7494 WILC_memcpy(pNewJoinBssParam
->au8bssid
, ptstrNetworkInfo
->au8bssid
, 6);
7496 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/
7497 WILC_memcpy((u8
*)pNewJoinBssParam
->ssid
, ptstrNetworkInfo
->au8ssid
, ptstrNetworkInfo
->u8SsidLen
+ 1);
7498 pNewJoinBssParam
->ssidLen
= ptstrNetworkInfo
->u8SsidLen
;
7499 WILC_memset(pNewJoinBssParam
->rsn_pcip_policy
, 0xFF, 3);
7500 WILC_memset(pNewJoinBssParam
->rsn_auth_policy
, 0xFF, 3);
7501 /*for(i=0; i<pNewJoinBssParam->ssidLen;i++)
7502 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/
7504 /* parse supported rates: */
7505 while (index
< u16IEsLen
) {
7506 /* supportedRates IE */
7507 if (pu8IEs
[index
] == SUPP_RATES_IE
) {
7508 /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */
7509 suppRatesNo
= pu8IEs
[index
+ 1];
7510 pNewJoinBssParam
->supp_rates
[0] = suppRatesNo
;
7511 index
+= 2; /* skipping ID and length bytes; */
7513 for (i
= 0; i
< suppRatesNo
; i
++) {
7514 pNewJoinBssParam
->supp_rates
[i
+ 1] = pu8IEs
[index
+ i
];
7515 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */
7517 index
+= suppRatesNo
;
7520 /* Ext SupportedRates IE */
7521 else if (pu8IEs
[index
] == EXT_SUPP_RATES_IE
) {
7522 /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */
7523 /* checking if no of ext. supp and supp rates < max limit */
7524 extSuppRatesNo
= pu8IEs
[index
+ 1];
7525 if (extSuppRatesNo
> (MAX_RATES_SUPPORTED
- suppRatesNo
))
7526 pNewJoinBssParam
->supp_rates
[0] = MAX_RATES_SUPPORTED
;
7528 pNewJoinBssParam
->supp_rates
[0] += extSuppRatesNo
;
7530 /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */
7531 for (i
= 0; i
< (pNewJoinBssParam
->supp_rates
[0] - suppRatesNo
); i
++) {
7532 pNewJoinBssParam
->supp_rates
[suppRatesNo
+ i
+ 1] = pu8IEs
[index
+ i
];
7533 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */
7535 index
+= extSuppRatesNo
;
7539 else if (pu8IEs
[index
] == HT_CAPABILITY_IE
) {
7540 /* if IE found set the flag */
7541 pNewJoinBssParam
->ht_capable
= true;
7542 index
+= pu8IEs
[index
+ 1] + 2; /* ID,Length bytes and IE body */
7543 /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */
7545 } else if ((pu8IEs
[index
] == WMM_IE
) && /* WMM Element ID */
7546 (pu8IEs
[index
+ 2] == 0x00) && (pu8IEs
[index
+ 3] == 0x50) &&
7547 (pu8IEs
[index
+ 4] == 0xF2) && /* OUI */
7548 (pu8IEs
[index
+ 5] == 0x02) && /* OUI Type */
7549 ((pu8IEs
[index
+ 6] == 0x00) || (pu8IEs
[index
+ 6] == 0x01)) && /* OUI Sub Type */
7550 (pu8IEs
[index
+ 7] == 0x01)) {
7551 /* Presence of WMM Info/Param element indicates WMM capability */
7552 pNewJoinBssParam
->wmm_cap
= true;
7554 /* Check if Bit 7 is set indicating U-APSD capability */
7555 if (pu8IEs
[index
+ 8] & (1 << 7))
7556 pNewJoinBssParam
->uapsd_cap
= true;
7557 index
+= pu8IEs
[index
+ 1] + 2;
7561 else if ((pu8IEs
[index
] == P2P_IE
) && /* P2P Element ID */
7562 (pu8IEs
[index
+ 2] == 0x50) && (pu8IEs
[index
+ 3] == 0x6f) &&
7563 (pu8IEs
[index
+ 4] == 0x9a) && /* OUI */
7564 (pu8IEs
[index
+ 5] == 0x09) && (pu8IEs
[index
+ 6] == 0x0c)) { /* OUI Type */
7566 pNewJoinBssParam
->tsf
= ptstrNetworkInfo
->u32Tsf
;
7567 pNewJoinBssParam
->u8NoaEnbaled
= 1;
7568 pNewJoinBssParam
->u8Index
= pu8IEs
[index
+ 9];
7570 /* Check if Bit 7 is set indicating Opss capability */
7571 if (pu8IEs
[index
+ 10] & (1 << 7)) {
7572 pNewJoinBssParam
->u8OppEnable
= 1;
7573 pNewJoinBssParam
->u8CtWindow
= pu8IEs
[index
+ 10];
7575 pNewJoinBssParam
->u8OppEnable
= 0;
7577 PRINT_D(GENERIC_DBG
, "P2P Dump \n");
7578 for (i
= 0; i
< pu8IEs
[index
+ 7]; i
++)
7579 PRINT_D(GENERIC_DBG
, " %x \n", pu8IEs
[index
+ 9 + i
]);
7581 pNewJoinBssParam
->u8Count
= pu8IEs
[index
+ 11];
7582 u16P2P_count
= index
+ 12;
7584 WILC_memcpy(pNewJoinBssParam
->au8Duration
, pu8IEs
+ u16P2P_count
, 4);
7587 WILC_memcpy(pNewJoinBssParam
->au8Interval
, pu8IEs
+ u16P2P_count
, 4);
7590 WILC_memcpy(pNewJoinBssParam
->au8StartTime
, pu8IEs
+ u16P2P_count
, 4);
7592 index
+= pu8IEs
[index
+ 1] + 2;
7597 else if ((pu8IEs
[index
] == RSN_IE
) ||
7598 ((pu8IEs
[index
] == WPA_IE
) && (pu8IEs
[index
+ 2] == 0x00) &&
7599 (pu8IEs
[index
+ 3] == 0x50) && (pu8IEs
[index
+ 4] == 0xF2) &&
7600 (pu8IEs
[index
+ 5] == 0x01))) {
7601 u16 rsnIndex
= index
;
7602 /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]);
7603 * for(i=0; i<pu8IEs[rsnIndex+1]; i++)
7605 * PRINT_D(HOSTINF_DBG,"%0x ",pu8IEs[rsnIndex+2+i]);
7607 if (pu8IEs
[rsnIndex
] == RSN_IE
) {
7608 pNewJoinBssParam
->mode_802_11i
= 2;
7609 /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */
7610 } else { /* check if rsn was previously parsed */
7611 if (pNewJoinBssParam
->mode_802_11i
== 0)
7612 pNewJoinBssParam
->mode_802_11i
= 1;
7613 /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */
7616 rsnIndex
+= 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */
7617 pNewJoinBssParam
->rsn_grp_policy
= pu8IEs
[rsnIndex
];
7619 /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x \n",pNewJoinBssParam->rsn_grp_policy); */
7620 /* initialize policies with invalid values */
7622 jumpOffset
= pu8IEs
[rsnIndex
] * 4; /* total no.of bytes of pcipher field (count*4) */
7624 /*parsing pairwise cipher*/
7626 /* saving 3 pcipher max. */
7627 pcipherCount
= (pu8IEs
[rsnIndex
] > 3) ? 3 : pu8IEs
[rsnIndex
];
7628 rsnIndex
+= 2; /* jump 2 bytes of pcipher count */
7630 /* PRINT_D(HOSTINF_DBG,"\npcipher:%d \n",pcipherCount); */
7631 for (i
= pcipherTotalCount
, j
= 0; i
< pcipherCount
+ pcipherTotalCount
&& i
< 3; i
++, j
++) {
7632 /* each count corresponds to 4 bytes, only last byte is saved */
7633 pNewJoinBssParam
->rsn_pcip_policy
[i
] = pu8IEs
[rsnIndex
+ ((j
+ 1) * 4) - 1];
7634 /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */
7636 pcipherTotalCount
+= pcipherCount
;
7637 rsnIndex
+= jumpOffset
;
7639 jumpOffset
= pu8IEs
[rsnIndex
] * 4;
7641 /*parsing AKM suite (auth_policy)*/
7642 /* saving 3 auth policies max. */
7643 authCount
= (pu8IEs
[rsnIndex
] > 3) ? 3 : pu8IEs
[rsnIndex
];
7644 rsnIndex
+= 2; /* jump 2 bytes of pcipher count */
7646 for (i
= authTotalCount
, j
= 0; i
< authTotalCount
+ authCount
; i
++, j
++) {
7647 /* each count corresponds to 4 bytes, only last byte is saved */
7648 pNewJoinBssParam
->rsn_auth_policy
[i
] = pu8IEs
[rsnIndex
+ ((j
+ 1) * 4) - 1];
7650 authTotalCount
+= authCount
;
7651 rsnIndex
+= jumpOffset
;
7652 /*pasring rsn cap. only if rsn IE*/
7653 if (pu8IEs
[index
] == RSN_IE
) {
7654 pNewJoinBssParam
->rsn_cap
[0] = pu8IEs
[rsnIndex
];
7655 pNewJoinBssParam
->rsn_cap
[1] = pu8IEs
[rsnIndex
+ 1];
7658 pNewJoinBssParam
->rsn_found
= true;
7659 index
+= pu8IEs
[index
+ 1] + 2; /* ID,Length bytes and IE body */
7662 index
+= pu8IEs
[index
+ 1] + 2; /* ID,Length bytes and IE body */
7669 return (void *)pNewJoinBssParam
;
7673 void host_int_freeJoinParams(void *pJoinParams
)
7675 if ((tstrJoinBssParam
*)pJoinParams
!= NULL
)
7676 WILC_FREE((tstrJoinBssParam
*)pJoinParams
);
7678 PRINT_ER("Unable to FREE null pointer\n");
7680 #endif /*WILC_PARSE_SCAN_IN_HOST*/
7684 * @brief host_int_addBASession
7685 * @details Open a block Ack session with the given parameters
7686 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7688 * @author anoureldin
7692 static int host_int_addBASession(WILC_WFIDrvHandle hWFIDrv
, char *pBSSID
, char TID
, short int BufferSize
,
7693 short int SessionTimeout
, void *drvHandler
)
7695 s32 s32Error
= WILC_SUCCESS
;
7696 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7697 tstrHostIFmsg strHostIFmsg
;
7698 tstrHostIfBASessionInfo
*pBASessionInfo
= &strHostIFmsg
.uniHostIFmsgBody
.strHostIfBASessionInfo
;
7700 if (pstrWFIDrv
== NULL
)
7701 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7703 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7705 /* prepare the WiphyParams Message */
7706 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_ADD_BA_SESSION
;
7708 memcpy(pBASessionInfo
->au8Bssid
, pBSSID
, ETH_ALEN
);
7709 pBASessionInfo
->u8Ted
= TID
;
7710 pBASessionInfo
->u16BufferSize
= BufferSize
;
7711 pBASessionInfo
->u16SessionTimeout
= SessionTimeout
;
7712 strHostIFmsg
.drvHandler
= hWFIDrv
;
7714 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7716 WILC_ERRORREPORT(s32Error
, s32Error
);
7717 WILC_CATCH(s32Error
)
7726 s32
host_int_delBASession(WILC_WFIDrvHandle hWFIDrv
, char *pBSSID
, char TID
)
7728 s32 s32Error
= WILC_SUCCESS
;
7729 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7730 tstrHostIFmsg strHostIFmsg
;
7731 tstrHostIfBASessionInfo
*pBASessionInfo
= &strHostIFmsg
.uniHostIFmsgBody
.strHostIfBASessionInfo
;
7733 if (pstrWFIDrv
== NULL
)
7734 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7736 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7738 /* prepare the WiphyParams Message */
7739 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_DEL_BA_SESSION
;
7741 memcpy(pBASessionInfo
->au8Bssid
, pBSSID
, ETH_ALEN
);
7742 pBASessionInfo
->u8Ted
= TID
;
7743 strHostIFmsg
.drvHandler
= hWFIDrv
;
7745 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7747 WILC_ERRORREPORT(s32Error
, s32Error
);
7748 WILC_CATCH(s32Error
)
7754 down(&hWaitResponse
);
7759 s32
host_int_del_All_Rx_BASession(WILC_WFIDrvHandle hWFIDrv
, char *pBSSID
, char TID
)
7761 s32 s32Error
= WILC_SUCCESS
;
7762 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7763 tstrHostIFmsg strHostIFmsg
;
7764 tstrHostIfBASessionInfo
*pBASessionInfo
= &strHostIFmsg
.uniHostIFmsgBody
.strHostIfBASessionInfo
;
7766 if (pstrWFIDrv
== NULL
)
7767 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7769 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7771 /* prepare the WiphyParams Message */
7772 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS
;
7774 memcpy(pBASessionInfo
->au8Bssid
, pBSSID
, ETH_ALEN
);
7775 pBASessionInfo
->u8Ted
= TID
;
7776 strHostIFmsg
.drvHandler
= hWFIDrv
;
7778 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7780 WILC_ERRORREPORT(s32Error
, s32Error
);
7781 WILC_CATCH(s32Error
)
7787 down(&hWaitResponse
);
7793 * @brief host_int_setup_ipaddress
7794 * @details setup IP in firmware
7795 * @param[in] Handle to wifi driver
7796 * @return Error code.
7797 * @author Abdelrahman Sobhy
7800 s32
host_int_setup_ipaddress(WILC_WFIDrvHandle hWFIDrv
, u8
*u16ipadd
, u8 idx
)
7802 s32 s32Error
= WILC_SUCCESS
;
7803 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7804 tstrHostIFmsg strHostIFmsg
;
7806 /* TODO: Enable This feature on softap firmware */
7809 if (pstrWFIDrv
== NULL
)
7810 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7812 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7814 /* prepare the WiphyParams Message */
7815 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SET_IPADDRESS
;
7817 strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.au8IPAddr
= u16ipadd
;
7818 strHostIFmsg
.drvHandler
= hWFIDrv
;
7819 strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.idx
= idx
;
7821 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7823 WILC_ERRORREPORT(s32Error
, s32Error
);
7824 WILC_CATCH(s32Error
)
7835 * @brief host_int_get_ipaddress
7836 * @details Get IP from firmware
7837 * @param[in] Handle to wifi driver
7838 * @return Error code.
7839 * @author Abdelrahman Sobhy
7842 s32
host_int_get_ipaddress(WILC_WFIDrvHandle hWFIDrv
, u8
*u16ipadd
, u8 idx
)
7844 s32 s32Error
= WILC_SUCCESS
;
7845 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7846 tstrHostIFmsg strHostIFmsg
;
7848 if (pstrWFIDrv
== NULL
)
7849 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7851 WILC_memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7853 /* prepare the WiphyParams Message */
7854 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_IPADDRESS
;
7856 strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.au8IPAddr
= u16ipadd
;
7857 strHostIFmsg
.drvHandler
= hWFIDrv
;
7858 strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.idx
= idx
;
7860 s32Error
= WILC_MsgQueueSend(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), NULL
);
7862 WILC_ERRORREPORT(s32Error
, s32Error
);
7863 WILC_CATCH(s32Error
)