1 #include <linux/slab.h>
2 #include <linux/time.h>
3 #include <linux/kthread.h>
4 #include <linux/delay.h>
5 #include "host_interface.h"
6 #include "coreconfigurator.h"
7 #include "wilc_wlan_if.h"
8 #include "wilc_msgqueue.h"
12 extern struct timer_list hDuringIpTimer;
14 extern u8 g_wilc_initialized;
16 /* Message types of the Host IF Message Queue*/
17 #define HOST_IF_MSG_SCAN 0
18 #define HOST_IF_MSG_CONNECT 1
19 #define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
20 #define HOST_IF_MSG_KEY 3
21 #define HOST_IF_MSG_RCVD_NTWRK_INFO 4
22 #define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
23 #define HOST_IF_MSG_CFG_PARAMS 6
24 #define HOST_IF_MSG_SET_CHANNEL 7
25 #define HOST_IF_MSG_DISCONNECT 8
26 #define HOST_IF_MSG_GET_RSSI 9
27 #define HOST_IF_MSG_GET_CHNL 10
28 #define HOST_IF_MSG_ADD_BEACON 11
29 #define HOST_IF_MSG_DEL_BEACON 12
30 #define HOST_IF_MSG_ADD_STATION 13
31 #define HOST_IF_MSG_DEL_STATION 14
32 #define HOST_IF_MSG_EDIT_STATION 15
33 #define HOST_IF_MSG_SCAN_TIMER_FIRED 16
34 #define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
35 #define HOST_IF_MSG_POWER_MGMT 18
36 #define HOST_IF_MSG_GET_INACTIVETIME 19
37 #define HOST_IF_MSG_REMAIN_ON_CHAN 20
38 #define HOST_IF_MSG_REGISTER_FRAME 21
39 #define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
40 #define HOST_IF_MSG_GET_LINKSPEED 23
41 #define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
42 #define HOST_IF_MSG_SET_MAC_ADDRESS 25
43 #define HOST_IF_MSG_GET_MAC_ADDRESS 26
44 #define HOST_IF_MSG_SET_OPERATION_MODE 27
45 #define HOST_IF_MSG_SET_IPADDRESS 28
46 #define HOST_IF_MSG_GET_IPADDRESS 29
47 #define HOST_IF_MSG_FLUSH_CONNECT 30
48 #define HOST_IF_MSG_GET_STATISTICS 31
49 #define HOST_IF_MSG_SET_MULTICAST_FILTER 32
50 #define HOST_IF_MSG_ADD_BA_SESSION 33
51 #define HOST_IF_MSG_DEL_BA_SESSION 34
52 #define HOST_IF_MSG_Q_IDLE 35
53 #define HOST_IF_MSG_DEL_ALL_STA 36
54 #define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
55 #define HOST_IF_MSG_EXIT 100
57 #define HOST_IF_SCAN_TIMEOUT 4000
58 #define HOST_IF_CONNECT_TIMEOUT 9500
60 #define BA_SESSION_DEFAULT_BUFFER_SIZE 16
61 #define BA_SESSION_DEFAULT_TIMEOUT 1000
62 #define BLOCK_ACK_REQ_SIZE 0x14
65 * @struct cfg_param_attr
66 * @brief Structure to hold Host IF CFG Params Attributes
70 * @author Mai Daftedar
74 struct cfg_param_attr {
75 struct cfg_param_val pstrCfgParamVal;
79 * @struct host_if_wpa_attr
80 * @brief Structure to hold Host IF Scan Attributes
84 * @author Mai Daftedar
88 struct host_if_wpa_attr {
100 * @struct host_if_wep_attr
101 * @brief Structure to hold Host IF Scan Attributes
105 * @author Mai Daftedar
106 * @date 25 March 2012
109 struct host_if_wep_attr {
114 enum AUTHTYPE tenuAuth_type;
118 * @struct host_if_key_attr
119 * @brief Structure to hold Host IF Scan Attributes
123 * @author Mai Daftedar
124 * @date 25 March 2012
127 union host_if_key_attr {
128 struct host_if_wep_attr strHostIFwepAttr;
129 struct host_if_wpa_attr strHostIFwpaAttr;
130 struct host_if_pmkid_attr strHostIFpmkidAttr;
135 * @brief Structure to hold Host IF Scan Attributes
139 * @author Mai Daftedar
140 * @date 25 March 2012
144 enum KEY_TYPE enuKeyType;
146 union host_if_key_attr uniHostIFkeyAttr;
154 * @brief Structure to hold Host IF Scan Attributes
158 * @author Mostafa Abu Bakr
159 * @date 25 March 2012
169 wilc_scan_result pfScanResult;
171 struct hidden_network strHiddenNetwork;
175 * @struct connect_attr
176 * @brief Structure to hold Host IF Connect Attributes
180 * @author Mostafa Abu Bakr
181 * @date 25 March 2012
184 struct connect_attr {
191 wilc_connect_result pfConnectResult;
193 enum AUTHTYPE tenuAuth_type;
199 * @struct rcvd_async_info
200 * @brief Structure to hold Received General Asynchronous info
204 * @author Mostafa Abu Bakr
205 * @date 25 March 2012
208 struct rcvd_async_info {
214 * @struct channel_attr
215 * @brief Set Channel message body
219 * @author Mai Daftedar
220 * @date 25 March 2012
223 struct channel_attr {
228 * @struct tstrScanComplete
229 * @brief hold received Async. Scan Complete message body
234 * @date 25 March 2012
237 /*typedef struct _tstrScanComplete
241 * } tstrScanComplete;*/
244 * @struct beacon_attr
245 * @brief Set Beacon message body
249 * @author Adham Abozaeid
254 u32 u32Interval; /*!< Beacon Interval. Period between two successive beacons on air */
255 u32 u32DTIMPeriod; /*!< DTIM Period. Indicates how many Beacon frames
256 * (including the current frame) appear before the next DTIM */
257 u32 u32HeadLen; /*!< Length of the head buffer in bytes */
258 u8 *pu8Head; /*!< Pointer to the beacon's head buffer. Beacon's head is the part
259 * from the beacon's start till the TIM element, NOT including the TIM */
260 u32 u32TailLen; /*!< Length of the tail buffer in bytes */
261 u8 *pu8Tail; /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just
262 * after the TIM inormation element */
266 * @struct set_multicast
267 * @brief set Multicast filter Address
271 * @author Abdelrahman Sobhy
272 * @date 30 August 2013
273 * @version 1.0 Description
276 struct set_multicast {
282 * @struct del_all_sta
283 * @brief Deauth station message body
287 * @author Mai Daftedar
288 * @date 09 April 2014
289 * @version 1.0 Description
292 u8 au8Sta_DelAllSta[MAX_NUM_STA][ETH_ALEN];
298 * @brief Delete station message body
302 * @author Adham Abozaeid
304 * @version 1.0 Description
307 u8 au8MacAddr[ETH_ALEN];
311 * @struct power_mgmt_param
312 * @brief Power management message body
316 * @author Adham Abozaeid
317 * @date 24 November 2012
320 struct power_mgmt_param {
327 * @struct set_ip_addr
328 * @brief set IP Address message body
332 * @author Abdelrahman Sobhy
333 * @date 30 August 2013
334 * @version 1.0 Description
342 * @struct sta_inactive_t
343 * @brief Get station message body
347 * @author Mai Daftedar
348 * @date 16 April 2013
351 struct sta_inactive_t {
356 * @union message_body
357 * @brief Message body for the Host Interface message_q
361 * @author Mostafa Abu Bakr
362 * @date 25 March 2012
366 struct scan_attr scan_info;
367 struct connect_attr con_info;
368 struct rcvd_net_info net_info;
369 struct rcvd_async_info async_info;
370 struct key_attr key_info;
371 struct cfg_param_attr cfg_info;
372 struct channel_attr channel_info;
373 struct beacon_attr beacon_info;
374 struct add_sta_param add_sta_info;
375 struct del_sta del_sta_info;
376 struct add_sta_param edit_sta_info;
377 struct power_mgmt_param pwr_mgmt_info;
378 struct sta_inactive_t mac_info;
379 struct set_ip_addr ip_info;
380 struct drv_handler drv;
381 struct set_multicast multicast_info;
383 struct set_mac_addr set_mac_info;
384 struct get_mac_addr get_mac_info;
385 struct ba_session_info session_info;
386 struct remain_ch remain_on_ch;
387 struct reg_frame reg_frame;
389 struct del_all_sta del_all_sta_info;
393 * @struct struct host_if_msg
394 * @brief Host Interface message
398 * @author Mostafa Abu Bakr
399 * @date 25 March 2012
403 u16 id; /*!< Message ID */
404 union message_body body; /*!< Message body */
405 tstrWILC_WFIDrv *drvHandler;
408 typedef struct _tstrWidJoinReqExt {
409 char SSID[MAX_SSID_LEN];
414 /*Struct containg joinParam of each AP*/
415 typedef struct _tstrJoinBssParam {
421 char ssid[MAX_SSID_LEN];
423 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
430 u8 rsn_pcip_policy[3];
431 u8 rsn_auth_policy[3];
433 struct _tstrJoinParam *nextJoinBss;
444 /*a linked list table containing needed join parameters entries for each AP found in most recent scan*/
445 typedef struct _tstrBssTable {
447 tstrJoinBssParam *head;
448 tstrJoinBssParam *tail;
454 SCAN_CONNECT_TIMER_FORCE_32BIT = 0xFFFFFFFF
457 /*****************************************************************************/
459 /* Global Variabls */
461 /*****************************************************************************/
462 /* Zero is not used, because a zero ID means termination */
463 static tstrWILC_WFIDrv *wfidrv_list[NUM_CONCURRENT_IFC + 1];
464 tstrWILC_WFIDrv *terminated_handle;
465 tstrWILC_WFIDrv *gWFiDrvHandle;
466 bool g_obtainingIP = false;
468 static struct task_struct *HostIFthreadHandler;
469 static WILC_MsgQueueHandle gMsgQHostIF;
470 static struct semaphore hSemHostIFthrdEnd;
472 struct semaphore hSemDeinitDrvHandle;
473 static struct semaphore hWaitResponse;
474 struct semaphore hSemHostIntDeinit;
475 struct timer_list g_hPeriodicRSSI;
479 u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
481 static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE];
483 bool gbScanWhileConnected = false;
488 static u8 gs8SetIP[2][4];
489 static u8 gs8GetIP[2][4];
490 static u32 gu32InactiveTime;
492 static u32 gu32WidConnRstHack;
494 u8 *gu8FlushedJoinReq;
495 u8 *gu8FlushedInfoElemAsoc;
496 u8 gu8Flushed11iMode;
497 u8 gu8FlushedAuthType;
498 u32 gu32FlushedJoinReqSize;
499 u32 gu32FlushedInfoElemAsocSize;
500 tstrWILC_WFIDrv *gu8FlushedJoinReqDrvHandler;
501 #define REAL_JOIN_REQ 0
502 #define FLUSHED_JOIN_REQ 1
503 #define FLUSHED_BYTE_POS 79 /* Position the byte indicating flushing in the flushed request */
505 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
507 extern void chip_sleep_manually(u32 u32SleepTime);
508 extern int linux_wlan_get_num_conn_ifcs(void);
510 static int add_handler_in_list(tstrWILC_WFIDrv *handler)
514 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
515 if (!wfidrv_list[i]) {
516 wfidrv_list[i] = handler;
524 static int remove_handler_in_list(tstrWILC_WFIDrv *handler)
528 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
529 if (wfidrv_list[i] == handler) {
530 wfidrv_list[i] = NULL;
538 static int get_id_from_handler(tstrWILC_WFIDrv *handler)
545 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
546 if (wfidrv_list[i] == handler)
553 static tstrWILC_WFIDrv *get_handler_from_id(int id)
555 if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list))
557 return wfidrv_list[id];
561 * @brief Handle_SetChannel
562 * @details Sending config packet to firmware to set channel
563 * @param[in] struct channel_attr *pstrHostIFSetChan
564 * @return Error code.
569 static s32 Handle_SetChannel(tstrWILC_WFIDrv *drvHandler,
570 struct channel_attr *pstrHostIFSetChan)
575 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
577 /*prepare configuration packet*/
578 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
579 strWID.enuWIDtype = WID_CHAR;
580 strWID.ps8WidVal = (char *)&(pstrHostIFSetChan->u8SetChan);
581 strWID.s32ValueSize = sizeof(char);
583 PRINT_D(HOSTINF_DBG, "Setting channel\n");
585 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
586 get_id_from_handler(pstrWFIDrv));
588 PRINT_ER("Failed to set channel\n");
595 * @brief Handle_SetWfiDrvHandler
596 * @details Sending config packet to firmware to set driver handler
597 * @param[in] void * drvHandler,
598 * struct drv_handler *pstrHostIfSetDrvHandler
599 * @return Error code.
604 static s32 Handle_SetWfiDrvHandler(tstrWILC_WFIDrv *drvHandler,
605 struct drv_handler *pstrHostIfSetDrvHandler)
610 tstrWILC_WFIDrv *pstrWFIDrv = drvHandler;
613 /*prepare configuration packet*/
614 strWID.u16WIDid = (u16)WID_SET_DRV_HANDLER;
615 strWID.enuWIDtype = WID_INT;
616 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetDrvHandler->u32Address);
617 strWID.s32ValueSize = sizeof(u32);
621 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
622 pstrHostIfSetDrvHandler->u32Address);
624 if (pstrWFIDrv == NULL)
625 up(&hSemDeinitDrvHandle);
629 PRINT_ER("Failed to set driver handler\n");
637 * @brief Handle_SetWfiAPDrvHandler
638 * @details Sending config packet to firmware to set driver handler
639 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
640 * @return Error code.
645 static s32 Handle_SetOperationMode(tstrWILC_WFIDrv *drvHandler,
646 struct op_mode *pstrHostIfSetOperationMode)
651 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
654 /*prepare configuration packet*/
655 strWID.u16WIDid = (u16)WID_SET_OPERATION_MODE;
656 strWID.enuWIDtype = WID_INT;
657 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetOperationMode->u32Mode);
658 strWID.s32ValueSize = sizeof(u32);
661 PRINT_INFO(HOSTINF_DBG, "pstrWFIDrv= %p\n", pstrWFIDrv);
663 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
664 get_id_from_handler(pstrWFIDrv));
667 if ((pstrHostIfSetOperationMode->u32Mode) == IDLE_MODE)
668 up(&hSemDeinitDrvHandle);
672 PRINT_ER("Failed to set driver handler\n");
680 * @brief host_int_set_IPAddress
681 * @details Setting IP address params in message queue
682 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
683 * @return Error code.
688 s32 Handle_set_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 *pu8IPAddr, u8 idx)
693 char firmwareIPAddress[4] = {0};
694 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
696 if (pu8IPAddr[0] < 192)
699 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n", idx, pu8IPAddr);
701 memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN);
703 /*prepare configuration packet*/
704 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
705 strWID.enuWIDtype = WID_STR;
706 strWID.ps8WidVal = (u8 *)pu8IPAddr;
707 strWID.s32ValueSize = IP_ALEN;
709 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
710 get_id_from_handler(pstrWFIDrv));
713 host_int_get_ipaddress(drvHandler, firmwareIPAddress, idx);
716 PRINT_ER("Failed to set IP address\n");
720 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
727 * @brief Handle_get_IPAddress
728 * @details Setting IP address params in message queue
729 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
730 * @return Error code.
735 s32 Handle_get_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 *pu8IPAddr, u8 idx)
740 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
742 /*prepare configuration packet*/
743 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
744 strWID.enuWIDtype = WID_STR;
745 strWID.ps8WidVal = kmalloc(IP_ALEN, GFP_KERNEL);
746 strWID.s32ValueSize = IP_ALEN;
748 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
749 get_id_from_handler(pstrWFIDrv));
751 PRINT_INFO(HOSTINF_DBG, "%pI4\n", strWID.ps8WidVal);
753 memcpy(gs8GetIP[idx], strWID.ps8WidVal, IP_ALEN);
755 /*get the value by searching the local copy*/
756 kfree(strWID.ps8WidVal);
758 if (memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0)
759 host_int_setup_ipaddress(pstrWFIDrv, gs8SetIP[idx], idx);
762 PRINT_ER("Failed to get IP address\n");
766 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
767 PRINT_INFO(HOSTINF_DBG, "%pI4\n", gs8GetIP[idx]);
768 PRINT_INFO(HOSTINF_DBG, "\n");
775 * @brief Handle_SetMacAddress
776 * @details Setting mac address
777 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
778 * @return Error code.
779 * @author Amr Abdel-Moghny
780 * @date November 2013
783 static s32 Handle_SetMacAddress(tstrWILC_WFIDrv *drvHandler,
784 struct set_mac_addr *pstrHostIfSetMacAddress)
789 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
790 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
792 if (mac_buf == NULL) {
793 PRINT_ER("No buffer to send mac address\n");
796 memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
798 /*prepare configuration packet*/
799 strWID.u16WIDid = (u16)WID_MAC_ADDR;
800 strWID.enuWIDtype = WID_STR;
801 strWID.ps8WidVal = mac_buf;
802 strWID.s32ValueSize = ETH_ALEN;
803 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", strWID.ps8WidVal);
805 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
806 get_id_from_handler(pstrWFIDrv));
808 PRINT_ER("Failed to set mac address\n");
818 * @brief Handle_GetMacAddress
819 * @details Getting mac address
820 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
821 * @return Error code.
822 * @author Amr Abdel-Moghny
826 static s32 Handle_GetMacAddress(tstrWILC_WFIDrv *drvHandler,
827 struct get_mac_addr *pstrHostIfGetMacAddress)
833 /*prepare configuration packet*/
834 strWID.u16WIDid = (u16)WID_MAC_ADDR;
835 strWID.enuWIDtype = WID_STR;
836 strWID.ps8WidVal = pstrHostIfGetMacAddress->u8MacAddress;
837 strWID.s32ValueSize = ETH_ALEN;
840 s32Error = send_config_pkt(GET_CFG, &strWID, 1, false,
841 get_id_from_handler(drvHandler));
843 PRINT_ER("Failed to get mac address\n");
853 * @brief Handle_CfgParam
854 * @details Sending config packet to firmware to set CFG params
855 * @param[in] struct cfg_param_attr *strHostIFCfgParamAttr
856 * @return Error code.
861 static s32 Handle_CfgParam(tstrWILC_WFIDrv *drvHandler,
862 struct cfg_param_attr *strHostIFCfgParamAttr)
865 tstrWID strWIDList[32];
867 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
870 down(&(pstrWFIDrv->gtOsCfgValuesSem));
873 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
875 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BSS_TYPE) {
876 /*----------------------------------------------------------*/
877 /*Input Value: INFRASTRUCTURE = 1, */
878 /* INDEPENDENT= 2, */
880 /*----------------------------------------------------------*/
881 /* validate input then copy>> need to check value 4 and 5 */
882 if (strHostIFCfgParamAttr->pstrCfgParamVal.bss_type < 6) {
883 strWIDList[u8WidCnt].u16WIDid = WID_BSS_TYPE;
884 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
885 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
886 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
887 pstrWFIDrv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
889 PRINT_ER("check value 6 over\n");
895 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTH_TYPE) {
896 /*------------------------------------------------------*/
897 /*Input Values: OPEN_SYSTEM = 0, */
898 /* SHARED_KEY = 1, */
900 /*------------------------------------------------------*/
901 /*validate Possible values*/
902 if ((strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 1 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 2 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 5) {
903 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TYPE;
904 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
905 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
906 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
907 pstrWFIDrv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
909 PRINT_ER("Impossible value \n");
915 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTHEN_TIMEOUT) {
916 /* range is 1 to 65535. */
917 if (strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout < 65536) {
918 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TIMEOUT;
919 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
920 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
921 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
922 pstrWFIDrv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
924 PRINT_ER("Range(1 ~ 65535) over\n");
930 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & POWER_MANAGEMENT) {
931 /*-----------------------------------------------------------*/
932 /*Input Values: NO_POWERSAVE = 0, */
933 /* MIN_FAST_PS = 1, */
934 /* MAX_FAST_PS = 2, */
935 /* MIN_PSPOLL_PS = 3, */
936 /* MAX_PSPOLL_PS = 4 */
937 /*----------------------------------------------------------*/
938 if (strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode < 5) {
939 strWIDList[u8WidCnt].u16WIDid = WID_POWER_MANAGEMENT;
940 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
941 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
942 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
943 pstrWFIDrv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
945 PRINT_ER("Invalide power mode\n");
951 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_SHORT) {
952 /* range from 1 to 256 */
953 if ((strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit < 256)) {
954 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_RETRY_LIMIT;
955 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
956 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
957 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
958 pstrWFIDrv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
960 PRINT_ER("Range(1~256) over\n");
966 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_LONG) {
967 /* range from 1 to 256 */
968 if ((strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit < 256)) {
969 strWIDList[u8WidCnt].u16WIDid = WID_LONG_RETRY_LIMIT;
970 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
972 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
973 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
974 pstrWFIDrv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
976 PRINT_ER("Range(1~256) over\n");
982 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & FRAG_THRESHOLD) {
984 if (strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold < 7937) {
985 strWIDList[u8WidCnt].u16WIDid = WID_FRAG_THRESHOLD;
986 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
987 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
988 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
989 pstrWFIDrv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
991 PRINT_ER("Threshold Range fail\n");
997 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RTS_THRESHOLD) {
998 /* range 256 to 65535 */
999 if (strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold < 65536) {
1000 strWIDList[u8WidCnt].u16WIDid = WID_RTS_THRESHOLD;
1001 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
1002 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1003 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1004 pstrWFIDrv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
1006 PRINT_ER("Threshold Range fail\n");
1012 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PREAMBLE) {
1013 /*-----------------------------------------------------*/
1014 /*Input Values: Short= 0, */
1017 /*------------------------------------------------------*/
1018 if (strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type < 3) {
1019 strWIDList[u8WidCnt].u16WIDid = WID_PREAMBLE;
1020 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
1021 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1022 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1023 pstrWFIDrv->strCfgValues.preamble_type = strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
1025 PRINT_ER("Preamle Range(0~2) over\n");
1031 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SHORT_SLOT_ALLOWED) {
1032 if (strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed < 2) {
1033 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_SLOT_ALLOWED;
1034 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
1035 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1036 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1037 pstrWFIDrv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
1039 PRINT_ER("Short slot(2) over\n");
1045 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & TXOP_PROT_DISABLE) {
1046 /*Description: used to Disable RTS-CTS protection for TXOP burst*/
1047 /*transmission when the acknowledgement policy is No-Ack or Block-Ack */
1048 /* this information is useful for external supplicant */
1049 /*Input Values: 1 for enable and 0 for disable. */
1050 if (strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled < 2) {
1051 strWIDList[u8WidCnt].u16WIDid = WID_11N_TXOP_PROT_DISABLE;
1052 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
1053 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1054 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1055 pstrWFIDrv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
1057 PRINT_ER("TXOP prot disable\n");
1063 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BEACON_INTERVAL) {
1064 /* range is 1 to 65535. */
1065 if (strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval < 65536) {
1066 strWIDList[u8WidCnt].u16WIDid = WID_BEACON_INTERVAL;
1067 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
1068 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1069 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1070 pstrWFIDrv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
1072 PRINT_ER("Beacon interval(1~65535) fail\n");
1078 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & DTIM_PERIOD) {
1079 /* range is 1 to 255. */
1080 if (strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period < 256) {
1081 strWIDList[u8WidCnt].u16WIDid = WID_DTIM_PERIOD;
1082 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
1083 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1084 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1085 pstrWFIDrv->strCfgValues.dtim_period = strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
1087 PRINT_ER("DTIM range(1~255) fail\n");
1093 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY) {
1094 /*----------------------------------------------------------------------*/
1095 /*Input Values: SITE_SURVEY_1CH = 0, i.e.: currently set channel */
1096 /* SITE_SURVEY_ALL_CH = 1, */
1097 /* SITE_SURVEY_OFF = 2 */
1098 /*----------------------------------------------------------------------*/
1099 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled < 3) {
1100 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY;
1101 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
1102 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
1103 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
1104 pstrWFIDrv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
1106 PRINT_ER("Site survey disable\n");
1112 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY_SCAN_TIME) {
1113 /* range is 1 to 65535. */
1114 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time < 65536) {
1115 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY_SCAN_TIME;
1116 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
1117 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1118 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1119 pstrWFIDrv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
1121 PRINT_ER("Site survey scan time(1~65535) over\n");
1127 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & ACTIVE_SCANTIME) {
1128 /* range is 1 to 65535. */
1129 if (strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time < 65536) {
1130 strWIDList[u8WidCnt].u16WIDid = WID_ACTIVE_SCAN_TIME;
1131 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
1132 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1133 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1134 pstrWFIDrv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
1136 PRINT_ER("Active scan time(1~65535) over\n");
1142 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PASSIVE_SCANTIME) {
1143 /* range is 1 to 65535. */
1144 if (strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time < 65536) {
1145 strWIDList[u8WidCnt].u16WIDid = WID_PASSIVE_SCAN_TIME;
1146 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
1147 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1148 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1149 pstrWFIDrv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
1151 PRINT_ER("Passive scan time(1~65535) over\n");
1157 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & CURRENT_TX_RATE) {
1158 enum CURRENT_TXRATE curr_tx_rate = strHostIFCfgParamAttr->pstrCfgParamVal.curr_tx_rate;
1159 /*----------------------------------------------------------------------*/
1160 /*Rates: 1 2 5.5 11 6 9 12 18 24 36 48 54 Auto */
1161 /*InputValues: 1 2 3 4 5 6 7 8 9 10 11 12 0 */
1162 /*----------------------------------------------------------------------*/
1164 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
1165 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
1166 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
1167 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
1168 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
1169 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
1170 strWIDList[u8WidCnt].u16WIDid = WID_CURRENT_TX_RATE;
1171 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&curr_tx_rate;
1172 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
1173 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
1174 pstrWFIDrv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
1176 PRINT_ER("out of TX rate\n");
1182 s32Error = send_config_pkt(SET_CFG, strWIDList, u8WidCnt, false,
1183 get_id_from_handler(pstrWFIDrv));
1186 PRINT_ER("Error in setting CFG params\n");
1189 up(&(pstrWFIDrv->gtOsCfgValuesSem));
1195 * @brief Handle_wait_msg_q_empty
1196 * @details this should be the last msg and then the msg Q becomes idle
1197 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1198 * @return Error code.
1203 static s32 Handle_wait_msg_q_empty(void)
1207 g_wilc_initialized = 0;
1213 * @brief Handle_Scan
1214 * @details Sending config packet to firmware to set the scan params
1215 * @param[in] struct scan_attr *pstrHostIFscanAttr
1216 * @return Error code.
1221 static s32 Handle_Scan(tstrWILC_WFIDrv *drvHandler,
1222 struct scan_attr *pstrHostIFscanAttr)
1225 tstrWID strWIDList[5];
1226 u32 u32WidsCount = 0;
1230 u8 *pu8HdnNtwrksWidVal = NULL;
1231 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
1233 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1234 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", pstrWFIDrv->enuHostIFstate);
1236 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->pfScanResult;
1237 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->pvUserArg;
1239 if ((pstrWFIDrv->enuHostIFstate >= HOST_IF_SCANNING) && (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTED)) {
1240 /* here we either in HOST_IF_SCANNING, HOST_IF_WAITING_CONN_REQ or HOST_IF_WAITING_CONN_RESP */
1241 PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", pstrWFIDrv->enuHostIFstate);
1242 PRINT_ER("Already scan\n");
1247 if (g_obtainingIP || connecting) {
1248 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
1249 PRINT_ER("Don't do obss scan\n");
1254 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1257 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount = 0;
1259 strWIDList[u32WidsCount].u16WIDid = (u16)WID_SSID_PROBE_REQ;
1260 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1262 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++)
1263 valuesize += ((pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
1264 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
1265 strWIDList[u32WidsCount].ps8WidVal = pu8HdnNtwrksWidVal;
1266 if (strWIDList[u32WidsCount].ps8WidVal != NULL) {
1267 pu8Buffer = strWIDList[u32WidsCount].ps8WidVal;
1269 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum;
1271 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum);
1273 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) {
1274 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1275 memcpy(pu8Buffer, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen);
1276 pu8Buffer += pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1281 strWIDList[u32WidsCount].s32ValueSize = (s32)(valuesize + 1);
1285 /*filling cfg param array*/
1287 /* if((pstrHostIFscanAttr->pu8IEs != NULL) && (pstrHostIFscanAttr->IEsLen != 0)) */
1289 /* IEs to be inserted in Probe Request */
1290 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_PROBE;
1291 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1292 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8IEs;
1293 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->IEsLen;
1298 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_TYPE;
1299 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1300 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1301 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanType));
1304 /*list of channels to be scanned*/
1305 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_CHANNEL_LIST;
1306 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1308 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL && pstrHostIFscanAttr->u8ChnlListLen > 0) {
1311 for (i = 0; i < pstrHostIFscanAttr->u8ChnlListLen; i++) {
1312 if (pstrHostIFscanAttr->pu8ChnlFreqList[i] > 0)
1313 pstrHostIFscanAttr->pu8ChnlFreqList[i] = pstrHostIFscanAttr->pu8ChnlFreqList[i] - 1;
1317 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8ChnlFreqList;
1318 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->u8ChnlListLen;
1322 strWIDList[u32WidsCount].u16WIDid = WID_START_SCAN_REQ;
1323 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1324 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1325 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanSource));
1328 /*keep the state as is , no need to change it*/
1329 /* gWFiDrvHandle->enuHostIFstate = HOST_IF_SCANNING; */
1331 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
1332 gbScanWhileConnected = true;
1333 else if (pstrWFIDrv->enuHostIFstate == HOST_IF_IDLE)
1334 gbScanWhileConnected = false;
1336 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount, false,
1337 get_id_from_handler(pstrWFIDrv));
1340 PRINT_ER("Failed to send scan paramters config packet\n");
1342 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
1346 del_timer(&pstrWFIDrv->hScanTimer);
1347 /*if there is an ongoing scan request*/
1348 Handle_ScanDone(drvHandler, SCAN_EVENT_ABORTED);
1351 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1352 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
1353 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
1354 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1357 /* Deallocate pstrHostIFscanAttr->pu8IEs which was previously allocated by the sending thread */
1358 if (pstrHostIFscanAttr->pu8IEs != NULL) {
1359 kfree(pstrHostIFscanAttr->pu8IEs);
1360 pstrHostIFscanAttr->pu8IEs = NULL;
1362 if (pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo != NULL) {
1363 kfree(pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo);
1364 pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo = NULL;
1367 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1368 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
1369 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
1370 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1373 if (pu8HdnNtwrksWidVal != NULL)
1374 kfree(pu8HdnNtwrksWidVal);
1380 * @brief Handle_ScanDone
1381 * @details Call scan notification callback function
1383 * @return Error code.
1388 static s32 Handle_ScanDone(tstrWILC_WFIDrv *drvHandler, tenuScanEvent enuEvent)
1392 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
1395 u8 u8abort_running_scan;
1399 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
1401 /*Ask FW to abort the running scan, if any*/
1402 if (enuEvent == SCAN_EVENT_ABORTED) {
1403 PRINT_D(GENERIC_DBG, "Abort running scan\n");
1404 u8abort_running_scan = 1;
1405 strWID.u16WIDid = (u16)WID_ABORT_RUNNING_SCAN;
1406 strWID.enuWIDtype = WID_CHAR;
1407 strWID.ps8WidVal = (s8 *)&u8abort_running_scan;
1408 strWID.s32ValueSize = sizeof(char);
1411 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
1412 get_id_from_handler(pstrWFIDrv));
1414 PRINT_ER("Failed to set abort running scan\n");
1419 if (pstrWFIDrv == NULL) {
1420 PRINT_ER("Driver handler is NULL\n");
1424 /*if there is an ongoing scan request*/
1425 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
1426 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
1427 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
1428 /*delete current scan request*/
1429 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
1436 * @brief Handle_Connect
1437 * @details Sending config packet to firmware to starting connection
1438 * @param[in] struct connect_attr *pstrHostIFconnectAttr
1439 * @return Error code.
1444 u8 u8ConnectedSSID[6] = {0};
1445 static s32 Handle_Connect(tstrWILC_WFIDrv *drvHandler,
1446 struct connect_attr *pstrHostIFconnectAttr)
1448 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
1450 tstrWID strWIDList[8];
1451 u32 u32WidsCount = 0, dummyval = 0;
1452 /* char passphrase[] = "12345678"; */
1453 u8 *pu8CurrByte = NULL;
1454 tstrJoinBssParam *ptstrJoinBssParam;
1456 PRINT_D(GENERIC_DBG, "Handling connect request\n");
1458 /* if we try to connect to an already connected AP then discard the request */
1460 if (memcmp(pstrHostIFconnectAttr->pu8bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
1463 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1467 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1469 ptstrJoinBssParam = (tstrJoinBssParam *)pstrHostIFconnectAttr->pJoinParams;
1470 if (ptstrJoinBssParam == NULL) {
1471 PRINT_ER("Required BSSID not found\n");
1476 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1477 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = kmalloc(6, GFP_KERNEL);
1478 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
1481 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1482 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1483 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssidLen + 1, GFP_KERNEL);
1484 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
1485 pstrHostIFconnectAttr->ssidLen);
1486 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1489 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1490 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1491 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
1492 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
1493 pstrHostIFconnectAttr->IEsLen);
1496 pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1497 pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1498 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1499 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1501 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
1502 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
1503 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
1504 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
1507 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
1508 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
1509 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
1510 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
1513 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
1514 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
1515 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
1516 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
1519 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1520 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1522 /* IEs to be inserted in Association Request */
1523 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1524 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1525 strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1526 strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1529 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1531 gu32FlushedInfoElemAsocSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1532 gu8FlushedInfoElemAsoc = kmalloc(gu32FlushedInfoElemAsocSize, GFP_KERNEL);
1533 memcpy(gu8FlushedInfoElemAsoc, pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
1534 gu32FlushedInfoElemAsocSize);
1537 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
1538 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1539 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1540 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
1543 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
1544 gu8Flushed11iMode = pstrWFIDrv->strWILC_UsrConnReq.u8security;
1546 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1549 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
1550 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1551 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1552 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1555 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
1556 gu8FlushedAuthType = (u8)pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type;
1558 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1560 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
1561 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1562 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
1563 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
1567 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
1568 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->u8channel);
1570 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
1571 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1573 /*Sending NoA attributes during connection*/
1574 strWIDList[u32WidsCount].s32ValueSize = 112; /* 79; */
1575 strWIDList[u32WidsCount].ps8WidVal = kmalloc(strWIDList[u32WidsCount].s32ValueSize, GFP_KERNEL);
1577 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1578 gu32FlushedJoinReqSize = strWIDList[u32WidsCount].s32ValueSize;
1579 gu8FlushedJoinReq = kmalloc(gu32FlushedJoinReqSize, GFP_KERNEL);
1581 if (strWIDList[u32WidsCount].ps8WidVal == NULL) {
1586 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1589 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1590 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
1591 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1593 pu8CurrByte += MAX_SSID_LEN;
1596 *(pu8CurrByte++) = INFRASTRUCTURE;
1598 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1599 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1601 PRINT_ER("Channel out of range\n");
1602 *(pu8CurrByte++) = 0xFF;
1605 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1606 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1607 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1610 if (pstrHostIFconnectAttr->pu8bssid != NULL)
1611 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
1615 if (pstrHostIFconnectAttr->pu8bssid != NULL)
1616 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
1620 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1621 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1622 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1624 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1625 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1626 /* Supported rates*/
1627 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
1628 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1631 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1632 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1634 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1637 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1638 /* copy this information to the user request */
1639 pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
1642 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1643 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1644 /* rsn group policy*/
1645 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1646 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1648 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1649 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1650 /* rsn pcip policy*/
1651 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
1652 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1654 /* rsn auth policy*/
1655 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
1656 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1658 /* rsn auth policy*/
1659 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
1660 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1662 *(pu8CurrByte++) = REAL_JOIN_REQ;
1664 *(pu8CurrByte++) = ptstrJoinBssParam->u8NoaEnbaled;
1665 if (ptstrJoinBssParam->u8NoaEnbaled) {
1666 PRINT_D(HOSTINF_DBG, "NOA present\n");
1668 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1669 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1670 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1671 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1673 *(pu8CurrByte++) = ptstrJoinBssParam->u8Index;
1675 *(pu8CurrByte++) = ptstrJoinBssParam->u8OppEnable;
1677 if (ptstrJoinBssParam->u8OppEnable)
1678 *(pu8CurrByte++) = ptstrJoinBssParam->u8CtWindow;
1680 *(pu8CurrByte++) = ptstrJoinBssParam->u8Count;
1682 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Duration, sizeof(ptstrJoinBssParam->au8Duration));
1684 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Duration);
1686 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Interval, sizeof(ptstrJoinBssParam->au8Interval));
1688 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Interval);
1690 memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
1692 pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1695 PRINT_D(HOSTINF_DBG, "NOA not present\n");
1697 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1698 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1701 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1702 * firmware at chip reset when processing the WIDs of the Connect Request.
1703 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1704 /* ////////////////////// */
1705 gu32WidConnRstHack = 0;
1706 /* ////////////////////// */
1708 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1709 memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
1710 gu8FlushedJoinReqDrvHandler = pstrWFIDrv;
1713 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1715 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1716 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->pu8bssid, ETH_ALEN);
1718 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n", pstrHostIFconnectAttr->pu8bssid);
1719 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", u8ConnectedSSID);
1722 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount, false,
1723 get_id_from_handler(pstrWFIDrv));
1725 PRINT_ER("failed to send config packet\n");
1729 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
1730 pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1735 tstrConnectInfo strConnectInfo;
1737 del_timer(&pstrWFIDrv->hConnectTimer);
1739 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
1741 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1743 if (pstrHostIFconnectAttr->pfConnectResult != NULL) {
1744 if (pstrHostIFconnectAttr->pu8bssid != NULL)
1745 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
1747 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1748 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1749 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
1750 memcpy(strConnectInfo.pu8ReqIEs,
1751 pstrHostIFconnectAttr->pu8IEs,
1752 pstrHostIFconnectAttr->IEsLen);
1755 pstrHostIFconnectAttr->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1759 pstrHostIFconnectAttr->pvUserArg);
1760 /*Change state to idle*/
1761 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
1763 if (strConnectInfo.pu8ReqIEs != NULL) {
1764 kfree(strConnectInfo.pu8ReqIEs);
1765 strConnectInfo.pu8ReqIEs = NULL;
1769 PRINT_ER("Connect callback function pointer is NULL\n");
1773 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
1774 /* Deallocate pstrHostIFconnectAttr->pu8bssid which was prevoisuly allocated by the sending thread */
1775 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1776 kfree(pstrHostIFconnectAttr->pu8bssid);
1777 pstrHostIFconnectAttr->pu8bssid = NULL;
1780 /* Deallocate pstrHostIFconnectAttr->pu8ssid which was prevoisuly allocated by the sending thread */
1781 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1782 kfree(pstrHostIFconnectAttr->pu8ssid);
1783 pstrHostIFconnectAttr->pu8ssid = NULL;
1786 /* Deallocate pstrHostIFconnectAttr->pu8IEs which was prevoisuly allocated by the sending thread */
1787 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1788 kfree(pstrHostIFconnectAttr->pu8IEs);
1789 pstrHostIFconnectAttr->pu8IEs = NULL;
1792 if (pu8CurrByte != NULL)
1798 * @brief Handle_FlushConnect
1799 * @details Sending config packet to firmware to flush an old connection
1800 * after switching FW from station one to hybrid one
1801 * @param[in] void * drvHandler
1802 * @return Error code.
1803 * @author Amr Abdel-Moghny
1808 static s32 Handle_FlushConnect(tstrWILC_WFIDrv *drvHandler)
1811 tstrWID strWIDList[5];
1812 u32 u32WidsCount = 0;
1813 u8 *pu8CurrByte = NULL;
1816 /* IEs to be inserted in Association Request */
1817 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1818 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1819 strWIDList[u32WidsCount].ps8WidVal = gu8FlushedInfoElemAsoc;
1820 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedInfoElemAsocSize;
1823 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
1824 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1825 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1826 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(gu8Flushed11iMode));
1831 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
1832 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
1833 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
1834 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&gu8FlushedAuthType);
1837 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
1838 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1839 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedJoinReqSize;
1840 strWIDList[u32WidsCount].ps8WidVal = (s8 *)gu8FlushedJoinReq;
1841 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1843 pu8CurrByte += FLUSHED_BYTE_POS;
1844 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1848 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount, false,
1849 get_id_from_handler(gu8FlushedJoinReqDrvHandler));
1851 PRINT_ER("failed to send config packet\n");
1859 * @brief Handle_ConnectTimeout
1860 * @details Call connect notification callback function indicating connection failure
1862 * @return Error code.
1867 static s32 Handle_ConnectTimeout(tstrWILC_WFIDrv *drvHandler)
1870 tstrConnectInfo strConnectInfo;
1872 u16 u16DummyReasonCode = 0;
1873 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
1875 if (pstrWFIDrv == NULL) {
1876 PRINT_ER("Driver handler is NULL\n");
1880 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
1882 gbScanWhileConnected = false;
1885 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1888 /* First, we will notify the upper layer with the Connection failure {through the Connect Callback function},
1889 * then we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
1890 * WID_DISCONNECT} */
1891 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
1892 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
1893 memcpy(strConnectInfo.au8bssid,
1894 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
1897 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1898 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1899 strConnectInfo.pu8ReqIEs = kmalloc(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
1900 memcpy(strConnectInfo.pu8ReqIEs,
1901 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
1902 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
1905 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1909 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
1911 /* Deallocation of strConnectInfo.pu8ReqIEs */
1912 if (strConnectInfo.pu8ReqIEs != NULL) {
1913 kfree(strConnectInfo.pu8ReqIEs);
1914 strConnectInfo.pu8ReqIEs = NULL;
1917 PRINT_ER("Connect callback function pointer is NULL\n");
1920 /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
1921 * WID_DISCONNECT} */
1922 strWID.u16WIDid = (u16)WID_DISCONNECT;
1923 strWID.enuWIDtype = WID_CHAR;
1924 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
1925 strWID.s32ValueSize = sizeof(char);
1927 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1929 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
1930 get_id_from_handler(pstrWFIDrv));
1932 PRINT_ER("Failed to send dissconect config packet\n");
1934 /* Deallocation of the Saved Connect Request in the global Handle */
1935 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
1936 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
1937 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
1938 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
1941 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
1942 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
1943 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
1946 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1947 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1948 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
1949 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
1952 memset(u8ConnectedSSID, 0, ETH_ALEN);
1953 /*Freeing flushed join request params on connect timeout*/
1954 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
1955 kfree(gu8FlushedJoinReq);
1956 gu8FlushedJoinReq = NULL;
1958 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
1959 kfree(gu8FlushedInfoElemAsoc);
1960 gu8FlushedInfoElemAsoc = NULL;
1967 * @brief Handle_RcvdNtwrkInfo
1968 * @details Handling received network information
1969 * @param[in] struct rcvd_net_info *pstrRcvdNetworkInfo
1970 * @return Error code.
1975 static s32 Handle_RcvdNtwrkInfo(tstrWILC_WFIDrv *drvHandler,
1976 struct rcvd_net_info *pstrRcvdNetworkInfo)
1979 bool bNewNtwrkFound;
1984 tstrNetworkInfo *pstrNetworkInfo = NULL;
1985 void *pJoinParams = NULL;
1987 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
1991 bNewNtwrkFound = true;
1992 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
1994 /*if there is a an ongoing scan request*/
1995 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
1996 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
1997 parse_network_info(pstrRcvdNetworkInfo->pu8Buffer, &pstrNetworkInfo);
1998 if ((pstrNetworkInfo == NULL)
1999 || (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
2000 PRINT_ER("driver is null\n");
2005 /* check whether this network is discovered before */
2006 for (i = 0; i < pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
2008 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
2009 (pstrNetworkInfo->au8bssid != NULL)) {
2010 if (memcmp(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
2011 pstrNetworkInfo->au8bssid, 6) == 0) {
2012 if (pstrNetworkInfo->s8rssi <= pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
2013 /*we have already found this network with better rssi, so keep the old cached one and don't
2014 * send anything to the upper layer */
2015 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
2018 /* here the same already found network is found again but with a better rssi, so just update
2019 * the rssi for this cached network and send this updated network to the upper layer but
2020 * don't add a new record for it */
2021 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
2022 bNewNtwrkFound = false;
2029 if (bNewNtwrkFound == true) {
2030 /* here it is confirmed that it is a new discovered network,
2031 * so add its record then call the User CallBack function */
2033 PRINT_D(HOSTINF_DBG, "New network found\n");
2035 if (pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
2036 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
2038 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
2039 && (pstrNetworkInfo->au8bssid != NULL)) {
2040 memcpy(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
2041 pstrNetworkInfo->au8bssid, 6);
2043 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount++;
2045 pstrNetworkInfo->bNewNetwork = true;
2046 /* add new BSS to JoinBssTable */
2047 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
2049 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2050 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid,
2056 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
2059 pstrNetworkInfo->bNewNetwork = false;
2060 /* just call the User CallBack function to send the same discovered network with its updated RSSI */
2061 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2062 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2067 /* Deallocate pstrRcvdNetworkInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2068 if (pstrRcvdNetworkInfo->pu8Buffer != NULL) {
2069 kfree(pstrRcvdNetworkInfo->pu8Buffer);
2070 pstrRcvdNetworkInfo->pu8Buffer = NULL;
2073 /*free structure allocated*/
2074 if (pstrNetworkInfo != NULL) {
2075 DeallocateNetworkInfo(pstrNetworkInfo);
2076 pstrNetworkInfo = NULL;
2083 * @brief Handle_RcvdGnrlAsyncInfo
2084 * @details Handling received asynchrous general network information
2085 * @param[in] struct rcvd_async_info *pstrRcvdGnrlAsyncInfo
2086 * @return Error code.
2091 static s32 Handle_RcvdGnrlAsyncInfo(tstrWILC_WFIDrv *drvHandler,
2092 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
2094 /* TODO: mostafa: till now, this function just handles only the received mac status msg, */
2095 /* which carries only 1 WID which have WID ID = WID_STATUS */
2100 u16 u16WidID = (u16)WID_NIL;
2103 u8 u8MacStatusReasonCode;
2104 u8 u8MacStatusAdditionalInfo;
2105 tstrConnectInfo strConnectInfo;
2106 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2108 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
2111 PRINT_ER("Driver handler is NULL\n");
2114 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", pstrWFIDrv->enuHostIFstate,
2115 pstrRcvdGnrlAsyncInfo->pu8Buffer[7]);
2117 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
2118 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) ||
2119 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2120 if ((pstrRcvdGnrlAsyncInfo->pu8Buffer == NULL) ||
2121 (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
2122 PRINT_ER("driver is null\n");
2126 u8MsgType = pstrRcvdGnrlAsyncInfo->pu8Buffer[0];
2128 /* Check whether the received message type is 'I' */
2129 if ('I' != u8MsgType) {
2130 PRINT_ER("Received Message format incorrect.\n");
2134 /* Extract message ID */
2135 u8MsgID = pstrRcvdGnrlAsyncInfo->pu8Buffer[1];
2137 /* Extract message Length */
2138 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[2], pstrRcvdGnrlAsyncInfo->pu8Buffer[3]);
2140 /* Extract WID ID [expected to be = WID_STATUS] */
2141 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[4], pstrRcvdGnrlAsyncInfo->pu8Buffer[5]);
2143 /* Extract WID Length [expected to be = 1] */
2144 u8WidLen = pstrRcvdGnrlAsyncInfo->pu8Buffer[6];
2146 /* get the WID value [expected to be one of two values: either MAC_CONNECTED = (1) or MAC_DISCONNECTED = (0)] */
2147 u8MacStatus = pstrRcvdGnrlAsyncInfo->pu8Buffer[7];
2148 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->pu8Buffer[8];
2149 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->pu8Buffer[9];
2150 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2151 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2152 /* our station had sent Association Request frame, so here it will get the Association Response frame then parse it */
2153 u32 u32RcvdAssocRespInfoLen;
2154 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
2156 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2158 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
2160 if (u8MacStatus == MAC_CONNECTED) {
2161 memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
2163 host_int_get_assoc_res_info(pstrWFIDrv,
2165 MAX_ASSOC_RESP_FRAME_SIZE,
2166 &u32RcvdAssocRespInfoLen);
2168 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
2170 if (u32RcvdAssocRespInfoLen != 0) {
2172 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
2173 s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
2174 &pstrConnectRespInfo);
2176 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
2178 /* use the necessary parsed Info from the Received Association Response */
2179 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
2181 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
2182 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
2183 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
2184 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
2187 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL);
2188 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
2189 pstrConnectRespInfo->u16RespIEsLen);
2193 /* deallocate the Assoc. Resp. parsed structure as it is not needed anymore */
2194 if (pstrConnectRespInfo != NULL) {
2195 DeallocateAssocRespInfo(pstrConnectRespInfo);
2196 pstrConnectRespInfo = NULL;
2202 /* The station has just received mac status and it also received assoc. response which
2203 * it was waiting for.
2204 * So check first the matching between the received mac status and the received status code in Asoc Resp */
2205 if ((u8MacStatus == MAC_CONNECTED) &&
2206 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
2207 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
2208 memset(u8ConnectedSSID, 0, ETH_ALEN);
2210 } else if (u8MacStatus == MAC_DISCONNECTED) {
2211 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
2212 memset(u8ConnectedSSID, 0, ETH_ALEN);
2215 /* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */
2216 /* through a structure of type tstrConnectRespInfo */
2217 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2218 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
2219 memcpy(strConnectInfo.au8bssid, pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
2221 if ((u8MacStatus == MAC_CONNECTED) &&
2222 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
2223 memcpy(pstrWFIDrv->au8AssociatedBSSID,
2224 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
2229 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2230 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
2231 strConnectInfo.pu8ReqIEs = kmalloc(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
2232 memcpy(strConnectInfo.pu8ReqIEs,
2233 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2234 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2238 del_timer(&pstrWFIDrv->hConnectTimer);
2239 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2243 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2246 /* if received mac status is MAC_CONNECTED and
2247 * received status code in Asoc Resp is SUCCESSFUL_STATUSCODE, change state to CONNECTED
2248 * else change state to IDLE */
2249 if ((u8MacStatus == MAC_CONNECTED) &&
2250 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
2251 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
2253 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
2254 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTED;
2256 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
2257 g_obtainingIP = true;
2258 mod_timer(&hDuringIpTimer,
2259 jiffies + msecs_to_jiffies(10000));
2261 /* open a BA session if possible */
2262 /* if(pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable) */
2263 /* BA_SESSION_DEFAULT_BUFFER_SIZE,BA_SESSION_DEFAULT_TIMEOUT); */
2265 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
2266 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2267 gbScanWhileConnected = false;
2271 if (strConnectInfo.pu8RespIEs != NULL) {
2272 kfree(strConnectInfo.pu8RespIEs);
2273 strConnectInfo.pu8RespIEs = NULL;
2276 if (strConnectInfo.pu8ReqIEs != NULL) {
2277 kfree(strConnectInfo.pu8ReqIEs);
2278 strConnectInfo.pu8ReqIEs = NULL;
2282 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2283 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
2284 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
2285 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2288 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2289 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
2290 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2293 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2294 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2295 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
2296 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2299 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2300 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)) {
2301 /* Disassociation or Deauthentication frame has been received */
2302 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
2304 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
2306 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2307 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
2308 del_timer(&pstrWFIDrv->hScanTimer);
2309 Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED);
2312 strDisconnectNotifInfo.u16reason = 0;
2313 strDisconnectNotifInfo.ie = NULL;
2314 strDisconnectNotifInfo.ie_len = 0;
2316 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2317 g_obtainingIP = false;
2318 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
2320 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
2323 &strDisconnectNotifInfo,
2324 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2327 PRINT_ER("Connect result callback function is NULL\n");
2330 memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
2335 /* if Information Elements were retrieved from the Received deauth/disassoc frame, then they
2336 * should be deallocated here */
2338 * if(strDisconnectNotifInfo.ie != NULL)
2340 * kfree(strDisconnectNotifInfo.ie);
2341 * strDisconnectNotifInfo.ie = NULL;
2345 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2346 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
2347 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
2348 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2351 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2352 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
2353 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2356 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2357 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2358 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
2359 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2362 /*Freeing flushed join request params on receiving*/
2363 /*MAC_DISCONNECTED while connected*/
2364 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
2365 kfree(gu8FlushedJoinReq);
2366 gu8FlushedJoinReq = NULL;
2368 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
2369 kfree(gu8FlushedInfoElemAsoc);
2370 gu8FlushedInfoElemAsoc = NULL;
2373 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2374 gbScanWhileConnected = false;
2376 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2377 (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
2378 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
2379 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
2380 /*Abort the running scan*/
2381 del_timer(&pstrWFIDrv->hScanTimer);
2382 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult)
2383 Handle_ScanDone(pstrWFIDrv, SCAN_EVENT_ABORTED);
2389 /* Deallocate pstrRcvdGnrlAsyncInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2390 if (pstrRcvdGnrlAsyncInfo->pu8Buffer != NULL) {
2391 kfree(pstrRcvdGnrlAsyncInfo->pu8Buffer);
2392 pstrRcvdGnrlAsyncInfo->pu8Buffer = NULL;
2400 * @details Sending config packet to firmware to set key
2401 * @param[in] struct key_attr *pstrHostIFkeyAttr
2402 * @return Error code.
2407 static int Handle_Key(tstrWILC_WFIDrv *drvHandler,
2408 struct key_attr *pstrHostIFkeyAttr)
2412 tstrWID strWIDList[5];
2417 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2420 switch (pstrHostIFkeyAttr->enuKeyType) {
2425 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2427 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
2428 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
2429 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
2430 strWIDList[0].enuWIDtype = WID_CHAR;
2431 strWIDList[0].s32ValueSize = sizeof(char);
2432 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8mode));
2434 strWIDList[1].u16WIDid = WID_AUTH_TYPE;
2435 strWIDList[1].enuWIDtype = WID_CHAR;
2436 strWIDList[1].s32ValueSize = sizeof(char);
2437 strWIDList[1].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type));
2439 strWIDList[2].u16WIDid = (u16)WID_KEY_ID;
2440 strWIDList[2].enuWIDtype = WID_CHAR;
2442 strWIDList[2].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
2443 strWIDList[2].s32ValueSize = sizeof(char);
2446 pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, GFP_KERNEL);
2449 if (pu8keybuf == NULL) {
2450 PRINT_ER("No buffer to send Key\n");
2454 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
2455 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2458 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
2460 strWIDList[3].u16WIDid = (u16)WID_WEP_KEY_VALUE;
2461 strWIDList[3].enuWIDtype = WID_STR;
2462 strWIDList[3].s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen;
2463 strWIDList[3].ps8WidVal = (s8 *)pu8keybuf;
2466 s32Error = send_config_pkt(SET_CFG, strWIDList, 4, true,
2467 get_id_from_handler(pstrWFIDrv));
2473 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2474 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
2475 pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2, GFP_KERNEL);
2476 if (pu8keybuf == NULL) {
2477 PRINT_ER("No buffer to send Key\n");
2480 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2482 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, 1);
2484 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
2485 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2487 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
2489 strWID.u16WIDid = (u16)WID_ADD_WEP_KEY;
2490 strWID.enuWIDtype = WID_STR;
2491 strWID.ps8WidVal = (s8 *)pu8keybuf;
2492 strWID.s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2;
2494 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2495 get_id_from_handler(pstrWFIDrv));
2497 } else if (pstrHostIFkeyAttr->u8KeyAction & REMOVEKEY) {
2499 PRINT_D(HOSTINF_DBG, "Removing key\n");
2500 strWID.u16WIDid = (u16)WID_REMOVE_WEP_KEY;
2501 strWID.enuWIDtype = WID_STR;
2503 s8idxarray[0] = (s8)pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2504 strWID.ps8WidVal = s8idxarray;
2505 strWID.s32ValueSize = 1;
2507 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2508 get_id_from_handler(pstrWFIDrv));
2510 strWID.u16WIDid = (u16)WID_KEY_ID;
2511 strWID.enuWIDtype = WID_CHAR;
2512 strWID.ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
2513 strWID.s32ValueSize = sizeof(char);
2515 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
2517 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2518 get_id_from_handler(pstrWFIDrv));
2520 up(&(pstrWFIDrv->hSemTestKeyBlock));
2524 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2525 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
2526 if (pu8keybuf == NULL) {
2527 PRINT_ER("No buffer to send RxGTK Key\n");
2529 goto _WPARxGtk_end_case_;
2532 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
2535 /*|----------------------------------------------------------------------------|
2536 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2537 * |------------|---------|-------|------------|---------------|----------------|
2538 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2542 if (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq != NULL)
2543 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
2546 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2548 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2550 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2551 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2552 /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */
2553 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
2554 strWIDList[0].enuWIDtype = WID_CHAR;
2555 strWIDList[0].s32ValueSize = sizeof(char);
2556 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
2558 strWIDList[1].u16WIDid = (u16)WID_ADD_RX_GTK;
2559 strWIDList[1].enuWIDtype = WID_STR;
2560 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
2561 strWIDList[1].s32ValueSize = RX_MIC_KEY_MSG_LEN;
2563 s32Error = send_config_pkt(SET_CFG, strWIDList, 2, true,
2564 get_id_from_handler(pstrWFIDrv));
2568 /* ////////////////////////// */
2569 up(&(pstrWFIDrv->hSemTestKeyBlock));
2570 /* ///////////////////////// */
2573 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2574 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
2576 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
2577 if (pu8keybuf == NULL) {
2578 PRINT_ER("No buffer to send RxGTK Key\n");
2580 goto _WPARxGtk_end_case_;
2583 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
2586 /*|----------------------------------------------------------------------------|
2587 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2588 * |------------|---------|-------|------------|---------------|----------------|
2589 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2591 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
2592 memcpy(pu8keybuf, pstrWFIDrv->au8AssociatedBSSID, ETH_ALEN);
2594 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
2596 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
2598 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2600 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2601 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2602 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2604 strWID.u16WIDid = (u16)WID_ADD_RX_GTK;
2605 strWID.enuWIDtype = WID_STR;
2606 strWID.ps8WidVal = (s8 *)pu8keybuf;
2607 strWID.s32ValueSize = RX_MIC_KEY_MSG_LEN;
2609 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2610 get_id_from_handler(pstrWFIDrv));
2614 /* ////////////////////////// */
2615 up(&(pstrWFIDrv->hSemTestKeyBlock));
2616 /* ///////////////////////// */
2618 _WPARxGtk_end_case_:
2619 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
2620 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq);
2627 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2630 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
2634 if (pu8keybuf == NULL) {
2635 PRINT_ER("No buffer to send PTK Key\n");
2637 goto _WPAPtk_end_case_;
2641 /*|-----------------------------------------------------------------------------|
2642 * |Station address | keyidx |Key Length |Temporal Key | Rx Michael Key |Tx Michael Key |
2643 * |----------------|------------ |--------------|----------------|---------------|
2644 | 6 bytes | 1 byte | 1byte | 16 bytes | 8 bytes | 8 bytes |
2645 |-----------------------------------------------------------------------------|*/
2647 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
2649 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2650 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2652 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2653 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2656 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
2657 strWIDList[0].enuWIDtype = WID_CHAR;
2658 strWIDList[0].s32ValueSize = sizeof(char);
2659 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
2661 strWIDList[1].u16WIDid = (u16)WID_ADD_PTK;
2662 strWIDList[1].enuWIDtype = WID_STR;
2663 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
2664 strWIDList[1].s32ValueSize = PTK_KEY_MSG_LEN + 1;
2666 s32Error = send_config_pkt(SET_CFG, strWIDList, 2, true,
2667 get_id_from_handler(pstrWFIDrv));
2670 /* ////////////////////////// */
2671 up(&(pstrWFIDrv->hSemTestKeyBlock));
2672 /* ///////////////////////// */
2674 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2677 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
2681 if (pu8keybuf == NULL) {
2682 PRINT_ER("No buffer to send PTK Key\n");
2684 goto _WPAPtk_end_case_;
2688 /*|-----------------------------------------------------------------------------|
2689 * |Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
2690 * |----------------|------------|--------------|----------------|---------------|
2691 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
2692 |-----------------------------------------------------------------------------|*/
2694 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
2696 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2698 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2699 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2702 strWID.u16WIDid = (u16)WID_ADD_PTK;
2703 strWID.enuWIDtype = WID_STR;
2704 strWID.ps8WidVal = (s8 *)pu8keybuf;
2705 strWID.s32ValueSize = PTK_KEY_MSG_LEN;
2707 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2708 get_id_from_handler(pstrWFIDrv));
2711 /* ////////////////////////// */
2712 up(&(pstrWFIDrv->hSemTestKeyBlock));
2713 /* ///////////////////////// */
2717 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
2726 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
2728 pu8keybuf = kmalloc((pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
2729 if (pu8keybuf == NULL) {
2730 PRINT_ER("No buffer to send PMKSA Key\n");
2734 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid;
2736 for (i = 0; i < pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid; i++) {
2738 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, ETH_ALEN);
2739 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, PMKID_LEN);
2742 strWID.u16WIDid = (u16)WID_PMKID_INFO;
2743 strWID.enuWIDtype = WID_STR;
2744 strWID.ps8WidVal = (s8 *)pu8keybuf;
2745 strWID.s32ValueSize = (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1;
2747 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2748 get_id_from_handler(pstrWFIDrv));
2755 PRINT_ER("Failed to send key config packet\n");
2763 * @brief Handle_Disconnect
2764 * @details Sending config packet to firmware to disconnect
2771 static void Handle_Disconnect(tstrWILC_WFIDrv *drvHandler)
2776 u16 u16DummyReasonCode = 0;
2777 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2780 strWID.u16WIDid = (u16)WID_DISCONNECT;
2781 strWID.enuWIDtype = WID_CHAR;
2782 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
2783 strWID.s32ValueSize = sizeof(char);
2787 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2789 g_obtainingIP = false;
2790 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
2792 memset(u8ConnectedSSID, 0, ETH_ALEN);
2794 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
2795 get_id_from_handler(pstrWFIDrv));
2798 PRINT_ER("Failed to send dissconect config packet\n");
2800 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2802 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
2804 strDisconnectNotifInfo.u16reason = 0;
2805 strDisconnectNotifInfo.ie = NULL;
2806 strDisconnectNotifInfo.ie_len = 0;
2808 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2809 del_timer(&pstrWFIDrv->hScanTimer);
2810 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
2811 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2813 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
2816 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2818 /*Stop connect timer, if connection in progress*/
2819 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2820 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
2821 del_timer(&pstrWFIDrv->hConnectTimer);
2824 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
2825 0, &strDisconnectNotifInfo, pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2827 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
2830 gbScanWhileConnected = false;
2832 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2834 memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
2838 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2839 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
2840 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
2841 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2844 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2845 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
2846 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2849 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2850 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2851 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
2852 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2856 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
2857 kfree(gu8FlushedJoinReq);
2858 gu8FlushedJoinReq = NULL;
2860 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
2861 kfree(gu8FlushedInfoElemAsoc);
2862 gu8FlushedInfoElemAsoc = NULL;
2867 /* ////////////////////////// */
2868 up(&(pstrWFIDrv->hSemTestDisconnectBlock));
2869 /* ///////////////////////// */
2874 void resolve_disconnect_aberration(tstrWILC_WFIDrv *drvHandler)
2876 tstrWILC_WFIDrv *pstrWFIDrv;
2878 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2879 if (pstrWFIDrv == NULL)
2881 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTING)) {
2882 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
2883 host_int_disconnect(pstrWFIDrv, 1);
2888 * @brief Handle_GetChnl
2889 * @details Sending config packet to get channel
2897 static s32 Handle_GetChnl(tstrWILC_WFIDrv *drvHandler)
2902 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
2903 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2905 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
2906 strWID.enuWIDtype = WID_CHAR;
2907 strWID.ps8WidVal = (s8 *)&gu8Chnl;
2908 strWID.s32ValueSize = sizeof(char);
2910 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
2912 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
2913 get_id_from_handler(pstrWFIDrv));
2914 /*get the value by searching the local copy*/
2916 PRINT_ER("Failed to get channel number\n");
2920 up(&(pstrWFIDrv->hSemGetCHNL));
2930 * @brief Handle_GetRssi
2931 * @details Sending config packet to get RSSI
2938 static void Handle_GetRssi(tstrWILC_WFIDrv *drvHandler)
2942 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2944 strWID.u16WIDid = (u16)WID_RSSI;
2945 strWID.enuWIDtype = WID_CHAR;
2946 strWID.ps8WidVal = &gs8Rssi;
2947 strWID.s32ValueSize = sizeof(char);
2950 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
2952 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
2953 get_id_from_handler(pstrWFIDrv));
2955 PRINT_ER("Failed to get RSSI value\n");
2959 up(&(pstrWFIDrv->hSemGetRSSI));
2965 static void Handle_GetLinkspeed(tstrWILC_WFIDrv *drvHandler)
2969 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2973 strWID.u16WIDid = (u16)WID_LINKSPEED;
2974 strWID.enuWIDtype = WID_CHAR;
2975 strWID.ps8WidVal = &gs8lnkspd;
2976 strWID.s32ValueSize = sizeof(char);
2978 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
2980 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
2981 get_id_from_handler(pstrWFIDrv));
2983 PRINT_ER("Failed to get LINKSPEED value\n");
2987 up(&(pstrWFIDrv->hSemGetLINKSPEED));
2992 s32 Handle_GetStatistics(tstrWILC_WFIDrv *drvHandler, tstrStatistics *pstrStatistics)
2994 tstrWID strWIDList[5];
2995 u32 u32WidsCount = 0, s32Error = 0;
2997 strWIDList[u32WidsCount].u16WIDid = WID_LINKSPEED;
2998 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
2999 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
3000 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u8LinkSpeed));
3003 strWIDList[u32WidsCount].u16WIDid = WID_RSSI;
3004 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
3005 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
3006 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->s8RSSI));
3009 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
3010 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
3011 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
3012 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxCount));
3015 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
3016 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
3017 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
3018 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32RxCount));
3021 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
3022 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
3023 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
3024 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxFailureCount));
3027 s32Error = send_config_pkt(GET_CFG, strWIDList, u32WidsCount, false,
3028 get_id_from_handler(drvHandler));
3031 PRINT_ER("Failed to send scan paramters config packet\n");
3039 * @brief Handle_Get_InActiveTime
3040 * @details Sending config packet to set mac adddress for station and
3049 static s32 Handle_Get_InActiveTime(tstrWILC_WFIDrv *drvHandler,
3050 struct sta_inactive_t *strHostIfStaInactiveT)
3056 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3059 strWID.u16WIDid = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
3060 strWID.enuWIDtype = WID_STR;
3061 strWID.s32ValueSize = ETH_ALEN;
3062 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
3065 stamac = strWID.ps8WidVal;
3066 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
3069 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
3072 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3073 get_id_from_handler(pstrWFIDrv));
3074 /*get the value by searching the local copy*/
3076 PRINT_ER("Failed to SET incative time\n");
3081 strWID.u16WIDid = (u16)WID_GET_INACTIVE_TIME;
3082 strWID.enuWIDtype = WID_INT;
3083 strWID.ps8WidVal = (s8 *)&gu32InactiveTime;
3084 strWID.s32ValueSize = sizeof(u32);
3087 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
3088 get_id_from_handler(pstrWFIDrv));
3089 /*get the value by searching the local copy*/
3091 PRINT_ER("Failed to get incative time\n");
3096 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
3098 up(&(pstrWFIDrv->hSemInactiveTime));
3108 * @brief Handle_AddBeacon
3109 * @details Sending config packet to add beacon
3110 * @param[in] struct beacon_attr *pstrSetBeaconParam
3116 static void Handle_AddBeacon(tstrWILC_WFIDrv *drvHandler,
3117 struct beacon_attr *pstrSetBeaconParam)
3122 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3124 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
3126 strWID.u16WIDid = (u16)WID_ADD_BEACON;
3127 strWID.enuWIDtype = WID_BIN;
3128 strWID.s32ValueSize = pstrSetBeaconParam->u32HeadLen + pstrSetBeaconParam->u32TailLen + 16;
3129 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
3130 if (strWID.ps8WidVal == NULL)
3133 pu8CurrByte = strWID.ps8WidVal;
3134 *pu8CurrByte++ = (pstrSetBeaconParam->u32Interval & 0xFF);
3135 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 8) & 0xFF);
3136 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 16) & 0xFF);
3137 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 24) & 0xFF);
3139 *pu8CurrByte++ = (pstrSetBeaconParam->u32DTIMPeriod & 0xFF);
3140 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 8) & 0xFF);
3141 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 16) & 0xFF);
3142 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 24) & 0xFF);
3144 *pu8CurrByte++ = (pstrSetBeaconParam->u32HeadLen & 0xFF);
3145 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 8) & 0xFF);
3146 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 16) & 0xFF);
3147 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 24) & 0xFF);
3149 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Head, pstrSetBeaconParam->u32HeadLen);
3150 pu8CurrByte += pstrSetBeaconParam->u32HeadLen;
3152 *pu8CurrByte++ = (pstrSetBeaconParam->u32TailLen & 0xFF);
3153 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 8) & 0xFF);
3154 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 16) & 0xFF);
3155 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 24) & 0xFF);
3157 if (pstrSetBeaconParam->pu8Tail > 0)
3158 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Tail, pstrSetBeaconParam->u32TailLen);
3159 pu8CurrByte += pstrSetBeaconParam->u32TailLen;
3164 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3165 get_id_from_handler(pstrWFIDrv));
3167 PRINT_ER("Failed to send add beacon config packet\n");
3170 kfree(strWID.ps8WidVal);
3171 kfree(pstrSetBeaconParam->pu8Head);
3172 kfree(pstrSetBeaconParam->pu8Tail);
3177 * @brief Handle_AddBeacon
3178 * @details Sending config packet to delete beacon
3179 * @param[in] tstrWILC_WFIDrv *drvHandler
3185 static void Handle_DelBeacon(tstrWILC_WFIDrv *drvHandler)
3190 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3192 strWID.u16WIDid = (u16)WID_DEL_BEACON;
3193 strWID.enuWIDtype = WID_CHAR;
3194 strWID.s32ValueSize = sizeof(char);
3195 strWID.ps8WidVal = &gu8DelBcn;
3197 if (strWID.ps8WidVal == NULL)
3200 pu8CurrByte = strWID.ps8WidVal;
3202 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
3203 /* TODO: build del beacon message*/
3206 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3207 get_id_from_handler(pstrWFIDrv));
3209 PRINT_ER("Failed to send delete beacon config packet\n");
3214 * @brief WILC_HostIf_PackStaParam
3215 * @details Handling packing of the station params in a buffer
3216 * @param[in] u8* pu8Buffer, struct add_sta_param *pstrStationParam
3222 static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
3223 struct add_sta_param *pstrStationParam)
3227 pu8CurrByte = pu8Buffer;
3229 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
3230 memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
3231 pu8CurrByte += ETH_ALEN;
3233 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
3234 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
3236 *pu8CurrByte++ = pstrStationParam->u8NumRates;
3237 if (pstrStationParam->u8NumRates > 0)
3238 memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
3239 pu8CurrByte += pstrStationParam->u8NumRates;
3241 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
3242 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
3243 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
3245 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
3246 memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
3247 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
3249 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
3250 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
3252 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
3253 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
3254 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
3255 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
3257 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
3259 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
3260 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
3262 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
3263 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
3265 return pu8CurrByte - pu8Buffer;
3269 * @brief Handle_AddStation
3270 * @details Sending config packet to add station
3271 * @param[in] struct add_sta_param *pstrStationParam
3277 static void Handle_AddStation(tstrWILC_WFIDrv *drvHandler,
3278 struct add_sta_param *pstrStationParam)
3283 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3285 PRINT_D(HOSTINF_DBG, "Handling add station\n");
3286 strWID.u16WIDid = (u16)WID_ADD_STA;
3287 strWID.enuWIDtype = WID_BIN;
3288 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3290 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
3291 if (strWID.ps8WidVal == NULL)
3294 pu8CurrByte = strWID.ps8WidVal;
3295 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3298 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3299 get_id_from_handler(pstrWFIDrv));
3301 PRINT_ER("Failed to send add station config packet\n");
3304 kfree(pstrStationParam->pu8Rates);
3305 kfree(strWID.ps8WidVal);
3309 * @brief Handle_DelAllSta
3310 * @details Sending config packet to delete station
3311 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3317 static void Handle_DelAllSta(tstrWILC_WFIDrv *drvHandler,
3318 struct del_all_sta *pstrDelAllStaParam)
3324 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3326 u8 au8Zero_Buff[6] = {0};
3328 strWID.u16WIDid = (u16)WID_DEL_ALL_STA;
3329 strWID.enuWIDtype = WID_STR;
3330 strWID.s32ValueSize = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1;
3332 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
3334 strWID.ps8WidVal = kmalloc((pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1, GFP_KERNEL);
3335 if (strWID.ps8WidVal == NULL)
3338 pu8CurrByte = strWID.ps8WidVal;
3340 *(pu8CurrByte++) = pstrDelAllStaParam->u8Num_AssocSta;
3342 for (i = 0; i < MAX_NUM_STA; i++) {
3343 if (memcmp(pstrDelAllStaParam->au8Sta_DelAllSta[i], au8Zero_Buff, ETH_ALEN))
3344 memcpy(pu8CurrByte, pstrDelAllStaParam->au8Sta_DelAllSta[i], ETH_ALEN);
3348 pu8CurrByte += ETH_ALEN;
3352 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3353 get_id_from_handler(pstrWFIDrv));
3355 PRINT_ER("Failed to send add station config packet\n");
3358 kfree(strWID.ps8WidVal);
3365 * @brief Handle_DelStation
3366 * @details Sending config packet to delete station
3367 * @param[in] struct del_sta *pstrDelStaParam
3373 static void Handle_DelStation(tstrWILC_WFIDrv *drvHandler,
3374 struct del_sta *pstrDelStaParam)
3379 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3381 strWID.u16WIDid = (u16)WID_REMOVE_STA;
3382 strWID.enuWIDtype = WID_BIN;
3383 strWID.s32ValueSize = ETH_ALEN;
3385 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
3387 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
3388 if (strWID.ps8WidVal == NULL)
3391 pu8CurrByte = strWID.ps8WidVal;
3393 memcpy(pu8CurrByte, pstrDelStaParam->au8MacAddr, ETH_ALEN);
3396 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3397 get_id_from_handler(pstrWFIDrv));
3399 PRINT_ER("Failed to send add station config packet\n");
3402 kfree(strWID.ps8WidVal);
3407 * @brief Handle_EditStation
3408 * @details Sending config packet to edit station
3409 * @param[in] struct add_sta_param *pstrStationParam
3415 static void Handle_EditStation(tstrWILC_WFIDrv *drvHandler,
3416 struct add_sta_param *pstrStationParam)
3421 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3423 strWID.u16WIDid = (u16)WID_EDIT_STA;
3424 strWID.enuWIDtype = WID_BIN;
3425 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3427 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
3428 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
3429 if (strWID.ps8WidVal == NULL)
3432 pu8CurrByte = strWID.ps8WidVal;
3433 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3436 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3437 get_id_from_handler(pstrWFIDrv));
3439 PRINT_ER("Failed to send edit station config packet\n");
3442 kfree(pstrStationParam->pu8Rates);
3443 kfree(strWID.ps8WidVal);
3447 * @brief Handle_RemainOnChan
3448 * @details Sending config packet to edit station
3449 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3455 static int Handle_RemainOnChan(tstrWILC_WFIDrv *drvHandler,
3456 struct remain_ch *pstrHostIfRemainOnChan)
3459 u8 u8remain_on_chan_flag;
3461 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3463 /*If it's a pendig remain-on-channel, don't overwrite gWFiDrvHandle values (since incoming msg is garbbage)*/
3464 if (!pstrWFIDrv->u8RemainOnChan_pendingreq) {
3465 pstrWFIDrv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
3466 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
3467 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
3468 pstrWFIDrv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
3469 pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
3471 /*Set the channel to use it as a wid val*/
3472 pstrHostIfRemainOnChan->u16Channel = pstrWFIDrv->strHostIfRemainOnChan.u16Channel;
3475 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
3476 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
3477 pstrWFIDrv->u8RemainOnChan_pendingreq = 1;
3481 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3482 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
3487 if (g_obtainingIP || connecting) {
3488 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
3493 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
3495 u8remain_on_chan_flag = true;
3496 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
3497 strWID.enuWIDtype = WID_STR;
3498 strWID.s32ValueSize = 2;
3499 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
3501 if (strWID.ps8WidVal == NULL) {
3506 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
3507 strWID.ps8WidVal[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
3510 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3511 get_id_from_handler(pstrWFIDrv));
3513 PRINT_ER("Failed to set remain on channel\n");
3517 P2P_LISTEN_STATE = 1;
3518 pstrWFIDrv->hRemainOnChannel.data = (unsigned long)pstrWFIDrv;
3519 mod_timer(&pstrWFIDrv->hRemainOnChannel,
3521 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
3523 /*Calling CFG ready_on_channel*/
3524 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady)
3525 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady(pstrWFIDrv->strHostIfRemainOnChan.pVoid);
3527 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
3528 pstrWFIDrv->u8RemainOnChan_pendingreq = 0;
3534 * @brief Handle_RegisterFrame
3542 static int Handle_RegisterFrame(tstrWILC_WFIDrv *drvHandler,
3543 struct reg_frame *pstrHostIfRegisterFrame)
3548 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3550 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
3552 /*prepare configuration packet*/
3553 strWID.u16WIDid = (u16)WID_REGISTER_FRAME;
3554 strWID.enuWIDtype = WID_STR;
3555 strWID.ps8WidVal = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
3556 if (strWID.ps8WidVal == NULL)
3559 pu8CurrByte = strWID.ps8WidVal;
3561 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
3562 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
3563 memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
3566 strWID.s32ValueSize = sizeof(u16) + 2;
3570 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3571 get_id_from_handler(pstrWFIDrv));
3573 PRINT_ER("Failed to frame register config packet\n");
3582 * @brief Handle_ListenStateExpired
3583 * @details Handle of listen state expiration
3585 * @return Error code.
3590 #define FALSE_FRMWR_CHANNEL 100
3591 static u32 Handle_ListenStateExpired(tstrWILC_WFIDrv *drvHandler,
3592 struct remain_ch *pstrHostIfRemainOnChan)
3594 u8 u8remain_on_chan_flag;
3597 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3599 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
3601 /*Make sure we are already in listen state*/
3602 /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/
3603 if (P2P_LISTEN_STATE) {
3604 u8remain_on_chan_flag = false;
3605 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
3606 strWID.enuWIDtype = WID_STR;
3607 strWID.s32ValueSize = 2;
3608 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
3610 if (strWID.ps8WidVal == NULL)
3611 PRINT_ER("Failed to allocate memory\n");
3613 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
3614 strWID.ps8WidVal[1] = FALSE_FRMWR_CHANNEL;
3617 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3618 get_id_from_handler(pstrWFIDrv));
3619 if (s32Error != 0) {
3620 PRINT_ER("Failed to set remain on channel\n");
3624 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired) {
3625 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired(pstrWFIDrv->strHostIfRemainOnChan.pVoid
3626 , pstrHostIfRemainOnChan->u32ListenSessionID);
3628 P2P_LISTEN_STATE = 0;
3630 PRINT_D(GENERIC_DBG, "Not in listen state\n");
3640 * @brief ListenTimerCB
3641 * @details Callback function of remain-on-channel timer
3643 * @return Error code.
3648 static void ListenTimerCB(unsigned long arg)
3651 struct host_if_msg msg;
3652 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)arg;
3653 /*Stopping remain-on-channel timer*/
3654 del_timer(&pstrWFIDrv->hRemainOnChannel);
3656 /* prepare the Timer Callback message */
3657 memset(&msg, 0, sizeof(struct host_if_msg));
3658 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
3659 msg.drvHandler = pstrWFIDrv;
3660 msg.body.remain_on_ch.u32ListenSessionID = pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID;
3662 /* send the message */
3663 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3665 PRINT_ER("wilc_mq_send fail\n");
3669 * @brief Handle_EditStation
3670 * @details Sending config packet to edit station
3671 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3677 static void Handle_PowerManagement(tstrWILC_WFIDrv *drvHandler,
3678 struct power_mgmt_param *strPowerMgmtParam)
3683 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3685 strWID.u16WIDid = (u16)WID_POWER_MANAGEMENT;
3687 if (strPowerMgmtParam->bIsEnabled == true)
3688 s8PowerMode = MIN_FAST_PS;
3690 s8PowerMode = NO_POWERSAVE;
3691 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
3692 strWID.ps8WidVal = &s8PowerMode;
3693 strWID.s32ValueSize = sizeof(char);
3695 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
3698 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3699 get_id_from_handler(pstrWFIDrv));
3701 PRINT_ER("Failed to send power management config packet\n");
3705 * @brief Handle_SetMulticastFilter
3706 * @details Set Multicast filter in firmware
3707 * @param[in] struct set_multicast *strHostIfSetMulti
3713 static void Handle_SetMulticastFilter(tstrWILC_WFIDrv *drvHandler,
3714 struct set_multicast *strHostIfSetMulti)
3720 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
3722 strWID.u16WIDid = (u16)WID_SETUP_MULTICAST_FILTER;
3723 strWID.enuWIDtype = WID_BIN;
3724 strWID.s32ValueSize = sizeof(struct set_multicast) + ((strHostIfSetMulti->u32count) * ETH_ALEN);
3725 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
3726 if (strWID.ps8WidVal == NULL)
3729 pu8CurrByte = strWID.ps8WidVal;
3730 *pu8CurrByte++ = (strHostIfSetMulti->bIsEnabled & 0xFF);
3731 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 8) & 0xFF);
3732 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 16) & 0xFF);
3733 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 24) & 0xFF);
3735 *pu8CurrByte++ = (strHostIfSetMulti->u32count & 0xFF);
3736 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 8) & 0xFF);
3737 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 16) & 0xFF);
3738 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 24) & 0xFF);
3740 if ((strHostIfSetMulti->u32count) > 0)
3741 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->u32count) * ETH_ALEN));
3744 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3745 get_id_from_handler(drvHandler));
3747 PRINT_ER("Failed to send setup multicast config packet\n");
3750 kfree(strWID.ps8WidVal);
3756 * @brief Handle_AddBASession
3757 * @details Add block ack session
3758 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
3760 * @author Amr Abdel-Moghny
3764 static s32 Handle_AddBASession(tstrWILC_WFIDrv *drvHandler,
3765 struct ba_session_info *strHostIfBASessionInfo)
3769 int AddbaTimeout = 100;
3771 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3773 PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\nBufferSize == %d\nSessionTimeOut = %d\n",
3774 strHostIfBASessionInfo->au8Bssid[0],
3775 strHostIfBASessionInfo->au8Bssid[1],
3776 strHostIfBASessionInfo->au8Bssid[2],
3777 strHostIfBASessionInfo->u16BufferSize,
3778 strHostIfBASessionInfo->u16SessionTimeout,
3779 strHostIfBASessionInfo->u8Ted);
3781 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
3782 strWID.enuWIDtype = WID_STR;
3783 strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
3784 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
3785 ptr = strWID.ps8WidVal;
3786 /* *ptr++ = 0x14; */
3790 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
3792 *ptr++ = strHostIfBASessionInfo->u8Ted;
3796 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
3797 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
3799 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
3800 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
3802 *ptr++ = (AddbaTimeout & 0xFF);
3803 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
3804 /* Group Buffer Max Frames*/
3806 /* Group Buffer Timeout */
3809 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3810 get_id_from_handler(pstrWFIDrv));
3812 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
3815 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
3816 strWID.enuWIDtype = WID_STR;
3817 strWID.s32ValueSize = 15;
3818 ptr = strWID.ps8WidVal;
3819 /* *ptr++ = 0x14; */
3823 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
3826 *ptr++ = strHostIfBASessionInfo->u8Ted;
3830 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
3831 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
3834 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3835 get_id_from_handler(pstrWFIDrv));
3837 if (strWID.ps8WidVal != NULL)
3838 kfree(strWID.ps8WidVal);
3845 * @brief Handle_DelAllRxBASessions
3846 * @details Delete all Rx BA sessions
3847 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
3849 * @author Abdelrahman Sobhy
3853 static s32 Handle_DelAllRxBASessions(tstrWILC_WFIDrv *drvHandler,
3854 struct ba_session_info *strHostIfBASessionInfo)
3859 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3861 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
3862 strHostIfBASessionInfo->au8Bssid[0],
3863 strHostIfBASessionInfo->au8Bssid[1],
3864 strHostIfBASessionInfo->au8Bssid[2],
3865 strHostIfBASessionInfo->u8Ted);
3867 strWID.u16WIDid = (u16)WID_DEL_ALL_RX_BA;
3868 strWID.enuWIDtype = WID_STR;
3869 strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
3870 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
3871 ptr = strWID.ps8WidVal;
3875 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
3877 *ptr++ = strHostIfBASessionInfo->u8Ted;
3878 /* BA direction = recipent*/
3881 *ptr++ = 32; /* Unspecific QOS reason */
3883 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3884 get_id_from_handler(pstrWFIDrv));
3886 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
3889 if (strWID.ps8WidVal != NULL)
3890 kfree(strWID.ps8WidVal);
3899 * @brief hostIFthread
3900 * @details Main thread to handle message queue requests
3901 * @param[in] void* pvArg
3907 static int hostIFthread(void *pvArg)
3910 struct host_if_msg msg;
3911 tstrWILC_WFIDrv *pstrWFIDrv;
3913 memset(&msg, 0, sizeof(struct host_if_msg));
3916 wilc_mq_recv(&gMsgQHostIF, &msg, sizeof(struct host_if_msg), &u32Ret);
3917 pstrWFIDrv = (tstrWILC_WFIDrv *)msg.drvHandler;
3918 if (msg.id == HOST_IF_MSG_EXIT) {
3919 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
3924 /*Re-Queue HIF message*/
3925 if ((!g_wilc_initialized)) {
3926 PRINT_D(GENERIC_DBG, "--WAIT--");
3927 usleep_range(200 * 1000, 200 * 1000);
3928 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3932 if (msg.id == HOST_IF_MSG_CONNECT && pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
3933 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
3934 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3935 usleep_range(2 * 1000, 2 * 1000);
3940 case HOST_IF_MSG_Q_IDLE:
3941 Handle_wait_msg_q_empty();
3944 case HOST_IF_MSG_SCAN:
3945 Handle_Scan(msg.drvHandler, &msg.body.scan_info);
3948 case HOST_IF_MSG_CONNECT:
3949 Handle_Connect(msg.drvHandler, &msg.body.con_info);
3952 case HOST_IF_MSG_FLUSH_CONNECT:
3953 Handle_FlushConnect(msg.drvHandler);
3956 case HOST_IF_MSG_RCVD_NTWRK_INFO:
3957 Handle_RcvdNtwrkInfo(msg.drvHandler, &msg.body.net_info);
3960 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
3961 Handle_RcvdGnrlAsyncInfo(msg.drvHandler, &msg.body.async_info);
3964 case HOST_IF_MSG_KEY:
3965 Handle_Key(msg.drvHandler, &msg.body.key_info);
3968 case HOST_IF_MSG_CFG_PARAMS:
3970 Handle_CfgParam(msg.drvHandler, &msg.body.cfg_info);
3973 case HOST_IF_MSG_SET_CHANNEL:
3974 Handle_SetChannel(msg.drvHandler, &msg.body.channel_info);
3977 case HOST_IF_MSG_DISCONNECT:
3978 Handle_Disconnect(msg.drvHandler);
3981 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
3982 del_timer(&pstrWFIDrv->hScanTimer);
3983 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
3985 /*Allow chip sleep, only if both interfaces are not connected*/
3986 if (!linux_wlan_get_num_conn_ifcs())
3987 chip_sleep_manually(INFINITE_SLEEP_TIME);
3989 Handle_ScanDone(msg.drvHandler, SCAN_EVENT_DONE);
3991 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
3992 Handle_RemainOnChan(msg.drvHandler, &msg.body.remain_on_ch);
3996 case HOST_IF_MSG_GET_RSSI:
3997 Handle_GetRssi(msg.drvHandler);
4000 case HOST_IF_MSG_GET_LINKSPEED:
4001 Handle_GetLinkspeed(msg.drvHandler);
4004 case HOST_IF_MSG_GET_STATISTICS:
4005 Handle_GetStatistics(msg.drvHandler, (tstrStatistics *)msg.body.data);
4008 case HOST_IF_MSG_GET_CHNL:
4009 Handle_GetChnl(msg.drvHandler);
4012 case HOST_IF_MSG_ADD_BEACON:
4013 Handle_AddBeacon(msg.drvHandler, &msg.body.beacon_info);
4016 case HOST_IF_MSG_DEL_BEACON:
4017 Handle_DelBeacon(msg.drvHandler);
4020 case HOST_IF_MSG_ADD_STATION:
4021 Handle_AddStation(msg.drvHandler, &msg.body.add_sta_info);
4024 case HOST_IF_MSG_DEL_STATION:
4025 Handle_DelStation(msg.drvHandler, &msg.body.del_sta_info);
4028 case HOST_IF_MSG_EDIT_STATION:
4029 Handle_EditStation(msg.drvHandler, &msg.body.edit_sta_info);
4032 case HOST_IF_MSG_GET_INACTIVETIME:
4033 Handle_Get_InActiveTime(msg.drvHandler, &msg.body.mac_info);
4036 case HOST_IF_MSG_SCAN_TIMER_FIRED:
4037 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
4039 Handle_ScanDone(msg.drvHandler, SCAN_EVENT_ABORTED);
4042 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
4043 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
4044 Handle_ConnectTimeout(msg.drvHandler);
4047 case HOST_IF_MSG_POWER_MGMT:
4048 Handle_PowerManagement(msg.drvHandler, &msg.body.pwr_mgmt_info);
4051 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
4052 Handle_SetWfiDrvHandler(msg.drvHandler,
4056 case HOST_IF_MSG_SET_OPERATION_MODE:
4057 Handle_SetOperationMode(msg.drvHandler, &msg.body.mode);
4060 case HOST_IF_MSG_SET_IPADDRESS:
4061 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
4062 Handle_set_IPAddress(msg.drvHandler, msg.body.ip_info.au8IPAddr, msg.body.ip_info.idx);
4065 case HOST_IF_MSG_GET_IPADDRESS:
4066 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
4067 Handle_get_IPAddress(msg.drvHandler, msg.body.ip_info.au8IPAddr, msg.body.ip_info.idx);
4070 case HOST_IF_MSG_SET_MAC_ADDRESS:
4071 Handle_SetMacAddress(msg.drvHandler, &msg.body.set_mac_info);
4074 case HOST_IF_MSG_GET_MAC_ADDRESS:
4075 Handle_GetMacAddress(msg.drvHandler, &msg.body.get_mac_info);
4078 case HOST_IF_MSG_REMAIN_ON_CHAN:
4079 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
4080 Handle_RemainOnChan(msg.drvHandler, &msg.body.remain_on_ch);
4083 case HOST_IF_MSG_REGISTER_FRAME:
4084 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
4085 Handle_RegisterFrame(msg.drvHandler, &msg.body.reg_frame);
4088 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
4089 Handle_ListenStateExpired(msg.drvHandler, &msg.body.remain_on_ch);
4092 case HOST_IF_MSG_SET_MULTICAST_FILTER:
4093 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
4094 Handle_SetMulticastFilter(msg.drvHandler, &msg.body.multicast_info);
4097 case HOST_IF_MSG_ADD_BA_SESSION:
4098 Handle_AddBASession(msg.drvHandler, &msg.body.session_info);
4101 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
4102 Handle_DelAllRxBASessions(msg.drvHandler, &msg.body.session_info);
4105 case HOST_IF_MSG_DEL_ALL_STA:
4106 Handle_DelAllSta(msg.drvHandler, &msg.body.del_all_sta_info);
4110 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
4115 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
4116 up(&hSemHostIFthrdEnd);
4120 static void TimerCB_Scan(unsigned long arg)
4122 void *pvArg = (void *)arg;
4123 struct host_if_msg msg;
4125 /* prepare the Timer Callback message */
4126 memset(&msg, 0, sizeof(struct host_if_msg));
4127 msg.drvHandler = pvArg;
4128 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
4130 /* send the message */
4131 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4134 static void TimerCB_Connect(unsigned long arg)
4136 void *pvArg = (void *)arg;
4137 struct host_if_msg msg;
4139 /* prepare the Timer Callback message */
4140 memset(&msg, 0, sizeof(struct host_if_msg));
4141 msg.drvHandler = pvArg;
4142 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
4144 /* send the message */
4145 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4150 * @brief removes wpa/wpa2 keys
4151 * @details only in BSS STA mode if External Supplicant support is enabled.
4152 * removes all WPA/WPA2 station key entries from MAC hardware.
4153 * @param[in,out] handle to the wifi driver
4154 * @param[in] 6 bytes of Station Adress in the station entry table
4155 * @return Error code indicating success/failure
4158 * @date 8 March 2012
4161 /* Check implementation in core adding 9 bytes to the input! */
4162 s32 host_int_remove_key(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8StaAddress)
4166 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4168 strWID.u16WIDid = (u16)WID_REMOVE_KEY;
4169 strWID.enuWIDtype = WID_STR;
4170 strWID.ps8WidVal = (s8 *)pu8StaAddress;
4171 strWID.s32ValueSize = 6;
4178 * @brief removes WEP key
4179 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4180 * remove a WEP key entry from MAC HW.
4181 * The BSS Station automatically finds the index of the entry using its
4182 * BSS ID and removes that entry from the MAC hardware.
4183 * @param[in,out] handle to the wifi driver
4184 * @param[in] 6 bytes of Station Adress in the station entry table
4185 * @return Error code indicating success/failure
4186 * @note NO need for the STA add since it is not used for processing
4188 * @date 8 March 2012
4191 int host_int_remove_wep_key(tstrWILC_WFIDrv *wfi_drv, u8 index)
4194 struct host_if_msg msg;
4197 if (wfi_drv == NULL) {
4199 PRINT_ER("Failed to send setup multicast config packet\n");
4203 /* prepare the Remove Wep Key Message */
4204 memset(&msg, 0, sizeof(struct host_if_msg));
4207 msg.id = HOST_IF_MSG_KEY;
4208 msg.body.key_info.enuKeyType = WEP;
4209 msg.body.key_info.u8KeyAction = REMOVEKEY;
4210 msg.drvHandler = wfi_drv;
4215 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = index;
4217 /* send the message */
4218 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4220 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
4221 down(&(wfi_drv->hSemTestKeyBlock));
4227 * @brief sets WEP default key
4228 * @details Sets the index of the WEP encryption key in use,
4230 * @param[in,out] handle to the wifi driver
4231 * @param[in] key index ( 0, 1, 2, 3)
4232 * @return Error code indicating success/failure
4235 * @date 8 March 2012
4238 s32 host_int_set_WEPDefaultKeyID(tstrWILC_WFIDrv *hWFIDrv, u8 u8Index)
4241 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4242 struct host_if_msg msg;
4245 if (pstrWFIDrv == NULL) {
4247 PRINT_ER("driver is null\n");
4251 /* prepare the Key Message */
4252 memset(&msg, 0, sizeof(struct host_if_msg));
4255 msg.id = HOST_IF_MSG_KEY;
4256 msg.body.key_info.enuKeyType = WEP;
4257 msg.body.key_info.u8KeyAction = DEFAULTKEY;
4258 msg.drvHandler = hWFIDrv;
4262 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Index;
4264 /* send the message */
4265 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4267 PRINT_ER("Error in sending message queue : Default key index\n");
4268 down(&(pstrWFIDrv->hSemTestKeyBlock));
4274 * @brief sets WEP deafault key
4275 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4276 * sets WEP key entry into MAC hardware when it receives the
4277 * corresponding request from NDIS.
4278 * @param[in,out] handle to the wifi driver
4279 * @param[in] message containing WEP Key in the following format
4280 *|---------------------------------------|
4281 *|Key ID Value | Key Length | Key |
4282 *|-------------|------------|------------|
4283 | 1byte | 1byte | Key Length |
4284 ||---------------------------------------|
4286 * @return Error code indicating success/failure
4289 * @date 8 March 2012
4292 s32 host_int_add_wep_key_bss_sta(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx)
4296 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4297 struct host_if_msg msg;
4299 if (pstrWFIDrv == NULL) {
4301 PRINT_ER("driver is null\n");
4305 /* prepare the Key Message */
4306 memset(&msg, 0, sizeof(struct host_if_msg));
4309 msg.id = HOST_IF_MSG_KEY;
4310 msg.body.key_info.enuKeyType = WEP;
4311 msg.body.key_info.u8KeyAction = ADDKEY;
4312 msg.drvHandler = hWFIDrv;
4316 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = kmalloc(u8WepKeylen, GFP_KERNEL);
4318 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
4319 pu8WepKey, u8WepKeylen);
4323 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4326 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4328 /* send the message */
4329 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4331 PRINT_ER("Error in sending message queue :WEP Key\n");
4332 down(&(pstrWFIDrv->hSemTestKeyBlock));
4340 * @brief host_int_add_wep_key_bss_ap
4341 * @details valid only in BSS AP mode if External Supplicant support is enabled.
4342 * sets WEP key entry into MAC hardware when it receives the
4344 * corresponding request from NDIS.
4345 * @param[in,out] handle to the wifi driver
4348 * @return Error code indicating success/failure
4354 s32 host_int_add_wep_key_bss_ap(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx, u8 u8mode, enum AUTHTYPE tenuAuth_type)
4358 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4359 struct host_if_msg msg;
4362 if (pstrWFIDrv == NULL) {
4364 PRINT_ER("driver is null\n");
4368 /* prepare the Key Message */
4369 memset(&msg, 0, sizeof(struct host_if_msg));
4372 for (i = 0; i < u8WepKeylen; i++)
4373 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
4375 msg.id = HOST_IF_MSG_KEY;
4376 msg.body.key_info.enuKeyType = WEP;
4377 msg.body.key_info.u8KeyAction = ADDKEY_AP;
4378 msg.drvHandler = hWFIDrv;
4382 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = kmalloc(u8WepKeylen, GFP_KERNEL);
4385 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
4386 pu8WepKey, (u8WepKeylen));
4390 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4393 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4396 uniHostIFkeyAttr.strHostIFwepAttr.u8mode = u8mode;
4399 uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type = tenuAuth_type;
4400 /* send the message */
4401 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4404 PRINT_ER("Error in sending message queue :WEP Key\n");
4405 down(&(pstrWFIDrv->hSemTestKeyBlock));
4412 * @brief adds ptk Key
4414 * @param[in,out] handle to the wifi driver
4415 * @param[in] message containing PTK Key in the following format
4416 *|-----------------------------------------------------------------------------|
4417 *|Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
4418 *|----------------|------------|--------------|----------------|---------------|
4419 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
4420 ||-----------------------------------------------------------------------------|
4421 * @return Error code indicating success/failure
4424 * @date 8 March 2012
4427 s32 host_int_add_ptk(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen,
4428 const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode, u8 u8Idx)
4431 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4432 struct host_if_msg msg;
4433 u8 u8KeyLen = u8PtkKeylen;
4436 if (pstrWFIDrv == NULL) {
4438 PRINT_ER("driver is null\n");
4441 if (pu8RxMic != NULL)
4442 u8KeyLen += RX_MIC_KEY_LEN;
4443 if (pu8TxMic != NULL)
4444 u8KeyLen += TX_MIC_KEY_LEN;
4446 /* prepare the Key Message */
4447 memset(&msg, 0, sizeof(struct host_if_msg));
4450 msg.id = HOST_IF_MSG_KEY;
4451 msg.body.key_info.enuKeyType = WPAPtk;
4452 if (mode == AP_MODE) {
4453 msg.body.key_info.u8KeyAction = ADDKEY_AP;
4455 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8Idx;
4457 if (mode == STATION_MODE)
4458 msg.body.key_info.u8KeyAction = ADDKEY;
4462 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = kmalloc(u8PtkKeylen, GFP_KERNEL);
4465 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
4466 pu8Ptk, u8PtkKeylen);
4468 if (pu8RxMic != NULL) {
4470 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
4471 pu8RxMic, RX_MIC_KEY_LEN);
4473 for (i = 0; i < RX_MIC_KEY_LEN; i++)
4474 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
4477 if (pu8TxMic != NULL) {
4479 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
4480 pu8TxMic, TX_MIC_KEY_LEN);
4482 for (i = 0; i < TX_MIC_KEY_LEN; i++)
4483 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
4488 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
4491 uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
4493 uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr = mac_addr;
4494 msg.drvHandler = hWFIDrv;
4496 /* send the message */
4497 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4500 PRINT_ER("Error in sending message queue: PTK Key\n");
4502 /* ////////////// */
4503 down(&(pstrWFIDrv->hSemTestKeyBlock));
4510 * @brief adds Rx GTk Key
4512 * @param[in,out] handle to the wifi driver
4513 * @param[in] pu8RxGtk : contains temporal key | Rx Mic | Tx Mic
4514 * u8GtkKeylen :The total key length
4516 * @return Error code indicating success/failure
4519 * @date 8 March 2012
4522 s32 host_int_add_rx_gtk(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen,
4523 u8 u8KeyIdx, u32 u32KeyRSClen, const u8 *KeyRSC,
4524 const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode)
4527 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4528 struct host_if_msg msg;
4529 u8 u8KeyLen = u8GtkKeylen;
4531 if (pstrWFIDrv == NULL) {
4533 PRINT_ER("driver is null\n");
4536 /* prepare the Key Message */
4537 memset(&msg, 0, sizeof(struct host_if_msg));
4540 if (pu8RxMic != NULL)
4541 u8KeyLen += RX_MIC_KEY_LEN;
4542 if (pu8TxMic != NULL)
4543 u8KeyLen += TX_MIC_KEY_LEN;
4544 if (KeyRSC != NULL) {
4546 uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq = kmalloc(u32KeyRSClen, GFP_KERNEL);
4548 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq,
4549 KeyRSC, u32KeyRSClen);
4553 msg.id = HOST_IF_MSG_KEY;
4554 msg.body.key_info.enuKeyType = WPARxGtk;
4555 msg.drvHandler = hWFIDrv;
4557 if (mode == AP_MODE) {
4558 msg.body.key_info.u8KeyAction = ADDKEY_AP;
4559 msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
4561 if (mode == STATION_MODE)
4562 msg.body.key_info.u8KeyAction = ADDKEY;
4566 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = kmalloc(u8KeyLen, GFP_KERNEL);
4568 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
4569 pu8RxGtk, u8GtkKeylen);
4571 if (pu8RxMic != NULL) {
4573 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
4574 pu8RxMic, RX_MIC_KEY_LEN);
4577 if (pu8TxMic != NULL) {
4579 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
4580 pu8TxMic, TX_MIC_KEY_LEN);
4585 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8KeyIdx;
4587 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
4590 uniHostIFkeyAttr.strHostIFwpaAttr.u8seqlen = u32KeyRSClen;
4594 /* send the message */
4595 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4597 PRINT_ER("Error in sending message queue: RX GTK\n");
4598 /* ////////////// */
4599 down(&(pstrWFIDrv->hSemTestKeyBlock));
4606 * @brief host_int_set_pmkid_info
4607 * @details caches the pmkid valid only in BSS STA mode if External Supplicant
4608 * support is enabled. This Function sets the PMKID in firmware
4609 * when host drivr receives the corresponding request from NDIS.
4610 * The firmware then includes theset PMKID in the appropriate
4612 * @param[in,out] handle to the wifi driver
4613 * @param[in] message containing PMKID Info in the following format
4614 *|-----------------------------------------------------------------|
4615 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
4616 *|-----------|------------|----------|-------|----------|----------|
4617 | 1 | 6 | 16 | ... | 6 | 16 |
4618 ||-----------------------------------------------------------------|
4619 * @return Error code indicating success/failure
4622 * @date 8 March 2012
4625 s32 host_int_set_pmkid_info(tstrWILC_WFIDrv *hWFIDrv, struct host_if_pmkid_attr *pu8PmkidInfoArray)
4628 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4629 struct host_if_msg msg;
4633 if (pstrWFIDrv == NULL) {
4635 PRINT_ER("driver is null\n");
4639 /* prepare the Key Message */
4640 memset(&msg, 0, sizeof(struct host_if_msg));
4642 msg.id = HOST_IF_MSG_KEY;
4643 msg.body.key_info.enuKeyType = PMKSA;
4644 msg.body.key_info.u8KeyAction = ADDKEY;
4645 msg.drvHandler = hWFIDrv;
4647 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
4649 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
4652 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
4656 /* send the message */
4657 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4659 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
4665 * @brief gets the cached the pmkid info
4666 * @details valid only in BSS STA mode if External Supplicant
4667 * support is enabled. This Function sets the PMKID in firmware
4668 * when host drivr receives the corresponding request from NDIS.
4669 * The firmware then includes theset PMKID in the appropriate
4671 * @param[in,out] handle to the wifi driver,
4672 * message containing PMKID Info in the following format
4673 *|-----------------------------------------------------------------|
4674 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
4675 *|-----------|------------|----------|-------|----------|----------|
4676 | 1 | 6 | 16 | ... | 6 | 16 |
4677 ||-----------------------------------------------------------------|
4679 * @return Error code indicating success/failure
4682 * @date 8 March 2012
4685 s32 host_int_get_pmkid_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8PmkidInfoArray,
4686 u32 u32PmkidInfoLen)
4690 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4692 strWID.u16WIDid = (u16)WID_PMKID_INFO;
4693 strWID.enuWIDtype = WID_STR;
4694 strWID.s32ValueSize = u32PmkidInfoLen;
4695 strWID.ps8WidVal = pu8PmkidInfoArray;
4701 * @brief sets the pass phrase
4702 * @details AP/STA mode. This function gives the pass phrase used to
4703 * generate the Pre-Shared Key when WPA/WPA2 is enabled
4704 * The length of the field can vary from 8 to 64 bytes,
4705 * the lower layer should get the
4706 * @param[in,out] handle to the wifi driver,
4707 * @param[in] String containing PSK
4708 * @return Error code indicating success/failure
4711 * @date 8 March 2012
4714 s32 host_int_set_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8PassPhrase,
4720 /*validating psk length*/
4721 if ((u8Psklength > 7) && (u8Psklength < 65)) {
4722 strWID.u16WIDid = (u16)WID_11I_PSK;
4723 strWID.enuWIDtype = WID_STR;
4724 strWID.ps8WidVal = pu8PassPhrase;
4725 strWID.s32ValueSize = u8Psklength;
4731 * @brief host_int_get_MacAddress
4732 * @details gets mac address
4733 * @param[in,out] handle to the wifi driver,
4735 * @return Error code indicating success/failure
4738 * @date 19 April 2012
4741 s32 host_int_get_MacAddress(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8MacAddress)
4744 struct host_if_msg msg;
4747 /* prepare the Message */
4748 memset(&msg, 0, sizeof(struct host_if_msg));
4750 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
4751 msg.body.get_mac_info.u8MacAddress = pu8MacAddress;
4752 msg.drvHandler = hWFIDrv;
4753 /* send the message */
4754 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4756 PRINT_ER("Failed to send get mac address\n");
4760 down(&hWaitResponse);
4765 * @brief host_int_set_MacAddress
4766 * @details sets mac address
4767 * @param[in,out] handle to the wifi driver,
4769 * @return Error code indicating success/failure
4772 * @date 16 July 2012
4775 s32 host_int_set_MacAddress(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8MacAddress)
4778 struct host_if_msg msg;
4780 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
4782 /* prepare setting mac address message */
4783 memset(&msg, 0, sizeof(struct host_if_msg));
4784 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
4785 memcpy(msg.body.set_mac_info.u8MacAddress, pu8MacAddress, ETH_ALEN);
4786 msg.drvHandler = hWFIDrv;
4788 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4790 PRINT_ER("Failed to send message queue: Set mac address\n");
4797 * @brief host_int_get_RSNAConfigPSKPassPhrase
4798 * @details gets the pass phrase:AP/STA mode. This function gets the pass phrase used to
4799 * generate the Pre-Shared Key when WPA/WPA2 is enabled
4800 * The length of the field can vary from 8 to 64 bytes,
4801 * the lower layer should get the
4802 * @param[in,out] handle to the wifi driver,
4803 * String containing PSK
4804 * @return Error code indicating success/failure
4807 * @date 8 March 2012
4810 s32 host_int_get_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv *hWFIDrv,
4811 u8 *pu8PassPhrase, u8 u8Psklength)
4815 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4817 strWID.u16WIDid = (u16)WID_11I_PSK;
4818 strWID.enuWIDtype = WID_STR;
4819 strWID.s32ValueSize = u8Psklength;
4820 strWID.ps8WidVal = pu8PassPhrase;
4826 * @brief sets a start scan request
4828 * @param[in,out] handle to the wifi driver,
4829 * @param[in] Scan Source one of the following values
4832 * OBSS_PERIODIC_SCAN BIT1
4833 * OBSS_ONETIME_SCAN BIT2
4834 * @return Error code indicating success/failure
4837 * @date 8 March 2012
4840 s32 host_int_set_start_scan_req(tstrWILC_WFIDrv *hWFIDrv, u8 scanSource)
4844 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4846 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
4847 strWID.enuWIDtype = WID_CHAR;
4848 strWID.ps8WidVal = (s8 *)&scanSource;
4849 strWID.s32ValueSize = sizeof(char);
4855 * @brief host_int_get_start_scan_req
4856 * @details gets a start scan request
4857 * @param[in,out] handle to the wifi driver,
4858 * @param[in] Scan Source one of the following values
4861 * OBSS_PERIODIC_SCAN BIT1
4862 * OBSS_ONETIME_SCAN BIT2
4863 * @return Error code indicating success/failure
4866 * @date 8 March 2012
4870 s32 host_int_get_start_scan_req(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8ScanSource)
4874 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4876 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
4877 strWID.enuWIDtype = WID_CHAR;
4878 strWID.ps8WidVal = (s8 *)pu8ScanSource;
4879 strWID.s32ValueSize = sizeof(char);
4885 * @brief host_int_set_join_req
4886 * @details sets a join request
4887 * @param[in,out] handle to the wifi driver,
4888 * @param[in] Index of the bss descriptor
4889 * @return Error code indicating success/failure
4892 * @date 8 March 2012
4895 s32 host_int_set_join_req(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8bssid,
4896 const u8 *pu8ssid, size_t ssidLen,
4897 const u8 *pu8IEs, size_t IEsLen,
4898 wilc_connect_result pfConnectResult, void *pvUserArg,
4899 u8 u8security, enum AUTHTYPE tenuAuth_type,
4904 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4905 struct host_if_msg msg;
4906 tenuScanConnTimer enuScanConnTimer;
4908 if (pstrWFIDrv == NULL || pfConnectResult == NULL) {
4910 PRINT_ER("Driver is null\n");
4914 if (hWFIDrv == NULL) {
4915 PRINT_ER("Driver is null\n");
4919 if (pJoinParams == NULL) {
4920 PRINT_ER("Unable to Join - JoinParams is NULL\n");
4924 /* prepare the Connect Message */
4925 memset(&msg, 0, sizeof(struct host_if_msg));
4927 msg.id = HOST_IF_MSG_CONNECT;
4929 msg.body.con_info.u8security = u8security;
4930 msg.body.con_info.tenuAuth_type = tenuAuth_type;
4931 msg.body.con_info.u8channel = u8channel;
4932 msg.body.con_info.pfConnectResult = pfConnectResult;
4933 msg.body.con_info.pvUserArg = pvUserArg;
4934 msg.body.con_info.pJoinParams = pJoinParams;
4935 msg.drvHandler = hWFIDrv;
4937 if (pu8bssid != NULL) {
4938 msg.body.con_info.pu8bssid = kmalloc(6, GFP_KERNEL); /* will be deallocated by the receiving thread */
4939 memcpy(msg.body.con_info.pu8bssid,
4943 if (pu8ssid != NULL) {
4944 msg.body.con_info.ssidLen = ssidLen;
4945 msg.body.con_info.pu8ssid = kmalloc(ssidLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
4946 memcpy(msg.body.con_info.pu8ssid,
4951 if (pu8IEs != NULL) {
4952 msg.body.con_info.IEsLen = IEsLen;
4953 msg.body.con_info.pu8IEs = kmalloc(IEsLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
4954 memcpy(msg.body.con_info.pu8IEs,
4957 if (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTING)
4958 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTING;
4960 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", pstrWFIDrv->enuHostIFstate);
4962 /* send the message */
4963 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4965 PRINT_ER("Failed to send message queue: Set join request\n");
4969 enuScanConnTimer = CONNECT_TIMER;
4970 pstrWFIDrv->hConnectTimer.data = (unsigned long)hWFIDrv;
4971 mod_timer(&pstrWFIDrv->hConnectTimer,
4972 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
4978 * @brief Flush a join request parameters to FW, but actual connection
4979 * @details The function is called in situation where WILC is connected to AP and
4980 * required to switch to hybrid FW for P2P connection
4981 * @param[in] handle to the wifi driver,
4982 * @return Error code indicating success/failure
4984 * @author Amr Abdel-Moghny
4989 s32 host_int_flush_join_req(tstrWILC_WFIDrv *hWFIDrv)
4992 struct host_if_msg msg;
4994 if (!gu8FlushedJoinReq) {
5000 if (hWFIDrv == NULL) {
5002 PRINT_ER("Driver is null\n");
5006 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
5007 msg.drvHandler = hWFIDrv;
5009 /* send the message */
5010 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5012 PRINT_ER("Failed to send message queue: Flush join request\n");
5020 * @brief host_int_disconnect
5021 * @details disconnects from the currently associated network
5022 * @param[in,out] handle to the wifi driver,
5023 * @param[in] Reason Code of the Disconnection
5024 * @return Error code indicating success/failure
5027 * @date 8 March 2012
5030 s32 host_int_disconnect(tstrWILC_WFIDrv *hWFIDrv, u16 u16ReasonCode)
5033 struct host_if_msg msg;
5034 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5036 if (pstrWFIDrv == NULL) {
5037 PRINT_ER("Driver is null\n");
5041 /* prepare the Disconnect Message */
5042 memset(&msg, 0, sizeof(struct host_if_msg));
5044 msg.id = HOST_IF_MSG_DISCONNECT;
5045 msg.drvHandler = hWFIDrv;
5047 /* send the message */
5048 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5050 PRINT_ER("Failed to send message queue: disconnect\n");
5051 /* ////////////// */
5052 down(&(pstrWFIDrv->hSemTestDisconnectBlock));
5059 * @brief host_int_disconnect_station
5060 * @details disconnects a sta
5061 * @param[in,out] handle to the wifi driver,
5062 * @param[in] Association Id of the station to be disconnected
5063 * @return Error code indicating success/failure
5066 * @date 8 March 2012
5069 s32 host_int_disconnect_station(tstrWILC_WFIDrv *hWFIDrv, u8 assoc_id)
5073 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5075 strWID.u16WIDid = (u16)WID_DISCONNECT;
5076 strWID.enuWIDtype = WID_CHAR;
5077 strWID.ps8WidVal = (s8 *)&assoc_id;
5078 strWID.s32ValueSize = sizeof(char);
5084 * @brief host_int_get_assoc_req_info
5085 * @details gets a Association request info
5086 * @param[in,out] handle to the wifi driver,
5087 * Message containg assoc. req info in the following format
5088 * ------------------------------------------------------------------------
5089 | Management Frame Format |
5090 ||-------------------------------------------------------------------|
5091 ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS |
5092 ||-------------|--------|--|--|-----|----------------|----------|----|
5093 | 2 |2 |6 |6 |6 | 2 |0 - 2312 | 4 |
5094 ||-------------------------------------------------------------------|
5096 | Association Request Frame - Frame Body |
5097 ||-------------------------------------------------------------------|
5098 | Capability Information | Listen Interval | SSID | Supported Rates |
5099 ||------------------------|-----------------|------|-----------------|
5100 | 2 | 2 | 2-34 | 3-10 |
5101 | ---------------------------------------------------------------------
5102 * @return Error code indicating success/failure
5105 * @date 8 March 2012
5109 s32 host_int_get_assoc_req_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8AssocReqInfo,
5110 u32 u32AssocReqInfoLen)
5114 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5116 strWID.u16WIDid = (u16)WID_ASSOC_REQ_INFO;
5117 strWID.enuWIDtype = WID_STR;
5118 strWID.ps8WidVal = pu8AssocReqInfo;
5119 strWID.s32ValueSize = u32AssocReqInfoLen;
5126 * @brief gets a Association Response info
5128 * @param[in,out] handle to the wifi driver,
5129 * Message containg assoc. resp info
5130 * @return Error code indicating success/failure
5133 * @date 8 March 2012
5136 s32 host_int_get_assoc_res_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8AssocRespInfo,
5137 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
5141 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5143 if (pstrWFIDrv == NULL) {
5144 PRINT_ER("Driver is null\n");
5148 strWID.u16WIDid = (u16)WID_ASSOC_RES_INFO;
5149 strWID.enuWIDtype = WID_STR;
5150 strWID.ps8WidVal = pu8AssocRespInfo;
5151 strWID.s32ValueSize = u32MaxAssocRespInfoLen;
5154 /* Sending Configuration packet */
5155 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
5156 get_id_from_handler(pstrWFIDrv));
5158 *pu32RcvdAssocRespInfoLen = 0;
5159 PRINT_ER("Failed to send association response config packet\n");
5162 *pu32RcvdAssocRespInfoLen = strWID.s32ValueSize;
5169 * @brief gets a Association Response info
5170 * @details Valid only in STA mode. This function gives the RSSI
5171 * values observed in all the channels at the time of scanning.
5172 * The length of the field is 1 greater that the total number of
5173 * channels supported. Byte 0 contains the number of channels while
5174 * each of Byte N contains the observed RSSI value for the channel index N.
5175 * @param[in,out] handle to the wifi driver,
5176 * array of scanned channels' RSSI
5177 * @return Error code indicating success/failure
5180 * @date 8 March 2012
5183 s32 host_int_get_rx_power_level(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8RxPowerLevel,
5184 u32 u32RxPowerLevelLen)
5188 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5190 strWID.u16WIDid = (u16)WID_RX_POWER_LEVEL;
5191 strWID.enuWIDtype = WID_STR;
5192 strWID.ps8WidVal = pu8RxPowerLevel;
5193 strWID.s32ValueSize = u32RxPowerLevelLen;
5200 * @brief sets a channel
5202 * @param[in,out] handle to the wifi driver,
5203 * @param[in] Index of the channel to be set
5204 *|-------------------------------------------------------------------|
5205 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5207 ||-------------------------------------------------------------------|
5208 * @return Error code indicating success/failure
5211 * @date 8 March 2012
5214 int host_int_set_mac_chnl_num(tstrWILC_WFIDrv *wfi_drv, u8 channel)
5217 struct host_if_msg msg;
5220 PRINT_ER("driver is null\n");
5224 /* prepare the set channel message */
5225 memset(&msg, 0, sizeof(struct host_if_msg));
5226 msg.id = HOST_IF_MSG_SET_CHANNEL;
5227 msg.body.channel_info.u8SetChan = channel;
5228 msg.drvHandler = wfi_drv;
5230 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5232 PRINT_ER("wilc mq send fail\n");
5239 int host_int_wait_msg_queue_idle(void)
5243 struct host_if_msg msg;
5245 /* prepare the set driver handler message */
5247 memset(&msg, 0, sizeof(struct host_if_msg));
5248 msg.id = HOST_IF_MSG_Q_IDLE;
5249 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5251 PRINT_ER("wilc mq send fail\n");
5255 /* wait untill MSG Q is empty */
5256 down(&hWaitResponse);
5261 int host_int_set_wfi_drv_handler(tstrWILC_WFIDrv *address)
5265 struct host_if_msg msg;
5267 /* prepare the set driver handler message */
5269 memset(&msg, 0, sizeof(struct host_if_msg));
5270 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
5271 msg.body.drv.u32Address = get_id_from_handler(address);
5272 msg.drvHandler = address;
5274 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5276 PRINT_ER("wilc mq send fail\n");
5283 int host_int_set_operation_mode(tstrWILC_WFIDrv *wfi_drv, u32 mode)
5287 struct host_if_msg msg;
5289 /* prepare the set driver handler message */
5291 memset(&msg, 0, sizeof(struct host_if_msg));
5292 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
5293 msg.body.mode.u32Mode = mode;
5294 msg.drvHandler = wfi_drv;
5296 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5298 PRINT_ER("wilc mq send fail\n");
5306 * @brief gets the current channel index
5308 * @param[in,out] handle to the wifi driver,
5309 * current channel index
5310 *|-----------------------------------------------------------------------|
5311 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5313 ||-----------------------------------------------------------------------|
5314 * @return Error code indicating success/failure
5317 * @date 8 March 2012
5320 s32 host_int_get_host_chnl_num(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8ChNo)
5323 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5324 struct host_if_msg msg;
5326 if (pstrWFIDrv == NULL) {
5327 PRINT_ER("driver is null\n");
5331 /* prepare the Get Channel Message */
5332 memset(&msg, 0, sizeof(struct host_if_msg));
5334 msg.id = HOST_IF_MSG_GET_CHNL;
5335 msg.drvHandler = hWFIDrv;
5337 /* send the message */
5338 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5340 PRINT_ER("wilc mq send fail\n");
5341 down(&(pstrWFIDrv->hSemGetCHNL));
5352 * @brief host_int_get_inactive_time
5354 * @param[in,out] handle to the wifi driver,
5355 * current sta macaddress, inactive_time
5362 s32 host_int_get_inactive_time(tstrWILC_WFIDrv *hWFIDrv, const u8 *mac, u32 *pu32InactiveTime)
5365 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5366 struct host_if_msg msg;
5368 if (pstrWFIDrv == NULL) {
5369 PRINT_ER("driver is null\n");
5373 memset(&msg, 0, sizeof(struct host_if_msg));
5376 memcpy(msg.body.mac_info.mac,
5379 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
5380 msg.drvHandler = hWFIDrv;
5382 /* send the message */
5383 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5385 PRINT_ER("Failed to send get host channel param's message queue ");
5387 down(&(pstrWFIDrv->hSemInactiveTime));
5389 *pu32InactiveTime = gu32InactiveTime;
5395 * @brief host_int_test_get_int_wid
5396 * @details Test function for getting wids
5397 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32* pu32TestMemAddr
5398 * @return Error code indicating success/failure
5401 * @date 8 March 2012
5404 s32 host_int_test_get_int_wid(tstrWILC_WFIDrv *hWFIDrv, u32 *pu32TestMemAddr)
5409 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5412 if (pstrWFIDrv == NULL) {
5413 PRINT_ER("driver is null\n");
5417 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
5418 strWID.enuWIDtype = WID_INT;
5419 strWID.ps8WidVal = (s8 *)pu32TestMemAddr;
5420 strWID.s32ValueSize = sizeof(u32);
5422 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
5423 get_id_from_handler(pstrWFIDrv));
5424 /*get the value by searching the local copy*/
5426 PRINT_ER("Failed to get wid value\n");
5429 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
5438 * @brief host_int_get_rssi
5439 * @details gets the currently maintained RSSI value for the station.
5440 * The received signal strength value in dB.
5441 * The range of valid values is -128 to 0.
5442 * @param[in,out] handle to the wifi driver,
5444 * @return Error code indicating success/failure
5447 * @date 8 March 2012
5450 s32 host_int_get_rssi(tstrWILC_WFIDrv *hWFIDrv, s8 *ps8Rssi)
5453 struct host_if_msg msg;
5454 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5457 /* prepare the Get RSSI Message */
5458 memset(&msg, 0, sizeof(struct host_if_msg));
5460 msg.id = HOST_IF_MSG_GET_RSSI;
5461 msg.drvHandler = hWFIDrv;
5463 /* send the message */
5464 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5466 PRINT_ER("Failed to send get host channel param's message queue ");
5470 down(&(pstrWFIDrv->hSemGetRSSI));
5473 if (ps8Rssi == NULL) {
5474 PRINT_ER("RSS pointer value is null");
5485 s32 host_int_get_link_speed(tstrWILC_WFIDrv *hWFIDrv, s8 *ps8lnkspd)
5487 struct host_if_msg msg;
5490 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5494 /* prepare the Get LINKSPEED Message */
5495 memset(&msg, 0, sizeof(struct host_if_msg));
5497 msg.id = HOST_IF_MSG_GET_LINKSPEED;
5498 msg.drvHandler = hWFIDrv;
5500 /* send the message */
5501 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5503 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
5507 down(&(pstrWFIDrv->hSemGetLINKSPEED));
5510 if (ps8lnkspd == NULL) {
5511 PRINT_ER("LINKSPEED pointer value is null");
5516 *ps8lnkspd = gs8lnkspd;
5522 s32 host_int_get_statistics(tstrWILC_WFIDrv *hWFIDrv, tstrStatistics *pstrStatistics)
5525 struct host_if_msg msg;
5528 /* prepare the Get RSSI Message */
5529 memset(&msg, 0, sizeof(struct host_if_msg));
5531 msg.id = HOST_IF_MSG_GET_STATISTICS;
5532 msg.body.data = (char *)pstrStatistics;
5533 msg.drvHandler = hWFIDrv;
5534 /* send the message */
5535 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5537 PRINT_ER("Failed to send get host channel param's message queue ");
5541 down(&hWaitResponse);
5547 * @brief host_int_scan
5548 * @details scans a set of channels
5549 * @param[in,out] handle to the wifi driver,
5550 * @param[in] Scan source
5551 * Scan Type PASSIVE_SCAN = 0,
5554 * Channels Array length
5555 * Scan Callback function
5556 * @return Error code indicating success/failure
5559 * @date 8 March 2012
5562 s32 host_int_scan(tstrWILC_WFIDrv *hWFIDrv, u8 u8ScanSource,
5563 u8 u8ScanType, u8 *pu8ChnlFreqList,
5564 u8 u8ChnlListLen, const u8 *pu8IEs,
5565 size_t IEsLen, wilc_scan_result ScanResult,
5567 struct hidden_network *pstrHiddenNetwork)
5570 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5571 struct host_if_msg msg;
5572 tenuScanConnTimer enuScanConnTimer;
5574 if (pstrWFIDrv == NULL || ScanResult == NULL) {
5575 PRINT_ER("pstrWFIDrv or ScanResult = NULL\n");
5579 /* prepare the Scan Message */
5580 memset(&msg, 0, sizeof(struct host_if_msg));
5582 msg.id = HOST_IF_MSG_SCAN;
5584 if (pstrHiddenNetwork != NULL) {
5585 msg.body.scan_info.strHiddenNetwork.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
5586 msg.body.scan_info.strHiddenNetwork.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
5589 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
5591 msg.drvHandler = hWFIDrv;
5592 msg.body.scan_info.u8ScanSource = u8ScanSource;
5593 msg.body.scan_info.u8ScanType = u8ScanType;
5594 msg.body.scan_info.pfScanResult = ScanResult;
5595 msg.body.scan_info.pvUserArg = pvUserArg;
5597 msg.body.scan_info.u8ChnlListLen = u8ChnlListLen;
5598 msg.body.scan_info.pu8ChnlFreqList = kmalloc(u8ChnlListLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5599 memcpy(msg.body.scan_info.pu8ChnlFreqList,
5600 pu8ChnlFreqList, u8ChnlListLen);
5602 msg.body.scan_info.IEsLen = IEsLen;
5603 msg.body.scan_info.pu8IEs = kmalloc(IEsLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5604 memcpy(msg.body.scan_info.pu8IEs,
5607 /* send the message */
5608 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5610 PRINT_ER("Error in sending message queue\n");
5614 enuScanConnTimer = SCAN_TIMER;
5615 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
5616 pstrWFIDrv->hScanTimer.data = (unsigned long)hWFIDrv;
5617 mod_timer(&pstrWFIDrv->hScanTimer,
5618 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
5624 * @brief hif_set_cfg
5625 * @details sets configuration wids values
5626 * @param[in,out] handle to the wifi driver,
5627 * @param[in] WID, WID value
5628 * @return Error code indicating success/failure
5631 * @date 8 March 2012
5634 s32 hif_set_cfg(tstrWILC_WFIDrv *hWFIDrv, struct cfg_param_val *pstrCfgParamVal)
5638 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5640 struct host_if_msg msg;
5643 if (pstrWFIDrv == NULL) {
5644 PRINT_ER("pstrWFIDrv NULL\n");
5647 /* prepare the WiphyParams Message */
5648 memset(&msg, 0, sizeof(struct host_if_msg));
5649 msg.id = HOST_IF_MSG_CFG_PARAMS;
5650 msg.body.cfg_info.pstrCfgParamVal = *pstrCfgParamVal;
5651 msg.drvHandler = hWFIDrv;
5653 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5661 * @brief hif_get_cfg
5662 * @details gets configuration wids values
5663 * @param[in,out] handle to the wifi driver,
5666 * @return Error code indicating success/failure
5670 * @date 8 March 2012
5673 s32 hif_get_cfg(tstrWILC_WFIDrv *hWFIDrv, u16 u16WID, u16 *pu16WID_Value)
5676 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5678 down(&(pstrWFIDrv->gtOsCfgValuesSem));
5680 if (pstrWFIDrv == NULL) {
5681 PRINT_ER("pstrWFIDrv NULL\n");
5684 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
5688 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.bss_type;
5692 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.auth_type;
5695 case WID_AUTH_TIMEOUT:
5696 *pu16WID_Value = pstrWFIDrv->strCfgValues.auth_timeout;
5699 case WID_POWER_MANAGEMENT:
5700 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.power_mgmt_mode;
5703 case WID_SHORT_RETRY_LIMIT:
5704 *pu16WID_Value = pstrWFIDrv->strCfgValues.short_retry_limit;
5707 case WID_LONG_RETRY_LIMIT:
5708 *pu16WID_Value = pstrWFIDrv->strCfgValues.long_retry_limit;
5711 case WID_FRAG_THRESHOLD:
5712 *pu16WID_Value = pstrWFIDrv->strCfgValues.frag_threshold;
5715 case WID_RTS_THRESHOLD:
5716 *pu16WID_Value = pstrWFIDrv->strCfgValues.rts_threshold;
5720 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.preamble_type;
5723 case WID_SHORT_SLOT_ALLOWED:
5724 *pu16WID_Value = (u16) pstrWFIDrv->strCfgValues.short_slot_allowed;
5727 case WID_11N_TXOP_PROT_DISABLE:
5728 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.txop_prot_disabled;
5731 case WID_BEACON_INTERVAL:
5732 *pu16WID_Value = pstrWFIDrv->strCfgValues.beacon_interval;
5735 case WID_DTIM_PERIOD:
5736 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.dtim_period;
5739 case WID_SITE_SURVEY:
5740 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.site_survey_enabled;
5743 case WID_SITE_SURVEY_SCAN_TIME:
5744 *pu16WID_Value = pstrWFIDrv->strCfgValues.site_survey_scan_time;
5747 case WID_ACTIVE_SCAN_TIME:
5748 *pu16WID_Value = pstrWFIDrv->strCfgValues.active_scan_time;
5751 case WID_PASSIVE_SCAN_TIME:
5752 *pu16WID_Value = pstrWFIDrv->strCfgValues.passive_scan_time;
5755 case WID_CURRENT_TX_RATE:
5756 *pu16WID_Value = pstrWFIDrv->strCfgValues.curr_tx_rate;
5763 up(&(pstrWFIDrv->gtOsCfgValuesSem));
5769 /*****************************************************************************/
5770 /* Notification Functions */
5771 /*****************************************************************************/
5773 * @brief notifies host with join and leave requests
5774 * @details This function prepares an Information frame having the
5775 * information about a joining/leaving station.
5776 * @param[in,out] handle to the wifi driver,
5777 * @param[in] 6 byte Sta Adress
5778 * Join or leave flag:
5781 * @return Error code indicating success/failure
5784 * @date 8 March 2012
5787 void host_int_send_join_leave_info_to_host
5788 (u16 assocId, u8 *stationAddr, bool joining)
5792 * @brief notifies host with stations found in scan
5793 * @details sends the beacon/probe response from scan
5794 * @param[in,out] handle to the wifi driver,
5795 * @param[in] Sta Address,
5797 * Rssi of the Station found
5798 * @return Error code indicating success/failure
5801 * @date 8 March 2012
5805 static void GetPeriodicRSSI(unsigned long arg)
5807 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)arg;
5809 if (pstrWFIDrv == NULL) {
5810 PRINT_ER("Driver handler is NULL\n");
5814 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
5816 struct host_if_msg msg;
5818 /* prepare the Get RSSI Message */
5819 memset(&msg, 0, sizeof(struct host_if_msg));
5821 msg.id = HOST_IF_MSG_GET_RSSI;
5822 msg.drvHandler = pstrWFIDrv;
5824 /* send the message */
5825 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5827 PRINT_ER("Failed to send get host channel param's message queue ");
5831 g_hPeriodicRSSI.data = (unsigned long)pstrWFIDrv;
5832 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
5836 void host_int_send_network_info_to_host
5837 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
5841 * @brief host_int_init
5842 * @details host interface initialization function
5843 * @param[in,out] handle to the wifi driver,
5846 * @date 8 March 2012
5849 static u32 clients_count;
5851 s32 host_int_init(tstrWILC_WFIDrv **phWFIDrv)
5854 tstrWILC_WFIDrv *pstrWFIDrv;
5857 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
5859 gbScanWhileConnected = false;
5861 sema_init(&hWaitResponse, 0);
5863 /*Allocate host interface private structure*/
5864 pstrWFIDrv = kzalloc(sizeof(tstrWILC_WFIDrv), GFP_KERNEL);
5869 *phWFIDrv = pstrWFIDrv;
5870 err = add_handler_in_list(pstrWFIDrv);
5876 g_obtainingIP = false;
5878 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", pstrWFIDrv);
5879 if (clients_count == 0) {
5880 sema_init(&hSemHostIFthrdEnd, 0);
5881 sema_init(&hSemDeinitDrvHandle, 0);
5882 sema_init(&hSemHostIntDeinit, 1);
5885 sema_init(&pstrWFIDrv->hSemTestKeyBlock, 0);
5886 sema_init(&pstrWFIDrv->hSemTestDisconnectBlock, 0);
5887 sema_init(&pstrWFIDrv->hSemGetRSSI, 0);
5888 sema_init(&pstrWFIDrv->hSemGetLINKSPEED, 0);
5889 sema_init(&pstrWFIDrv->hSemGetCHNL, 0);
5890 sema_init(&pstrWFIDrv->hSemInactiveTime, 0);
5892 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
5894 if (clients_count == 0) {
5895 result = wilc_mq_create(&gMsgQHostIF);
5898 PRINT_ER("Failed to creat MQ\n");
5901 HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread");
5902 if (IS_ERR(HostIFthreadHandler)) {
5903 PRINT_ER("Failed to creat Thread\n");
5907 setup_timer(&g_hPeriodicRSSI, GetPeriodicRSSI,
5908 (unsigned long)pstrWFIDrv);
5909 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
5912 setup_timer(&pstrWFIDrv->hScanTimer, TimerCB_Scan, 0);
5914 setup_timer(&pstrWFIDrv->hConnectTimer, TimerCB_Connect, 0);
5916 /*Remain on channel timer*/
5917 setup_timer(&pstrWFIDrv->hRemainOnChannel, ListenTimerCB, 0);
5919 sema_init(&(pstrWFIDrv->gtOsCfgValuesSem), 1);
5920 down(&pstrWFIDrv->gtOsCfgValuesSem);
5922 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
5924 /*Initialize CFG WIDS Defualt Values*/
5926 pstrWFIDrv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
5927 pstrWFIDrv->strCfgValues.scan_source = DEFAULT_SCAN;
5928 pstrWFIDrv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
5929 pstrWFIDrv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
5930 pstrWFIDrv->strCfgValues.curr_tx_rate = AUTORATE;
5932 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
5934 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",
5936 pstrWFIDrv->strCfgValues.site_survey_enabled, pstrWFIDrv->strCfgValues.scan_source,
5937 pstrWFIDrv->strCfgValues.active_scan_time, pstrWFIDrv->strCfgValues.passive_scan_time,
5938 pstrWFIDrv->strCfgValues.curr_tx_rate);
5940 up(&pstrWFIDrv->gtOsCfgValuesSem);
5942 clients_count++; /* increase number of created entities */
5947 up(&pstrWFIDrv->gtOsCfgValuesSem);
5948 del_timer_sync(&pstrWFIDrv->hConnectTimer);
5949 del_timer_sync(&pstrWFIDrv->hScanTimer);
5950 kthread_stop(HostIFthreadHandler);
5952 wilc_mq_destroy(&gMsgQHostIF);
5957 * @brief host_int_deinit
5958 * @details host interface initialization function
5959 * @param[in,out] handle to the wifi driver,
5962 * @date 8 March 2012
5966 s32 host_int_deinit(tstrWILC_WFIDrv *hWFIDrv)
5969 struct host_if_msg msg;
5972 /*obtain driver handle*/
5973 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5975 if (pstrWFIDrv == NULL) {
5976 PRINT_ER("pstrWFIDrv = NULL\n");
5980 down(&hSemHostIntDeinit);
5982 terminated_handle = pstrWFIDrv;
5983 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
5985 /*Destroy all timers before acquiring hSemDeinitDrvHandle*/
5986 /*to guarantee handling all messages befor proceeding*/
5987 if (del_timer_sync(&pstrWFIDrv->hScanTimer)) {
5988 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
5989 /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */
5992 if (del_timer_sync(&pstrWFIDrv->hConnectTimer)) {
5993 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
5994 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
5998 if (del_timer_sync(&g_hPeriodicRSSI)) {
5999 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
6000 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6003 /*Destroy Remain-onchannel Timer*/
6004 del_timer_sync(&pstrWFIDrv->hRemainOnChannel);
6006 host_int_set_wfi_drv_handler(NULL);
6007 down(&hSemDeinitDrvHandle);
6010 /*Calling the CFG80211 scan done function with the abort flag set to true*/
6011 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
6012 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
6013 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
6015 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
6018 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
6020 gbScanWhileConnected = false;
6022 memset(&msg, 0, sizeof(struct host_if_msg));
6024 if (clients_count == 1) {
6025 if (del_timer_sync(&g_hPeriodicRSSI)) {
6026 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
6027 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6029 msg.id = HOST_IF_MSG_EXIT;
6030 msg.drvHandler = hWFIDrv;
6033 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6035 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
6037 down(&hSemHostIFthrdEnd);
6039 wilc_mq_destroy(&gMsgQHostIF);
6042 down(&(pstrWFIDrv->gtOsCfgValuesSem));
6044 /*Setting the gloabl driver handler with NULL*/
6045 /* gWFiDrvHandle = NULL; */
6046 ret = remove_handler_in_list(pstrWFIDrv);
6050 if (pstrWFIDrv != NULL) {
6052 /* pstrWFIDrv=NULL; */
6056 clients_count--; /* Decrease number of created entities */
6057 terminated_handle = NULL;
6058 up(&hSemHostIntDeinit);
6064 * @brief NetworkInfoReceived
6065 * @details function to to be called when network info packet is received
6066 * @param[in] pu8Buffer the received packet
6067 * @param[in] u32Length length of the received packet
6074 void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
6077 struct host_if_msg msg;
6079 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
6081 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6082 pstrWFIDrv = get_handler_from_id(id);
6087 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
6088 PRINT_ER("NetworkInfo received but driver not init[%p]\n", pstrWFIDrv);
6092 /* prepare the Asynchronous Network Info message */
6093 memset(&msg, 0, sizeof(struct host_if_msg));
6095 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
6096 msg.drvHandler = pstrWFIDrv;
6098 msg.body.net_info.u32Length = u32Length;
6099 msg.body.net_info.pu8Buffer = kmalloc(u32Length, GFP_KERNEL); /* will be deallocated by the receiving thread */
6100 memcpy(msg.body.net_info.pu8Buffer,
6101 pu8Buffer, u32Length);
6103 /* send the message */
6104 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6106 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
6110 * @brief GnrlAsyncInfoReceived
6111 * @details function to be called when general Asynchronous info packet is received
6112 * @param[in] pu8Buffer the received packet
6113 * @param[in] u32Length length of the received packet
6120 void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
6123 struct host_if_msg msg;
6125 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
6127 down(&hSemHostIntDeinit);
6129 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6130 pstrWFIDrv = get_handler_from_id(id);
6131 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
6134 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
6135 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
6136 up(&hSemHostIntDeinit);
6140 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL) {
6141 /* received mac status is not needed when there is no current Connect Request */
6142 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
6143 up(&hSemHostIntDeinit);
6147 /* prepare the General Asynchronous Info message */
6148 memset(&msg, 0, sizeof(struct host_if_msg));
6151 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
6152 msg.drvHandler = pstrWFIDrv;
6155 msg.body.async_info.u32Length = u32Length;
6156 msg.body.async_info.pu8Buffer = kmalloc(u32Length, GFP_KERNEL); /* will be deallocated by the receiving thread */
6157 memcpy(msg.body.async_info.pu8Buffer,
6158 pu8Buffer, u32Length);
6160 /* send the message */
6161 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6163 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
6165 up(&hSemHostIntDeinit);
6169 * @brief host_int_ScanCompleteReceived
6170 * @details Setting scan complete received notifcation in message queue
6171 * @param[in] u8* pu8Buffer, u32 u32Length
6172 * @return Error code.
6177 void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
6180 struct host_if_msg msg;
6182 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
6184 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6185 pstrWFIDrv = get_handler_from_id(id);
6188 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", pstrWFIDrv);
6190 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle)
6193 /*if there is an ongoing scan request*/
6194 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
6195 /* prepare theScan Done message */
6196 memset(&msg, 0, sizeof(struct host_if_msg));
6198 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
6199 msg.drvHandler = pstrWFIDrv;
6202 /* will be deallocated by the receiving thread */
6203 /*no need to send message body*/
6205 /*msg.body.strScanComplete.u32Length = u32Length;
6206 * msg.body.strScanComplete.pu8Buffer = (u8*)WILC_MALLOC(u32Length);
6207 * memcpy(msg.body.strScanComplete.pu8Buffer,
6208 * pu8Buffer, u32Length); */
6210 /* send the message */
6211 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6213 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
6222 * @brief host_int_remain_on_channel
6224 * @param[in] Handle to wifi driver
6225 * Duration to remain on channel
6226 * Channel to remain on
6227 * Pointer to fn to be called on receive frames in listen state
6228 * Pointer to remain-on-channel expired fn
6230 * @return Error code.
6235 s32 host_int_remain_on_channel(tstrWILC_WFIDrv *hWFIDrv, u32 u32SessionID, u32 u32duration, u16 chan, wilc_remain_on_chan_expired RemainOnChanExpired, wilc_remain_on_chan_ready RemainOnChanReady, void *pvUserArg)
6238 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6239 struct host_if_msg msg;
6241 if (pstrWFIDrv == NULL) {
6242 PRINT_ER("driver is null\n");
6246 /* prepare the remainonchan Message */
6247 memset(&msg, 0, sizeof(struct host_if_msg));
6249 /* prepare the WiphyParams Message */
6250 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
6251 msg.body.remain_on_ch.u16Channel = chan;
6252 msg.body.remain_on_ch.pRemainOnChanExpired = RemainOnChanExpired;
6253 msg.body.remain_on_ch.pRemainOnChanReady = RemainOnChanReady;
6254 msg.body.remain_on_ch.pVoid = pvUserArg;
6255 msg.body.remain_on_ch.u32duration = u32duration;
6256 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
6257 msg.drvHandler = hWFIDrv;
6259 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6261 PRINT_ER("wilc mq send fail\n");
6267 * @brief host_int_ListenStateExpired
6269 * @param[in] Handle to wifi driver
6270 * Duration to remain on channel
6271 * Channel to remain on
6272 * Pointer to fn to be called on receive frames in listen state
6273 * Pointer to remain-on-channel expired fn
6275 * @return Error code.
6280 s32 host_int_ListenStateExpired(tstrWILC_WFIDrv *hWFIDrv, u32 u32SessionID)
6283 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6284 struct host_if_msg msg;
6286 if (pstrWFIDrv == NULL) {
6287 PRINT_ER("driver is null\n");
6291 /*Stopping remain-on-channel timer*/
6292 del_timer(&pstrWFIDrv->hRemainOnChannel);
6294 /* prepare the timer fire Message */
6295 memset(&msg, 0, sizeof(struct host_if_msg));
6296 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
6297 msg.drvHandler = hWFIDrv;
6298 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
6300 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6302 PRINT_ER("wilc mq send fail\n");
6308 * @brief host_int_frame_register
6310 * @param[in] Handle to wifi driver
6311 * @return Error code.
6315 s32 host_int_frame_register(tstrWILC_WFIDrv *hWFIDrv, u16 u16FrameType, bool bReg)
6318 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6319 struct host_if_msg msg;
6321 if (pstrWFIDrv == NULL) {
6322 PRINT_ER("driver is null\n");
6326 memset(&msg, 0, sizeof(struct host_if_msg));
6328 /* prepare the WiphyParams Message */
6329 msg.id = HOST_IF_MSG_REGISTER_FRAME;
6330 switch (u16FrameType) {
6332 PRINT_D(HOSTINF_DBG, "ACTION\n");
6333 msg.body.reg_frame.u8Regid = ACTION_FRM_IDX;
6337 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
6338 msg.body.reg_frame.u8Regid = PROBE_REQ_IDX;
6342 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
6345 msg.body.reg_frame.u16FrameType = u16FrameType;
6346 msg.body.reg_frame.bReg = bReg;
6347 msg.drvHandler = hWFIDrv;
6349 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6351 PRINT_ER("wilc mq send fail\n");
6359 * @brief host_int_add_beacon
6360 * @details Setting add beacon params in message queue
6361 * @param[in] WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
6362 * u32 u32DTIMPeriod,u32 u32HeadLen, u8* pu8Head,
6363 * u32 u32TailLen, u8* pu8Tail
6364 * @return Error code.
6369 s32 host_int_add_beacon(tstrWILC_WFIDrv *hWFIDrv, u32 u32Interval,
6371 u32 u32HeadLen, u8 *pu8Head,
6372 u32 u32TailLen, u8 *pu8Tail)
6375 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6376 struct host_if_msg msg;
6377 struct beacon_attr *pstrSetBeaconParam = &msg.body.beacon_info;
6379 if (pstrWFIDrv == NULL) {
6380 PRINT_ER("driver is null\n");
6384 memset(&msg, 0, sizeof(struct host_if_msg));
6386 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
6389 /* prepare the WiphyParams Message */
6390 msg.id = HOST_IF_MSG_ADD_BEACON;
6391 msg.drvHandler = hWFIDrv;
6392 pstrSetBeaconParam->u32Interval = u32Interval;
6393 pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
6394 pstrSetBeaconParam->u32HeadLen = u32HeadLen;
6395 pstrSetBeaconParam->pu8Head = kmalloc(u32HeadLen, GFP_KERNEL);
6396 if (pstrSetBeaconParam->pu8Head == NULL) {
6400 memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
6401 pstrSetBeaconParam->u32TailLen = u32TailLen;
6403 if (u32TailLen > 0) {
6404 pstrSetBeaconParam->pu8Tail = kmalloc(u32TailLen, GFP_KERNEL);
6405 if (pstrSetBeaconParam->pu8Tail == NULL) {
6409 memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen);
6411 pstrSetBeaconParam->pu8Tail = NULL;
6414 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6416 PRINT_ER("wilc mq send fail\n");
6420 if (pstrSetBeaconParam->pu8Head != NULL)
6421 kfree(pstrSetBeaconParam->pu8Head);
6423 if (pstrSetBeaconParam->pu8Tail != NULL)
6424 kfree(pstrSetBeaconParam->pu8Tail);
6433 * @brief host_int_del_beacon
6434 * @details Setting add beacon params in message queue
6435 * @param[in] WILC_WFIDrvHandle hWFIDrv
6436 * @return Error code.
6441 s32 host_int_del_beacon(tstrWILC_WFIDrv *hWFIDrv)
6444 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6445 struct host_if_msg msg;
6447 if (pstrWFIDrv == NULL) {
6448 PRINT_ER("driver is null\n");
6452 /* prepare the WiphyParams Message */
6453 msg.id = HOST_IF_MSG_DEL_BEACON;
6454 msg.drvHandler = hWFIDrv;
6455 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
6457 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6459 PRINT_ER("wilc_mq_send fail\n");
6466 * @brief host_int_add_station
6467 * @details Setting add station params in message queue
6468 * @param[in] WILC_WFIDrvHandle hWFIDrv, struct add_sta_param *pstrStaParams
6469 * @return Error code.
6474 s32 host_int_add_station(tstrWILC_WFIDrv *hWFIDrv,
6475 struct add_sta_param *pstrStaParams)
6478 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6479 struct host_if_msg msg;
6480 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
6483 if (pstrWFIDrv == NULL) {
6484 PRINT_ER("driver is null\n");
6488 memset(&msg, 0, sizeof(struct host_if_msg));
6490 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
6493 /* prepare the WiphyParams Message */
6494 msg.id = HOST_IF_MSG_ADD_STATION;
6495 msg.drvHandler = hWFIDrv;
6497 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
6498 if (pstrAddStationMsg->u8NumRates > 0) {
6499 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
6504 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
6505 pstrAddStationMsg->pu8Rates = rates;
6509 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6511 PRINT_ER("wilc_mq_send fail\n");
6516 * @brief host_int_del_station
6517 * @details Setting delete station params in message queue
6518 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr
6519 * @return Error code.
6524 s32 host_int_del_station(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8MacAddr)
6527 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6528 struct host_if_msg msg;
6529 struct del_sta *pstrDelStationMsg = &msg.body.del_sta_info;
6531 if (pstrWFIDrv == NULL) {
6532 PRINT_ER("driver is null\n");
6536 memset(&msg, 0, sizeof(struct host_if_msg));
6538 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
6542 /* prepare the WiphyParams Message */
6543 msg.id = HOST_IF_MSG_DEL_STATION;
6544 msg.drvHandler = hWFIDrv;
6546 if (pu8MacAddr == NULL)
6547 memset(pstrDelStationMsg->au8MacAddr, 255, ETH_ALEN);
6549 memcpy(pstrDelStationMsg->au8MacAddr, pu8MacAddr, ETH_ALEN);
6551 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6553 PRINT_ER("wilc_mq_send fail\n");
6557 * @brief host_int_del_allstation
6558 * @details Setting del station params in message queue
6559 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]s
6560 * @return Error code.
6565 s32 host_int_del_allstation(tstrWILC_WFIDrv *hWFIDrv, u8 pu8MacAddr[][ETH_ALEN])
6568 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6569 struct host_if_msg msg;
6570 struct del_all_sta *pstrDelAllStationMsg = &msg.body.del_all_sta_info;
6571 u8 au8Zero_Buff[ETH_ALEN] = {0};
6576 if (pstrWFIDrv == NULL) {
6577 PRINT_ER("driver is null\n");
6581 memset(&msg, 0, sizeof(struct host_if_msg));
6583 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
6585 /* prepare the WiphyParams Message */
6586 msg.id = HOST_IF_MSG_DEL_ALL_STA;
6587 msg.drvHandler = hWFIDrv;
6589 /* Handling situation of deauthenticing all associated stations*/
6590 for (i = 0; i < MAX_NUM_STA; i++) {
6591 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
6592 memcpy(pstrDelAllStationMsg->au8Sta_DelAllSta[i], pu8MacAddr[i], ETH_ALEN);
6593 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],
6594 pstrDelAllStationMsg->au8Sta_DelAllSta[i][5]);
6599 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
6603 pstrDelAllStationMsg->u8Num_AssocSta = u8AssocNumb;
6604 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6608 PRINT_ER("wilc_mq_send fail\n");
6610 down(&hWaitResponse);
6617 * @brief host_int_edit_station
6618 * @details Setting edit station params in message queue
6619 * @param[in] WILC_WFIDrvHandle hWFIDrv, struct add_sta_param *pstrStaParams
6620 * @return Error code.
6625 s32 host_int_edit_station(tstrWILC_WFIDrv *hWFIDrv,
6626 struct add_sta_param *pstrStaParams)
6629 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6630 struct host_if_msg msg;
6631 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
6633 if (pstrWFIDrv == NULL) {
6634 PRINT_ER("driver is null\n");
6638 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
6640 memset(&msg, 0, sizeof(struct host_if_msg));
6643 /* prepare the WiphyParams Message */
6644 msg.id = HOST_IF_MSG_EDIT_STATION;
6645 msg.drvHandler = hWFIDrv;
6647 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
6648 if (pstrAddStationMsg->u8NumRates > 0) {
6649 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
6654 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
6655 pstrAddStationMsg->pu8Rates = rates;
6658 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6660 PRINT_ER("wilc_mq_send fail\n");
6665 s32 host_int_set_power_mgmt(tstrWILC_WFIDrv *hWFIDrv, bool bIsEnabled, u32 u32Timeout)
6668 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6669 struct host_if_msg msg;
6670 struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.pwr_mgmt_info;
6672 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
6674 if (pstrWFIDrv == NULL) {
6675 PRINT_ER("driver is null\n");
6679 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
6681 memset(&msg, 0, sizeof(struct host_if_msg));
6684 /* prepare the WiphyParams Message */
6685 msg.id = HOST_IF_MSG_POWER_MGMT;
6686 msg.drvHandler = hWFIDrv;
6688 pstrPowerMgmtParam->bIsEnabled = bIsEnabled;
6689 pstrPowerMgmtParam->u32Timeout = u32Timeout;
6692 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6694 PRINT_ER("wilc_mq_send fail\n");
6698 s32 host_int_setup_multicast_filter(tstrWILC_WFIDrv *hWFIDrv, bool bIsEnabled, u32 u32count)
6702 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6703 struct host_if_msg msg;
6704 struct set_multicast *pstrMulticastFilterParam = &msg.body.multicast_info;
6707 if (pstrWFIDrv == NULL) {
6708 PRINT_ER("driver is null\n");
6712 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
6714 memset(&msg, 0, sizeof(struct host_if_msg));
6717 /* prepare the WiphyParams Message */
6718 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
6719 msg.drvHandler = hWFIDrv;
6721 pstrMulticastFilterParam->bIsEnabled = bIsEnabled;
6722 pstrMulticastFilterParam->u32count = u32count;
6724 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6726 PRINT_ER("wilc_mq_send fail\n");
6731 * @brief host_int_ParseJoinBssParam
6732 * @details Parse Needed Join Parameters and save it in a new JoinBssParam entry
6733 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
6738 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
6740 tstrJoinBssParam *pNewJoinBssParam = NULL;
6749 u8 pcipherTotalCount = 0;
6750 u8 authTotalCount = 0;
6753 pu8IEs = ptstrNetworkInfo->pu8IEs;
6754 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
6756 pNewJoinBssParam = kmalloc(sizeof(tstrJoinBssParam), GFP_KERNEL);
6757 if (pNewJoinBssParam != NULL) {
6758 memset(pNewJoinBssParam, 0, sizeof(tstrJoinBssParam));
6759 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
6760 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
6761 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
6762 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
6764 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/
6765 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
6766 pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen;
6767 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
6768 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
6769 /*for(i=0; i<pNewJoinBssParam->ssidLen;i++)
6770 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/
6772 /* parse supported rates: */
6773 while (index < u16IEsLen) {
6774 /* supportedRates IE */
6775 if (pu8IEs[index] == SUPP_RATES_IE) {
6776 /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */
6777 suppRatesNo = pu8IEs[index + 1];
6778 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
6779 index += 2; /* skipping ID and length bytes; */
6781 for (i = 0; i < suppRatesNo; i++) {
6782 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
6783 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */
6785 index += suppRatesNo;
6788 /* Ext SupportedRates IE */
6789 else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
6790 /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */
6791 /* checking if no of ext. supp and supp rates < max limit */
6792 extSuppRatesNo = pu8IEs[index + 1];
6793 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
6794 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
6796 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
6798 /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */
6799 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
6800 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
6801 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */
6803 index += extSuppRatesNo;
6807 else if (pu8IEs[index] == HT_CAPABILITY_IE) {
6808 /* if IE found set the flag */
6809 pNewJoinBssParam->ht_capable = true;
6810 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
6811 /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */
6813 } else if ((pu8IEs[index] == WMM_IE) && /* WMM Element ID */
6814 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
6815 (pu8IEs[index + 4] == 0xF2) && /* OUI */
6816 (pu8IEs[index + 5] == 0x02) && /* OUI Type */
6817 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) && /* OUI Sub Type */
6818 (pu8IEs[index + 7] == 0x01)) {
6819 /* Presence of WMM Info/Param element indicates WMM capability */
6820 pNewJoinBssParam->wmm_cap = true;
6822 /* Check if Bit 7 is set indicating U-APSD capability */
6823 if (pu8IEs[index + 8] & BIT(7))
6824 pNewJoinBssParam->uapsd_cap = true;
6825 index += pu8IEs[index + 1] + 2;
6828 else if ((pu8IEs[index] == P2P_IE) && /* P2P Element ID */
6829 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
6830 (pu8IEs[index + 4] == 0x9a) && /* OUI */
6831 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) { /* OUI Type */
6834 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
6835 pNewJoinBssParam->u8NoaEnbaled = 1;
6836 pNewJoinBssParam->u8Index = pu8IEs[index + 9];
6838 /* Check if Bit 7 is set indicating Opss capability */
6839 if (pu8IEs[index + 10] & BIT(7)) {
6840 pNewJoinBssParam->u8OppEnable = 1;
6841 pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10];
6843 pNewJoinBssParam->u8OppEnable = 0;
6845 PRINT_D(GENERIC_DBG, "P2P Dump\n");
6846 for (i = 0; i < pu8IEs[index + 7]; i++)
6847 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
6849 pNewJoinBssParam->u8Count = pu8IEs[index + 11];
6850 u16P2P_count = index + 12;
6852 memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4);
6855 memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4);
6858 memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
6860 index += pu8IEs[index + 1] + 2;
6864 else if ((pu8IEs[index] == RSN_IE) ||
6865 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
6866 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
6867 (pu8IEs[index + 5] == 0x01))) {
6868 u16 rsnIndex = index;
6869 /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]);
6870 * for(i=0; i<pu8IEs[rsnIndex+1]; i++)
6872 * PRINT_D(HOSTINF_DBG,"%0x ",pu8IEs[rsnIndex+2+i]);
6874 if (pu8IEs[rsnIndex] == RSN_IE) {
6875 pNewJoinBssParam->mode_802_11i = 2;
6876 /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */
6877 } else { /* check if rsn was previously parsed */
6878 if (pNewJoinBssParam->mode_802_11i == 0)
6879 pNewJoinBssParam->mode_802_11i = 1;
6880 /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */
6883 rsnIndex += 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */
6884 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
6886 /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x\n",pNewJoinBssParam->rsn_grp_policy); */
6887 /* initialize policies with invalid values */
6889 jumpOffset = pu8IEs[rsnIndex] * 4; /* total no.of bytes of pcipher field (count*4) */
6891 /*parsing pairwise cipher*/
6893 /* saving 3 pcipher max. */
6894 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
6895 rsnIndex += 2; /* jump 2 bytes of pcipher count */
6897 /* PRINT_D(HOSTINF_DBG,"\npcipher:%d\n",pcipherCount); */
6898 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
6899 /* each count corresponds to 4 bytes, only last byte is saved */
6900 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
6901 /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */
6903 pcipherTotalCount += pcipherCount;
6904 rsnIndex += jumpOffset;
6906 jumpOffset = pu8IEs[rsnIndex] * 4;
6908 /*parsing AKM suite (auth_policy)*/
6909 /* saving 3 auth policies max. */
6910 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
6911 rsnIndex += 2; /* jump 2 bytes of pcipher count */
6913 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
6914 /* each count corresponds to 4 bytes, only last byte is saved */
6915 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
6917 authTotalCount += authCount;
6918 rsnIndex += jumpOffset;
6919 /*pasring rsn cap. only if rsn IE*/
6920 if (pu8IEs[index] == RSN_IE) {
6921 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
6922 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
6925 pNewJoinBssParam->rsn_found = true;
6926 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
6929 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
6936 return (void *)pNewJoinBssParam;
6940 void host_int_freeJoinParams(void *pJoinParams)
6942 if ((tstrJoinBssParam *)pJoinParams != NULL)
6943 kfree((tstrJoinBssParam *)pJoinParams);
6945 PRINT_ER("Unable to FREE null pointer\n");
6948 s32 host_int_delBASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID)
6951 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6952 struct host_if_msg msg;
6953 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
6955 if (pstrWFIDrv == NULL) {
6956 PRINT_ER("driver is null\n");
6960 memset(&msg, 0, sizeof(struct host_if_msg));
6962 /* prepare the WiphyParams Message */
6963 msg.id = HOST_IF_MSG_DEL_BA_SESSION;
6965 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
6966 pBASessionInfo->u8Ted = TID;
6967 msg.drvHandler = hWFIDrv;
6969 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6971 PRINT_ER("wilc_mq_send fail\n");
6973 down(&hWaitResponse);
6978 s32 host_int_del_All_Rx_BASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID)
6981 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6982 struct host_if_msg msg;
6983 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
6985 if (pstrWFIDrv == NULL) {
6986 PRINT_ER("driver is null\n");
6990 memset(&msg, 0, sizeof(struct host_if_msg));
6992 /* prepare the WiphyParams Message */
6993 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
6995 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
6996 pBASessionInfo->u8Ted = TID;
6997 msg.drvHandler = hWFIDrv;
6999 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
7001 PRINT_ER("wilc_mq_send fail\n");
7003 down(&hWaitResponse);
7009 * @brief host_int_setup_ipaddress
7010 * @details setup IP in firmware
7011 * @param[in] Handle to wifi driver
7012 * @return Error code.
7013 * @author Abdelrahman Sobhy
7016 s32 host_int_setup_ipaddress(tstrWILC_WFIDrv *hWFIDrv, u8 *u16ipadd, u8 idx)
7019 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7020 struct host_if_msg msg;
7022 /* TODO: Enable This feature on softap firmware */
7025 if (pstrWFIDrv == NULL) {
7026 PRINT_ER("driver is null\n");
7030 memset(&msg, 0, sizeof(struct host_if_msg));
7032 /* prepare the WiphyParams Message */
7033 msg.id = HOST_IF_MSG_SET_IPADDRESS;
7035 msg.body.ip_info.au8IPAddr = u16ipadd;
7036 msg.drvHandler = hWFIDrv;
7037 msg.body.ip_info.idx = idx;
7039 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
7041 PRINT_ER("wilc_mq_send fail\n");
7049 * @brief host_int_get_ipaddress
7050 * @details Get IP from firmware
7051 * @param[in] Handle to wifi driver
7052 * @return Error code.
7053 * @author Abdelrahman Sobhy
7056 s32 host_int_get_ipaddress(tstrWILC_WFIDrv *hWFIDrv, u8 *u16ipadd, u8 idx)
7059 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7060 struct host_if_msg msg;
7062 if (pstrWFIDrv == NULL) {
7063 PRINT_ER("driver is null\n");
7067 memset(&msg, 0, sizeof(struct host_if_msg));
7069 /* prepare the WiphyParams Message */
7070 msg.id = HOST_IF_MSG_GET_IPADDRESS;
7072 msg.body.ip_info.au8IPAddr = u16ipadd;
7073 msg.drvHandler = hWFIDrv;
7074 msg.body.ip_info.idx = idx;
7076 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
7078 PRINT_ER("wilc_mq_send fail\n");