1 #include "host_interface.h"
2 #include "coreconfigurator.h"
6 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
7 extern struct timer_list hDuringIpTimer
;
11 extern u8 g_wilc_initialized
;
12 /*****************************************************************************/
14 /*****************************************************************************/
16 /* Message types of the Host IF Message Queue*/
17 #define HOST_IF_MSG_SCAN 0
18 #define HOST_IF_MSG_CONNECT 1
19 #define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
20 #define HOST_IF_MSG_KEY 3
21 #define HOST_IF_MSG_RCVD_NTWRK_INFO 4
22 #define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
23 #define HOST_IF_MSG_CFG_PARAMS 6
24 #define HOST_IF_MSG_SET_CHANNEL 7
25 #define HOST_IF_MSG_DISCONNECT 8
26 #define HOST_IF_MSG_GET_RSSI 9
27 #define HOST_IF_MSG_GET_CHNL 10
28 #define HOST_IF_MSG_ADD_BEACON 11
29 #define HOST_IF_MSG_DEL_BEACON 12
30 #define HOST_IF_MSG_ADD_STATION 13
31 #define HOST_IF_MSG_DEL_STATION 14
32 #define HOST_IF_MSG_EDIT_STATION 15
33 #define HOST_IF_MSG_SCAN_TIMER_FIRED 16
34 #define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
35 #define HOST_IF_MSG_POWER_MGMT 18
36 #define HOST_IF_MSG_GET_INACTIVETIME 19
37 #define HOST_IF_MSG_REMAIN_ON_CHAN 20
38 #define HOST_IF_MSG_REGISTER_FRAME 21
39 #define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
40 #define HOST_IF_MSG_GET_LINKSPEED 23
41 #define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
42 #define HOST_IF_MSG_SET_MAC_ADDRESS 25
43 #define HOST_IF_MSG_GET_MAC_ADDRESS 26
44 #define HOST_IF_MSG_SET_OPERATION_MODE 27
45 #define HOST_IF_MSG_SET_IPADDRESS 28
46 #define HOST_IF_MSG_GET_IPADDRESS 29
47 #define HOST_IF_MSG_FLUSH_CONNECT 30
48 #define HOST_IF_MSG_GET_STATISTICS 31
49 #define HOST_IF_MSG_SET_MULTICAST_FILTER 32
50 #define HOST_IF_MSG_ADD_BA_SESSION 33
51 #define HOST_IF_MSG_DEL_BA_SESSION 34
52 #define HOST_IF_MSG_Q_IDLE 35
53 #define HOST_IF_MSG_DEL_ALL_STA 36
54 #define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
55 #define HOST_IF_MSG_EXIT 100
57 #define HOST_IF_SCAN_TIMEOUT 4000
58 #define HOST_IF_CONNECT_TIMEOUT 9500
60 #define BA_SESSION_DEFAULT_BUFFER_SIZE 16
61 #define BA_SESSION_DEFAULT_TIMEOUT 1000
62 #define BLOCK_ACK_REQ_SIZE 0x14
63 /*****************************************************************************/
64 /* Type Definitions */
65 /*****************************************************************************/
68 * @struct tstrHostIFCfgParamAttr
69 * @brief Structure to hold Host IF CFG Params Attributes
73 * @author Mai Daftedar
77 typedef struct _tstrHostIFCfgParamAttr
{
78 tstrCfgParamVal pstrCfgParamVal
;
80 } tstrHostIFCfgParamAttr
;
83 * @struct tstrHostIFwpaAttr
84 * @brief Structure to hold Host IF Scan Attributes
88 * @author Mai Daftedar
92 typedef struct _tstrHostIFwpaAttr
{
104 * @struct tstrHostIFwepAttr
105 * @brief Structure to hold Host IF Scan Attributes
109 * @author Mai Daftedar
110 * @date 25 March 2012
113 typedef struct _tstrHostIFwepAttr
{
118 AUTHTYPE_T tenuAuth_type
;
123 * @struct tuniHostIFkeyAttr
124 * @brief Structure to hold Host IF Scan Attributes
128 * @author Mai Daftedar
129 * @date 25 March 2012
132 typedef union _tuniHostIFkeyAttr
{
133 tstrHostIFwepAttr strHostIFwepAttr
;
134 tstrHostIFwpaAttr strHostIFwpaAttr
;
135 tstrHostIFpmkidAttr strHostIFpmkidAttr
;
139 * @struct tstrHostIFkeyAttr
140 * @brief Structure to hold Host IF Scan Attributes
144 * @author Mai Daftedar
145 * @date 25 March 2012
148 typedef struct _tstrHostIFkeyAttr
{
149 tenuKeyType enuKeyType
;
151 tuniHostIFkeyAttr uniHostIFkeyAttr
;
158 * @struct tstrHostIFscanAttr
159 * @brief Structure to hold Host IF Scan Attributes
163 * @author Mostafa Abu Bakr
164 * @date 25 March 2012
167 typedef struct _tstrHostIFscanAttr
{
174 tWILCpfScanResult pfScanResult
;
177 tstrHiddenNetwork strHiddenNetwork
;
179 } tstrHostIFscanAttr
;
182 * @struct tstrHostIFconnectAttr
183 * @brief Structure to hold Host IF Connect Attributes
187 * @author Mostafa Abu Bakr
188 * @date 25 March 2012
191 typedef struct _tstrHostIFconnectAttr
{
198 tWILCpfConnectResult pfConnectResult
;
200 AUTHTYPE_T tenuAuth_type
;
203 } tstrHostIFconnectAttr
;
206 * @struct tstrRcvdGnrlAsyncInfo
207 * @brief Structure to hold Received General Asynchronous info
211 * @author Mostafa Abu Bakr
212 * @date 25 March 2012
215 typedef struct _tstrRcvdGnrlAsyncInfo
{
218 } tstrRcvdGnrlAsyncInfo
;
221 * @struct tstrHostIFSetChan
222 * @brief Set Channel message body
226 * @author Mai Daftedar
227 * @date 25 March 2012
230 typedef struct _tstrHostIFSetChan
{
235 * @struct tstrHostIFSetChan
236 * @brief Get Channel message body
240 * @author Mai Daftedar
244 typedef struct _tstrHostIFGetChan
{
248 /*bug3819: Add Scan acomplete notification to host*/
250 * @struct tstrScanComplete
251 * @brief hold received Async. Scan Complete message body
256 * @date 25 March 2012
259 /*typedef struct _tstrScanComplete
263 * } tstrScanComplete;*/
266 * @struct tstrHostIFSetBeacon
267 * @brief Set Beacon message body
271 * @author Adham Abozaeid
275 typedef struct _tstrHostIFSetBeacon
{
276 u32 u32Interval
; /*!< Beacon Interval. Period between two successive beacons on air */
277 u32 u32DTIMPeriod
; /*!< DTIM Period. Indicates how many Beacon frames
278 * (including the current frame) appear before the next DTIM */
279 u32 u32HeadLen
; /*!< Length of the head buffer in bytes */
280 u8
*pu8Head
; /*!< Pointer to the beacon's head buffer. Beacon's head is the part
281 * from the beacon's start till the TIM element, NOT including the TIM */
282 u32 u32TailLen
; /*!< Length of the tail buffer in bytes */
283 u8
*pu8Tail
; /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just
284 * after the TIM inormation element */
285 } tstrHostIFSetBeacon
;
290 * @struct tstrHostIFDelBeacon
291 * @brief Del Beacon message body
295 * @author Adham Abozaeid
299 typedef struct _tstrHostIFDelBeacon
{
301 } tstrHostIFDelBeacon
;
304 * @struct tstrHostIFSetMulti
305 * @brief set Multicast filter Address
309 * @author Abdelrahman Sobhy
310 * @date 30 August 2013
311 * @version 1.0 Description
317 } tstrHostIFSetMulti
;
320 * @struct tstrHostIFDelAllSta
321 * @brief Deauth station message body
325 * @author Mai Daftedar
326 * @date 09 April 2014
327 * @version 1.0 Description
331 u8 au8Sta_DelAllSta
[MAX_NUM_STA
][ETH_ALEN
];
333 } tstrHostIFDelAllSta
;
336 * @struct tstrHostIFDelSta
337 * @brief Delete station message body
341 * @author Adham Abozaeid
343 * @version 1.0 Description
347 u8 au8MacAddr
[ETH_ALEN
];
351 * @struct tstrTimerCb
352 * @brief Timer callback message body
356 * @author Mostafa Abu Bakr
357 * @date 25 March 2012
360 typedef struct _tstrTimerCb
{
361 void *pvUsrArg
; /*!< Private data passed at timer start */
365 * @struct tstrHostIfPowerMgmtParam
366 * @brief Power management message body
370 * @author Adham Abozaeid
371 * @date 24 November 2012
378 } tstrHostIfPowerMgmtParam
;
381 * @struct tstrHostIFSetIPAddr
382 * @brief set IP Address message body
386 * @author Abdelrahman Sobhy
387 * @date 30 August 2013
388 * @version 1.0 Description
394 } tstrHostIFSetIPAddr
;
397 * @struct tstrHostIfStaInactiveT
398 * @brief Get station message body
402 * @author Mai Daftedar
403 * @date 16 April 2013
409 } tstrHostIfStaInactiveT
;
412 * @union tuniHostIFmsgBody
413 * @brief Message body for the Host Interface message_q
417 * @author Mostafa Abu Bakr
418 * @date 25 March 2012
421 typedef union _tuniHostIFmsgBody
{
422 tstrHostIFscanAttr strHostIFscanAttr
; /*!< Host IF Scan Request Attributes message body */
423 tstrHostIFconnectAttr strHostIFconnectAttr
; /*!< Host IF Connect Request Attributes message body */
424 tstrRcvdNetworkInfo strRcvdNetworkInfo
; /*!< Received Asynchronous Network Info message body */
425 tstrRcvdGnrlAsyncInfo strRcvdGnrlAsyncInfo
; /*!< Received General Asynchronous Info message body */
426 tstrHostIFkeyAttr strHostIFkeyAttr
; /*!<>*/
427 tstrHostIFCfgParamAttr strHostIFCfgParamAttr
; /*! <CFG Parameter message Body> */
428 tstrHostIFSetChan strHostIFSetChan
;
429 tstrHostIFGetChan strHostIFGetChan
;
430 tstrHostIFSetBeacon strHostIFSetBeacon
; /*!< Set beacon message body */
431 tstrHostIFDelBeacon strHostIFDelBeacon
; /*!< Del beacon message body */
432 tstrWILC_AddStaParam strAddStaParam
; /*!< Add station message body */
433 tstrHostIFDelSta strDelStaParam
; /*!< Del Station message body */
434 tstrWILC_AddStaParam strEditStaParam
; /*!< Edit station message body */
435 /* tstrScanComplete strScanComplete; / *Received Async. Scan Complete message body* / */
436 tstrTimerCb strTimerCb
; /*!< Timer callback message body */
437 tstrHostIfPowerMgmtParam strPowerMgmtparam
; /*!< Power Management message body */
438 tstrHostIfStaInactiveT strHostIfStaInactiveT
;
439 tstrHostIFSetIPAddr strHostIfSetIP
;
440 tstrHostIfSetDrvHandler strHostIfSetDrvHandler
;
441 tstrHostIFSetMulti strHostIfSetMulti
;
442 tstrHostIfSetOperationMode strHostIfSetOperationMode
;
443 tstrHostIfSetMacAddress strHostIfSetMacAddress
;
444 tstrHostIfGetMacAddress strHostIfGetMacAddress
;
445 tstrHostIfBASessionInfo strHostIfBASessionInfo
;
447 tstrHostIfRemainOnChan strHostIfRemainOnChan
;
448 tstrHostIfRegisterFrame strHostIfRegisterFrame
;
451 tstrHostIFDelAllSta strHostIFDelAllSta
;
455 * @struct tstrHostIFmsg
456 * @brief Host Interface message
460 * @author Mostafa Abu Bakr
461 * @date 25 March 2012
464 typedef struct _tstrHostIFmsg
{
465 u16 u16MsgId
; /*!< Message ID */
466 tuniHostIFmsgBody uniHostIFmsgBody
; /*!< Message body */
467 tstrWILC_WFIDrv
*drvHandler
;
470 #ifdef CONNECT_DIRECT
471 typedef struct _tstrWidJoinReqExt
{
472 char SSID
[MAX_SSID_LEN
];
478 /*Bug4218: Parsing Join Param*/
479 #ifdef WILC_PARSE_SCAN_IN_HOST
480 /*Struct containg joinParam of each AP*/
481 typedef struct _tstrJoinBssParam
{
487 char ssid
[MAX_SSID_LEN
];
489 u8 supp_rates
[MAX_RATES_SUPPORTED
+ 1];
496 u8 rsn_pcip_policy
[3];
497 u8 rsn_auth_policy
[3];
499 struct _tstrJoinParam
*nextJoinBss
;
512 /*Bug4218: Parsing Join Param*/
513 /*a linked list table containing needed join parameters entries for each AP found in most recent scan*/
514 typedef struct _tstrBssTable
{
516 tstrJoinBssParam
*head
;
517 tstrJoinBssParam
*tail
;
519 #endif /*WILC_PARSE_SCAN_IN_HOST*/
524 SCAN_CONNECT_TIMER_FORCE_32BIT
= 0xFFFFFFFF
527 /*****************************************************************************/
529 /* Global Variabls */
531 /*****************************************************************************/
532 /* Zero is not used, because a zero ID means termination */
533 static tstrWILC_WFIDrv
*wfidrv_list
[NUM_CONCURRENT_IFC
+ 1];
534 tstrWILC_WFIDrv
*terminated_handle
;
535 tstrWILC_WFIDrv
*gWFiDrvHandle
;
536 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
537 bool g_obtainingIP
= false;
540 static struct task_struct
*HostIFthreadHandler
;
541 static WILC_MsgQueueHandle gMsgQHostIF
;
542 static struct semaphore hSemHostIFthrdEnd
;
544 struct semaphore hSemDeinitDrvHandle
;
545 static struct semaphore hWaitResponse
;
546 struct semaphore hSemHostIntDeinit
;
547 struct timer_list g_hPeriodicRSSI
;
551 u8 gau8MulticastMacAddrList
[WILC_MULTICAST_TABLE_SIZE
][ETH_ALEN
];
553 #ifndef CONNECT_DIRECT
554 static u8 gapu8RcvdSurveyResults
[2][MAX_SURVEY_RESULT_FRAG_SIZE
];
557 static u8 gapu8RcvdAssocResp
[MAX_ASSOC_RESP_FRAME_SIZE
];
559 bool gbScanWhileConnected
= false;
564 static u8 gs8SetIP
[2][4];
565 static u8 gs8GetIP
[2][4];
566 #ifdef WILC_AP_EXTERNAL_MLME
567 static u32 gu32InactiveTime
;
570 static u32 gu32WidConnRstHack
;
573 u8
*gu8FlushedJoinReq
;
574 u8
*gu8FlushedInfoElemAsoc
;
575 u8 gu8Flushed11iMode
;
576 u8 gu8FlushedAuthType
;
577 u32 gu32FlushedJoinReqSize
;
578 u32 gu32FlushedInfoElemAsocSize
;
579 tstrWILC_WFIDrv
*gu8FlushedJoinReqDrvHandler
;
580 #define REAL_JOIN_REQ 0
581 #define FLUSHED_JOIN_REQ 1
582 #define FLUSHED_BYTE_POS 79 /* Position the byte indicating flushing in the flushed request */
584 /*Bug4218: Parsing Join Param*/
585 #ifdef WILC_PARSE_SCAN_IN_HOST
586 /*Bug4218: Parsing Join Param*/
587 static void *host_int_ParseJoinBssParam(tstrNetworkInfo
*ptstrNetworkInfo
);
588 #endif /*WILC_PARSE_SCAN_IN_HOST*/
590 extern void chip_sleep_manually(u32 u32SleepTime
);
591 extern int linux_wlan_get_num_conn_ifcs(void);
593 static int add_handler_in_list(tstrWILC_WFIDrv
*handler
)
597 for (i
= 1; i
< ARRAY_SIZE(wfidrv_list
); i
++) {
598 if (!wfidrv_list
[i
]) {
599 wfidrv_list
[i
] = handler
;
607 static int remove_handler_in_list(tstrWILC_WFIDrv
*handler
)
611 for (i
= 1; i
< ARRAY_SIZE(wfidrv_list
); i
++) {
612 if (wfidrv_list
[i
] == handler
) {
613 wfidrv_list
[i
] = NULL
;
621 static int get_id_from_handler(tstrWILC_WFIDrv
*handler
)
628 for (i
= 1; i
< ARRAY_SIZE(wfidrv_list
); i
++) {
629 if (wfidrv_list
[i
] == handler
)
636 static tstrWILC_WFIDrv
*get_handler_from_id(int id
)
638 if (id
<= 0 || id
>= ARRAY_SIZE(wfidrv_list
))
640 return wfidrv_list
[id
];
644 * @brief Handle_SetChannel
645 * @details Sending config packet to firmware to set channel
646 * @param[in] tstrHostIFSetChan* pstrHostIFSetChan
647 * @return Error code.
652 static s32
Handle_SetChannel(tstrWILC_WFIDrv
*drvHandler
, tstrHostIFSetChan
*pstrHostIFSetChan
)
655 s32 s32Error
= WILC_SUCCESS
;
657 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
659 /*prepare configuration packet*/
660 strWID
.u16WIDid
= (u16
)WID_CURRENT_CHANNEL
;
661 strWID
.enuWIDtype
= WID_CHAR
;
662 strWID
.ps8WidVal
= (char *)&(pstrHostIFSetChan
->u8SetChan
);
663 strWID
.s32ValueSize
= sizeof(char);
665 PRINT_D(HOSTINF_DBG
, "Setting channel\n");
667 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
668 get_id_from_handler(pstrWFIDrv
));
670 PRINT_ER("Failed to set channel\n");
671 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
681 * @brief Handle_SetWfiDrvHandler
682 * @details Sending config packet to firmware to set driver handler
683 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
684 * @return Error code.
689 static s32
Handle_SetWfiDrvHandler(tstrWILC_WFIDrv
*drvHandler
,
690 tstrHostIfSetDrvHandler
*pstrHostIfSetDrvHandler
)
693 s32 s32Error
= WILC_SUCCESS
;
695 tstrWILC_WFIDrv
*pstrWFIDrv
= drvHandler
;
698 /*prepare configuration packet*/
699 strWID
.u16WIDid
= (u16
)WID_SET_DRV_HANDLER
;
700 strWID
.enuWIDtype
= WID_INT
;
701 strWID
.ps8WidVal
= (s8
*)&(pstrHostIfSetDrvHandler
->u32Address
);
702 strWID
.s32ValueSize
= sizeof(u32
);
706 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
707 pstrHostIfSetDrvHandler
->u32Address
);
709 if (pstrWFIDrv
== NULL
)
710 up(&hSemDeinitDrvHandle
);
714 PRINT_ER("Failed to set driver handler\n");
715 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
726 * @brief Handle_SetWfiAPDrvHandler
727 * @details Sending config packet to firmware to set driver handler
728 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
729 * @return Error code.
734 static s32
Handle_SetOperationMode(tstrWILC_WFIDrv
*drvHandler
, tstrHostIfSetOperationMode
*pstrHostIfSetOperationMode
)
737 s32 s32Error
= WILC_SUCCESS
;
739 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
742 /*prepare configuration packet*/
743 strWID
.u16WIDid
= (u16
)WID_SET_OPERATION_MODE
;
744 strWID
.enuWIDtype
= WID_INT
;
745 strWID
.ps8WidVal
= (s8
*)&(pstrHostIfSetOperationMode
->u32Mode
);
746 strWID
.s32ValueSize
= sizeof(u32
);
749 PRINT_INFO(HOSTINF_DBG
, "pstrWFIDrv= %p\n", pstrWFIDrv
);
751 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
752 get_id_from_handler(pstrWFIDrv
));
755 if ((pstrHostIfSetOperationMode
->u32Mode
) == IDLE_MODE
)
756 up(&hSemDeinitDrvHandle
);
760 PRINT_ER("Failed to set driver handler\n");
761 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
772 * @brief host_int_set_IPAddress
773 * @details Setting IP address params in message queue
774 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
775 * @return Error code.
780 s32
Handle_set_IPAddress(tstrWILC_WFIDrv
*drvHandler
, u8
*pu8IPAddr
, u8 idx
)
783 s32 s32Error
= WILC_SUCCESS
;
785 char firmwareIPAddress
[4] = {0};
786 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
788 if (pu8IPAddr
[0] < 192)
791 PRINT_INFO(HOSTINF_DBG
, "Indx = %d, Handling set IP = %pI4\n", idx
, pu8IPAddr
);
793 memcpy(gs8SetIP
[idx
], pu8IPAddr
, IP_ALEN
);
795 /*prepare configuration packet*/
796 strWID
.u16WIDid
= (u16
)WID_IP_ADDRESS
;
797 strWID
.enuWIDtype
= WID_STR
;
798 strWID
.ps8WidVal
= (u8
*)pu8IPAddr
;
799 strWID
.s32ValueSize
= IP_ALEN
;
801 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
802 get_id_from_handler(pstrWFIDrv
));
805 host_int_get_ipaddress(drvHandler
, firmwareIPAddress
, idx
);
808 PRINT_D(HOSTINF_DBG
, "Failed to set IP address\n");
809 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
811 PRINT_INFO(HOSTINF_DBG
, "IP address set\n");
824 * @brief Handle_get_IPAddress
825 * @details Setting IP address params in message queue
826 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
827 * @return Error code.
832 s32
Handle_get_IPAddress(tstrWILC_WFIDrv
*drvHandler
, u8
*pu8IPAddr
, u8 idx
)
835 s32 s32Error
= WILC_SUCCESS
;
837 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
839 /*prepare configuration packet*/
840 strWID
.u16WIDid
= (u16
)WID_IP_ADDRESS
;
841 strWID
.enuWIDtype
= WID_STR
;
842 strWID
.ps8WidVal
= kmalloc(IP_ALEN
, GFP_KERNEL
);
843 strWID
.s32ValueSize
= IP_ALEN
;
845 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true,
846 get_id_from_handler(pstrWFIDrv
));
848 PRINT_INFO(HOSTINF_DBG
, "%pI4\n", strWID
.ps8WidVal
);
850 memcpy(gs8GetIP
[idx
], strWID
.ps8WidVal
, IP_ALEN
);
852 /*get the value by searching the local copy*/
853 kfree(strWID
.ps8WidVal
);
855 if (memcmp(gs8GetIP
[idx
], gs8SetIP
[idx
], IP_ALEN
) != 0)
856 host_int_setup_ipaddress(pstrWFIDrv
, gs8SetIP
[idx
], idx
);
858 if (s32Error
!= WILC_SUCCESS
) {
859 PRINT_ER("Failed to get IP address\n");
860 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
862 PRINT_INFO(HOSTINF_DBG
, "IP address retrieved:: u8IfIdx = %d\n", idx
);
863 PRINT_INFO(HOSTINF_DBG
, "%pI4\n", gs8GetIP
[idx
]);
864 PRINT_INFO(HOSTINF_DBG
, "\n");
878 * @brief Handle_SetMacAddress
879 * @details Setting mac address
880 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
881 * @return Error code.
882 * @author Amr Abdel-Moghny
883 * @date November 2013
886 static s32
Handle_SetMacAddress(tstrWILC_WFIDrv
*drvHandler
, tstrHostIfSetMacAddress
*pstrHostIfSetMacAddress
)
889 s32 s32Error
= WILC_SUCCESS
;
891 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
892 u8
*mac_buf
= kmalloc(ETH_ALEN
, GFP_KERNEL
);
894 if (mac_buf
== NULL
) {
895 PRINT_ER("No buffer to send mac address\n");
898 memcpy(mac_buf
, pstrHostIfSetMacAddress
->u8MacAddress
, ETH_ALEN
);
900 /*prepare configuration packet*/
901 strWID
.u16WIDid
= (u16
)WID_MAC_ADDR
;
902 strWID
.enuWIDtype
= WID_STR
;
903 strWID
.ps8WidVal
= mac_buf
;
904 strWID
.s32ValueSize
= ETH_ALEN
;
905 PRINT_D(GENERIC_DBG
, "mac addr = :%pM\n", strWID
.ps8WidVal
);
907 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
908 get_id_from_handler(pstrWFIDrv
));
910 PRINT_ER("Failed to set mac address\n");
911 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
925 * @brief Handle_GetMacAddress
926 * @details Getting mac address
927 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
928 * @return Error code.
929 * @author Amr Abdel-Moghny
933 static s32
Handle_GetMacAddress(tstrWILC_WFIDrv
*drvHandler
, tstrHostIfGetMacAddress
*pstrHostIfGetMacAddress
)
936 s32 s32Error
= WILC_SUCCESS
;
939 /*prepare configuration packet*/
940 strWID
.u16WIDid
= (u16
)WID_MAC_ADDR
;
941 strWID
.enuWIDtype
= WID_STR
;
942 strWID
.ps8WidVal
= pstrHostIfGetMacAddress
->u8MacAddress
;
943 strWID
.s32ValueSize
= ETH_ALEN
;
946 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, false,
947 get_id_from_handler(drvHandler
));
949 PRINT_ER("Failed to get mac address\n");
950 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
963 * @brief Handle_CfgParam
964 * @details Sending config packet to firmware to set CFG params
965 * @param[in] tstrHostIFCfgParamAttr* strHostIFCfgParamAttr
966 * @return Error code.
971 static s32
Handle_CfgParam(tstrWILC_WFIDrv
*drvHandler
, tstrHostIFCfgParamAttr
*strHostIFCfgParamAttr
)
973 s32 s32Error
= WILC_SUCCESS
;
974 tstrWID strWIDList
[32];
976 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
979 down(&(pstrWFIDrv
->gtOsCfgValuesSem
));
982 PRINT_D(HOSTINF_DBG
, "Setting CFG params\n");
984 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& BSS_TYPE
) {
985 /*----------------------------------------------------------*/
986 /*Input Value: INFRASTRUCTURE = 1, */
987 /* INDEPENDENT= 2, */
989 /*----------------------------------------------------------*/
990 /* validate input then copy>> need to check value 4 and 5 */
991 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.bss_type
< 6) {
992 strWIDList
[u8WidCnt
].u16WIDid
= WID_BSS_TYPE
;
993 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.bss_type
;
994 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
995 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
996 pstrWFIDrv
->strCfgValues
.bss_type
= (u8
)strHostIFCfgParamAttr
->pstrCfgParamVal
.bss_type
;
998 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1002 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& AUTH_TYPE
) {
1003 /*------------------------------------------------------*/
1004 /*Input Values: OPEN_SYSTEM = 0, */
1005 /* SHARED_KEY = 1, */
1007 /*------------------------------------------------------*/
1008 /*validate Possible values*/
1009 if ((strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_type
) == 1 || (strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_type
) == 2 || (strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_type
) == 5) {
1010 strWIDList
[u8WidCnt
].u16WIDid
= WID_AUTH_TYPE
;
1011 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_type
;
1012 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
1013 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
1014 pstrWFIDrv
->strCfgValues
.auth_type
= (u8
)strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_type
;
1016 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1020 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& AUTHEN_TIMEOUT
) {
1021 /* range is 1 to 65535. */
1022 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_timeout
> 0 && strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_timeout
< 65536) {
1023 strWIDList
[u8WidCnt
].u16WIDid
= WID_AUTH_TIMEOUT
;
1024 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_timeout
;
1025 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1026 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1027 pstrWFIDrv
->strCfgValues
.auth_timeout
= strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_timeout
;
1029 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1033 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& POWER_MANAGEMENT
) {
1034 /*-----------------------------------------------------------*/
1035 /*Input Values: NO_POWERSAVE = 0, */
1036 /* MIN_FAST_PS = 1, */
1037 /* MAX_FAST_PS = 2, */
1038 /* MIN_PSPOLL_PS = 3, */
1039 /* MAX_PSPOLL_PS = 4 */
1040 /*----------------------------------------------------------*/
1041 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.power_mgmt_mode
< 5) {
1042 strWIDList
[u8WidCnt
].u16WIDid
= WID_POWER_MANAGEMENT
;
1043 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.power_mgmt_mode
;
1044 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
1045 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
1046 pstrWFIDrv
->strCfgValues
.power_mgmt_mode
= (u8
)strHostIFCfgParamAttr
->pstrCfgParamVal
.power_mgmt_mode
;
1048 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1052 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& RETRY_SHORT
) {
1053 /* range from 1 to 256 */
1054 if ((strHostIFCfgParamAttr
->pstrCfgParamVal
.short_retry_limit
> 0) && (strHostIFCfgParamAttr
->pstrCfgParamVal
.short_retry_limit
< 256)) {
1055 strWIDList
[u8WidCnt
].u16WIDid
= WID_SHORT_RETRY_LIMIT
;
1056 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.short_retry_limit
;
1057 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1058 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1059 pstrWFIDrv
->strCfgValues
.short_retry_limit
= strHostIFCfgParamAttr
->pstrCfgParamVal
.short_retry_limit
;
1061 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1065 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& RETRY_LONG
) {
1066 /* range from 1 to 256 */
1067 if ((strHostIFCfgParamAttr
->pstrCfgParamVal
.long_retry_limit
> 0) && (strHostIFCfgParamAttr
->pstrCfgParamVal
.long_retry_limit
< 256)) {
1068 strWIDList
[u8WidCnt
].u16WIDid
= WID_LONG_RETRY_LIMIT
;
1069 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.long_retry_limit
;
1071 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1072 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1073 pstrWFIDrv
->strCfgValues
.long_retry_limit
= strHostIFCfgParamAttr
->pstrCfgParamVal
.long_retry_limit
;
1075 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1079 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& FRAG_THRESHOLD
) {
1081 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.frag_threshold
> 255 && strHostIFCfgParamAttr
->pstrCfgParamVal
.frag_threshold
< 7937) {
1082 strWIDList
[u8WidCnt
].u16WIDid
= WID_FRAG_THRESHOLD
;
1083 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.frag_threshold
;
1084 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1085 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1086 pstrWFIDrv
->strCfgValues
.frag_threshold
= strHostIFCfgParamAttr
->pstrCfgParamVal
.frag_threshold
;
1088 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1092 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& RTS_THRESHOLD
) {
1093 /* range 256 to 65535 */
1094 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.rts_threshold
> 255 && strHostIFCfgParamAttr
->pstrCfgParamVal
.rts_threshold
< 65536) {
1095 strWIDList
[u8WidCnt
].u16WIDid
= WID_RTS_THRESHOLD
;
1096 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.rts_threshold
;
1097 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1098 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1099 pstrWFIDrv
->strCfgValues
.rts_threshold
= strHostIFCfgParamAttr
->pstrCfgParamVal
.rts_threshold
;
1101 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1105 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& PREAMBLE
) {
1106 /*-----------------------------------------------------*/
1107 /*Input Values: Short= 0, */
1110 /*------------------------------------------------------*/
1111 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.preamble_type
< 3) {
1112 strWIDList
[u8WidCnt
].u16WIDid
= WID_PREAMBLE
;
1113 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.preamble_type
;
1114 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
1115 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
1116 pstrWFIDrv
->strCfgValues
.preamble_type
= strHostIFCfgParamAttr
->pstrCfgParamVal
.preamble_type
;
1118 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1122 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& SHORT_SLOT_ALLOWED
) {
1123 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.short_slot_allowed
< 2) {
1124 strWIDList
[u8WidCnt
].u16WIDid
= WID_SHORT_SLOT_ALLOWED
;
1125 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.short_slot_allowed
;
1126 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
1127 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
1128 pstrWFIDrv
->strCfgValues
.short_slot_allowed
= (u8
)strHostIFCfgParamAttr
->pstrCfgParamVal
.short_slot_allowed
;
1130 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1134 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& TXOP_PROT_DISABLE
) {
1135 /*Description: used to Disable RTS-CTS protection for TXOP burst*/
1136 /*transmission when the acknowledgement policy is No-Ack or Block-Ack */
1137 /* this information is useful for external supplicant */
1138 /*Input Values: 1 for enable and 0 for disable. */
1139 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.txop_prot_disabled
< 2) {
1140 strWIDList
[u8WidCnt
].u16WIDid
= WID_11N_TXOP_PROT_DISABLE
;
1141 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.txop_prot_disabled
;
1142 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
1143 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
1144 pstrWFIDrv
->strCfgValues
.txop_prot_disabled
= (u8
)strHostIFCfgParamAttr
->pstrCfgParamVal
.txop_prot_disabled
;
1146 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1150 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& BEACON_INTERVAL
) {
1151 /* range is 1 to 65535. */
1152 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.beacon_interval
> 0 && strHostIFCfgParamAttr
->pstrCfgParamVal
.beacon_interval
< 65536) {
1153 strWIDList
[u8WidCnt
].u16WIDid
= WID_BEACON_INTERVAL
;
1154 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.beacon_interval
;
1155 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1156 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1157 pstrWFIDrv
->strCfgValues
.beacon_interval
= strHostIFCfgParamAttr
->pstrCfgParamVal
.beacon_interval
;
1159 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1163 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& DTIM_PERIOD
) {
1164 /* range is 1 to 255. */
1165 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.dtim_period
> 0 && strHostIFCfgParamAttr
->pstrCfgParamVal
.dtim_period
< 256) {
1166 strWIDList
[u8WidCnt
].u16WIDid
= WID_DTIM_PERIOD
;
1167 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.dtim_period
;
1168 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
1169 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
1170 pstrWFIDrv
->strCfgValues
.dtim_period
= strHostIFCfgParamAttr
->pstrCfgParamVal
.dtim_period
;
1172 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1176 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& SITE_SURVEY
) {
1177 /*----------------------------------------------------------------------*/
1178 /*Input Values: SITE_SURVEY_1CH = 0, i.e.: currently set channel */
1179 /* SITE_SURVEY_ALL_CH = 1, */
1180 /* SITE_SURVEY_OFF = 2 */
1181 /*----------------------------------------------------------------------*/
1182 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_enabled
< 3) {
1183 strWIDList
[u8WidCnt
].u16WIDid
= WID_SITE_SURVEY
;
1184 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_enabled
;
1185 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
1186 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
1187 pstrWFIDrv
->strCfgValues
.site_survey_enabled
= (u8
)strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_enabled
;
1189 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1193 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& SITE_SURVEY_SCAN_TIME
) {
1194 /* range is 1 to 65535. */
1195 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_scan_time
> 0 && strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_scan_time
< 65536) {
1196 strWIDList
[u8WidCnt
].u16WIDid
= WID_SITE_SURVEY_SCAN_TIME
;
1197 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_scan_time
;
1198 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1199 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1200 pstrWFIDrv
->strCfgValues
.site_survey_scan_time
= strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_scan_time
;
1202 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1206 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& ACTIVE_SCANTIME
) {
1207 /* range is 1 to 65535. */
1208 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.active_scan_time
> 0 && strHostIFCfgParamAttr
->pstrCfgParamVal
.active_scan_time
< 65536) {
1209 strWIDList
[u8WidCnt
].u16WIDid
= WID_ACTIVE_SCAN_TIME
;
1210 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.active_scan_time
;
1211 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1212 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1213 pstrWFIDrv
->strCfgValues
.active_scan_time
= strHostIFCfgParamAttr
->pstrCfgParamVal
.active_scan_time
;
1215 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1219 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& PASSIVE_SCANTIME
) {
1220 /* range is 1 to 65535. */
1221 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.passive_scan_time
> 0 && strHostIFCfgParamAttr
->pstrCfgParamVal
.passive_scan_time
< 65536) {
1222 strWIDList
[u8WidCnt
].u16WIDid
= WID_PASSIVE_SCAN_TIME
;
1223 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.passive_scan_time
;
1224 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1225 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1226 pstrWFIDrv
->strCfgValues
.passive_scan_time
= strHostIFCfgParamAttr
->pstrCfgParamVal
.passive_scan_time
;
1228 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1232 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& CURRENT_TX_RATE
) {
1233 CURRENT_TX_RATE_T curr_tx_rate
= strHostIFCfgParamAttr
->pstrCfgParamVal
.curr_tx_rate
;
1234 /*----------------------------------------------------------------------*/
1235 /*Rates: 1 2 5.5 11 6 9 12 18 24 36 48 54 Auto */
1236 /*InputValues: 1 2 3 4 5 6 7 8 9 10 11 12 0 */
1237 /*----------------------------------------------------------------------*/
1239 if (curr_tx_rate
== AUTORATE
|| curr_tx_rate
== MBPS_1
1240 || curr_tx_rate
== MBPS_2
|| curr_tx_rate
== MBPS_5_5
1241 || curr_tx_rate
== MBPS_11
|| curr_tx_rate
== MBPS_6
1242 || curr_tx_rate
== MBPS_9
|| curr_tx_rate
== MBPS_12
1243 || curr_tx_rate
== MBPS_18
|| curr_tx_rate
== MBPS_24
1244 || curr_tx_rate
== MBPS_36
|| curr_tx_rate
== MBPS_48
|| curr_tx_rate
== MBPS_54
) {
1245 strWIDList
[u8WidCnt
].u16WIDid
= WID_CURRENT_TX_RATE
;
1246 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&curr_tx_rate
;
1247 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1248 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1249 pstrWFIDrv
->strCfgValues
.curr_tx_rate
= (u8
)curr_tx_rate
;
1251 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1255 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, u8WidCnt
, false,
1256 get_id_from_handler(pstrWFIDrv
));
1259 PRINT_ER("Error in setting CFG params\n");
1261 WILC_CATCH(s32Error
)
1264 up(&(pstrWFIDrv
->gtOsCfgValuesSem
));
1270 * @brief Handle_wait_msg_q_empty
1271 * @details this should be the last msg and then the msg Q becomes idle
1272 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1273 * @return Error code.
1278 static s32
Handle_wait_msg_q_empty(void)
1280 s32 s32Error
= WILC_SUCCESS
;
1282 g_wilc_initialized
= 0;
1288 * @brief Handle_Scan
1289 * @details Sending config packet to firmware to set the scan params
1290 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1291 * @return Error code.
1296 static s32
Handle_Scan(tstrWILC_WFIDrv
*drvHandler
, tstrHostIFscanAttr
*pstrHostIFscanAttr
)
1298 s32 s32Error
= WILC_SUCCESS
;
1299 tstrWID strWIDList
[5];
1300 u32 u32WidsCount
= 0;
1304 u8
*pu8HdnNtwrksWidVal
= NULL
;
1305 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*) drvHandler
;
1307 PRINT_D(HOSTINF_DBG
, "Setting SCAN params\n");
1308 PRINT_D(HOSTINF_DBG
, "Scanning: In [%d] state\n", pstrWFIDrv
->enuHostIFstate
);
1310 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
= pstrHostIFscanAttr
->pfScanResult
;
1311 pstrWFIDrv
->strWILC_UsrScanReq
.u32UserScanPvoid
= pstrHostIFscanAttr
->pvUserArg
;
1316 if ((pstrWFIDrv
->enuHostIFstate
>= HOST_IF_SCANNING
) && (pstrWFIDrv
->enuHostIFstate
< HOST_IF_CONNECTED
)) {
1317 /* here we either in HOST_IF_SCANNING, HOST_IF_WAITING_CONN_REQ or HOST_IF_WAITING_CONN_RESP */
1318 PRINT_D(GENERIC_DBG
, "Don't scan we are already in [%d] state\n", pstrWFIDrv
->enuHostIFstate
);
1319 WILC_ERRORREPORT(s32Error
, WILC_BUSY
);
1322 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
1323 if (g_obtainingIP
|| connecting
) {
1324 PRINT_D(GENERIC_DBG
, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
1325 WILC_ERRORREPORT(s32Error
, WILC_BUSY
);
1329 PRINT_D(HOSTINF_DBG
, "Setting SCAN params\n");
1332 pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
= 0;
1335 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_SSID_PROBE_REQ
;
1336 strWIDList
[u32WidsCount
].enuWIDtype
= WID_STR
;
1338 for (i
= 0; i
< pstrHostIFscanAttr
->strHiddenNetwork
.u8ssidnum
; i
++)
1339 valuesize
+= ((pstrHostIFscanAttr
->strHiddenNetwork
.pstrHiddenNetworkInfo
[i
].u8ssidlen
) + 1);
1340 pu8HdnNtwrksWidVal
= kmalloc(valuesize
+ 1, GFP_KERNEL
);
1341 strWIDList
[u32WidsCount
].ps8WidVal
= pu8HdnNtwrksWidVal
;
1342 if (strWIDList
[u32WidsCount
].ps8WidVal
!= NULL
) {
1343 pu8Buffer
= strWIDList
[u32WidsCount
].ps8WidVal
;
1345 *pu8Buffer
++ = pstrHostIFscanAttr
->strHiddenNetwork
.u8ssidnum
;
1347 PRINT_D(HOSTINF_DBG
, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr
->strHiddenNetwork
.u8ssidnum
);
1349 for (i
= 0; i
< pstrHostIFscanAttr
->strHiddenNetwork
.u8ssidnum
; i
++) {
1350 *pu8Buffer
++ = pstrHostIFscanAttr
->strHiddenNetwork
.pstrHiddenNetworkInfo
[i
].u8ssidlen
;
1351 memcpy(pu8Buffer
, pstrHostIFscanAttr
->strHiddenNetwork
.pstrHiddenNetworkInfo
[i
].pu8ssid
, pstrHostIFscanAttr
->strHiddenNetwork
.pstrHiddenNetworkInfo
[i
].u8ssidlen
);
1352 pu8Buffer
+= pstrHostIFscanAttr
->strHiddenNetwork
.pstrHiddenNetworkInfo
[i
].u8ssidlen
;
1357 strWIDList
[u32WidsCount
].s32ValueSize
= (s32
)(valuesize
+ 1);
1361 /*filling cfg param array*/
1363 /* if((pstrHostIFscanAttr->pu8IEs != NULL) && (pstrHostIFscanAttr->IEsLen != 0)) */
1365 /* IEs to be inserted in Probe Request */
1366 strWIDList
[u32WidsCount
].u16WIDid
= WID_INFO_ELEMENT_PROBE
;
1367 strWIDList
[u32WidsCount
].enuWIDtype
= WID_BIN_DATA
;
1368 strWIDList
[u32WidsCount
].ps8WidVal
= pstrHostIFscanAttr
->pu8IEs
;
1369 strWIDList
[u32WidsCount
].s32ValueSize
= pstrHostIFscanAttr
->IEsLen
;
1374 strWIDList
[u32WidsCount
].u16WIDid
= WID_SCAN_TYPE
;
1375 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
1376 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
1377 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrHostIFscanAttr
->u8ScanType
));
1380 /*list of channels to be scanned*/
1381 strWIDList
[u32WidsCount
].u16WIDid
= WID_SCAN_CHANNEL_LIST
;
1382 strWIDList
[u32WidsCount
].enuWIDtype
= WID_BIN_DATA
;
1384 /* Bug 4648: Convert channel numbers to start from 0 not 1. */
1385 if (pstrHostIFscanAttr
->pu8ChnlFreqList
!= NULL
&& pstrHostIFscanAttr
->u8ChnlListLen
> 0) {
1388 for (i
= 0; i
< pstrHostIFscanAttr
->u8ChnlListLen
; i
++) {
1389 if (pstrHostIFscanAttr
->pu8ChnlFreqList
[i
] > 0)
1390 pstrHostIFscanAttr
->pu8ChnlFreqList
[i
] = pstrHostIFscanAttr
->pu8ChnlFreqList
[i
] - 1;
1394 strWIDList
[u32WidsCount
].ps8WidVal
= pstrHostIFscanAttr
->pu8ChnlFreqList
;
1395 strWIDList
[u32WidsCount
].s32ValueSize
= pstrHostIFscanAttr
->u8ChnlListLen
;
1399 strWIDList
[u32WidsCount
].u16WIDid
= WID_START_SCAN_REQ
;
1400 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
1401 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
1402 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrHostIFscanAttr
->u8ScanSource
));
1405 /*keep the state as is , no need to change it*/
1406 /* gWFiDrvHandle->enuHostIFstate = HOST_IF_SCANNING; */
1408 if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_CONNECTED
)
1409 gbScanWhileConnected
= true;
1410 else if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_IDLE
)
1411 gbScanWhileConnected
= false;
1413 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, u32WidsCount
, false,
1414 get_id_from_handler(pstrWFIDrv
));
1417 PRINT_ER("Failed to send scan paramters config packet\n");
1418 WILC_ERRORREPORT(s32Error
, s32Error
);
1420 PRINT_D(HOSTINF_DBG
, "Successfully sent SCAN params config packet\n");
1423 WILC_CATCH(s32Error
)
1425 del_timer(&pstrWFIDrv
->hScanTimer
);
1426 /*if there is an ongoing scan request*/
1427 Handle_ScanDone(drvHandler
, SCAN_EVENT_ABORTED
);
1430 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1431 if (pstrHostIFscanAttr
->pu8ChnlFreqList
!= NULL
) {
1432 kfree(pstrHostIFscanAttr
->pu8ChnlFreqList
);
1433 pstrHostIFscanAttr
->pu8ChnlFreqList
= NULL
;
1436 /* Deallocate pstrHostIFscanAttr->pu8IEs which was previously allocated by the sending thread */
1437 if (pstrHostIFscanAttr
->pu8IEs
!= NULL
) {
1438 kfree(pstrHostIFscanAttr
->pu8IEs
);
1439 pstrHostIFscanAttr
->pu8IEs
= NULL
;
1441 if (pstrHostIFscanAttr
->strHiddenNetwork
.pstrHiddenNetworkInfo
!= NULL
) {
1442 kfree(pstrHostIFscanAttr
->strHiddenNetwork
.pstrHiddenNetworkInfo
);
1443 pstrHostIFscanAttr
->strHiddenNetwork
.pstrHiddenNetworkInfo
= NULL
;
1446 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1447 if (pstrHostIFscanAttr
->pu8ChnlFreqList
!= NULL
) {
1448 kfree(pstrHostIFscanAttr
->pu8ChnlFreqList
);
1449 pstrHostIFscanAttr
->pu8ChnlFreqList
= NULL
;
1452 if (pu8HdnNtwrksWidVal
!= NULL
)
1453 kfree(pu8HdnNtwrksWidVal
);
1459 * @brief Handle_ScanDone
1460 * @details Call scan notification callback function
1462 * @return Error code.
1467 static s32
Handle_ScanDone(tstrWILC_WFIDrv
*drvHandler
, tenuScanEvent enuEvent
)
1469 s32 s32Error
= WILC_SUCCESS
;
1471 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
1474 u8 u8abort_running_scan
;
1478 PRINT_D(HOSTINF_DBG
, "in Handle_ScanDone()\n");
1481 /*Ask FW to abort the running scan, if any*/
1482 if (enuEvent
== SCAN_EVENT_ABORTED
) {
1483 PRINT_D(GENERIC_DBG
, "Abort running scan\n");
1484 u8abort_running_scan
= 1;
1485 strWID
.u16WIDid
= (u16
)WID_ABORT_RUNNING_SCAN
;
1486 strWID
.enuWIDtype
= WID_CHAR
;
1487 strWID
.ps8WidVal
= (s8
*)&u8abort_running_scan
;
1488 strWID
.s32ValueSize
= sizeof(char);
1491 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
1492 get_id_from_handler(pstrWFIDrv
));
1493 if (s32Error
!= WILC_SUCCESS
) {
1494 PRINT_ER("Failed to set abort running scan\n");
1495 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
1497 WILC_CATCH(s32Error
)
1502 if (pstrWFIDrv
== NULL
) {
1503 PRINT_ER("Driver handler is NULL\n");
1507 /*if there is an ongoing scan request*/
1508 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
1509 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult(enuEvent
, NULL
,
1510 pstrWFIDrv
->strWILC_UsrScanReq
.u32UserScanPvoid
, NULL
);
1511 /*delete current scan request*/
1512 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
= NULL
;
1519 * @brief Handle_Connect
1520 * @details Sending config packet to firmware to starting connection
1521 * @param[in] tstrHostIFconnectAttr* pstrHostIFconnectAttr
1522 * @return Error code.
1527 u8 u8ConnectedSSID
[6] = {0};
1528 static s32
Handle_Connect(tstrWILC_WFIDrv
*drvHandler
, tstrHostIFconnectAttr
*pstrHostIFconnectAttr
)
1530 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*) drvHandler
;
1531 s32 s32Error
= WILC_SUCCESS
;
1532 tstrWID strWIDList
[8];
1533 u32 u32WidsCount
= 0, dummyval
= 0;
1534 /* char passphrase[] = "12345678"; */
1535 #ifndef CONNECT_DIRECT
1536 s32 s32Err
= WILC_SUCCESS
;
1538 u8 u8bssDscListIndex
;
1539 wid_site_survey_reslts_s
*pstrSurveyResults
= NULL
;
1541 u8
*pu8CurrByte
= NULL
;
1542 /*Bug4218: Parsing Join Param*/
1543 #ifdef WILC_PARSE_SCAN_IN_HOST
1544 tstrJoinBssParam
*ptstrJoinBssParam
;
1545 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1549 PRINT_D(GENERIC_DBG
, "Handling connect request\n");
1551 #ifndef CONNECT_DIRECT
1552 memset(gapu8RcvdSurveyResults
, 0, sizeof(gapu8RcvdSurveyResults
));
1555 PRINT_D(HOSTINF_DBG
, "Getting site survey results\n");
1556 s32Err
= host_int_get_site_survey_results(pstrWFIDrv
,
1557 gapu8RcvdSurveyResults
,
1558 MAX_SURVEY_RESULT_FRAG_SIZE
);
1560 PRINT_ER("Failed to get site survey results\n");
1561 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
1564 s32Err
= ParseSurveyResults(gapu8RcvdSurveyResults
, &pstrSurveyResults
,
1565 &pstrWFIDrv
->u32SurveyResultsCount
);
1568 if (s32Err
== WILC_SUCCESS
) {
1569 /* use the parsed info in pstrSurveyResults, then deallocate it */
1570 PRINT_D(HOSTINF_DBG
, "Copying site survey results in global structure, then deallocate\n");
1571 for (i
= 0; i
< pstrWFIDrv
->u32SurveyResultsCount
; i
++) {
1572 memcpy(&pstrWFIDrv
->astrSurveyResults
[i
], &pstrSurveyResults
[i
],
1573 sizeof(wid_site_survey_reslts_s
));
1576 DeallocateSurveyResults(pstrSurveyResults
);
1578 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
1579 PRINT_ER("ParseSurveyResults() Error(%d)\n", s32Err
);
1583 for (i
= 0; i
< pstrWFIDrv
->u32SurveyResultsCount
; i
++) {
1584 if (memcmp(pstrWFIDrv
->astrSurveyResults
[i
].SSID
,
1585 pstrHostIFconnectAttr
->pu8ssid
,
1586 pstrHostIFconnectAttr
->ssidLen
) == 0) {
1587 PRINT_INFO(HOSTINF_DBG
, "Network with required SSID is found %s\n", pstrHostIFconnectAttr
->pu8ssid
);
1588 if (pstrHostIFconnectAttr
->pu8bssid
== NULL
) {
1589 /* BSSID is not passed from the user, so decision of matching
1590 * is done by SSID only */
1591 PRINT_INFO(HOSTINF_DBG
, "BSSID is not passed from the user\n");
1594 /* BSSID is also passed from the user, so decision of matching
1595 * should consider also this passed BSSID */
1597 if (memcmp(pstrWFIDrv
->astrSurveyResults
[i
].BSSID
,
1598 pstrHostIFconnectAttr
->pu8bssid
,
1600 PRINT_INFO(HOSTINF_DBG
, "BSSID is passed from the user and matched\n");
1607 if (i
< pstrWFIDrv
->u32SurveyResultsCount
) {
1608 u8bssDscListIndex
= i
;
1610 PRINT_INFO(HOSTINF_DBG
, "Connecting to network of Bss Idx%d and SSID %s and channel%d\n",
1611 u8bssDscListIndex
, pstrWFIDrv
->astrSurveyResults
[u8bssDscListIndex
].SSID
,
1612 pstrWFIDrv
->astrSurveyResults
[u8bssDscListIndex
].Channel
);
1614 PRINT_INFO(HOSTINF_DBG
, "Saving connection parameters in global structure\n");
1616 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
) {
1617 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
= kmalloc(6, GFP_KERNEL
);
1618 memcpy(pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
, pstrHostIFconnectAttr
->pu8bssid
, 6);
1621 pstrWFIDrv
->strWILC_UsrConnReq
.ssidLen
= pstrHostIFconnectAttr
->ssidLen
;
1622 if (pstrHostIFconnectAttr
->pu8ssid
!= NULL
) {
1623 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
= kmalloc(pstrHostIFconnectAttr
->ssidLen
+ 1, GFP_KERNEL
);
1624 memcpy(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
, pstrHostIFconnectAttr
->pu8ssid
,
1625 pstrHostIFconnectAttr
->ssidLen
);
1626 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
[pstrHostIFconnectAttr
->ssidLen
] = '\0';
1629 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
= pstrHostIFconnectAttr
->IEsLen
;
1630 if (pstrHostIFconnectAttr
->pu8IEs
!= NULL
) {
1631 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
= kmalloc(pstrHostIFconnectAttr
->IEsLen
, GFP_KERNEL
);
1632 memcpy(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
, pstrHostIFconnectAttr
->pu8IEs
,
1633 pstrHostIFconnectAttr
->IEsLen
);
1636 pstrWFIDrv
->strWILC_UsrConnReq
.u8security
= pstrHostIFconnectAttr
->u8security
;
1637 pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
= pstrHostIFconnectAttr
->tenuAuth_type
;
1638 pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
= pstrHostIFconnectAttr
->pfConnectResult
;
1639 pstrWFIDrv
->strWILC_UsrConnReq
.u32UserConnectPvoid
= pstrHostIFconnectAttr
->pvUserArg
;
1642 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1643 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1645 /* IEs to be inserted in Association Request */
1646 strWIDList
[u32WidsCount
].u16WIDid
= WID_INFO_ELEMENT_ASSOCIATE
;
1647 strWIDList
[u32WidsCount
].enuWIDtype
= WID_BIN_DATA
;
1648 strWIDList
[u32WidsCount
].ps8WidVal
= pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
;
1649 strWIDList
[u32WidsCount
].s32ValueSize
= pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
;
1652 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_11I_MODE
;
1653 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
1654 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
1655 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrWFIDrv
->strWILC_UsrConnReq
.u8security
));
1658 PRINT_INFO(HOSTINF_DBG
, "Encrypt Mode = %x\n", pstrWFIDrv
->strWILC_UsrConnReq
.u8security
);
1660 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_AUTH_TYPE
;
1661 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
1662 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
1663 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
);
1666 PRINT_INFO(HOSTINF_DBG
, "Authentication Type = %x\n", pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
);
1668 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
1669 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1670 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
1671 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
1675 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_JOIN_REQ
;
1676 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
1677 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
1678 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)&u8bssDscListIndex
;
1681 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1682 * firmware at chip reset when processing the WIDs of the Connect Request.
1683 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1684 /* ////////////////////// */
1685 gu32WidConnRstHack
= 0;
1686 /* ////////////////////// */
1688 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, u32WidsCount
, false,
1689 get_id_from_handler(pstrWFIDrv
));
1691 PRINT_ER("Handle_Connect()] failed to send config packet\n");
1692 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
1694 pstrWFIDrv
->enuHostIFstate
= HOST_IF_WAITING_CONN_RESP
;
1698 PRINT_ER("Required BSSID not found\n");
1699 WILC_ERRORREPORT(s32Error
, WILC_NOT_FOUND
);
1704 /* if we try to connect to an already connected AP then discard the request */
1706 if (memcmp(pstrHostIFconnectAttr
->pu8bssid
, u8ConnectedSSID
, ETH_ALEN
) == 0) {
1708 s32Error
= WILC_SUCCESS
;
1709 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1713 PRINT_INFO(HOSTINF_DBG
, "Saving connection parameters in global structure\n");
1715 /*Bug4218: Parsing Join Param*/
1716 #ifdef WILC_PARSE_SCAN_IN_HOST
1717 ptstrJoinBssParam
= (tstrJoinBssParam
*)pstrHostIFconnectAttr
->pJoinParams
;
1718 if (ptstrJoinBssParam
== NULL
) {
1719 PRINT_ER("Required BSSID not found\n");
1720 WILC_ERRORREPORT(s32Error
, WILC_NOT_FOUND
);
1722 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1724 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
) {
1725 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
= kmalloc(6, GFP_KERNEL
);
1726 memcpy(pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
, pstrHostIFconnectAttr
->pu8bssid
, 6);
1729 pstrWFIDrv
->strWILC_UsrConnReq
.ssidLen
= pstrHostIFconnectAttr
->ssidLen
;
1730 if (pstrHostIFconnectAttr
->pu8ssid
!= NULL
) {
1731 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
= kmalloc(pstrHostIFconnectAttr
->ssidLen
+ 1, GFP_KERNEL
);
1732 memcpy(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
, pstrHostIFconnectAttr
->pu8ssid
,
1733 pstrHostIFconnectAttr
->ssidLen
);
1734 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
[pstrHostIFconnectAttr
->ssidLen
] = '\0';
1737 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
= pstrHostIFconnectAttr
->IEsLen
;
1738 if (pstrHostIFconnectAttr
->pu8IEs
!= NULL
) {
1739 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
= kmalloc(pstrHostIFconnectAttr
->IEsLen
, GFP_KERNEL
);
1740 memcpy(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
, pstrHostIFconnectAttr
->pu8IEs
,
1741 pstrHostIFconnectAttr
->IEsLen
);
1744 pstrWFIDrv
->strWILC_UsrConnReq
.u8security
= pstrHostIFconnectAttr
->u8security
;
1745 pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
= pstrHostIFconnectAttr
->tenuAuth_type
;
1746 pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
= pstrHostIFconnectAttr
->pfConnectResult
;
1747 pstrWFIDrv
->strWILC_UsrConnReq
.u32UserConnectPvoid
= pstrHostIFconnectAttr
->pvUserArg
;
1749 strWIDList
[u32WidsCount
].u16WIDid
= WID_SUCCESS_FRAME_COUNT
;
1750 strWIDList
[u32WidsCount
].enuWIDtype
= WID_INT
;
1751 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(u32
);
1752 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(dummyval
));
1755 strWIDList
[u32WidsCount
].u16WIDid
= WID_RECEIVED_FRAGMENT_COUNT
;
1756 strWIDList
[u32WidsCount
].enuWIDtype
= WID_INT
;
1757 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(u32
);
1758 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(dummyval
));
1761 strWIDList
[u32WidsCount
].u16WIDid
= WID_FAILED_COUNT
;
1762 strWIDList
[u32WidsCount
].enuWIDtype
= WID_INT
;
1763 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(u32
);
1764 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(dummyval
));
1767 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1768 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1770 /* IEs to be inserted in Association Request */
1771 strWIDList
[u32WidsCount
].u16WIDid
= WID_INFO_ELEMENT_ASSOCIATE
;
1772 strWIDList
[u32WidsCount
].enuWIDtype
= WID_BIN_DATA
;
1773 strWIDList
[u32WidsCount
].ps8WidVal
= pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
;
1774 strWIDList
[u32WidsCount
].s32ValueSize
= pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
;
1778 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->pu8ssid
, 7)) {
1780 gu32FlushedInfoElemAsocSize
= pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
;
1781 gu8FlushedInfoElemAsoc
= kmalloc(gu32FlushedInfoElemAsocSize
, GFP_KERNEL
);
1782 memcpy(gu8FlushedInfoElemAsoc
, pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
,
1783 gu32FlushedInfoElemAsocSize
);
1786 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_11I_MODE
;
1787 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
1788 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
1789 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrWFIDrv
->strWILC_UsrConnReq
.u8security
));
1793 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->pu8ssid
, 7))
1794 gu8Flushed11iMode
= pstrWFIDrv
->strWILC_UsrConnReq
.u8security
;
1796 PRINT_INFO(HOSTINF_DBG
, "Encrypt Mode = %x\n", pstrWFIDrv
->strWILC_UsrConnReq
.u8security
);
1799 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_AUTH_TYPE
;
1800 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
1801 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
1802 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
);
1806 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->pu8ssid
, 7))
1807 gu8FlushedAuthType
= (u8
)pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
;
1809 PRINT_INFO(HOSTINF_DBG
, "Authentication Type = %x\n", pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
);
1811 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
1812 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1813 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
1814 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
1818 PRINT_D(HOSTINF_DBG
, "Connecting to network of SSID %s on channel %d\n",
1819 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
, pstrHostIFconnectAttr
->u8channel
);
1822 #ifndef WILC_PARSE_SCAN_IN_HOST
1823 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_JOIN_REQ_EXTENDED
;
1824 strWIDList
[u32WidsCount
].enuWIDtype
= WID_STR
;
1825 strWIDList
[u32WidsCount
].s32ValueSize
= MAX_SSID_LEN
+ 7;
1826 strWIDList
[u32WidsCount
].ps8WidVal
= kmalloc(strWIDList
[u32WidsCount
].s32ValueSize
, GFP_KERNEL
);
1828 if (strWIDList
[u32WidsCount
].ps8WidVal
== NULL
)
1829 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
1831 pu8CurrByte
= strWIDList
[u32WidsCount
].ps8WidVal
;
1833 if (pstrHostIFconnectAttr
->pu8ssid
!= NULL
) {
1834 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->pu8ssid
, pstrHostIFconnectAttr
->ssidLen
);
1835 pu8CurrByte
[pstrHostIFconnectAttr
->ssidLen
] = '\0';
1837 pu8CurrByte
+= MAX_SSID_LEN
;
1838 if ((pstrHostIFconnectAttr
->u8channel
>= 1) && (pstrHostIFconnectAttr
->u8channel
<= 14)) {
1839 *(pu8CurrByte
++) = pstrHostIFconnectAttr
->u8channel
;
1841 PRINT_ER("Channel out of range\n");
1842 *(pu8CurrByte
++) = 0xFF;
1844 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
)
1845 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->pu8bssid
, 6);
1848 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1849 pu8CurrByte
= strWIDList
[u32WidsCount
].ps8WidVal
;
1853 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_JOIN_REQ_EXTENDED
;
1854 strWIDList
[u32WidsCount
].enuWIDtype
= WID_STR
;
1856 /*Sending NoA attributes during connection*/
1857 strWIDList
[u32WidsCount
].s32ValueSize
= 112; /* 79; */
1858 strWIDList
[u32WidsCount
].ps8WidVal
= kmalloc(strWIDList
[u32WidsCount
].s32ValueSize
, GFP_KERNEL
);
1861 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->pu8ssid
, 7)) {
1862 gu32FlushedJoinReqSize
= strWIDList
[u32WidsCount
].s32ValueSize
;
1863 gu8FlushedJoinReq
= kmalloc(gu32FlushedJoinReqSize
, GFP_KERNEL
);
1865 if (strWIDList
[u32WidsCount
].ps8WidVal
== NULL
)
1866 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
1868 pu8CurrByte
= strWIDList
[u32WidsCount
].ps8WidVal
;
1871 if (pstrHostIFconnectAttr
->pu8ssid
!= NULL
) {
1872 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->pu8ssid
, pstrHostIFconnectAttr
->ssidLen
);
1873 pu8CurrByte
[pstrHostIFconnectAttr
->ssidLen
] = '\0';
1875 pu8CurrByte
+= MAX_SSID_LEN
;
1878 *(pu8CurrByte
++) = INFRASTRUCTURE
;
1880 if ((pstrHostIFconnectAttr
->u8channel
>= 1) && (pstrHostIFconnectAttr
->u8channel
<= 14)) {
1881 *(pu8CurrByte
++) = pstrHostIFconnectAttr
->u8channel
;
1883 PRINT_ER("Channel out of range\n");
1884 *(pu8CurrByte
++) = 0xFF;
1887 *(pu8CurrByte
++) = (ptstrJoinBssParam
->cap_info
) & 0xFF;
1888 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->cap_info
) >> 8) & 0xFF;
1889 PRINT_D(HOSTINF_DBG
, "* Cap Info %0x*\n", (*(pu8CurrByte
- 2) | ((*(pu8CurrByte
- 1)) << 8)));
1892 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
)
1893 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->pu8bssid
, 6);
1897 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
)
1898 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->pu8bssid
, 6);
1902 *(pu8CurrByte
++) = (ptstrJoinBssParam
->beacon_period
) & 0xFF;
1903 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->beacon_period
) >> 8) & 0xFF;
1904 PRINT_D(HOSTINF_DBG
, "* Beacon Period %d*\n", (*(pu8CurrByte
- 2) | ((*(pu8CurrByte
- 1)) << 8)));
1906 *(pu8CurrByte
++) = ptstrJoinBssParam
->dtim_period
;
1907 PRINT_D(HOSTINF_DBG
, "* DTIM Period %d*\n", (*(pu8CurrByte
- 1)));
1908 /* Supported rates*/
1909 memcpy(pu8CurrByte
, ptstrJoinBssParam
->supp_rates
, MAX_RATES_SUPPORTED
+ 1);
1910 pu8CurrByte
+= (MAX_RATES_SUPPORTED
+ 1);
1913 *(pu8CurrByte
++) = ptstrJoinBssParam
->wmm_cap
;
1914 PRINT_D(HOSTINF_DBG
, "* wmm cap%d*\n", (*(pu8CurrByte
- 1)));
1916 *(pu8CurrByte
++) = ptstrJoinBssParam
->uapsd_cap
;
1919 *(pu8CurrByte
++) = ptstrJoinBssParam
->ht_capable
;
1920 /* copy this information to the user request */
1921 pstrWFIDrv
->strWILC_UsrConnReq
.IsHTCapable
= ptstrJoinBssParam
->ht_capable
;
1924 *(pu8CurrByte
++) = ptstrJoinBssParam
->rsn_found
;
1925 PRINT_D(HOSTINF_DBG
, "* rsn found %d*\n", *(pu8CurrByte
- 1));
1926 /* rsn group policy*/
1927 *(pu8CurrByte
++) = ptstrJoinBssParam
->rsn_grp_policy
;
1928 PRINT_D(HOSTINF_DBG
, "* rsn group policy %0x*\n", (*(pu8CurrByte
- 1)));
1930 *(pu8CurrByte
++) = ptstrJoinBssParam
->mode_802_11i
;
1931 PRINT_D(HOSTINF_DBG
, "* mode_802_11i %d*\n", (*(pu8CurrByte
- 1)));
1932 /* rsn pcip policy*/
1933 memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_pcip_policy
, sizeof(ptstrJoinBssParam
->rsn_pcip_policy
));
1934 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_pcip_policy
);
1936 /* rsn auth policy*/
1937 memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_auth_policy
, sizeof(ptstrJoinBssParam
->rsn_auth_policy
));
1938 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_auth_policy
);
1940 /* rsn auth policy*/
1941 memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_cap
, sizeof(ptstrJoinBssParam
->rsn_cap
));
1942 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_cap
);
1945 *(pu8CurrByte
++) = REAL_JOIN_REQ
;
1948 *(pu8CurrByte
++) = ptstrJoinBssParam
->u8NoaEnbaled
;
1949 if (ptstrJoinBssParam
->u8NoaEnbaled
) {
1950 PRINT_D(HOSTINF_DBG
, "NOA present\n");
1952 *(pu8CurrByte
++) = (ptstrJoinBssParam
->tsf
) & 0xFF;
1953 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 8) & 0xFF;
1954 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 16) & 0xFF;
1955 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 24) & 0xFF;
1957 *(pu8CurrByte
++) = ptstrJoinBssParam
->u8Index
;
1959 *(pu8CurrByte
++) = ptstrJoinBssParam
->u8OppEnable
;
1961 if (ptstrJoinBssParam
->u8OppEnable
)
1962 *(pu8CurrByte
++) = ptstrJoinBssParam
->u8CtWindow
;
1964 *(pu8CurrByte
++) = ptstrJoinBssParam
->u8Count
;
1966 memcpy(pu8CurrByte
, ptstrJoinBssParam
->au8Duration
, sizeof(ptstrJoinBssParam
->au8Duration
));
1968 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->au8Duration
);
1970 memcpy(pu8CurrByte
, ptstrJoinBssParam
->au8Interval
, sizeof(ptstrJoinBssParam
->au8Interval
));
1972 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->au8Interval
);
1974 memcpy(pu8CurrByte
, ptstrJoinBssParam
->au8StartTime
, sizeof(ptstrJoinBssParam
->au8StartTime
));
1976 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->au8StartTime
);
1979 PRINT_D(HOSTINF_DBG
, "NOA not present\n");
1983 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1984 pu8CurrByte
= strWIDList
[u32WidsCount
].ps8WidVal
;
1987 #endif /* #ifdef WILC_PARSE_SCAN_IN_HOST*/
1990 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1991 * firmware at chip reset when processing the WIDs of the Connect Request.
1992 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1993 /* ////////////////////// */
1994 gu32WidConnRstHack
= 0;
1995 /* ////////////////////// */
1998 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->pu8ssid
, 7)) {
1999 memcpy(gu8FlushedJoinReq
, pu8CurrByte
, gu32FlushedJoinReqSize
);
2000 gu8FlushedJoinReqDrvHandler
= pstrWFIDrv
;
2003 PRINT_D(GENERIC_DBG
, "send HOST_IF_WAITING_CONN_RESP\n");
2005 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
) {
2006 memcpy(u8ConnectedSSID
, pstrHostIFconnectAttr
->pu8bssid
, ETH_ALEN
);
2008 PRINT_D(GENERIC_DBG
, "save Bssid = %pM\n", pstrHostIFconnectAttr
->pu8bssid
);
2009 PRINT_D(GENERIC_DBG
, "save bssid = %pM\n", u8ConnectedSSID
);
2012 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, u32WidsCount
, false,
2013 get_id_from_handler(pstrWFIDrv
));
2015 PRINT_ER("Handle_Connect()] failed to send config packet\n");
2016 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
2018 PRINT_D(GENERIC_DBG
, "set HOST_IF_WAITING_CONN_RESP\n");
2019 pstrWFIDrv
->enuHostIFstate
= HOST_IF_WAITING_CONN_RESP
;
2023 WILC_CATCH(s32Error
)
2025 tstrConnectInfo strConnectInfo
;
2027 del_timer(&pstrWFIDrv
->hConnectTimer
);
2029 PRINT_D(HOSTINF_DBG
, "could not start connecting to the required network\n");
2031 memset(&strConnectInfo
, 0, sizeof(tstrConnectInfo
));
2033 if (pstrHostIFconnectAttr
->pfConnectResult
!= NULL
) {
2034 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
)
2035 memcpy(strConnectInfo
.au8bssid
, pstrHostIFconnectAttr
->pu8bssid
, 6);
2037 if (pstrHostIFconnectAttr
->pu8IEs
!= NULL
) {
2038 strConnectInfo
.ReqIEsLen
= pstrHostIFconnectAttr
->IEsLen
;
2039 strConnectInfo
.pu8ReqIEs
= kmalloc(pstrHostIFconnectAttr
->IEsLen
, GFP_KERNEL
);
2040 memcpy(strConnectInfo
.pu8ReqIEs
,
2041 pstrHostIFconnectAttr
->pu8IEs
,
2042 pstrHostIFconnectAttr
->IEsLen
);
2045 pstrHostIFconnectAttr
->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP
,
2049 pstrHostIFconnectAttr
->pvUserArg
);
2050 /*Change state to idle*/
2051 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
2053 if (strConnectInfo
.pu8ReqIEs
!= NULL
) {
2054 kfree(strConnectInfo
.pu8ReqIEs
);
2055 strConnectInfo
.pu8ReqIEs
= NULL
;
2059 PRINT_ER("Connect callback function pointer is NULL\n");
2063 PRINT_D(HOSTINF_DBG
, "Deallocating connection parameters\n");
2064 /* Deallocate pstrHostIFconnectAttr->pu8bssid which was prevoisuly allocated by the sending thread */
2065 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
) {
2066 kfree(pstrHostIFconnectAttr
->pu8bssid
);
2067 pstrHostIFconnectAttr
->pu8bssid
= NULL
;
2070 /* Deallocate pstrHostIFconnectAttr->pu8ssid which was prevoisuly allocated by the sending thread */
2071 if (pstrHostIFconnectAttr
->pu8ssid
!= NULL
) {
2072 kfree(pstrHostIFconnectAttr
->pu8ssid
);
2073 pstrHostIFconnectAttr
->pu8ssid
= NULL
;
2076 /* Deallocate pstrHostIFconnectAttr->pu8IEs which was prevoisuly allocated by the sending thread */
2077 if (pstrHostIFconnectAttr
->pu8IEs
!= NULL
) {
2078 kfree(pstrHostIFconnectAttr
->pu8IEs
);
2079 pstrHostIFconnectAttr
->pu8IEs
= NULL
;
2082 if (pu8CurrByte
!= NULL
)
2088 * @brief Handle_FlushConnect
2089 * @details Sending config packet to firmware to flush an old connection
2090 * after switching FW from station one to hybrid one
2091 * @param[in] void * drvHandler
2092 * @return Error code.
2093 * @author Amr Abdel-Moghny
2098 static s32
Handle_FlushConnect(tstrWILC_WFIDrv
*drvHandler
)
2100 s32 s32Error
= WILC_SUCCESS
;
2101 tstrWID strWIDList
[5];
2102 u32 u32WidsCount
= 0;
2103 u8
*pu8CurrByte
= NULL
;
2106 /* IEs to be inserted in Association Request */
2107 strWIDList
[u32WidsCount
].u16WIDid
= WID_INFO_ELEMENT_ASSOCIATE
;
2108 strWIDList
[u32WidsCount
].enuWIDtype
= WID_BIN_DATA
;
2109 strWIDList
[u32WidsCount
].ps8WidVal
= gu8FlushedInfoElemAsoc
;
2110 strWIDList
[u32WidsCount
].s32ValueSize
= gu32FlushedInfoElemAsocSize
;
2113 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_11I_MODE
;
2114 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
2115 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
2116 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(gu8Flushed11iMode
));
2121 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_AUTH_TYPE
;
2122 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
2123 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
2124 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&gu8FlushedAuthType
);
2128 #ifdef WILC_PARSE_SCAN_IN_HOST
2129 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_JOIN_REQ_EXTENDED
;
2130 strWIDList
[u32WidsCount
].enuWIDtype
= WID_STR
;
2131 strWIDList
[u32WidsCount
].s32ValueSize
= gu32FlushedJoinReqSize
;
2132 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)gu8FlushedJoinReq
;
2133 pu8CurrByte
= strWIDList
[u32WidsCount
].ps8WidVal
;
2135 pu8CurrByte
+= FLUSHED_BYTE_POS
;
2136 *(pu8CurrByte
) = FLUSHED_JOIN_REQ
;
2142 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, u32WidsCount
, false,
2143 get_id_from_handler(gu8FlushedJoinReqDrvHandler
));
2145 PRINT_ER("Handle_Flush_Connect()] failed to send config packet\n");
2146 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
2149 WILC_CATCH(s32Error
)
2158 * @brief Handle_ConnectTimeout
2159 * @details Call connect notification callback function indicating connection failure
2161 * @return Error code.
2166 static s32
Handle_ConnectTimeout(tstrWILC_WFIDrv
*drvHandler
)
2168 s32 s32Error
= WILC_SUCCESS
;
2169 tstrConnectInfo strConnectInfo
;
2171 u16 u16DummyReasonCode
= 0;
2172 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*) drvHandler
;
2174 if (pstrWFIDrv
== NULL
) {
2175 PRINT_ER("Driver handler is NULL\n");
2179 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
2181 gbScanWhileConnected
= false;
2184 memset(&strConnectInfo
, 0, sizeof(tstrConnectInfo
));
2187 /* First, we will notify the upper layer with the Connection failure {through the Connect Callback function},
2188 * then we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2189 * WID_DISCONNECT} */
2190 if (pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
!= NULL
) {
2191 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
!= NULL
) {
2192 memcpy(strConnectInfo
.au8bssid
,
2193 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
, 6);
2196 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
!= NULL
) {
2197 strConnectInfo
.ReqIEsLen
= pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
;
2198 strConnectInfo
.pu8ReqIEs
= kmalloc(pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
, GFP_KERNEL
);
2199 memcpy(strConnectInfo
.pu8ReqIEs
,
2200 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
,
2201 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
);
2204 pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP
,
2208 pstrWFIDrv
->strWILC_UsrConnReq
.u32UserConnectPvoid
);
2210 /* Deallocation of strConnectInfo.pu8ReqIEs */
2211 if (strConnectInfo
.pu8ReqIEs
!= NULL
) {
2212 kfree(strConnectInfo
.pu8ReqIEs
);
2213 strConnectInfo
.pu8ReqIEs
= NULL
;
2216 PRINT_ER("Connect callback function pointer is NULL\n");
2219 /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2220 * WID_DISCONNECT} */
2221 strWID
.u16WIDid
= (u16
)WID_DISCONNECT
;
2222 strWID
.enuWIDtype
= WID_CHAR
;
2223 strWID
.ps8WidVal
= (s8
*)&u16DummyReasonCode
;
2224 strWID
.s32ValueSize
= sizeof(char);
2226 PRINT_D(HOSTINF_DBG
, "Sending disconnect request\n");
2228 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false,
2229 get_id_from_handler(pstrWFIDrv
));
2231 PRINT_ER("Failed to send dissconect config packet\n");
2233 /* Deallocation of the Saved Connect Request in the global Handle */
2234 pstrWFIDrv
->strWILC_UsrConnReq
.ssidLen
= 0;
2235 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
!= NULL
) {
2236 kfree(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
);
2237 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
= NULL
;
2240 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
!= NULL
) {
2241 kfree(pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
);
2242 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
= NULL
;
2245 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
= 0;
2246 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
!= NULL
) {
2247 kfree(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
);
2248 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
= NULL
;
2251 memset(u8ConnectedSSID
, 0, ETH_ALEN
);
2253 /*Freeing flushed join request params on connect timeout*/
2254 if (gu8FlushedJoinReq
!= NULL
&& gu8FlushedJoinReqDrvHandler
== drvHandler
) {
2255 kfree(gu8FlushedJoinReq
);
2256 gu8FlushedJoinReq
= NULL
;
2258 if (gu8FlushedInfoElemAsoc
!= NULL
&& gu8FlushedJoinReqDrvHandler
== drvHandler
) {
2259 kfree(gu8FlushedInfoElemAsoc
);
2260 gu8FlushedInfoElemAsoc
= NULL
;
2267 * @brief Handle_RcvdNtwrkInfo
2268 * @details Handling received network information
2269 * @param[in] tstrRcvdNetworkInfo* pstrRcvdNetworkInfo
2270 * @return Error code.
2275 static s32
Handle_RcvdNtwrkInfo(tstrWILC_WFIDrv
*drvHandler
, tstrRcvdNetworkInfo
*pstrRcvdNetworkInfo
)
2278 bool bNewNtwrkFound
;
2282 s32 s32Error
= WILC_SUCCESS
;
2283 tstrNetworkInfo
*pstrNetworkInfo
= NULL
;
2284 void *pJoinParams
= NULL
;
2286 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
2290 bNewNtwrkFound
= true;
2291 PRINT_INFO(HOSTINF_DBG
, "Handling received network info\n");
2293 /*if there is a an ongoing scan request*/
2294 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
2295 PRINT_D(HOSTINF_DBG
, "State: Scanning, parsing network information received\n");
2296 ParseNetworkInfo(pstrRcvdNetworkInfo
->pu8Buffer
, &pstrNetworkInfo
);
2297 if ((pstrNetworkInfo
== NULL
)
2298 || (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
== NULL
)) {
2299 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
2302 /* check whether this network is discovered before */
2303 for (i
= 0; i
< pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
; i
++) {
2305 if ((pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[i
].au8bssid
!= NULL
) &&
2306 (pstrNetworkInfo
->au8bssid
!= NULL
)) {
2307 if (memcmp(pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[i
].au8bssid
,
2308 pstrNetworkInfo
->au8bssid
, 6) == 0) {
2309 if (pstrNetworkInfo
->s8rssi
<= pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[i
].s8rssi
) {
2310 /*we have already found this network with better rssi, so keep the old cached one and don't
2311 * send anything to the upper layer */
2312 PRINT_D(HOSTINF_DBG
, "Network previously discovered\n");
2315 /* here the same already found network is found again but with a better rssi, so just update
2316 * the rssi for this cached network and send this updated network to the upper layer but
2317 * don't add a new record for it */
2318 pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[i
].s8rssi
= pstrNetworkInfo
->s8rssi
;
2319 bNewNtwrkFound
= false;
2326 if (bNewNtwrkFound
== true) {
2327 /* here it is confirmed that it is a new discovered network,
2328 * so add its record then call the User CallBack function */
2330 PRINT_D(HOSTINF_DBG
, "New network found\n");
2332 if (pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
< MAX_NUM_SCANNED_NETWORKS
) {
2333 pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
].s8rssi
= pstrNetworkInfo
->s8rssi
;
2335 if ((pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
].au8bssid
!= NULL
)
2336 && (pstrNetworkInfo
->au8bssid
!= NULL
)) {
2337 memcpy(pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
].au8bssid
,
2338 pstrNetworkInfo
->au8bssid
, 6);
2340 pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
++;
2342 pstrNetworkInfo
->bNewNetwork
= true;
2343 /*Bug4218: Parsing Join Param*/
2344 /* add new BSS to JoinBssTable */
2345 #ifdef WILC_PARSE_SCAN_IN_HOST
2346 pJoinParams
= host_int_ParseJoinBssParam(pstrNetworkInfo
);
2347 #endif /*WILC_PARSE_SCAN_IN_HOST*/
2349 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND
, pstrNetworkInfo
,
2350 pstrWFIDrv
->strWILC_UsrScanReq
.u32UserScanPvoid
,
2356 PRINT_WRN(HOSTINF_DBG
, "Discovered networks exceeded max. limit\n");
2359 pstrNetworkInfo
->bNewNetwork
= false;
2360 /* just call the User CallBack function to send the same discovered network with its updated RSSI */
2361 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND
, pstrNetworkInfo
,
2362 pstrWFIDrv
->strWILC_UsrScanReq
.u32UserScanPvoid
, NULL
);
2367 WILC_CATCH(s32Error
)
2373 /* Deallocate pstrRcvdNetworkInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2374 if (pstrRcvdNetworkInfo
->pu8Buffer
!= NULL
) {
2375 kfree(pstrRcvdNetworkInfo
->pu8Buffer
);
2376 pstrRcvdNetworkInfo
->pu8Buffer
= NULL
;
2379 /*free structure allocated*/
2380 if (pstrNetworkInfo
!= NULL
) {
2381 DeallocateNetworkInfo(pstrNetworkInfo
);
2382 pstrNetworkInfo
= NULL
;
2389 * @brief Handle_RcvdGnrlAsyncInfo
2390 * @details Handling received asynchrous general network information
2391 * @param[in] tstrRcvdGnrlAsyncInfo* pstrRcvdGnrlAsyncInfo
2392 * @return Error code.
2397 static s32
Handle_RcvdGnrlAsyncInfo(tstrWILC_WFIDrv
*drvHandler
, tstrRcvdGnrlAsyncInfo
*pstrRcvdGnrlAsyncInfo
)
2399 /* TODO: mostafa: till now, this function just handles only the received mac status msg, */
2400 /* which carries only 1 WID which have WID ID = WID_STATUS */
2401 s32 s32Error
= WILC_SUCCESS
;
2405 u16 u16WidID
= (u16
)WID_NIL
;
2408 u8 u8MacStatusReasonCode
;
2409 u8 u8MacStatusAdditionalInfo
;
2410 tstrConnectInfo strConnectInfo
;
2411 tstrDisconnectNotifInfo strDisconnectNotifInfo
;
2412 s32 s32Err
= WILC_SUCCESS
;
2413 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*) drvHandler
;
2415 if (pstrWFIDrv
== NULL
)
2416 PRINT_ER("Driver handler is NULL\n");
2417 PRINT_D(GENERIC_DBG
, "Current State = %d,Received state = %d\n", pstrWFIDrv
->enuHostIFstate
,
2418 pstrRcvdGnrlAsyncInfo
->pu8Buffer
[7]);
2420 if ((pstrWFIDrv
->enuHostIFstate
== HOST_IF_WAITING_CONN_RESP
) ||
2421 (pstrWFIDrv
->enuHostIFstate
== HOST_IF_CONNECTED
) ||
2422 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
2423 if ((pstrRcvdGnrlAsyncInfo
->pu8Buffer
== NULL
) ||
2424 (pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
== NULL
)) {
2425 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
2428 u8MsgType
= pstrRcvdGnrlAsyncInfo
->pu8Buffer
[0];
2430 /* Check whether the received message type is 'I' */
2431 if ('I' != u8MsgType
) {
2432 PRINT_ER("Received Message format incorrect.\n");
2433 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
2436 /* Extract message ID */
2437 u8MsgID
= pstrRcvdGnrlAsyncInfo
->pu8Buffer
[1];
2439 /* Extract message Length */
2440 u16MsgLen
= MAKE_WORD16(pstrRcvdGnrlAsyncInfo
->pu8Buffer
[2], pstrRcvdGnrlAsyncInfo
->pu8Buffer
[3]);
2442 /* Extract WID ID [expected to be = WID_STATUS] */
2443 u16WidID
= MAKE_WORD16(pstrRcvdGnrlAsyncInfo
->pu8Buffer
[4], pstrRcvdGnrlAsyncInfo
->pu8Buffer
[5]);
2445 /* Extract WID Length [expected to be = 1] */
2446 u8WidLen
= pstrRcvdGnrlAsyncInfo
->pu8Buffer
[6];
2448 /* get the WID value [expected to be one of two values: either MAC_CONNECTED = (1) or MAC_DISCONNECTED = (0)] */
2449 u8MacStatus
= pstrRcvdGnrlAsyncInfo
->pu8Buffer
[7];
2450 u8MacStatusReasonCode
= pstrRcvdGnrlAsyncInfo
->pu8Buffer
[8];
2451 u8MacStatusAdditionalInfo
= pstrRcvdGnrlAsyncInfo
->pu8Buffer
[9];
2452 PRINT_INFO(HOSTINF_DBG
, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus
, u8MacStatusReasonCode
, u8MacStatusAdditionalInfo
);
2453 if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_WAITING_CONN_RESP
) {
2454 /* our station had sent Association Request frame, so here it will get the Association Response frame then parse it */
2455 u32 u32RcvdAssocRespInfoLen
;
2456 tstrConnectRespInfo
*pstrConnectRespInfo
= NULL
;
2458 PRINT_D(HOSTINF_DBG
, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus
, u8MacStatusReasonCode
, u8MacStatusAdditionalInfo
);
2460 memset(&strConnectInfo
, 0, sizeof(tstrConnectInfo
));
2462 if (u8MacStatus
== MAC_CONNECTED
) {
2463 memset(gapu8RcvdAssocResp
, 0, MAX_ASSOC_RESP_FRAME_SIZE
);
2465 host_int_get_assoc_res_info(pstrWFIDrv
,
2467 MAX_ASSOC_RESP_FRAME_SIZE
,
2468 &u32RcvdAssocRespInfoLen
);
2470 PRINT_INFO(HOSTINF_DBG
, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen
);
2472 if (u32RcvdAssocRespInfoLen
!= 0) {
2474 PRINT_D(HOSTINF_DBG
, "Parsing association response\n");
2475 s32Err
= ParseAssocRespInfo(gapu8RcvdAssocResp
, u32RcvdAssocRespInfoLen
,
2476 &pstrConnectRespInfo
);
2478 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err
);
2480 /* use the necessary parsed Info from the Received Association Response */
2481 strConnectInfo
.u16ConnectStatus
= pstrConnectRespInfo
->u16ConnectStatus
;
2483 if (strConnectInfo
.u16ConnectStatus
== SUCCESSFUL_STATUSCODE
) {
2484 PRINT_INFO(HOSTINF_DBG
, "Association response received : Successful connection status\n");
2485 if (pstrConnectRespInfo
->pu8RespIEs
!= NULL
) {
2486 strConnectInfo
.u16RespIEsLen
= pstrConnectRespInfo
->u16RespIEsLen
;
2489 strConnectInfo
.pu8RespIEs
= kmalloc(pstrConnectRespInfo
->u16RespIEsLen
, GFP_KERNEL
);
2490 memcpy(strConnectInfo
.pu8RespIEs
, pstrConnectRespInfo
->pu8RespIEs
,
2491 pstrConnectRespInfo
->u16RespIEsLen
);
2495 /* deallocate the Assoc. Resp. parsed structure as it is not needed anymore */
2496 if (pstrConnectRespInfo
!= NULL
) {
2497 DeallocateAssocRespInfo(pstrConnectRespInfo
);
2498 pstrConnectRespInfo
= NULL
;
2504 /* The station has just received mac status and it also received assoc. response which
2505 * it was waiting for.
2506 * So check first the matching between the received mac status and the received status code in Asoc Resp */
2507 if ((u8MacStatus
== MAC_CONNECTED
) &&
2508 (strConnectInfo
.u16ConnectStatus
!= SUCCESSFUL_STATUSCODE
)) {
2509 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
2510 memset(u8ConnectedSSID
, 0, ETH_ALEN
);
2512 } else if (u8MacStatus
== MAC_DISCONNECTED
) {
2513 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
2514 memset(u8ConnectedSSID
, 0, ETH_ALEN
);
2517 /* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */
2518 /* through a structure of type tstrConnectRespInfo */
2519 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
!= NULL
) {
2520 PRINT_D(HOSTINF_DBG
, "Retrieving actual BSSID from AP\n");
2521 memcpy(strConnectInfo
.au8bssid
, pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
, 6);
2523 if ((u8MacStatus
== MAC_CONNECTED
) &&
2524 (strConnectInfo
.u16ConnectStatus
== SUCCESSFUL_STATUSCODE
)) {
2525 memcpy(pstrWFIDrv
->au8AssociatedBSSID
,
2526 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
, ETH_ALEN
);
2531 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
!= NULL
) {
2532 strConnectInfo
.ReqIEsLen
= pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
;
2533 strConnectInfo
.pu8ReqIEs
= kmalloc(pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
, GFP_KERNEL
);
2534 memcpy(strConnectInfo
.pu8ReqIEs
,
2535 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
,
2536 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
);
2540 del_timer(&pstrWFIDrv
->hConnectTimer
);
2541 pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP
,
2545 pstrWFIDrv
->strWILC_UsrConnReq
.u32UserConnectPvoid
);
2548 /* if received mac status is MAC_CONNECTED and
2549 * received status code in Asoc Resp is SUCCESSFUL_STATUSCODE, change state to CONNECTED
2550 * else change state to IDLE */
2551 if ((u8MacStatus
== MAC_CONNECTED
) &&
2552 (strConnectInfo
.u16ConnectStatus
== SUCCESSFUL_STATUSCODE
)) {
2553 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2555 host_int_set_power_mgmt(pstrWFIDrv
, 0, 0);
2558 PRINT_D(HOSTINF_DBG
, "MAC status : CONNECTED and Connect Status : Successful\n");
2559 pstrWFIDrv
->enuHostIFstate
= HOST_IF_CONNECTED
;
2561 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2562 PRINT_D(GENERIC_DBG
, "Obtaining an IP, Disable Scan\n");
2563 g_obtainingIP
= true;
2564 mod_timer(&hDuringIpTimer
,
2565 jiffies
+ msecs_to_jiffies(10000));
2568 #ifdef WILC_PARSE_SCAN_IN_HOST
2569 /* open a BA session if possible */
2570 /* if(pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable) */
2574 /* host_int_addBASession(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid,0, */
2575 /* BA_SESSION_DEFAULT_BUFFER_SIZE,BA_SESSION_DEFAULT_TIMEOUT); */
2577 PRINT_D(HOSTINF_DBG
, "MAC status : %d and Connect Status : %d\n", u8MacStatus
, strConnectInfo
.u16ConnectStatus
);
2578 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
2579 gbScanWhileConnected
= false;
2583 if (strConnectInfo
.pu8RespIEs
!= NULL
) {
2584 kfree(strConnectInfo
.pu8RespIEs
);
2585 strConnectInfo
.pu8RespIEs
= NULL
;
2588 if (strConnectInfo
.pu8ReqIEs
!= NULL
) {
2589 kfree(strConnectInfo
.pu8ReqIEs
);
2590 strConnectInfo
.pu8ReqIEs
= NULL
;
2594 pstrWFIDrv
->strWILC_UsrConnReq
.ssidLen
= 0;
2595 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
!= NULL
) {
2596 kfree(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
);
2597 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
= NULL
;
2600 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
!= NULL
) {
2601 kfree(pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
);
2602 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
= NULL
;
2605 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
= 0;
2606 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
!= NULL
) {
2607 kfree(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
);
2608 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
= NULL
;
2611 } else if ((u8MacStatus
== MAC_DISCONNECTED
) &&
2612 (pstrWFIDrv
->enuHostIFstate
== HOST_IF_CONNECTED
)) {
2613 /* Disassociation or Deauthentication frame has been received */
2614 PRINT_D(HOSTINF_DBG
, "Received MAC_DISCONNECTED from the FW\n");
2616 memset(&strDisconnectNotifInfo
, 0, sizeof(tstrDisconnectNotifInfo
));
2618 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
2619 PRINT_D(HOSTINF_DBG
, "\n\n<< Abort the running OBSS Scan >>\n\n");
2620 del_timer(&pstrWFIDrv
->hScanTimer
);
2621 Handle_ScanDone((void *)pstrWFIDrv
, SCAN_EVENT_ABORTED
);
2624 strDisconnectNotifInfo
.u16reason
= 0;
2625 strDisconnectNotifInfo
.ie
= NULL
;
2626 strDisconnectNotifInfo
.ie_len
= 0;
2628 if (pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
!= NULL
) {
2629 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2631 g_obtainingIP
= false;
2632 host_int_set_power_mgmt(pstrWFIDrv
, 0, 0);
2635 pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF
,
2638 &strDisconnectNotifInfo
,
2639 pstrWFIDrv
->strWILC_UsrConnReq
.u32UserConnectPvoid
);
2642 PRINT_ER("Connect result callback function is NULL\n");
2645 memset(pstrWFIDrv
->au8AssociatedBSSID
, 0, ETH_ALEN
);
2650 /* if Information Elements were retrieved from the Received deauth/disassoc frame, then they
2651 * should be deallocated here */
2653 * if(strDisconnectNotifInfo.ie != NULL)
2655 * kfree(strDisconnectNotifInfo.ie);
2656 * strDisconnectNotifInfo.ie = NULL;
2660 pstrWFIDrv
->strWILC_UsrConnReq
.ssidLen
= 0;
2661 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
!= NULL
) {
2662 kfree(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
);
2663 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
= NULL
;
2666 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
!= NULL
) {
2667 kfree(pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
);
2668 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
= NULL
;
2671 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
= 0;
2672 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
!= NULL
) {
2673 kfree(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
);
2674 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
= NULL
;
2678 /*Freeing flushed join request params on receiving*/
2679 /*MAC_DISCONNECTED while connected*/
2680 if (gu8FlushedJoinReq
!= NULL
&& gu8FlushedJoinReqDrvHandler
== drvHandler
) {
2681 kfree(gu8FlushedJoinReq
);
2682 gu8FlushedJoinReq
= NULL
;
2684 if (gu8FlushedInfoElemAsoc
!= NULL
&& gu8FlushedJoinReqDrvHandler
== drvHandler
) {
2685 kfree(gu8FlushedInfoElemAsoc
);
2686 gu8FlushedInfoElemAsoc
= NULL
;
2689 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
2690 gbScanWhileConnected
= false;
2692 } else if ((u8MacStatus
== MAC_DISCONNECTED
) &&
2693 (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
!= NULL
)) {
2694 PRINT_D(HOSTINF_DBG
, "Received MAC_DISCONNECTED from the FW while scanning\n");
2695 PRINT_D(HOSTINF_DBG
, "\n\n<< Abort the running Scan >>\n\n");
2696 /*Abort the running scan*/
2697 del_timer(&pstrWFIDrv
->hScanTimer
);
2698 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
)
2699 Handle_ScanDone(pstrWFIDrv
, SCAN_EVENT_ABORTED
);
2705 WILC_CATCH(s32Error
)
2710 /* Deallocate pstrRcvdGnrlAsyncInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2711 if (pstrRcvdGnrlAsyncInfo
->pu8Buffer
!= NULL
) {
2712 kfree(pstrRcvdGnrlAsyncInfo
->pu8Buffer
);
2713 pstrRcvdGnrlAsyncInfo
->pu8Buffer
= NULL
;
2721 * @details Sending config packet to firmware to set key
2722 * @param[in] tstrHostIFkeyAttr* pstrHostIFkeyAttr
2723 * @return Error code.
2728 static int Handle_Key(tstrWILC_WFIDrv
*drvHandler
, tstrHostIFkeyAttr
*pstrHostIFkeyAttr
)
2730 s32 s32Error
= WILC_SUCCESS
;
2732 #ifdef WILC_AP_EXTERNAL_MLME
2733 tstrWID strWIDList
[5];
2739 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
2742 switch (pstrHostIFkeyAttr
->enuKeyType
) {
2747 #ifdef WILC_AP_EXTERNAL_MLME
2748 if (pstrHostIFkeyAttr
->u8KeyAction
& ADDKEY_AP
) {
2750 PRINT_D(HOSTINF_DBG
, "Handling WEP key\n");
2751 PRINT_D(GENERIC_DBG
, "ID Hostint is %d\n", (pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
));
2752 strWIDList
[0].u16WIDid
= (u16
)WID_11I_MODE
;
2753 strWIDList
[0].enuWIDtype
= WID_CHAR
;
2754 strWIDList
[0].s32ValueSize
= sizeof(char);
2755 strWIDList
[0].ps8WidVal
= (s8
*)(&(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8mode
));
2757 strWIDList
[1].u16WIDid
= WID_AUTH_TYPE
;
2758 strWIDList
[1].enuWIDtype
= WID_CHAR
;
2759 strWIDList
[1].s32ValueSize
= sizeof(char);
2760 strWIDList
[1].ps8WidVal
= (s8
*)(&(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.tenuAuth_type
));
2762 strWIDList
[2].u16WIDid
= (u16
)WID_KEY_ID
;
2763 strWIDList
[2].enuWIDtype
= WID_CHAR
;
2765 strWIDList
[2].ps8WidVal
= (s8
*)(&(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
));
2766 strWIDList
[2].s32ValueSize
= sizeof(char);
2769 pu8keybuf
= kmalloc(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
, GFP_KERNEL
);
2772 if (pu8keybuf
== NULL
) {
2773 PRINT_ER("No buffer to send Key\n");
2777 memcpy(pu8keybuf
, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
,
2778 pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
);
2781 kfree(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
);
2783 strWIDList
[3].u16WIDid
= (u16
)WID_WEP_KEY_VALUE
;
2784 strWIDList
[3].enuWIDtype
= WID_STR
;
2785 strWIDList
[3].s32ValueSize
= pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
;
2786 strWIDList
[3].ps8WidVal
= (s8
*)pu8keybuf
;
2789 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, 4, true,
2790 get_id_from_handler(pstrWFIDrv
));
2797 if (pstrHostIFkeyAttr
->u8KeyAction
& ADDKEY
) {
2798 PRINT_D(HOSTINF_DBG
, "Handling WEP key\n");
2799 pu8keybuf
= kmalloc(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
+ 2, GFP_KERNEL
);
2800 if (pu8keybuf
== NULL
) {
2801 PRINT_ER("No buffer to send Key\n");
2804 pu8keybuf
[0] = pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
;
2806 memcpy(pu8keybuf
+ 1, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
, 1);
2808 memcpy(pu8keybuf
+ 2, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
,
2809 pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
);
2811 kfree(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
);
2813 strWID
.u16WIDid
= (u16
)WID_ADD_WEP_KEY
;
2814 strWID
.enuWIDtype
= WID_STR
;
2815 strWID
.ps8WidVal
= (s8
*)pu8keybuf
;
2816 strWID
.s32ValueSize
= pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
+ 2;
2818 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
2819 get_id_from_handler(pstrWFIDrv
));
2821 } else if (pstrHostIFkeyAttr
->u8KeyAction
& REMOVEKEY
) {
2823 PRINT_D(HOSTINF_DBG
, "Removing key\n");
2824 strWID
.u16WIDid
= (u16
)WID_REMOVE_WEP_KEY
;
2825 strWID
.enuWIDtype
= WID_STR
;
2827 s8idxarray
[0] = (s8
)pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
;
2828 strWID
.ps8WidVal
= s8idxarray
;
2829 strWID
.s32ValueSize
= 1;
2831 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
2832 get_id_from_handler(pstrWFIDrv
));
2834 strWID
.u16WIDid
= (u16
)WID_KEY_ID
;
2835 strWID
.enuWIDtype
= WID_CHAR
;
2836 strWID
.ps8WidVal
= (s8
*)(&(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
));
2837 strWID
.s32ValueSize
= sizeof(char);
2839 PRINT_D(HOSTINF_DBG
, "Setting default key index\n");
2841 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
2842 get_id_from_handler(pstrWFIDrv
));
2844 up(&(pstrWFIDrv
->hSemTestKeyBlock
));
2848 #ifdef WILC_AP_EXTERNAL_MLME
2849 if (pstrHostIFkeyAttr
->u8KeyAction
& ADDKEY_AP
) {
2850 pu8keybuf
= kmalloc(RX_MIC_KEY_MSG_LEN
, GFP_KERNEL
);
2851 if (pu8keybuf
== NULL
) {
2852 PRINT_ER("No buffer to send RxGTK Key\n");
2854 goto _WPARxGtk_end_case_
;
2857 memset(pu8keybuf
, 0, RX_MIC_KEY_MSG_LEN
);
2860 /*|----------------------------------------------------------------------------|
2861 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2862 * |------------|---------|-------|------------|---------------|----------------|
2863 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2867 if (pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8seq
!= NULL
)
2868 memcpy(pu8keybuf
+ 6, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8seq
, 8);
2871 memcpy(pu8keybuf
+ 14, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8keyidx
, 1);
2873 memcpy(pu8keybuf
+ 15, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
, 1);
2875 memcpy(pu8keybuf
+ 16, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
,
2876 pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
);
2877 /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */
2878 strWIDList
[0].u16WIDid
= (u16
)WID_11I_MODE
;
2879 strWIDList
[0].enuWIDtype
= WID_CHAR
;
2880 strWIDList
[0].s32ValueSize
= sizeof(char);
2881 strWIDList
[0].ps8WidVal
= (s8
*)(&(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Ciphermode
));
2883 strWIDList
[1].u16WIDid
= (u16
)WID_ADD_RX_GTK
;
2884 strWIDList
[1].enuWIDtype
= WID_STR
;
2885 strWIDList
[1].ps8WidVal
= (s8
*)pu8keybuf
;
2886 strWIDList
[1].s32ValueSize
= RX_MIC_KEY_MSG_LEN
;
2888 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, 2, true,
2889 get_id_from_handler(pstrWFIDrv
));
2893 /* ////////////////////////// */
2894 up(&(pstrWFIDrv
->hSemTestKeyBlock
));
2895 /* ///////////////////////// */
2899 if (pstrHostIFkeyAttr
->u8KeyAction
& ADDKEY
) {
2900 PRINT_D(HOSTINF_DBG
, "Handling group key(Rx) function\n");
2902 pu8keybuf
= kmalloc(RX_MIC_KEY_MSG_LEN
, GFP_KERNEL
);
2903 if (pu8keybuf
== NULL
) {
2904 PRINT_ER("No buffer to send RxGTK Key\n");
2906 goto _WPARxGtk_end_case_
;
2909 memset(pu8keybuf
, 0, RX_MIC_KEY_MSG_LEN
);
2912 /*|----------------------------------------------------------------------------|
2913 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2914 * |------------|---------|-------|------------|---------------|----------------|
2915 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2917 if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_CONNECTED
)
2918 memcpy(pu8keybuf
, pstrWFIDrv
->au8AssociatedBSSID
, ETH_ALEN
);
2920 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
2922 memcpy(pu8keybuf
+ 6, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8seq
, 8);
2924 memcpy(pu8keybuf
+ 14, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8keyidx
, 1);
2926 memcpy(pu8keybuf
+ 15, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
, 1);
2927 memcpy(pu8keybuf
+ 16, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
,
2928 pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
);
2930 strWID
.u16WIDid
= (u16
)WID_ADD_RX_GTK
;
2931 strWID
.enuWIDtype
= WID_STR
;
2932 strWID
.ps8WidVal
= (s8
*)pu8keybuf
;
2933 strWID
.s32ValueSize
= RX_MIC_KEY_MSG_LEN
;
2935 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
2936 get_id_from_handler(pstrWFIDrv
));
2940 /* ////////////////////////// */
2941 up(&(pstrWFIDrv
->hSemTestKeyBlock
));
2942 /* ///////////////////////// */
2944 _WPARxGtk_end_case_
:
2945 kfree(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
);
2946 kfree(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8seq
);
2953 #ifdef WILC_AP_EXTERNAL_MLME
2954 if (pstrHostIFkeyAttr
->u8KeyAction
& ADDKEY_AP
) {
2957 pu8keybuf
= kmalloc(PTK_KEY_MSG_LEN
+ 1, GFP_KERNEL
);
2961 if (pu8keybuf
== NULL
) {
2962 PRINT_ER("No buffer to send PTK Key\n");
2964 goto _WPAPtk_end_case_
;
2968 /*|-----------------------------------------------------------------------------|
2969 * |Station address | keyidx |Key Length |Temporal Key | Rx Michael Key |Tx Michael Key |
2970 * |----------------|------------ |--------------|----------------|---------------|
2971 | 6 bytes | 1 byte | 1byte | 16 bytes | 8 bytes | 8 bytes |
2972 |-----------------------------------------------------------------------------|*/
2974 memcpy(pu8keybuf
, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8macaddr
, 6); /*1 bytes Key Length */
2976 memcpy(pu8keybuf
+ 6, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8keyidx
, 1);
2977 memcpy(pu8keybuf
+ 7, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
, 1);
2979 memcpy(pu8keybuf
+ 8, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
,
2980 pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
);
2983 strWIDList
[0].u16WIDid
= (u16
)WID_11I_MODE
;
2984 strWIDList
[0].enuWIDtype
= WID_CHAR
;
2985 strWIDList
[0].s32ValueSize
= sizeof(char);
2986 strWIDList
[0].ps8WidVal
= (s8
*)(&(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Ciphermode
));
2988 strWIDList
[1].u16WIDid
= (u16
)WID_ADD_PTK
;
2989 strWIDList
[1].enuWIDtype
= WID_STR
;
2990 strWIDList
[1].ps8WidVal
= (s8
*)pu8keybuf
;
2991 strWIDList
[1].s32ValueSize
= PTK_KEY_MSG_LEN
+ 1;
2993 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, 2, true,
2994 get_id_from_handler(pstrWFIDrv
));
2997 /* ////////////////////////// */
2998 up(&(pstrWFIDrv
->hSemTestKeyBlock
));
2999 /* ///////////////////////// */
3002 if (pstrHostIFkeyAttr
->u8KeyAction
& ADDKEY
) {
3005 pu8keybuf
= kmalloc(PTK_KEY_MSG_LEN
, GFP_KERNEL
);
3009 if (pu8keybuf
== NULL
) {
3010 PRINT_ER("No buffer to send PTK Key\n");
3012 goto _WPAPtk_end_case_
;
3016 /*|-----------------------------------------------------------------------------|
3017 * |Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
3018 * |----------------|------------|--------------|----------------|---------------|
3019 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
3020 |-----------------------------------------------------------------------------|*/
3022 memcpy(pu8keybuf
, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8macaddr
, 6); /*1 bytes Key Length */
3024 memcpy(pu8keybuf
+ 6, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
, 1);
3026 memcpy(pu8keybuf
+ 7, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
,
3027 pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
);
3030 strWID
.u16WIDid
= (u16
)WID_ADD_PTK
;
3031 strWID
.enuWIDtype
= WID_STR
;
3032 strWID
.ps8WidVal
= (s8
*)pu8keybuf
;
3033 strWID
.s32ValueSize
= PTK_KEY_MSG_LEN
;
3035 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
3036 get_id_from_handler(pstrWFIDrv
));
3039 /* ////////////////////////// */
3040 up(&(pstrWFIDrv
->hSemTestKeyBlock
));
3041 /* ///////////////////////// */
3045 kfree(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
);
3054 PRINT_D(HOSTINF_DBG
, "Handling PMKSA key\n");
3056 pu8keybuf
= kmalloc((pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFpmkidAttr
.numpmkid
* PMKSA_KEY_LEN
) + 1, GFP_KERNEL
);
3057 if (pu8keybuf
== NULL
) {
3058 PRINT_ER("No buffer to send PMKSA Key\n");
3062 pu8keybuf
[0] = pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFpmkidAttr
.numpmkid
;
3064 for (i
= 0; i
< pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFpmkidAttr
.numpmkid
; i
++) {
3066 memcpy(pu8keybuf
+ ((PMKSA_KEY_LEN
* i
) + 1), pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFpmkidAttr
.pmkidlist
[i
].bssid
, ETH_ALEN
);
3067 memcpy(pu8keybuf
+ ((PMKSA_KEY_LEN
* i
) + ETH_ALEN
+ 1), pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFpmkidAttr
.pmkidlist
[i
].pmkid
, PMKID_LEN
);
3070 strWID
.u16WIDid
= (u16
)WID_PMKID_INFO
;
3071 strWID
.enuWIDtype
= WID_STR
;
3072 strWID
.ps8WidVal
= (s8
*)pu8keybuf
;
3073 strWID
.s32ValueSize
= (pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFpmkidAttr
.numpmkid
* PMKSA_KEY_LEN
) + 1;
3075 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
3076 get_id_from_handler(pstrWFIDrv
));
3083 PRINT_ER("Failed to send key config packet\n");
3091 * @brief Handle_Disconnect
3092 * @details Sending config packet to firmware to disconnect
3099 static void Handle_Disconnect(tstrWILC_WFIDrv
*drvHandler
)
3103 s32 s32Error
= WILC_SUCCESS
;
3104 u16 u16DummyReasonCode
= 0;
3105 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3108 strWID
.u16WIDid
= (u16
)WID_DISCONNECT
;
3109 strWID
.enuWIDtype
= WID_CHAR
;
3110 strWID
.ps8WidVal
= (s8
*)&u16DummyReasonCode
;
3111 strWID
.s32ValueSize
= sizeof(char);
3115 PRINT_D(HOSTINF_DBG
, "Sending disconnect request\n");
3117 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3119 g_obtainingIP
= false;
3120 host_int_set_power_mgmt(pstrWFIDrv
, 0, 0);
3123 memset(u8ConnectedSSID
, 0, ETH_ALEN
);
3125 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false,
3126 get_id_from_handler(pstrWFIDrv
));
3129 PRINT_ER("Failed to send dissconect config packet\n");
3130 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3132 tstrDisconnectNotifInfo strDisconnectNotifInfo
;
3134 memset(&strDisconnectNotifInfo
, 0, sizeof(tstrDisconnectNotifInfo
));
3136 strDisconnectNotifInfo
.u16reason
= 0;
3137 strDisconnectNotifInfo
.ie
= NULL
;
3138 strDisconnectNotifInfo
.ie_len
= 0;
3140 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
3141 del_timer(&pstrWFIDrv
->hScanTimer
);
3142 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult(SCAN_EVENT_ABORTED
, NULL
,
3143 pstrWFIDrv
->strWILC_UsrScanReq
.u32UserScanPvoid
, NULL
);
3145 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
= NULL
;
3148 if (pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
!= NULL
) {
3151 /*Stop connect timer, if connection in progress*/
3152 if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_WAITING_CONN_RESP
) {
3153 PRINT_D(HOSTINF_DBG
, "Upper layer requested termination of connection\n");
3154 del_timer(&pstrWFIDrv
->hConnectTimer
);
3157 pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF
, NULL
,
3158 0, &strDisconnectNotifInfo
, pstrWFIDrv
->strWILC_UsrConnReq
.u32UserConnectPvoid
);
3160 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
3163 gbScanWhileConnected
= false;
3165 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
3167 memset(pstrWFIDrv
->au8AssociatedBSSID
, 0, ETH_ALEN
);
3171 pstrWFIDrv
->strWILC_UsrConnReq
.ssidLen
= 0;
3172 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
!= NULL
) {
3173 kfree(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
);
3174 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
= NULL
;
3177 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
!= NULL
) {
3178 kfree(pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
);
3179 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
= NULL
;
3182 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
= 0;
3183 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
!= NULL
) {
3184 kfree(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
);
3185 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
= NULL
;
3190 if (gu8FlushedJoinReq
!= NULL
&& gu8FlushedJoinReqDrvHandler
== drvHandler
) {
3191 kfree(gu8FlushedJoinReq
);
3192 gu8FlushedJoinReq
= NULL
;
3194 if (gu8FlushedInfoElemAsoc
!= NULL
&& gu8FlushedJoinReqDrvHandler
== drvHandler
) {
3195 kfree(gu8FlushedInfoElemAsoc
);
3196 gu8FlushedInfoElemAsoc
= NULL
;
3201 WILC_CATCH(s32Error
)
3206 /* ////////////////////////// */
3207 up(&(pstrWFIDrv
->hSemTestDisconnectBlock
));
3208 /* ///////////////////////// */
3213 void resolve_disconnect_aberration(tstrWILC_WFIDrv
*drvHandler
)
3215 tstrWILC_WFIDrv
*pstrWFIDrv
;
3217 pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3218 if (pstrWFIDrv
== NULL
)
3220 if ((pstrWFIDrv
->enuHostIFstate
== HOST_IF_WAITING_CONN_RESP
) || (pstrWFIDrv
->enuHostIFstate
== HOST_IF_CONNECTING
)) {
3221 PRINT_D(HOSTINF_DBG
, "\n\n<< correcting Supplicant state machine >>\n\n");
3222 host_int_disconnect(pstrWFIDrv
, 1);
3225 static s32
Switch_Log_Terminal(tstrWILC_WFIDrv
*drvHandler
)
3229 s32 s32Error
= WILC_SUCCESS
;
3231 static char dummy
= 9;
3232 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3234 strWID
.u16WIDid
= (u16
)WID_LOGTerminal_Switch
;
3235 strWID
.enuWIDtype
= WID_CHAR
;
3236 strWID
.ps8WidVal
= &dummy
;
3237 strWID
.s32ValueSize
= sizeof(char);
3239 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
3240 get_id_from_handler(pstrWFIDrv
));
3244 PRINT_D(HOSTINF_DBG
, "Failed to switch log terminal\n");
3245 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
3247 PRINT_INFO(HOSTINF_DBG
, "MAC address set ::\n");
3252 WILC_CATCH(s32Error
)
3261 * @brief Handle_GetChnl
3262 * @details Sending config packet to get channel
3270 static s32
Handle_GetChnl(tstrWILC_WFIDrv
*drvHandler
)
3273 s32 s32Error
= WILC_SUCCESS
;
3275 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
3276 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3278 strWID
.u16WIDid
= (u16
)WID_CURRENT_CHANNEL
;
3279 strWID
.enuWIDtype
= WID_CHAR
;
3280 strWID
.ps8WidVal
= (s8
*)&gu8Chnl
;
3281 strWID
.s32ValueSize
= sizeof(char);
3283 PRINT_D(HOSTINF_DBG
, "Getting channel value\n");
3285 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true,
3286 get_id_from_handler(pstrWFIDrv
));
3287 /*get the value by searching the local copy*/
3289 PRINT_ER("Failed to get channel number\n");
3290 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3294 WILC_CATCH(s32Error
)
3298 up(&(pstrWFIDrv
->hSemGetCHNL
));
3308 * @brief Handle_GetRssi
3309 * @details Sending config packet to get RSSI
3316 static void Handle_GetRssi(tstrWILC_WFIDrv
*drvHandler
)
3318 s32 s32Error
= WILC_SUCCESS
;
3320 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3322 strWID
.u16WIDid
= (u16
)WID_RSSI
;
3323 strWID
.enuWIDtype
= WID_CHAR
;
3324 strWID
.ps8WidVal
= &gs8Rssi
;
3325 strWID
.s32ValueSize
= sizeof(char);
3328 PRINT_D(HOSTINF_DBG
, "Getting RSSI value\n");
3330 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true,
3331 get_id_from_handler(pstrWFIDrv
));
3333 PRINT_ER("Failed to get RSSI value\n");
3334 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3337 WILC_CATCH(s32Error
)
3341 up(&(pstrWFIDrv
->hSemGetRSSI
));
3347 static void Handle_GetLinkspeed(tstrWILC_WFIDrv
*drvHandler
)
3349 s32 s32Error
= WILC_SUCCESS
;
3351 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3355 strWID
.u16WIDid
= (u16
)WID_LINKSPEED
;
3356 strWID
.enuWIDtype
= WID_CHAR
;
3357 strWID
.ps8WidVal
= &gs8lnkspd
;
3358 strWID
.s32ValueSize
= sizeof(char);
3360 PRINT_D(HOSTINF_DBG
, "Getting LINKSPEED value\n");
3362 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true,
3363 get_id_from_handler(pstrWFIDrv
));
3365 PRINT_ER("Failed to get LINKSPEED value\n");
3366 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3369 WILC_CATCH(s32Error
)
3373 up(&(pstrWFIDrv
->hSemGetLINKSPEED
));
3378 s32
Handle_GetStatistics(tstrWILC_WFIDrv
*drvHandler
, tstrStatistics
*pstrStatistics
)
3380 tstrWID strWIDList
[5];
3381 u32 u32WidsCount
= 0, s32Error
= 0;
3383 strWIDList
[u32WidsCount
].u16WIDid
= WID_LINKSPEED
;
3384 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
3385 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
3386 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrStatistics
->u8LinkSpeed
));
3389 strWIDList
[u32WidsCount
].u16WIDid
= WID_RSSI
;
3390 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
3391 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
3392 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrStatistics
->s8RSSI
));
3395 strWIDList
[u32WidsCount
].u16WIDid
= WID_SUCCESS_FRAME_COUNT
;
3396 strWIDList
[u32WidsCount
].enuWIDtype
= WID_INT
;
3397 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(u32
);
3398 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrStatistics
->u32TxCount
));
3401 strWIDList
[u32WidsCount
].u16WIDid
= WID_RECEIVED_FRAGMENT_COUNT
;
3402 strWIDList
[u32WidsCount
].enuWIDtype
= WID_INT
;
3403 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(u32
);
3404 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrStatistics
->u32RxCount
));
3407 strWIDList
[u32WidsCount
].u16WIDid
= WID_FAILED_COUNT
;
3408 strWIDList
[u32WidsCount
].enuWIDtype
= WID_INT
;
3409 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(u32
);
3410 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrStatistics
->u32TxFailureCount
));
3413 s32Error
= SendConfigPkt(GET_CFG
, strWIDList
, u32WidsCount
, false,
3414 get_id_from_handler(drvHandler
));
3417 PRINT_ER("Failed to send scan paramters config packet\n");
3418 /* WILC_ERRORREPORT(s32Error, s32Error); */
3426 #ifdef WILC_AP_EXTERNAL_MLME
3430 * @brief Handle_Get_InActiveTime
3431 * @details Sending config packet to set mac adddress for station and
3440 static s32
Handle_Get_InActiveTime(tstrWILC_WFIDrv
*drvHandler
, tstrHostIfStaInactiveT
*strHostIfStaInactiveT
)
3443 s32 s32Error
= WILC_SUCCESS
;
3446 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3449 strWID
.u16WIDid
= (u16
)WID_SET_STA_MAC_INACTIVE_TIME
;
3450 strWID
.enuWIDtype
= WID_STR
;
3451 strWID
.s32ValueSize
= ETH_ALEN
;
3452 strWID
.ps8WidVal
= kmalloc(strWID
.s32ValueSize
, GFP_KERNEL
);
3455 stamac
= strWID
.ps8WidVal
;
3456 memcpy(stamac
, strHostIfStaInactiveT
->mac
, ETH_ALEN
);
3459 PRINT_D(CFG80211_DBG
, "SETING STA inactive time\n");
3462 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
3463 get_id_from_handler(pstrWFIDrv
));
3464 /*get the value by searching the local copy*/
3466 PRINT_ER("Failed to SET incative time\n");
3467 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3471 strWID
.u16WIDid
= (u16
)WID_GET_INACTIVE_TIME
;
3472 strWID
.enuWIDtype
= WID_INT
;
3473 strWID
.ps8WidVal
= (s8
*)&gu32InactiveTime
;
3474 strWID
.s32ValueSize
= sizeof(u32
);
3477 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true,
3478 get_id_from_handler(pstrWFIDrv
));
3479 /*get the value by searching the local copy*/
3481 PRINT_ER("Failed to get incative time\n");
3482 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3486 PRINT_D(CFG80211_DBG
, "Getting inactive time : %d\n", gu32InactiveTime
);
3488 up(&(pstrWFIDrv
->hSemInactiveTime
));
3489 WILC_CATCH(s32Error
)
3503 * @brief Handle_AddBeacon
3504 * @details Sending config packet to add beacon
3505 * @param[in] tstrHostIFSetBeacon* pstrSetBeaconParam
3511 static void Handle_AddBeacon(tstrWILC_WFIDrv
*drvHandler
, tstrHostIFSetBeacon
*pstrSetBeaconParam
)
3513 s32 s32Error
= WILC_SUCCESS
;
3516 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3518 PRINT_D(HOSTINF_DBG
, "Adding BEACON\n");
3520 strWID
.u16WIDid
= (u16
)WID_ADD_BEACON
;
3521 strWID
.enuWIDtype
= WID_BIN
;
3522 strWID
.s32ValueSize
= pstrSetBeaconParam
->u32HeadLen
+ pstrSetBeaconParam
->u32TailLen
+ 16;
3523 strWID
.ps8WidVal
= kmalloc(strWID
.s32ValueSize
, GFP_KERNEL
);
3524 if (strWID
.ps8WidVal
== NULL
)
3525 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3527 pu8CurrByte
= strWID
.ps8WidVal
;
3528 *pu8CurrByte
++ = (pstrSetBeaconParam
->u32Interval
& 0xFF);
3529 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32Interval
>> 8) & 0xFF);
3530 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32Interval
>> 16) & 0xFF);
3531 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32Interval
>> 24) & 0xFF);
3533 *pu8CurrByte
++ = (pstrSetBeaconParam
->u32DTIMPeriod
& 0xFF);
3534 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32DTIMPeriod
>> 8) & 0xFF);
3535 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32DTIMPeriod
>> 16) & 0xFF);
3536 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32DTIMPeriod
>> 24) & 0xFF);
3538 *pu8CurrByte
++ = (pstrSetBeaconParam
->u32HeadLen
& 0xFF);
3539 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32HeadLen
>> 8) & 0xFF);
3540 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32HeadLen
>> 16) & 0xFF);
3541 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32HeadLen
>> 24) & 0xFF);
3543 memcpy(pu8CurrByte
, pstrSetBeaconParam
->pu8Head
, pstrSetBeaconParam
->u32HeadLen
);
3544 pu8CurrByte
+= pstrSetBeaconParam
->u32HeadLen
;
3546 *pu8CurrByte
++ = (pstrSetBeaconParam
->u32TailLen
& 0xFF);
3547 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32TailLen
>> 8) & 0xFF);
3548 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32TailLen
>> 16) & 0xFF);
3549 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32TailLen
>> 24) & 0xFF);
3551 /* Bug 4599 : if tail length = 0 skip copying */
3552 if (pstrSetBeaconParam
->pu8Tail
> 0)
3553 memcpy(pu8CurrByte
, pstrSetBeaconParam
->pu8Tail
, pstrSetBeaconParam
->u32TailLen
);
3554 pu8CurrByte
+= pstrSetBeaconParam
->u32TailLen
;
3559 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false,
3560 get_id_from_handler(pstrWFIDrv
));
3562 PRINT_ER("Failed to send add beacon config packet\n");
3563 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3566 WILC_CATCH(s32Error
)
3569 kfree(strWID
.ps8WidVal
);
3570 kfree(pstrSetBeaconParam
->pu8Head
);
3571 kfree(pstrSetBeaconParam
->pu8Tail
);
3576 * @brief Handle_AddBeacon
3577 * @details Sending config packet to delete beacon
3578 * @param[in] tstrHostIFDelBeacon* pstrDelBeacon
3584 static void Handle_DelBeacon(tstrWILC_WFIDrv
*drvHandler
, tstrHostIFDelBeacon
*pstrDelBeacon
)
3586 s32 s32Error
= WILC_SUCCESS
;
3589 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3591 strWID
.u16WIDid
= (u16
)WID_DEL_BEACON
;
3592 strWID
.enuWIDtype
= WID_CHAR
;
3593 strWID
.s32ValueSize
= sizeof(char);
3594 strWID
.ps8WidVal
= &gu8DelBcn
;
3596 if (strWID
.ps8WidVal
== NULL
)
3597 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3599 pu8CurrByte
= strWID
.ps8WidVal
;
3601 PRINT_D(HOSTINF_DBG
, "Deleting BEACON\n");
3602 /* TODO: build del beacon message*/
3605 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false,
3606 get_id_from_handler(pstrWFIDrv
));
3609 PRINT_ER("Failed to send delete beacon config packet\n");
3610 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3613 WILC_CATCH(s32Error
)
3620 * @brief WILC_HostIf_PackStaParam
3621 * @details Handling packing of the station params in a buffer
3622 * @param[in] u8* pu8Buffer, tstrWILC_AddStaParam* pstrStationParam
3628 static u32
WILC_HostIf_PackStaParam(u8
*pu8Buffer
, tstrWILC_AddStaParam
*pstrStationParam
)
3632 pu8CurrByte
= pu8Buffer
;
3634 PRINT_D(HOSTINF_DBG
, "Packing STA params\n");
3635 memcpy(pu8CurrByte
, pstrStationParam
->au8BSSID
, ETH_ALEN
);
3636 pu8CurrByte
+= ETH_ALEN
;
3638 *pu8CurrByte
++ = pstrStationParam
->u16AssocID
& 0xFF;
3639 *pu8CurrByte
++ = (pstrStationParam
->u16AssocID
>> 8) & 0xFF;
3641 *pu8CurrByte
++ = pstrStationParam
->u8NumRates
;
3642 if (pstrStationParam
->u8NumRates
> 0)
3643 memcpy(pu8CurrByte
, pstrStationParam
->pu8Rates
, pstrStationParam
->u8NumRates
);
3644 pu8CurrByte
+= pstrStationParam
->u8NumRates
;
3646 *pu8CurrByte
++ = pstrStationParam
->bIsHTSupported
;
3647 *pu8CurrByte
++ = pstrStationParam
->u16HTCapInfo
& 0xFF;
3648 *pu8CurrByte
++ = (pstrStationParam
->u16HTCapInfo
>> 8) & 0xFF;
3650 *pu8CurrByte
++ = pstrStationParam
->u8AmpduParams
;
3651 memcpy(pu8CurrByte
, pstrStationParam
->au8SuppMCsSet
, WILC_SUPP_MCS_SET_SIZE
);
3652 pu8CurrByte
+= WILC_SUPP_MCS_SET_SIZE
;
3654 *pu8CurrByte
++ = pstrStationParam
->u16HTExtParams
& 0xFF;
3655 *pu8CurrByte
++ = (pstrStationParam
->u16HTExtParams
>> 8) & 0xFF;
3657 *pu8CurrByte
++ = pstrStationParam
->u32TxBeamformingCap
& 0xFF;
3658 *pu8CurrByte
++ = (pstrStationParam
->u32TxBeamformingCap
>> 8) & 0xFF;
3659 *pu8CurrByte
++ = (pstrStationParam
->u32TxBeamformingCap
>> 16) & 0xFF;
3660 *pu8CurrByte
++ = (pstrStationParam
->u32TxBeamformingCap
>> 24) & 0xFF;
3662 *pu8CurrByte
++ = pstrStationParam
->u8ASELCap
;
3664 *pu8CurrByte
++ = pstrStationParam
->u16FlagsMask
& 0xFF;
3665 *pu8CurrByte
++ = (pstrStationParam
->u16FlagsMask
>> 8) & 0xFF;
3667 *pu8CurrByte
++ = pstrStationParam
->u16FlagsSet
& 0xFF;
3668 *pu8CurrByte
++ = (pstrStationParam
->u16FlagsSet
>> 8) & 0xFF;
3670 return pu8CurrByte
- pu8Buffer
;
3674 * @brief Handle_AddStation
3675 * @details Sending config packet to add station
3676 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3682 static void Handle_AddStation(tstrWILC_WFIDrv
*drvHandler
, tstrWILC_AddStaParam
*pstrStationParam
)
3684 s32 s32Error
= WILC_SUCCESS
;
3687 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3689 PRINT_D(HOSTINF_DBG
, "Handling add station\n");
3690 strWID
.u16WIDid
= (u16
)WID_ADD_STA
;
3691 strWID
.enuWIDtype
= WID_BIN
;
3692 strWID
.s32ValueSize
= WILC_ADD_STA_LENGTH
+ pstrStationParam
->u8NumRates
;
3694 strWID
.ps8WidVal
= kmalloc(strWID
.s32ValueSize
, GFP_KERNEL
);
3695 if (strWID
.ps8WidVal
== NULL
)
3696 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3698 pu8CurrByte
= strWID
.ps8WidVal
;
3699 pu8CurrByte
+= WILC_HostIf_PackStaParam(pu8CurrByte
, pstrStationParam
);
3702 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false,
3703 get_id_from_handler(pstrWFIDrv
));
3704 if (s32Error
!= WILC_SUCCESS
) {
3706 PRINT_ER("Failed to send add station config packet\n");
3707 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3710 WILC_CATCH(s32Error
)
3713 kfree(pstrStationParam
->pu8Rates
);
3714 kfree(strWID
.ps8WidVal
);
3718 * @brief Handle_DelAllSta
3719 * @details Sending config packet to delete station
3720 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3726 static void Handle_DelAllSta(tstrWILC_WFIDrv
*drvHandler
, tstrHostIFDelAllSta
*pstrDelAllStaParam
)
3728 s32 s32Error
= WILC_SUCCESS
;
3732 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3734 u8 au8Zero_Buff
[6] = {0};
3736 strWID
.u16WIDid
= (u16
)WID_DEL_ALL_STA
;
3737 strWID
.enuWIDtype
= WID_STR
;
3738 strWID
.s32ValueSize
= (pstrDelAllStaParam
->u8Num_AssocSta
* ETH_ALEN
) + 1;
3740 PRINT_D(HOSTINF_DBG
, "Handling delete station\n");
3742 strWID
.ps8WidVal
= kmalloc((pstrDelAllStaParam
->u8Num_AssocSta
* ETH_ALEN
) + 1, GFP_KERNEL
);
3743 if (strWID
.ps8WidVal
== NULL
)
3744 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3746 pu8CurrByte
= strWID
.ps8WidVal
;
3748 *(pu8CurrByte
++) = pstrDelAllStaParam
->u8Num_AssocSta
;
3750 for (i
= 0; i
< MAX_NUM_STA
; i
++) {
3751 if (memcmp(pstrDelAllStaParam
->au8Sta_DelAllSta
[i
], au8Zero_Buff
, ETH_ALEN
))
3752 memcpy(pu8CurrByte
, pstrDelAllStaParam
->au8Sta_DelAllSta
[i
], ETH_ALEN
);
3756 pu8CurrByte
+= ETH_ALEN
;
3760 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
3761 get_id_from_handler(pstrWFIDrv
));
3764 PRINT_ER("Failed to send add station config packet\n");
3765 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3768 WILC_CATCH(s32Error
)
3771 kfree(strWID
.ps8WidVal
);
3778 * @brief Handle_DelStation
3779 * @details Sending config packet to delete station
3780 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3786 static void Handle_DelStation(tstrWILC_WFIDrv
*drvHandler
, tstrHostIFDelSta
*pstrDelStaParam
)
3788 s32 s32Error
= WILC_SUCCESS
;
3791 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3793 strWID
.u16WIDid
= (u16
)WID_REMOVE_STA
;
3794 strWID
.enuWIDtype
= WID_BIN
;
3795 strWID
.s32ValueSize
= ETH_ALEN
;
3797 PRINT_D(HOSTINF_DBG
, "Handling delete station\n");
3799 strWID
.ps8WidVal
= kmalloc(strWID
.s32ValueSize
, GFP_KERNEL
);
3800 if (strWID
.ps8WidVal
== NULL
)
3801 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3803 pu8CurrByte
= strWID
.ps8WidVal
;
3805 memcpy(pu8CurrByte
, pstrDelStaParam
->au8MacAddr
, ETH_ALEN
);
3808 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false,
3809 get_id_from_handler(pstrWFIDrv
));
3812 PRINT_ER("Failed to send add station config packet\n");
3813 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3816 WILC_CATCH(s32Error
)
3819 kfree(strWID
.ps8WidVal
);
3824 * @brief Handle_EditStation
3825 * @details Sending config packet to edit station
3826 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3832 static void Handle_EditStation(tstrWILC_WFIDrv
*drvHandler
, tstrWILC_AddStaParam
*pstrStationParam
)
3834 s32 s32Error
= WILC_SUCCESS
;
3837 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3839 strWID
.u16WIDid
= (u16
)WID_EDIT_STA
;
3840 strWID
.enuWIDtype
= WID_BIN
;
3841 strWID
.s32ValueSize
= WILC_ADD_STA_LENGTH
+ pstrStationParam
->u8NumRates
;
3843 PRINT_D(HOSTINF_DBG
, "Handling edit station\n");
3844 strWID
.ps8WidVal
= kmalloc(strWID
.s32ValueSize
, GFP_KERNEL
);
3845 if (strWID
.ps8WidVal
== NULL
)
3846 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3848 pu8CurrByte
= strWID
.ps8WidVal
;
3849 pu8CurrByte
+= WILC_HostIf_PackStaParam(pu8CurrByte
, pstrStationParam
);
3852 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false,
3853 get_id_from_handler(pstrWFIDrv
));
3856 PRINT_ER("Failed to send edit station config packet\n");
3857 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3860 WILC_CATCH(s32Error
)
3863 kfree(pstrStationParam
->pu8Rates
);
3864 kfree(strWID
.ps8WidVal
);
3866 #endif /*WILC_AP_EXTERNAL_MLME*/
3870 * @brief Handle_RemainOnChan
3871 * @details Sending config packet to edit station
3872 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3878 static int Handle_RemainOnChan(tstrWILC_WFIDrv
*drvHandler
, tstrHostIfRemainOnChan
*pstrHostIfRemainOnChan
)
3880 s32 s32Error
= WILC_SUCCESS
;
3881 u8 u8remain_on_chan_flag
;
3883 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*) drvHandler
;
3885 /*If it's a pendig remain-on-channel, don't overwrite gWFiDrvHandle values (since incoming msg is garbbage)*/
3886 if (!pstrWFIDrv
->u8RemainOnChan_pendingreq
) {
3887 pstrWFIDrv
->strHostIfRemainOnChan
.pVoid
= pstrHostIfRemainOnChan
->pVoid
;
3888 pstrWFIDrv
->strHostIfRemainOnChan
.pRemainOnChanExpired
= pstrHostIfRemainOnChan
->pRemainOnChanExpired
;
3889 pstrWFIDrv
->strHostIfRemainOnChan
.pRemainOnChanReady
= pstrHostIfRemainOnChan
->pRemainOnChanReady
;
3890 pstrWFIDrv
->strHostIfRemainOnChan
.u16Channel
= pstrHostIfRemainOnChan
->u16Channel
;
3891 pstrWFIDrv
->strHostIfRemainOnChan
.u32ListenSessionID
= pstrHostIfRemainOnChan
->u32ListenSessionID
;
3893 /*Set the channel to use it as a wid val*/
3894 pstrHostIfRemainOnChan
->u16Channel
= pstrWFIDrv
->strHostIfRemainOnChan
.u16Channel
;
3897 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
!= NULL
) {
3898 PRINT_INFO(GENERIC_DBG
, "Required to remain on chan while scanning return\n");
3899 pstrWFIDrv
->u8RemainOnChan_pendingreq
= 1;
3900 WILC_ERRORREPORT(s32Error
, WILC_BUSY
);
3902 if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_WAITING_CONN_RESP
) {
3903 PRINT_INFO(GENERIC_DBG
, "Required to remain on chan while connecting return\n");
3904 WILC_ERRORREPORT(s32Error
, WILC_BUSY
);
3907 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3908 if (g_obtainingIP
|| connecting
) {
3909 PRINT_D(GENERIC_DBG
, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
3910 WILC_ERRORREPORT(s32Error
, WILC_BUSY
);
3914 PRINT_D(HOSTINF_DBG
, "Setting channel :%d\n", pstrHostIfRemainOnChan
->u16Channel
);
3916 u8remain_on_chan_flag
= true;
3917 strWID
.u16WIDid
= (u16
)WID_REMAIN_ON_CHAN
;
3918 strWID
.enuWIDtype
= WID_STR
;
3919 strWID
.s32ValueSize
= 2;
3920 strWID
.ps8WidVal
= kmalloc(strWID
.s32ValueSize
, GFP_KERNEL
);
3922 if (strWID
.ps8WidVal
== NULL
)
3923 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3925 strWID
.ps8WidVal
[0] = u8remain_on_chan_flag
;
3926 strWID
.ps8WidVal
[1] = (s8
)pstrHostIfRemainOnChan
->u16Channel
;
3929 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
3930 get_id_from_handler(pstrWFIDrv
));
3931 if (s32Error
!= WILC_SUCCESS
)
3932 PRINT_ER("Failed to set remain on channel\n");
3936 P2P_LISTEN_STATE
= 1;
3937 pstrWFIDrv
->hRemainOnChannel
.data
= (unsigned long)pstrWFIDrv
;
3938 mod_timer(&pstrWFIDrv
->hRemainOnChannel
,
3940 msecs_to_jiffies(pstrHostIfRemainOnChan
->u32duration
));
3942 /*Calling CFG ready_on_channel*/
3943 if (pstrWFIDrv
->strHostIfRemainOnChan
.pRemainOnChanReady
)
3944 pstrWFIDrv
->strHostIfRemainOnChan
.pRemainOnChanReady(pstrWFIDrv
->strHostIfRemainOnChan
.pVoid
);
3946 if (pstrWFIDrv
->u8RemainOnChan_pendingreq
)
3947 pstrWFIDrv
->u8RemainOnChan_pendingreq
= 0;
3953 * @brief Handle_RegisterFrame
3961 static int Handle_RegisterFrame(tstrWILC_WFIDrv
*drvHandler
, tstrHostIfRegisterFrame
*pstrHostIfRegisterFrame
)
3963 s32 s32Error
= WILC_SUCCESS
;
3966 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3968 PRINT_D(HOSTINF_DBG
, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame
->bReg
, pstrHostIfRegisterFrame
->u16FrameType
);
3970 /*prepare configuration packet*/
3971 strWID
.u16WIDid
= (u16
)WID_REGISTER_FRAME
;
3972 strWID
.enuWIDtype
= WID_STR
;
3973 strWID
.ps8WidVal
= kmalloc(sizeof(u16
) + 2, GFP_KERNEL
);
3974 if (strWID
.ps8WidVal
== NULL
)
3975 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3977 pu8CurrByte
= strWID
.ps8WidVal
;
3979 *pu8CurrByte
++ = pstrHostIfRegisterFrame
->bReg
;
3980 *pu8CurrByte
++ = pstrHostIfRegisterFrame
->u8Regid
;
3981 memcpy(pu8CurrByte
, &(pstrHostIfRegisterFrame
->u16FrameType
), sizeof(u16
));
3984 strWID
.s32ValueSize
= sizeof(u16
) + 2;
3988 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
3989 get_id_from_handler(pstrWFIDrv
));
3991 PRINT_ER("Failed to frame register config packet\n");
3992 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
3996 WILC_CATCH(s32Error
)
4005 * @brief Handle_ListenStateExpired
4006 * @details Handle of listen state expiration
4008 * @return Error code.
4013 #define FALSE_FRMWR_CHANNEL 100
4014 static u32
Handle_ListenStateExpired(tstrWILC_WFIDrv
*drvHandler
, tstrHostIfRemainOnChan
*pstrHostIfRemainOnChan
)
4016 u8 u8remain_on_chan_flag
;
4018 s32 s32Error
= WILC_SUCCESS
;
4019 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*) drvHandler
;
4021 PRINT_D(HOSTINF_DBG
, "CANCEL REMAIN ON CHAN\n");
4024 /*Make sure we are already in listen state*/
4025 /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/
4026 if (P2P_LISTEN_STATE
) {
4027 u8remain_on_chan_flag
= false;
4028 strWID
.u16WIDid
= (u16
)WID_REMAIN_ON_CHAN
;
4029 strWID
.enuWIDtype
= WID_STR
;
4030 strWID
.s32ValueSize
= 2;
4031 strWID
.ps8WidVal
= kmalloc(strWID
.s32ValueSize
, GFP_KERNEL
);
4033 if (strWID
.ps8WidVal
== NULL
)
4034 PRINT_ER("Failed to allocate memory\n");
4036 strWID
.ps8WidVal
[0] = u8remain_on_chan_flag
;
4037 strWID
.ps8WidVal
[1] = FALSE_FRMWR_CHANNEL
;
4040 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
4041 get_id_from_handler(pstrWFIDrv
));
4042 if (s32Error
!= WILC_SUCCESS
) {
4043 PRINT_ER("Failed to set remain on channel\n");
4047 if (pstrWFIDrv
->strHostIfRemainOnChan
.pRemainOnChanExpired
) {
4048 pstrWFIDrv
->strHostIfRemainOnChan
.pRemainOnChanExpired(pstrWFIDrv
->strHostIfRemainOnChan
.pVoid
4049 , pstrHostIfRemainOnChan
->u32ListenSessionID
);
4051 P2P_LISTEN_STATE
= 0;
4053 PRINT_D(GENERIC_DBG
, "Not in listen state\n");
4054 s32Error
= WILC_FAIL
;
4063 * @brief ListenTimerCB
4064 * @details Callback function of remain-on-channel timer
4066 * @return Error code.
4071 static void ListenTimerCB(unsigned long arg
)
4073 s32 s32Error
= WILC_SUCCESS
;
4074 tstrHostIFmsg strHostIFmsg
;
4075 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)arg
;
4076 /*Stopping remain-on-channel timer*/
4077 del_timer(&pstrWFIDrv
->hRemainOnChannel
);
4079 /* prepare the Timer Callback message */
4080 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4081 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_LISTEN_TIMER_FIRED
;
4082 strHostIFmsg
.drvHandler
= pstrWFIDrv
;
4083 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.u32ListenSessionID
= pstrWFIDrv
->strHostIfRemainOnChan
.u32ListenSessionID
;
4085 /* send the message */
4086 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
4088 WILC_ERRORREPORT(s32Error
, s32Error
);
4089 WILC_CATCH(s32Error
)
4098 * @brief Handle_EditStation
4099 * @details Sending config packet to edit station
4100 * @param[in] tstrWILC_AddStaParam* pstrStationParam
4106 static void Handle_PowerManagement(tstrWILC_WFIDrv
*drvHandler
, tstrHostIfPowerMgmtParam
*strPowerMgmtParam
)
4108 s32 s32Error
= WILC_SUCCESS
;
4111 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
4113 strWID
.u16WIDid
= (u16
)WID_POWER_MANAGEMENT
;
4115 if (strPowerMgmtParam
->bIsEnabled
== true)
4116 s8PowerMode
= MIN_FAST_PS
;
4118 s8PowerMode
= NO_POWERSAVE
;
4119 PRINT_D(HOSTINF_DBG
, "Handling power mgmt to %d\n", s8PowerMode
);
4120 strWID
.ps8WidVal
= &s8PowerMode
;
4121 strWID
.s32ValueSize
= sizeof(char);
4123 PRINT_D(HOSTINF_DBG
, "Handling Power Management\n");
4126 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
4127 get_id_from_handler(pstrWFIDrv
));
4129 PRINT_ER("Failed to send power management config packet\n");
4130 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
4133 WILC_CATCH(s32Error
)
4140 * @brief Handle_SetMulticastFilter
4141 * @details Set Multicast filter in firmware
4142 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4148 static void Handle_SetMulticastFilter(tstrWILC_WFIDrv
*drvHandler
, tstrHostIFSetMulti
*strHostIfSetMulti
)
4150 s32 s32Error
= WILC_SUCCESS
;
4154 PRINT_D(HOSTINF_DBG
, "Setup Multicast Filter\n");
4156 strWID
.u16WIDid
= (u16
)WID_SETUP_MULTICAST_FILTER
;
4157 strWID
.enuWIDtype
= WID_BIN
;
4158 strWID
.s32ValueSize
= sizeof(tstrHostIFSetMulti
) + ((strHostIfSetMulti
->u32count
) * ETH_ALEN
);
4159 strWID
.ps8WidVal
= kmalloc(strWID
.s32ValueSize
, GFP_KERNEL
);
4160 if (strWID
.ps8WidVal
== NULL
)
4161 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
4163 pu8CurrByte
= strWID
.ps8WidVal
;
4164 *pu8CurrByte
++ = (strHostIfSetMulti
->bIsEnabled
& 0xFF);
4165 *pu8CurrByte
++ = ((strHostIfSetMulti
->bIsEnabled
>> 8) & 0xFF);
4166 *pu8CurrByte
++ = ((strHostIfSetMulti
->bIsEnabled
>> 16) & 0xFF);
4167 *pu8CurrByte
++ = ((strHostIfSetMulti
->bIsEnabled
>> 24) & 0xFF);
4169 *pu8CurrByte
++ = (strHostIfSetMulti
->u32count
& 0xFF);
4170 *pu8CurrByte
++ = ((strHostIfSetMulti
->u32count
>> 8) & 0xFF);
4171 *pu8CurrByte
++ = ((strHostIfSetMulti
->u32count
>> 16) & 0xFF);
4172 *pu8CurrByte
++ = ((strHostIfSetMulti
->u32count
>> 24) & 0xFF);
4174 if ((strHostIfSetMulti
->u32count
) > 0)
4175 memcpy(pu8CurrByte
, gau8MulticastMacAddrList
, ((strHostIfSetMulti
->u32count
) * ETH_ALEN
));
4178 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false,
4179 get_id_from_handler(drvHandler
));
4181 PRINT_ER("Failed to send setup multicast config packet\n");
4182 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
4185 WILC_CATCH(s32Error
)
4188 kfree(strWID
.ps8WidVal
);
4195 * @brief Handle_AddBASession
4196 * @details Add block ack session
4197 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4199 * @author Amr Abdel-Moghny
4203 static s32
Handle_AddBASession(tstrWILC_WFIDrv
*drvHandler
, tstrHostIfBASessionInfo
*strHostIfBASessionInfo
)
4205 s32 s32Error
= WILC_SUCCESS
;
4207 int AddbaTimeout
= 100;
4209 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
4211 PRINT_D(HOSTINF_DBG
, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\nBufferSize == %d\nSessionTimeOut = %d\n",
4212 strHostIfBASessionInfo
->au8Bssid
[0],
4213 strHostIfBASessionInfo
->au8Bssid
[1],
4214 strHostIfBASessionInfo
->au8Bssid
[2],
4215 strHostIfBASessionInfo
->u16BufferSize
,
4216 strHostIfBASessionInfo
->u16SessionTimeout
,
4217 strHostIfBASessionInfo
->u8Ted
);
4219 strWID
.u16WIDid
= (u16
)WID_11E_P_ACTION_REQ
;
4220 strWID
.enuWIDtype
= WID_STR
;
4221 strWID
.ps8WidVal
= kmalloc(BLOCK_ACK_REQ_SIZE
, GFP_KERNEL
);
4222 strWID
.s32ValueSize
= BLOCK_ACK_REQ_SIZE
;
4223 ptr
= strWID
.ps8WidVal
;
4224 /* *ptr++ = 0x14; */
4228 memcpy(ptr
, strHostIfBASessionInfo
->au8Bssid
, ETH_ALEN
);
4230 *ptr
++ = strHostIfBASessionInfo
->u8Ted
;
4234 *ptr
++ = (strHostIfBASessionInfo
->u16BufferSize
& 0xFF);
4235 *ptr
++ = ((strHostIfBASessionInfo
->u16BufferSize
>> 16) & 0xFF);
4237 *ptr
++ = (strHostIfBASessionInfo
->u16SessionTimeout
& 0xFF);
4238 *ptr
++ = ((strHostIfBASessionInfo
->u16SessionTimeout
>> 16) & 0xFF);
4240 *ptr
++ = (AddbaTimeout
& 0xFF);
4241 *ptr
++ = ((AddbaTimeout
>> 16) & 0xFF);
4242 /* Group Buffer Max Frames*/
4244 /* Group Buffer Timeout */
4247 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
4248 get_id_from_handler(pstrWFIDrv
));
4250 PRINT_D(HOSTINF_DBG
, "Couldn't open BA Session\n");
4253 strWID
.u16WIDid
= (u16
)WID_11E_P_ACTION_REQ
;
4254 strWID
.enuWIDtype
= WID_STR
;
4255 strWID
.s32ValueSize
= 15;
4256 ptr
= strWID
.ps8WidVal
;
4257 /* *ptr++ = 0x14; */
4261 memcpy(ptr
, strHostIfBASessionInfo
->au8Bssid
, ETH_ALEN
);
4264 *ptr
++ = strHostIfBASessionInfo
->u8Ted
;
4268 *ptr
++ = (strHostIfBASessionInfo
->u16BufferSize
& 0xFF);
4269 *ptr
++ = ((strHostIfBASessionInfo
->u16SessionTimeout
>> 16) & 0xFF);
4272 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
4273 get_id_from_handler(pstrWFIDrv
));
4275 if (strWID
.ps8WidVal
!= NULL
)
4276 kfree(strWID
.ps8WidVal
);
4285 * @brief Handle_DelBASession
4286 * @details Delete block ack session
4287 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4289 * @author Amr Abdel-Moghny
4293 static s32
Handle_DelBASession(tstrWILC_WFIDrv
*drvHandler
, tstrHostIfBASessionInfo
*strHostIfBASessionInfo
)
4295 s32 s32Error
= WILC_SUCCESS
;
4298 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
4300 PRINT_D(GENERIC_DBG
, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
4301 strHostIfBASessionInfo
->au8Bssid
[0],
4302 strHostIfBASessionInfo
->au8Bssid
[1],
4303 strHostIfBASessionInfo
->au8Bssid
[2],
4304 strHostIfBASessionInfo
->u8Ted
);
4306 strWID
.u16WIDid
= (u16
)WID_11E_P_ACTION_REQ
;
4307 strWID
.enuWIDtype
= WID_STR
;
4308 strWID
.ps8WidVal
= kmalloc(BLOCK_ACK_REQ_SIZE
, GFP_KERNEL
);
4309 strWID
.s32ValueSize
= BLOCK_ACK_REQ_SIZE
;
4310 ptr
= strWID
.ps8WidVal
;
4311 /* *ptr++ = 0x14; */
4315 memcpy(ptr
, strHostIfBASessionInfo
->au8Bssid
, ETH_ALEN
);
4317 *ptr
++ = strHostIfBASessionInfo
->u8Ted
;
4318 /* BA direction = recipent*/
4321 *ptr
++ = 32; /* Unspecific QOS reason */
4323 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
4324 get_id_from_handler(pstrWFIDrv
));
4326 PRINT_D(HOSTINF_DBG
, "Couldn't delete BA Session\n");
4329 strWID
.u16WIDid
= (u16
)WID_11E_P_ACTION_REQ
;
4330 strWID
.enuWIDtype
= WID_STR
;
4331 strWID
.s32ValueSize
= 15;
4332 ptr
= strWID
.ps8WidVal
;
4333 /* *ptr++ = 0x14; */
4337 memcpy(ptr
, strHostIfBASessionInfo
->au8Bssid
, ETH_ALEN
);
4340 *ptr
++ = strHostIfBASessionInfo
->u8Ted
;
4342 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
4343 get_id_from_handler(pstrWFIDrv
));
4345 if (strWID
.ps8WidVal
!= NULL
)
4346 kfree(strWID
.ps8WidVal
);
4357 * @brief Handle_DelAllRxBASessions
4358 * @details Delete all Rx BA sessions
4359 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4361 * @author Abdelrahman Sobhy
4365 static s32
Handle_DelAllRxBASessions(tstrWILC_WFIDrv
*drvHandler
, tstrHostIfBASessionInfo
*strHostIfBASessionInfo
)
4367 s32 s32Error
= WILC_SUCCESS
;
4370 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
4372 PRINT_D(GENERIC_DBG
, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
4373 strHostIfBASessionInfo
->au8Bssid
[0],
4374 strHostIfBASessionInfo
->au8Bssid
[1],
4375 strHostIfBASessionInfo
->au8Bssid
[2],
4376 strHostIfBASessionInfo
->u8Ted
);
4378 strWID
.u16WIDid
= (u16
)WID_DEL_ALL_RX_BA
;
4379 strWID
.enuWIDtype
= WID_STR
;
4380 strWID
.ps8WidVal
= kmalloc(BLOCK_ACK_REQ_SIZE
, GFP_KERNEL
);
4381 strWID
.s32ValueSize
= BLOCK_ACK_REQ_SIZE
;
4382 ptr
= strWID
.ps8WidVal
;
4386 memcpy(ptr
, strHostIfBASessionInfo
->au8Bssid
, ETH_ALEN
);
4388 *ptr
++ = strHostIfBASessionInfo
->u8Ted
;
4389 /* BA direction = recipent*/
4392 *ptr
++ = 32; /* Unspecific QOS reason */
4394 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
4395 get_id_from_handler(pstrWFIDrv
));
4397 PRINT_D(HOSTINF_DBG
, "Couldn't delete BA Session\n");
4400 if (strWID
.ps8WidVal
!= NULL
)
4401 kfree(strWID
.ps8WidVal
);
4411 * @brief hostIFthread
4412 * @details Main thread to handle message queue requests
4413 * @param[in] void* pvArg
4419 static int hostIFthread(void *pvArg
)
4422 tstrHostIFmsg strHostIFmsg
;
4423 tstrWILC_WFIDrv
*pstrWFIDrv
;
4425 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4428 wilc_mq_recv(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), &u32Ret
);
4429 pstrWFIDrv
= (tstrWILC_WFIDrv
*)strHostIFmsg
.drvHandler
;
4430 if (strHostIFmsg
.u16MsgId
== HOST_IF_MSG_EXIT
) {
4431 PRINT_D(GENERIC_DBG
, "THREAD: Exiting HostIfThread\n");
4436 /*Re-Queue HIF message*/
4437 if ((!g_wilc_initialized
)) {
4438 PRINT_D(GENERIC_DBG
, "--WAIT--");
4439 usleep_range(200 * 1000, 200 * 1000);
4440 wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
4444 if (strHostIFmsg
.u16MsgId
== HOST_IF_MSG_CONNECT
&& pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
!= NULL
) {
4445 PRINT_D(HOSTINF_DBG
, "Requeue connect request till scan done received\n");
4446 wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
4447 usleep_range(2 * 1000, 2 * 1000);
4451 switch (strHostIFmsg
.u16MsgId
) {
4452 case HOST_IF_MSG_Q_IDLE
:
4453 Handle_wait_msg_q_empty();
4456 case HOST_IF_MSG_SCAN
:
4457 Handle_Scan(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
);
4460 case HOST_IF_MSG_CONNECT
:
4461 Handle_Connect(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
);
4465 case HOST_IF_MSG_FLUSH_CONNECT
:
4466 Handle_FlushConnect(strHostIFmsg
.drvHandler
);
4469 case HOST_IF_MSG_RCVD_NTWRK_INFO
:
4470 Handle_RcvdNtwrkInfo(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strRcvdNetworkInfo
);
4473 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO
:
4474 Handle_RcvdGnrlAsyncInfo(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strRcvdGnrlAsyncInfo
);
4477 case HOST_IF_MSG_KEY
:
4478 Handle_Key(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
);
4481 case HOST_IF_MSG_CFG_PARAMS
:
4483 Handle_CfgParam(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIFCfgParamAttr
);
4486 case HOST_IF_MSG_SET_CHANNEL
:
4487 Handle_SetChannel(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIFSetChan
);
4490 case HOST_IF_MSG_DISCONNECT
:
4491 Handle_Disconnect(strHostIFmsg
.drvHandler
);
4494 case HOST_IF_MSG_RCVD_SCAN_COMPLETE
:
4495 del_timer(&pstrWFIDrv
->hScanTimer
);
4496 PRINT_D(HOSTINF_DBG
, "scan completed successfully\n");
4499 /*Allow chip sleep, only if both interfaces are not connected*/
4500 if (!linux_wlan_get_num_conn_ifcs())
4501 chip_sleep_manually(INFINITE_SLEEP_TIME
);
4503 Handle_ScanDone(strHostIFmsg
.drvHandler
, SCAN_EVENT_DONE
);
4506 if (pstrWFIDrv
->u8RemainOnChan_pendingreq
)
4507 Handle_RemainOnChan(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
);
4512 case HOST_IF_MSG_GET_RSSI
:
4513 Handle_GetRssi(strHostIFmsg
.drvHandler
);
4516 case HOST_IF_MSG_GET_LINKSPEED
:
4517 Handle_GetLinkspeed(strHostIFmsg
.drvHandler
);
4520 case HOST_IF_MSG_GET_STATISTICS
:
4521 Handle_GetStatistics(strHostIFmsg
.drvHandler
, (tstrStatistics
*)strHostIFmsg
.uniHostIFmsgBody
.pUserData
);
4524 case HOST_IF_MSG_GET_CHNL
:
4525 Handle_GetChnl(strHostIFmsg
.drvHandler
);
4528 #ifdef WILC_AP_EXTERNAL_MLME
4529 case HOST_IF_MSG_ADD_BEACON
:
4530 Handle_AddBeacon(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIFSetBeacon
);
4533 case HOST_IF_MSG_DEL_BEACON
:
4534 Handle_DelBeacon(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIFDelBeacon
);
4537 case HOST_IF_MSG_ADD_STATION
:
4538 Handle_AddStation(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strAddStaParam
);
4541 case HOST_IF_MSG_DEL_STATION
:
4542 Handle_DelStation(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strDelStaParam
);
4545 case HOST_IF_MSG_EDIT_STATION
:
4546 Handle_EditStation(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strEditStaParam
);
4549 case HOST_IF_MSG_GET_INACTIVETIME
:
4550 Handle_Get_InActiveTime(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfStaInactiveT
);
4553 #endif /*WILC_AP_EXTERNAL_MLME*/
4554 case HOST_IF_MSG_SCAN_TIMER_FIRED
:
4555 PRINT_D(HOSTINF_DBG
, "Scan Timeout\n");
4557 Handle_ScanDone(strHostIFmsg
.drvHandler
, SCAN_EVENT_ABORTED
);
4560 case HOST_IF_MSG_CONNECT_TIMER_FIRED
:
4561 PRINT_D(HOSTINF_DBG
, "Connect Timeout\n");
4562 Handle_ConnectTimeout(strHostIFmsg
.drvHandler
);
4565 case HOST_IF_MSG_POWER_MGMT
:
4566 Handle_PowerManagement(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strPowerMgmtparam
);
4569 case HOST_IF_MSG_SET_WFIDRV_HANDLER
:
4570 Handle_SetWfiDrvHandler(strHostIFmsg
.drvHandler
,
4571 &strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetDrvHandler
);
4574 case HOST_IF_MSG_SET_OPERATION_MODE
:
4575 Handle_SetOperationMode(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetOperationMode
);
4578 case HOST_IF_MSG_SET_IPADDRESS
:
4579 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_SET_IPADDRESS\n");
4580 Handle_set_IPAddress(strHostIFmsg
.drvHandler
, strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.au8IPAddr
, strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.idx
);
4583 case HOST_IF_MSG_GET_IPADDRESS
:
4584 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_SET_IPADDRESS\n");
4585 Handle_get_IPAddress(strHostIFmsg
.drvHandler
, strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.au8IPAddr
, strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.idx
);
4589 case HOST_IF_MSG_SET_MAC_ADDRESS
:
4590 Handle_SetMacAddress(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetMacAddress
);
4594 case HOST_IF_MSG_GET_MAC_ADDRESS
:
4595 Handle_GetMacAddress(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfGetMacAddress
);
4599 case HOST_IF_MSG_REMAIN_ON_CHAN
:
4600 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
4601 Handle_RemainOnChan(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
);
4604 case HOST_IF_MSG_REGISTER_FRAME
:
4605 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_REGISTER_FRAME\n");
4606 Handle_RegisterFrame(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfRegisterFrame
);
4609 case HOST_IF_MSG_LISTEN_TIMER_FIRED
:
4610 Handle_ListenStateExpired(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
);
4614 case HOST_IF_MSG_SET_MULTICAST_FILTER
:
4615 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
4616 Handle_SetMulticastFilter(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetMulti
);
4620 case HOST_IF_MSG_ADD_BA_SESSION
:
4621 Handle_AddBASession(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfBASessionInfo
);
4624 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS
:
4625 Handle_DelAllRxBASessions(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfBASessionInfo
);
4628 case HOST_IF_MSG_DEL_ALL_STA
:
4629 Handle_DelAllSta(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIFDelAllSta
);
4633 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
4638 PRINT_D(HOSTINF_DBG
, "Releasing thread exit semaphore\n");
4639 up(&hSemHostIFthrdEnd
);
4643 static void TimerCB_Scan(unsigned long arg
)
4645 void *pvArg
= (void *)arg
;
4646 tstrHostIFmsg strHostIFmsg
;
4648 /* prepare the Timer Callback message */
4649 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4650 strHostIFmsg
.drvHandler
= pvArg
;
4651 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SCAN_TIMER_FIRED
;
4653 /* send the message */
4654 wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
4657 static void TimerCB_Connect(unsigned long arg
)
4659 void *pvArg
= (void *)arg
;
4660 tstrHostIFmsg strHostIFmsg
;
4662 /* prepare the Timer Callback message */
4663 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4664 strHostIFmsg
.drvHandler
= pvArg
;
4665 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_CONNECT_TIMER_FIRED
;
4667 /* send the message */
4668 wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
4673 * @brief removes wpa/wpa2 keys
4674 * @details only in BSS STA mode if External Supplicant support is enabled.
4675 * removes all WPA/WPA2 station key entries from MAC hardware.
4676 * @param[in,out] handle to the wifi driver
4677 * @param[in] 6 bytes of Station Adress in the station entry table
4678 * @return Error code indicating success/failure
4681 * @date 8 March 2012
4684 /* Check implementation in core adding 9 bytes to the input! */
4685 s32
host_int_remove_key(tstrWILC_WFIDrv
*hWFIDrv
, const u8
*pu8StaAddress
)
4687 s32 s32Error
= WILC_SUCCESS
;
4689 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4691 strWID
.u16WIDid
= (u16
)WID_REMOVE_KEY
;
4692 strWID
.enuWIDtype
= WID_STR
;
4693 strWID
.ps8WidVal
= (s8
*)pu8StaAddress
;
4694 strWID
.s32ValueSize
= 6;
4701 * @brief removes WEP key
4702 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4703 * remove a WEP key entry from MAC HW.
4704 * The BSS Station automatically finds the index of the entry using its
4705 * BSS ID and removes that entry from the MAC hardware.
4706 * @param[in,out] handle to the wifi driver
4707 * @param[in] 6 bytes of Station Adress in the station entry table
4708 * @return Error code indicating success/failure
4709 * @note NO need for the STA add since it is not used for processing
4711 * @date 8 March 2012
4714 s32
host_int_remove_wep_key(tstrWILC_WFIDrv
*hWFIDrv
, u8 u8keyIdx
)
4716 s32 s32Error
= WILC_SUCCESS
;
4717 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
4718 tstrHostIFmsg strHostIFmsg
;
4721 if (pstrWFIDrv
== NULL
)
4722 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
4724 /* prepare the Remove Wep Key Message */
4725 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4728 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
4729 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= WEP
;
4730 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= REMOVEKEY
;
4731 strHostIFmsg
.drvHandler
= hWFIDrv
;
4735 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4736 uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
= u8keyIdx
;
4738 /* send the message */
4739 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
4741 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
4742 down(&(pstrWFIDrv
->hSemTestKeyBlock
));
4744 WILC_CATCH(s32Error
)
4752 * @brief sets WEP default key
4753 * @details Sets the index of the WEP encryption key in use,
4755 * @param[in,out] handle to the wifi driver
4756 * @param[in] key index ( 0, 1, 2, 3)
4757 * @return Error code indicating success/failure
4760 * @date 8 March 2012
4763 s32
host_int_set_WEPDefaultKeyID(tstrWILC_WFIDrv
*hWFIDrv
, u8 u8Index
)
4765 s32 s32Error
= WILC_SUCCESS
;
4766 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
4767 tstrHostIFmsg strHostIFmsg
;
4770 if (pstrWFIDrv
== NULL
)
4771 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
4773 /* prepare the Key Message */
4774 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4777 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
4778 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= WEP
;
4779 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= DEFAULTKEY
;
4780 strHostIFmsg
.drvHandler
= hWFIDrv
;
4783 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4784 uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
= u8Index
;
4786 /* send the message */
4787 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
4789 PRINT_ER("Error in sending message queue : Default key index\n");
4790 down(&(pstrWFIDrv
->hSemTestKeyBlock
));
4792 WILC_CATCH(s32Error
)
4801 * @brief sets WEP deafault key
4802 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4803 * sets WEP key entry into MAC hardware when it receives the
4804 * corresponding request from NDIS.
4805 * @param[in,out] handle to the wifi driver
4806 * @param[in] message containing WEP Key in the following format
4807 *|---------------------------------------|
4808 *|Key ID Value | Key Length | Key |
4809 *|-------------|------------|------------|
4810 | 1byte | 1byte | Key Length |
4811 ||---------------------------------------|
4813 * @return Error code indicating success/failure
4816 * @date 8 March 2012
4819 s32
host_int_add_wep_key_bss_sta(tstrWILC_WFIDrv
*hWFIDrv
, const u8
*pu8WepKey
, u8 u8WepKeylen
, u8 u8Keyidx
)
4822 s32 s32Error
= WILC_SUCCESS
;
4823 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
4824 tstrHostIFmsg strHostIFmsg
;
4826 if (pstrWFIDrv
== NULL
)
4827 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
4830 /* prepare the Key Message */
4831 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4834 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
4835 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= WEP
;
4836 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY
;
4837 strHostIFmsg
.drvHandler
= hWFIDrv
;
4840 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4841 uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
= kmalloc(u8WepKeylen
, GFP_KERNEL
);
4843 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
,
4844 pu8WepKey
, u8WepKeylen
);
4847 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4848 uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
= (u8WepKeylen
);
4850 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4851 uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
= u8Keyidx
;
4853 /* send the message */
4854 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
4856 PRINT_ER("Error in sending message queue :WEP Key\n");
4857 down(&(pstrWFIDrv
->hSemTestKeyBlock
));
4859 WILC_CATCH(s32Error
)
4867 #ifdef WILC_AP_EXTERNAL_MLME
4870 * @brief host_int_add_wep_key_bss_ap
4871 * @details valid only in BSS AP mode if External Supplicant support is enabled.
4872 * sets WEP key entry into MAC hardware when it receives the
4874 * corresponding request from NDIS.
4875 * @param[in,out] handle to the wifi driver
4878 * @return Error code indicating success/failure
4884 s32
host_int_add_wep_key_bss_ap(tstrWILC_WFIDrv
*hWFIDrv
, const u8
*pu8WepKey
, u8 u8WepKeylen
, u8 u8Keyidx
, u8 u8mode
, AUTHTYPE_T tenuAuth_type
)
4887 s32 s32Error
= WILC_SUCCESS
;
4888 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
4889 tstrHostIFmsg strHostIFmsg
;
4892 if (pstrWFIDrv
== NULL
)
4893 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
4896 /* prepare the Key Message */
4897 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4900 for (i
= 0; i
< u8WepKeylen
; i
++)
4901 PRINT_INFO(HOSTAPD_DBG
, "KEY is %x\n", pu8WepKey
[i
]);
4903 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
4904 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= WEP
;
4905 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY_AP
;
4906 strHostIFmsg
.drvHandler
= hWFIDrv
;
4909 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4910 uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
= kmalloc(u8WepKeylen
, GFP_KERNEL
);
4913 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
,
4914 pu8WepKey
, (u8WepKeylen
));
4917 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4918 uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
= (u8WepKeylen
);
4920 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4921 uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
= u8Keyidx
;
4923 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4924 uniHostIFkeyAttr
.strHostIFwepAttr
.u8mode
= u8mode
;
4926 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4927 uniHostIFkeyAttr
.strHostIFwepAttr
.tenuAuth_type
= tenuAuth_type
;
4928 /* send the message */
4929 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
4932 PRINT_ER("Error in sending message queue :WEP Key\n");
4933 down(&(pstrWFIDrv
->hSemTestKeyBlock
));
4935 WILC_CATCH(s32Error
)
4944 * @brief adds ptk Key
4946 * @param[in,out] handle to the wifi driver
4947 * @param[in] message containing PTK Key in the following format
4948 *|-----------------------------------------------------------------------------|
4949 *|Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
4950 *|----------------|------------|--------------|----------------|---------------|
4951 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
4952 ||-----------------------------------------------------------------------------|
4953 * @return Error code indicating success/failure
4956 * @date 8 March 2012
4959 s32
host_int_add_ptk(tstrWILC_WFIDrv
*hWFIDrv
, const u8
*pu8Ptk
, u8 u8PtkKeylen
,
4960 const u8
*mac_addr
, const u8
*pu8RxMic
, const u8
*pu8TxMic
, u8 mode
, u8 u8Ciphermode
, u8 u8Idx
)
4962 s32 s32Error
= WILC_SUCCESS
;
4963 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
4964 tstrHostIFmsg strHostIFmsg
;
4965 u8 u8KeyLen
= u8PtkKeylen
;
4968 if (pstrWFIDrv
== NULL
)
4969 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
4970 if (pu8RxMic
!= NULL
)
4971 u8KeyLen
+= RX_MIC_KEY_LEN
;
4972 if (pu8TxMic
!= NULL
)
4973 u8KeyLen
+= TX_MIC_KEY_LEN
;
4975 /* prepare the Key Message */
4976 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4979 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
4980 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= WPAPtk
;
4981 #ifdef WILC_AP_EXTERNAL_MLME
4982 if (mode
== AP_MODE
) {
4983 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY_AP
;
4984 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4985 uniHostIFkeyAttr
.strHostIFwpaAttr
.u8keyidx
= u8Idx
;
4988 if (mode
== STATION_MODE
)
4989 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY
;
4992 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4993 uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
= kmalloc(u8PtkKeylen
, GFP_KERNEL
);
4996 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
,
4997 pu8Ptk
, u8PtkKeylen
);
4999 if (pu8RxMic
!= NULL
) {
5001 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
+ 16,
5002 pu8RxMic
, RX_MIC_KEY_LEN
);
5004 for (i
= 0; i
< RX_MIC_KEY_LEN
; i
++)
5005 PRINT_INFO(CFG80211_DBG
, "PairwiseRx[%d] = %x\n", i
, pu8RxMic
[i
]);
5008 if (pu8TxMic
!= NULL
) {
5010 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
+ 24,
5011 pu8TxMic
, TX_MIC_KEY_LEN
);
5013 for (i
= 0; i
< TX_MIC_KEY_LEN
; i
++)
5014 PRINT_INFO(CFG80211_DBG
, "PairwiseTx[%d] = %x\n", i
, pu8TxMic
[i
]);
5018 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
5019 uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
= u8KeyLen
;
5021 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
5022 uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Ciphermode
= u8Ciphermode
;
5023 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
5024 uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8macaddr
= mac_addr
;
5025 strHostIFmsg
.drvHandler
= hWFIDrv
;
5027 /* send the message */
5028 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5031 PRINT_ER("Error in sending message queue: PTK Key\n");
5033 /* ////////////// */
5034 down(&(pstrWFIDrv
->hSemTestKeyBlock
));
5037 WILC_CATCH(s32Error
)
5046 * @brief adds Rx GTk Key
5048 * @param[in,out] handle to the wifi driver
5049 * @param[in] pu8RxGtk : contains temporal key | Rx Mic | Tx Mic
5050 * u8GtkKeylen :The total key length
5052 * @return Error code indicating success/failure
5055 * @date 8 March 2012
5058 s32
host_int_add_rx_gtk(tstrWILC_WFIDrv
*hWFIDrv
, const u8
*pu8RxGtk
, u8 u8GtkKeylen
,
5059 u8 u8KeyIdx
, u32 u32KeyRSClen
, const u8
*KeyRSC
,
5060 const u8
*pu8RxMic
, const u8
*pu8TxMic
, u8 mode
, u8 u8Ciphermode
)
5062 s32 s32Error
= WILC_SUCCESS
;
5063 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5064 tstrHostIFmsg strHostIFmsg
;
5065 u8 u8KeyLen
= u8GtkKeylen
;
5067 if (pstrWFIDrv
== NULL
)
5068 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5069 /* prepare the Key Message */
5070 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5073 if (pu8RxMic
!= NULL
)
5074 u8KeyLen
+= RX_MIC_KEY_LEN
;
5075 if (pu8TxMic
!= NULL
)
5076 u8KeyLen
+= TX_MIC_KEY_LEN
;
5077 if (KeyRSC
!= NULL
) {
5078 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
5079 uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8seq
= kmalloc(u32KeyRSClen
, GFP_KERNEL
);
5081 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8seq
,
5082 KeyRSC
, u32KeyRSClen
);
5086 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
5087 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= WPARxGtk
;
5088 strHostIFmsg
.drvHandler
= hWFIDrv
;
5090 #ifdef WILC_AP_EXTERNAL_MLME
5091 if (mode
== AP_MODE
) {
5092 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY_AP
;
5093 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Ciphermode
= u8Ciphermode
;
5096 if (mode
== STATION_MODE
)
5097 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY
;
5100 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
5101 uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
= kmalloc(u8KeyLen
, GFP_KERNEL
);
5103 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
,
5104 pu8RxGtk
, u8GtkKeylen
);
5106 if (pu8RxMic
!= NULL
) {
5108 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
+ 16,
5109 pu8RxMic
, RX_MIC_KEY_LEN
);
5112 if (pu8TxMic
!= NULL
) {
5114 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
+ 24,
5115 pu8TxMic
, TX_MIC_KEY_LEN
);
5119 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
5120 uniHostIFkeyAttr
.strHostIFwpaAttr
.u8keyidx
= u8KeyIdx
;
5121 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
5122 uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
= u8KeyLen
;
5124 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
5125 uniHostIFkeyAttr
.strHostIFwpaAttr
.u8seqlen
= u32KeyRSClen
;
5129 /* send the message */
5130 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5132 PRINT_ER("Error in sending message queue: RX GTK\n");
5133 /* ////////////// */
5134 down(&(pstrWFIDrv
->hSemTestKeyBlock
));
5137 WILC_CATCH(s32Error
)
5145 * @brief host_int_set_pmkid_info
5146 * @details caches the pmkid valid only in BSS STA mode if External Supplicant
5147 * support is enabled. This Function sets the PMKID in firmware
5148 * when host drivr receives the corresponding request from NDIS.
5149 * The firmware then includes theset PMKID in the appropriate
5151 * @param[in,out] handle to the wifi driver
5152 * @param[in] message containing PMKID Info in the following format
5153 *|-----------------------------------------------------------------|
5154 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
5155 *|-----------|------------|----------|-------|----------|----------|
5156 | 1 | 6 | 16 | ... | 6 | 16 |
5157 ||-----------------------------------------------------------------|
5158 * @return Error code indicating success/failure
5161 * @date 8 March 2012
5164 s32
host_int_set_pmkid_info(tstrWILC_WFIDrv
*hWFIDrv
, tstrHostIFpmkidAttr
*pu8PmkidInfoArray
)
5166 s32 s32Error
= WILC_SUCCESS
;
5167 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5168 tstrHostIFmsg strHostIFmsg
;
5172 if (pstrWFIDrv
== NULL
)
5173 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5175 /* prepare the Key Message */
5176 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5178 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
5179 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= PMKSA
;
5180 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY
;
5181 strHostIFmsg
.drvHandler
= hWFIDrv
;
5183 for (i
= 0; i
< pu8PmkidInfoArray
->numpmkid
; i
++) {
5185 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFpmkidAttr
.pmkidlist
[i
].bssid
, &pu8PmkidInfoArray
->pmkidlist
[i
].bssid
,
5188 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFpmkidAttr
.pmkidlist
[i
].pmkid
, &pu8PmkidInfoArray
->pmkidlist
[i
].pmkid
,
5192 /* send the message */
5193 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5195 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
5197 WILC_CATCH(s32Error
)
5206 * @brief gets the cached the pmkid info
5207 * @details valid only in BSS STA mode if External Supplicant
5208 * support is enabled. This Function sets the PMKID in firmware
5209 * when host drivr receives the corresponding request from NDIS.
5210 * The firmware then includes theset PMKID in the appropriate
5212 * @param[in,out] handle to the wifi driver,
5213 * message containing PMKID Info in the following format
5214 *|-----------------------------------------------------------------|
5215 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
5216 *|-----------|------------|----------|-------|----------|----------|
5217 | 1 | 6 | 16 | ... | 6 | 16 |
5218 ||-----------------------------------------------------------------|
5220 * @return Error code indicating success/failure
5223 * @date 8 March 2012
5226 s32
host_int_get_pmkid_info(tstrWILC_WFIDrv
*hWFIDrv
, u8
*pu8PmkidInfoArray
,
5227 u32 u32PmkidInfoLen
)
5229 s32 s32Error
= WILC_SUCCESS
;
5231 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5233 strWID
.u16WIDid
= (u16
)WID_PMKID_INFO
;
5234 strWID
.enuWIDtype
= WID_STR
;
5235 strWID
.s32ValueSize
= u32PmkidInfoLen
;
5236 strWID
.ps8WidVal
= pu8PmkidInfoArray
;
5242 * @brief sets the pass phrase
5243 * @details AP/STA mode. This function gives the pass phrase used to
5244 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5245 * The length of the field can vary from 8 to 64 bytes,
5246 * the lower layer should get the
5247 * @param[in,out] handle to the wifi driver,
5248 * @param[in] String containing PSK
5249 * @return Error code indicating success/failure
5252 * @date 8 March 2012
5255 s32
host_int_set_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv
*hWFIDrv
, u8
*pu8PassPhrase
,
5258 s32 s32Error
= WILC_SUCCESS
;
5261 /*validating psk length*/
5262 if ((u8Psklength
> 7) && (u8Psklength
< 65)) {
5263 strWID
.u16WIDid
= (u16
)WID_11I_PSK
;
5264 strWID
.enuWIDtype
= WID_STR
;
5265 strWID
.ps8WidVal
= pu8PassPhrase
;
5266 strWID
.s32ValueSize
= u8Psklength
;
5272 * @brief host_int_get_MacAddress
5273 * @details gets mac address
5274 * @param[in,out] handle to the wifi driver,
5276 * @return Error code indicating success/failure
5279 * @date 19 April 2012
5282 s32
host_int_get_MacAddress(tstrWILC_WFIDrv
*hWFIDrv
, u8
*pu8MacAddress
)
5284 s32 s32Error
= WILC_SUCCESS
;
5285 tstrHostIFmsg strHostIFmsg
;
5288 /* prepare the Message */
5289 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5291 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_MAC_ADDRESS
;
5292 strHostIFmsg
.uniHostIFmsgBody
.strHostIfGetMacAddress
.u8MacAddress
= pu8MacAddress
;
5293 strHostIFmsg
.drvHandler
= hWFIDrv
;
5294 /* send the message */
5295 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5297 PRINT_ER("Failed to send get mac address\n");
5301 down(&hWaitResponse
);
5306 * @brief host_int_set_MacAddress
5307 * @details sets mac address
5308 * @param[in,out] handle to the wifi driver,
5310 * @return Error code indicating success/failure
5313 * @date 16 July 2012
5316 s32
host_int_set_MacAddress(tstrWILC_WFIDrv
*hWFIDrv
, u8
*pu8MacAddress
)
5318 s32 s32Error
= WILC_SUCCESS
;
5319 tstrHostIFmsg strHostIFmsg
;
5321 PRINT_D(GENERIC_DBG
, "mac addr = %x:%x:%x\n", pu8MacAddress
[0], pu8MacAddress
[1], pu8MacAddress
[2]);
5323 /* prepare setting mac address message */
5324 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5325 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SET_MAC_ADDRESS
;
5326 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetMacAddress
.u8MacAddress
, pu8MacAddress
, ETH_ALEN
);
5327 strHostIFmsg
.drvHandler
= hWFIDrv
;
5329 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5331 PRINT_ER("Failed to send message queue: Set mac address\n");
5332 WILC_ERRORREPORT(s32Error
, s32Error
);
5334 WILC_CATCH(s32Error
)
5344 * @brief host_int_get_RSNAConfigPSKPassPhrase
5345 * @details gets the pass phrase:AP/STA mode. This function gets the pass phrase used to
5346 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5347 * The length of the field can vary from 8 to 64 bytes,
5348 * the lower layer should get the
5349 * @param[in,out] handle to the wifi driver,
5350 * String containing PSK
5351 * @return Error code indicating success/failure
5354 * @date 8 March 2012
5357 s32
host_int_get_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv
*hWFIDrv
,
5358 u8
*pu8PassPhrase
, u8 u8Psklength
)
5360 s32 s32Error
= WILC_SUCCESS
;
5362 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5364 strWID
.u16WIDid
= (u16
)WID_11I_PSK
;
5365 strWID
.enuWIDtype
= WID_STR
;
5366 strWID
.s32ValueSize
= u8Psklength
;
5367 strWID
.ps8WidVal
= pu8PassPhrase
;
5373 * @brief host_int_get_site_survey_results
5374 * @details gets the site survey results
5375 * @param[in,out] handle to the wifi driver,
5376 * Message containing site survey results in the
5378 *|---------------------------------------------------|
5379 | MsgLength | fragNo. | MsgBodyLength | MsgBody |
5380 ||-----------|-----------|---------------|-----------|
5382 | ----------------------------------------- | ----------------
5384 ||---------------------------------------|
5385 | Network1 | Netweork2 | ... | Network5 |
5386 ||---------------------------------------|
5387 | 44 | 44 | ... | 44 |
5388 | -------------------------- | ---------------------------------------
5390 ||---------------------------------------------------------------------|
5391 | SSID | BSS Type | Channel | Security Status| BSSID | RSSI |Reserved |
5394 ||------|----------|---------|----------------|-------|------|---------|
5395 | 33 | 1 | 1 | 1 | 6 | 1 | 1 |
5396 ||---------------------------------------------------------------------|
5397 * @return Error code indicating success/failure
5400 * @date 8 March 2012
5403 #ifndef CONNECT_DIRECT
5404 s32
host_int_get_site_survey_results(tstrWILC_WFIDrv
*hWFIDrv
,
5405 u8 ppu8RcvdSiteSurveyResults
[][MAX_SURVEY_RESULT_FRAG_SIZE
],
5406 u32 u32MaxSiteSrvyFragLen
)
5408 s32 s32Error
= WILC_SUCCESS
;
5409 tstrWID astrWIDList
[2];
5410 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5412 astrWIDList
[0].u16WIDid
= (u16
)WID_SITE_SURVEY_RESULTS
;
5413 astrWIDList
[0].enuWIDtype
= WID_STR
;
5414 astrWIDList
[0].ps8WidVal
= ppu8RcvdSiteSurveyResults
[0];
5415 astrWIDList
[0].s32ValueSize
= u32MaxSiteSrvyFragLen
;
5417 astrWIDList
[1].u16WIDid
= (u16
)WID_SITE_SURVEY_RESULTS
;
5418 astrWIDList
[1].enuWIDtype
= WID_STR
;
5419 astrWIDList
[1].ps8WidVal
= ppu8RcvdSiteSurveyResults
[1];
5420 astrWIDList
[1].s32ValueSize
= u32MaxSiteSrvyFragLen
;
5422 s32Error
= SendConfigPkt(GET_CFG
, astrWIDList
, 2, true,
5423 get_id_from_handler(pstrWFIDrv
));
5425 /*get the value by searching the local copy*/
5427 PRINT_ER("Failed to send config packet to get survey results\n");
5428 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
5431 WILC_CATCH(s32Error
)
5441 * @brief sets a start scan request
5443 * @param[in,out] handle to the wifi driver,
5444 * @param[in] Scan Source one of the following values
5447 * OBSS_PERIODIC_SCAN BIT1
5448 * OBSS_ONETIME_SCAN BIT2
5449 * @return Error code indicating success/failure
5452 * @date 8 March 2012
5455 s32
host_int_set_start_scan_req(tstrWILC_WFIDrv
*hWFIDrv
, u8 scanSource
)
5457 s32 s32Error
= WILC_SUCCESS
;
5459 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5461 strWID
.u16WIDid
= (u16
)WID_START_SCAN_REQ
;
5462 strWID
.enuWIDtype
= WID_CHAR
;
5463 strWID
.ps8WidVal
= (s8
*)&scanSource
;
5464 strWID
.s32ValueSize
= sizeof(char);
5470 * @brief host_int_get_start_scan_req
5471 * @details gets a start scan request
5472 * @param[in,out] handle to the wifi driver,
5473 * @param[in] Scan Source one of the following values
5476 * OBSS_PERIODIC_SCAN BIT1
5477 * OBSS_ONETIME_SCAN BIT2
5478 * @return Error code indicating success/failure
5481 * @date 8 March 2012
5485 s32
host_int_get_start_scan_req(tstrWILC_WFIDrv
*hWFIDrv
, u8
*pu8ScanSource
)
5487 s32 s32Error
= WILC_SUCCESS
;
5489 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5491 strWID
.u16WIDid
= (u16
)WID_START_SCAN_REQ
;
5492 strWID
.enuWIDtype
= WID_CHAR
;
5493 strWID
.ps8WidVal
= (s8
*)pu8ScanSource
;
5494 strWID
.s32ValueSize
= sizeof(char);
5500 * @brief host_int_set_join_req
5501 * @details sets a join request
5502 * @param[in,out] handle to the wifi driver,
5503 * @param[in] Index of the bss descriptor
5504 * @return Error code indicating success/failure
5507 * @date 8 March 2012
5510 s32
host_int_set_join_req(tstrWILC_WFIDrv
*hWFIDrv
, u8
*pu8bssid
,
5511 const u8
*pu8ssid
, size_t ssidLen
,
5512 const u8
*pu8IEs
, size_t IEsLen
,
5513 tWILCpfConnectResult pfConnectResult
, void *pvUserArg
,
5514 u8 u8security
, AUTHTYPE_T tenuAuth_type
,
5518 s32 s32Error
= WILC_SUCCESS
;
5519 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5520 tstrHostIFmsg strHostIFmsg
;
5521 tenuScanConnTimer enuScanConnTimer
;
5523 if (pstrWFIDrv
== NULL
|| pfConnectResult
== NULL
)
5524 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5526 if (hWFIDrv
== NULL
) {
5527 PRINT_ER("Driver not initialized: gWFiDrvHandle = NULL\n");
5528 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
5531 if (pJoinParams
== NULL
) {
5532 PRINT_ER("Unable to Join - JoinParams is NULL\n");
5533 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
5537 * if(gWFiDrvHandle->strWILC_UsrScanReq.u32RcvdChCount == 0)
5539 * PRINT_ER("No scan results exist: Scanning should be done\n");
5540 * WILC_ERRORREPORT(s32Error, WILC_FAIL);
5543 /* prepare the Connect Message */
5544 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5546 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_CONNECT
;
5548 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.u8security
= u8security
;
5549 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.tenuAuth_type
= tenuAuth_type
;
5550 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.u8channel
= u8channel
;
5551 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pfConnectResult
= pfConnectResult
;
5552 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pvUserArg
= pvUserArg
;
5553 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pJoinParams
= pJoinParams
;
5554 strHostIFmsg
.drvHandler
= hWFIDrv
;
5556 if (pu8bssid
!= NULL
) {
5557 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pu8bssid
= kmalloc(6, GFP_KERNEL
); /* will be deallocated by the receiving thread */
5558 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pu8bssid
,
5562 if (pu8ssid
!= NULL
) {
5563 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.ssidLen
= ssidLen
;
5564 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pu8ssid
= kmalloc(ssidLen
, GFP_KERNEL
); /* will be deallocated by the receiving thread */
5565 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pu8ssid
,
5570 if (pu8IEs
!= NULL
) {
5571 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.IEsLen
= IEsLen
;
5572 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pu8IEs
= kmalloc(IEsLen
, GFP_KERNEL
); /* will be deallocated by the receiving thread */
5573 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pu8IEs
,
5576 if (pstrWFIDrv
->enuHostIFstate
< HOST_IF_CONNECTING
)
5577 pstrWFIDrv
->enuHostIFstate
= HOST_IF_CONNECTING
;
5579 PRINT_D(GENERIC_DBG
, "Don't set state to 'connecting' as state is %d\n", pstrWFIDrv
->enuHostIFstate
);
5581 /* send the message */
5582 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5584 PRINT_ER("Failed to send message queue: Set join request\n");
5585 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
5588 enuScanConnTimer
= CONNECT_TIMER
;
5589 pstrWFIDrv
->hConnectTimer
.data
= (unsigned long)hWFIDrv
;
5590 mod_timer(&pstrWFIDrv
->hConnectTimer
,
5591 jiffies
+ msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT
));
5593 WILC_CATCH(s32Error
)
5602 * @brief Flush a join request parameters to FW, but actual connection
5603 * @details The function is called in situation where WILC is connected to AP and
5604 * required to switch to hybrid FW for P2P connection
5605 * @param[in] handle to the wifi driver,
5606 * @return Error code indicating success/failure
5608 * @author Amr Abdel-Moghny
5613 s32
host_int_flush_join_req(tstrWILC_WFIDrv
*hWFIDrv
)
5615 s32 s32Error
= WILC_SUCCESS
;
5616 tstrHostIFmsg strHostIFmsg
;
5618 if (!gu8FlushedJoinReq
) {
5619 s32Error
= WILC_FAIL
;
5624 if (hWFIDrv
== NULL
)
5625 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5628 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_FLUSH_CONNECT
;
5629 strHostIFmsg
.drvHandler
= hWFIDrv
;
5631 /* send the message */
5632 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5634 PRINT_ER("Failed to send message queue: Flush join request\n");
5635 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
5638 WILC_CATCH(s32Error
)
5646 * @brief host_int_disconnect
5647 * @details disconnects from the currently associated network
5648 * @param[in,out] handle to the wifi driver,
5649 * @param[in] Reason Code of the Disconnection
5650 * @return Error code indicating success/failure
5653 * @date 8 March 2012
5656 s32
host_int_disconnect(tstrWILC_WFIDrv
*hWFIDrv
, u16 u16ReasonCode
)
5658 s32 s32Error
= WILC_SUCCESS
;
5659 tstrHostIFmsg strHostIFmsg
;
5660 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5662 if (pstrWFIDrv
== NULL
) {
5663 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
5664 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5667 if (pstrWFIDrv
== NULL
) {
5668 PRINT_ER("gWFiDrvHandle = NULL\n");
5669 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
5672 /* prepare the Disconnect Message */
5673 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5675 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_DISCONNECT
;
5676 strHostIFmsg
.drvHandler
= hWFIDrv
;
5678 /* send the message */
5679 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5681 PRINT_ER("Failed to send message queue: disconnect\n");
5682 /* ////////////// */
5683 down(&(pstrWFIDrv
->hSemTestDisconnectBlock
));
5686 WILC_CATCH(s32Error
)
5695 * @brief host_int_disconnect_station
5696 * @details disconnects a sta
5697 * @param[in,out] handle to the wifi driver,
5698 * @param[in] Association Id of the station to be disconnected
5699 * @return Error code indicating success/failure
5702 * @date 8 March 2012
5705 s32
host_int_disconnect_station(tstrWILC_WFIDrv
*hWFIDrv
, u8 assoc_id
)
5707 s32 s32Error
= WILC_SUCCESS
;
5709 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5711 strWID
.u16WIDid
= (u16
)WID_DISCONNECT
;
5712 strWID
.enuWIDtype
= WID_CHAR
;
5713 strWID
.ps8WidVal
= (s8
*)&assoc_id
;
5714 strWID
.s32ValueSize
= sizeof(char);
5720 * @brief host_int_get_assoc_req_info
5721 * @details gets a Association request info
5722 * @param[in,out] handle to the wifi driver,
5723 * Message containg assoc. req info in the following format
5724 * ------------------------------------------------------------------------
5725 | Management Frame Format |
5726 ||-------------------------------------------------------------------|
5727 ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS |
5728 ||-------------|--------|--|--|-----|----------------|----------|----|
5729 | 2 |2 |6 |6 |6 | 2 |0 - 2312 | 4 |
5730 ||-------------------------------------------------------------------|
5732 | Association Request Frame - Frame Body |
5733 ||-------------------------------------------------------------------|
5734 | Capability Information | Listen Interval | SSID | Supported Rates |
5735 ||------------------------|-----------------|------|-----------------|
5736 | 2 | 2 | 2-34 | 3-10 |
5737 | ---------------------------------------------------------------------
5738 * @return Error code indicating success/failure
5741 * @date 8 March 2012
5745 s32
host_int_get_assoc_req_info(tstrWILC_WFIDrv
*hWFIDrv
, u8
*pu8AssocReqInfo
,
5746 u32 u32AssocReqInfoLen
)
5748 s32 s32Error
= WILC_SUCCESS
;
5750 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5752 strWID
.u16WIDid
= (u16
)WID_ASSOC_REQ_INFO
;
5753 strWID
.enuWIDtype
= WID_STR
;
5754 strWID
.ps8WidVal
= pu8AssocReqInfo
;
5755 strWID
.s32ValueSize
= u32AssocReqInfoLen
;
5762 * @brief gets a Association Response info
5764 * @param[in,out] handle to the wifi driver,
5765 * Message containg assoc. resp info
5766 * @return Error code indicating success/failure
5769 * @date 8 March 2012
5772 s32
host_int_get_assoc_res_info(tstrWILC_WFIDrv
*hWFIDrv
, u8
*pu8AssocRespInfo
,
5773 u32 u32MaxAssocRespInfoLen
, u32
*pu32RcvdAssocRespInfoLen
)
5775 s32 s32Error
= WILC_SUCCESS
;
5777 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5779 if (pstrWFIDrv
== NULL
) {
5780 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
5781 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5784 strWID
.u16WIDid
= (u16
)WID_ASSOC_RES_INFO
;
5785 strWID
.enuWIDtype
= WID_STR
;
5786 strWID
.ps8WidVal
= pu8AssocRespInfo
;
5787 strWID
.s32ValueSize
= u32MaxAssocRespInfoLen
;
5790 /* Sending Configuration packet */
5791 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true,
5792 get_id_from_handler(pstrWFIDrv
));
5794 PRINT_ER("Failed to send association response config packet\n");
5795 *pu32RcvdAssocRespInfoLen
= 0;
5796 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
5798 *pu32RcvdAssocRespInfoLen
= strWID
.s32ValueSize
;
5801 WILC_CATCH(s32Error
)
5809 * @brief gets a Association Response info
5810 * @details Valid only in STA mode. This function gives the RSSI
5811 * values observed in all the channels at the time of scanning.
5812 * The length of the field is 1 greater that the total number of
5813 * channels supported. Byte 0 contains the number of channels while
5814 * each of Byte N contains the observed RSSI value for the channel index N.
5815 * @param[in,out] handle to the wifi driver,
5816 * array of scanned channels' RSSI
5817 * @return Error code indicating success/failure
5820 * @date 8 March 2012
5823 s32
host_int_get_rx_power_level(tstrWILC_WFIDrv
*hWFIDrv
, u8
*pu8RxPowerLevel
,
5824 u32 u32RxPowerLevelLen
)
5826 s32 s32Error
= WILC_SUCCESS
;
5828 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5830 strWID
.u16WIDid
= (u16
)WID_RX_POWER_LEVEL
;
5831 strWID
.enuWIDtype
= WID_STR
;
5832 strWID
.ps8WidVal
= pu8RxPowerLevel
;
5833 strWID
.s32ValueSize
= u32RxPowerLevelLen
;
5840 * @brief sets a channel
5842 * @param[in,out] handle to the wifi driver,
5843 * @param[in] Index of the channel to be set
5844 *|-------------------------------------------------------------------|
5845 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5847 ||-------------------------------------------------------------------|
5848 * @return Error code indicating success/failure
5851 * @date 8 March 2012
5854 s32
host_int_set_mac_chnl_num(tstrWILC_WFIDrv
*hWFIDrv
, u8 u8ChNum
)
5856 s32 s32Error
= WILC_SUCCESS
;
5857 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5858 tstrHostIFmsg strHostIFmsg
;
5860 if (pstrWFIDrv
== NULL
)
5861 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5863 /* prepare the set channel message */
5864 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5865 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SET_CHANNEL
;
5866 strHostIFmsg
.uniHostIFmsgBody
.strHostIFSetChan
.u8SetChan
= u8ChNum
;
5867 strHostIFmsg
.drvHandler
= hWFIDrv
;
5869 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5871 WILC_ERRORREPORT(s32Error
, s32Error
);
5872 WILC_CATCH(s32Error
)
5881 s32
host_int_wait_msg_queue_idle(void)
5883 s32 s32Error
= WILC_SUCCESS
;
5885 tstrHostIFmsg strHostIFmsg
;
5887 /* prepare the set driver handler message */
5889 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5890 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_Q_IDLE
;
5891 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5893 WILC_ERRORREPORT(s32Error
, s32Error
);
5894 WILC_CATCH(s32Error
)
5899 /* wait untill MSG Q is empty */
5900 down(&hWaitResponse
);
5906 s32
host_int_set_wfi_drv_handler(tstrWILC_WFIDrv
*u32address
)
5908 s32 s32Error
= WILC_SUCCESS
;
5910 tstrHostIFmsg strHostIFmsg
;
5913 /* prepare the set driver handler message */
5915 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5916 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SET_WFIDRV_HANDLER
;
5917 strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetDrvHandler
.u32Address
= get_id_from_handler(u32address
);
5918 strHostIFmsg
.drvHandler
= u32address
;
5920 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5922 WILC_ERRORREPORT(s32Error
, s32Error
);
5923 WILC_CATCH(s32Error
)
5933 s32
host_int_set_operation_mode(tstrWILC_WFIDrv
*hWFIDrv
, u32 u32mode
)
5935 s32 s32Error
= WILC_SUCCESS
;
5937 tstrHostIFmsg strHostIFmsg
;
5940 /* prepare the set driver handler message */
5942 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5943 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SET_OPERATION_MODE
;
5944 strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetOperationMode
.u32Mode
= u32mode
;
5945 strHostIFmsg
.drvHandler
= hWFIDrv
;
5947 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5949 WILC_ERRORREPORT(s32Error
, s32Error
);
5950 WILC_CATCH(s32Error
)
5959 * @brief gets the current channel index
5961 * @param[in,out] handle to the wifi driver,
5962 * current channel index
5963 *|-----------------------------------------------------------------------|
5964 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5966 ||-----------------------------------------------------------------------|
5967 * @return Error code indicating success/failure
5970 * @date 8 March 2012
5973 s32
host_int_get_host_chnl_num(tstrWILC_WFIDrv
*hWFIDrv
, u8
*pu8ChNo
)
5975 s32 s32Error
= WILC_SUCCESS
;
5976 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5977 tstrHostIFmsg strHostIFmsg
;
5979 if (pstrWFIDrv
== NULL
) {
5980 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
5981 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5984 /* prepare the Get Channel Message */
5985 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5987 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_CHNL
;
5988 strHostIFmsg
.drvHandler
= hWFIDrv
;
5990 /* send the message */
5991 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5993 PRINT_ER("Failed to send get host channel param's message queue ");
5994 down(&(pstrWFIDrv
->hSemGetCHNL
));
5999 WILC_CATCH(s32Error
)
6010 * @brief host_int_test_set_int_wid
6011 * @details Test function for setting wids
6012 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr
6013 * @return Error code indicating success/failure
6016 * @date 8 March 2012
6019 s32
host_int_test_set_int_wid(tstrWILC_WFIDrv
*hWFIDrv
, u32 u32TestMemAddr
)
6021 s32 s32Error
= WILC_SUCCESS
;
6023 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6026 if (pstrWFIDrv
== NULL
) {
6027 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
6028 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
6031 /*prepare configuration packet*/
6032 strWID
.u16WIDid
= (u16
)WID_MEMORY_ADDRESS
;
6033 strWID
.enuWIDtype
= WID_INT
;
6034 strWID
.ps8WidVal
= (char *)&u32TestMemAddr
;
6035 strWID
.s32ValueSize
= sizeof(u32
);
6038 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
6039 get_id_from_handler(pstrWFIDrv
));
6041 PRINT_ER("Test Function: Failed to set wid value\n");
6042 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
6044 PRINT_D(HOSTINF_DBG
, "Successfully set wid value\n");
6048 WILC_CATCH(s32Error
)
6055 #ifdef WILC_AP_EXTERNAL_MLME
6057 * @brief host_int_get_inactive_time
6059 * @param[in,out] handle to the wifi driver,
6060 * current sta macaddress, inactive_time
6067 s32
host_int_get_inactive_time(tstrWILC_WFIDrv
*hWFIDrv
, const u8
*mac
, u32
*pu32InactiveTime
)
6069 s32 s32Error
= WILC_SUCCESS
;
6070 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6071 tstrHostIFmsg strHostIFmsg
;
6073 if (pstrWFIDrv
== NULL
) {
6074 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
6075 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
6078 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6081 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIfStaInactiveT
.mac
,
6084 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_INACTIVETIME
;
6085 strHostIFmsg
.drvHandler
= hWFIDrv
;
6087 /* send the message */
6088 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
6090 PRINT_ER("Failed to send get host channel param's message queue ");
6092 down(&(pstrWFIDrv
->hSemInactiveTime
));
6094 *pu32InactiveTime
= gu32InactiveTime
;
6096 WILC_CATCH(s32Error
)
6104 * @brief host_int_test_get_int_wid
6105 * @details Test function for getting wids
6106 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32* pu32TestMemAddr
6107 * @return Error code indicating success/failure
6110 * @date 8 March 2012
6113 s32
host_int_test_get_int_wid(tstrWILC_WFIDrv
*hWFIDrv
, u32
*pu32TestMemAddr
)
6116 s32 s32Error
= WILC_SUCCESS
;
6118 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6121 if (pstrWFIDrv
== NULL
) {
6122 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
6123 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
6126 strWID
.u16WIDid
= (u16
)WID_MEMORY_ADDRESS
;
6127 strWID
.enuWIDtype
= WID_INT
;
6128 strWID
.ps8WidVal
= (s8
*)pu32TestMemAddr
;
6129 strWID
.s32ValueSize
= sizeof(u32
);
6131 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true,
6132 get_id_from_handler(pstrWFIDrv
));
6133 /*get the value by searching the local copy*/
6135 PRINT_ER("Test Function: Failed to get wid value\n");
6136 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
6138 PRINT_D(HOSTINF_DBG
, "Successfully got wid value\n");
6142 WILC_CATCH(s32Error
)
6151 * @brief host_int_get_rssi
6152 * @details gets the currently maintained RSSI value for the station.
6153 * The received signal strength value in dB.
6154 * The range of valid values is -128 to 0.
6155 * @param[in,out] handle to the wifi driver,
6157 * @return Error code indicating success/failure
6160 * @date 8 March 2012
6163 s32
host_int_get_rssi(tstrWILC_WFIDrv
*hWFIDrv
, s8
*ps8Rssi
)
6165 s32 s32Error
= WILC_SUCCESS
;
6166 tstrHostIFmsg strHostIFmsg
;
6167 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6170 /* prepare the Get RSSI Message */
6171 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6173 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_RSSI
;
6174 strHostIFmsg
.drvHandler
= hWFIDrv
;
6176 /* send the message */
6177 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
6179 PRINT_ER("Failed to send get host channel param's message queue ");
6183 down(&(pstrWFIDrv
->hSemGetRSSI
));
6186 if (ps8Rssi
== NULL
) {
6187 PRINT_ER("RSS pointer value is null");
6198 s32
host_int_get_link_speed(tstrWILC_WFIDrv
*hWFIDrv
, s8
*ps8lnkspd
)
6200 tstrHostIFmsg strHostIFmsg
;
6201 s32 s32Error
= WILC_SUCCESS
;
6203 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6207 /* prepare the Get LINKSPEED Message */
6208 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6210 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_LINKSPEED
;
6211 strHostIFmsg
.drvHandler
= hWFIDrv
;
6213 /* send the message */
6214 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
6216 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
6220 down(&(pstrWFIDrv
->hSemGetLINKSPEED
));
6223 if (ps8lnkspd
== NULL
) {
6224 PRINT_ER("LINKSPEED pointer value is null");
6229 *ps8lnkspd
= gs8lnkspd
;
6235 s32
host_int_get_statistics(tstrWILC_WFIDrv
*hWFIDrv
, tstrStatistics
*pstrStatistics
)
6237 s32 s32Error
= WILC_SUCCESS
;
6238 tstrHostIFmsg strHostIFmsg
;
6241 /* prepare the Get RSSI Message */
6242 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6244 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_STATISTICS
;
6245 strHostIFmsg
.uniHostIFmsgBody
.pUserData
= (char *)pstrStatistics
;
6246 strHostIFmsg
.drvHandler
= hWFIDrv
;
6247 /* send the message */
6248 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
6250 PRINT_ER("Failed to send get host channel param's message queue ");
6254 down(&hWaitResponse
);
6260 * @brief host_int_scan
6261 * @details scans a set of channels
6262 * @param[in,out] handle to the wifi driver,
6263 * @param[in] Scan source
6264 * Scan Type PASSIVE_SCAN = 0,
6267 * Channels Array length
6268 * Scan Callback function
6269 * @return Error code indicating success/failure
6272 * @date 8 March 2012
6275 s32
host_int_scan(tstrWILC_WFIDrv
*hWFIDrv
, u8 u8ScanSource
,
6276 u8 u8ScanType
, u8
*pu8ChnlFreqList
,
6277 u8 u8ChnlListLen
, const u8
*pu8IEs
,
6278 size_t IEsLen
, tWILCpfScanResult ScanResult
,
6279 void *pvUserArg
, tstrHiddenNetwork
*pstrHiddenNetwork
)
6281 s32 s32Error
= WILC_SUCCESS
;
6282 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6283 tstrHostIFmsg strHostIFmsg
;
6284 tenuScanConnTimer enuScanConnTimer
;
6286 if (pstrWFIDrv
== NULL
|| ScanResult
== NULL
)
6287 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
6290 /* prepare the Scan Message */
6291 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6293 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SCAN
;
6295 if (pstrHiddenNetwork
!= NULL
) {
6296 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.strHiddenNetwork
.pstrHiddenNetworkInfo
= pstrHiddenNetwork
->pstrHiddenNetworkInfo
;
6297 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.strHiddenNetwork
.u8ssidnum
= pstrHiddenNetwork
->u8ssidnum
;
6300 PRINT_D(HOSTINF_DBG
, "pstrHiddenNetwork IS EQUAL TO NULL\n");
6302 strHostIFmsg
.drvHandler
= hWFIDrv
;
6303 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.u8ScanSource
= u8ScanSource
;
6304 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.u8ScanType
= u8ScanType
;
6305 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.pfScanResult
= ScanResult
;
6306 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.pvUserArg
= pvUserArg
;
6308 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.u8ChnlListLen
= u8ChnlListLen
;
6309 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.pu8ChnlFreqList
= kmalloc(u8ChnlListLen
, GFP_KERNEL
); /* will be deallocated by the receiving thread */
6310 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.pu8ChnlFreqList
,
6311 pu8ChnlFreqList
, u8ChnlListLen
);
6313 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.IEsLen
= IEsLen
;
6314 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.pu8IEs
= kmalloc(IEsLen
, GFP_KERNEL
); /* will be deallocated by the receiving thread */
6315 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.pu8IEs
,
6318 /* send the message */
6319 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
6321 PRINT_ER("Error in sending message queue scanning parameters: Error(%d)\n", s32Error
);
6322 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
6325 enuScanConnTimer
= SCAN_TIMER
;
6326 PRINT_D(HOSTINF_DBG
, ">> Starting the SCAN timer\n");
6327 pstrWFIDrv
->hScanTimer
.data
= (unsigned long)hWFIDrv
;
6328 mod_timer(&pstrWFIDrv
->hScanTimer
,
6329 jiffies
+ msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT
));
6331 WILC_CATCH(s32Error
)
6339 * @brief hif_set_cfg
6340 * @details sets configuration wids values
6341 * @param[in,out] handle to the wifi driver,
6342 * @param[in] WID, WID value
6343 * @return Error code indicating success/failure
6346 * @date 8 March 2012
6349 s32
hif_set_cfg(tstrWILC_WFIDrv
*hWFIDrv
, tstrCfgParamVal
*pstrCfgParamVal
)
6352 s32 s32Error
= WILC_SUCCESS
;
6353 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6355 tstrHostIFmsg strHostIFmsg
;
6358 if (pstrWFIDrv
== NULL
)
6359 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
6360 /* prepare the WiphyParams Message */
6361 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6362 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_CFG_PARAMS
;
6363 strHostIFmsg
.uniHostIFmsgBody
.strHostIFCfgParamAttr
.pstrCfgParamVal
= *pstrCfgParamVal
;
6364 strHostIFmsg
.drvHandler
= hWFIDrv
;
6366 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
6368 WILC_CATCH(s32Error
)
6378 * @brief hif_get_cfg
6379 * @details gets configuration wids values
6380 * @param[in,out] handle to the wifi driver,
6383 * @return Error code indicating success/failure
6387 * @date 8 March 2012
6390 s32
hif_get_cfg(tstrWILC_WFIDrv
*hWFIDrv
, u16 u16WID
, u16
*pu16WID_Value
)
6392 s32 s32Error
= WILC_SUCCESS
;
6393 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6395 down(&(pstrWFIDrv
->gtOsCfgValuesSem
));
6397 if (pstrWFIDrv
== NULL
) {
6398 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
6399 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
6401 PRINT_D(HOSTINF_DBG
, "Getting configuration parameters\n");
6405 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.bss_type
;
6409 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.auth_type
;
6412 case WID_AUTH_TIMEOUT
:
6413 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.auth_timeout
;
6416 case WID_POWER_MANAGEMENT
:
6417 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.power_mgmt_mode
;
6420 case WID_SHORT_RETRY_LIMIT
:
6421 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.short_retry_limit
;
6424 case WID_LONG_RETRY_LIMIT
:
6425 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.long_retry_limit
;
6428 case WID_FRAG_THRESHOLD
:
6429 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.frag_threshold
;
6432 case WID_RTS_THRESHOLD
:
6433 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.rts_threshold
;
6437 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.preamble_type
;
6440 case WID_SHORT_SLOT_ALLOWED
:
6441 *pu16WID_Value
= (u16
) pstrWFIDrv
->strCfgValues
.short_slot_allowed
;
6444 case WID_11N_TXOP_PROT_DISABLE
:
6445 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.txop_prot_disabled
;
6448 case WID_BEACON_INTERVAL
:
6449 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.beacon_interval
;
6452 case WID_DTIM_PERIOD
:
6453 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.dtim_period
;
6456 case WID_SITE_SURVEY
:
6457 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.site_survey_enabled
;
6460 case WID_SITE_SURVEY_SCAN_TIME
:
6461 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.site_survey_scan_time
;
6464 case WID_ACTIVE_SCAN_TIME
:
6465 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.active_scan_time
;
6468 case WID_PASSIVE_SCAN_TIME
:
6469 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.passive_scan_time
;
6472 case WID_CURRENT_TX_RATE
:
6473 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.curr_tx_rate
;
6480 up(&(pstrWFIDrv
->gtOsCfgValuesSem
));
6482 WILC_CATCH(s32Error
)
6489 /*****************************************************************************/
6490 /* Notification Functions */
6491 /*****************************************************************************/
6493 * @brief notifies host with join and leave requests
6494 * @details This function prepares an Information frame having the
6495 * information about a joining/leaving station.
6496 * @param[in,out] handle to the wifi driver,
6497 * @param[in] 6 byte Sta Adress
6498 * Join or leave flag:
6501 * @return Error code indicating success/failure
6504 * @date 8 March 2012
6507 void host_int_send_join_leave_info_to_host
6508 (u16 assocId
, u8
*stationAddr
, bool joining
)
6512 * @brief notifies host with stations found in scan
6513 * @details sends the beacon/probe response from scan
6514 * @param[in,out] handle to the wifi driver,
6515 * @param[in] Sta Address,
6517 * Rssi of the Station found
6518 * @return Error code indicating success/failure
6521 * @date 8 March 2012
6525 static void GetPeriodicRSSI(unsigned long arg
)
6527 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)arg
;
6529 if (pstrWFIDrv
== NULL
) {
6530 PRINT_ER("Driver handler is NULL\n");
6534 if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_CONNECTED
) {
6535 s32 s32Error
= WILC_SUCCESS
;
6536 tstrHostIFmsg strHostIFmsg
;
6538 /* prepare the Get RSSI Message */
6539 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6541 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_RSSI
;
6542 strHostIFmsg
.drvHandler
= pstrWFIDrv
;
6544 /* send the message */
6545 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
6547 PRINT_ER("Failed to send get host channel param's message queue ");
6551 g_hPeriodicRSSI
.data
= (unsigned long)pstrWFIDrv
;
6552 mod_timer(&g_hPeriodicRSSI
, jiffies
+ msecs_to_jiffies(5000));
6556 void host_int_send_network_info_to_host
6557 (u8
*macStartAddress
, u16 u16RxFrameLen
, s8 s8Rssi
)
6561 * @brief host_int_init
6562 * @details host interface initialization function
6563 * @param[in,out] handle to the wifi driver,
6566 * @date 8 March 2012
6569 static u32 u32Intialized
;
6570 static u32 msgQ_created
;
6571 static u32 clients_count
;
6573 s32
host_int_init(tstrWILC_WFIDrv
**phWFIDrv
)
6575 s32 s32Error
= WILC_SUCCESS
;
6576 tstrWILC_WFIDrv
*pstrWFIDrv
;
6579 /*if(u32Intialized == 1)
6581 * PRINT_D(HOSTINF_DBG,"Host interface is previously initialized\n");
6582 * *phWFIDrv = (WILC_WFIDrvHandle)gWFiDrvHandle; //Will be adjusted later for P2P
6585 PRINT_D(HOSTINF_DBG
, "Initializing host interface for client %d\n", clients_count
+ 1);
6587 gbScanWhileConnected
= false;
6589 sema_init(&hWaitResponse
, 0);
6593 /*Allocate host interface private structure*/
6594 pstrWFIDrv
= kmalloc(sizeof(tstrWILC_WFIDrv
), GFP_KERNEL
);
6595 if (pstrWFIDrv
== NULL
) {
6596 /* WILC_ERRORREPORT(s32Error,WILC_NO_MEM); */
6597 s32Error
= WILC_NO_MEM
;
6598 PRINT_ER("Failed to allocate memory\n");
6601 memset(pstrWFIDrv
, 0, sizeof(tstrWILC_WFIDrv
));
6602 /*return driver handle to user*/
6603 *phWFIDrv
= pstrWFIDrv
;
6604 /*save into globl handle*/
6605 err
= add_handler_in_list(pstrWFIDrv
);
6607 s32Error
= WILC_FAIL
;
6611 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
6613 g_obtainingIP
= false;
6616 PRINT_D(HOSTINF_DBG
, "Global handle pointer value=%p\n", pstrWFIDrv
);
6617 /* /////////////////////////////////////// */
6618 if (clients_count
== 0) {
6619 sema_init(&hSemHostIFthrdEnd
, 0);
6620 sema_init(&hSemDeinitDrvHandle
, 0);
6622 sema_init(&hSemHostIntDeinit
, 1);
6625 sema_init(&(pstrWFIDrv
->hSemTestKeyBlock
), 0);
6626 sema_init(&(pstrWFIDrv
->hSemTestDisconnectBlock
), 0);
6627 sema_init(&(pstrWFIDrv
->hSemGetRSSI
), 0);
6628 sema_init(&(pstrWFIDrv
->hSemGetLINKSPEED
), 0);
6629 sema_init(&(pstrWFIDrv
->hSemGetCHNL
), 0);
6630 sema_init(&(pstrWFIDrv
->hSemInactiveTime
), 0);
6632 /* /////////////////////////////////////// */
6636 PRINT_D(HOSTINF_DBG
, "INIT: CLIENT COUNT %d\n", clients_count
);
6638 if (clients_count
== 0) {
6639 s32Error
= wilc_mq_create(&gMsgQHostIF
);
6642 PRINT_ER("Failed to creat MQ\n");
6646 HostIFthreadHandler
= kthread_run(hostIFthread
, NULL
, "WILC_kthread");
6647 if (IS_ERR(HostIFthreadHandler
)) {
6648 PRINT_ER("Failed to creat Thread\n");
6649 s32Error
= WILC_FAIL
;
6652 setup_timer(&g_hPeriodicRSSI
, GetPeriodicRSSI
,
6653 (unsigned long)pstrWFIDrv
);
6654 mod_timer(&g_hPeriodicRSSI
, jiffies
+ msecs_to_jiffies(5000));
6658 setup_timer(&pstrWFIDrv
->hScanTimer
, TimerCB_Scan
, 0);
6660 setup_timer(&pstrWFIDrv
->hConnectTimer
, TimerCB_Connect
, 0);
6663 /*Remain on channel timer*/
6664 setup_timer(&pstrWFIDrv
->hRemainOnChannel
, ListenTimerCB
, 0);
6667 sema_init(&(pstrWFIDrv
->gtOsCfgValuesSem
), 1);
6668 down(&(pstrWFIDrv
->gtOsCfgValuesSem
));
6670 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
6671 /* gWFiDrvHandle->bPendingConnRequest = false; */
6673 /*Initialize CFG WIDS Defualt Values*/
6675 pstrWFIDrv
->strCfgValues
.site_survey_enabled
= SITE_SURVEY_OFF
;
6676 pstrWFIDrv
->strCfgValues
.scan_source
= DEFAULT_SCAN
;
6677 pstrWFIDrv
->strCfgValues
.active_scan_time
= ACTIVE_SCAN_TIME
;
6678 pstrWFIDrv
->strCfgValues
.passive_scan_time
= PASSIVE_SCAN_TIME
;
6679 pstrWFIDrv
->strCfgValues
.curr_tx_rate
= AUTORATE
;
6684 pstrWFIDrv
->u64P2p_MgmtTimeout
= 0;
6688 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",
6690 pstrWFIDrv
->strCfgValues
.site_survey_enabled
, pstrWFIDrv
->strCfgValues
.scan_source
,
6691 pstrWFIDrv
->strCfgValues
.active_scan_time
, pstrWFIDrv
->strCfgValues
.passive_scan_time
,
6692 pstrWFIDrv
->strCfgValues
.curr_tx_rate
);
6695 up(&(pstrWFIDrv
->gtOsCfgValuesSem
));
6697 /*TODO Code to setup simulation to be removed later*/
6698 /*Intialize configurator module*/
6699 s32Error
= CoreConfiguratorInit();
6701 PRINT_ER("Failed to initialize core configurator\n");
6706 clients_count
++; /* increase number of created entities */
6712 if (pstrWFIDrv
!= NULL
)
6715 del_timer_sync(&pstrWFIDrv
->hRemainOnChannel
);
6718 up(&(pstrWFIDrv
->gtOsCfgValuesSem
));
6719 del_timer_sync(&pstrWFIDrv
->hConnectTimer
);
6720 del_timer_sync(&pstrWFIDrv
->hScanTimer
);
6721 kthread_stop(HostIFthreadHandler
);
6723 wilc_mq_destroy(&gMsgQHostIF
);
6730 * @brief host_int_deinit
6731 * @details host interface initialization function
6732 * @param[in,out] handle to the wifi driver,
6735 * @date 8 March 2012
6739 s32
host_int_deinit(tstrWILC_WFIDrv
*hWFIDrv
)
6741 s32 s32Error
= WILC_SUCCESS
;
6742 tstrHostIFmsg strHostIFmsg
;
6745 /*obtain driver handle*/
6746 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6747 /*if(u32Intialized == 0)
6749 * PRINT_ER("Host Interface is not initialized\n");
6755 if (pstrWFIDrv
== NULL
) {
6756 PRINT_ER("pstrWFIDrv = NULL\n");
6760 down(&hSemHostIntDeinit
);
6762 terminated_handle
= pstrWFIDrv
;
6763 PRINT_D(HOSTINF_DBG
, "De-initializing host interface for client %d\n", clients_count
);
6766 /*Destroy all timers before acquiring hSemDeinitDrvHandle*/
6767 /*to guarantee handling all messages befor proceeding*/
6768 if (del_timer_sync(&pstrWFIDrv
->hScanTimer
)) {
6769 PRINT_D(HOSTINF_DBG
, ">> Scan timer is active\n");
6770 /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */
6773 if (del_timer_sync(&pstrWFIDrv
->hConnectTimer
)) {
6774 PRINT_D(HOSTINF_DBG
, ">> Connect timer is active\n");
6775 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6779 if (del_timer_sync(&g_hPeriodicRSSI
)) {
6780 PRINT_D(HOSTINF_DBG
, ">> Connect timer is active\n");
6781 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6785 /*Destroy Remain-onchannel Timer*/
6786 del_timer_sync(&pstrWFIDrv
->hRemainOnChannel
);
6789 host_int_set_wfi_drv_handler(NULL
);
6790 down(&hSemDeinitDrvHandle
);
6793 /*Calling the CFG80211 scan done function with the abort flag set to true*/
6794 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
6795 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult(SCAN_EVENT_ABORTED
, NULL
,
6796 pstrWFIDrv
->strWILC_UsrScanReq
.u32UserScanPvoid
, NULL
);
6798 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
= NULL
;
6800 /*deinit configurator and simulator*/
6801 CoreConfiguratorDeInit();
6803 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
6805 gbScanWhileConnected
= false;
6807 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6809 if (clients_count
== 1) {
6810 if (del_timer_sync(&g_hPeriodicRSSI
)) {
6811 PRINT_D(HOSTINF_DBG
, ">> Connect timer is active\n");
6812 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6814 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_EXIT
;
6815 strHostIFmsg
.drvHandler
= hWFIDrv
;
6818 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
6819 if (s32Error
!= WILC_SUCCESS
)
6820 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error
);
6822 down(&hSemHostIFthrdEnd
);
6824 wilc_mq_destroy(&gMsgQHostIF
);
6828 down(&(pstrWFIDrv
->gtOsCfgValuesSem
));
6830 /*Setting the gloabl driver handler with NULL*/
6832 /* gWFiDrvHandle = NULL; */
6833 ret
= remove_handler_in_list(pstrWFIDrv
);
6835 s32Error
= WILC_NOT_FOUND
;
6837 if (pstrWFIDrv
!= NULL
) {
6839 /* pstrWFIDrv=NULL; */
6843 clients_count
--; /* Decrease number of created entities */
6844 terminated_handle
= NULL
;
6845 up(&hSemHostIntDeinit
);
6851 * @brief NetworkInfoReceived
6852 * @details function to to be called when network info packet is received
6853 * @param[in] pu8Buffer the received packet
6854 * @param[in] u32Length length of the received packet
6861 void NetworkInfoReceived(u8
*pu8Buffer
, u32 u32Length
)
6863 s32 s32Error
= WILC_SUCCESS
;
6864 tstrHostIFmsg strHostIFmsg
;
6866 tstrWILC_WFIDrv
*pstrWFIDrv
= NULL
;
6868 id
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
6869 pstrWFIDrv
= get_handler_from_id(id
);
6874 if (pstrWFIDrv
== NULL
|| pstrWFIDrv
== terminated_handle
) {
6875 PRINT_ER("NetworkInfo received but driver not init[%p]\n", pstrWFIDrv
);
6879 /* prepare the Asynchronous Network Info message */
6880 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6882 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_RCVD_NTWRK_INFO
;
6883 strHostIFmsg
.drvHandler
= pstrWFIDrv
;
6885 strHostIFmsg
.uniHostIFmsgBody
.strRcvdNetworkInfo
.u32Length
= u32Length
;
6886 strHostIFmsg
.uniHostIFmsgBody
.strRcvdNetworkInfo
.pu8Buffer
= kmalloc(u32Length
, GFP_KERNEL
); /* will be deallocated by the receiving thread */
6887 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strRcvdNetworkInfo
.pu8Buffer
,
6888 pu8Buffer
, u32Length
);
6890 /* send the message */
6891 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
6893 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error
);
6897 * @brief GnrlAsyncInfoReceived
6898 * @details function to be called when general Asynchronous info packet is received
6899 * @param[in] pu8Buffer the received packet
6900 * @param[in] u32Length length of the received packet
6907 void GnrlAsyncInfoReceived(u8
*pu8Buffer
, u32 u32Length
)
6909 s32 s32Error
= WILC_SUCCESS
;
6910 tstrHostIFmsg strHostIFmsg
;
6912 tstrWILC_WFIDrv
*pstrWFIDrv
= NULL
;
6915 down(&hSemHostIntDeinit
);
6917 id
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
6918 pstrWFIDrv
= get_handler_from_id(id
);
6919 PRINT_D(HOSTINF_DBG
, "General asynchronous info packet received\n");
6922 if (pstrWFIDrv
== NULL
|| pstrWFIDrv
== terminated_handle
) {
6923 PRINT_D(HOSTINF_DBG
, "Wifi driver handler is equal to NULL\n");
6925 up(&hSemHostIntDeinit
);
6929 if (pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
== NULL
) {
6930 /* received mac status is not needed when there is no current Connect Request */
6931 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
6933 up(&hSemHostIntDeinit
);
6937 /* prepare the General Asynchronous Info message */
6938 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6941 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO
;
6942 strHostIFmsg
.drvHandler
= pstrWFIDrv
;
6945 strHostIFmsg
.uniHostIFmsgBody
.strRcvdGnrlAsyncInfo
.u32Length
= u32Length
;
6946 strHostIFmsg
.uniHostIFmsgBody
.strRcvdGnrlAsyncInfo
.pu8Buffer
= kmalloc(u32Length
, GFP_KERNEL
); /* will be deallocated by the receiving thread */
6947 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strRcvdGnrlAsyncInfo
.pu8Buffer
,
6948 pu8Buffer
, u32Length
);
6950 /* send the message */
6951 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
6953 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error
);
6956 up(&hSemHostIntDeinit
);
6960 * @brief host_int_ScanCompleteReceived
6961 * @details Setting scan complete received notifcation in message queue
6962 * @param[in] u8* pu8Buffer, u32 u32Length
6963 * @return Error code.
6968 void host_int_ScanCompleteReceived(u8
*pu8Buffer
, u32 u32Length
)
6970 s32 s32Error
= WILC_SUCCESS
;
6971 tstrHostIFmsg strHostIFmsg
;
6973 tstrWILC_WFIDrv
*pstrWFIDrv
= NULL
;
6975 id
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
6976 pstrWFIDrv
= get_handler_from_id(id
);
6979 PRINT_D(GENERIC_DBG
, "Scan notification received %p\n", pstrWFIDrv
);
6981 if (pstrWFIDrv
== NULL
|| pstrWFIDrv
== terminated_handle
)
6984 /*if there is an ongoing scan request*/
6985 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
6986 /* prepare theScan Done message */
6987 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6989 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_RCVD_SCAN_COMPLETE
;
6990 strHostIFmsg
.drvHandler
= pstrWFIDrv
;
6993 /* will be deallocated by the receiving thread */
6994 /*no need to send message body*/
6996 /*strHostIFmsg.uniHostIFmsgBody.strScanComplete.u32Length = u32Length;
6997 * strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer = (u8*)WILC_MALLOC(u32Length);
6998 * memcpy(strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer,
6999 * pu8Buffer, u32Length); */
7001 /* send the message */
7002 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7004 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error
);
7014 * @brief host_int_remain_on_channel
7016 * @param[in] Handle to wifi driver
7017 * Duration to remain on channel
7018 * Channel to remain on
7019 * Pointer to fn to be called on receive frames in listen state
7020 * Pointer to remain-on-channel expired fn
7022 * @return Error code.
7027 s32
host_int_remain_on_channel(tstrWILC_WFIDrv
*hWFIDrv
, u32 u32SessionID
, u32 u32duration
, u16 chan
, tWILCpfRemainOnChanExpired RemainOnChanExpired
, tWILCpfRemainOnChanReady RemainOnChanReady
, void *pvUserArg
)
7029 s32 s32Error
= WILC_SUCCESS
;
7030 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7031 tstrHostIFmsg strHostIFmsg
;
7033 if (pstrWFIDrv
== NULL
)
7034 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7036 /* prepare the remainonchan Message */
7037 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7039 /* prepare the WiphyParams Message */
7040 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_REMAIN_ON_CHAN
;
7041 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.u16Channel
= chan
;
7042 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.pRemainOnChanExpired
= RemainOnChanExpired
;
7043 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.pRemainOnChanReady
= RemainOnChanReady
;
7044 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.pVoid
= pvUserArg
;
7045 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.u32duration
= u32duration
;
7046 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.u32ListenSessionID
= u32SessionID
;
7047 strHostIFmsg
.drvHandler
= hWFIDrv
;
7049 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7051 WILC_ERRORREPORT(s32Error
, s32Error
);
7052 WILC_CATCH(s32Error
)
7061 * @brief host_int_ListenStateExpired
7063 * @param[in] Handle to wifi driver
7064 * Duration to remain on channel
7065 * Channel to remain on
7066 * Pointer to fn to be called on receive frames in listen state
7067 * Pointer to remain-on-channel expired fn
7069 * @return Error code.
7074 s32
host_int_ListenStateExpired(tstrWILC_WFIDrv
*hWFIDrv
, u32 u32SessionID
)
7076 s32 s32Error
= WILC_SUCCESS
;
7077 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7078 tstrHostIFmsg strHostIFmsg
;
7080 if (pstrWFIDrv
== NULL
)
7081 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7083 /*Stopping remain-on-channel timer*/
7084 del_timer(&pstrWFIDrv
->hRemainOnChannel
);
7086 /* prepare the timer fire Message */
7087 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7088 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_LISTEN_TIMER_FIRED
;
7089 strHostIFmsg
.drvHandler
= hWFIDrv
;
7090 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.u32ListenSessionID
= u32SessionID
;
7092 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7094 WILC_ERRORREPORT(s32Error
, s32Error
);
7095 WILC_CATCH(s32Error
)
7103 * @brief host_int_frame_register
7105 * @param[in] Handle to wifi driver
7106 * @return Error code.
7110 s32
host_int_frame_register(tstrWILC_WFIDrv
*hWFIDrv
, u16 u16FrameType
, bool bReg
)
7112 s32 s32Error
= WILC_SUCCESS
;
7113 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7114 tstrHostIFmsg strHostIFmsg
;
7116 if (pstrWFIDrv
== NULL
)
7117 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7119 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7121 /* prepare the WiphyParams Message */
7122 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_REGISTER_FRAME
;
7123 switch (u16FrameType
) {
7125 PRINT_D(HOSTINF_DBG
, "ACTION\n");
7126 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRegisterFrame
.u8Regid
= ACTION_FRM_IDX
;
7130 PRINT_D(HOSTINF_DBG
, "PROBE REQ\n");
7131 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRegisterFrame
.u8Regid
= PROBE_REQ_IDX
;
7135 PRINT_D(HOSTINF_DBG
, "Not valid frame type\n");
7138 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRegisterFrame
.u16FrameType
= u16FrameType
;
7139 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRegisterFrame
.bReg
= bReg
;
7140 strHostIFmsg
.drvHandler
= hWFIDrv
;
7142 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7144 WILC_ERRORREPORT(s32Error
, s32Error
);
7145 WILC_CATCH(s32Error
)
7156 #ifdef WILC_AP_EXTERNAL_MLME
7158 * @brief host_int_add_beacon
7159 * @details Setting add beacon params in message queue
7160 * @param[in] WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
7161 * u32 u32DTIMPeriod,u32 u32HeadLen, u8* pu8Head,
7162 * u32 u32TailLen, u8* pu8Tail
7163 * @return Error code.
7168 s32
host_int_add_beacon(tstrWILC_WFIDrv
*hWFIDrv
, u32 u32Interval
,
7170 u32 u32HeadLen
, u8
*pu8Head
,
7171 u32 u32TailLen
, u8
*pu8Tail
)
7173 s32 s32Error
= WILC_SUCCESS
;
7174 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7175 tstrHostIFmsg strHostIFmsg
;
7176 tstrHostIFSetBeacon
*pstrSetBeaconParam
= &strHostIFmsg
.uniHostIFmsgBody
.strHostIFSetBeacon
;
7178 if (pstrWFIDrv
== NULL
)
7179 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7181 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7183 PRINT_D(HOSTINF_DBG
, "Setting adding beacon message queue params\n");
7186 /* prepare the WiphyParams Message */
7187 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_ADD_BEACON
;
7188 strHostIFmsg
.drvHandler
= hWFIDrv
;
7189 pstrSetBeaconParam
->u32Interval
= u32Interval
;
7190 pstrSetBeaconParam
->u32DTIMPeriod
= u32DTIMPeriod
;
7191 pstrSetBeaconParam
->u32HeadLen
= u32HeadLen
;
7192 pstrSetBeaconParam
->pu8Head
= kmalloc(u32HeadLen
, GFP_KERNEL
);
7193 if (pstrSetBeaconParam
->pu8Head
== NULL
)
7194 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
7195 memcpy(pstrSetBeaconParam
->pu8Head
, pu8Head
, u32HeadLen
);
7196 pstrSetBeaconParam
->u32TailLen
= u32TailLen
;
7198 /* Bug 4599 : if tail length = 0 skip allocating & copying */
7199 if (u32TailLen
> 0) {
7200 pstrSetBeaconParam
->pu8Tail
= kmalloc(u32TailLen
, GFP_KERNEL
);
7201 if (pstrSetBeaconParam
->pu8Tail
== NULL
)
7202 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
7203 memcpy(pstrSetBeaconParam
->pu8Tail
, pu8Tail
, u32TailLen
);
7205 pstrSetBeaconParam
->pu8Tail
= NULL
;
7208 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7210 WILC_ERRORREPORT(s32Error
, s32Error
);
7212 WILC_CATCH(s32Error
)
7214 if (pstrSetBeaconParam
->pu8Head
!= NULL
)
7215 kfree(pstrSetBeaconParam
->pu8Head
);
7217 if (pstrSetBeaconParam
->pu8Tail
!= NULL
)
7218 kfree(pstrSetBeaconParam
->pu8Tail
);
7227 * @brief host_int_del_beacon
7228 * @details Setting add beacon params in message queue
7229 * @param[in] WILC_WFIDrvHandle hWFIDrv
7230 * @return Error code.
7235 s32
host_int_del_beacon(tstrWILC_WFIDrv
*hWFIDrv
)
7237 s32 s32Error
= WILC_SUCCESS
;
7238 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7239 tstrHostIFmsg strHostIFmsg
;
7241 if (pstrWFIDrv
== NULL
)
7242 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7244 /* prepare the WiphyParams Message */
7245 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_DEL_BEACON
;
7246 strHostIFmsg
.drvHandler
= hWFIDrv
;
7247 PRINT_D(HOSTINF_DBG
, "Setting deleting beacon message queue params\n");
7249 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7250 WILC_ERRORCHECK(s32Error
);
7252 WILC_CATCH(s32Error
)
7260 * @brief host_int_add_station
7261 * @details Setting add station params in message queue
7262 * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7263 * @return Error code.
7268 s32
host_int_add_station(tstrWILC_WFIDrv
*hWFIDrv
, tstrWILC_AddStaParam
*pstrStaParams
)
7270 s32 s32Error
= WILC_SUCCESS
;
7271 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7272 tstrHostIFmsg strHostIFmsg
;
7273 tstrWILC_AddStaParam
*pstrAddStationMsg
= &strHostIFmsg
.uniHostIFmsgBody
.strAddStaParam
;
7276 if (pstrWFIDrv
== NULL
)
7277 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7279 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7281 PRINT_D(HOSTINF_DBG
, "Setting adding station message queue params\n");
7284 /* prepare the WiphyParams Message */
7285 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_ADD_STATION
;
7286 strHostIFmsg
.drvHandler
= hWFIDrv
;
7288 memcpy(pstrAddStationMsg
, pstrStaParams
, sizeof(tstrWILC_AddStaParam
));
7289 if (pstrAddStationMsg
->u8NumRates
> 0) {
7290 u8
*rates
= kmalloc(pstrAddStationMsg
->u8NumRates
, GFP_KERNEL
);
7292 WILC_NULLCHECK(s32Error
, rates
);
7294 memcpy(rates
, pstrStaParams
->pu8Rates
, pstrAddStationMsg
->u8NumRates
);
7295 pstrAddStationMsg
->pu8Rates
= rates
;
7299 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7301 WILC_ERRORREPORT(s32Error
, s32Error
);
7303 WILC_CATCH(s32Error
)
7310 * @brief host_int_del_station
7311 * @details Setting delete station params in message queue
7312 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr
7313 * @return Error code.
7318 s32
host_int_del_station(tstrWILC_WFIDrv
*hWFIDrv
, const u8
*pu8MacAddr
)
7320 s32 s32Error
= WILC_SUCCESS
;
7321 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7322 tstrHostIFmsg strHostIFmsg
;
7323 tstrHostIFDelSta
*pstrDelStationMsg
= &strHostIFmsg
.uniHostIFmsgBody
.strDelStaParam
;
7325 if (pstrWFIDrv
== NULL
)
7326 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7328 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7330 PRINT_D(HOSTINF_DBG
, "Setting deleting station message queue params\n");
7334 /* prepare the WiphyParams Message */
7335 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_DEL_STATION
;
7336 strHostIFmsg
.drvHandler
= hWFIDrv
;
7338 /*BugID_4795: Handling situation of deleting all stations*/
7339 if (pu8MacAddr
== NULL
)
7340 memset(pstrDelStationMsg
->au8MacAddr
, 255, ETH_ALEN
);
7342 memcpy(pstrDelStationMsg
->au8MacAddr
, pu8MacAddr
, ETH_ALEN
);
7344 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7346 WILC_ERRORREPORT(s32Error
, s32Error
);
7348 WILC_CATCH(s32Error
)
7354 * @brief host_int_del_allstation
7355 * @details Setting del station params in message queue
7356 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]s
7357 * @return Error code.
7362 s32
host_int_del_allstation(tstrWILC_WFIDrv
*hWFIDrv
, u8 pu8MacAddr
[][ETH_ALEN
])
7364 s32 s32Error
= WILC_SUCCESS
;
7365 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7366 tstrHostIFmsg strHostIFmsg
;
7367 tstrHostIFDelAllSta
*pstrDelAllStationMsg
= &strHostIFmsg
.uniHostIFmsgBody
.strHostIFDelAllSta
;
7368 u8 au8Zero_Buff
[ETH_ALEN
] = {0};
7373 if (pstrWFIDrv
== NULL
)
7374 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7376 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7378 PRINT_D(HOSTINF_DBG
, "Setting deauthenticating station message queue params\n");
7380 /* prepare the WiphyParams Message */
7381 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_DEL_ALL_STA
;
7382 strHostIFmsg
.drvHandler
= hWFIDrv
;
7384 /* Handling situation of deauthenticing all associated stations*/
7385 for (i
= 0; i
< MAX_NUM_STA
; i
++) {
7386 if (memcmp(pu8MacAddr
[i
], au8Zero_Buff
, ETH_ALEN
)) {
7387 memcpy(pstrDelAllStationMsg
->au8Sta_DelAllSta
[i
], pu8MacAddr
[i
], ETH_ALEN
);
7388 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],
7389 pstrDelAllStationMsg
->au8Sta_DelAllSta
[i
][5]);
7394 PRINT_D(CFG80211_DBG
, "NO ASSOCIATED STAS\n");
7398 pstrDelAllStationMsg
->u8Num_AssocSta
= u8AssocNumb
;
7399 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7403 WILC_ERRORREPORT(s32Error
, s32Error
);
7405 WILC_CATCH(s32Error
)
7409 down(&hWaitResponse
);
7416 * @brief host_int_edit_station
7417 * @details Setting edit station params in message queue
7418 * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7419 * @return Error code.
7424 s32
host_int_edit_station(tstrWILC_WFIDrv
*hWFIDrv
, tstrWILC_AddStaParam
*pstrStaParams
)
7426 s32 s32Error
= WILC_SUCCESS
;
7427 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7428 tstrHostIFmsg strHostIFmsg
;
7429 tstrWILC_AddStaParam
*pstrAddStationMsg
= &strHostIFmsg
.uniHostIFmsgBody
.strAddStaParam
;
7431 if (pstrWFIDrv
== NULL
)
7432 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7434 PRINT_D(HOSTINF_DBG
, "Setting editing station message queue params\n");
7436 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7439 /* prepare the WiphyParams Message */
7440 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_EDIT_STATION
;
7441 strHostIFmsg
.drvHandler
= hWFIDrv
;
7443 memcpy(pstrAddStationMsg
, pstrStaParams
, sizeof(tstrWILC_AddStaParam
));
7444 if (pstrAddStationMsg
->u8NumRates
> 0) {
7445 u8
*rates
= kmalloc(pstrAddStationMsg
->u8NumRates
, GFP_KERNEL
);
7447 WILC_NULLCHECK(s32Error
, rates
);
7448 memcpy(rates
, pstrStaParams
->pu8Rates
, pstrAddStationMsg
->u8NumRates
);
7449 pstrAddStationMsg
->pu8Rates
= rates
;
7452 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7454 WILC_ERRORREPORT(s32Error
, s32Error
);
7455 WILC_CATCH(s32Error
)
7460 #endif /*WILC_AP_EXTERNAL_MLME*/
7461 u32
wilc_get_chipid(u8
);
7463 s32
host_int_set_power_mgmt(tstrWILC_WFIDrv
*hWFIDrv
, bool bIsEnabled
, u32 u32Timeout
)
7465 s32 s32Error
= WILC_SUCCESS
;
7466 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7467 tstrHostIFmsg strHostIFmsg
;
7468 tstrHostIfPowerMgmtParam
*pstrPowerMgmtParam
= &strHostIFmsg
.uniHostIFmsgBody
.strPowerMgmtparam
;
7470 PRINT_INFO(HOSTINF_DBG
, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled
);
7472 if (pstrWFIDrv
== NULL
)
7473 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7475 PRINT_D(HOSTINF_DBG
, "Setting Power management message queue params\n");
7477 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7480 /* prepare the WiphyParams Message */
7481 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_POWER_MGMT
;
7482 strHostIFmsg
.drvHandler
= hWFIDrv
;
7484 pstrPowerMgmtParam
->bIsEnabled
= bIsEnabled
;
7485 pstrPowerMgmtParam
->u32Timeout
= u32Timeout
;
7488 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7490 WILC_ERRORREPORT(s32Error
, s32Error
);
7491 WILC_CATCH(s32Error
)
7497 s32
host_int_setup_multicast_filter(tstrWILC_WFIDrv
*hWFIDrv
, bool bIsEnabled
, u32 u32count
)
7499 s32 s32Error
= WILC_SUCCESS
;
7501 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7502 tstrHostIFmsg strHostIFmsg
;
7503 tstrHostIFSetMulti
*pstrMulticastFilterParam
= &strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetMulti
;
7506 if (pstrWFIDrv
== NULL
)
7507 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7509 PRINT_D(HOSTINF_DBG
, "Setting Multicast Filter params\n");
7511 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7514 /* prepare the WiphyParams Message */
7515 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SET_MULTICAST_FILTER
;
7516 strHostIFmsg
.drvHandler
= hWFIDrv
;
7518 pstrMulticastFilterParam
->bIsEnabled
= bIsEnabled
;
7519 pstrMulticastFilterParam
->u32count
= u32count
;
7521 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7523 WILC_ERRORREPORT(s32Error
, s32Error
);
7524 WILC_CATCH(s32Error
)
7532 /*Bug4218: Parsing Join Param*/
7533 #ifdef WILC_PARSE_SCAN_IN_HOST
7535 /*Bug4218: Parsing Join Param*/
7537 * @brief host_int_ParseJoinBssParam
7538 * @details Parse Needed Join Parameters and save it in a new JoinBssParam entry
7539 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7544 static void *host_int_ParseJoinBssParam(tstrNetworkInfo
*ptstrNetworkInfo
)
7546 tstrJoinBssParam
*pNewJoinBssParam
= NULL
;
7555 u8 pcipherTotalCount
= 0;
7556 u8 authTotalCount
= 0;
7559 pu8IEs
= ptstrNetworkInfo
->pu8IEs
;
7560 u16IEsLen
= ptstrNetworkInfo
->u16IEsLen
;
7562 pNewJoinBssParam
= kmalloc(sizeof(tstrJoinBssParam
), GFP_KERNEL
);
7563 if (pNewJoinBssParam
!= NULL
) {
7564 memset(pNewJoinBssParam
, 0, sizeof(tstrJoinBssParam
));
7565 pNewJoinBssParam
->dtim_period
= ptstrNetworkInfo
->u8DtimPeriod
;
7566 pNewJoinBssParam
->beacon_period
= ptstrNetworkInfo
->u16BeaconPeriod
;
7567 pNewJoinBssParam
->cap_info
= ptstrNetworkInfo
->u16CapInfo
;
7568 memcpy(pNewJoinBssParam
->au8bssid
, ptstrNetworkInfo
->au8bssid
, 6);
7570 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/
7571 memcpy((u8
*)pNewJoinBssParam
->ssid
, ptstrNetworkInfo
->au8ssid
, ptstrNetworkInfo
->u8SsidLen
+ 1);
7572 pNewJoinBssParam
->ssidLen
= ptstrNetworkInfo
->u8SsidLen
;
7573 memset(pNewJoinBssParam
->rsn_pcip_policy
, 0xFF, 3);
7574 memset(pNewJoinBssParam
->rsn_auth_policy
, 0xFF, 3);
7575 /*for(i=0; i<pNewJoinBssParam->ssidLen;i++)
7576 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/
7578 /* parse supported rates: */
7579 while (index
< u16IEsLen
) {
7580 /* supportedRates IE */
7581 if (pu8IEs
[index
] == SUPP_RATES_IE
) {
7582 /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */
7583 suppRatesNo
= pu8IEs
[index
+ 1];
7584 pNewJoinBssParam
->supp_rates
[0] = suppRatesNo
;
7585 index
+= 2; /* skipping ID and length bytes; */
7587 for (i
= 0; i
< suppRatesNo
; i
++) {
7588 pNewJoinBssParam
->supp_rates
[i
+ 1] = pu8IEs
[index
+ i
];
7589 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */
7591 index
+= suppRatesNo
;
7594 /* Ext SupportedRates IE */
7595 else if (pu8IEs
[index
] == EXT_SUPP_RATES_IE
) {
7596 /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */
7597 /* checking if no of ext. supp and supp rates < max limit */
7598 extSuppRatesNo
= pu8IEs
[index
+ 1];
7599 if (extSuppRatesNo
> (MAX_RATES_SUPPORTED
- suppRatesNo
))
7600 pNewJoinBssParam
->supp_rates
[0] = MAX_RATES_SUPPORTED
;
7602 pNewJoinBssParam
->supp_rates
[0] += extSuppRatesNo
;
7604 /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */
7605 for (i
= 0; i
< (pNewJoinBssParam
->supp_rates
[0] - suppRatesNo
); i
++) {
7606 pNewJoinBssParam
->supp_rates
[suppRatesNo
+ i
+ 1] = pu8IEs
[index
+ i
];
7607 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */
7609 index
+= extSuppRatesNo
;
7613 else if (pu8IEs
[index
] == HT_CAPABILITY_IE
) {
7614 /* if IE found set the flag */
7615 pNewJoinBssParam
->ht_capable
= true;
7616 index
+= pu8IEs
[index
+ 1] + 2; /* ID,Length bytes and IE body */
7617 /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */
7619 } else if ((pu8IEs
[index
] == WMM_IE
) && /* WMM Element ID */
7620 (pu8IEs
[index
+ 2] == 0x00) && (pu8IEs
[index
+ 3] == 0x50) &&
7621 (pu8IEs
[index
+ 4] == 0xF2) && /* OUI */
7622 (pu8IEs
[index
+ 5] == 0x02) && /* OUI Type */
7623 ((pu8IEs
[index
+ 6] == 0x00) || (pu8IEs
[index
+ 6] == 0x01)) && /* OUI Sub Type */
7624 (pu8IEs
[index
+ 7] == 0x01)) {
7625 /* Presence of WMM Info/Param element indicates WMM capability */
7626 pNewJoinBssParam
->wmm_cap
= true;
7628 /* Check if Bit 7 is set indicating U-APSD capability */
7629 if (pu8IEs
[index
+ 8] & (1 << 7))
7630 pNewJoinBssParam
->uapsd_cap
= true;
7631 index
+= pu8IEs
[index
+ 1] + 2;
7635 else if ((pu8IEs
[index
] == P2P_IE
) && /* P2P Element ID */
7636 (pu8IEs
[index
+ 2] == 0x50) && (pu8IEs
[index
+ 3] == 0x6f) &&
7637 (pu8IEs
[index
+ 4] == 0x9a) && /* OUI */
7638 (pu8IEs
[index
+ 5] == 0x09) && (pu8IEs
[index
+ 6] == 0x0c)) { /* OUI Type */
7641 pNewJoinBssParam
->tsf
= ptstrNetworkInfo
->u32Tsf
;
7642 pNewJoinBssParam
->u8NoaEnbaled
= 1;
7643 pNewJoinBssParam
->u8Index
= pu8IEs
[index
+ 9];
7645 /* Check if Bit 7 is set indicating Opss capability */
7646 if (pu8IEs
[index
+ 10] & (1 << 7)) {
7647 pNewJoinBssParam
->u8OppEnable
= 1;
7648 pNewJoinBssParam
->u8CtWindow
= pu8IEs
[index
+ 10];
7650 pNewJoinBssParam
->u8OppEnable
= 0;
7652 PRINT_D(GENERIC_DBG
, "P2P Dump\n");
7653 for (i
= 0; i
< pu8IEs
[index
+ 7]; i
++)
7654 PRINT_D(GENERIC_DBG
, " %x\n", pu8IEs
[index
+ 9 + i
]);
7656 pNewJoinBssParam
->u8Count
= pu8IEs
[index
+ 11];
7657 u16P2P_count
= index
+ 12;
7659 memcpy(pNewJoinBssParam
->au8Duration
, pu8IEs
+ u16P2P_count
, 4);
7662 memcpy(pNewJoinBssParam
->au8Interval
, pu8IEs
+ u16P2P_count
, 4);
7665 memcpy(pNewJoinBssParam
->au8StartTime
, pu8IEs
+ u16P2P_count
, 4);
7667 index
+= pu8IEs
[index
+ 1] + 2;
7672 else if ((pu8IEs
[index
] == RSN_IE
) ||
7673 ((pu8IEs
[index
] == WPA_IE
) && (pu8IEs
[index
+ 2] == 0x00) &&
7674 (pu8IEs
[index
+ 3] == 0x50) && (pu8IEs
[index
+ 4] == 0xF2) &&
7675 (pu8IEs
[index
+ 5] == 0x01))) {
7676 u16 rsnIndex
= index
;
7677 /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]);
7678 * for(i=0; i<pu8IEs[rsnIndex+1]; i++)
7680 * PRINT_D(HOSTINF_DBG,"%0x ",pu8IEs[rsnIndex+2+i]);
7682 if (pu8IEs
[rsnIndex
] == RSN_IE
) {
7683 pNewJoinBssParam
->mode_802_11i
= 2;
7684 /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */
7685 } else { /* check if rsn was previously parsed */
7686 if (pNewJoinBssParam
->mode_802_11i
== 0)
7687 pNewJoinBssParam
->mode_802_11i
= 1;
7688 /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */
7691 rsnIndex
+= 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */
7692 pNewJoinBssParam
->rsn_grp_policy
= pu8IEs
[rsnIndex
];
7694 /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x\n",pNewJoinBssParam->rsn_grp_policy); */
7695 /* initialize policies with invalid values */
7697 jumpOffset
= pu8IEs
[rsnIndex
] * 4; /* total no.of bytes of pcipher field (count*4) */
7699 /*parsing pairwise cipher*/
7701 /* saving 3 pcipher max. */
7702 pcipherCount
= (pu8IEs
[rsnIndex
] > 3) ? 3 : pu8IEs
[rsnIndex
];
7703 rsnIndex
+= 2; /* jump 2 bytes of pcipher count */
7705 /* PRINT_D(HOSTINF_DBG,"\npcipher:%d\n",pcipherCount); */
7706 for (i
= pcipherTotalCount
, j
= 0; i
< pcipherCount
+ pcipherTotalCount
&& i
< 3; i
++, j
++) {
7707 /* each count corresponds to 4 bytes, only last byte is saved */
7708 pNewJoinBssParam
->rsn_pcip_policy
[i
] = pu8IEs
[rsnIndex
+ ((j
+ 1) * 4) - 1];
7709 /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */
7711 pcipherTotalCount
+= pcipherCount
;
7712 rsnIndex
+= jumpOffset
;
7714 jumpOffset
= pu8IEs
[rsnIndex
] * 4;
7716 /*parsing AKM suite (auth_policy)*/
7717 /* saving 3 auth policies max. */
7718 authCount
= (pu8IEs
[rsnIndex
] > 3) ? 3 : pu8IEs
[rsnIndex
];
7719 rsnIndex
+= 2; /* jump 2 bytes of pcipher count */
7721 for (i
= authTotalCount
, j
= 0; i
< authTotalCount
+ authCount
; i
++, j
++) {
7722 /* each count corresponds to 4 bytes, only last byte is saved */
7723 pNewJoinBssParam
->rsn_auth_policy
[i
] = pu8IEs
[rsnIndex
+ ((j
+ 1) * 4) - 1];
7725 authTotalCount
+= authCount
;
7726 rsnIndex
+= jumpOffset
;
7727 /*pasring rsn cap. only if rsn IE*/
7728 if (pu8IEs
[index
] == RSN_IE
) {
7729 pNewJoinBssParam
->rsn_cap
[0] = pu8IEs
[rsnIndex
];
7730 pNewJoinBssParam
->rsn_cap
[1] = pu8IEs
[rsnIndex
+ 1];
7733 pNewJoinBssParam
->rsn_found
= true;
7734 index
+= pu8IEs
[index
+ 1] + 2; /* ID,Length bytes and IE body */
7737 index
+= pu8IEs
[index
+ 1] + 2; /* ID,Length bytes and IE body */
7744 return (void *)pNewJoinBssParam
;
7748 void host_int_freeJoinParams(void *pJoinParams
)
7750 if ((tstrJoinBssParam
*)pJoinParams
!= NULL
)
7751 kfree((tstrJoinBssParam
*)pJoinParams
);
7753 PRINT_ER("Unable to FREE null pointer\n");
7755 #endif /*WILC_PARSE_SCAN_IN_HOST*/
7759 * @brief host_int_addBASession
7760 * @details Open a block Ack session with the given parameters
7761 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7763 * @author anoureldin
7767 static int host_int_addBASession(tstrWILC_WFIDrv
*hWFIDrv
, char *pBSSID
, char TID
, short int BufferSize
,
7768 short int SessionTimeout
, void *drvHandler
)
7770 s32 s32Error
= WILC_SUCCESS
;
7771 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7772 tstrHostIFmsg strHostIFmsg
;
7773 tstrHostIfBASessionInfo
*pBASessionInfo
= &strHostIFmsg
.uniHostIFmsgBody
.strHostIfBASessionInfo
;
7775 if (pstrWFIDrv
== NULL
)
7776 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7778 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7780 /* prepare the WiphyParams Message */
7781 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_ADD_BA_SESSION
;
7783 memcpy(pBASessionInfo
->au8Bssid
, pBSSID
, ETH_ALEN
);
7784 pBASessionInfo
->u8Ted
= TID
;
7785 pBASessionInfo
->u16BufferSize
= BufferSize
;
7786 pBASessionInfo
->u16SessionTimeout
= SessionTimeout
;
7787 strHostIFmsg
.drvHandler
= hWFIDrv
;
7789 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7791 WILC_ERRORREPORT(s32Error
, s32Error
);
7792 WILC_CATCH(s32Error
)
7801 s32
host_int_delBASession(tstrWILC_WFIDrv
*hWFIDrv
, char *pBSSID
, char TID
)
7803 s32 s32Error
= WILC_SUCCESS
;
7804 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7805 tstrHostIFmsg strHostIFmsg
;
7806 tstrHostIfBASessionInfo
*pBASessionInfo
= &strHostIFmsg
.uniHostIFmsgBody
.strHostIfBASessionInfo
;
7808 if (pstrWFIDrv
== NULL
)
7809 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7811 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7813 /* prepare the WiphyParams Message */
7814 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_DEL_BA_SESSION
;
7816 memcpy(pBASessionInfo
->au8Bssid
, pBSSID
, ETH_ALEN
);
7817 pBASessionInfo
->u8Ted
= TID
;
7818 strHostIFmsg
.drvHandler
= hWFIDrv
;
7820 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7822 WILC_ERRORREPORT(s32Error
, s32Error
);
7823 WILC_CATCH(s32Error
)
7829 down(&hWaitResponse
);
7834 s32
host_int_del_All_Rx_BASession(tstrWILC_WFIDrv
*hWFIDrv
, char *pBSSID
, char TID
)
7836 s32 s32Error
= WILC_SUCCESS
;
7837 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7838 tstrHostIFmsg strHostIFmsg
;
7839 tstrHostIfBASessionInfo
*pBASessionInfo
= &strHostIFmsg
.uniHostIFmsgBody
.strHostIfBASessionInfo
;
7841 if (pstrWFIDrv
== NULL
)
7842 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7844 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7846 /* prepare the WiphyParams Message */
7847 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS
;
7849 memcpy(pBASessionInfo
->au8Bssid
, pBSSID
, ETH_ALEN
);
7850 pBASessionInfo
->u8Ted
= TID
;
7851 strHostIFmsg
.drvHandler
= hWFIDrv
;
7853 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7855 WILC_ERRORREPORT(s32Error
, s32Error
);
7856 WILC_CATCH(s32Error
)
7862 down(&hWaitResponse
);
7868 * @brief host_int_setup_ipaddress
7869 * @details setup IP in firmware
7870 * @param[in] Handle to wifi driver
7871 * @return Error code.
7872 * @author Abdelrahman Sobhy
7875 s32
host_int_setup_ipaddress(tstrWILC_WFIDrv
*hWFIDrv
, u8
*u16ipadd
, u8 idx
)
7877 s32 s32Error
= WILC_SUCCESS
;
7878 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7879 tstrHostIFmsg strHostIFmsg
;
7881 /* TODO: Enable This feature on softap firmware */
7884 if (pstrWFIDrv
== NULL
)
7885 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7887 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7889 /* prepare the WiphyParams Message */
7890 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SET_IPADDRESS
;
7892 strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.au8IPAddr
= u16ipadd
;
7893 strHostIFmsg
.drvHandler
= hWFIDrv
;
7894 strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.idx
= idx
;
7896 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7898 WILC_ERRORREPORT(s32Error
, s32Error
);
7899 WILC_CATCH(s32Error
)
7910 * @brief host_int_get_ipaddress
7911 * @details Get IP from firmware
7912 * @param[in] Handle to wifi driver
7913 * @return Error code.
7914 * @author Abdelrahman Sobhy
7917 s32
host_int_get_ipaddress(tstrWILC_WFIDrv
*hWFIDrv
, u8
*u16ipadd
, u8 idx
)
7919 s32 s32Error
= WILC_SUCCESS
;
7920 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7921 tstrHostIFmsg strHostIFmsg
;
7923 if (pstrWFIDrv
== NULL
)
7924 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7926 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7928 /* prepare the WiphyParams Message */
7929 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_IPADDRESS
;
7931 strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.au8IPAddr
= u16ipadd
;
7932 strHostIFmsg
.drvHandler
= hWFIDrv
;
7933 strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.idx
= idx
;
7935 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7937 WILC_ERRORREPORT(s32Error
, s32Error
);
7938 WILC_CATCH(s32Error
)