1 #include "host_interface.h"
2 #include "coreconfigurator.h"
4 extern s32
TransportInit(void);
5 extern s32
TransportDeInit(void);
8 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
9 extern struct timer_list hDuringIpTimer
;
13 extern u8 g_wilc_initialized
;
14 /*****************************************************************************/
16 /*****************************************************************************/
18 /* Message types of the Host IF Message Queue*/
19 #define HOST_IF_MSG_SCAN 0
20 #define HOST_IF_MSG_CONNECT 1
21 #define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
22 #define HOST_IF_MSG_KEY 3
23 #define HOST_IF_MSG_RCVD_NTWRK_INFO 4
24 #define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
25 #define HOST_IF_MSG_CFG_PARAMS 6
26 #define HOST_IF_MSG_SET_CHANNEL 7
27 #define HOST_IF_MSG_DISCONNECT 8
28 #define HOST_IF_MSG_GET_RSSI 9
29 #define HOST_IF_MSG_GET_CHNL 10
30 #define HOST_IF_MSG_ADD_BEACON 11
31 #define HOST_IF_MSG_DEL_BEACON 12
32 #define HOST_IF_MSG_ADD_STATION 13
33 #define HOST_IF_MSG_DEL_STATION 14
34 #define HOST_IF_MSG_EDIT_STATION 15
35 #define HOST_IF_MSG_SCAN_TIMER_FIRED 16
36 #define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
37 #define HOST_IF_MSG_POWER_MGMT 18
38 #define HOST_IF_MSG_GET_INACTIVETIME 19
39 #define HOST_IF_MSG_REMAIN_ON_CHAN 20
40 #define HOST_IF_MSG_REGISTER_FRAME 21
41 #define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
42 #define HOST_IF_MSG_GET_LINKSPEED 23
43 #define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
44 #define HOST_IF_MSG_SET_MAC_ADDRESS 25
45 #define HOST_IF_MSG_GET_MAC_ADDRESS 26
46 #define HOST_IF_MSG_SET_OPERATION_MODE 27
47 #define HOST_IF_MSG_SET_IPADDRESS 28
48 #define HOST_IF_MSG_GET_IPADDRESS 29
49 #define HOST_IF_MSG_FLUSH_CONNECT 30
50 #define HOST_IF_MSG_GET_STATISTICS 31
51 #define HOST_IF_MSG_SET_MULTICAST_FILTER 32
52 #define HOST_IF_MSG_ADD_BA_SESSION 33
53 #define HOST_IF_MSG_DEL_BA_SESSION 34
54 #define HOST_IF_MSG_Q_IDLE 35
55 #define HOST_IF_MSG_DEL_ALL_STA 36
56 #define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
57 #define HOST_IF_MSG_EXIT 100
59 #define HOST_IF_SCAN_TIMEOUT 4000
60 #define HOST_IF_CONNECT_TIMEOUT 9500
62 #define BA_SESSION_DEFAULT_BUFFER_SIZE 16
63 #define BA_SESSION_DEFAULT_TIMEOUT 1000
64 #define BLOCK_ACK_REQ_SIZE 0x14
65 /*****************************************************************************/
66 /* Type Definitions */
67 /*****************************************************************************/
70 * @struct tstrHostIFCfgParamAttr
71 * @brief Structure to hold Host IF CFG Params Attributes
75 * @author Mai Daftedar
79 typedef struct _tstrHostIFCfgParamAttr
{
80 tstrCfgParamVal pstrCfgParamVal
;
82 } tstrHostIFCfgParamAttr
;
85 * @struct tstrHostIFwpaAttr
86 * @brief Structure to hold Host IF Scan Attributes
90 * @author Mai Daftedar
94 typedef struct _tstrHostIFwpaAttr
{
106 * @struct tstrHostIFwepAttr
107 * @brief Structure to hold Host IF Scan Attributes
111 * @author Mai Daftedar
112 * @date 25 March 2012
115 typedef struct _tstrHostIFwepAttr
{
120 AUTHTYPE_T tenuAuth_type
;
125 * @struct tuniHostIFkeyAttr
126 * @brief Structure to hold Host IF Scan Attributes
130 * @author Mai Daftedar
131 * @date 25 March 2012
134 typedef union _tuniHostIFkeyAttr
{
135 tstrHostIFwepAttr strHostIFwepAttr
;
136 tstrHostIFwpaAttr strHostIFwpaAttr
;
137 tstrHostIFpmkidAttr strHostIFpmkidAttr
;
141 * @struct tstrHostIFkeyAttr
142 * @brief Structure to hold Host IF Scan Attributes
146 * @author Mai Daftedar
147 * @date 25 March 2012
150 typedef struct _tstrHostIFkeyAttr
{
151 tenuKeyType enuKeyType
;
153 tuniHostIFkeyAttr uniHostIFkeyAttr
;
160 * @struct tstrHostIFscanAttr
161 * @brief Structure to hold Host IF Scan Attributes
165 * @author Mostafa Abu Bakr
166 * @date 25 March 2012
169 typedef struct _tstrHostIFscanAttr
{
176 tWILCpfScanResult pfScanResult
;
179 tstrHiddenNetwork strHiddenNetwork
;
181 } tstrHostIFscanAttr
;
184 * @struct tstrHostIFconnectAttr
185 * @brief Structure to hold Host IF Connect Attributes
189 * @author Mostafa Abu Bakr
190 * @date 25 March 2012
193 typedef struct _tstrHostIFconnectAttr
{
200 tWILCpfConnectResult pfConnectResult
;
202 AUTHTYPE_T tenuAuth_type
;
205 } tstrHostIFconnectAttr
;
208 * @struct tstrRcvdGnrlAsyncInfo
209 * @brief Structure to hold Received General Asynchronous info
213 * @author Mostafa Abu Bakr
214 * @date 25 March 2012
217 typedef struct _tstrRcvdGnrlAsyncInfo
{
220 } tstrRcvdGnrlAsyncInfo
;
223 * @struct tstrHostIFSetChan
224 * @brief Set Channel message body
228 * @author Mai Daftedar
229 * @date 25 March 2012
232 typedef struct _tstrHostIFSetChan
{
237 * @struct tstrHostIFSetChan
238 * @brief Get Channel message body
242 * @author Mai Daftedar
246 typedef struct _tstrHostIFGetChan
{
250 /*bug3819: Add Scan acomplete notification to host*/
252 * @struct tstrScanComplete
253 * @brief hold received Async. Scan Complete message body
258 * @date 25 March 2012
261 /*typedef struct _tstrScanComplete
265 * } tstrScanComplete;*/
268 * @struct tstrHostIFSetBeacon
269 * @brief Set Beacon message body
273 * @author Adham Abozaeid
277 typedef struct _tstrHostIFSetBeacon
{
278 u32 u32Interval
; /*!< Beacon Interval. Period between two successive beacons on air */
279 u32 u32DTIMPeriod
; /*!< DTIM Period. Indicates how many Beacon frames
280 * (including the current frame) appear before the next DTIM */
281 u32 u32HeadLen
; /*!< Length of the head buffer in bytes */
282 u8
*pu8Head
; /*!< Pointer to the beacon's head buffer. Beacon's head is the part
283 * from the beacon's start till the TIM element, NOT including the TIM */
284 u32 u32TailLen
; /*!< Length of the tail buffer in bytes */
285 u8
*pu8Tail
; /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just
286 * after the TIM inormation element */
287 } tstrHostIFSetBeacon
;
292 * @struct tstrHostIFDelBeacon
293 * @brief Del Beacon message body
297 * @author Adham Abozaeid
301 typedef struct _tstrHostIFDelBeacon
{
303 } tstrHostIFDelBeacon
;
306 * @struct tstrHostIFSetMulti
307 * @brief set Multicast filter Address
311 * @author Abdelrahman Sobhy
312 * @date 30 August 2013
313 * @version 1.0 Description
319 } tstrHostIFSetMulti
;
322 * @struct tstrHostIFDelAllSta
323 * @brief Deauth station message body
327 * @author Mai Daftedar
328 * @date 09 April 2014
329 * @version 1.0 Description
333 u8 au8Sta_DelAllSta
[MAX_NUM_STA
][ETH_ALEN
];
335 } tstrHostIFDelAllSta
;
338 * @struct tstrHostIFDelSta
339 * @brief Delete station message body
343 * @author Adham Abozaeid
345 * @version 1.0 Description
349 u8 au8MacAddr
[ETH_ALEN
];
353 * @struct tstrTimerCb
354 * @brief Timer callback message body
358 * @author Mostafa Abu Bakr
359 * @date 25 March 2012
362 typedef struct _tstrTimerCb
{
363 void *pvUsrArg
; /*!< Private data passed at timer start */
367 * @struct tstrHostIfPowerMgmtParam
368 * @brief Power management message body
372 * @author Adham Abozaeid
373 * @date 24 November 2012
380 } tstrHostIfPowerMgmtParam
;
383 * @struct tstrHostIFSetIPAddr
384 * @brief set IP Address message body
388 * @author Abdelrahman Sobhy
389 * @date 30 August 2013
390 * @version 1.0 Description
396 } tstrHostIFSetIPAddr
;
399 * @struct tstrHostIfStaInactiveT
400 * @brief Get station message body
404 * @author Mai Daftedar
405 * @date 16 April 2013
411 } tstrHostIfStaInactiveT
;
414 * @union tuniHostIFmsgBody
415 * @brief Message body for the Host Interface message_q
419 * @author Mostafa Abu Bakr
420 * @date 25 March 2012
423 typedef union _tuniHostIFmsgBody
{
424 tstrHostIFscanAttr strHostIFscanAttr
; /*!< Host IF Scan Request Attributes message body */
425 tstrHostIFconnectAttr strHostIFconnectAttr
; /*!< Host IF Connect Request Attributes message body */
426 tstrRcvdNetworkInfo strRcvdNetworkInfo
; /*!< Received Asynchronous Network Info message body */
427 tstrRcvdGnrlAsyncInfo strRcvdGnrlAsyncInfo
; /*!< Received General Asynchronous Info message body */
428 tstrHostIFkeyAttr strHostIFkeyAttr
; /*!<>*/
429 tstrHostIFCfgParamAttr strHostIFCfgParamAttr
; /*! <CFG Parameter message Body> */
430 tstrHostIFSetChan strHostIFSetChan
;
431 tstrHostIFGetChan strHostIFGetChan
;
432 tstrHostIFSetBeacon strHostIFSetBeacon
; /*!< Set beacon message body */
433 tstrHostIFDelBeacon strHostIFDelBeacon
; /*!< Del beacon message body */
434 tstrWILC_AddStaParam strAddStaParam
; /*!< Add station message body */
435 tstrHostIFDelSta strDelStaParam
; /*!< Del Station message body */
436 tstrWILC_AddStaParam strEditStaParam
; /*!< Edit station message body */
437 /* tstrScanComplete strScanComplete; / *Received Async. Scan Complete message body* / */
438 tstrTimerCb strTimerCb
; /*!< Timer callback message body */
439 tstrHostIfPowerMgmtParam strPowerMgmtparam
; /*!< Power Management message body */
440 tstrHostIfStaInactiveT strHostIfStaInactiveT
;
441 tstrHostIFSetIPAddr strHostIfSetIP
;
442 tstrHostIfSetDrvHandler strHostIfSetDrvHandler
;
443 tstrHostIFSetMulti strHostIfSetMulti
;
444 tstrHostIfSetOperationMode strHostIfSetOperationMode
;
445 tstrHostIfSetMacAddress strHostIfSetMacAddress
;
446 tstrHostIfGetMacAddress strHostIfGetMacAddress
;
447 tstrHostIfBASessionInfo strHostIfBASessionInfo
;
449 tstrHostIfRemainOnChan strHostIfRemainOnChan
;
450 tstrHostIfRegisterFrame strHostIfRegisterFrame
;
453 tstrHostIFDelAllSta strHostIFDelAllSta
;
457 * @struct tstrHostIFmsg
458 * @brief Host Interface message
462 * @author Mostafa Abu Bakr
463 * @date 25 March 2012
466 typedef struct _tstrHostIFmsg
{
467 u16 u16MsgId
; /*!< Message ID */
468 tuniHostIFmsgBody uniHostIFmsgBody
; /*!< Message body */
469 tstrWILC_WFIDrv
*drvHandler
;
472 #ifdef CONNECT_DIRECT
473 typedef struct _tstrWidJoinReqExt
{
474 char SSID
[MAX_SSID_LEN
];
480 /*Bug4218: Parsing Join Param*/
481 #ifdef WILC_PARSE_SCAN_IN_HOST
482 /*Struct containg joinParam of each AP*/
483 typedef struct _tstrJoinBssParam
{
489 char ssid
[MAX_SSID_LEN
];
491 u8 supp_rates
[MAX_RATES_SUPPORTED
+ 1];
498 u8 rsn_pcip_policy
[3];
499 u8 rsn_auth_policy
[3];
501 struct _tstrJoinParam
*nextJoinBss
;
514 /*Bug4218: Parsing Join Param*/
515 /*a linked list table containing needed join parameters entries for each AP found in most recent scan*/
516 typedef struct _tstrBssTable
{
518 tstrJoinBssParam
*head
;
519 tstrJoinBssParam
*tail
;
521 #endif /*WILC_PARSE_SCAN_IN_HOST*/
526 SCAN_CONNECT_TIMER_FORCE_32BIT
= 0xFFFFFFFF
529 /*****************************************************************************/
531 /* Global Variabls */
533 /*****************************************************************************/
534 /* Zero is not used, because a zero ID means termination */
535 static tstrWILC_WFIDrv
*wfidrv_list
[NUM_CONCURRENT_IFC
+ 1];
536 tstrWILC_WFIDrv
*terminated_handle
;
537 tstrWILC_WFIDrv
*gWFiDrvHandle
;
538 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
539 bool g_obtainingIP
= false;
542 static struct task_struct
*HostIFthreadHandler
;
543 static WILC_MsgQueueHandle gMsgQHostIF
;
544 static struct semaphore hSemHostIFthrdEnd
;
546 struct semaphore hSemDeinitDrvHandle
;
547 static struct semaphore hWaitResponse
;
548 struct semaphore hSemHostIntDeinit
;
549 struct timer_list g_hPeriodicRSSI
;
553 u8 gau8MulticastMacAddrList
[WILC_MULTICAST_TABLE_SIZE
][ETH_ALEN
];
555 #ifndef CONNECT_DIRECT
556 static u8 gapu8RcvdSurveyResults
[2][MAX_SURVEY_RESULT_FRAG_SIZE
];
559 static u8 gapu8RcvdAssocResp
[MAX_ASSOC_RESP_FRAME_SIZE
];
561 bool gbScanWhileConnected
= false;
566 static u8 gs8SetIP
[2][4];
567 static u8 gs8GetIP
[2][4];
568 #ifdef WILC_AP_EXTERNAL_MLME
569 static u32 gu32InactiveTime
;
572 static u32 gu32WidConnRstHack
;
575 u8
*gu8FlushedJoinReq
;
576 u8
*gu8FlushedInfoElemAsoc
;
577 u8 gu8Flushed11iMode
;
578 u8 gu8FlushedAuthType
;
579 u32 gu32FlushedJoinReqSize
;
580 u32 gu32FlushedInfoElemAsocSize
;
581 tstrWILC_WFIDrv
*gu8FlushedJoinReqDrvHandler
;
582 #define REAL_JOIN_REQ 0
583 #define FLUSHED_JOIN_REQ 1
584 #define FLUSHED_BYTE_POS 79 /* Position the byte indicating flushing in the flushed request */
586 /*Bug4218: Parsing Join Param*/
587 #ifdef WILC_PARSE_SCAN_IN_HOST
588 /*Bug4218: Parsing Join Param*/
589 static void *host_int_ParseJoinBssParam(tstrNetworkInfo
*ptstrNetworkInfo
);
590 #endif /*WILC_PARSE_SCAN_IN_HOST*/
592 extern void chip_sleep_manually(u32 u32SleepTime
);
593 extern int linux_wlan_get_num_conn_ifcs(void);
595 static int add_handler_in_list(tstrWILC_WFIDrv
*handler
)
599 for (i
= 1; i
< ARRAY_SIZE(wfidrv_list
); i
++) {
600 if (!wfidrv_list
[i
]) {
601 wfidrv_list
[i
] = handler
;
609 static int remove_handler_in_list(tstrWILC_WFIDrv
*handler
)
613 for (i
= 1; i
< ARRAY_SIZE(wfidrv_list
); i
++) {
614 if (wfidrv_list
[i
] == handler
) {
615 wfidrv_list
[i
] = NULL
;
623 static int get_id_from_handler(tstrWILC_WFIDrv
*handler
)
630 for (i
= 1; i
< ARRAY_SIZE(wfidrv_list
); i
++) {
631 if (wfidrv_list
[i
] == handler
)
638 static tstrWILC_WFIDrv
*get_handler_from_id(int id
)
640 if (id
<= 0 || id
>= ARRAY_SIZE(wfidrv_list
))
642 return wfidrv_list
[id
];
646 * @brief Handle_SetChannel
647 * @details Sending config packet to firmware to set channel
648 * @param[in] tstrHostIFSetChan* pstrHostIFSetChan
649 * @return Error code.
654 static s32
Handle_SetChannel(tstrWILC_WFIDrv
*drvHandler
, tstrHostIFSetChan
*pstrHostIFSetChan
)
657 s32 s32Error
= WILC_SUCCESS
;
659 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
661 /*prepare configuration packet*/
662 strWID
.u16WIDid
= (u16
)WID_CURRENT_CHANNEL
;
663 strWID
.enuWIDtype
= WID_CHAR
;
664 strWID
.ps8WidVal
= (char *)&(pstrHostIFSetChan
->u8SetChan
);
665 strWID
.s32ValueSize
= sizeof(char);
667 PRINT_D(HOSTINF_DBG
, "Setting channel\n");
669 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
670 get_id_from_handler(pstrWFIDrv
));
672 PRINT_ER("Failed to set channel\n");
673 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
683 * @brief Handle_SetWfiDrvHandler
684 * @details Sending config packet to firmware to set driver handler
685 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
686 * @return Error code.
691 static s32
Handle_SetWfiDrvHandler(tstrWILC_WFIDrv
*drvHandler
,
692 tstrHostIfSetDrvHandler
*pstrHostIfSetDrvHandler
)
695 s32 s32Error
= WILC_SUCCESS
;
697 tstrWILC_WFIDrv
*pstrWFIDrv
= drvHandler
;
700 /*prepare configuration packet*/
701 strWID
.u16WIDid
= (u16
)WID_SET_DRV_HANDLER
;
702 strWID
.enuWIDtype
= WID_INT
;
703 strWID
.ps8WidVal
= (s8
*)&(pstrHostIfSetDrvHandler
->u32Address
);
704 strWID
.s32ValueSize
= sizeof(u32
);
708 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
709 pstrHostIfSetDrvHandler
->u32Address
);
711 if (pstrWFIDrv
== NULL
)
712 up(&hSemDeinitDrvHandle
);
716 PRINT_ER("Failed to set driver handler\n");
717 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
728 * @brief Handle_SetWfiAPDrvHandler
729 * @details Sending config packet to firmware to set driver handler
730 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
731 * @return Error code.
736 static s32
Handle_SetOperationMode(tstrWILC_WFIDrv
*drvHandler
, tstrHostIfSetOperationMode
*pstrHostIfSetOperationMode
)
739 s32 s32Error
= WILC_SUCCESS
;
741 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
744 /*prepare configuration packet*/
745 strWID
.u16WIDid
= (u16
)WID_SET_OPERATION_MODE
;
746 strWID
.enuWIDtype
= WID_INT
;
747 strWID
.ps8WidVal
= (s8
*)&(pstrHostIfSetOperationMode
->u32Mode
);
748 strWID
.s32ValueSize
= sizeof(u32
);
751 PRINT_INFO(HOSTINF_DBG
, "pstrWFIDrv= %p\n", pstrWFIDrv
);
753 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
754 get_id_from_handler(pstrWFIDrv
));
757 if ((pstrHostIfSetOperationMode
->u32Mode
) == IDLE_MODE
)
758 up(&hSemDeinitDrvHandle
);
762 PRINT_ER("Failed to set driver handler\n");
763 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
774 * @brief host_int_set_IPAddress
775 * @details Setting IP address params in message queue
776 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
777 * @return Error code.
782 s32
Handle_set_IPAddress(tstrWILC_WFIDrv
*drvHandler
, u8
*pu8IPAddr
, u8 idx
)
785 s32 s32Error
= WILC_SUCCESS
;
787 char firmwareIPAddress
[4] = {0};
788 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
790 if (pu8IPAddr
[0] < 192)
793 PRINT_INFO(HOSTINF_DBG
, "Indx = %d, Handling set IP = %pI4\n", idx
, pu8IPAddr
);
795 memcpy(gs8SetIP
[idx
], pu8IPAddr
, IP_ALEN
);
797 /*prepare configuration packet*/
798 strWID
.u16WIDid
= (u16
)WID_IP_ADDRESS
;
799 strWID
.enuWIDtype
= WID_STR
;
800 strWID
.ps8WidVal
= (u8
*)pu8IPAddr
;
801 strWID
.s32ValueSize
= IP_ALEN
;
803 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
804 get_id_from_handler(pstrWFIDrv
));
807 host_int_get_ipaddress(drvHandler
, firmwareIPAddress
, idx
);
810 PRINT_D(HOSTINF_DBG
, "Failed to set IP address\n");
811 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
813 PRINT_INFO(HOSTINF_DBG
, "IP address set\n");
826 * @brief Handle_get_IPAddress
827 * @details Setting IP address params in message queue
828 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
829 * @return Error code.
834 s32
Handle_get_IPAddress(tstrWILC_WFIDrv
*drvHandler
, u8
*pu8IPAddr
, u8 idx
)
837 s32 s32Error
= WILC_SUCCESS
;
839 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
841 /*prepare configuration packet*/
842 strWID
.u16WIDid
= (u16
)WID_IP_ADDRESS
;
843 strWID
.enuWIDtype
= WID_STR
;
844 strWID
.ps8WidVal
= kmalloc(IP_ALEN
, GFP_KERNEL
);
845 strWID
.s32ValueSize
= IP_ALEN
;
847 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true,
848 get_id_from_handler(pstrWFIDrv
));
850 PRINT_INFO(HOSTINF_DBG
, "%pI4\n", strWID
.ps8WidVal
);
852 memcpy(gs8GetIP
[idx
], strWID
.ps8WidVal
, IP_ALEN
);
854 /*get the value by searching the local copy*/
855 kfree(strWID
.ps8WidVal
);
857 if (memcmp(gs8GetIP
[idx
], gs8SetIP
[idx
], IP_ALEN
) != 0)
858 host_int_setup_ipaddress(pstrWFIDrv
, gs8SetIP
[idx
], idx
);
860 if (s32Error
!= WILC_SUCCESS
) {
861 PRINT_ER("Failed to get IP address\n");
862 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
864 PRINT_INFO(HOSTINF_DBG
, "IP address retrieved:: u8IfIdx = %d\n", idx
);
865 PRINT_INFO(HOSTINF_DBG
, "%pI4\n", gs8GetIP
[idx
]);
866 PRINT_INFO(HOSTINF_DBG
, "\n");
880 * @brief Handle_SetMacAddress
881 * @details Setting mac address
882 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
883 * @return Error code.
884 * @author Amr Abdel-Moghny
885 * @date November 2013
888 static s32
Handle_SetMacAddress(tstrWILC_WFIDrv
*drvHandler
, tstrHostIfSetMacAddress
*pstrHostIfSetMacAddress
)
891 s32 s32Error
= WILC_SUCCESS
;
893 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
894 u8
*mac_buf
= kmalloc(ETH_ALEN
, GFP_KERNEL
);
896 if (mac_buf
== NULL
) {
897 PRINT_ER("No buffer to send mac address\n");
900 memcpy(mac_buf
, pstrHostIfSetMacAddress
->u8MacAddress
, ETH_ALEN
);
902 /*prepare configuration packet*/
903 strWID
.u16WIDid
= (u16
)WID_MAC_ADDR
;
904 strWID
.enuWIDtype
= WID_STR
;
905 strWID
.ps8WidVal
= mac_buf
;
906 strWID
.s32ValueSize
= ETH_ALEN
;
907 PRINT_D(GENERIC_DBG
, "mac addr = :%pM\n", strWID
.ps8WidVal
);
909 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
910 get_id_from_handler(pstrWFIDrv
));
912 PRINT_ER("Failed to set mac address\n");
913 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
927 * @brief Handle_GetMacAddress
928 * @details Getting mac address
929 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
930 * @return Error code.
931 * @author Amr Abdel-Moghny
935 static s32
Handle_GetMacAddress(tstrWILC_WFIDrv
*drvHandler
, tstrHostIfGetMacAddress
*pstrHostIfGetMacAddress
)
938 s32 s32Error
= WILC_SUCCESS
;
941 /*prepare configuration packet*/
942 strWID
.u16WIDid
= (u16
)WID_MAC_ADDR
;
943 strWID
.enuWIDtype
= WID_STR
;
944 strWID
.ps8WidVal
= pstrHostIfGetMacAddress
->u8MacAddress
;
945 strWID
.s32ValueSize
= ETH_ALEN
;
948 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, false,
949 get_id_from_handler(drvHandler
));
951 PRINT_ER("Failed to get mac address\n");
952 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
965 * @brief Handle_CfgParam
966 * @details Sending config packet to firmware to set CFG params
967 * @param[in] tstrHostIFCfgParamAttr* strHostIFCfgParamAttr
968 * @return Error code.
973 static s32
Handle_CfgParam(tstrWILC_WFIDrv
*drvHandler
, tstrHostIFCfgParamAttr
*strHostIFCfgParamAttr
)
975 s32 s32Error
= WILC_SUCCESS
;
976 tstrWID strWIDList
[32];
978 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
981 down(&(pstrWFIDrv
->gtOsCfgValuesSem
));
984 PRINT_D(HOSTINF_DBG
, "Setting CFG params\n");
986 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& BSS_TYPE
) {
987 /*----------------------------------------------------------*/
988 /*Input Value: INFRASTRUCTURE = 1, */
989 /* INDEPENDENT= 2, */
991 /*----------------------------------------------------------*/
992 /* validate input then copy>> need to check value 4 and 5 */
993 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.bss_type
< 6) {
994 strWIDList
[u8WidCnt
].u16WIDid
= WID_BSS_TYPE
;
995 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.bss_type
;
996 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
997 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
998 pstrWFIDrv
->strCfgValues
.bss_type
= (u8
)strHostIFCfgParamAttr
->pstrCfgParamVal
.bss_type
;
1000 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1004 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& AUTH_TYPE
) {
1005 /*------------------------------------------------------*/
1006 /*Input Values: OPEN_SYSTEM = 0, */
1007 /* SHARED_KEY = 1, */
1009 /*------------------------------------------------------*/
1010 /*validate Possible values*/
1011 if ((strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_type
) == 1 || (strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_type
) == 2 || (strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_type
) == 5) {
1012 strWIDList
[u8WidCnt
].u16WIDid
= WID_AUTH_TYPE
;
1013 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_type
;
1014 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
1015 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
1016 pstrWFIDrv
->strCfgValues
.auth_type
= (u8
)strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_type
;
1018 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1022 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& AUTHEN_TIMEOUT
) {
1023 /* range is 1 to 65535. */
1024 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_timeout
> 0 && strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_timeout
< 65536) {
1025 strWIDList
[u8WidCnt
].u16WIDid
= WID_AUTH_TIMEOUT
;
1026 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_timeout
;
1027 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1028 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1029 pstrWFIDrv
->strCfgValues
.auth_timeout
= strHostIFCfgParamAttr
->pstrCfgParamVal
.auth_timeout
;
1031 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1035 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& POWER_MANAGEMENT
) {
1036 /*-----------------------------------------------------------*/
1037 /*Input Values: NO_POWERSAVE = 0, */
1038 /* MIN_FAST_PS = 1, */
1039 /* MAX_FAST_PS = 2, */
1040 /* MIN_PSPOLL_PS = 3, */
1041 /* MAX_PSPOLL_PS = 4 */
1042 /*----------------------------------------------------------*/
1043 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.power_mgmt_mode
< 5) {
1044 strWIDList
[u8WidCnt
].u16WIDid
= WID_POWER_MANAGEMENT
;
1045 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.power_mgmt_mode
;
1046 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
1047 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
1048 pstrWFIDrv
->strCfgValues
.power_mgmt_mode
= (u8
)strHostIFCfgParamAttr
->pstrCfgParamVal
.power_mgmt_mode
;
1050 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1054 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& RETRY_SHORT
) {
1055 /* range from 1 to 256 */
1056 if ((strHostIFCfgParamAttr
->pstrCfgParamVal
.short_retry_limit
> 0) && (strHostIFCfgParamAttr
->pstrCfgParamVal
.short_retry_limit
< 256)) {
1057 strWIDList
[u8WidCnt
].u16WIDid
= WID_SHORT_RETRY_LIMIT
;
1058 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.short_retry_limit
;
1059 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1060 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1061 pstrWFIDrv
->strCfgValues
.short_retry_limit
= strHostIFCfgParamAttr
->pstrCfgParamVal
.short_retry_limit
;
1063 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1067 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& RETRY_LONG
) {
1068 /* range from 1 to 256 */
1069 if ((strHostIFCfgParamAttr
->pstrCfgParamVal
.long_retry_limit
> 0) && (strHostIFCfgParamAttr
->pstrCfgParamVal
.long_retry_limit
< 256)) {
1070 strWIDList
[u8WidCnt
].u16WIDid
= WID_LONG_RETRY_LIMIT
;
1071 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.long_retry_limit
;
1073 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1074 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1075 pstrWFIDrv
->strCfgValues
.long_retry_limit
= strHostIFCfgParamAttr
->pstrCfgParamVal
.long_retry_limit
;
1077 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1081 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& FRAG_THRESHOLD
) {
1083 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.frag_threshold
> 255 && strHostIFCfgParamAttr
->pstrCfgParamVal
.frag_threshold
< 7937) {
1084 strWIDList
[u8WidCnt
].u16WIDid
= WID_FRAG_THRESHOLD
;
1085 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.frag_threshold
;
1086 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1087 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1088 pstrWFIDrv
->strCfgValues
.frag_threshold
= strHostIFCfgParamAttr
->pstrCfgParamVal
.frag_threshold
;
1090 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1094 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& RTS_THRESHOLD
) {
1095 /* range 256 to 65535 */
1096 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.rts_threshold
> 255 && strHostIFCfgParamAttr
->pstrCfgParamVal
.rts_threshold
< 65536) {
1097 strWIDList
[u8WidCnt
].u16WIDid
= WID_RTS_THRESHOLD
;
1098 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.rts_threshold
;
1099 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1100 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1101 pstrWFIDrv
->strCfgValues
.rts_threshold
= strHostIFCfgParamAttr
->pstrCfgParamVal
.rts_threshold
;
1103 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1107 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& PREAMBLE
) {
1108 /*-----------------------------------------------------*/
1109 /*Input Values: Short= 0, */
1112 /*------------------------------------------------------*/
1113 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.preamble_type
< 3) {
1114 strWIDList
[u8WidCnt
].u16WIDid
= WID_PREAMBLE
;
1115 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.preamble_type
;
1116 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
1117 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
1118 pstrWFIDrv
->strCfgValues
.preamble_type
= strHostIFCfgParamAttr
->pstrCfgParamVal
.preamble_type
;
1120 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1124 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& SHORT_SLOT_ALLOWED
) {
1125 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.short_slot_allowed
< 2) {
1126 strWIDList
[u8WidCnt
].u16WIDid
= WID_SHORT_SLOT_ALLOWED
;
1127 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.short_slot_allowed
;
1128 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
1129 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
1130 pstrWFIDrv
->strCfgValues
.short_slot_allowed
= (u8
)strHostIFCfgParamAttr
->pstrCfgParamVal
.short_slot_allowed
;
1132 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1136 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& TXOP_PROT_DISABLE
) {
1137 /*Description: used to Disable RTS-CTS protection for TXOP burst*/
1138 /*transmission when the acknowledgement policy is No-Ack or Block-Ack */
1139 /* this information is useful for external supplicant */
1140 /*Input Values: 1 for enable and 0 for disable. */
1141 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.txop_prot_disabled
< 2) {
1142 strWIDList
[u8WidCnt
].u16WIDid
= WID_11N_TXOP_PROT_DISABLE
;
1143 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.txop_prot_disabled
;
1144 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
1145 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
1146 pstrWFIDrv
->strCfgValues
.txop_prot_disabled
= (u8
)strHostIFCfgParamAttr
->pstrCfgParamVal
.txop_prot_disabled
;
1148 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1152 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& BEACON_INTERVAL
) {
1153 /* range is 1 to 65535. */
1154 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.beacon_interval
> 0 && strHostIFCfgParamAttr
->pstrCfgParamVal
.beacon_interval
< 65536) {
1155 strWIDList
[u8WidCnt
].u16WIDid
= WID_BEACON_INTERVAL
;
1156 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.beacon_interval
;
1157 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1158 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1159 pstrWFIDrv
->strCfgValues
.beacon_interval
= strHostIFCfgParamAttr
->pstrCfgParamVal
.beacon_interval
;
1161 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1165 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& DTIM_PERIOD
) {
1166 /* range is 1 to 255. */
1167 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.dtim_period
> 0 && strHostIFCfgParamAttr
->pstrCfgParamVal
.dtim_period
< 256) {
1168 strWIDList
[u8WidCnt
].u16WIDid
= WID_DTIM_PERIOD
;
1169 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.dtim_period
;
1170 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
1171 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
1172 pstrWFIDrv
->strCfgValues
.dtim_period
= strHostIFCfgParamAttr
->pstrCfgParamVal
.dtim_period
;
1174 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1178 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& SITE_SURVEY
) {
1179 /*----------------------------------------------------------------------*/
1180 /*Input Values: SITE_SURVEY_1CH = 0, i.e.: currently set channel */
1181 /* SITE_SURVEY_ALL_CH = 1, */
1182 /* SITE_SURVEY_OFF = 2 */
1183 /*----------------------------------------------------------------------*/
1184 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_enabled
< 3) {
1185 strWIDList
[u8WidCnt
].u16WIDid
= WID_SITE_SURVEY
;
1186 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_enabled
;
1187 strWIDList
[u8WidCnt
].enuWIDtype
= WID_CHAR
;
1188 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(char);
1189 pstrWFIDrv
->strCfgValues
.site_survey_enabled
= (u8
)strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_enabled
;
1191 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1195 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& SITE_SURVEY_SCAN_TIME
) {
1196 /* range is 1 to 65535. */
1197 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_scan_time
> 0 && strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_scan_time
< 65536) {
1198 strWIDList
[u8WidCnt
].u16WIDid
= WID_SITE_SURVEY_SCAN_TIME
;
1199 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_scan_time
;
1200 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1201 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1202 pstrWFIDrv
->strCfgValues
.site_survey_scan_time
= strHostIFCfgParamAttr
->pstrCfgParamVal
.site_survey_scan_time
;
1204 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1208 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& ACTIVE_SCANTIME
) {
1209 /* range is 1 to 65535. */
1210 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.active_scan_time
> 0 && strHostIFCfgParamAttr
->pstrCfgParamVal
.active_scan_time
< 65536) {
1211 strWIDList
[u8WidCnt
].u16WIDid
= WID_ACTIVE_SCAN_TIME
;
1212 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.active_scan_time
;
1213 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1214 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1215 pstrWFIDrv
->strCfgValues
.active_scan_time
= strHostIFCfgParamAttr
->pstrCfgParamVal
.active_scan_time
;
1217 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1221 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& PASSIVE_SCANTIME
) {
1222 /* range is 1 to 65535. */
1223 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.passive_scan_time
> 0 && strHostIFCfgParamAttr
->pstrCfgParamVal
.passive_scan_time
< 65536) {
1224 strWIDList
[u8WidCnt
].u16WIDid
= WID_PASSIVE_SCAN_TIME
;
1225 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&strHostIFCfgParamAttr
->pstrCfgParamVal
.passive_scan_time
;
1226 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1227 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1228 pstrWFIDrv
->strCfgValues
.passive_scan_time
= strHostIFCfgParamAttr
->pstrCfgParamVal
.passive_scan_time
;
1230 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1234 if (strHostIFCfgParamAttr
->pstrCfgParamVal
.u32SetCfgFlag
& CURRENT_TX_RATE
) {
1235 CURRENT_TX_RATE_T curr_tx_rate
= strHostIFCfgParamAttr
->pstrCfgParamVal
.curr_tx_rate
;
1236 /*----------------------------------------------------------------------*/
1237 /*Rates: 1 2 5.5 11 6 9 12 18 24 36 48 54 Auto */
1238 /*InputValues: 1 2 3 4 5 6 7 8 9 10 11 12 0 */
1239 /*----------------------------------------------------------------------*/
1241 if (curr_tx_rate
== AUTORATE
|| curr_tx_rate
== MBPS_1
1242 || curr_tx_rate
== MBPS_2
|| curr_tx_rate
== MBPS_5_5
1243 || curr_tx_rate
== MBPS_11
|| curr_tx_rate
== MBPS_6
1244 || curr_tx_rate
== MBPS_9
|| curr_tx_rate
== MBPS_12
1245 || curr_tx_rate
== MBPS_18
|| curr_tx_rate
== MBPS_24
1246 || curr_tx_rate
== MBPS_36
|| curr_tx_rate
== MBPS_48
|| curr_tx_rate
== MBPS_54
) {
1247 strWIDList
[u8WidCnt
].u16WIDid
= WID_CURRENT_TX_RATE
;
1248 strWIDList
[u8WidCnt
].ps8WidVal
= (s8
*)&curr_tx_rate
;
1249 strWIDList
[u8WidCnt
].enuWIDtype
= WID_SHORT
;
1250 strWIDList
[u8WidCnt
].s32ValueSize
= sizeof(u16
);
1251 pstrWFIDrv
->strCfgValues
.curr_tx_rate
= (u8
)curr_tx_rate
;
1253 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
1257 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, u8WidCnt
, false,
1258 get_id_from_handler(pstrWFIDrv
));
1261 PRINT_ER("Error in setting CFG params\n");
1263 WILC_CATCH(s32Error
)
1266 up(&(pstrWFIDrv
->gtOsCfgValuesSem
));
1272 * @brief Handle_wait_msg_q_empty
1273 * @details this should be the last msg and then the msg Q becomes idle
1274 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1275 * @return Error code.
1280 static s32
Handle_wait_msg_q_empty(void)
1282 s32 s32Error
= WILC_SUCCESS
;
1284 g_wilc_initialized
= 0;
1290 * @brief Handle_Scan
1291 * @details Sending config packet to firmware to set the scan params
1292 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1293 * @return Error code.
1298 static s32
Handle_Scan(tstrWILC_WFIDrv
*drvHandler
, tstrHostIFscanAttr
*pstrHostIFscanAttr
)
1300 s32 s32Error
= WILC_SUCCESS
;
1301 tstrWID strWIDList
[5];
1302 u32 u32WidsCount
= 0;
1306 u8
*pu8HdnNtwrksWidVal
= NULL
;
1307 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*) drvHandler
;
1309 PRINT_D(HOSTINF_DBG
, "Setting SCAN params\n");
1310 PRINT_D(HOSTINF_DBG
, "Scanning: In [%d] state\n", pstrWFIDrv
->enuHostIFstate
);
1312 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
= pstrHostIFscanAttr
->pfScanResult
;
1313 pstrWFIDrv
->strWILC_UsrScanReq
.u32UserScanPvoid
= pstrHostIFscanAttr
->pvUserArg
;
1318 if ((pstrWFIDrv
->enuHostIFstate
>= HOST_IF_SCANNING
) && (pstrWFIDrv
->enuHostIFstate
< HOST_IF_CONNECTED
)) {
1319 /* here we either in HOST_IF_SCANNING, HOST_IF_WAITING_CONN_REQ or HOST_IF_WAITING_CONN_RESP */
1320 PRINT_D(GENERIC_DBG
, "Don't scan we are already in [%d] state\n", pstrWFIDrv
->enuHostIFstate
);
1321 WILC_ERRORREPORT(s32Error
, WILC_BUSY
);
1324 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
1325 if (g_obtainingIP
|| connecting
) {
1326 PRINT_D(GENERIC_DBG
, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
1327 WILC_ERRORREPORT(s32Error
, WILC_BUSY
);
1331 PRINT_D(HOSTINF_DBG
, "Setting SCAN params\n");
1334 pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
= 0;
1337 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_SSID_PROBE_REQ
;
1338 strWIDList
[u32WidsCount
].enuWIDtype
= WID_STR
;
1340 for (i
= 0; i
< pstrHostIFscanAttr
->strHiddenNetwork
.u8ssidnum
; i
++)
1341 valuesize
+= ((pstrHostIFscanAttr
->strHiddenNetwork
.pstrHiddenNetworkInfo
[i
].u8ssidlen
) + 1);
1342 pu8HdnNtwrksWidVal
= kmalloc(valuesize
+ 1, GFP_KERNEL
);
1343 strWIDList
[u32WidsCount
].ps8WidVal
= pu8HdnNtwrksWidVal
;
1344 if (strWIDList
[u32WidsCount
].ps8WidVal
!= NULL
) {
1345 pu8Buffer
= strWIDList
[u32WidsCount
].ps8WidVal
;
1347 *pu8Buffer
++ = pstrHostIFscanAttr
->strHiddenNetwork
.u8ssidnum
;
1349 PRINT_D(HOSTINF_DBG
, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr
->strHiddenNetwork
.u8ssidnum
);
1351 for (i
= 0; i
< pstrHostIFscanAttr
->strHiddenNetwork
.u8ssidnum
; i
++) {
1352 *pu8Buffer
++ = pstrHostIFscanAttr
->strHiddenNetwork
.pstrHiddenNetworkInfo
[i
].u8ssidlen
;
1353 memcpy(pu8Buffer
, pstrHostIFscanAttr
->strHiddenNetwork
.pstrHiddenNetworkInfo
[i
].pu8ssid
, pstrHostIFscanAttr
->strHiddenNetwork
.pstrHiddenNetworkInfo
[i
].u8ssidlen
);
1354 pu8Buffer
+= pstrHostIFscanAttr
->strHiddenNetwork
.pstrHiddenNetworkInfo
[i
].u8ssidlen
;
1359 strWIDList
[u32WidsCount
].s32ValueSize
= (s32
)(valuesize
+ 1);
1363 /*filling cfg param array*/
1365 /* if((pstrHostIFscanAttr->pu8IEs != NULL) && (pstrHostIFscanAttr->IEsLen != 0)) */
1367 /* IEs to be inserted in Probe Request */
1368 strWIDList
[u32WidsCount
].u16WIDid
= WID_INFO_ELEMENT_PROBE
;
1369 strWIDList
[u32WidsCount
].enuWIDtype
= WID_BIN_DATA
;
1370 strWIDList
[u32WidsCount
].ps8WidVal
= pstrHostIFscanAttr
->pu8IEs
;
1371 strWIDList
[u32WidsCount
].s32ValueSize
= pstrHostIFscanAttr
->IEsLen
;
1376 strWIDList
[u32WidsCount
].u16WIDid
= WID_SCAN_TYPE
;
1377 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
1378 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
1379 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrHostIFscanAttr
->u8ScanType
));
1382 /*list of channels to be scanned*/
1383 strWIDList
[u32WidsCount
].u16WIDid
= WID_SCAN_CHANNEL_LIST
;
1384 strWIDList
[u32WidsCount
].enuWIDtype
= WID_BIN_DATA
;
1386 /* Bug 4648: Convert channel numbers to start from 0 not 1. */
1387 if (pstrHostIFscanAttr
->pu8ChnlFreqList
!= NULL
&& pstrHostIFscanAttr
->u8ChnlListLen
> 0) {
1390 for (i
= 0; i
< pstrHostIFscanAttr
->u8ChnlListLen
; i
++) {
1391 if (pstrHostIFscanAttr
->pu8ChnlFreqList
[i
] > 0)
1392 pstrHostIFscanAttr
->pu8ChnlFreqList
[i
] = pstrHostIFscanAttr
->pu8ChnlFreqList
[i
] - 1;
1396 strWIDList
[u32WidsCount
].ps8WidVal
= pstrHostIFscanAttr
->pu8ChnlFreqList
;
1397 strWIDList
[u32WidsCount
].s32ValueSize
= pstrHostIFscanAttr
->u8ChnlListLen
;
1401 strWIDList
[u32WidsCount
].u16WIDid
= WID_START_SCAN_REQ
;
1402 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
1403 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
1404 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrHostIFscanAttr
->u8ScanSource
));
1407 /*keep the state as is , no need to change it*/
1408 /* gWFiDrvHandle->enuHostIFstate = HOST_IF_SCANNING; */
1410 if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_CONNECTED
)
1411 gbScanWhileConnected
= true;
1412 else if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_IDLE
)
1413 gbScanWhileConnected
= false;
1415 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, u32WidsCount
, false,
1416 get_id_from_handler(pstrWFIDrv
));
1419 PRINT_ER("Failed to send scan paramters config packet\n");
1420 WILC_ERRORREPORT(s32Error
, s32Error
);
1422 PRINT_D(HOSTINF_DBG
, "Successfully sent SCAN params config packet\n");
1425 WILC_CATCH(s32Error
)
1427 del_timer(&pstrWFIDrv
->hScanTimer
);
1428 /*if there is an ongoing scan request*/
1429 Handle_ScanDone(drvHandler
, SCAN_EVENT_ABORTED
);
1432 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1433 if (pstrHostIFscanAttr
->pu8ChnlFreqList
!= NULL
) {
1434 kfree(pstrHostIFscanAttr
->pu8ChnlFreqList
);
1435 pstrHostIFscanAttr
->pu8ChnlFreqList
= NULL
;
1438 /* Deallocate pstrHostIFscanAttr->pu8IEs which was previously allocated by the sending thread */
1439 if (pstrHostIFscanAttr
->pu8IEs
!= NULL
) {
1440 kfree(pstrHostIFscanAttr
->pu8IEs
);
1441 pstrHostIFscanAttr
->pu8IEs
= NULL
;
1443 if (pstrHostIFscanAttr
->strHiddenNetwork
.pstrHiddenNetworkInfo
!= NULL
) {
1444 kfree(pstrHostIFscanAttr
->strHiddenNetwork
.pstrHiddenNetworkInfo
);
1445 pstrHostIFscanAttr
->strHiddenNetwork
.pstrHiddenNetworkInfo
= NULL
;
1448 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1449 if (pstrHostIFscanAttr
->pu8ChnlFreqList
!= NULL
) {
1450 kfree(pstrHostIFscanAttr
->pu8ChnlFreqList
);
1451 pstrHostIFscanAttr
->pu8ChnlFreqList
= NULL
;
1454 if (pu8HdnNtwrksWidVal
!= NULL
)
1455 kfree(pu8HdnNtwrksWidVal
);
1461 * @brief Handle_ScanDone
1462 * @details Call scan notification callback function
1464 * @return Error code.
1469 static s32
Handle_ScanDone(tstrWILC_WFIDrv
*drvHandler
, tenuScanEvent enuEvent
)
1471 s32 s32Error
= WILC_SUCCESS
;
1473 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
1476 u8 u8abort_running_scan
;
1480 PRINT_D(HOSTINF_DBG
, "in Handle_ScanDone()\n");
1483 /*Ask FW to abort the running scan, if any*/
1484 if (enuEvent
== SCAN_EVENT_ABORTED
) {
1485 PRINT_D(GENERIC_DBG
, "Abort running scan\n");
1486 u8abort_running_scan
= 1;
1487 strWID
.u16WIDid
= (u16
)WID_ABORT_RUNNING_SCAN
;
1488 strWID
.enuWIDtype
= WID_CHAR
;
1489 strWID
.ps8WidVal
= (s8
*)&u8abort_running_scan
;
1490 strWID
.s32ValueSize
= sizeof(char);
1493 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
1494 get_id_from_handler(pstrWFIDrv
));
1495 if (s32Error
!= WILC_SUCCESS
) {
1496 PRINT_ER("Failed to set abort running scan\n");
1497 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
1499 WILC_CATCH(s32Error
)
1504 if (pstrWFIDrv
== NULL
) {
1505 PRINT_ER("Driver handler is NULL\n");
1509 /*if there is an ongoing scan request*/
1510 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
1511 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult(enuEvent
, NULL
,
1512 pstrWFIDrv
->strWILC_UsrScanReq
.u32UserScanPvoid
, NULL
);
1513 /*delete current scan request*/
1514 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
= NULL
;
1521 * @brief Handle_Connect
1522 * @details Sending config packet to firmware to starting connection
1523 * @param[in] tstrHostIFconnectAttr* pstrHostIFconnectAttr
1524 * @return Error code.
1529 u8 u8ConnectedSSID
[6] = {0};
1530 static s32
Handle_Connect(tstrWILC_WFIDrv
*drvHandler
, tstrHostIFconnectAttr
*pstrHostIFconnectAttr
)
1532 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*) drvHandler
;
1533 s32 s32Error
= WILC_SUCCESS
;
1534 tstrWID strWIDList
[8];
1535 u32 u32WidsCount
= 0, dummyval
= 0;
1536 /* char passphrase[] = "12345678"; */
1537 #ifndef CONNECT_DIRECT
1538 s32 s32Err
= WILC_SUCCESS
;
1540 u8 u8bssDscListIndex
;
1541 wid_site_survey_reslts_s
*pstrSurveyResults
= NULL
;
1543 u8
*pu8CurrByte
= NULL
;
1544 /*Bug4218: Parsing Join Param*/
1545 #ifdef WILC_PARSE_SCAN_IN_HOST
1546 tstrJoinBssParam
*ptstrJoinBssParam
;
1547 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1551 PRINT_D(GENERIC_DBG
, "Handling connect request\n");
1553 #ifndef CONNECT_DIRECT
1554 memset(gapu8RcvdSurveyResults
, 0, sizeof(gapu8RcvdSurveyResults
));
1557 PRINT_D(HOSTINF_DBG
, "Getting site survey results\n");
1558 s32Err
= host_int_get_site_survey_results(pstrWFIDrv
,
1559 gapu8RcvdSurveyResults
,
1560 MAX_SURVEY_RESULT_FRAG_SIZE
);
1562 PRINT_ER("Failed to get site survey results\n");
1563 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
1566 s32Err
= ParseSurveyResults(gapu8RcvdSurveyResults
, &pstrSurveyResults
,
1567 &pstrWFIDrv
->u32SurveyResultsCount
);
1570 if (s32Err
== WILC_SUCCESS
) {
1571 /* use the parsed info in pstrSurveyResults, then deallocate it */
1572 PRINT_D(HOSTINF_DBG
, "Copying site survey results in global structure, then deallocate\n");
1573 for (i
= 0; i
< pstrWFIDrv
->u32SurveyResultsCount
; i
++) {
1574 memcpy(&pstrWFIDrv
->astrSurveyResults
[i
], &pstrSurveyResults
[i
],
1575 sizeof(wid_site_survey_reslts_s
));
1578 DeallocateSurveyResults(pstrSurveyResults
);
1580 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
1581 PRINT_ER("ParseSurveyResults() Error(%d)\n", s32Err
);
1585 for (i
= 0; i
< pstrWFIDrv
->u32SurveyResultsCount
; i
++) {
1586 if (memcmp(pstrWFIDrv
->astrSurveyResults
[i
].SSID
,
1587 pstrHostIFconnectAttr
->pu8ssid
,
1588 pstrHostIFconnectAttr
->ssidLen
) == 0) {
1589 PRINT_INFO(HOSTINF_DBG
, "Network with required SSID is found %s\n", pstrHostIFconnectAttr
->pu8ssid
);
1590 if (pstrHostIFconnectAttr
->pu8bssid
== NULL
) {
1591 /* BSSID is not passed from the user, so decision of matching
1592 * is done by SSID only */
1593 PRINT_INFO(HOSTINF_DBG
, "BSSID is not passed from the user\n");
1596 /* BSSID is also passed from the user, so decision of matching
1597 * should consider also this passed BSSID */
1599 if (memcmp(pstrWFIDrv
->astrSurveyResults
[i
].BSSID
,
1600 pstrHostIFconnectAttr
->pu8bssid
,
1602 PRINT_INFO(HOSTINF_DBG
, "BSSID is passed from the user and matched\n");
1609 if (i
< pstrWFIDrv
->u32SurveyResultsCount
) {
1610 u8bssDscListIndex
= i
;
1612 PRINT_INFO(HOSTINF_DBG
, "Connecting to network of Bss Idx%d and SSID %s and channel%d\n",
1613 u8bssDscListIndex
, pstrWFIDrv
->astrSurveyResults
[u8bssDscListIndex
].SSID
,
1614 pstrWFIDrv
->astrSurveyResults
[u8bssDscListIndex
].Channel
);
1616 PRINT_INFO(HOSTINF_DBG
, "Saving connection parameters in global structure\n");
1618 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
) {
1619 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
= kmalloc(6, GFP_KERNEL
);
1620 memcpy(pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
, pstrHostIFconnectAttr
->pu8bssid
, 6);
1623 pstrWFIDrv
->strWILC_UsrConnReq
.ssidLen
= pstrHostIFconnectAttr
->ssidLen
;
1624 if (pstrHostIFconnectAttr
->pu8ssid
!= NULL
) {
1625 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
= kmalloc(pstrHostIFconnectAttr
->ssidLen
+ 1, GFP_KERNEL
);
1626 memcpy(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
, pstrHostIFconnectAttr
->pu8ssid
,
1627 pstrHostIFconnectAttr
->ssidLen
);
1628 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
[pstrHostIFconnectAttr
->ssidLen
] = '\0';
1631 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
= pstrHostIFconnectAttr
->IEsLen
;
1632 if (pstrHostIFconnectAttr
->pu8IEs
!= NULL
) {
1633 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
= kmalloc(pstrHostIFconnectAttr
->IEsLen
, GFP_KERNEL
);
1634 memcpy(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
, pstrHostIFconnectAttr
->pu8IEs
,
1635 pstrHostIFconnectAttr
->IEsLen
);
1638 pstrWFIDrv
->strWILC_UsrConnReq
.u8security
= pstrHostIFconnectAttr
->u8security
;
1639 pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
= pstrHostIFconnectAttr
->tenuAuth_type
;
1640 pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
= pstrHostIFconnectAttr
->pfConnectResult
;
1641 pstrWFIDrv
->strWILC_UsrConnReq
.u32UserConnectPvoid
= pstrHostIFconnectAttr
->pvUserArg
;
1644 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1645 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1647 /* IEs to be inserted in Association Request */
1648 strWIDList
[u32WidsCount
].u16WIDid
= WID_INFO_ELEMENT_ASSOCIATE
;
1649 strWIDList
[u32WidsCount
].enuWIDtype
= WID_BIN_DATA
;
1650 strWIDList
[u32WidsCount
].ps8WidVal
= pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
;
1651 strWIDList
[u32WidsCount
].s32ValueSize
= pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
;
1654 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_11I_MODE
;
1655 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
1656 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
1657 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrWFIDrv
->strWILC_UsrConnReq
.u8security
));
1660 PRINT_INFO(HOSTINF_DBG
, "Encrypt Mode = %x\n", pstrWFIDrv
->strWILC_UsrConnReq
.u8security
);
1662 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_AUTH_TYPE
;
1663 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
1664 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
1665 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
);
1668 PRINT_INFO(HOSTINF_DBG
, "Authentication Type = %x\n", pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
);
1670 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
1671 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1672 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
1673 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
1677 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_JOIN_REQ
;
1678 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
1679 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
1680 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)&u8bssDscListIndex
;
1683 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1684 * firmware at chip reset when processing the WIDs of the Connect Request.
1685 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1686 /* ////////////////////// */
1687 gu32WidConnRstHack
= 0;
1688 /* ////////////////////// */
1690 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, u32WidsCount
, false,
1691 get_id_from_handler(pstrWFIDrv
));
1693 PRINT_ER("Handle_Connect()] failed to send config packet\n");
1694 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
1696 pstrWFIDrv
->enuHostIFstate
= HOST_IF_WAITING_CONN_RESP
;
1700 PRINT_ER("Required BSSID not found\n");
1701 WILC_ERRORREPORT(s32Error
, WILC_NOT_FOUND
);
1706 /* if we try to connect to an already connected AP then discard the request */
1708 if (memcmp(pstrHostIFconnectAttr
->pu8bssid
, u8ConnectedSSID
, ETH_ALEN
) == 0) {
1710 s32Error
= WILC_SUCCESS
;
1711 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1715 PRINT_INFO(HOSTINF_DBG
, "Saving connection parameters in global structure\n");
1717 /*Bug4218: Parsing Join Param*/
1718 #ifdef WILC_PARSE_SCAN_IN_HOST
1719 ptstrJoinBssParam
= (tstrJoinBssParam
*)pstrHostIFconnectAttr
->pJoinParams
;
1720 if (ptstrJoinBssParam
== NULL
) {
1721 PRINT_ER("Required BSSID not found\n");
1722 WILC_ERRORREPORT(s32Error
, WILC_NOT_FOUND
);
1724 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1726 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
) {
1727 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
= kmalloc(6, GFP_KERNEL
);
1728 memcpy(pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
, pstrHostIFconnectAttr
->pu8bssid
, 6);
1731 pstrWFIDrv
->strWILC_UsrConnReq
.ssidLen
= pstrHostIFconnectAttr
->ssidLen
;
1732 if (pstrHostIFconnectAttr
->pu8ssid
!= NULL
) {
1733 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
= kmalloc(pstrHostIFconnectAttr
->ssidLen
+ 1, GFP_KERNEL
);
1734 memcpy(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
, pstrHostIFconnectAttr
->pu8ssid
,
1735 pstrHostIFconnectAttr
->ssidLen
);
1736 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
[pstrHostIFconnectAttr
->ssidLen
] = '\0';
1739 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
= pstrHostIFconnectAttr
->IEsLen
;
1740 if (pstrHostIFconnectAttr
->pu8IEs
!= NULL
) {
1741 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
= kmalloc(pstrHostIFconnectAttr
->IEsLen
, GFP_KERNEL
);
1742 memcpy(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
, pstrHostIFconnectAttr
->pu8IEs
,
1743 pstrHostIFconnectAttr
->IEsLen
);
1746 pstrWFIDrv
->strWILC_UsrConnReq
.u8security
= pstrHostIFconnectAttr
->u8security
;
1747 pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
= pstrHostIFconnectAttr
->tenuAuth_type
;
1748 pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
= pstrHostIFconnectAttr
->pfConnectResult
;
1749 pstrWFIDrv
->strWILC_UsrConnReq
.u32UserConnectPvoid
= pstrHostIFconnectAttr
->pvUserArg
;
1751 strWIDList
[u32WidsCount
].u16WIDid
= WID_SUCCESS_FRAME_COUNT
;
1752 strWIDList
[u32WidsCount
].enuWIDtype
= WID_INT
;
1753 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(u32
);
1754 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(dummyval
));
1757 strWIDList
[u32WidsCount
].u16WIDid
= WID_RECEIVED_FRAGMENT_COUNT
;
1758 strWIDList
[u32WidsCount
].enuWIDtype
= WID_INT
;
1759 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(u32
);
1760 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(dummyval
));
1763 strWIDList
[u32WidsCount
].u16WIDid
= WID_FAILED_COUNT
;
1764 strWIDList
[u32WidsCount
].enuWIDtype
= WID_INT
;
1765 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(u32
);
1766 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(dummyval
));
1769 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1770 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1772 /* IEs to be inserted in Association Request */
1773 strWIDList
[u32WidsCount
].u16WIDid
= WID_INFO_ELEMENT_ASSOCIATE
;
1774 strWIDList
[u32WidsCount
].enuWIDtype
= WID_BIN_DATA
;
1775 strWIDList
[u32WidsCount
].ps8WidVal
= pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
;
1776 strWIDList
[u32WidsCount
].s32ValueSize
= pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
;
1780 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->pu8ssid
, 7)) {
1782 gu32FlushedInfoElemAsocSize
= pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
;
1783 gu8FlushedInfoElemAsoc
= kmalloc(gu32FlushedInfoElemAsocSize
, GFP_KERNEL
);
1784 memcpy(gu8FlushedInfoElemAsoc
, pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
,
1785 gu32FlushedInfoElemAsocSize
);
1788 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_11I_MODE
;
1789 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
1790 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
1791 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrWFIDrv
->strWILC_UsrConnReq
.u8security
));
1795 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->pu8ssid
, 7))
1796 gu8Flushed11iMode
= pstrWFIDrv
->strWILC_UsrConnReq
.u8security
;
1798 PRINT_INFO(HOSTINF_DBG
, "Encrypt Mode = %x\n", pstrWFIDrv
->strWILC_UsrConnReq
.u8security
);
1801 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_AUTH_TYPE
;
1802 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
1803 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
1804 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
);
1808 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->pu8ssid
, 7))
1809 gu8FlushedAuthType
= (u8
)pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
;
1811 PRINT_INFO(HOSTINF_DBG
, "Authentication Type = %x\n", pstrWFIDrv
->strWILC_UsrConnReq
.tenuAuth_type
);
1813 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
1814 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1815 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
1816 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
1820 PRINT_D(HOSTINF_DBG
, "Connecting to network of SSID %s on channel %d\n",
1821 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
, pstrHostIFconnectAttr
->u8channel
);
1824 #ifndef WILC_PARSE_SCAN_IN_HOST
1825 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_JOIN_REQ_EXTENDED
;
1826 strWIDList
[u32WidsCount
].enuWIDtype
= WID_STR
;
1827 strWIDList
[u32WidsCount
].s32ValueSize
= MAX_SSID_LEN
+ 7;
1828 strWIDList
[u32WidsCount
].ps8WidVal
= kmalloc(strWIDList
[u32WidsCount
].s32ValueSize
, GFP_KERNEL
);
1830 if (strWIDList
[u32WidsCount
].ps8WidVal
== NULL
)
1831 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
1833 pu8CurrByte
= strWIDList
[u32WidsCount
].ps8WidVal
;
1835 if (pstrHostIFconnectAttr
->pu8ssid
!= NULL
) {
1836 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->pu8ssid
, pstrHostIFconnectAttr
->ssidLen
);
1837 pu8CurrByte
[pstrHostIFconnectAttr
->ssidLen
] = '\0';
1839 pu8CurrByte
+= MAX_SSID_LEN
;
1840 if ((pstrHostIFconnectAttr
->u8channel
>= 1) && (pstrHostIFconnectAttr
->u8channel
<= 14)) {
1841 *(pu8CurrByte
++) = pstrHostIFconnectAttr
->u8channel
;
1843 PRINT_ER("Channel out of range\n");
1844 *(pu8CurrByte
++) = 0xFF;
1846 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
)
1847 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->pu8bssid
, 6);
1850 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1851 pu8CurrByte
= strWIDList
[u32WidsCount
].ps8WidVal
;
1855 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_JOIN_REQ_EXTENDED
;
1856 strWIDList
[u32WidsCount
].enuWIDtype
= WID_STR
;
1858 /*Sending NoA attributes during connection*/
1859 strWIDList
[u32WidsCount
].s32ValueSize
= 112; /* 79; */
1860 strWIDList
[u32WidsCount
].ps8WidVal
= kmalloc(strWIDList
[u32WidsCount
].s32ValueSize
, GFP_KERNEL
);
1863 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->pu8ssid
, 7)) {
1864 gu32FlushedJoinReqSize
= strWIDList
[u32WidsCount
].s32ValueSize
;
1865 gu8FlushedJoinReq
= kmalloc(gu32FlushedJoinReqSize
, GFP_KERNEL
);
1867 if (strWIDList
[u32WidsCount
].ps8WidVal
== NULL
)
1868 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
1870 pu8CurrByte
= strWIDList
[u32WidsCount
].ps8WidVal
;
1873 if (pstrHostIFconnectAttr
->pu8ssid
!= NULL
) {
1874 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->pu8ssid
, pstrHostIFconnectAttr
->ssidLen
);
1875 pu8CurrByte
[pstrHostIFconnectAttr
->ssidLen
] = '\0';
1877 pu8CurrByte
+= MAX_SSID_LEN
;
1880 *(pu8CurrByte
++) = INFRASTRUCTURE
;
1882 if ((pstrHostIFconnectAttr
->u8channel
>= 1) && (pstrHostIFconnectAttr
->u8channel
<= 14)) {
1883 *(pu8CurrByte
++) = pstrHostIFconnectAttr
->u8channel
;
1885 PRINT_ER("Channel out of range\n");
1886 *(pu8CurrByte
++) = 0xFF;
1889 *(pu8CurrByte
++) = (ptstrJoinBssParam
->cap_info
) & 0xFF;
1890 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->cap_info
) >> 8) & 0xFF;
1891 PRINT_D(HOSTINF_DBG
, "* Cap Info %0x*\n", (*(pu8CurrByte
- 2) | ((*(pu8CurrByte
- 1)) << 8)));
1894 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
)
1895 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->pu8bssid
, 6);
1899 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
)
1900 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->pu8bssid
, 6);
1904 *(pu8CurrByte
++) = (ptstrJoinBssParam
->beacon_period
) & 0xFF;
1905 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->beacon_period
) >> 8) & 0xFF;
1906 PRINT_D(HOSTINF_DBG
, "* Beacon Period %d*\n", (*(pu8CurrByte
- 2) | ((*(pu8CurrByte
- 1)) << 8)));
1908 *(pu8CurrByte
++) = ptstrJoinBssParam
->dtim_period
;
1909 PRINT_D(HOSTINF_DBG
, "* DTIM Period %d*\n", (*(pu8CurrByte
- 1)));
1910 /* Supported rates*/
1911 memcpy(pu8CurrByte
, ptstrJoinBssParam
->supp_rates
, MAX_RATES_SUPPORTED
+ 1);
1912 pu8CurrByte
+= (MAX_RATES_SUPPORTED
+ 1);
1915 *(pu8CurrByte
++) = ptstrJoinBssParam
->wmm_cap
;
1916 PRINT_D(HOSTINF_DBG
, "* wmm cap%d*\n", (*(pu8CurrByte
- 1)));
1918 *(pu8CurrByte
++) = ptstrJoinBssParam
->uapsd_cap
;
1921 *(pu8CurrByte
++) = ptstrJoinBssParam
->ht_capable
;
1922 /* copy this information to the user request */
1923 pstrWFIDrv
->strWILC_UsrConnReq
.IsHTCapable
= ptstrJoinBssParam
->ht_capable
;
1926 *(pu8CurrByte
++) = ptstrJoinBssParam
->rsn_found
;
1927 PRINT_D(HOSTINF_DBG
, "* rsn found %d*\n", *(pu8CurrByte
- 1));
1928 /* rsn group policy*/
1929 *(pu8CurrByte
++) = ptstrJoinBssParam
->rsn_grp_policy
;
1930 PRINT_D(HOSTINF_DBG
, "* rsn group policy %0x*\n", (*(pu8CurrByte
- 1)));
1932 *(pu8CurrByte
++) = ptstrJoinBssParam
->mode_802_11i
;
1933 PRINT_D(HOSTINF_DBG
, "* mode_802_11i %d*\n", (*(pu8CurrByte
- 1)));
1934 /* rsn pcip policy*/
1935 memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_pcip_policy
, sizeof(ptstrJoinBssParam
->rsn_pcip_policy
));
1936 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_pcip_policy
);
1938 /* rsn auth policy*/
1939 memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_auth_policy
, sizeof(ptstrJoinBssParam
->rsn_auth_policy
));
1940 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_auth_policy
);
1942 /* rsn auth policy*/
1943 memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_cap
, sizeof(ptstrJoinBssParam
->rsn_cap
));
1944 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_cap
);
1947 *(pu8CurrByte
++) = REAL_JOIN_REQ
;
1950 *(pu8CurrByte
++) = ptstrJoinBssParam
->u8NoaEnbaled
;
1951 if (ptstrJoinBssParam
->u8NoaEnbaled
) {
1952 PRINT_D(HOSTINF_DBG
, "NOA present\n");
1954 *(pu8CurrByte
++) = (ptstrJoinBssParam
->tsf
) & 0xFF;
1955 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 8) & 0xFF;
1956 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 16) & 0xFF;
1957 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 24) & 0xFF;
1959 *(pu8CurrByte
++) = ptstrJoinBssParam
->u8Index
;
1961 *(pu8CurrByte
++) = ptstrJoinBssParam
->u8OppEnable
;
1963 if (ptstrJoinBssParam
->u8OppEnable
)
1964 *(pu8CurrByte
++) = ptstrJoinBssParam
->u8CtWindow
;
1966 *(pu8CurrByte
++) = ptstrJoinBssParam
->u8Count
;
1968 memcpy(pu8CurrByte
, ptstrJoinBssParam
->au8Duration
, sizeof(ptstrJoinBssParam
->au8Duration
));
1970 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->au8Duration
);
1972 memcpy(pu8CurrByte
, ptstrJoinBssParam
->au8Interval
, sizeof(ptstrJoinBssParam
->au8Interval
));
1974 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->au8Interval
);
1976 memcpy(pu8CurrByte
, ptstrJoinBssParam
->au8StartTime
, sizeof(ptstrJoinBssParam
->au8StartTime
));
1978 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->au8StartTime
);
1981 PRINT_D(HOSTINF_DBG
, "NOA not present\n");
1985 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1986 pu8CurrByte
= strWIDList
[u32WidsCount
].ps8WidVal
;
1989 #endif /* #ifdef WILC_PARSE_SCAN_IN_HOST*/
1992 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1993 * firmware at chip reset when processing the WIDs of the Connect Request.
1994 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1995 /* ////////////////////// */
1996 gu32WidConnRstHack
= 0;
1997 /* ////////////////////// */
2000 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->pu8ssid
, 7)) {
2001 memcpy(gu8FlushedJoinReq
, pu8CurrByte
, gu32FlushedJoinReqSize
);
2002 gu8FlushedJoinReqDrvHandler
= pstrWFIDrv
;
2005 PRINT_D(GENERIC_DBG
, "send HOST_IF_WAITING_CONN_RESP\n");
2007 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
) {
2008 memcpy(u8ConnectedSSID
, pstrHostIFconnectAttr
->pu8bssid
, ETH_ALEN
);
2010 PRINT_D(GENERIC_DBG
, "save Bssid = %pM\n", pstrHostIFconnectAttr
->pu8bssid
);
2011 PRINT_D(GENERIC_DBG
, "save bssid = %pM\n", u8ConnectedSSID
);
2014 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, u32WidsCount
, false,
2015 get_id_from_handler(pstrWFIDrv
));
2017 PRINT_ER("Handle_Connect()] failed to send config packet\n");
2018 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
2020 PRINT_D(GENERIC_DBG
, "set HOST_IF_WAITING_CONN_RESP\n");
2021 pstrWFIDrv
->enuHostIFstate
= HOST_IF_WAITING_CONN_RESP
;
2025 WILC_CATCH(s32Error
)
2027 tstrConnectInfo strConnectInfo
;
2029 del_timer(&pstrWFIDrv
->hConnectTimer
);
2031 PRINT_D(HOSTINF_DBG
, "could not start connecting to the required network\n");
2033 memset(&strConnectInfo
, 0, sizeof(tstrConnectInfo
));
2035 if (pstrHostIFconnectAttr
->pfConnectResult
!= NULL
) {
2036 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
)
2037 memcpy(strConnectInfo
.au8bssid
, pstrHostIFconnectAttr
->pu8bssid
, 6);
2039 if (pstrHostIFconnectAttr
->pu8IEs
!= NULL
) {
2040 strConnectInfo
.ReqIEsLen
= pstrHostIFconnectAttr
->IEsLen
;
2041 strConnectInfo
.pu8ReqIEs
= kmalloc(pstrHostIFconnectAttr
->IEsLen
, GFP_KERNEL
);
2042 memcpy(strConnectInfo
.pu8ReqIEs
,
2043 pstrHostIFconnectAttr
->pu8IEs
,
2044 pstrHostIFconnectAttr
->IEsLen
);
2047 pstrHostIFconnectAttr
->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP
,
2051 pstrHostIFconnectAttr
->pvUserArg
);
2052 /*Change state to idle*/
2053 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
2055 if (strConnectInfo
.pu8ReqIEs
!= NULL
) {
2056 kfree(strConnectInfo
.pu8ReqIEs
);
2057 strConnectInfo
.pu8ReqIEs
= NULL
;
2061 PRINT_ER("Connect callback function pointer is NULL\n");
2065 PRINT_D(HOSTINF_DBG
, "Deallocating connection parameters\n");
2066 /* Deallocate pstrHostIFconnectAttr->pu8bssid which was prevoisuly allocated by the sending thread */
2067 if (pstrHostIFconnectAttr
->pu8bssid
!= NULL
) {
2068 kfree(pstrHostIFconnectAttr
->pu8bssid
);
2069 pstrHostIFconnectAttr
->pu8bssid
= NULL
;
2072 /* Deallocate pstrHostIFconnectAttr->pu8ssid which was prevoisuly allocated by the sending thread */
2073 if (pstrHostIFconnectAttr
->pu8ssid
!= NULL
) {
2074 kfree(pstrHostIFconnectAttr
->pu8ssid
);
2075 pstrHostIFconnectAttr
->pu8ssid
= NULL
;
2078 /* Deallocate pstrHostIFconnectAttr->pu8IEs which was prevoisuly allocated by the sending thread */
2079 if (pstrHostIFconnectAttr
->pu8IEs
!= NULL
) {
2080 kfree(pstrHostIFconnectAttr
->pu8IEs
);
2081 pstrHostIFconnectAttr
->pu8IEs
= NULL
;
2084 if (pu8CurrByte
!= NULL
)
2090 * @brief Handle_FlushConnect
2091 * @details Sending config packet to firmware to flush an old connection
2092 * after switching FW from station one to hybrid one
2093 * @param[in] void * drvHandler
2094 * @return Error code.
2095 * @author Amr Abdel-Moghny
2100 static s32
Handle_FlushConnect(tstrWILC_WFIDrv
*drvHandler
)
2102 s32 s32Error
= WILC_SUCCESS
;
2103 tstrWID strWIDList
[5];
2104 u32 u32WidsCount
= 0;
2105 u8
*pu8CurrByte
= NULL
;
2108 /* IEs to be inserted in Association Request */
2109 strWIDList
[u32WidsCount
].u16WIDid
= WID_INFO_ELEMENT_ASSOCIATE
;
2110 strWIDList
[u32WidsCount
].enuWIDtype
= WID_BIN_DATA
;
2111 strWIDList
[u32WidsCount
].ps8WidVal
= gu8FlushedInfoElemAsoc
;
2112 strWIDList
[u32WidsCount
].s32ValueSize
= gu32FlushedInfoElemAsocSize
;
2115 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_11I_MODE
;
2116 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
2117 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
2118 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(gu8Flushed11iMode
));
2123 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_AUTH_TYPE
;
2124 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
2125 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
2126 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&gu8FlushedAuthType
);
2130 #ifdef WILC_PARSE_SCAN_IN_HOST
2131 strWIDList
[u32WidsCount
].u16WIDid
= (u16
)WID_JOIN_REQ_EXTENDED
;
2132 strWIDList
[u32WidsCount
].enuWIDtype
= WID_STR
;
2133 strWIDList
[u32WidsCount
].s32ValueSize
= gu32FlushedJoinReqSize
;
2134 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)gu8FlushedJoinReq
;
2135 pu8CurrByte
= strWIDList
[u32WidsCount
].ps8WidVal
;
2137 pu8CurrByte
+= FLUSHED_BYTE_POS
;
2138 *(pu8CurrByte
) = FLUSHED_JOIN_REQ
;
2144 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, u32WidsCount
, false,
2145 get_id_from_handler(gu8FlushedJoinReqDrvHandler
));
2147 PRINT_ER("Handle_Flush_Connect()] failed to send config packet\n");
2148 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
2151 WILC_CATCH(s32Error
)
2160 * @brief Handle_ConnectTimeout
2161 * @details Call connect notification callback function indicating connection failure
2163 * @return Error code.
2168 static s32
Handle_ConnectTimeout(tstrWILC_WFIDrv
*drvHandler
)
2170 s32 s32Error
= WILC_SUCCESS
;
2171 tstrConnectInfo strConnectInfo
;
2173 u16 u16DummyReasonCode
= 0;
2174 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*) drvHandler
;
2176 if (pstrWFIDrv
== NULL
) {
2177 PRINT_ER("Driver handler is NULL\n");
2181 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
2183 gbScanWhileConnected
= false;
2186 memset(&strConnectInfo
, 0, sizeof(tstrConnectInfo
));
2189 /* First, we will notify the upper layer with the Connection failure {through the Connect Callback function},
2190 * then we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2191 * WID_DISCONNECT} */
2192 if (pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
!= NULL
) {
2193 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
!= NULL
) {
2194 memcpy(strConnectInfo
.au8bssid
,
2195 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
, 6);
2198 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
!= NULL
) {
2199 strConnectInfo
.ReqIEsLen
= pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
;
2200 strConnectInfo
.pu8ReqIEs
= kmalloc(pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
, GFP_KERNEL
);
2201 memcpy(strConnectInfo
.pu8ReqIEs
,
2202 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
,
2203 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
);
2206 pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP
,
2210 pstrWFIDrv
->strWILC_UsrConnReq
.u32UserConnectPvoid
);
2212 /* Deallocation of strConnectInfo.pu8ReqIEs */
2213 if (strConnectInfo
.pu8ReqIEs
!= NULL
) {
2214 kfree(strConnectInfo
.pu8ReqIEs
);
2215 strConnectInfo
.pu8ReqIEs
= NULL
;
2218 PRINT_ER("Connect callback function pointer is NULL\n");
2221 /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2222 * WID_DISCONNECT} */
2223 strWID
.u16WIDid
= (u16
)WID_DISCONNECT
;
2224 strWID
.enuWIDtype
= WID_CHAR
;
2225 strWID
.ps8WidVal
= (s8
*)&u16DummyReasonCode
;
2226 strWID
.s32ValueSize
= sizeof(char);
2228 PRINT_D(HOSTINF_DBG
, "Sending disconnect request\n");
2230 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false,
2231 get_id_from_handler(pstrWFIDrv
));
2233 PRINT_ER("Failed to send dissconect config packet\n");
2235 /* Deallocation of the Saved Connect Request in the global Handle */
2236 pstrWFIDrv
->strWILC_UsrConnReq
.ssidLen
= 0;
2237 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
!= NULL
) {
2238 kfree(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
);
2239 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
= NULL
;
2242 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
!= NULL
) {
2243 kfree(pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
);
2244 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
= NULL
;
2247 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
= 0;
2248 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
!= NULL
) {
2249 kfree(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
);
2250 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
= NULL
;
2253 memset(u8ConnectedSSID
, 0, ETH_ALEN
);
2255 /*Freeing flushed join request params on connect timeout*/
2256 if (gu8FlushedJoinReq
!= NULL
&& gu8FlushedJoinReqDrvHandler
== drvHandler
) {
2257 kfree(gu8FlushedJoinReq
);
2258 gu8FlushedJoinReq
= NULL
;
2260 if (gu8FlushedInfoElemAsoc
!= NULL
&& gu8FlushedJoinReqDrvHandler
== drvHandler
) {
2261 kfree(gu8FlushedInfoElemAsoc
);
2262 gu8FlushedInfoElemAsoc
= NULL
;
2269 * @brief Handle_RcvdNtwrkInfo
2270 * @details Handling received network information
2271 * @param[in] tstrRcvdNetworkInfo* pstrRcvdNetworkInfo
2272 * @return Error code.
2277 static s32
Handle_RcvdNtwrkInfo(tstrWILC_WFIDrv
*drvHandler
, tstrRcvdNetworkInfo
*pstrRcvdNetworkInfo
)
2280 bool bNewNtwrkFound
;
2284 s32 s32Error
= WILC_SUCCESS
;
2285 tstrNetworkInfo
*pstrNetworkInfo
= NULL
;
2286 void *pJoinParams
= NULL
;
2288 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
2292 bNewNtwrkFound
= true;
2293 PRINT_INFO(HOSTINF_DBG
, "Handling received network info\n");
2295 /*if there is a an ongoing scan request*/
2296 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
2297 PRINT_D(HOSTINF_DBG
, "State: Scanning, parsing network information received\n");
2298 ParseNetworkInfo(pstrRcvdNetworkInfo
->pu8Buffer
, &pstrNetworkInfo
);
2299 if ((pstrNetworkInfo
== NULL
)
2300 || (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
== NULL
)) {
2301 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
2304 /* check whether this network is discovered before */
2305 for (i
= 0; i
< pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
; i
++) {
2307 if ((pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[i
].au8bssid
!= NULL
) &&
2308 (pstrNetworkInfo
->au8bssid
!= NULL
)) {
2309 if (memcmp(pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[i
].au8bssid
,
2310 pstrNetworkInfo
->au8bssid
, 6) == 0) {
2311 if (pstrNetworkInfo
->s8rssi
<= pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[i
].s8rssi
) {
2312 /*we have already found this network with better rssi, so keep the old cached one and don't
2313 * send anything to the upper layer */
2314 PRINT_D(HOSTINF_DBG
, "Network previously discovered\n");
2317 /* here the same already found network is found again but with a better rssi, so just update
2318 * the rssi for this cached network and send this updated network to the upper layer but
2319 * don't add a new record for it */
2320 pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[i
].s8rssi
= pstrNetworkInfo
->s8rssi
;
2321 bNewNtwrkFound
= false;
2328 if (bNewNtwrkFound
== true) {
2329 /* here it is confirmed that it is a new discovered network,
2330 * so add its record then call the User CallBack function */
2332 PRINT_D(HOSTINF_DBG
, "New network found\n");
2334 if (pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
< MAX_NUM_SCANNED_NETWORKS
) {
2335 pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
].s8rssi
= pstrNetworkInfo
->s8rssi
;
2337 if ((pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
].au8bssid
!= NULL
)
2338 && (pstrNetworkInfo
->au8bssid
!= NULL
)) {
2339 memcpy(pstrWFIDrv
->strWILC_UsrScanReq
.astrFoundNetworkInfo
[pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
].au8bssid
,
2340 pstrNetworkInfo
->au8bssid
, 6);
2342 pstrWFIDrv
->strWILC_UsrScanReq
.u32RcvdChCount
++;
2344 pstrNetworkInfo
->bNewNetwork
= true;
2345 /*Bug4218: Parsing Join Param*/
2346 /* add new BSS to JoinBssTable */
2347 #ifdef WILC_PARSE_SCAN_IN_HOST
2348 pJoinParams
= host_int_ParseJoinBssParam(pstrNetworkInfo
);
2349 #endif /*WILC_PARSE_SCAN_IN_HOST*/
2351 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND
, pstrNetworkInfo
,
2352 pstrWFIDrv
->strWILC_UsrScanReq
.u32UserScanPvoid
,
2358 PRINT_WRN(HOSTINF_DBG
, "Discovered networks exceeded max. limit\n");
2361 pstrNetworkInfo
->bNewNetwork
= false;
2362 /* just call the User CallBack function to send the same discovered network with its updated RSSI */
2363 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND
, pstrNetworkInfo
,
2364 pstrWFIDrv
->strWILC_UsrScanReq
.u32UserScanPvoid
, NULL
);
2369 WILC_CATCH(s32Error
)
2375 /* Deallocate pstrRcvdNetworkInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2376 if (pstrRcvdNetworkInfo
->pu8Buffer
!= NULL
) {
2377 kfree(pstrRcvdNetworkInfo
->pu8Buffer
);
2378 pstrRcvdNetworkInfo
->pu8Buffer
= NULL
;
2381 /*free structure allocated*/
2382 if (pstrNetworkInfo
!= NULL
) {
2383 DeallocateNetworkInfo(pstrNetworkInfo
);
2384 pstrNetworkInfo
= NULL
;
2391 * @brief Handle_RcvdGnrlAsyncInfo
2392 * @details Handling received asynchrous general network information
2393 * @param[in] tstrRcvdGnrlAsyncInfo* pstrRcvdGnrlAsyncInfo
2394 * @return Error code.
2399 static s32
Handle_RcvdGnrlAsyncInfo(tstrWILC_WFIDrv
*drvHandler
, tstrRcvdGnrlAsyncInfo
*pstrRcvdGnrlAsyncInfo
)
2401 /* TODO: mostafa: till now, this function just handles only the received mac status msg, */
2402 /* which carries only 1 WID which have WID ID = WID_STATUS */
2403 s32 s32Error
= WILC_SUCCESS
;
2407 u16 u16WidID
= (u16
)WID_NIL
;
2410 u8 u8MacStatusReasonCode
;
2411 u8 u8MacStatusAdditionalInfo
;
2412 tstrConnectInfo strConnectInfo
;
2413 tstrDisconnectNotifInfo strDisconnectNotifInfo
;
2414 s32 s32Err
= WILC_SUCCESS
;
2415 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*) drvHandler
;
2417 if (pstrWFIDrv
== NULL
)
2418 PRINT_ER("Driver handler is NULL\n");
2419 PRINT_D(GENERIC_DBG
, "Current State = %d,Received state = %d\n", pstrWFIDrv
->enuHostIFstate
,
2420 pstrRcvdGnrlAsyncInfo
->pu8Buffer
[7]);
2422 if ((pstrWFIDrv
->enuHostIFstate
== HOST_IF_WAITING_CONN_RESP
) ||
2423 (pstrWFIDrv
->enuHostIFstate
== HOST_IF_CONNECTED
) ||
2424 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
2425 if ((pstrRcvdGnrlAsyncInfo
->pu8Buffer
== NULL
) ||
2426 (pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
== NULL
)) {
2427 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
2430 u8MsgType
= pstrRcvdGnrlAsyncInfo
->pu8Buffer
[0];
2432 /* Check whether the received message type is 'I' */
2433 if ('I' != u8MsgType
) {
2434 PRINT_ER("Received Message format incorrect.\n");
2435 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
2438 /* Extract message ID */
2439 u8MsgID
= pstrRcvdGnrlAsyncInfo
->pu8Buffer
[1];
2441 /* Extract message Length */
2442 u16MsgLen
= MAKE_WORD16(pstrRcvdGnrlAsyncInfo
->pu8Buffer
[2], pstrRcvdGnrlAsyncInfo
->pu8Buffer
[3]);
2444 /* Extract WID ID [expected to be = WID_STATUS] */
2445 u16WidID
= MAKE_WORD16(pstrRcvdGnrlAsyncInfo
->pu8Buffer
[4], pstrRcvdGnrlAsyncInfo
->pu8Buffer
[5]);
2447 /* Extract WID Length [expected to be = 1] */
2448 u8WidLen
= pstrRcvdGnrlAsyncInfo
->pu8Buffer
[6];
2450 /* get the WID value [expected to be one of two values: either MAC_CONNECTED = (1) or MAC_DISCONNECTED = (0)] */
2451 u8MacStatus
= pstrRcvdGnrlAsyncInfo
->pu8Buffer
[7];
2452 u8MacStatusReasonCode
= pstrRcvdGnrlAsyncInfo
->pu8Buffer
[8];
2453 u8MacStatusAdditionalInfo
= pstrRcvdGnrlAsyncInfo
->pu8Buffer
[9];
2454 PRINT_INFO(HOSTINF_DBG
, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus
, u8MacStatusReasonCode
, u8MacStatusAdditionalInfo
);
2455 if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_WAITING_CONN_RESP
) {
2456 /* our station had sent Association Request frame, so here it will get the Association Response frame then parse it */
2457 u32 u32RcvdAssocRespInfoLen
;
2458 tstrConnectRespInfo
*pstrConnectRespInfo
= NULL
;
2460 PRINT_D(HOSTINF_DBG
, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus
, u8MacStatusReasonCode
, u8MacStatusAdditionalInfo
);
2462 memset(&strConnectInfo
, 0, sizeof(tstrConnectInfo
));
2464 if (u8MacStatus
== MAC_CONNECTED
) {
2465 memset(gapu8RcvdAssocResp
, 0, MAX_ASSOC_RESP_FRAME_SIZE
);
2467 host_int_get_assoc_res_info(pstrWFIDrv
,
2469 MAX_ASSOC_RESP_FRAME_SIZE
,
2470 &u32RcvdAssocRespInfoLen
);
2472 PRINT_INFO(HOSTINF_DBG
, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen
);
2474 if (u32RcvdAssocRespInfoLen
!= 0) {
2476 PRINT_D(HOSTINF_DBG
, "Parsing association response\n");
2477 s32Err
= ParseAssocRespInfo(gapu8RcvdAssocResp
, u32RcvdAssocRespInfoLen
,
2478 &pstrConnectRespInfo
);
2480 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err
);
2482 /* use the necessary parsed Info from the Received Association Response */
2483 strConnectInfo
.u16ConnectStatus
= pstrConnectRespInfo
->u16ConnectStatus
;
2485 if (strConnectInfo
.u16ConnectStatus
== SUCCESSFUL_STATUSCODE
) {
2486 PRINT_INFO(HOSTINF_DBG
, "Association response received : Successful connection status\n");
2487 if (pstrConnectRespInfo
->pu8RespIEs
!= NULL
) {
2488 strConnectInfo
.u16RespIEsLen
= pstrConnectRespInfo
->u16RespIEsLen
;
2491 strConnectInfo
.pu8RespIEs
= kmalloc(pstrConnectRespInfo
->u16RespIEsLen
, GFP_KERNEL
);
2492 memcpy(strConnectInfo
.pu8RespIEs
, pstrConnectRespInfo
->pu8RespIEs
,
2493 pstrConnectRespInfo
->u16RespIEsLen
);
2497 /* deallocate the Assoc. Resp. parsed structure as it is not needed anymore */
2498 if (pstrConnectRespInfo
!= NULL
) {
2499 DeallocateAssocRespInfo(pstrConnectRespInfo
);
2500 pstrConnectRespInfo
= NULL
;
2506 /* The station has just received mac status and it also received assoc. response which
2507 * it was waiting for.
2508 * So check first the matching between the received mac status and the received status code in Asoc Resp */
2509 if ((u8MacStatus
== MAC_CONNECTED
) &&
2510 (strConnectInfo
.u16ConnectStatus
!= SUCCESSFUL_STATUSCODE
)) {
2511 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
2512 memset(u8ConnectedSSID
, 0, ETH_ALEN
);
2514 } else if (u8MacStatus
== MAC_DISCONNECTED
) {
2515 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
2516 memset(u8ConnectedSSID
, 0, ETH_ALEN
);
2519 /* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */
2520 /* through a structure of type tstrConnectRespInfo */
2521 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
!= NULL
) {
2522 PRINT_D(HOSTINF_DBG
, "Retrieving actual BSSID from AP\n");
2523 memcpy(strConnectInfo
.au8bssid
, pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
, 6);
2525 if ((u8MacStatus
== MAC_CONNECTED
) &&
2526 (strConnectInfo
.u16ConnectStatus
== SUCCESSFUL_STATUSCODE
)) {
2527 memcpy(pstrWFIDrv
->au8AssociatedBSSID
,
2528 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
, ETH_ALEN
);
2533 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
!= NULL
) {
2534 strConnectInfo
.ReqIEsLen
= pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
;
2535 strConnectInfo
.pu8ReqIEs
= kmalloc(pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
, GFP_KERNEL
);
2536 memcpy(strConnectInfo
.pu8ReqIEs
,
2537 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
,
2538 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
);
2542 del_timer(&pstrWFIDrv
->hConnectTimer
);
2543 pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP
,
2547 pstrWFIDrv
->strWILC_UsrConnReq
.u32UserConnectPvoid
);
2550 /* if received mac status is MAC_CONNECTED and
2551 * received status code in Asoc Resp is SUCCESSFUL_STATUSCODE, change state to CONNECTED
2552 * else change state to IDLE */
2553 if ((u8MacStatus
== MAC_CONNECTED
) &&
2554 (strConnectInfo
.u16ConnectStatus
== SUCCESSFUL_STATUSCODE
)) {
2555 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2557 host_int_set_power_mgmt(pstrWFIDrv
, 0, 0);
2560 PRINT_D(HOSTINF_DBG
, "MAC status : CONNECTED and Connect Status : Successful\n");
2561 pstrWFIDrv
->enuHostIFstate
= HOST_IF_CONNECTED
;
2563 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2564 PRINT_D(GENERIC_DBG
, "Obtaining an IP, Disable Scan\n");
2565 g_obtainingIP
= true;
2566 mod_timer(&hDuringIpTimer
,
2567 jiffies
+ msecs_to_jiffies(10000));
2570 #ifdef WILC_PARSE_SCAN_IN_HOST
2571 /* open a BA session if possible */
2572 /* if(pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable) */
2576 /* host_int_addBASession(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid,0, */
2577 /* BA_SESSION_DEFAULT_BUFFER_SIZE,BA_SESSION_DEFAULT_TIMEOUT); */
2579 PRINT_D(HOSTINF_DBG
, "MAC status : %d and Connect Status : %d\n", u8MacStatus
, strConnectInfo
.u16ConnectStatus
);
2580 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
2581 gbScanWhileConnected
= false;
2585 if (strConnectInfo
.pu8RespIEs
!= NULL
) {
2586 kfree(strConnectInfo
.pu8RespIEs
);
2587 strConnectInfo
.pu8RespIEs
= NULL
;
2590 if (strConnectInfo
.pu8ReqIEs
!= NULL
) {
2591 kfree(strConnectInfo
.pu8ReqIEs
);
2592 strConnectInfo
.pu8ReqIEs
= NULL
;
2596 pstrWFIDrv
->strWILC_UsrConnReq
.ssidLen
= 0;
2597 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
!= NULL
) {
2598 kfree(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
);
2599 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
= NULL
;
2602 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
!= NULL
) {
2603 kfree(pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
);
2604 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
= NULL
;
2607 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
= 0;
2608 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
!= NULL
) {
2609 kfree(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
);
2610 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
= NULL
;
2613 } else if ((u8MacStatus
== MAC_DISCONNECTED
) &&
2614 (pstrWFIDrv
->enuHostIFstate
== HOST_IF_CONNECTED
)) {
2615 /* Disassociation or Deauthentication frame has been received */
2616 PRINT_D(HOSTINF_DBG
, "Received MAC_DISCONNECTED from the FW\n");
2618 memset(&strDisconnectNotifInfo
, 0, sizeof(tstrDisconnectNotifInfo
));
2620 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
2621 PRINT_D(HOSTINF_DBG
, "\n\n<< Abort the running OBSS Scan >>\n\n");
2622 del_timer(&pstrWFIDrv
->hScanTimer
);
2623 Handle_ScanDone((void *)pstrWFIDrv
, SCAN_EVENT_ABORTED
);
2626 strDisconnectNotifInfo
.u16reason
= 0;
2627 strDisconnectNotifInfo
.ie
= NULL
;
2628 strDisconnectNotifInfo
.ie_len
= 0;
2630 if (pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
!= NULL
) {
2631 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2633 g_obtainingIP
= false;
2634 host_int_set_power_mgmt(pstrWFIDrv
, 0, 0);
2637 pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF
,
2640 &strDisconnectNotifInfo
,
2641 pstrWFIDrv
->strWILC_UsrConnReq
.u32UserConnectPvoid
);
2644 PRINT_ER("Connect result callback function is NULL\n");
2647 memset(pstrWFIDrv
->au8AssociatedBSSID
, 0, ETH_ALEN
);
2652 /* if Information Elements were retrieved from the Received deauth/disassoc frame, then they
2653 * should be deallocated here */
2655 * if(strDisconnectNotifInfo.ie != NULL)
2657 * kfree(strDisconnectNotifInfo.ie);
2658 * strDisconnectNotifInfo.ie = NULL;
2662 pstrWFIDrv
->strWILC_UsrConnReq
.ssidLen
= 0;
2663 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
!= NULL
) {
2664 kfree(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
);
2665 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
= NULL
;
2668 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
!= NULL
) {
2669 kfree(pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
);
2670 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
= NULL
;
2673 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
= 0;
2674 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
!= NULL
) {
2675 kfree(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
);
2676 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
= NULL
;
2680 /*Freeing flushed join request params on receiving*/
2681 /*MAC_DISCONNECTED while connected*/
2682 if (gu8FlushedJoinReq
!= NULL
&& gu8FlushedJoinReqDrvHandler
== drvHandler
) {
2683 kfree(gu8FlushedJoinReq
);
2684 gu8FlushedJoinReq
= NULL
;
2686 if (gu8FlushedInfoElemAsoc
!= NULL
&& gu8FlushedJoinReqDrvHandler
== drvHandler
) {
2687 kfree(gu8FlushedInfoElemAsoc
);
2688 gu8FlushedInfoElemAsoc
= NULL
;
2691 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
2692 gbScanWhileConnected
= false;
2694 } else if ((u8MacStatus
== MAC_DISCONNECTED
) &&
2695 (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
!= NULL
)) {
2696 PRINT_D(HOSTINF_DBG
, "Received MAC_DISCONNECTED from the FW while scanning\n");
2697 PRINT_D(HOSTINF_DBG
, "\n\n<< Abort the running Scan >>\n\n");
2698 /*Abort the running scan*/
2699 del_timer(&pstrWFIDrv
->hScanTimer
);
2700 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
)
2701 Handle_ScanDone(pstrWFIDrv
, SCAN_EVENT_ABORTED
);
2707 WILC_CATCH(s32Error
)
2712 /* Deallocate pstrRcvdGnrlAsyncInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2713 if (pstrRcvdGnrlAsyncInfo
->pu8Buffer
!= NULL
) {
2714 kfree(pstrRcvdGnrlAsyncInfo
->pu8Buffer
);
2715 pstrRcvdGnrlAsyncInfo
->pu8Buffer
= NULL
;
2723 * @details Sending config packet to firmware to set key
2724 * @param[in] tstrHostIFkeyAttr* pstrHostIFkeyAttr
2725 * @return Error code.
2730 static int Handle_Key(tstrWILC_WFIDrv
*drvHandler
, tstrHostIFkeyAttr
*pstrHostIFkeyAttr
)
2732 s32 s32Error
= WILC_SUCCESS
;
2734 #ifdef WILC_AP_EXTERNAL_MLME
2735 tstrWID strWIDList
[5];
2741 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
2744 switch (pstrHostIFkeyAttr
->enuKeyType
) {
2749 #ifdef WILC_AP_EXTERNAL_MLME
2750 if (pstrHostIFkeyAttr
->u8KeyAction
& ADDKEY_AP
) {
2752 PRINT_D(HOSTINF_DBG
, "Handling WEP key\n");
2753 PRINT_D(GENERIC_DBG
, "ID Hostint is %d\n", (pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
));
2754 strWIDList
[0].u16WIDid
= (u16
)WID_11I_MODE
;
2755 strWIDList
[0].enuWIDtype
= WID_CHAR
;
2756 strWIDList
[0].s32ValueSize
= sizeof(char);
2757 strWIDList
[0].ps8WidVal
= (s8
*)(&(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8mode
));
2759 strWIDList
[1].u16WIDid
= WID_AUTH_TYPE
;
2760 strWIDList
[1].enuWIDtype
= WID_CHAR
;
2761 strWIDList
[1].s32ValueSize
= sizeof(char);
2762 strWIDList
[1].ps8WidVal
= (s8
*)(&(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.tenuAuth_type
));
2764 strWIDList
[2].u16WIDid
= (u16
)WID_KEY_ID
;
2765 strWIDList
[2].enuWIDtype
= WID_CHAR
;
2767 strWIDList
[2].ps8WidVal
= (s8
*)(&(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
));
2768 strWIDList
[2].s32ValueSize
= sizeof(char);
2771 pu8keybuf
= kmalloc(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
, GFP_KERNEL
);
2774 if (pu8keybuf
== NULL
) {
2775 PRINT_ER("No buffer to send Key\n");
2779 memcpy(pu8keybuf
, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
,
2780 pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
);
2783 kfree(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
);
2785 strWIDList
[3].u16WIDid
= (u16
)WID_WEP_KEY_VALUE
;
2786 strWIDList
[3].enuWIDtype
= WID_STR
;
2787 strWIDList
[3].s32ValueSize
= pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
;
2788 strWIDList
[3].ps8WidVal
= (s8
*)pu8keybuf
;
2791 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, 4, true,
2792 get_id_from_handler(pstrWFIDrv
));
2799 if (pstrHostIFkeyAttr
->u8KeyAction
& ADDKEY
) {
2800 PRINT_D(HOSTINF_DBG
, "Handling WEP key\n");
2801 pu8keybuf
= kmalloc(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
+ 2, GFP_KERNEL
);
2802 if (pu8keybuf
== NULL
) {
2803 PRINT_ER("No buffer to send Key\n");
2806 pu8keybuf
[0] = pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
;
2808 memcpy(pu8keybuf
+ 1, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
, 1);
2810 memcpy(pu8keybuf
+ 2, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
,
2811 pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
);
2813 kfree(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
);
2815 strWID
.u16WIDid
= (u16
)WID_ADD_WEP_KEY
;
2816 strWID
.enuWIDtype
= WID_STR
;
2817 strWID
.ps8WidVal
= (s8
*)pu8keybuf
;
2818 strWID
.s32ValueSize
= pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
+ 2;
2820 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
2821 get_id_from_handler(pstrWFIDrv
));
2823 } else if (pstrHostIFkeyAttr
->u8KeyAction
& REMOVEKEY
) {
2825 PRINT_D(HOSTINF_DBG
, "Removing key\n");
2826 strWID
.u16WIDid
= (u16
)WID_REMOVE_WEP_KEY
;
2827 strWID
.enuWIDtype
= WID_STR
;
2829 s8idxarray
[0] = (s8
)pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
;
2830 strWID
.ps8WidVal
= s8idxarray
;
2831 strWID
.s32ValueSize
= 1;
2833 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
2834 get_id_from_handler(pstrWFIDrv
));
2836 strWID
.u16WIDid
= (u16
)WID_KEY_ID
;
2837 strWID
.enuWIDtype
= WID_CHAR
;
2838 strWID
.ps8WidVal
= (s8
*)(&(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
));
2839 strWID
.s32ValueSize
= sizeof(char);
2841 PRINT_D(HOSTINF_DBG
, "Setting default key index\n");
2843 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
2844 get_id_from_handler(pstrWFIDrv
));
2846 up(&(pstrWFIDrv
->hSemTestKeyBlock
));
2850 #ifdef WILC_AP_EXTERNAL_MLME
2851 if (pstrHostIFkeyAttr
->u8KeyAction
& ADDKEY_AP
) {
2852 pu8keybuf
= kmalloc(RX_MIC_KEY_MSG_LEN
, GFP_KERNEL
);
2853 if (pu8keybuf
== NULL
) {
2854 PRINT_ER("No buffer to send RxGTK Key\n");
2856 goto _WPARxGtk_end_case_
;
2859 memset(pu8keybuf
, 0, RX_MIC_KEY_MSG_LEN
);
2862 /*|----------------------------------------------------------------------------|
2863 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2864 * |------------|---------|-------|------------|---------------|----------------|
2865 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2869 if (pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8seq
!= NULL
)
2870 memcpy(pu8keybuf
+ 6, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8seq
, 8);
2873 memcpy(pu8keybuf
+ 14, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8keyidx
, 1);
2875 memcpy(pu8keybuf
+ 15, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
, 1);
2877 memcpy(pu8keybuf
+ 16, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
,
2878 pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
);
2879 /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */
2880 strWIDList
[0].u16WIDid
= (u16
)WID_11I_MODE
;
2881 strWIDList
[0].enuWIDtype
= WID_CHAR
;
2882 strWIDList
[0].s32ValueSize
= sizeof(char);
2883 strWIDList
[0].ps8WidVal
= (s8
*)(&(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Ciphermode
));
2885 strWIDList
[1].u16WIDid
= (u16
)WID_ADD_RX_GTK
;
2886 strWIDList
[1].enuWIDtype
= WID_STR
;
2887 strWIDList
[1].ps8WidVal
= (s8
*)pu8keybuf
;
2888 strWIDList
[1].s32ValueSize
= RX_MIC_KEY_MSG_LEN
;
2890 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, 2, true,
2891 get_id_from_handler(pstrWFIDrv
));
2895 /* ////////////////////////// */
2896 up(&(pstrWFIDrv
->hSemTestKeyBlock
));
2897 /* ///////////////////////// */
2901 if (pstrHostIFkeyAttr
->u8KeyAction
& ADDKEY
) {
2902 PRINT_D(HOSTINF_DBG
, "Handling group key(Rx) function\n");
2904 pu8keybuf
= kmalloc(RX_MIC_KEY_MSG_LEN
, GFP_KERNEL
);
2905 if (pu8keybuf
== NULL
) {
2906 PRINT_ER("No buffer to send RxGTK Key\n");
2908 goto _WPARxGtk_end_case_
;
2911 memset(pu8keybuf
, 0, RX_MIC_KEY_MSG_LEN
);
2914 /*|----------------------------------------------------------------------------|
2915 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2916 * |------------|---------|-------|------------|---------------|----------------|
2917 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2919 if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_CONNECTED
)
2920 memcpy(pu8keybuf
, pstrWFIDrv
->au8AssociatedBSSID
, ETH_ALEN
);
2922 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
2924 memcpy(pu8keybuf
+ 6, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8seq
, 8);
2926 memcpy(pu8keybuf
+ 14, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8keyidx
, 1);
2928 memcpy(pu8keybuf
+ 15, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
, 1);
2929 memcpy(pu8keybuf
+ 16, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
,
2930 pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
);
2932 strWID
.u16WIDid
= (u16
)WID_ADD_RX_GTK
;
2933 strWID
.enuWIDtype
= WID_STR
;
2934 strWID
.ps8WidVal
= (s8
*)pu8keybuf
;
2935 strWID
.s32ValueSize
= RX_MIC_KEY_MSG_LEN
;
2937 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
2938 get_id_from_handler(pstrWFIDrv
));
2942 /* ////////////////////////// */
2943 up(&(pstrWFIDrv
->hSemTestKeyBlock
));
2944 /* ///////////////////////// */
2946 _WPARxGtk_end_case_
:
2947 kfree(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
);
2948 kfree(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8seq
);
2955 #ifdef WILC_AP_EXTERNAL_MLME
2956 if (pstrHostIFkeyAttr
->u8KeyAction
& ADDKEY_AP
) {
2959 pu8keybuf
= kmalloc(PTK_KEY_MSG_LEN
+ 1, GFP_KERNEL
);
2963 if (pu8keybuf
== NULL
) {
2964 PRINT_ER("No buffer to send PTK Key\n");
2966 goto _WPAPtk_end_case_
;
2970 /*|-----------------------------------------------------------------------------|
2971 * |Station address | keyidx |Key Length |Temporal Key | Rx Michael Key |Tx Michael Key |
2972 * |----------------|------------ |--------------|----------------|---------------|
2973 | 6 bytes | 1 byte | 1byte | 16 bytes | 8 bytes | 8 bytes |
2974 |-----------------------------------------------------------------------------|*/
2976 memcpy(pu8keybuf
, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8macaddr
, 6); /*1 bytes Key Length */
2978 memcpy(pu8keybuf
+ 6, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8keyidx
, 1);
2979 memcpy(pu8keybuf
+ 7, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
, 1);
2981 memcpy(pu8keybuf
+ 8, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
,
2982 pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
);
2985 strWIDList
[0].u16WIDid
= (u16
)WID_11I_MODE
;
2986 strWIDList
[0].enuWIDtype
= WID_CHAR
;
2987 strWIDList
[0].s32ValueSize
= sizeof(char);
2988 strWIDList
[0].ps8WidVal
= (s8
*)(&(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Ciphermode
));
2990 strWIDList
[1].u16WIDid
= (u16
)WID_ADD_PTK
;
2991 strWIDList
[1].enuWIDtype
= WID_STR
;
2992 strWIDList
[1].ps8WidVal
= (s8
*)pu8keybuf
;
2993 strWIDList
[1].s32ValueSize
= PTK_KEY_MSG_LEN
+ 1;
2995 s32Error
= SendConfigPkt(SET_CFG
, strWIDList
, 2, true,
2996 get_id_from_handler(pstrWFIDrv
));
2999 /* ////////////////////////// */
3000 up(&(pstrWFIDrv
->hSemTestKeyBlock
));
3001 /* ///////////////////////// */
3004 if (pstrHostIFkeyAttr
->u8KeyAction
& ADDKEY
) {
3007 pu8keybuf
= kmalloc(PTK_KEY_MSG_LEN
, GFP_KERNEL
);
3011 if (pu8keybuf
== NULL
) {
3012 PRINT_ER("No buffer to send PTK Key\n");
3014 goto _WPAPtk_end_case_
;
3018 /*|-----------------------------------------------------------------------------|
3019 * |Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
3020 * |----------------|------------|--------------|----------------|---------------|
3021 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
3022 |-----------------------------------------------------------------------------|*/
3024 memcpy(pu8keybuf
, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8macaddr
, 6); /*1 bytes Key Length */
3026 memcpy(pu8keybuf
+ 6, &pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
, 1);
3028 memcpy(pu8keybuf
+ 7, pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
,
3029 pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
);
3032 strWID
.u16WIDid
= (u16
)WID_ADD_PTK
;
3033 strWID
.enuWIDtype
= WID_STR
;
3034 strWID
.ps8WidVal
= (s8
*)pu8keybuf
;
3035 strWID
.s32ValueSize
= PTK_KEY_MSG_LEN
;
3037 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
3038 get_id_from_handler(pstrWFIDrv
));
3041 /* ////////////////////////// */
3042 up(&(pstrWFIDrv
->hSemTestKeyBlock
));
3043 /* ///////////////////////// */
3047 kfree(pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
);
3056 PRINT_D(HOSTINF_DBG
, "Handling PMKSA key\n");
3058 pu8keybuf
= kmalloc((pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFpmkidAttr
.numpmkid
* PMKSA_KEY_LEN
) + 1, GFP_KERNEL
);
3059 if (pu8keybuf
== NULL
) {
3060 PRINT_ER("No buffer to send PMKSA Key\n");
3064 pu8keybuf
[0] = pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFpmkidAttr
.numpmkid
;
3066 for (i
= 0; i
< pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFpmkidAttr
.numpmkid
; i
++) {
3068 memcpy(pu8keybuf
+ ((PMKSA_KEY_LEN
* i
) + 1), pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFpmkidAttr
.pmkidlist
[i
].bssid
, ETH_ALEN
);
3069 memcpy(pu8keybuf
+ ((PMKSA_KEY_LEN
* i
) + ETH_ALEN
+ 1), pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFpmkidAttr
.pmkidlist
[i
].pmkid
, PMKID_LEN
);
3072 strWID
.u16WIDid
= (u16
)WID_PMKID_INFO
;
3073 strWID
.enuWIDtype
= WID_STR
;
3074 strWID
.ps8WidVal
= (s8
*)pu8keybuf
;
3075 strWID
.s32ValueSize
= (pstrHostIFkeyAttr
->uniHostIFkeyAttr
.strHostIFpmkidAttr
.numpmkid
* PMKSA_KEY_LEN
) + 1;
3077 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
3078 get_id_from_handler(pstrWFIDrv
));
3085 PRINT_ER("Failed to send key config packet\n");
3093 * @brief Handle_Disconnect
3094 * @details Sending config packet to firmware to disconnect
3101 static void Handle_Disconnect(tstrWILC_WFIDrv
*drvHandler
)
3105 s32 s32Error
= WILC_SUCCESS
;
3106 u16 u16DummyReasonCode
= 0;
3107 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3110 strWID
.u16WIDid
= (u16
)WID_DISCONNECT
;
3111 strWID
.enuWIDtype
= WID_CHAR
;
3112 strWID
.ps8WidVal
= (s8
*)&u16DummyReasonCode
;
3113 strWID
.s32ValueSize
= sizeof(char);
3117 PRINT_D(HOSTINF_DBG
, "Sending disconnect request\n");
3119 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3121 g_obtainingIP
= false;
3122 host_int_set_power_mgmt(pstrWFIDrv
, 0, 0);
3125 memset(u8ConnectedSSID
, 0, ETH_ALEN
);
3127 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false,
3128 get_id_from_handler(pstrWFIDrv
));
3131 PRINT_ER("Failed to send dissconect config packet\n");
3132 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3134 tstrDisconnectNotifInfo strDisconnectNotifInfo
;
3136 memset(&strDisconnectNotifInfo
, 0, sizeof(tstrDisconnectNotifInfo
));
3138 strDisconnectNotifInfo
.u16reason
= 0;
3139 strDisconnectNotifInfo
.ie
= NULL
;
3140 strDisconnectNotifInfo
.ie_len
= 0;
3142 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
3143 del_timer(&pstrWFIDrv
->hScanTimer
);
3144 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult(SCAN_EVENT_ABORTED
, NULL
,
3145 pstrWFIDrv
->strWILC_UsrScanReq
.u32UserScanPvoid
, NULL
);
3147 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
= NULL
;
3150 if (pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
!= NULL
) {
3153 /*Stop connect timer, if connection in progress*/
3154 if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_WAITING_CONN_RESP
) {
3155 PRINT_D(HOSTINF_DBG
, "Upper layer requested termination of connection\n");
3156 del_timer(&pstrWFIDrv
->hConnectTimer
);
3159 pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF
, NULL
,
3160 0, &strDisconnectNotifInfo
, pstrWFIDrv
->strWILC_UsrConnReq
.u32UserConnectPvoid
);
3162 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
3165 gbScanWhileConnected
= false;
3167 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
3169 memset(pstrWFIDrv
->au8AssociatedBSSID
, 0, ETH_ALEN
);
3173 pstrWFIDrv
->strWILC_UsrConnReq
.ssidLen
= 0;
3174 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
!= NULL
) {
3175 kfree(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
);
3176 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ssid
= NULL
;
3179 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
!= NULL
) {
3180 kfree(pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
);
3181 pstrWFIDrv
->strWILC_UsrConnReq
.pu8bssid
= NULL
;
3184 pstrWFIDrv
->strWILC_UsrConnReq
.ConnReqIEsLen
= 0;
3185 if (pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
!= NULL
) {
3186 kfree(pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
);
3187 pstrWFIDrv
->strWILC_UsrConnReq
.pu8ConnReqIEs
= NULL
;
3192 if (gu8FlushedJoinReq
!= NULL
&& gu8FlushedJoinReqDrvHandler
== drvHandler
) {
3193 kfree(gu8FlushedJoinReq
);
3194 gu8FlushedJoinReq
= NULL
;
3196 if (gu8FlushedInfoElemAsoc
!= NULL
&& gu8FlushedJoinReqDrvHandler
== drvHandler
) {
3197 kfree(gu8FlushedInfoElemAsoc
);
3198 gu8FlushedInfoElemAsoc
= NULL
;
3203 WILC_CATCH(s32Error
)
3208 /* ////////////////////////// */
3209 up(&(pstrWFIDrv
->hSemTestDisconnectBlock
));
3210 /* ///////////////////////// */
3215 void resolve_disconnect_aberration(tstrWILC_WFIDrv
*drvHandler
)
3217 tstrWILC_WFIDrv
*pstrWFIDrv
;
3219 pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3220 if (pstrWFIDrv
== NULL
)
3222 if ((pstrWFIDrv
->enuHostIFstate
== HOST_IF_WAITING_CONN_RESP
) || (pstrWFIDrv
->enuHostIFstate
== HOST_IF_CONNECTING
)) {
3223 PRINT_D(HOSTINF_DBG
, "\n\n<< correcting Supplicant state machine >>\n\n");
3224 host_int_disconnect(pstrWFIDrv
, 1);
3227 static s32
Switch_Log_Terminal(tstrWILC_WFIDrv
*drvHandler
)
3231 s32 s32Error
= WILC_SUCCESS
;
3233 static char dummy
= 9;
3234 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3236 strWID
.u16WIDid
= (u16
)WID_LOGTerminal_Switch
;
3237 strWID
.enuWIDtype
= WID_CHAR
;
3238 strWID
.ps8WidVal
= &dummy
;
3239 strWID
.s32ValueSize
= sizeof(char);
3241 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
3242 get_id_from_handler(pstrWFIDrv
));
3246 PRINT_D(HOSTINF_DBG
, "Failed to switch log terminal\n");
3247 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
3249 PRINT_INFO(HOSTINF_DBG
, "MAC address set ::\n");
3254 WILC_CATCH(s32Error
)
3263 * @brief Handle_GetChnl
3264 * @details Sending config packet to get channel
3272 static s32
Handle_GetChnl(tstrWILC_WFIDrv
*drvHandler
)
3275 s32 s32Error
= WILC_SUCCESS
;
3277 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
3278 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3280 strWID
.u16WIDid
= (u16
)WID_CURRENT_CHANNEL
;
3281 strWID
.enuWIDtype
= WID_CHAR
;
3282 strWID
.ps8WidVal
= (s8
*)&gu8Chnl
;
3283 strWID
.s32ValueSize
= sizeof(char);
3285 PRINT_D(HOSTINF_DBG
, "Getting channel value\n");
3287 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true,
3288 get_id_from_handler(pstrWFIDrv
));
3289 /*get the value by searching the local copy*/
3291 PRINT_ER("Failed to get channel number\n");
3292 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3296 WILC_CATCH(s32Error
)
3300 up(&(pstrWFIDrv
->hSemGetCHNL
));
3310 * @brief Handle_GetRssi
3311 * @details Sending config packet to get RSSI
3318 static void Handle_GetRssi(tstrWILC_WFIDrv
*drvHandler
)
3320 s32 s32Error
= WILC_SUCCESS
;
3322 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3324 strWID
.u16WIDid
= (u16
)WID_RSSI
;
3325 strWID
.enuWIDtype
= WID_CHAR
;
3326 strWID
.ps8WidVal
= &gs8Rssi
;
3327 strWID
.s32ValueSize
= sizeof(char);
3330 PRINT_D(HOSTINF_DBG
, "Getting RSSI value\n");
3332 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true,
3333 get_id_from_handler(pstrWFIDrv
));
3335 PRINT_ER("Failed to get RSSI value\n");
3336 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3339 WILC_CATCH(s32Error
)
3343 up(&(pstrWFIDrv
->hSemGetRSSI
));
3349 static void Handle_GetLinkspeed(tstrWILC_WFIDrv
*drvHandler
)
3351 s32 s32Error
= WILC_SUCCESS
;
3353 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3357 strWID
.u16WIDid
= (u16
)WID_LINKSPEED
;
3358 strWID
.enuWIDtype
= WID_CHAR
;
3359 strWID
.ps8WidVal
= &gs8lnkspd
;
3360 strWID
.s32ValueSize
= sizeof(char);
3362 PRINT_D(HOSTINF_DBG
, "Getting LINKSPEED value\n");
3364 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true,
3365 get_id_from_handler(pstrWFIDrv
));
3367 PRINT_ER("Failed to get LINKSPEED value\n");
3368 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3371 WILC_CATCH(s32Error
)
3375 up(&(pstrWFIDrv
->hSemGetLINKSPEED
));
3380 s32
Handle_GetStatistics(tstrWILC_WFIDrv
*drvHandler
, tstrStatistics
*pstrStatistics
)
3382 tstrWID strWIDList
[5];
3383 u32 u32WidsCount
= 0, s32Error
= 0;
3385 strWIDList
[u32WidsCount
].u16WIDid
= WID_LINKSPEED
;
3386 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
3387 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
3388 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrStatistics
->u8LinkSpeed
));
3391 strWIDList
[u32WidsCount
].u16WIDid
= WID_RSSI
;
3392 strWIDList
[u32WidsCount
].enuWIDtype
= WID_CHAR
;
3393 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(char);
3394 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrStatistics
->s8RSSI
));
3397 strWIDList
[u32WidsCount
].u16WIDid
= WID_SUCCESS_FRAME_COUNT
;
3398 strWIDList
[u32WidsCount
].enuWIDtype
= WID_INT
;
3399 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(u32
);
3400 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrStatistics
->u32TxCount
));
3403 strWIDList
[u32WidsCount
].u16WIDid
= WID_RECEIVED_FRAGMENT_COUNT
;
3404 strWIDList
[u32WidsCount
].enuWIDtype
= WID_INT
;
3405 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(u32
);
3406 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrStatistics
->u32RxCount
));
3409 strWIDList
[u32WidsCount
].u16WIDid
= WID_FAILED_COUNT
;
3410 strWIDList
[u32WidsCount
].enuWIDtype
= WID_INT
;
3411 strWIDList
[u32WidsCount
].s32ValueSize
= sizeof(u32
);
3412 strWIDList
[u32WidsCount
].ps8WidVal
= (s8
*)(&(pstrStatistics
->u32TxFailureCount
));
3415 s32Error
= SendConfigPkt(GET_CFG
, strWIDList
, u32WidsCount
, false,
3416 get_id_from_handler(drvHandler
));
3419 PRINT_ER("Failed to send scan paramters config packet\n");
3420 /* WILC_ERRORREPORT(s32Error, s32Error); */
3428 #ifdef WILC_AP_EXTERNAL_MLME
3432 * @brief Handle_Get_InActiveTime
3433 * @details Sending config packet to set mac adddress for station and
3442 static s32
Handle_Get_InActiveTime(tstrWILC_WFIDrv
*drvHandler
, tstrHostIfStaInactiveT
*strHostIfStaInactiveT
)
3445 s32 s32Error
= WILC_SUCCESS
;
3448 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3451 strWID
.u16WIDid
= (u16
)WID_SET_STA_MAC_INACTIVE_TIME
;
3452 strWID
.enuWIDtype
= WID_STR
;
3453 strWID
.s32ValueSize
= ETH_ALEN
;
3454 strWID
.ps8WidVal
= kmalloc(strWID
.s32ValueSize
, GFP_KERNEL
);
3457 stamac
= strWID
.ps8WidVal
;
3458 memcpy(stamac
, strHostIfStaInactiveT
->mac
, ETH_ALEN
);
3461 PRINT_D(CFG80211_DBG
, "SETING STA inactive time\n");
3464 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
3465 get_id_from_handler(pstrWFIDrv
));
3466 /*get the value by searching the local copy*/
3468 PRINT_ER("Failed to SET incative time\n");
3469 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3473 strWID
.u16WIDid
= (u16
)WID_GET_INACTIVE_TIME
;
3474 strWID
.enuWIDtype
= WID_INT
;
3475 strWID
.ps8WidVal
= (s8
*)&gu32InactiveTime
;
3476 strWID
.s32ValueSize
= sizeof(u32
);
3479 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true,
3480 get_id_from_handler(pstrWFIDrv
));
3481 /*get the value by searching the local copy*/
3483 PRINT_ER("Failed to get incative time\n");
3484 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3488 PRINT_D(CFG80211_DBG
, "Getting inactive time : %d\n", gu32InactiveTime
);
3490 up(&(pstrWFIDrv
->hSemInactiveTime
));
3491 WILC_CATCH(s32Error
)
3505 * @brief Handle_AddBeacon
3506 * @details Sending config packet to add beacon
3507 * @param[in] tstrHostIFSetBeacon* pstrSetBeaconParam
3513 static void Handle_AddBeacon(tstrWILC_WFIDrv
*drvHandler
, tstrHostIFSetBeacon
*pstrSetBeaconParam
)
3515 s32 s32Error
= WILC_SUCCESS
;
3518 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3520 PRINT_D(HOSTINF_DBG
, "Adding BEACON\n");
3522 strWID
.u16WIDid
= (u16
)WID_ADD_BEACON
;
3523 strWID
.enuWIDtype
= WID_BIN
;
3524 strWID
.s32ValueSize
= pstrSetBeaconParam
->u32HeadLen
+ pstrSetBeaconParam
->u32TailLen
+ 16;
3525 strWID
.ps8WidVal
= kmalloc(strWID
.s32ValueSize
, GFP_KERNEL
);
3526 if (strWID
.ps8WidVal
== NULL
)
3527 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3529 pu8CurrByte
= strWID
.ps8WidVal
;
3530 *pu8CurrByte
++ = (pstrSetBeaconParam
->u32Interval
& 0xFF);
3531 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32Interval
>> 8) & 0xFF);
3532 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32Interval
>> 16) & 0xFF);
3533 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32Interval
>> 24) & 0xFF);
3535 *pu8CurrByte
++ = (pstrSetBeaconParam
->u32DTIMPeriod
& 0xFF);
3536 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32DTIMPeriod
>> 8) & 0xFF);
3537 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32DTIMPeriod
>> 16) & 0xFF);
3538 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32DTIMPeriod
>> 24) & 0xFF);
3540 *pu8CurrByte
++ = (pstrSetBeaconParam
->u32HeadLen
& 0xFF);
3541 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32HeadLen
>> 8) & 0xFF);
3542 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32HeadLen
>> 16) & 0xFF);
3543 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32HeadLen
>> 24) & 0xFF);
3545 memcpy(pu8CurrByte
, pstrSetBeaconParam
->pu8Head
, pstrSetBeaconParam
->u32HeadLen
);
3546 pu8CurrByte
+= pstrSetBeaconParam
->u32HeadLen
;
3548 *pu8CurrByte
++ = (pstrSetBeaconParam
->u32TailLen
& 0xFF);
3549 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32TailLen
>> 8) & 0xFF);
3550 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32TailLen
>> 16) & 0xFF);
3551 *pu8CurrByte
++ = ((pstrSetBeaconParam
->u32TailLen
>> 24) & 0xFF);
3553 /* Bug 4599 : if tail length = 0 skip copying */
3554 if (pstrSetBeaconParam
->pu8Tail
> 0)
3555 memcpy(pu8CurrByte
, pstrSetBeaconParam
->pu8Tail
, pstrSetBeaconParam
->u32TailLen
);
3556 pu8CurrByte
+= pstrSetBeaconParam
->u32TailLen
;
3561 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false,
3562 get_id_from_handler(pstrWFIDrv
));
3564 PRINT_ER("Failed to send add beacon config packet\n");
3565 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3568 WILC_CATCH(s32Error
)
3571 kfree(strWID
.ps8WidVal
);
3572 kfree(pstrSetBeaconParam
->pu8Head
);
3573 kfree(pstrSetBeaconParam
->pu8Tail
);
3578 * @brief Handle_AddBeacon
3579 * @details Sending config packet to delete beacon
3580 * @param[in] tstrHostIFDelBeacon* pstrDelBeacon
3586 static void Handle_DelBeacon(tstrWILC_WFIDrv
*drvHandler
, tstrHostIFDelBeacon
*pstrDelBeacon
)
3588 s32 s32Error
= WILC_SUCCESS
;
3591 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3593 strWID
.u16WIDid
= (u16
)WID_DEL_BEACON
;
3594 strWID
.enuWIDtype
= WID_CHAR
;
3595 strWID
.s32ValueSize
= sizeof(char);
3596 strWID
.ps8WidVal
= &gu8DelBcn
;
3598 if (strWID
.ps8WidVal
== NULL
)
3599 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3601 pu8CurrByte
= strWID
.ps8WidVal
;
3603 PRINT_D(HOSTINF_DBG
, "Deleting BEACON\n");
3604 /* TODO: build del beacon message*/
3607 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false,
3608 get_id_from_handler(pstrWFIDrv
));
3611 PRINT_ER("Failed to send delete beacon config packet\n");
3612 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3615 WILC_CATCH(s32Error
)
3622 * @brief WILC_HostIf_PackStaParam
3623 * @details Handling packing of the station params in a buffer
3624 * @param[in] u8* pu8Buffer, tstrWILC_AddStaParam* pstrStationParam
3630 static u32
WILC_HostIf_PackStaParam(u8
*pu8Buffer
, tstrWILC_AddStaParam
*pstrStationParam
)
3634 pu8CurrByte
= pu8Buffer
;
3636 PRINT_D(HOSTINF_DBG
, "Packing STA params\n");
3637 memcpy(pu8CurrByte
, pstrStationParam
->au8BSSID
, ETH_ALEN
);
3638 pu8CurrByte
+= ETH_ALEN
;
3640 *pu8CurrByte
++ = pstrStationParam
->u16AssocID
& 0xFF;
3641 *pu8CurrByte
++ = (pstrStationParam
->u16AssocID
>> 8) & 0xFF;
3643 *pu8CurrByte
++ = pstrStationParam
->u8NumRates
;
3644 if (pstrStationParam
->u8NumRates
> 0)
3645 memcpy(pu8CurrByte
, pstrStationParam
->pu8Rates
, pstrStationParam
->u8NumRates
);
3646 pu8CurrByte
+= pstrStationParam
->u8NumRates
;
3648 *pu8CurrByte
++ = pstrStationParam
->bIsHTSupported
;
3649 *pu8CurrByte
++ = pstrStationParam
->u16HTCapInfo
& 0xFF;
3650 *pu8CurrByte
++ = (pstrStationParam
->u16HTCapInfo
>> 8) & 0xFF;
3652 *pu8CurrByte
++ = pstrStationParam
->u8AmpduParams
;
3653 memcpy(pu8CurrByte
, pstrStationParam
->au8SuppMCsSet
, WILC_SUPP_MCS_SET_SIZE
);
3654 pu8CurrByte
+= WILC_SUPP_MCS_SET_SIZE
;
3656 *pu8CurrByte
++ = pstrStationParam
->u16HTExtParams
& 0xFF;
3657 *pu8CurrByte
++ = (pstrStationParam
->u16HTExtParams
>> 8) & 0xFF;
3659 *pu8CurrByte
++ = pstrStationParam
->u32TxBeamformingCap
& 0xFF;
3660 *pu8CurrByte
++ = (pstrStationParam
->u32TxBeamformingCap
>> 8) & 0xFF;
3661 *pu8CurrByte
++ = (pstrStationParam
->u32TxBeamformingCap
>> 16) & 0xFF;
3662 *pu8CurrByte
++ = (pstrStationParam
->u32TxBeamformingCap
>> 24) & 0xFF;
3664 *pu8CurrByte
++ = pstrStationParam
->u8ASELCap
;
3666 *pu8CurrByte
++ = pstrStationParam
->u16FlagsMask
& 0xFF;
3667 *pu8CurrByte
++ = (pstrStationParam
->u16FlagsMask
>> 8) & 0xFF;
3669 *pu8CurrByte
++ = pstrStationParam
->u16FlagsSet
& 0xFF;
3670 *pu8CurrByte
++ = (pstrStationParam
->u16FlagsSet
>> 8) & 0xFF;
3672 return pu8CurrByte
- pu8Buffer
;
3676 * @brief Handle_AddStation
3677 * @details Sending config packet to add station
3678 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3684 static void Handle_AddStation(tstrWILC_WFIDrv
*drvHandler
, tstrWILC_AddStaParam
*pstrStationParam
)
3686 s32 s32Error
= WILC_SUCCESS
;
3689 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3691 PRINT_D(HOSTINF_DBG
, "Handling add station\n");
3692 strWID
.u16WIDid
= (u16
)WID_ADD_STA
;
3693 strWID
.enuWIDtype
= WID_BIN
;
3694 strWID
.s32ValueSize
= WILC_ADD_STA_LENGTH
+ pstrStationParam
->u8NumRates
;
3696 strWID
.ps8WidVal
= kmalloc(strWID
.s32ValueSize
, GFP_KERNEL
);
3697 if (strWID
.ps8WidVal
== NULL
)
3698 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3700 pu8CurrByte
= strWID
.ps8WidVal
;
3701 pu8CurrByte
+= WILC_HostIf_PackStaParam(pu8CurrByte
, pstrStationParam
);
3704 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false,
3705 get_id_from_handler(pstrWFIDrv
));
3706 if (s32Error
!= WILC_SUCCESS
) {
3708 PRINT_ER("Failed to send add station config packet\n");
3709 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3712 WILC_CATCH(s32Error
)
3715 kfree(pstrStationParam
->pu8Rates
);
3716 kfree(strWID
.ps8WidVal
);
3720 * @brief Handle_DelAllSta
3721 * @details Sending config packet to delete station
3722 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3728 static void Handle_DelAllSta(tstrWILC_WFIDrv
*drvHandler
, tstrHostIFDelAllSta
*pstrDelAllStaParam
)
3730 s32 s32Error
= WILC_SUCCESS
;
3734 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3736 u8 au8Zero_Buff
[6] = {0};
3738 strWID
.u16WIDid
= (u16
)WID_DEL_ALL_STA
;
3739 strWID
.enuWIDtype
= WID_STR
;
3740 strWID
.s32ValueSize
= (pstrDelAllStaParam
->u8Num_AssocSta
* ETH_ALEN
) + 1;
3742 PRINT_D(HOSTINF_DBG
, "Handling delete station\n");
3744 strWID
.ps8WidVal
= kmalloc((pstrDelAllStaParam
->u8Num_AssocSta
* ETH_ALEN
) + 1, GFP_KERNEL
);
3745 if (strWID
.ps8WidVal
== NULL
)
3746 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3748 pu8CurrByte
= strWID
.ps8WidVal
;
3750 *(pu8CurrByte
++) = pstrDelAllStaParam
->u8Num_AssocSta
;
3752 for (i
= 0; i
< MAX_NUM_STA
; i
++) {
3753 if (memcmp(pstrDelAllStaParam
->au8Sta_DelAllSta
[i
], au8Zero_Buff
, ETH_ALEN
))
3754 memcpy(pu8CurrByte
, pstrDelAllStaParam
->au8Sta_DelAllSta
[i
], ETH_ALEN
);
3758 pu8CurrByte
+= ETH_ALEN
;
3762 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
3763 get_id_from_handler(pstrWFIDrv
));
3766 PRINT_ER("Failed to send add station config packet\n");
3767 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3770 WILC_CATCH(s32Error
)
3773 kfree(strWID
.ps8WidVal
);
3780 * @brief Handle_DelStation
3781 * @details Sending config packet to delete station
3782 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3788 static void Handle_DelStation(tstrWILC_WFIDrv
*drvHandler
, tstrHostIFDelSta
*pstrDelStaParam
)
3790 s32 s32Error
= WILC_SUCCESS
;
3793 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3795 strWID
.u16WIDid
= (u16
)WID_REMOVE_STA
;
3796 strWID
.enuWIDtype
= WID_BIN
;
3797 strWID
.s32ValueSize
= ETH_ALEN
;
3799 PRINT_D(HOSTINF_DBG
, "Handling delete station\n");
3801 strWID
.ps8WidVal
= kmalloc(strWID
.s32ValueSize
, GFP_KERNEL
);
3802 if (strWID
.ps8WidVal
== NULL
)
3803 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3805 pu8CurrByte
= strWID
.ps8WidVal
;
3807 memcpy(pu8CurrByte
, pstrDelStaParam
->au8MacAddr
, ETH_ALEN
);
3810 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false,
3811 get_id_from_handler(pstrWFIDrv
));
3814 PRINT_ER("Failed to send add station config packet\n");
3815 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3818 WILC_CATCH(s32Error
)
3821 kfree(strWID
.ps8WidVal
);
3826 * @brief Handle_EditStation
3827 * @details Sending config packet to edit station
3828 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3834 static void Handle_EditStation(tstrWILC_WFIDrv
*drvHandler
, tstrWILC_AddStaParam
*pstrStationParam
)
3836 s32 s32Error
= WILC_SUCCESS
;
3839 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3841 strWID
.u16WIDid
= (u16
)WID_EDIT_STA
;
3842 strWID
.enuWIDtype
= WID_BIN
;
3843 strWID
.s32ValueSize
= WILC_ADD_STA_LENGTH
+ pstrStationParam
->u8NumRates
;
3845 PRINT_D(HOSTINF_DBG
, "Handling edit station\n");
3846 strWID
.ps8WidVal
= kmalloc(strWID
.s32ValueSize
, GFP_KERNEL
);
3847 if (strWID
.ps8WidVal
== NULL
)
3848 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3850 pu8CurrByte
= strWID
.ps8WidVal
;
3851 pu8CurrByte
+= WILC_HostIf_PackStaParam(pu8CurrByte
, pstrStationParam
);
3854 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false,
3855 get_id_from_handler(pstrWFIDrv
));
3858 PRINT_ER("Failed to send edit station config packet\n");
3859 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
3862 WILC_CATCH(s32Error
)
3865 kfree(pstrStationParam
->pu8Rates
);
3866 kfree(strWID
.ps8WidVal
);
3868 #endif /*WILC_AP_EXTERNAL_MLME*/
3872 * @brief Handle_RemainOnChan
3873 * @details Sending config packet to edit station
3874 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3880 static int Handle_RemainOnChan(tstrWILC_WFIDrv
*drvHandler
, tstrHostIfRemainOnChan
*pstrHostIfRemainOnChan
)
3882 s32 s32Error
= WILC_SUCCESS
;
3883 u8 u8remain_on_chan_flag
;
3885 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*) drvHandler
;
3887 /*If it's a pendig remain-on-channel, don't overwrite gWFiDrvHandle values (since incoming msg is garbbage)*/
3888 if (!pstrWFIDrv
->u8RemainOnChan_pendingreq
) {
3889 pstrWFIDrv
->strHostIfRemainOnChan
.pVoid
= pstrHostIfRemainOnChan
->pVoid
;
3890 pstrWFIDrv
->strHostIfRemainOnChan
.pRemainOnChanExpired
= pstrHostIfRemainOnChan
->pRemainOnChanExpired
;
3891 pstrWFIDrv
->strHostIfRemainOnChan
.pRemainOnChanReady
= pstrHostIfRemainOnChan
->pRemainOnChanReady
;
3892 pstrWFIDrv
->strHostIfRemainOnChan
.u16Channel
= pstrHostIfRemainOnChan
->u16Channel
;
3893 pstrWFIDrv
->strHostIfRemainOnChan
.u32ListenSessionID
= pstrHostIfRemainOnChan
->u32ListenSessionID
;
3895 /*Set the channel to use it as a wid val*/
3896 pstrHostIfRemainOnChan
->u16Channel
= pstrWFIDrv
->strHostIfRemainOnChan
.u16Channel
;
3899 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
!= NULL
) {
3900 PRINT_INFO(GENERIC_DBG
, "Required to remain on chan while scanning return\n");
3901 pstrWFIDrv
->u8RemainOnChan_pendingreq
= 1;
3902 WILC_ERRORREPORT(s32Error
, WILC_BUSY
);
3904 if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_WAITING_CONN_RESP
) {
3905 PRINT_INFO(GENERIC_DBG
, "Required to remain on chan while connecting return\n");
3906 WILC_ERRORREPORT(s32Error
, WILC_BUSY
);
3909 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3910 if (g_obtainingIP
|| connecting
) {
3911 PRINT_D(GENERIC_DBG
, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
3912 WILC_ERRORREPORT(s32Error
, WILC_BUSY
);
3916 PRINT_D(HOSTINF_DBG
, "Setting channel :%d\n", pstrHostIfRemainOnChan
->u16Channel
);
3918 u8remain_on_chan_flag
= true;
3919 strWID
.u16WIDid
= (u16
)WID_REMAIN_ON_CHAN
;
3920 strWID
.enuWIDtype
= WID_STR
;
3921 strWID
.s32ValueSize
= 2;
3922 strWID
.ps8WidVal
= kmalloc(strWID
.s32ValueSize
, GFP_KERNEL
);
3924 if (strWID
.ps8WidVal
== NULL
)
3925 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3927 strWID
.ps8WidVal
[0] = u8remain_on_chan_flag
;
3928 strWID
.ps8WidVal
[1] = (s8
)pstrHostIfRemainOnChan
->u16Channel
;
3931 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
3932 get_id_from_handler(pstrWFIDrv
));
3933 if (s32Error
!= WILC_SUCCESS
)
3934 PRINT_ER("Failed to set remain on channel\n");
3938 P2P_LISTEN_STATE
= 1;
3939 pstrWFIDrv
->hRemainOnChannel
.data
= (unsigned long)pstrWFIDrv
;
3940 mod_timer(&pstrWFIDrv
->hRemainOnChannel
,
3942 msecs_to_jiffies(pstrHostIfRemainOnChan
->u32duration
));
3944 /*Calling CFG ready_on_channel*/
3945 if (pstrWFIDrv
->strHostIfRemainOnChan
.pRemainOnChanReady
)
3946 pstrWFIDrv
->strHostIfRemainOnChan
.pRemainOnChanReady(pstrWFIDrv
->strHostIfRemainOnChan
.pVoid
);
3948 if (pstrWFIDrv
->u8RemainOnChan_pendingreq
)
3949 pstrWFIDrv
->u8RemainOnChan_pendingreq
= 0;
3955 * @brief Handle_RegisterFrame
3963 static int Handle_RegisterFrame(tstrWILC_WFIDrv
*drvHandler
, tstrHostIfRegisterFrame
*pstrHostIfRegisterFrame
)
3965 s32 s32Error
= WILC_SUCCESS
;
3968 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
3970 PRINT_D(HOSTINF_DBG
, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame
->bReg
, pstrHostIfRegisterFrame
->u16FrameType
);
3972 /*prepare configuration packet*/
3973 strWID
.u16WIDid
= (u16
)WID_REGISTER_FRAME
;
3974 strWID
.enuWIDtype
= WID_STR
;
3975 strWID
.ps8WidVal
= kmalloc(sizeof(u16
) + 2, GFP_KERNEL
);
3976 if (strWID
.ps8WidVal
== NULL
)
3977 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
3979 pu8CurrByte
= strWID
.ps8WidVal
;
3981 *pu8CurrByte
++ = pstrHostIfRegisterFrame
->bReg
;
3982 *pu8CurrByte
++ = pstrHostIfRegisterFrame
->u8Regid
;
3983 memcpy(pu8CurrByte
, &(pstrHostIfRegisterFrame
->u16FrameType
), sizeof(u16
));
3986 strWID
.s32ValueSize
= sizeof(u16
) + 2;
3990 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
3991 get_id_from_handler(pstrWFIDrv
));
3993 PRINT_ER("Failed to frame register config packet\n");
3994 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
3998 WILC_CATCH(s32Error
)
4007 * @brief Handle_ListenStateExpired
4008 * @details Handle of listen state expiration
4010 * @return Error code.
4015 #define FALSE_FRMWR_CHANNEL 100
4016 static u32
Handle_ListenStateExpired(tstrWILC_WFIDrv
*drvHandler
, tstrHostIfRemainOnChan
*pstrHostIfRemainOnChan
)
4018 u8 u8remain_on_chan_flag
;
4020 s32 s32Error
= WILC_SUCCESS
;
4021 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*) drvHandler
;
4023 PRINT_D(HOSTINF_DBG
, "CANCEL REMAIN ON CHAN\n");
4026 /*Make sure we are already in listen state*/
4027 /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/
4028 if (P2P_LISTEN_STATE
) {
4029 u8remain_on_chan_flag
= false;
4030 strWID
.u16WIDid
= (u16
)WID_REMAIN_ON_CHAN
;
4031 strWID
.enuWIDtype
= WID_STR
;
4032 strWID
.s32ValueSize
= 2;
4033 strWID
.ps8WidVal
= kmalloc(strWID
.s32ValueSize
, GFP_KERNEL
);
4035 if (strWID
.ps8WidVal
== NULL
)
4036 PRINT_ER("Failed to allocate memory\n");
4038 strWID
.ps8WidVal
[0] = u8remain_on_chan_flag
;
4039 strWID
.ps8WidVal
[1] = FALSE_FRMWR_CHANNEL
;
4042 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
4043 get_id_from_handler(pstrWFIDrv
));
4044 if (s32Error
!= WILC_SUCCESS
) {
4045 PRINT_ER("Failed to set remain on channel\n");
4049 if (pstrWFIDrv
->strHostIfRemainOnChan
.pRemainOnChanExpired
) {
4050 pstrWFIDrv
->strHostIfRemainOnChan
.pRemainOnChanExpired(pstrWFIDrv
->strHostIfRemainOnChan
.pVoid
4051 , pstrHostIfRemainOnChan
->u32ListenSessionID
);
4053 P2P_LISTEN_STATE
= 0;
4055 PRINT_D(GENERIC_DBG
, "Not in listen state\n");
4056 s32Error
= WILC_FAIL
;
4065 * @brief ListenTimerCB
4066 * @details Callback function of remain-on-channel timer
4068 * @return Error code.
4073 static void ListenTimerCB(unsigned long arg
)
4075 s32 s32Error
= WILC_SUCCESS
;
4076 tstrHostIFmsg strHostIFmsg
;
4077 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)arg
;
4078 /*Stopping remain-on-channel timer*/
4079 del_timer(&pstrWFIDrv
->hRemainOnChannel
);
4081 /* prepare the Timer Callback message */
4082 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4083 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_LISTEN_TIMER_FIRED
;
4084 strHostIFmsg
.drvHandler
= pstrWFIDrv
;
4085 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.u32ListenSessionID
= pstrWFIDrv
->strHostIfRemainOnChan
.u32ListenSessionID
;
4087 /* send the message */
4088 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
4090 WILC_ERRORREPORT(s32Error
, s32Error
);
4091 WILC_CATCH(s32Error
)
4100 * @brief Handle_EditStation
4101 * @details Sending config packet to edit station
4102 * @param[in] tstrWILC_AddStaParam* pstrStationParam
4108 static void Handle_PowerManagement(tstrWILC_WFIDrv
*drvHandler
, tstrHostIfPowerMgmtParam
*strPowerMgmtParam
)
4110 s32 s32Error
= WILC_SUCCESS
;
4113 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
4115 strWID
.u16WIDid
= (u16
)WID_POWER_MANAGEMENT
;
4117 if (strPowerMgmtParam
->bIsEnabled
== true)
4118 s8PowerMode
= MIN_FAST_PS
;
4120 s8PowerMode
= NO_POWERSAVE
;
4121 PRINT_D(HOSTINF_DBG
, "Handling power mgmt to %d\n", s8PowerMode
);
4122 strWID
.ps8WidVal
= &s8PowerMode
;
4123 strWID
.s32ValueSize
= sizeof(char);
4125 PRINT_D(HOSTINF_DBG
, "Handling Power Management\n");
4128 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
4129 get_id_from_handler(pstrWFIDrv
));
4131 PRINT_ER("Failed to send power management config packet\n");
4132 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
4135 WILC_CATCH(s32Error
)
4142 * @brief Handle_SetMulticastFilter
4143 * @details Set Multicast filter in firmware
4144 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4150 static void Handle_SetMulticastFilter(tstrWILC_WFIDrv
*drvHandler
, tstrHostIFSetMulti
*strHostIfSetMulti
)
4152 s32 s32Error
= WILC_SUCCESS
;
4156 PRINT_D(HOSTINF_DBG
, "Setup Multicast Filter\n");
4158 strWID
.u16WIDid
= (u16
)WID_SETUP_MULTICAST_FILTER
;
4159 strWID
.enuWIDtype
= WID_BIN
;
4160 strWID
.s32ValueSize
= sizeof(tstrHostIFSetMulti
) + ((strHostIfSetMulti
->u32count
) * ETH_ALEN
);
4161 strWID
.ps8WidVal
= kmalloc(strWID
.s32ValueSize
, GFP_KERNEL
);
4162 if (strWID
.ps8WidVal
== NULL
)
4163 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
4165 pu8CurrByte
= strWID
.ps8WidVal
;
4166 *pu8CurrByte
++ = (strHostIfSetMulti
->bIsEnabled
& 0xFF);
4167 *pu8CurrByte
++ = ((strHostIfSetMulti
->bIsEnabled
>> 8) & 0xFF);
4168 *pu8CurrByte
++ = ((strHostIfSetMulti
->bIsEnabled
>> 16) & 0xFF);
4169 *pu8CurrByte
++ = ((strHostIfSetMulti
->bIsEnabled
>> 24) & 0xFF);
4171 *pu8CurrByte
++ = (strHostIfSetMulti
->u32count
& 0xFF);
4172 *pu8CurrByte
++ = ((strHostIfSetMulti
->u32count
>> 8) & 0xFF);
4173 *pu8CurrByte
++ = ((strHostIfSetMulti
->u32count
>> 16) & 0xFF);
4174 *pu8CurrByte
++ = ((strHostIfSetMulti
->u32count
>> 24) & 0xFF);
4176 if ((strHostIfSetMulti
->u32count
) > 0)
4177 memcpy(pu8CurrByte
, gau8MulticastMacAddrList
, ((strHostIfSetMulti
->u32count
) * ETH_ALEN
));
4180 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, false,
4181 get_id_from_handler(drvHandler
));
4183 PRINT_ER("Failed to send setup multicast config packet\n");
4184 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
4187 WILC_CATCH(s32Error
)
4190 kfree(strWID
.ps8WidVal
);
4197 * @brief Handle_AddBASession
4198 * @details Add block ack session
4199 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4201 * @author Amr Abdel-Moghny
4205 static s32
Handle_AddBASession(tstrWILC_WFIDrv
*drvHandler
, tstrHostIfBASessionInfo
*strHostIfBASessionInfo
)
4207 s32 s32Error
= WILC_SUCCESS
;
4209 int AddbaTimeout
= 100;
4211 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
4213 PRINT_D(HOSTINF_DBG
, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\nBufferSize == %d\nSessionTimeOut = %d\n",
4214 strHostIfBASessionInfo
->au8Bssid
[0],
4215 strHostIfBASessionInfo
->au8Bssid
[1],
4216 strHostIfBASessionInfo
->au8Bssid
[2],
4217 strHostIfBASessionInfo
->u16BufferSize
,
4218 strHostIfBASessionInfo
->u16SessionTimeout
,
4219 strHostIfBASessionInfo
->u8Ted
);
4221 strWID
.u16WIDid
= (u16
)WID_11E_P_ACTION_REQ
;
4222 strWID
.enuWIDtype
= WID_STR
;
4223 strWID
.ps8WidVal
= kmalloc(BLOCK_ACK_REQ_SIZE
, GFP_KERNEL
);
4224 strWID
.s32ValueSize
= BLOCK_ACK_REQ_SIZE
;
4225 ptr
= strWID
.ps8WidVal
;
4226 /* *ptr++ = 0x14; */
4230 memcpy(ptr
, strHostIfBASessionInfo
->au8Bssid
, ETH_ALEN
);
4232 *ptr
++ = strHostIfBASessionInfo
->u8Ted
;
4236 *ptr
++ = (strHostIfBASessionInfo
->u16BufferSize
& 0xFF);
4237 *ptr
++ = ((strHostIfBASessionInfo
->u16BufferSize
>> 16) & 0xFF);
4239 *ptr
++ = (strHostIfBASessionInfo
->u16SessionTimeout
& 0xFF);
4240 *ptr
++ = ((strHostIfBASessionInfo
->u16SessionTimeout
>> 16) & 0xFF);
4242 *ptr
++ = (AddbaTimeout
& 0xFF);
4243 *ptr
++ = ((AddbaTimeout
>> 16) & 0xFF);
4244 /* Group Buffer Max Frames*/
4246 /* Group Buffer Timeout */
4249 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
4250 get_id_from_handler(pstrWFIDrv
));
4252 PRINT_D(HOSTINF_DBG
, "Couldn't open BA Session\n");
4255 strWID
.u16WIDid
= (u16
)WID_11E_P_ACTION_REQ
;
4256 strWID
.enuWIDtype
= WID_STR
;
4257 strWID
.s32ValueSize
= 15;
4258 ptr
= strWID
.ps8WidVal
;
4259 /* *ptr++ = 0x14; */
4263 memcpy(ptr
, strHostIfBASessionInfo
->au8Bssid
, ETH_ALEN
);
4266 *ptr
++ = strHostIfBASessionInfo
->u8Ted
;
4270 *ptr
++ = (strHostIfBASessionInfo
->u16BufferSize
& 0xFF);
4271 *ptr
++ = ((strHostIfBASessionInfo
->u16SessionTimeout
>> 16) & 0xFF);
4274 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
4275 get_id_from_handler(pstrWFIDrv
));
4277 if (strWID
.ps8WidVal
!= NULL
)
4278 kfree(strWID
.ps8WidVal
);
4287 * @brief Handle_DelBASession
4288 * @details Delete block ack session
4289 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4291 * @author Amr Abdel-Moghny
4295 static s32
Handle_DelBASession(tstrWILC_WFIDrv
*drvHandler
, tstrHostIfBASessionInfo
*strHostIfBASessionInfo
)
4297 s32 s32Error
= WILC_SUCCESS
;
4300 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
4302 PRINT_D(GENERIC_DBG
, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
4303 strHostIfBASessionInfo
->au8Bssid
[0],
4304 strHostIfBASessionInfo
->au8Bssid
[1],
4305 strHostIfBASessionInfo
->au8Bssid
[2],
4306 strHostIfBASessionInfo
->u8Ted
);
4308 strWID
.u16WIDid
= (u16
)WID_11E_P_ACTION_REQ
;
4309 strWID
.enuWIDtype
= WID_STR
;
4310 strWID
.ps8WidVal
= kmalloc(BLOCK_ACK_REQ_SIZE
, GFP_KERNEL
);
4311 strWID
.s32ValueSize
= BLOCK_ACK_REQ_SIZE
;
4312 ptr
= strWID
.ps8WidVal
;
4313 /* *ptr++ = 0x14; */
4317 memcpy(ptr
, strHostIfBASessionInfo
->au8Bssid
, ETH_ALEN
);
4319 *ptr
++ = strHostIfBASessionInfo
->u8Ted
;
4320 /* BA direction = recipent*/
4323 *ptr
++ = 32; /* Unspecific QOS reason */
4325 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
4326 get_id_from_handler(pstrWFIDrv
));
4328 PRINT_D(HOSTINF_DBG
, "Couldn't delete BA Session\n");
4331 strWID
.u16WIDid
= (u16
)WID_11E_P_ACTION_REQ
;
4332 strWID
.enuWIDtype
= WID_STR
;
4333 strWID
.s32ValueSize
= 15;
4334 ptr
= strWID
.ps8WidVal
;
4335 /* *ptr++ = 0x14; */
4339 memcpy(ptr
, strHostIfBASessionInfo
->au8Bssid
, ETH_ALEN
);
4342 *ptr
++ = strHostIfBASessionInfo
->u8Ted
;
4344 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
4345 get_id_from_handler(pstrWFIDrv
));
4347 if (strWID
.ps8WidVal
!= NULL
)
4348 kfree(strWID
.ps8WidVal
);
4359 * @brief Handle_DelAllRxBASessions
4360 * @details Delete all Rx BA sessions
4361 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4363 * @author Abdelrahman Sobhy
4367 static s32
Handle_DelAllRxBASessions(tstrWILC_WFIDrv
*drvHandler
, tstrHostIfBASessionInfo
*strHostIfBASessionInfo
)
4369 s32 s32Error
= WILC_SUCCESS
;
4372 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)drvHandler
;
4374 PRINT_D(GENERIC_DBG
, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
4375 strHostIfBASessionInfo
->au8Bssid
[0],
4376 strHostIfBASessionInfo
->au8Bssid
[1],
4377 strHostIfBASessionInfo
->au8Bssid
[2],
4378 strHostIfBASessionInfo
->u8Ted
);
4380 strWID
.u16WIDid
= (u16
)WID_DEL_ALL_RX_BA
;
4381 strWID
.enuWIDtype
= WID_STR
;
4382 strWID
.ps8WidVal
= kmalloc(BLOCK_ACK_REQ_SIZE
, GFP_KERNEL
);
4383 strWID
.s32ValueSize
= BLOCK_ACK_REQ_SIZE
;
4384 ptr
= strWID
.ps8WidVal
;
4388 memcpy(ptr
, strHostIfBASessionInfo
->au8Bssid
, ETH_ALEN
);
4390 *ptr
++ = strHostIfBASessionInfo
->u8Ted
;
4391 /* BA direction = recipent*/
4394 *ptr
++ = 32; /* Unspecific QOS reason */
4396 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
4397 get_id_from_handler(pstrWFIDrv
));
4399 PRINT_D(HOSTINF_DBG
, "Couldn't delete BA Session\n");
4402 if (strWID
.ps8WidVal
!= NULL
)
4403 kfree(strWID
.ps8WidVal
);
4413 * @brief hostIFthread
4414 * @details Main thread to handle message queue requests
4415 * @param[in] void* pvArg
4421 static int hostIFthread(void *pvArg
)
4424 tstrHostIFmsg strHostIFmsg
;
4425 tstrWILC_WFIDrv
*pstrWFIDrv
;
4427 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4430 wilc_mq_recv(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
), &u32Ret
);
4431 pstrWFIDrv
= (tstrWILC_WFIDrv
*)strHostIFmsg
.drvHandler
;
4432 if (strHostIFmsg
.u16MsgId
== HOST_IF_MSG_EXIT
) {
4433 PRINT_D(GENERIC_DBG
, "THREAD: Exiting HostIfThread\n");
4438 /*Re-Queue HIF message*/
4439 if ((!g_wilc_initialized
)) {
4440 PRINT_D(GENERIC_DBG
, "--WAIT--");
4441 usleep_range(200 * 1000, 200 * 1000);
4442 wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
4446 if (strHostIFmsg
.u16MsgId
== HOST_IF_MSG_CONNECT
&& pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
!= NULL
) {
4447 PRINT_D(HOSTINF_DBG
, "Requeue connect request till scan done received\n");
4448 wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
4449 usleep_range(2 * 1000, 2 * 1000);
4453 switch (strHostIFmsg
.u16MsgId
) {
4454 case HOST_IF_MSG_Q_IDLE
:
4455 Handle_wait_msg_q_empty();
4458 case HOST_IF_MSG_SCAN
:
4459 Handle_Scan(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
);
4462 case HOST_IF_MSG_CONNECT
:
4463 Handle_Connect(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
);
4467 case HOST_IF_MSG_FLUSH_CONNECT
:
4468 Handle_FlushConnect(strHostIFmsg
.drvHandler
);
4471 case HOST_IF_MSG_RCVD_NTWRK_INFO
:
4472 Handle_RcvdNtwrkInfo(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strRcvdNetworkInfo
);
4475 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO
:
4476 Handle_RcvdGnrlAsyncInfo(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strRcvdGnrlAsyncInfo
);
4479 case HOST_IF_MSG_KEY
:
4480 Handle_Key(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
);
4483 case HOST_IF_MSG_CFG_PARAMS
:
4485 Handle_CfgParam(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIFCfgParamAttr
);
4488 case HOST_IF_MSG_SET_CHANNEL
:
4489 Handle_SetChannel(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIFSetChan
);
4492 case HOST_IF_MSG_DISCONNECT
:
4493 Handle_Disconnect(strHostIFmsg
.drvHandler
);
4496 case HOST_IF_MSG_RCVD_SCAN_COMPLETE
:
4497 del_timer(&pstrWFIDrv
->hScanTimer
);
4498 PRINT_D(HOSTINF_DBG
, "scan completed successfully\n");
4501 /*Allow chip sleep, only if both interfaces are not connected*/
4502 if (!linux_wlan_get_num_conn_ifcs())
4503 chip_sleep_manually(INFINITE_SLEEP_TIME
);
4505 Handle_ScanDone(strHostIFmsg
.drvHandler
, SCAN_EVENT_DONE
);
4508 if (pstrWFIDrv
->u8RemainOnChan_pendingreq
)
4509 Handle_RemainOnChan(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
);
4514 case HOST_IF_MSG_GET_RSSI
:
4515 Handle_GetRssi(strHostIFmsg
.drvHandler
);
4518 case HOST_IF_MSG_GET_LINKSPEED
:
4519 Handle_GetLinkspeed(strHostIFmsg
.drvHandler
);
4522 case HOST_IF_MSG_GET_STATISTICS
:
4523 Handle_GetStatistics(strHostIFmsg
.drvHandler
, (tstrStatistics
*)strHostIFmsg
.uniHostIFmsgBody
.pUserData
);
4526 case HOST_IF_MSG_GET_CHNL
:
4527 Handle_GetChnl(strHostIFmsg
.drvHandler
);
4530 #ifdef WILC_AP_EXTERNAL_MLME
4531 case HOST_IF_MSG_ADD_BEACON
:
4532 Handle_AddBeacon(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIFSetBeacon
);
4535 case HOST_IF_MSG_DEL_BEACON
:
4536 Handle_DelBeacon(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIFDelBeacon
);
4539 case HOST_IF_MSG_ADD_STATION
:
4540 Handle_AddStation(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strAddStaParam
);
4543 case HOST_IF_MSG_DEL_STATION
:
4544 Handle_DelStation(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strDelStaParam
);
4547 case HOST_IF_MSG_EDIT_STATION
:
4548 Handle_EditStation(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strEditStaParam
);
4551 case HOST_IF_MSG_GET_INACTIVETIME
:
4552 Handle_Get_InActiveTime(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfStaInactiveT
);
4555 #endif /*WILC_AP_EXTERNAL_MLME*/
4556 case HOST_IF_MSG_SCAN_TIMER_FIRED
:
4557 PRINT_D(HOSTINF_DBG
, "Scan Timeout\n");
4559 Handle_ScanDone(strHostIFmsg
.drvHandler
, SCAN_EVENT_ABORTED
);
4562 case HOST_IF_MSG_CONNECT_TIMER_FIRED
:
4563 PRINT_D(HOSTINF_DBG
, "Connect Timeout\n");
4564 Handle_ConnectTimeout(strHostIFmsg
.drvHandler
);
4567 case HOST_IF_MSG_POWER_MGMT
:
4568 Handle_PowerManagement(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strPowerMgmtparam
);
4571 case HOST_IF_MSG_SET_WFIDRV_HANDLER
:
4572 Handle_SetWfiDrvHandler(strHostIFmsg
.drvHandler
,
4573 &strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetDrvHandler
);
4576 case HOST_IF_MSG_SET_OPERATION_MODE
:
4577 Handle_SetOperationMode(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetOperationMode
);
4580 case HOST_IF_MSG_SET_IPADDRESS
:
4581 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_SET_IPADDRESS\n");
4582 Handle_set_IPAddress(strHostIFmsg
.drvHandler
, strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.au8IPAddr
, strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.idx
);
4585 case HOST_IF_MSG_GET_IPADDRESS
:
4586 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_SET_IPADDRESS\n");
4587 Handle_get_IPAddress(strHostIFmsg
.drvHandler
, strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.au8IPAddr
, strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.idx
);
4591 case HOST_IF_MSG_SET_MAC_ADDRESS
:
4592 Handle_SetMacAddress(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetMacAddress
);
4596 case HOST_IF_MSG_GET_MAC_ADDRESS
:
4597 Handle_GetMacAddress(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfGetMacAddress
);
4601 case HOST_IF_MSG_REMAIN_ON_CHAN
:
4602 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
4603 Handle_RemainOnChan(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
);
4606 case HOST_IF_MSG_REGISTER_FRAME
:
4607 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_REGISTER_FRAME\n");
4608 Handle_RegisterFrame(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfRegisterFrame
);
4611 case HOST_IF_MSG_LISTEN_TIMER_FIRED
:
4612 Handle_ListenStateExpired(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
);
4616 case HOST_IF_MSG_SET_MULTICAST_FILTER
:
4617 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
4618 Handle_SetMulticastFilter(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetMulti
);
4622 case HOST_IF_MSG_ADD_BA_SESSION
:
4623 Handle_AddBASession(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfBASessionInfo
);
4626 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS
:
4627 Handle_DelAllRxBASessions(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIfBASessionInfo
);
4630 case HOST_IF_MSG_DEL_ALL_STA
:
4631 Handle_DelAllSta(strHostIFmsg
.drvHandler
, &strHostIFmsg
.uniHostIFmsgBody
.strHostIFDelAllSta
);
4635 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
4640 PRINT_D(HOSTINF_DBG
, "Releasing thread exit semaphore\n");
4641 up(&hSemHostIFthrdEnd
);
4645 static void TimerCB_Scan(unsigned long arg
)
4647 void *pvArg
= (void *)arg
;
4648 tstrHostIFmsg strHostIFmsg
;
4650 /* prepare the Timer Callback message */
4651 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4652 strHostIFmsg
.drvHandler
= pvArg
;
4653 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SCAN_TIMER_FIRED
;
4655 /* send the message */
4656 wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
4659 static void TimerCB_Connect(unsigned long arg
)
4661 void *pvArg
= (void *)arg
;
4662 tstrHostIFmsg strHostIFmsg
;
4664 /* prepare the Timer Callback message */
4665 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4666 strHostIFmsg
.drvHandler
= pvArg
;
4667 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_CONNECT_TIMER_FIRED
;
4669 /* send the message */
4670 wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
4675 * @brief removes wpa/wpa2 keys
4676 * @details only in BSS STA mode if External Supplicant support is enabled.
4677 * removes all WPA/WPA2 station key entries from MAC hardware.
4678 * @param[in,out] handle to the wifi driver
4679 * @param[in] 6 bytes of Station Adress in the station entry table
4680 * @return Error code indicating success/failure
4683 * @date 8 March 2012
4686 /* Check implementation in core adding 9 bytes to the input! */
4687 s32
host_int_remove_key(tstrWILC_WFIDrv
*hWFIDrv
, const u8
*pu8StaAddress
)
4689 s32 s32Error
= WILC_SUCCESS
;
4691 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4693 strWID
.u16WIDid
= (u16
)WID_REMOVE_KEY
;
4694 strWID
.enuWIDtype
= WID_STR
;
4695 strWID
.ps8WidVal
= (s8
*)pu8StaAddress
;
4696 strWID
.s32ValueSize
= 6;
4703 * @brief removes WEP key
4704 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4705 * remove a WEP key entry from MAC HW.
4706 * The BSS Station automatically finds the index of the entry using its
4707 * BSS ID and removes that entry from the MAC hardware.
4708 * @param[in,out] handle to the wifi driver
4709 * @param[in] 6 bytes of Station Adress in the station entry table
4710 * @return Error code indicating success/failure
4711 * @note NO need for the STA add since it is not used for processing
4713 * @date 8 March 2012
4716 s32
host_int_remove_wep_key(tstrWILC_WFIDrv
*hWFIDrv
, u8 u8keyIdx
)
4718 s32 s32Error
= WILC_SUCCESS
;
4719 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
4720 tstrHostIFmsg strHostIFmsg
;
4723 if (pstrWFIDrv
== NULL
)
4724 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
4726 /* prepare the Remove Wep Key Message */
4727 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4730 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
4731 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= WEP
;
4732 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= REMOVEKEY
;
4733 strHostIFmsg
.drvHandler
= hWFIDrv
;
4737 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4738 uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
= u8keyIdx
;
4740 /* send the message */
4741 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
4743 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
4744 down(&(pstrWFIDrv
->hSemTestKeyBlock
));
4746 WILC_CATCH(s32Error
)
4754 * @brief sets WEP default key
4755 * @details Sets the index of the WEP encryption key in use,
4757 * @param[in,out] handle to the wifi driver
4758 * @param[in] key index ( 0, 1, 2, 3)
4759 * @return Error code indicating success/failure
4762 * @date 8 March 2012
4765 s32
host_int_set_WEPDefaultKeyID(tstrWILC_WFIDrv
*hWFIDrv
, u8 u8Index
)
4767 s32 s32Error
= WILC_SUCCESS
;
4768 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
4769 tstrHostIFmsg strHostIFmsg
;
4772 if (pstrWFIDrv
== NULL
)
4773 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
4775 /* prepare the Key Message */
4776 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4779 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
4780 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= WEP
;
4781 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= DEFAULTKEY
;
4782 strHostIFmsg
.drvHandler
= hWFIDrv
;
4785 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4786 uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
= u8Index
;
4788 /* send the message */
4789 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
4791 PRINT_ER("Error in sending message queue : Default key index\n");
4792 down(&(pstrWFIDrv
->hSemTestKeyBlock
));
4794 WILC_CATCH(s32Error
)
4803 * @brief sets WEP deafault key
4804 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4805 * sets WEP key entry into MAC hardware when it receives the
4806 * corresponding request from NDIS.
4807 * @param[in,out] handle to the wifi driver
4808 * @param[in] message containing WEP Key in the following format
4809 *|---------------------------------------|
4810 *|Key ID Value | Key Length | Key |
4811 *|-------------|------------|------------|
4812 | 1byte | 1byte | Key Length |
4813 ||---------------------------------------|
4815 * @return Error code indicating success/failure
4818 * @date 8 March 2012
4821 s32
host_int_add_wep_key_bss_sta(tstrWILC_WFIDrv
*hWFIDrv
, const u8
*pu8WepKey
, u8 u8WepKeylen
, u8 u8Keyidx
)
4824 s32 s32Error
= WILC_SUCCESS
;
4825 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
4826 tstrHostIFmsg strHostIFmsg
;
4828 if (pstrWFIDrv
== NULL
)
4829 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
4832 /* prepare the Key Message */
4833 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4836 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
4837 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= WEP
;
4838 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY
;
4839 strHostIFmsg
.drvHandler
= hWFIDrv
;
4842 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4843 uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
= kmalloc(u8WepKeylen
, GFP_KERNEL
);
4845 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
,
4846 pu8WepKey
, u8WepKeylen
);
4849 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4850 uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
= (u8WepKeylen
);
4852 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4853 uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
= u8Keyidx
;
4855 /* send the message */
4856 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
4858 PRINT_ER("Error in sending message queue :WEP Key\n");
4859 down(&(pstrWFIDrv
->hSemTestKeyBlock
));
4861 WILC_CATCH(s32Error
)
4869 #ifdef WILC_AP_EXTERNAL_MLME
4872 * @brief host_int_add_wep_key_bss_ap
4873 * @details valid only in BSS AP mode if External Supplicant support is enabled.
4874 * sets WEP key entry into MAC hardware when it receives the
4876 * corresponding request from NDIS.
4877 * @param[in,out] handle to the wifi driver
4880 * @return Error code indicating success/failure
4886 s32
host_int_add_wep_key_bss_ap(tstrWILC_WFIDrv
*hWFIDrv
, const u8
*pu8WepKey
, u8 u8WepKeylen
, u8 u8Keyidx
, u8 u8mode
, AUTHTYPE_T tenuAuth_type
)
4889 s32 s32Error
= WILC_SUCCESS
;
4890 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
4891 tstrHostIFmsg strHostIFmsg
;
4894 if (pstrWFIDrv
== NULL
)
4895 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
4898 /* prepare the Key Message */
4899 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4902 for (i
= 0; i
< u8WepKeylen
; i
++)
4903 PRINT_INFO(HOSTAPD_DBG
, "KEY is %x\n", pu8WepKey
[i
]);
4905 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
4906 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= WEP
;
4907 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY_AP
;
4908 strHostIFmsg
.drvHandler
= hWFIDrv
;
4911 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4912 uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
= kmalloc(u8WepKeylen
, GFP_KERNEL
);
4915 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwepAttr
.pu8WepKey
,
4916 pu8WepKey
, (u8WepKeylen
));
4919 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4920 uniHostIFkeyAttr
.strHostIFwepAttr
.u8WepKeylen
= (u8WepKeylen
);
4922 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4923 uniHostIFkeyAttr
.strHostIFwepAttr
.u8Wepidx
= u8Keyidx
;
4925 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4926 uniHostIFkeyAttr
.strHostIFwepAttr
.u8mode
= u8mode
;
4928 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4929 uniHostIFkeyAttr
.strHostIFwepAttr
.tenuAuth_type
= tenuAuth_type
;
4930 /* send the message */
4931 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
4934 PRINT_ER("Error in sending message queue :WEP Key\n");
4935 down(&(pstrWFIDrv
->hSemTestKeyBlock
));
4937 WILC_CATCH(s32Error
)
4946 * @brief adds ptk Key
4948 * @param[in,out] handle to the wifi driver
4949 * @param[in] message containing PTK Key in the following format
4950 *|-----------------------------------------------------------------------------|
4951 *|Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
4952 *|----------------|------------|--------------|----------------|---------------|
4953 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
4954 ||-----------------------------------------------------------------------------|
4955 * @return Error code indicating success/failure
4958 * @date 8 March 2012
4961 s32
host_int_add_ptk(tstrWILC_WFIDrv
*hWFIDrv
, const u8
*pu8Ptk
, u8 u8PtkKeylen
,
4962 const u8
*mac_addr
, const u8
*pu8RxMic
, const u8
*pu8TxMic
, u8 mode
, u8 u8Ciphermode
, u8 u8Idx
)
4964 s32 s32Error
= WILC_SUCCESS
;
4965 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
4966 tstrHostIFmsg strHostIFmsg
;
4967 u8 u8KeyLen
= u8PtkKeylen
;
4970 if (pstrWFIDrv
== NULL
)
4971 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
4972 if (pu8RxMic
!= NULL
)
4973 u8KeyLen
+= RX_MIC_KEY_LEN
;
4974 if (pu8TxMic
!= NULL
)
4975 u8KeyLen
+= TX_MIC_KEY_LEN
;
4977 /* prepare the Key Message */
4978 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
4981 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
4982 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= WPAPtk
;
4983 #ifdef WILC_AP_EXTERNAL_MLME
4984 if (mode
== AP_MODE
) {
4985 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY_AP
;
4986 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4987 uniHostIFkeyAttr
.strHostIFwpaAttr
.u8keyidx
= u8Idx
;
4990 if (mode
== STATION_MODE
)
4991 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY
;
4994 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
4995 uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
= kmalloc(u8PtkKeylen
, GFP_KERNEL
);
4998 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
,
4999 pu8Ptk
, u8PtkKeylen
);
5001 if (pu8RxMic
!= NULL
) {
5003 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
+ 16,
5004 pu8RxMic
, RX_MIC_KEY_LEN
);
5006 for (i
= 0; i
< RX_MIC_KEY_LEN
; i
++)
5007 PRINT_INFO(CFG80211_DBG
, "PairwiseRx[%d] = %x\n", i
, pu8RxMic
[i
]);
5010 if (pu8TxMic
!= NULL
) {
5012 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
+ 24,
5013 pu8TxMic
, TX_MIC_KEY_LEN
);
5015 for (i
= 0; i
< TX_MIC_KEY_LEN
; i
++)
5016 PRINT_INFO(CFG80211_DBG
, "PairwiseTx[%d] = %x\n", i
, pu8TxMic
[i
]);
5020 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
5021 uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
= u8KeyLen
;
5023 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
5024 uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Ciphermode
= u8Ciphermode
;
5025 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
5026 uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8macaddr
= mac_addr
;
5027 strHostIFmsg
.drvHandler
= hWFIDrv
;
5029 /* send the message */
5030 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5033 PRINT_ER("Error in sending message queue: PTK Key\n");
5035 /* ////////////// */
5036 down(&(pstrWFIDrv
->hSemTestKeyBlock
));
5039 WILC_CATCH(s32Error
)
5048 * @brief adds Rx GTk Key
5050 * @param[in,out] handle to the wifi driver
5051 * @param[in] pu8RxGtk : contains temporal key | Rx Mic | Tx Mic
5052 * u8GtkKeylen :The total key length
5054 * @return Error code indicating success/failure
5057 * @date 8 March 2012
5060 s32
host_int_add_rx_gtk(tstrWILC_WFIDrv
*hWFIDrv
, const u8
*pu8RxGtk
, u8 u8GtkKeylen
,
5061 u8 u8KeyIdx
, u32 u32KeyRSClen
, const u8
*KeyRSC
,
5062 const u8
*pu8RxMic
, const u8
*pu8TxMic
, u8 mode
, u8 u8Ciphermode
)
5064 s32 s32Error
= WILC_SUCCESS
;
5065 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5066 tstrHostIFmsg strHostIFmsg
;
5067 u8 u8KeyLen
= u8GtkKeylen
;
5069 if (pstrWFIDrv
== NULL
)
5070 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5071 /* prepare the Key Message */
5072 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5075 if (pu8RxMic
!= NULL
)
5076 u8KeyLen
+= RX_MIC_KEY_LEN
;
5077 if (pu8TxMic
!= NULL
)
5078 u8KeyLen
+= TX_MIC_KEY_LEN
;
5079 if (KeyRSC
!= NULL
) {
5080 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
5081 uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8seq
= kmalloc(u32KeyRSClen
, GFP_KERNEL
);
5083 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8seq
,
5084 KeyRSC
, u32KeyRSClen
);
5088 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
5089 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= WPARxGtk
;
5090 strHostIFmsg
.drvHandler
= hWFIDrv
;
5092 #ifdef WILC_AP_EXTERNAL_MLME
5093 if (mode
== AP_MODE
) {
5094 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY_AP
;
5095 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Ciphermode
= u8Ciphermode
;
5098 if (mode
== STATION_MODE
)
5099 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY
;
5102 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
5103 uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
= kmalloc(u8KeyLen
, GFP_KERNEL
);
5105 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
,
5106 pu8RxGtk
, u8GtkKeylen
);
5108 if (pu8RxMic
!= NULL
) {
5110 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
+ 16,
5111 pu8RxMic
, RX_MIC_KEY_LEN
);
5114 if (pu8TxMic
!= NULL
) {
5116 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFwpaAttr
.pu8key
+ 24,
5117 pu8TxMic
, TX_MIC_KEY_LEN
);
5121 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
5122 uniHostIFkeyAttr
.strHostIFwpaAttr
.u8keyidx
= u8KeyIdx
;
5123 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
5124 uniHostIFkeyAttr
.strHostIFwpaAttr
.u8Keylen
= u8KeyLen
;
5126 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.
5127 uniHostIFkeyAttr
.strHostIFwpaAttr
.u8seqlen
= u32KeyRSClen
;
5131 /* send the message */
5132 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5134 PRINT_ER("Error in sending message queue: RX GTK\n");
5135 /* ////////////// */
5136 down(&(pstrWFIDrv
->hSemTestKeyBlock
));
5139 WILC_CATCH(s32Error
)
5147 * @brief host_int_set_pmkid_info
5148 * @details caches the pmkid valid only in BSS STA mode if External Supplicant
5149 * support is enabled. This Function sets the PMKID in firmware
5150 * when host drivr receives the corresponding request from NDIS.
5151 * The firmware then includes theset PMKID in the appropriate
5153 * @param[in,out] handle to the wifi driver
5154 * @param[in] message containing PMKID Info in the following format
5155 *|-----------------------------------------------------------------|
5156 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
5157 *|-----------|------------|----------|-------|----------|----------|
5158 | 1 | 6 | 16 | ... | 6 | 16 |
5159 ||-----------------------------------------------------------------|
5160 * @return Error code indicating success/failure
5163 * @date 8 March 2012
5166 s32
host_int_set_pmkid_info(tstrWILC_WFIDrv
*hWFIDrv
, tstrHostIFpmkidAttr
*pu8PmkidInfoArray
)
5168 s32 s32Error
= WILC_SUCCESS
;
5169 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5170 tstrHostIFmsg strHostIFmsg
;
5174 if (pstrWFIDrv
== NULL
)
5175 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5177 /* prepare the Key Message */
5178 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5180 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_KEY
;
5181 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.enuKeyType
= PMKSA
;
5182 strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.u8KeyAction
= ADDKEY
;
5183 strHostIFmsg
.drvHandler
= hWFIDrv
;
5185 for (i
= 0; i
< pu8PmkidInfoArray
->numpmkid
; i
++) {
5187 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFpmkidAttr
.pmkidlist
[i
].bssid
, &pu8PmkidInfoArray
->pmkidlist
[i
].bssid
,
5190 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFkeyAttr
.uniHostIFkeyAttr
.strHostIFpmkidAttr
.pmkidlist
[i
].pmkid
, &pu8PmkidInfoArray
->pmkidlist
[i
].pmkid
,
5194 /* send the message */
5195 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5197 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
5199 WILC_CATCH(s32Error
)
5208 * @brief gets the cached the pmkid info
5209 * @details valid only in BSS STA mode if External Supplicant
5210 * support is enabled. This Function sets the PMKID in firmware
5211 * when host drivr receives the corresponding request from NDIS.
5212 * The firmware then includes theset PMKID in the appropriate
5214 * @param[in,out] handle to the wifi driver,
5215 * message containing PMKID Info in the following format
5216 *|-----------------------------------------------------------------|
5217 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
5218 *|-----------|------------|----------|-------|----------|----------|
5219 | 1 | 6 | 16 | ... | 6 | 16 |
5220 ||-----------------------------------------------------------------|
5222 * @return Error code indicating success/failure
5225 * @date 8 March 2012
5228 s32
host_int_get_pmkid_info(tstrWILC_WFIDrv
*hWFIDrv
, u8
*pu8PmkidInfoArray
,
5229 u32 u32PmkidInfoLen
)
5231 s32 s32Error
= WILC_SUCCESS
;
5233 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5235 strWID
.u16WIDid
= (u16
)WID_PMKID_INFO
;
5236 strWID
.enuWIDtype
= WID_STR
;
5237 strWID
.s32ValueSize
= u32PmkidInfoLen
;
5238 strWID
.ps8WidVal
= pu8PmkidInfoArray
;
5244 * @brief sets the pass phrase
5245 * @details AP/STA mode. This function gives the pass phrase used to
5246 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5247 * The length of the field can vary from 8 to 64 bytes,
5248 * the lower layer should get the
5249 * @param[in,out] handle to the wifi driver,
5250 * @param[in] String containing PSK
5251 * @return Error code indicating success/failure
5254 * @date 8 March 2012
5257 s32
host_int_set_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv
*hWFIDrv
, u8
*pu8PassPhrase
,
5260 s32 s32Error
= WILC_SUCCESS
;
5263 /*validating psk length*/
5264 if ((u8Psklength
> 7) && (u8Psklength
< 65)) {
5265 strWID
.u16WIDid
= (u16
)WID_11I_PSK
;
5266 strWID
.enuWIDtype
= WID_STR
;
5267 strWID
.ps8WidVal
= pu8PassPhrase
;
5268 strWID
.s32ValueSize
= u8Psklength
;
5274 * @brief host_int_get_MacAddress
5275 * @details gets mac address
5276 * @param[in,out] handle to the wifi driver,
5278 * @return Error code indicating success/failure
5281 * @date 19 April 2012
5284 s32
host_int_get_MacAddress(tstrWILC_WFIDrv
*hWFIDrv
, u8
*pu8MacAddress
)
5286 s32 s32Error
= WILC_SUCCESS
;
5287 tstrHostIFmsg strHostIFmsg
;
5290 /* prepare the Message */
5291 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5293 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_MAC_ADDRESS
;
5294 strHostIFmsg
.uniHostIFmsgBody
.strHostIfGetMacAddress
.u8MacAddress
= pu8MacAddress
;
5295 strHostIFmsg
.drvHandler
= hWFIDrv
;
5296 /* send the message */
5297 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5299 PRINT_ER("Failed to send get mac address\n");
5303 down(&hWaitResponse
);
5308 * @brief host_int_set_MacAddress
5309 * @details sets mac address
5310 * @param[in,out] handle to the wifi driver,
5312 * @return Error code indicating success/failure
5315 * @date 16 July 2012
5318 s32
host_int_set_MacAddress(tstrWILC_WFIDrv
*hWFIDrv
, u8
*pu8MacAddress
)
5320 s32 s32Error
= WILC_SUCCESS
;
5321 tstrHostIFmsg strHostIFmsg
;
5323 PRINT_D(GENERIC_DBG
, "mac addr = %x:%x:%x\n", pu8MacAddress
[0], pu8MacAddress
[1], pu8MacAddress
[2]);
5325 /* prepare setting mac address message */
5326 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5327 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SET_MAC_ADDRESS
;
5328 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetMacAddress
.u8MacAddress
, pu8MacAddress
, ETH_ALEN
);
5329 strHostIFmsg
.drvHandler
= hWFIDrv
;
5331 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5333 PRINT_ER("Failed to send message queue: Set mac address\n");
5334 WILC_ERRORREPORT(s32Error
, s32Error
);
5336 WILC_CATCH(s32Error
)
5346 * @brief host_int_get_RSNAConfigPSKPassPhrase
5347 * @details gets the pass phrase:AP/STA mode. This function gets the pass phrase used to
5348 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5349 * The length of the field can vary from 8 to 64 bytes,
5350 * the lower layer should get the
5351 * @param[in,out] handle to the wifi driver,
5352 * String containing PSK
5353 * @return Error code indicating success/failure
5356 * @date 8 March 2012
5359 s32
host_int_get_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv
*hWFIDrv
,
5360 u8
*pu8PassPhrase
, u8 u8Psklength
)
5362 s32 s32Error
= WILC_SUCCESS
;
5364 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5366 strWID
.u16WIDid
= (u16
)WID_11I_PSK
;
5367 strWID
.enuWIDtype
= WID_STR
;
5368 strWID
.s32ValueSize
= u8Psklength
;
5369 strWID
.ps8WidVal
= pu8PassPhrase
;
5375 * @brief host_int_get_site_survey_results
5376 * @details gets the site survey results
5377 * @param[in,out] handle to the wifi driver,
5378 * Message containing site survey results in the
5380 *|---------------------------------------------------|
5381 | MsgLength | fragNo. | MsgBodyLength | MsgBody |
5382 ||-----------|-----------|---------------|-----------|
5384 | ----------------------------------------- | ----------------
5386 ||---------------------------------------|
5387 | Network1 | Netweork2 | ... | Network5 |
5388 ||---------------------------------------|
5389 | 44 | 44 | ... | 44 |
5390 | -------------------------- | ---------------------------------------
5392 ||---------------------------------------------------------------------|
5393 | SSID | BSS Type | Channel | Security Status| BSSID | RSSI |Reserved |
5396 ||------|----------|---------|----------------|-------|------|---------|
5397 | 33 | 1 | 1 | 1 | 6 | 1 | 1 |
5398 ||---------------------------------------------------------------------|
5399 * @return Error code indicating success/failure
5402 * @date 8 March 2012
5405 #ifndef CONNECT_DIRECT
5406 s32
host_int_get_site_survey_results(tstrWILC_WFIDrv
*hWFIDrv
,
5407 u8 ppu8RcvdSiteSurveyResults
[][MAX_SURVEY_RESULT_FRAG_SIZE
],
5408 u32 u32MaxSiteSrvyFragLen
)
5410 s32 s32Error
= WILC_SUCCESS
;
5411 tstrWID astrWIDList
[2];
5412 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5414 astrWIDList
[0].u16WIDid
= (u16
)WID_SITE_SURVEY_RESULTS
;
5415 astrWIDList
[0].enuWIDtype
= WID_STR
;
5416 astrWIDList
[0].ps8WidVal
= ppu8RcvdSiteSurveyResults
[0];
5417 astrWIDList
[0].s32ValueSize
= u32MaxSiteSrvyFragLen
;
5419 astrWIDList
[1].u16WIDid
= (u16
)WID_SITE_SURVEY_RESULTS
;
5420 astrWIDList
[1].enuWIDtype
= WID_STR
;
5421 astrWIDList
[1].ps8WidVal
= ppu8RcvdSiteSurveyResults
[1];
5422 astrWIDList
[1].s32ValueSize
= u32MaxSiteSrvyFragLen
;
5424 s32Error
= SendConfigPkt(GET_CFG
, astrWIDList
, 2, true,
5425 get_id_from_handler(pstrWFIDrv
));
5427 /*get the value by searching the local copy*/
5429 PRINT_ER("Failed to send config packet to get survey results\n");
5430 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
5433 WILC_CATCH(s32Error
)
5443 * @brief sets a start scan request
5445 * @param[in,out] handle to the wifi driver,
5446 * @param[in] Scan Source one of the following values
5449 * OBSS_PERIODIC_SCAN BIT1
5450 * OBSS_ONETIME_SCAN BIT2
5451 * @return Error code indicating success/failure
5454 * @date 8 March 2012
5457 s32
host_int_set_start_scan_req(tstrWILC_WFIDrv
*hWFIDrv
, u8 scanSource
)
5459 s32 s32Error
= WILC_SUCCESS
;
5461 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5463 strWID
.u16WIDid
= (u16
)WID_START_SCAN_REQ
;
5464 strWID
.enuWIDtype
= WID_CHAR
;
5465 strWID
.ps8WidVal
= (s8
*)&scanSource
;
5466 strWID
.s32ValueSize
= sizeof(char);
5472 * @brief host_int_get_start_scan_req
5473 * @details gets a start scan request
5474 * @param[in,out] handle to the wifi driver,
5475 * @param[in] Scan Source one of the following values
5478 * OBSS_PERIODIC_SCAN BIT1
5479 * OBSS_ONETIME_SCAN BIT2
5480 * @return Error code indicating success/failure
5483 * @date 8 March 2012
5487 s32
host_int_get_start_scan_req(tstrWILC_WFIDrv
*hWFIDrv
, u8
*pu8ScanSource
)
5489 s32 s32Error
= WILC_SUCCESS
;
5491 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5493 strWID
.u16WIDid
= (u16
)WID_START_SCAN_REQ
;
5494 strWID
.enuWIDtype
= WID_CHAR
;
5495 strWID
.ps8WidVal
= (s8
*)pu8ScanSource
;
5496 strWID
.s32ValueSize
= sizeof(char);
5502 * @brief host_int_set_join_req
5503 * @details sets a join request
5504 * @param[in,out] handle to the wifi driver,
5505 * @param[in] Index of the bss descriptor
5506 * @return Error code indicating success/failure
5509 * @date 8 March 2012
5512 s32
host_int_set_join_req(tstrWILC_WFIDrv
*hWFIDrv
, u8
*pu8bssid
,
5513 const u8
*pu8ssid
, size_t ssidLen
,
5514 const u8
*pu8IEs
, size_t IEsLen
,
5515 tWILCpfConnectResult pfConnectResult
, void *pvUserArg
,
5516 u8 u8security
, AUTHTYPE_T tenuAuth_type
,
5520 s32 s32Error
= WILC_SUCCESS
;
5521 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5522 tstrHostIFmsg strHostIFmsg
;
5523 tenuScanConnTimer enuScanConnTimer
;
5525 if (pstrWFIDrv
== NULL
|| pfConnectResult
== NULL
)
5526 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5528 if (hWFIDrv
== NULL
) {
5529 PRINT_ER("Driver not initialized: gWFiDrvHandle = NULL\n");
5530 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
5533 if (pJoinParams
== NULL
) {
5534 PRINT_ER("Unable to Join - JoinParams is NULL\n");
5535 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
5539 * if(gWFiDrvHandle->strWILC_UsrScanReq.u32RcvdChCount == 0)
5541 * PRINT_ER("No scan results exist: Scanning should be done\n");
5542 * WILC_ERRORREPORT(s32Error, WILC_FAIL);
5545 /* prepare the Connect Message */
5546 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5548 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_CONNECT
;
5550 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.u8security
= u8security
;
5551 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.tenuAuth_type
= tenuAuth_type
;
5552 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.u8channel
= u8channel
;
5553 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pfConnectResult
= pfConnectResult
;
5554 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pvUserArg
= pvUserArg
;
5555 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pJoinParams
= pJoinParams
;
5556 strHostIFmsg
.drvHandler
= hWFIDrv
;
5558 if (pu8bssid
!= NULL
) {
5559 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pu8bssid
= kmalloc(6, GFP_KERNEL
); /* will be deallocated by the receiving thread */
5560 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pu8bssid
,
5564 if (pu8ssid
!= NULL
) {
5565 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.ssidLen
= ssidLen
;
5566 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pu8ssid
= kmalloc(ssidLen
, GFP_KERNEL
); /* will be deallocated by the receiving thread */
5567 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pu8ssid
,
5572 if (pu8IEs
!= NULL
) {
5573 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.IEsLen
= IEsLen
;
5574 strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pu8IEs
= kmalloc(IEsLen
, GFP_KERNEL
); /* will be deallocated by the receiving thread */
5575 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFconnectAttr
.pu8IEs
,
5578 if (pstrWFIDrv
->enuHostIFstate
< HOST_IF_CONNECTING
)
5579 pstrWFIDrv
->enuHostIFstate
= HOST_IF_CONNECTING
;
5581 PRINT_D(GENERIC_DBG
, "Don't set state to 'connecting' as state is %d\n", pstrWFIDrv
->enuHostIFstate
);
5583 /* send the message */
5584 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5586 PRINT_ER("Failed to send message queue: Set join request\n");
5587 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
5590 enuScanConnTimer
= CONNECT_TIMER
;
5591 pstrWFIDrv
->hConnectTimer
.data
= (unsigned long)hWFIDrv
;
5592 mod_timer(&pstrWFIDrv
->hConnectTimer
,
5593 jiffies
+ msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT
));
5595 WILC_CATCH(s32Error
)
5604 * @brief Flush a join request parameters to FW, but actual connection
5605 * @details The function is called in situation where WILC is connected to AP and
5606 * required to switch to hybrid FW for P2P connection
5607 * @param[in] handle to the wifi driver,
5608 * @return Error code indicating success/failure
5610 * @author Amr Abdel-Moghny
5615 s32
host_int_flush_join_req(tstrWILC_WFIDrv
*hWFIDrv
)
5617 s32 s32Error
= WILC_SUCCESS
;
5618 tstrHostIFmsg strHostIFmsg
;
5620 if (!gu8FlushedJoinReq
) {
5621 s32Error
= WILC_FAIL
;
5626 if (hWFIDrv
== NULL
)
5627 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5630 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_FLUSH_CONNECT
;
5631 strHostIFmsg
.drvHandler
= hWFIDrv
;
5633 /* send the message */
5634 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5636 PRINT_ER("Failed to send message queue: Flush join request\n");
5637 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
5640 WILC_CATCH(s32Error
)
5648 * @brief host_int_disconnect
5649 * @details disconnects from the currently associated network
5650 * @param[in,out] handle to the wifi driver,
5651 * @param[in] Reason Code of the Disconnection
5652 * @return Error code indicating success/failure
5655 * @date 8 March 2012
5658 s32
host_int_disconnect(tstrWILC_WFIDrv
*hWFIDrv
, u16 u16ReasonCode
)
5660 s32 s32Error
= WILC_SUCCESS
;
5661 tstrHostIFmsg strHostIFmsg
;
5662 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5664 if (pstrWFIDrv
== NULL
) {
5665 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
5666 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5669 if (pstrWFIDrv
== NULL
) {
5670 PRINT_ER("gWFiDrvHandle = NULL\n");
5671 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
5674 /* prepare the Disconnect Message */
5675 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5677 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_DISCONNECT
;
5678 strHostIFmsg
.drvHandler
= hWFIDrv
;
5680 /* send the message */
5681 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5683 PRINT_ER("Failed to send message queue: disconnect\n");
5684 /* ////////////// */
5685 down(&(pstrWFIDrv
->hSemTestDisconnectBlock
));
5688 WILC_CATCH(s32Error
)
5697 * @brief host_int_disconnect_station
5698 * @details disconnects a sta
5699 * @param[in,out] handle to the wifi driver,
5700 * @param[in] Association Id of the station to be disconnected
5701 * @return Error code indicating success/failure
5704 * @date 8 March 2012
5707 s32
host_int_disconnect_station(tstrWILC_WFIDrv
*hWFIDrv
, u8 assoc_id
)
5709 s32 s32Error
= WILC_SUCCESS
;
5711 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5713 strWID
.u16WIDid
= (u16
)WID_DISCONNECT
;
5714 strWID
.enuWIDtype
= WID_CHAR
;
5715 strWID
.ps8WidVal
= (s8
*)&assoc_id
;
5716 strWID
.s32ValueSize
= sizeof(char);
5722 * @brief host_int_get_assoc_req_info
5723 * @details gets a Association request info
5724 * @param[in,out] handle to the wifi driver,
5725 * Message containg assoc. req info in the following format
5726 * ------------------------------------------------------------------------
5727 | Management Frame Format |
5728 ||-------------------------------------------------------------------|
5729 ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS |
5730 ||-------------|--------|--|--|-----|----------------|----------|----|
5731 | 2 |2 |6 |6 |6 | 2 |0 - 2312 | 4 |
5732 ||-------------------------------------------------------------------|
5734 | Association Request Frame - Frame Body |
5735 ||-------------------------------------------------------------------|
5736 | Capability Information | Listen Interval | SSID | Supported Rates |
5737 ||------------------------|-----------------|------|-----------------|
5738 | 2 | 2 | 2-34 | 3-10 |
5739 | ---------------------------------------------------------------------
5740 * @return Error code indicating success/failure
5743 * @date 8 March 2012
5747 s32
host_int_get_assoc_req_info(tstrWILC_WFIDrv
*hWFIDrv
, u8
*pu8AssocReqInfo
,
5748 u32 u32AssocReqInfoLen
)
5750 s32 s32Error
= WILC_SUCCESS
;
5752 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5754 strWID
.u16WIDid
= (u16
)WID_ASSOC_REQ_INFO
;
5755 strWID
.enuWIDtype
= WID_STR
;
5756 strWID
.ps8WidVal
= pu8AssocReqInfo
;
5757 strWID
.s32ValueSize
= u32AssocReqInfoLen
;
5764 * @brief gets a Association Response info
5766 * @param[in,out] handle to the wifi driver,
5767 * Message containg assoc. resp info
5768 * @return Error code indicating success/failure
5771 * @date 8 March 2012
5774 s32
host_int_get_assoc_res_info(tstrWILC_WFIDrv
*hWFIDrv
, u8
*pu8AssocRespInfo
,
5775 u32 u32MaxAssocRespInfoLen
, u32
*pu32RcvdAssocRespInfoLen
)
5777 s32 s32Error
= WILC_SUCCESS
;
5779 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5781 if (pstrWFIDrv
== NULL
) {
5782 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
5783 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5786 strWID
.u16WIDid
= (u16
)WID_ASSOC_RES_INFO
;
5787 strWID
.enuWIDtype
= WID_STR
;
5788 strWID
.ps8WidVal
= pu8AssocRespInfo
;
5789 strWID
.s32ValueSize
= u32MaxAssocRespInfoLen
;
5792 /* Sending Configuration packet */
5793 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true,
5794 get_id_from_handler(pstrWFIDrv
));
5796 PRINT_ER("Failed to send association response config packet\n");
5797 *pu32RcvdAssocRespInfoLen
= 0;
5798 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
5800 *pu32RcvdAssocRespInfoLen
= strWID
.s32ValueSize
;
5803 WILC_CATCH(s32Error
)
5811 * @brief gets a Association Response info
5812 * @details Valid only in STA mode. This function gives the RSSI
5813 * values observed in all the channels at the time of scanning.
5814 * The length of the field is 1 greater that the total number of
5815 * channels supported. Byte 0 contains the number of channels while
5816 * each of Byte N contains the observed RSSI value for the channel index N.
5817 * @param[in,out] handle to the wifi driver,
5818 * array of scanned channels' RSSI
5819 * @return Error code indicating success/failure
5822 * @date 8 March 2012
5825 s32
host_int_get_rx_power_level(tstrWILC_WFIDrv
*hWFIDrv
, u8
*pu8RxPowerLevel
,
5826 u32 u32RxPowerLevelLen
)
5828 s32 s32Error
= WILC_SUCCESS
;
5830 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5832 strWID
.u16WIDid
= (u16
)WID_RX_POWER_LEVEL
;
5833 strWID
.enuWIDtype
= WID_STR
;
5834 strWID
.ps8WidVal
= pu8RxPowerLevel
;
5835 strWID
.s32ValueSize
= u32RxPowerLevelLen
;
5842 * @brief sets a channel
5844 * @param[in,out] handle to the wifi driver,
5845 * @param[in] Index of the channel to be set
5846 *|-------------------------------------------------------------------|
5847 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5849 ||-------------------------------------------------------------------|
5850 * @return Error code indicating success/failure
5853 * @date 8 March 2012
5856 s32
host_int_set_mac_chnl_num(tstrWILC_WFIDrv
*hWFIDrv
, u8 u8ChNum
)
5858 s32 s32Error
= WILC_SUCCESS
;
5859 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5860 tstrHostIFmsg strHostIFmsg
;
5862 if (pstrWFIDrv
== NULL
)
5863 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5865 /* prepare the set channel message */
5866 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5867 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SET_CHANNEL
;
5868 strHostIFmsg
.uniHostIFmsgBody
.strHostIFSetChan
.u8SetChan
= u8ChNum
;
5869 strHostIFmsg
.drvHandler
= hWFIDrv
;
5871 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5873 WILC_ERRORREPORT(s32Error
, s32Error
);
5874 WILC_CATCH(s32Error
)
5883 s32
host_int_wait_msg_queue_idle(void)
5885 s32 s32Error
= WILC_SUCCESS
;
5887 tstrHostIFmsg strHostIFmsg
;
5889 /* prepare the set driver handler message */
5891 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5892 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_Q_IDLE
;
5893 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5895 WILC_ERRORREPORT(s32Error
, s32Error
);
5896 WILC_CATCH(s32Error
)
5901 /* wait untill MSG Q is empty */
5902 down(&hWaitResponse
);
5908 s32
host_int_set_wfi_drv_handler(tstrWILC_WFIDrv
*u32address
)
5910 s32 s32Error
= WILC_SUCCESS
;
5912 tstrHostIFmsg strHostIFmsg
;
5915 /* prepare the set driver handler message */
5917 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5918 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SET_WFIDRV_HANDLER
;
5919 strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetDrvHandler
.u32Address
= get_id_from_handler(u32address
);
5920 strHostIFmsg
.drvHandler
= u32address
;
5922 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5924 WILC_ERRORREPORT(s32Error
, s32Error
);
5925 WILC_CATCH(s32Error
)
5935 s32
host_int_set_operation_mode(tstrWILC_WFIDrv
*hWFIDrv
, u32 u32mode
)
5937 s32 s32Error
= WILC_SUCCESS
;
5939 tstrHostIFmsg strHostIFmsg
;
5942 /* prepare the set driver handler message */
5944 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5945 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SET_OPERATION_MODE
;
5946 strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetOperationMode
.u32Mode
= u32mode
;
5947 strHostIFmsg
.drvHandler
= hWFIDrv
;
5949 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5951 WILC_ERRORREPORT(s32Error
, s32Error
);
5952 WILC_CATCH(s32Error
)
5961 * @brief gets the current channel index
5963 * @param[in,out] handle to the wifi driver,
5964 * current channel index
5965 *|-----------------------------------------------------------------------|
5966 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5968 ||-----------------------------------------------------------------------|
5969 * @return Error code indicating success/failure
5972 * @date 8 March 2012
5975 s32
host_int_get_host_chnl_num(tstrWILC_WFIDrv
*hWFIDrv
, u8
*pu8ChNo
)
5977 s32 s32Error
= WILC_SUCCESS
;
5978 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
5979 tstrHostIFmsg strHostIFmsg
;
5981 if (pstrWFIDrv
== NULL
) {
5982 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
5983 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
5986 /* prepare the Get Channel Message */
5987 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
5989 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_CHNL
;
5990 strHostIFmsg
.drvHandler
= hWFIDrv
;
5992 /* send the message */
5993 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
5995 PRINT_ER("Failed to send get host channel param's message queue ");
5996 down(&(pstrWFIDrv
->hSemGetCHNL
));
6001 WILC_CATCH(s32Error
)
6012 * @brief host_int_test_set_int_wid
6013 * @details Test function for setting wids
6014 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr
6015 * @return Error code indicating success/failure
6018 * @date 8 March 2012
6021 s32
host_int_test_set_int_wid(tstrWILC_WFIDrv
*hWFIDrv
, u32 u32TestMemAddr
)
6023 s32 s32Error
= WILC_SUCCESS
;
6025 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6028 if (pstrWFIDrv
== NULL
) {
6029 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
6030 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
6033 /*prepare configuration packet*/
6034 strWID
.u16WIDid
= (u16
)WID_MEMORY_ADDRESS
;
6035 strWID
.enuWIDtype
= WID_INT
;
6036 strWID
.ps8WidVal
= (char *)&u32TestMemAddr
;
6037 strWID
.s32ValueSize
= sizeof(u32
);
6040 s32Error
= SendConfigPkt(SET_CFG
, &strWID
, 1, true,
6041 get_id_from_handler(pstrWFIDrv
));
6043 PRINT_ER("Test Function: Failed to set wid value\n");
6044 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
6046 PRINT_D(HOSTINF_DBG
, "Successfully set wid value\n");
6050 WILC_CATCH(s32Error
)
6057 #ifdef WILC_AP_EXTERNAL_MLME
6059 * @brief host_int_get_inactive_time
6061 * @param[in,out] handle to the wifi driver,
6062 * current sta macaddress, inactive_time
6069 s32
host_int_get_inactive_time(tstrWILC_WFIDrv
*hWFIDrv
, const u8
*mac
, u32
*pu32InactiveTime
)
6071 s32 s32Error
= WILC_SUCCESS
;
6072 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6073 tstrHostIFmsg strHostIFmsg
;
6075 if (pstrWFIDrv
== NULL
) {
6076 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
6077 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
6080 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6083 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIfStaInactiveT
.mac
,
6086 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_INACTIVETIME
;
6087 strHostIFmsg
.drvHandler
= hWFIDrv
;
6089 /* send the message */
6090 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
6092 PRINT_ER("Failed to send get host channel param's message queue ");
6094 down(&(pstrWFIDrv
->hSemInactiveTime
));
6096 *pu32InactiveTime
= gu32InactiveTime
;
6098 WILC_CATCH(s32Error
)
6106 * @brief host_int_test_get_int_wid
6107 * @details Test function for getting wids
6108 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32* pu32TestMemAddr
6109 * @return Error code indicating success/failure
6112 * @date 8 March 2012
6115 s32
host_int_test_get_int_wid(tstrWILC_WFIDrv
*hWFIDrv
, u32
*pu32TestMemAddr
)
6118 s32 s32Error
= WILC_SUCCESS
;
6120 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6123 if (pstrWFIDrv
== NULL
) {
6124 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
6125 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
6128 strWID
.u16WIDid
= (u16
)WID_MEMORY_ADDRESS
;
6129 strWID
.enuWIDtype
= WID_INT
;
6130 strWID
.ps8WidVal
= (s8
*)pu32TestMemAddr
;
6131 strWID
.s32ValueSize
= sizeof(u32
);
6133 s32Error
= SendConfigPkt(GET_CFG
, &strWID
, 1, true,
6134 get_id_from_handler(pstrWFIDrv
));
6135 /*get the value by searching the local copy*/
6137 PRINT_ER("Test Function: Failed to get wid value\n");
6138 WILC_ERRORREPORT(s32Error
, WILC_INVALID_STATE
);
6140 PRINT_D(HOSTINF_DBG
, "Successfully got wid value\n");
6144 WILC_CATCH(s32Error
)
6153 * @brief host_int_get_rssi
6154 * @details gets the currently maintained RSSI value for the station.
6155 * The received signal strength value in dB.
6156 * The range of valid values is -128 to 0.
6157 * @param[in,out] handle to the wifi driver,
6159 * @return Error code indicating success/failure
6162 * @date 8 March 2012
6165 s32
host_int_get_rssi(tstrWILC_WFIDrv
*hWFIDrv
, s8
*ps8Rssi
)
6167 s32 s32Error
= WILC_SUCCESS
;
6168 tstrHostIFmsg strHostIFmsg
;
6169 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6172 /* prepare the Get RSSI Message */
6173 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6175 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_RSSI
;
6176 strHostIFmsg
.drvHandler
= hWFIDrv
;
6178 /* send the message */
6179 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
6181 PRINT_ER("Failed to send get host channel param's message queue ");
6185 down(&(pstrWFIDrv
->hSemGetRSSI
));
6188 if (ps8Rssi
== NULL
) {
6189 PRINT_ER("RSS pointer value is null");
6200 s32
host_int_get_link_speed(tstrWILC_WFIDrv
*hWFIDrv
, s8
*ps8lnkspd
)
6202 tstrHostIFmsg strHostIFmsg
;
6203 s32 s32Error
= WILC_SUCCESS
;
6205 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6209 /* prepare the Get LINKSPEED Message */
6210 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6212 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_LINKSPEED
;
6213 strHostIFmsg
.drvHandler
= hWFIDrv
;
6215 /* send the message */
6216 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
6218 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
6222 down(&(pstrWFIDrv
->hSemGetLINKSPEED
));
6225 if (ps8lnkspd
== NULL
) {
6226 PRINT_ER("LINKSPEED pointer value is null");
6231 *ps8lnkspd
= gs8lnkspd
;
6237 s32
host_int_get_statistics(tstrWILC_WFIDrv
*hWFIDrv
, tstrStatistics
*pstrStatistics
)
6239 s32 s32Error
= WILC_SUCCESS
;
6240 tstrHostIFmsg strHostIFmsg
;
6243 /* prepare the Get RSSI Message */
6244 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6246 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_STATISTICS
;
6247 strHostIFmsg
.uniHostIFmsgBody
.pUserData
= (char *)pstrStatistics
;
6248 strHostIFmsg
.drvHandler
= hWFIDrv
;
6249 /* send the message */
6250 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
6252 PRINT_ER("Failed to send get host channel param's message queue ");
6256 down(&hWaitResponse
);
6262 * @brief host_int_scan
6263 * @details scans a set of channels
6264 * @param[in,out] handle to the wifi driver,
6265 * @param[in] Scan source
6266 * Scan Type PASSIVE_SCAN = 0,
6269 * Channels Array length
6270 * Scan Callback function
6271 * @return Error code indicating success/failure
6274 * @date 8 March 2012
6277 s32
host_int_scan(tstrWILC_WFIDrv
*hWFIDrv
, u8 u8ScanSource
,
6278 u8 u8ScanType
, u8
*pu8ChnlFreqList
,
6279 u8 u8ChnlListLen
, const u8
*pu8IEs
,
6280 size_t IEsLen
, tWILCpfScanResult ScanResult
,
6281 void *pvUserArg
, tstrHiddenNetwork
*pstrHiddenNetwork
)
6283 s32 s32Error
= WILC_SUCCESS
;
6284 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6285 tstrHostIFmsg strHostIFmsg
;
6286 tenuScanConnTimer enuScanConnTimer
;
6288 if (pstrWFIDrv
== NULL
|| ScanResult
== NULL
)
6289 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
6292 /* prepare the Scan Message */
6293 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6295 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SCAN
;
6297 if (pstrHiddenNetwork
!= NULL
) {
6298 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.strHiddenNetwork
.pstrHiddenNetworkInfo
= pstrHiddenNetwork
->pstrHiddenNetworkInfo
;
6299 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.strHiddenNetwork
.u8ssidnum
= pstrHiddenNetwork
->u8ssidnum
;
6302 PRINT_D(HOSTINF_DBG
, "pstrHiddenNetwork IS EQUAL TO NULL\n");
6304 strHostIFmsg
.drvHandler
= hWFIDrv
;
6305 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.u8ScanSource
= u8ScanSource
;
6306 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.u8ScanType
= u8ScanType
;
6307 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.pfScanResult
= ScanResult
;
6308 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.pvUserArg
= pvUserArg
;
6310 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.u8ChnlListLen
= u8ChnlListLen
;
6311 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.pu8ChnlFreqList
= kmalloc(u8ChnlListLen
, GFP_KERNEL
); /* will be deallocated by the receiving thread */
6312 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.pu8ChnlFreqList
,
6313 pu8ChnlFreqList
, u8ChnlListLen
);
6315 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.IEsLen
= IEsLen
;
6316 strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.pu8IEs
= kmalloc(IEsLen
, GFP_KERNEL
); /* will be deallocated by the receiving thread */
6317 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strHostIFscanAttr
.pu8IEs
,
6320 /* send the message */
6321 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
6323 PRINT_ER("Error in sending message queue scanning parameters: Error(%d)\n", s32Error
);
6324 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
6327 enuScanConnTimer
= SCAN_TIMER
;
6328 PRINT_D(HOSTINF_DBG
, ">> Starting the SCAN timer\n");
6329 pstrWFIDrv
->hScanTimer
.data
= (unsigned long)hWFIDrv
;
6330 mod_timer(&pstrWFIDrv
->hScanTimer
,
6331 jiffies
+ msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT
));
6333 WILC_CATCH(s32Error
)
6341 * @brief hif_set_cfg
6342 * @details sets configuration wids values
6343 * @param[in,out] handle to the wifi driver,
6344 * @param[in] WID, WID value
6345 * @return Error code indicating success/failure
6348 * @date 8 March 2012
6351 s32
hif_set_cfg(tstrWILC_WFIDrv
*hWFIDrv
, tstrCfgParamVal
*pstrCfgParamVal
)
6354 s32 s32Error
= WILC_SUCCESS
;
6355 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6357 tstrHostIFmsg strHostIFmsg
;
6360 if (pstrWFIDrv
== NULL
)
6361 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
6362 /* prepare the WiphyParams Message */
6363 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6364 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_CFG_PARAMS
;
6365 strHostIFmsg
.uniHostIFmsgBody
.strHostIFCfgParamAttr
.pstrCfgParamVal
= *pstrCfgParamVal
;
6366 strHostIFmsg
.drvHandler
= hWFIDrv
;
6368 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
6370 WILC_CATCH(s32Error
)
6380 * @brief hif_get_cfg
6381 * @details gets configuration wids values
6382 * @param[in,out] handle to the wifi driver,
6385 * @return Error code indicating success/failure
6389 * @date 8 March 2012
6392 s32
hif_get_cfg(tstrWILC_WFIDrv
*hWFIDrv
, u16 u16WID
, u16
*pu16WID_Value
)
6394 s32 s32Error
= WILC_SUCCESS
;
6395 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6397 down(&(pstrWFIDrv
->gtOsCfgValuesSem
));
6399 if (pstrWFIDrv
== NULL
) {
6400 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
6401 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
6403 PRINT_D(HOSTINF_DBG
, "Getting configuration parameters\n");
6407 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.bss_type
;
6411 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.auth_type
;
6414 case WID_AUTH_TIMEOUT
:
6415 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.auth_timeout
;
6418 case WID_POWER_MANAGEMENT
:
6419 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.power_mgmt_mode
;
6422 case WID_SHORT_RETRY_LIMIT
:
6423 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.short_retry_limit
;
6426 case WID_LONG_RETRY_LIMIT
:
6427 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.long_retry_limit
;
6430 case WID_FRAG_THRESHOLD
:
6431 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.frag_threshold
;
6434 case WID_RTS_THRESHOLD
:
6435 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.rts_threshold
;
6439 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.preamble_type
;
6442 case WID_SHORT_SLOT_ALLOWED
:
6443 *pu16WID_Value
= (u16
) pstrWFIDrv
->strCfgValues
.short_slot_allowed
;
6446 case WID_11N_TXOP_PROT_DISABLE
:
6447 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.txop_prot_disabled
;
6450 case WID_BEACON_INTERVAL
:
6451 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.beacon_interval
;
6454 case WID_DTIM_PERIOD
:
6455 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.dtim_period
;
6458 case WID_SITE_SURVEY
:
6459 *pu16WID_Value
= (u16
)pstrWFIDrv
->strCfgValues
.site_survey_enabled
;
6462 case WID_SITE_SURVEY_SCAN_TIME
:
6463 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.site_survey_scan_time
;
6466 case WID_ACTIVE_SCAN_TIME
:
6467 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.active_scan_time
;
6470 case WID_PASSIVE_SCAN_TIME
:
6471 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.passive_scan_time
;
6474 case WID_CURRENT_TX_RATE
:
6475 *pu16WID_Value
= pstrWFIDrv
->strCfgValues
.curr_tx_rate
;
6482 up(&(pstrWFIDrv
->gtOsCfgValuesSem
));
6484 WILC_CATCH(s32Error
)
6491 /*****************************************************************************/
6492 /* Notification Functions */
6493 /*****************************************************************************/
6495 * @brief notifies host with join and leave requests
6496 * @details This function prepares an Information frame having the
6497 * information about a joining/leaving station.
6498 * @param[in,out] handle to the wifi driver,
6499 * @param[in] 6 byte Sta Adress
6500 * Join or leave flag:
6503 * @return Error code indicating success/failure
6506 * @date 8 March 2012
6509 void host_int_send_join_leave_info_to_host
6510 (u16 assocId
, u8
*stationAddr
, bool joining
)
6514 * @brief notifies host with stations found in scan
6515 * @details sends the beacon/probe response from scan
6516 * @param[in,out] handle to the wifi driver,
6517 * @param[in] Sta Address,
6519 * Rssi of the Station found
6520 * @return Error code indicating success/failure
6523 * @date 8 March 2012
6527 static void GetPeriodicRSSI(unsigned long arg
)
6529 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)arg
;
6531 if (pstrWFIDrv
== NULL
) {
6532 PRINT_ER("Driver handler is NULL\n");
6536 if (pstrWFIDrv
->enuHostIFstate
== HOST_IF_CONNECTED
) {
6537 s32 s32Error
= WILC_SUCCESS
;
6538 tstrHostIFmsg strHostIFmsg
;
6540 /* prepare the Get RSSI Message */
6541 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6543 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_RSSI
;
6544 strHostIFmsg
.drvHandler
= pstrWFIDrv
;
6546 /* send the message */
6547 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
6549 PRINT_ER("Failed to send get host channel param's message queue ");
6553 g_hPeriodicRSSI
.data
= (unsigned long)pstrWFIDrv
;
6554 mod_timer(&g_hPeriodicRSSI
, jiffies
+ msecs_to_jiffies(5000));
6558 void host_int_send_network_info_to_host
6559 (u8
*macStartAddress
, u16 u16RxFrameLen
, s8 s8Rssi
)
6563 * @brief host_int_init
6564 * @details host interface initialization function
6565 * @param[in,out] handle to the wifi driver,
6568 * @date 8 March 2012
6571 static u32 u32Intialized
;
6572 static u32 msgQ_created
;
6573 static u32 clients_count
;
6575 s32
host_int_init(tstrWILC_WFIDrv
**phWFIDrv
)
6577 s32 s32Error
= WILC_SUCCESS
;
6578 tstrWILC_WFIDrv
*pstrWFIDrv
;
6581 /*if(u32Intialized == 1)
6583 * PRINT_D(HOSTINF_DBG,"Host interface is previously initialized\n");
6584 * *phWFIDrv = (WILC_WFIDrvHandle)gWFiDrvHandle; //Will be adjusted later for P2P
6587 PRINT_D(HOSTINF_DBG
, "Initializing host interface for client %d\n", clients_count
+ 1);
6589 gbScanWhileConnected
= false;
6591 sema_init(&hWaitResponse
, 0);
6595 /*Allocate host interface private structure*/
6596 pstrWFIDrv
= kmalloc(sizeof(tstrWILC_WFIDrv
), GFP_KERNEL
);
6597 if (pstrWFIDrv
== NULL
) {
6598 /* WILC_ERRORREPORT(s32Error,WILC_NO_MEM); */
6599 s32Error
= WILC_NO_MEM
;
6600 PRINT_ER("Failed to allocate memory\n");
6603 memset(pstrWFIDrv
, 0, sizeof(tstrWILC_WFIDrv
));
6604 /*return driver handle to user*/
6605 *phWFIDrv
= pstrWFIDrv
;
6606 /*save into globl handle*/
6607 err
= add_handler_in_list(pstrWFIDrv
);
6609 s32Error
= WILC_FAIL
;
6613 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
6615 g_obtainingIP
= false;
6618 PRINT_D(HOSTINF_DBG
, "Global handle pointer value=%p\n", pstrWFIDrv
);
6619 /* /////////////////////////////////////// */
6620 if (clients_count
== 0) {
6621 sema_init(&hSemHostIFthrdEnd
, 0);
6622 sema_init(&hSemDeinitDrvHandle
, 0);
6624 sema_init(&hSemHostIntDeinit
, 1);
6627 sema_init(&(pstrWFIDrv
->hSemTestKeyBlock
), 0);
6628 sema_init(&(pstrWFIDrv
->hSemTestDisconnectBlock
), 0);
6629 sema_init(&(pstrWFIDrv
->hSemGetRSSI
), 0);
6630 sema_init(&(pstrWFIDrv
->hSemGetLINKSPEED
), 0);
6631 sema_init(&(pstrWFIDrv
->hSemGetCHNL
), 0);
6632 sema_init(&(pstrWFIDrv
->hSemInactiveTime
), 0);
6634 /* /////////////////////////////////////// */
6638 PRINT_D(HOSTINF_DBG
, "INIT: CLIENT COUNT %d\n", clients_count
);
6640 if (clients_count
== 0) {
6641 s32Error
= wilc_mq_create(&gMsgQHostIF
);
6644 PRINT_ER("Failed to creat MQ\n");
6648 HostIFthreadHandler
= kthread_run(hostIFthread
, NULL
, "WILC_kthread");
6649 if (IS_ERR(HostIFthreadHandler
)) {
6650 PRINT_ER("Failed to creat Thread\n");
6651 s32Error
= WILC_FAIL
;
6654 setup_timer(&g_hPeriodicRSSI
, GetPeriodicRSSI
,
6655 (unsigned long)pstrWFIDrv
);
6656 mod_timer(&g_hPeriodicRSSI
, jiffies
+ msecs_to_jiffies(5000));
6660 setup_timer(&pstrWFIDrv
->hScanTimer
, TimerCB_Scan
, 0);
6662 setup_timer(&pstrWFIDrv
->hConnectTimer
, TimerCB_Connect
, 0);
6665 /*Remain on channel timer*/
6666 setup_timer(&pstrWFIDrv
->hRemainOnChannel
, ListenTimerCB
, 0);
6669 sema_init(&(pstrWFIDrv
->gtOsCfgValuesSem
), 1);
6670 down(&(pstrWFIDrv
->gtOsCfgValuesSem
));
6672 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
6673 /* gWFiDrvHandle->bPendingConnRequest = false; */
6675 /*Initialize CFG WIDS Defualt Values*/
6677 pstrWFIDrv
->strCfgValues
.site_survey_enabled
= SITE_SURVEY_OFF
;
6678 pstrWFIDrv
->strCfgValues
.scan_source
= DEFAULT_SCAN
;
6679 pstrWFIDrv
->strCfgValues
.active_scan_time
= ACTIVE_SCAN_TIME
;
6680 pstrWFIDrv
->strCfgValues
.passive_scan_time
= PASSIVE_SCAN_TIME
;
6681 pstrWFIDrv
->strCfgValues
.curr_tx_rate
= AUTORATE
;
6686 pstrWFIDrv
->u64P2p_MgmtTimeout
= 0;
6690 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",
6692 pstrWFIDrv
->strCfgValues
.site_survey_enabled
, pstrWFIDrv
->strCfgValues
.scan_source
,
6693 pstrWFIDrv
->strCfgValues
.active_scan_time
, pstrWFIDrv
->strCfgValues
.passive_scan_time
,
6694 pstrWFIDrv
->strCfgValues
.curr_tx_rate
);
6697 up(&(pstrWFIDrv
->gtOsCfgValuesSem
));
6699 /*TODO Code to setup simulation to be removed later*/
6700 /*Intialize configurator module*/
6701 s32Error
= CoreConfiguratorInit();
6703 PRINT_ER("Failed to initialize core configurator\n");
6708 clients_count
++; /* increase number of created entities */
6714 if (pstrWFIDrv
!= NULL
)
6717 del_timer_sync(&pstrWFIDrv
->hRemainOnChannel
);
6720 up(&(pstrWFIDrv
->gtOsCfgValuesSem
));
6721 del_timer_sync(&pstrWFIDrv
->hConnectTimer
);
6722 del_timer_sync(&pstrWFIDrv
->hScanTimer
);
6723 kthread_stop(HostIFthreadHandler
);
6725 wilc_mq_destroy(&gMsgQHostIF
);
6732 * @brief host_int_deinit
6733 * @details host interface initialization function
6734 * @param[in,out] handle to the wifi driver,
6737 * @date 8 March 2012
6741 s32
host_int_deinit(tstrWILC_WFIDrv
*hWFIDrv
)
6743 s32 s32Error
= WILC_SUCCESS
;
6744 tstrHostIFmsg strHostIFmsg
;
6747 /*obtain driver handle*/
6748 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
6749 /*if(u32Intialized == 0)
6751 * PRINT_ER("Host Interface is not initialized\n");
6757 if (pstrWFIDrv
== NULL
) {
6758 PRINT_ER("pstrWFIDrv = NULL\n");
6762 down(&hSemHostIntDeinit
);
6764 terminated_handle
= pstrWFIDrv
;
6765 PRINT_D(HOSTINF_DBG
, "De-initializing host interface for client %d\n", clients_count
);
6768 /*Destroy all timers before acquiring hSemDeinitDrvHandle*/
6769 /*to guarantee handling all messages befor proceeding*/
6770 if (del_timer_sync(&pstrWFIDrv
->hScanTimer
)) {
6771 PRINT_D(HOSTINF_DBG
, ">> Scan timer is active\n");
6772 /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */
6775 if (del_timer_sync(&pstrWFIDrv
->hConnectTimer
)) {
6776 PRINT_D(HOSTINF_DBG
, ">> Connect timer is active\n");
6777 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6781 if (del_timer_sync(&g_hPeriodicRSSI
)) {
6782 PRINT_D(HOSTINF_DBG
, ">> Connect timer is active\n");
6783 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6787 /*Destroy Remain-onchannel Timer*/
6788 del_timer_sync(&pstrWFIDrv
->hRemainOnChannel
);
6791 host_int_set_wfi_drv_handler(NULL
);
6792 down(&hSemDeinitDrvHandle
);
6795 /*Calling the CFG80211 scan done function with the abort flag set to true*/
6796 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
6797 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult(SCAN_EVENT_ABORTED
, NULL
,
6798 pstrWFIDrv
->strWILC_UsrScanReq
.u32UserScanPvoid
, NULL
);
6800 pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
= NULL
;
6802 /*deinit configurator and simulator*/
6803 CoreConfiguratorDeInit();
6805 pstrWFIDrv
->enuHostIFstate
= HOST_IF_IDLE
;
6807 gbScanWhileConnected
= false;
6809 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6811 if (clients_count
== 1) {
6812 if (del_timer_sync(&g_hPeriodicRSSI
)) {
6813 PRINT_D(HOSTINF_DBG
, ">> Connect timer is active\n");
6814 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6816 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_EXIT
;
6817 strHostIFmsg
.drvHandler
= hWFIDrv
;
6820 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
6821 if (s32Error
!= WILC_SUCCESS
)
6822 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error
);
6824 down(&hSemHostIFthrdEnd
);
6826 wilc_mq_destroy(&gMsgQHostIF
);
6830 down(&(pstrWFIDrv
->gtOsCfgValuesSem
));
6832 /*Setting the gloabl driver handler with NULL*/
6834 /* gWFiDrvHandle = NULL; */
6835 ret
= remove_handler_in_list(pstrWFIDrv
);
6837 s32Error
= WILC_NOT_FOUND
;
6839 if (pstrWFIDrv
!= NULL
) {
6841 /* pstrWFIDrv=NULL; */
6845 clients_count
--; /* Decrease number of created entities */
6846 terminated_handle
= NULL
;
6847 up(&hSemHostIntDeinit
);
6853 * @brief NetworkInfoReceived
6854 * @details function to to be called when network info packet is received
6855 * @param[in] pu8Buffer the received packet
6856 * @param[in] u32Length length of the received packet
6863 void NetworkInfoReceived(u8
*pu8Buffer
, u32 u32Length
)
6865 s32 s32Error
= WILC_SUCCESS
;
6866 tstrHostIFmsg strHostIFmsg
;
6868 tstrWILC_WFIDrv
*pstrWFIDrv
= NULL
;
6870 id
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
6871 pstrWFIDrv
= get_handler_from_id(id
);
6876 if (pstrWFIDrv
== NULL
|| pstrWFIDrv
== terminated_handle
) {
6877 PRINT_ER("NetworkInfo received but driver not init[%p]\n", pstrWFIDrv
);
6881 /* prepare the Asynchronous Network Info message */
6882 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6884 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_RCVD_NTWRK_INFO
;
6885 strHostIFmsg
.drvHandler
= pstrWFIDrv
;
6887 strHostIFmsg
.uniHostIFmsgBody
.strRcvdNetworkInfo
.u32Length
= u32Length
;
6888 strHostIFmsg
.uniHostIFmsgBody
.strRcvdNetworkInfo
.pu8Buffer
= kmalloc(u32Length
, GFP_KERNEL
); /* will be deallocated by the receiving thread */
6889 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strRcvdNetworkInfo
.pu8Buffer
,
6890 pu8Buffer
, u32Length
);
6892 /* send the message */
6893 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
6895 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error
);
6899 * @brief GnrlAsyncInfoReceived
6900 * @details function to be called when general Asynchronous info packet is received
6901 * @param[in] pu8Buffer the received packet
6902 * @param[in] u32Length length of the received packet
6909 void GnrlAsyncInfoReceived(u8
*pu8Buffer
, u32 u32Length
)
6911 s32 s32Error
= WILC_SUCCESS
;
6912 tstrHostIFmsg strHostIFmsg
;
6914 tstrWILC_WFIDrv
*pstrWFIDrv
= NULL
;
6917 down(&hSemHostIntDeinit
);
6919 id
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
6920 pstrWFIDrv
= get_handler_from_id(id
);
6921 PRINT_D(HOSTINF_DBG
, "General asynchronous info packet received\n");
6924 if (pstrWFIDrv
== NULL
|| pstrWFIDrv
== terminated_handle
) {
6925 PRINT_D(HOSTINF_DBG
, "Wifi driver handler is equal to NULL\n");
6927 up(&hSemHostIntDeinit
);
6931 if (pstrWFIDrv
->strWILC_UsrConnReq
.pfUserConnectResult
== NULL
) {
6932 /* received mac status is not needed when there is no current Connect Request */
6933 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
6935 up(&hSemHostIntDeinit
);
6939 /* prepare the General Asynchronous Info message */
6940 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6943 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO
;
6944 strHostIFmsg
.drvHandler
= pstrWFIDrv
;
6947 strHostIFmsg
.uniHostIFmsgBody
.strRcvdGnrlAsyncInfo
.u32Length
= u32Length
;
6948 strHostIFmsg
.uniHostIFmsgBody
.strRcvdGnrlAsyncInfo
.pu8Buffer
= kmalloc(u32Length
, GFP_KERNEL
); /* will be deallocated by the receiving thread */
6949 memcpy(strHostIFmsg
.uniHostIFmsgBody
.strRcvdGnrlAsyncInfo
.pu8Buffer
,
6950 pu8Buffer
, u32Length
);
6952 /* send the message */
6953 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
6955 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error
);
6958 up(&hSemHostIntDeinit
);
6962 * @brief host_int_ScanCompleteReceived
6963 * @details Setting scan complete received notifcation in message queue
6964 * @param[in] u8* pu8Buffer, u32 u32Length
6965 * @return Error code.
6970 void host_int_ScanCompleteReceived(u8
*pu8Buffer
, u32 u32Length
)
6972 s32 s32Error
= WILC_SUCCESS
;
6973 tstrHostIFmsg strHostIFmsg
;
6975 tstrWILC_WFIDrv
*pstrWFIDrv
= NULL
;
6977 id
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
6978 pstrWFIDrv
= get_handler_from_id(id
);
6981 PRINT_D(GENERIC_DBG
, "Scan notification received %p\n", pstrWFIDrv
);
6983 if (pstrWFIDrv
== NULL
|| pstrWFIDrv
== terminated_handle
)
6986 /*if there is an ongoing scan request*/
6987 if (pstrWFIDrv
->strWILC_UsrScanReq
.pfUserScanResult
) {
6988 /* prepare theScan Done message */
6989 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
6991 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_RCVD_SCAN_COMPLETE
;
6992 strHostIFmsg
.drvHandler
= pstrWFIDrv
;
6995 /* will be deallocated by the receiving thread */
6996 /*no need to send message body*/
6998 /*strHostIFmsg.uniHostIFmsgBody.strScanComplete.u32Length = u32Length;
6999 * strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer = (u8*)WILC_MALLOC(u32Length);
7000 * memcpy(strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer,
7001 * pu8Buffer, u32Length); */
7003 /* send the message */
7004 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7006 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error
);
7016 * @brief host_int_remain_on_channel
7018 * @param[in] Handle to wifi driver
7019 * Duration to remain on channel
7020 * Channel to remain on
7021 * Pointer to fn to be called on receive frames in listen state
7022 * Pointer to remain-on-channel expired fn
7024 * @return Error code.
7029 s32
host_int_remain_on_channel(tstrWILC_WFIDrv
*hWFIDrv
, u32 u32SessionID
, u32 u32duration
, u16 chan
, tWILCpfRemainOnChanExpired RemainOnChanExpired
, tWILCpfRemainOnChanReady RemainOnChanReady
, void *pvUserArg
)
7031 s32 s32Error
= WILC_SUCCESS
;
7032 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7033 tstrHostIFmsg strHostIFmsg
;
7035 if (pstrWFIDrv
== NULL
)
7036 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7038 /* prepare the remainonchan Message */
7039 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7041 /* prepare the WiphyParams Message */
7042 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_REMAIN_ON_CHAN
;
7043 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.u16Channel
= chan
;
7044 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.pRemainOnChanExpired
= RemainOnChanExpired
;
7045 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.pRemainOnChanReady
= RemainOnChanReady
;
7046 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.pVoid
= pvUserArg
;
7047 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.u32duration
= u32duration
;
7048 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.u32ListenSessionID
= u32SessionID
;
7049 strHostIFmsg
.drvHandler
= hWFIDrv
;
7051 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7053 WILC_ERRORREPORT(s32Error
, s32Error
);
7054 WILC_CATCH(s32Error
)
7063 * @brief host_int_ListenStateExpired
7065 * @param[in] Handle to wifi driver
7066 * Duration to remain on channel
7067 * Channel to remain on
7068 * Pointer to fn to be called on receive frames in listen state
7069 * Pointer to remain-on-channel expired fn
7071 * @return Error code.
7076 s32
host_int_ListenStateExpired(tstrWILC_WFIDrv
*hWFIDrv
, u32 u32SessionID
)
7078 s32 s32Error
= WILC_SUCCESS
;
7079 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7080 tstrHostIFmsg strHostIFmsg
;
7082 if (pstrWFIDrv
== NULL
)
7083 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7085 /*Stopping remain-on-channel timer*/
7086 del_timer(&pstrWFIDrv
->hRemainOnChannel
);
7088 /* prepare the timer fire Message */
7089 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7090 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_LISTEN_TIMER_FIRED
;
7091 strHostIFmsg
.drvHandler
= hWFIDrv
;
7092 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRemainOnChan
.u32ListenSessionID
= u32SessionID
;
7094 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7096 WILC_ERRORREPORT(s32Error
, s32Error
);
7097 WILC_CATCH(s32Error
)
7105 * @brief host_int_frame_register
7107 * @param[in] Handle to wifi driver
7108 * @return Error code.
7112 s32
host_int_frame_register(tstrWILC_WFIDrv
*hWFIDrv
, u16 u16FrameType
, bool bReg
)
7114 s32 s32Error
= WILC_SUCCESS
;
7115 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7116 tstrHostIFmsg strHostIFmsg
;
7118 if (pstrWFIDrv
== NULL
)
7119 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7121 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7123 /* prepare the WiphyParams Message */
7124 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_REGISTER_FRAME
;
7125 switch (u16FrameType
) {
7127 PRINT_D(HOSTINF_DBG
, "ACTION\n");
7128 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRegisterFrame
.u8Regid
= ACTION_FRM_IDX
;
7132 PRINT_D(HOSTINF_DBG
, "PROBE REQ\n");
7133 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRegisterFrame
.u8Regid
= PROBE_REQ_IDX
;
7137 PRINT_D(HOSTINF_DBG
, "Not valid frame type\n");
7140 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRegisterFrame
.u16FrameType
= u16FrameType
;
7141 strHostIFmsg
.uniHostIFmsgBody
.strHostIfRegisterFrame
.bReg
= bReg
;
7142 strHostIFmsg
.drvHandler
= hWFIDrv
;
7144 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7146 WILC_ERRORREPORT(s32Error
, s32Error
);
7147 WILC_CATCH(s32Error
)
7158 #ifdef WILC_AP_EXTERNAL_MLME
7160 * @brief host_int_add_beacon
7161 * @details Setting add beacon params in message queue
7162 * @param[in] WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
7163 * u32 u32DTIMPeriod,u32 u32HeadLen, u8* pu8Head,
7164 * u32 u32TailLen, u8* pu8Tail
7165 * @return Error code.
7170 s32
host_int_add_beacon(tstrWILC_WFIDrv
*hWFIDrv
, u32 u32Interval
,
7172 u32 u32HeadLen
, u8
*pu8Head
,
7173 u32 u32TailLen
, u8
*pu8Tail
)
7175 s32 s32Error
= WILC_SUCCESS
;
7176 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7177 tstrHostIFmsg strHostIFmsg
;
7178 tstrHostIFSetBeacon
*pstrSetBeaconParam
= &strHostIFmsg
.uniHostIFmsgBody
.strHostIFSetBeacon
;
7180 if (pstrWFIDrv
== NULL
)
7181 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7183 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7185 PRINT_D(HOSTINF_DBG
, "Setting adding beacon message queue params\n");
7188 /* prepare the WiphyParams Message */
7189 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_ADD_BEACON
;
7190 strHostIFmsg
.drvHandler
= hWFIDrv
;
7191 pstrSetBeaconParam
->u32Interval
= u32Interval
;
7192 pstrSetBeaconParam
->u32DTIMPeriod
= u32DTIMPeriod
;
7193 pstrSetBeaconParam
->u32HeadLen
= u32HeadLen
;
7194 pstrSetBeaconParam
->pu8Head
= kmalloc(u32HeadLen
, GFP_KERNEL
);
7195 if (pstrSetBeaconParam
->pu8Head
== NULL
)
7196 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
7197 memcpy(pstrSetBeaconParam
->pu8Head
, pu8Head
, u32HeadLen
);
7198 pstrSetBeaconParam
->u32TailLen
= u32TailLen
;
7200 /* Bug 4599 : if tail length = 0 skip allocating & copying */
7201 if (u32TailLen
> 0) {
7202 pstrSetBeaconParam
->pu8Tail
= kmalloc(u32TailLen
, GFP_KERNEL
);
7203 if (pstrSetBeaconParam
->pu8Tail
== NULL
)
7204 WILC_ERRORREPORT(s32Error
, WILC_NO_MEM
);
7205 memcpy(pstrSetBeaconParam
->pu8Tail
, pu8Tail
, u32TailLen
);
7207 pstrSetBeaconParam
->pu8Tail
= NULL
;
7210 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7212 WILC_ERRORREPORT(s32Error
, s32Error
);
7214 WILC_CATCH(s32Error
)
7216 if (pstrSetBeaconParam
->pu8Head
!= NULL
)
7217 kfree(pstrSetBeaconParam
->pu8Head
);
7219 if (pstrSetBeaconParam
->pu8Tail
!= NULL
)
7220 kfree(pstrSetBeaconParam
->pu8Tail
);
7229 * @brief host_int_del_beacon
7230 * @details Setting add beacon params in message queue
7231 * @param[in] WILC_WFIDrvHandle hWFIDrv
7232 * @return Error code.
7237 s32
host_int_del_beacon(tstrWILC_WFIDrv
*hWFIDrv
)
7239 s32 s32Error
= WILC_SUCCESS
;
7240 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7241 tstrHostIFmsg strHostIFmsg
;
7243 if (pstrWFIDrv
== NULL
)
7244 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7246 /* prepare the WiphyParams Message */
7247 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_DEL_BEACON
;
7248 strHostIFmsg
.drvHandler
= hWFIDrv
;
7249 PRINT_D(HOSTINF_DBG
, "Setting deleting beacon message queue params\n");
7251 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7252 WILC_ERRORCHECK(s32Error
);
7254 WILC_CATCH(s32Error
)
7262 * @brief host_int_add_station
7263 * @details Setting add station params in message queue
7264 * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7265 * @return Error code.
7270 s32
host_int_add_station(tstrWILC_WFIDrv
*hWFIDrv
, tstrWILC_AddStaParam
*pstrStaParams
)
7272 s32 s32Error
= WILC_SUCCESS
;
7273 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7274 tstrHostIFmsg strHostIFmsg
;
7275 tstrWILC_AddStaParam
*pstrAddStationMsg
= &strHostIFmsg
.uniHostIFmsgBody
.strAddStaParam
;
7278 if (pstrWFIDrv
== NULL
)
7279 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7281 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7283 PRINT_D(HOSTINF_DBG
, "Setting adding station message queue params\n");
7286 /* prepare the WiphyParams Message */
7287 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_ADD_STATION
;
7288 strHostIFmsg
.drvHandler
= hWFIDrv
;
7290 memcpy(pstrAddStationMsg
, pstrStaParams
, sizeof(tstrWILC_AddStaParam
));
7291 if (pstrAddStationMsg
->u8NumRates
> 0) {
7292 u8
*rates
= kmalloc(pstrAddStationMsg
->u8NumRates
, GFP_KERNEL
);
7294 WILC_NULLCHECK(s32Error
, rates
);
7296 memcpy(rates
, pstrStaParams
->pu8Rates
, pstrAddStationMsg
->u8NumRates
);
7297 pstrAddStationMsg
->pu8Rates
= rates
;
7301 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7303 WILC_ERRORREPORT(s32Error
, s32Error
);
7305 WILC_CATCH(s32Error
)
7312 * @brief host_int_del_station
7313 * @details Setting delete station params in message queue
7314 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr
7315 * @return Error code.
7320 s32
host_int_del_station(tstrWILC_WFIDrv
*hWFIDrv
, const u8
*pu8MacAddr
)
7322 s32 s32Error
= WILC_SUCCESS
;
7323 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7324 tstrHostIFmsg strHostIFmsg
;
7325 tstrHostIFDelSta
*pstrDelStationMsg
= &strHostIFmsg
.uniHostIFmsgBody
.strDelStaParam
;
7327 if (pstrWFIDrv
== NULL
)
7328 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7330 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7332 PRINT_D(HOSTINF_DBG
, "Setting deleting station message queue params\n");
7336 /* prepare the WiphyParams Message */
7337 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_DEL_STATION
;
7338 strHostIFmsg
.drvHandler
= hWFIDrv
;
7340 /*BugID_4795: Handling situation of deleting all stations*/
7341 if (pu8MacAddr
== NULL
)
7342 memset(pstrDelStationMsg
->au8MacAddr
, 255, ETH_ALEN
);
7344 memcpy(pstrDelStationMsg
->au8MacAddr
, pu8MacAddr
, ETH_ALEN
);
7346 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7348 WILC_ERRORREPORT(s32Error
, s32Error
);
7350 WILC_CATCH(s32Error
)
7356 * @brief host_int_del_allstation
7357 * @details Setting del station params in message queue
7358 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]s
7359 * @return Error code.
7364 s32
host_int_del_allstation(tstrWILC_WFIDrv
*hWFIDrv
, u8 pu8MacAddr
[][ETH_ALEN
])
7366 s32 s32Error
= WILC_SUCCESS
;
7367 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7368 tstrHostIFmsg strHostIFmsg
;
7369 tstrHostIFDelAllSta
*pstrDelAllStationMsg
= &strHostIFmsg
.uniHostIFmsgBody
.strHostIFDelAllSta
;
7370 u8 au8Zero_Buff
[ETH_ALEN
] = {0};
7375 if (pstrWFIDrv
== NULL
)
7376 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7378 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7380 PRINT_D(HOSTINF_DBG
, "Setting deauthenticating station message queue params\n");
7382 /* prepare the WiphyParams Message */
7383 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_DEL_ALL_STA
;
7384 strHostIFmsg
.drvHandler
= hWFIDrv
;
7386 /* Handling situation of deauthenticing all associated stations*/
7387 for (i
= 0; i
< MAX_NUM_STA
; i
++) {
7388 if (memcmp(pu8MacAddr
[i
], au8Zero_Buff
, ETH_ALEN
)) {
7389 memcpy(pstrDelAllStationMsg
->au8Sta_DelAllSta
[i
], pu8MacAddr
[i
], ETH_ALEN
);
7390 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],
7391 pstrDelAllStationMsg
->au8Sta_DelAllSta
[i
][5]);
7396 PRINT_D(CFG80211_DBG
, "NO ASSOCIATED STAS\n");
7400 pstrDelAllStationMsg
->u8Num_AssocSta
= u8AssocNumb
;
7401 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7405 WILC_ERRORREPORT(s32Error
, s32Error
);
7407 WILC_CATCH(s32Error
)
7411 down(&hWaitResponse
);
7418 * @brief host_int_edit_station
7419 * @details Setting edit station params in message queue
7420 * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7421 * @return Error code.
7426 s32
host_int_edit_station(tstrWILC_WFIDrv
*hWFIDrv
, tstrWILC_AddStaParam
*pstrStaParams
)
7428 s32 s32Error
= WILC_SUCCESS
;
7429 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7430 tstrHostIFmsg strHostIFmsg
;
7431 tstrWILC_AddStaParam
*pstrAddStationMsg
= &strHostIFmsg
.uniHostIFmsgBody
.strAddStaParam
;
7433 if (pstrWFIDrv
== NULL
)
7434 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7436 PRINT_D(HOSTINF_DBG
, "Setting editing station message queue params\n");
7438 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7441 /* prepare the WiphyParams Message */
7442 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_EDIT_STATION
;
7443 strHostIFmsg
.drvHandler
= hWFIDrv
;
7445 memcpy(pstrAddStationMsg
, pstrStaParams
, sizeof(tstrWILC_AddStaParam
));
7446 if (pstrAddStationMsg
->u8NumRates
> 0) {
7447 u8
*rates
= kmalloc(pstrAddStationMsg
->u8NumRates
, GFP_KERNEL
);
7449 WILC_NULLCHECK(s32Error
, rates
);
7450 memcpy(rates
, pstrStaParams
->pu8Rates
, pstrAddStationMsg
->u8NumRates
);
7451 pstrAddStationMsg
->pu8Rates
= rates
;
7454 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7456 WILC_ERRORREPORT(s32Error
, s32Error
);
7457 WILC_CATCH(s32Error
)
7462 #endif /*WILC_AP_EXTERNAL_MLME*/
7463 u32
wilc_get_chipid(u8
);
7465 s32
host_int_set_power_mgmt(tstrWILC_WFIDrv
*hWFIDrv
, bool bIsEnabled
, u32 u32Timeout
)
7467 s32 s32Error
= WILC_SUCCESS
;
7468 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7469 tstrHostIFmsg strHostIFmsg
;
7470 tstrHostIfPowerMgmtParam
*pstrPowerMgmtParam
= &strHostIFmsg
.uniHostIFmsgBody
.strPowerMgmtparam
;
7472 PRINT_INFO(HOSTINF_DBG
, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled
);
7474 if (pstrWFIDrv
== NULL
)
7475 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7477 PRINT_D(HOSTINF_DBG
, "Setting Power management message queue params\n");
7479 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7482 /* prepare the WiphyParams Message */
7483 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_POWER_MGMT
;
7484 strHostIFmsg
.drvHandler
= hWFIDrv
;
7486 pstrPowerMgmtParam
->bIsEnabled
= bIsEnabled
;
7487 pstrPowerMgmtParam
->u32Timeout
= u32Timeout
;
7490 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7492 WILC_ERRORREPORT(s32Error
, s32Error
);
7493 WILC_CATCH(s32Error
)
7499 s32
host_int_setup_multicast_filter(tstrWILC_WFIDrv
*hWFIDrv
, bool bIsEnabled
, u32 u32count
)
7501 s32 s32Error
= WILC_SUCCESS
;
7503 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7504 tstrHostIFmsg strHostIFmsg
;
7505 tstrHostIFSetMulti
*pstrMulticastFilterParam
= &strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetMulti
;
7508 if (pstrWFIDrv
== NULL
)
7509 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7511 PRINT_D(HOSTINF_DBG
, "Setting Multicast Filter params\n");
7513 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7516 /* prepare the WiphyParams Message */
7517 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SET_MULTICAST_FILTER
;
7518 strHostIFmsg
.drvHandler
= hWFIDrv
;
7520 pstrMulticastFilterParam
->bIsEnabled
= bIsEnabled
;
7521 pstrMulticastFilterParam
->u32count
= u32count
;
7523 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7525 WILC_ERRORREPORT(s32Error
, s32Error
);
7526 WILC_CATCH(s32Error
)
7534 /*Bug4218: Parsing Join Param*/
7535 #ifdef WILC_PARSE_SCAN_IN_HOST
7537 /*Bug4218: Parsing Join Param*/
7539 * @brief host_int_ParseJoinBssParam
7540 * @details Parse Needed Join Parameters and save it in a new JoinBssParam entry
7541 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7546 static void *host_int_ParseJoinBssParam(tstrNetworkInfo
*ptstrNetworkInfo
)
7548 tstrJoinBssParam
*pNewJoinBssParam
= NULL
;
7557 u8 pcipherTotalCount
= 0;
7558 u8 authTotalCount
= 0;
7561 pu8IEs
= ptstrNetworkInfo
->pu8IEs
;
7562 u16IEsLen
= ptstrNetworkInfo
->u16IEsLen
;
7564 pNewJoinBssParam
= kmalloc(sizeof(tstrJoinBssParam
), GFP_KERNEL
);
7565 if (pNewJoinBssParam
!= NULL
) {
7566 memset(pNewJoinBssParam
, 0, sizeof(tstrJoinBssParam
));
7567 pNewJoinBssParam
->dtim_period
= ptstrNetworkInfo
->u8DtimPeriod
;
7568 pNewJoinBssParam
->beacon_period
= ptstrNetworkInfo
->u16BeaconPeriod
;
7569 pNewJoinBssParam
->cap_info
= ptstrNetworkInfo
->u16CapInfo
;
7570 memcpy(pNewJoinBssParam
->au8bssid
, ptstrNetworkInfo
->au8bssid
, 6);
7572 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/
7573 memcpy((u8
*)pNewJoinBssParam
->ssid
, ptstrNetworkInfo
->au8ssid
, ptstrNetworkInfo
->u8SsidLen
+ 1);
7574 pNewJoinBssParam
->ssidLen
= ptstrNetworkInfo
->u8SsidLen
;
7575 memset(pNewJoinBssParam
->rsn_pcip_policy
, 0xFF, 3);
7576 memset(pNewJoinBssParam
->rsn_auth_policy
, 0xFF, 3);
7577 /*for(i=0; i<pNewJoinBssParam->ssidLen;i++)
7578 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/
7580 /* parse supported rates: */
7581 while (index
< u16IEsLen
) {
7582 /* supportedRates IE */
7583 if (pu8IEs
[index
] == SUPP_RATES_IE
) {
7584 /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */
7585 suppRatesNo
= pu8IEs
[index
+ 1];
7586 pNewJoinBssParam
->supp_rates
[0] = suppRatesNo
;
7587 index
+= 2; /* skipping ID and length bytes; */
7589 for (i
= 0; i
< suppRatesNo
; i
++) {
7590 pNewJoinBssParam
->supp_rates
[i
+ 1] = pu8IEs
[index
+ i
];
7591 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */
7593 index
+= suppRatesNo
;
7596 /* Ext SupportedRates IE */
7597 else if (pu8IEs
[index
] == EXT_SUPP_RATES_IE
) {
7598 /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */
7599 /* checking if no of ext. supp and supp rates < max limit */
7600 extSuppRatesNo
= pu8IEs
[index
+ 1];
7601 if (extSuppRatesNo
> (MAX_RATES_SUPPORTED
- suppRatesNo
))
7602 pNewJoinBssParam
->supp_rates
[0] = MAX_RATES_SUPPORTED
;
7604 pNewJoinBssParam
->supp_rates
[0] += extSuppRatesNo
;
7606 /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */
7607 for (i
= 0; i
< (pNewJoinBssParam
->supp_rates
[0] - suppRatesNo
); i
++) {
7608 pNewJoinBssParam
->supp_rates
[suppRatesNo
+ i
+ 1] = pu8IEs
[index
+ i
];
7609 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */
7611 index
+= extSuppRatesNo
;
7615 else if (pu8IEs
[index
] == HT_CAPABILITY_IE
) {
7616 /* if IE found set the flag */
7617 pNewJoinBssParam
->ht_capable
= true;
7618 index
+= pu8IEs
[index
+ 1] + 2; /* ID,Length bytes and IE body */
7619 /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */
7621 } else if ((pu8IEs
[index
] == WMM_IE
) && /* WMM Element ID */
7622 (pu8IEs
[index
+ 2] == 0x00) && (pu8IEs
[index
+ 3] == 0x50) &&
7623 (pu8IEs
[index
+ 4] == 0xF2) && /* OUI */
7624 (pu8IEs
[index
+ 5] == 0x02) && /* OUI Type */
7625 ((pu8IEs
[index
+ 6] == 0x00) || (pu8IEs
[index
+ 6] == 0x01)) && /* OUI Sub Type */
7626 (pu8IEs
[index
+ 7] == 0x01)) {
7627 /* Presence of WMM Info/Param element indicates WMM capability */
7628 pNewJoinBssParam
->wmm_cap
= true;
7630 /* Check if Bit 7 is set indicating U-APSD capability */
7631 if (pu8IEs
[index
+ 8] & (1 << 7))
7632 pNewJoinBssParam
->uapsd_cap
= true;
7633 index
+= pu8IEs
[index
+ 1] + 2;
7637 else if ((pu8IEs
[index
] == P2P_IE
) && /* P2P Element ID */
7638 (pu8IEs
[index
+ 2] == 0x50) && (pu8IEs
[index
+ 3] == 0x6f) &&
7639 (pu8IEs
[index
+ 4] == 0x9a) && /* OUI */
7640 (pu8IEs
[index
+ 5] == 0x09) && (pu8IEs
[index
+ 6] == 0x0c)) { /* OUI Type */
7643 pNewJoinBssParam
->tsf
= ptstrNetworkInfo
->u32Tsf
;
7644 pNewJoinBssParam
->u8NoaEnbaled
= 1;
7645 pNewJoinBssParam
->u8Index
= pu8IEs
[index
+ 9];
7647 /* Check if Bit 7 is set indicating Opss capability */
7648 if (pu8IEs
[index
+ 10] & (1 << 7)) {
7649 pNewJoinBssParam
->u8OppEnable
= 1;
7650 pNewJoinBssParam
->u8CtWindow
= pu8IEs
[index
+ 10];
7652 pNewJoinBssParam
->u8OppEnable
= 0;
7654 PRINT_D(GENERIC_DBG
, "P2P Dump\n");
7655 for (i
= 0; i
< pu8IEs
[index
+ 7]; i
++)
7656 PRINT_D(GENERIC_DBG
, " %x\n", pu8IEs
[index
+ 9 + i
]);
7658 pNewJoinBssParam
->u8Count
= pu8IEs
[index
+ 11];
7659 u16P2P_count
= index
+ 12;
7661 memcpy(pNewJoinBssParam
->au8Duration
, pu8IEs
+ u16P2P_count
, 4);
7664 memcpy(pNewJoinBssParam
->au8Interval
, pu8IEs
+ u16P2P_count
, 4);
7667 memcpy(pNewJoinBssParam
->au8StartTime
, pu8IEs
+ u16P2P_count
, 4);
7669 index
+= pu8IEs
[index
+ 1] + 2;
7674 else if ((pu8IEs
[index
] == RSN_IE
) ||
7675 ((pu8IEs
[index
] == WPA_IE
) && (pu8IEs
[index
+ 2] == 0x00) &&
7676 (pu8IEs
[index
+ 3] == 0x50) && (pu8IEs
[index
+ 4] == 0xF2) &&
7677 (pu8IEs
[index
+ 5] == 0x01))) {
7678 u16 rsnIndex
= index
;
7679 /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]);
7680 * for(i=0; i<pu8IEs[rsnIndex+1]; i++)
7682 * PRINT_D(HOSTINF_DBG,"%0x ",pu8IEs[rsnIndex+2+i]);
7684 if (pu8IEs
[rsnIndex
] == RSN_IE
) {
7685 pNewJoinBssParam
->mode_802_11i
= 2;
7686 /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */
7687 } else { /* check if rsn was previously parsed */
7688 if (pNewJoinBssParam
->mode_802_11i
== 0)
7689 pNewJoinBssParam
->mode_802_11i
= 1;
7690 /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */
7693 rsnIndex
+= 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */
7694 pNewJoinBssParam
->rsn_grp_policy
= pu8IEs
[rsnIndex
];
7696 /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x\n",pNewJoinBssParam->rsn_grp_policy); */
7697 /* initialize policies with invalid values */
7699 jumpOffset
= pu8IEs
[rsnIndex
] * 4; /* total no.of bytes of pcipher field (count*4) */
7701 /*parsing pairwise cipher*/
7703 /* saving 3 pcipher max. */
7704 pcipherCount
= (pu8IEs
[rsnIndex
] > 3) ? 3 : pu8IEs
[rsnIndex
];
7705 rsnIndex
+= 2; /* jump 2 bytes of pcipher count */
7707 /* PRINT_D(HOSTINF_DBG,"\npcipher:%d\n",pcipherCount); */
7708 for (i
= pcipherTotalCount
, j
= 0; i
< pcipherCount
+ pcipherTotalCount
&& i
< 3; i
++, j
++) {
7709 /* each count corresponds to 4 bytes, only last byte is saved */
7710 pNewJoinBssParam
->rsn_pcip_policy
[i
] = pu8IEs
[rsnIndex
+ ((j
+ 1) * 4) - 1];
7711 /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */
7713 pcipherTotalCount
+= pcipherCount
;
7714 rsnIndex
+= jumpOffset
;
7716 jumpOffset
= pu8IEs
[rsnIndex
] * 4;
7718 /*parsing AKM suite (auth_policy)*/
7719 /* saving 3 auth policies max. */
7720 authCount
= (pu8IEs
[rsnIndex
] > 3) ? 3 : pu8IEs
[rsnIndex
];
7721 rsnIndex
+= 2; /* jump 2 bytes of pcipher count */
7723 for (i
= authTotalCount
, j
= 0; i
< authTotalCount
+ authCount
; i
++, j
++) {
7724 /* each count corresponds to 4 bytes, only last byte is saved */
7725 pNewJoinBssParam
->rsn_auth_policy
[i
] = pu8IEs
[rsnIndex
+ ((j
+ 1) * 4) - 1];
7727 authTotalCount
+= authCount
;
7728 rsnIndex
+= jumpOffset
;
7729 /*pasring rsn cap. only if rsn IE*/
7730 if (pu8IEs
[index
] == RSN_IE
) {
7731 pNewJoinBssParam
->rsn_cap
[0] = pu8IEs
[rsnIndex
];
7732 pNewJoinBssParam
->rsn_cap
[1] = pu8IEs
[rsnIndex
+ 1];
7735 pNewJoinBssParam
->rsn_found
= true;
7736 index
+= pu8IEs
[index
+ 1] + 2; /* ID,Length bytes and IE body */
7739 index
+= pu8IEs
[index
+ 1] + 2; /* ID,Length bytes and IE body */
7746 return (void *)pNewJoinBssParam
;
7750 void host_int_freeJoinParams(void *pJoinParams
)
7752 if ((tstrJoinBssParam
*)pJoinParams
!= NULL
)
7753 kfree((tstrJoinBssParam
*)pJoinParams
);
7755 PRINT_ER("Unable to FREE null pointer\n");
7757 #endif /*WILC_PARSE_SCAN_IN_HOST*/
7761 * @brief host_int_addBASession
7762 * @details Open a block Ack session with the given parameters
7763 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7765 * @author anoureldin
7769 static int host_int_addBASession(tstrWILC_WFIDrv
*hWFIDrv
, char *pBSSID
, char TID
, short int BufferSize
,
7770 short int SessionTimeout
, void *drvHandler
)
7772 s32 s32Error
= WILC_SUCCESS
;
7773 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7774 tstrHostIFmsg strHostIFmsg
;
7775 tstrHostIfBASessionInfo
*pBASessionInfo
= &strHostIFmsg
.uniHostIFmsgBody
.strHostIfBASessionInfo
;
7777 if (pstrWFIDrv
== NULL
)
7778 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7780 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7782 /* prepare the WiphyParams Message */
7783 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_ADD_BA_SESSION
;
7785 memcpy(pBASessionInfo
->au8Bssid
, pBSSID
, ETH_ALEN
);
7786 pBASessionInfo
->u8Ted
= TID
;
7787 pBASessionInfo
->u16BufferSize
= BufferSize
;
7788 pBASessionInfo
->u16SessionTimeout
= SessionTimeout
;
7789 strHostIFmsg
.drvHandler
= hWFIDrv
;
7791 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7793 WILC_ERRORREPORT(s32Error
, s32Error
);
7794 WILC_CATCH(s32Error
)
7803 s32
host_int_delBASession(tstrWILC_WFIDrv
*hWFIDrv
, char *pBSSID
, char TID
)
7805 s32 s32Error
= WILC_SUCCESS
;
7806 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7807 tstrHostIFmsg strHostIFmsg
;
7808 tstrHostIfBASessionInfo
*pBASessionInfo
= &strHostIFmsg
.uniHostIFmsgBody
.strHostIfBASessionInfo
;
7810 if (pstrWFIDrv
== NULL
)
7811 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7813 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7815 /* prepare the WiphyParams Message */
7816 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_DEL_BA_SESSION
;
7818 memcpy(pBASessionInfo
->au8Bssid
, pBSSID
, ETH_ALEN
);
7819 pBASessionInfo
->u8Ted
= TID
;
7820 strHostIFmsg
.drvHandler
= hWFIDrv
;
7822 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7824 WILC_ERRORREPORT(s32Error
, s32Error
);
7825 WILC_CATCH(s32Error
)
7831 down(&hWaitResponse
);
7836 s32
host_int_del_All_Rx_BASession(tstrWILC_WFIDrv
*hWFIDrv
, char *pBSSID
, char TID
)
7838 s32 s32Error
= WILC_SUCCESS
;
7839 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7840 tstrHostIFmsg strHostIFmsg
;
7841 tstrHostIfBASessionInfo
*pBASessionInfo
= &strHostIFmsg
.uniHostIFmsgBody
.strHostIfBASessionInfo
;
7843 if (pstrWFIDrv
== NULL
)
7844 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7846 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7848 /* prepare the WiphyParams Message */
7849 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS
;
7851 memcpy(pBASessionInfo
->au8Bssid
, pBSSID
, ETH_ALEN
);
7852 pBASessionInfo
->u8Ted
= TID
;
7853 strHostIFmsg
.drvHandler
= hWFIDrv
;
7855 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7857 WILC_ERRORREPORT(s32Error
, s32Error
);
7858 WILC_CATCH(s32Error
)
7864 down(&hWaitResponse
);
7870 * @brief host_int_setup_ipaddress
7871 * @details setup IP in firmware
7872 * @param[in] Handle to wifi driver
7873 * @return Error code.
7874 * @author Abdelrahman Sobhy
7877 s32
host_int_setup_ipaddress(tstrWILC_WFIDrv
*hWFIDrv
, u8
*u16ipadd
, u8 idx
)
7879 s32 s32Error
= WILC_SUCCESS
;
7880 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7881 tstrHostIFmsg strHostIFmsg
;
7883 /* TODO: Enable This feature on softap firmware */
7886 if (pstrWFIDrv
== NULL
)
7887 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7889 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7891 /* prepare the WiphyParams Message */
7892 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_SET_IPADDRESS
;
7894 strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.au8IPAddr
= u16ipadd
;
7895 strHostIFmsg
.drvHandler
= hWFIDrv
;
7896 strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.idx
= idx
;
7898 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7900 WILC_ERRORREPORT(s32Error
, s32Error
);
7901 WILC_CATCH(s32Error
)
7912 * @brief host_int_get_ipaddress
7913 * @details Get IP from firmware
7914 * @param[in] Handle to wifi driver
7915 * @return Error code.
7916 * @author Abdelrahman Sobhy
7919 s32
host_int_get_ipaddress(tstrWILC_WFIDrv
*hWFIDrv
, u8
*u16ipadd
, u8 idx
)
7921 s32 s32Error
= WILC_SUCCESS
;
7922 tstrWILC_WFIDrv
*pstrWFIDrv
= (tstrWILC_WFIDrv
*)hWFIDrv
;
7923 tstrHostIFmsg strHostIFmsg
;
7925 if (pstrWFIDrv
== NULL
)
7926 WILC_ERRORREPORT(s32Error
, WILC_INVALID_ARGUMENT
);
7928 memset(&strHostIFmsg
, 0, sizeof(tstrHostIFmsg
));
7930 /* prepare the WiphyParams Message */
7931 strHostIFmsg
.u16MsgId
= HOST_IF_MSG_GET_IPADDRESS
;
7933 strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.au8IPAddr
= u16ipadd
;
7934 strHostIFmsg
.drvHandler
= hWFIDrv
;
7935 strHostIFmsg
.uniHostIFmsgBody
.strHostIfSetIP
.idx
= idx
;
7937 s32Error
= wilc_mq_send(&gMsgQHostIF
, &strHostIFmsg
, sizeof(tstrHostIFmsg
));
7939 WILC_ERRORREPORT(s32Error
, s32Error
);
7940 WILC_CATCH(s32Error
)